@@ -131,7 +131,7 @@ def list_stores() -> list[dict[str, Any]]:
131131 Returns:
132132 List of store info dictionaries, each containing:
133133 - name: Store name
134- - docs_dir: Path to documents directory
134+ - docs_dirs: List of paths to documents directories
135135 - last_indexed: ISO timestamp of last indexing, or None
136136 - chunk_count: Number of indexed chunks
137137 """
@@ -153,9 +153,16 @@ def list_stores() -> list[dict[str, Any]]:
153153 with open (store_config_path , "r" , encoding = "utf-8" ) as f :
154154 store_data = json .load (f )
155155
156+ # Handle both old (docs_dir) and new (docs_dirs) formats
157+ docs_dirs = store_data .get ("docs_dirs" )
158+ if docs_dirs is None :
159+ # Backwards compatibility: convert single docs_dir to list
160+ old_docs_dir = store_data .get ("docs_dir" )
161+ docs_dirs = [old_docs_dir ] if old_docs_dir else []
162+
156163 stores .append ({
157164 "name" : store_data .get ("name" , store_dir .name ),
158- "docs_dir " : store_data . get ( "docs_dir" ) ,
165+ "docs_dirs " : docs_dirs ,
159166 "last_indexed" : store_data .get ("last_indexed" ),
160167 "chunk_count" : store_data .get ("chunk_count" , 0 ),
161168 })
@@ -174,6 +181,7 @@ def get_store(name: str) -> dict[str, Any] | None:
174181
175182 Returns:
176183 Store configuration dictionary, or None if store doesn't exist.
184+ Always returns docs_dirs as a list (converts legacy docs_dir if needed).
177185 """
178186 _validate_store_name (name )
179187 store_config_path = _get_store_dir (name ) / STORE_CONFIG_FILE
@@ -184,22 +192,27 @@ def get_store(name: str) -> dict[str, Any] | None:
184192 try :
185193 with open (store_config_path , "r" , encoding = "utf-8" ) as f :
186194 result : dict [str , Any ] = json .load (f )
187- return result
195+
196+ # Handle backwards compatibility: convert docs_dir to docs_dirs
197+ if "docs_dirs" not in result and "docs_dir" in result :
198+ result ["docs_dirs" ] = [result ["docs_dir" ]]
199+
200+ return result
188201 except (json .JSONDecodeError , OSError ) as e :
189202 console .print (f"[yellow]Warning: Could not read store config: { e } [/yellow]" )
190203 return None
191204
192205
193206def create_store (
194207 name : str ,
195- docs_dir : Path ,
208+ docs_dirs : list [ Path ] ,
196209 chat_model : str | None = None ,
197210) -> dict [str , Any ]:
198211 """Create a new document store.
199212
200213 Args:
201214 name: Unique name for the store.
202- docs_dir: Path to the documents directory .
215+ docs_dirs: List of paths to documents directories .
203216 chat_model: Optional chat model override for this store.
204217
205218 Returns:
@@ -214,9 +227,12 @@ def create_store(
214227 if store_dir .exists ():
215228 raise ValueError (f"Store '{ name } ' already exists." )
216229
217- # Convert to absolute path if relative
218- if not docs_dir .is_absolute ():
219- docs_dir = docs_dir .resolve ()
230+ # Convert to absolute paths if relative
231+ resolved_dirs = []
232+ for docs_dir in docs_dirs :
233+ if not docs_dir .is_absolute ():
234+ docs_dir = docs_dir .resolve ()
235+ resolved_dirs .append (str (docs_dir ))
220236
221237 # Create store directory structure
222238 store_dir .mkdir (parents = True , exist_ok = True )
@@ -226,7 +242,7 @@ def create_store(
226242 # Create store configuration
227243 store_config = {
228244 "name" : name ,
229- "docs_dir " : str ( docs_dir ) ,
245+ "docs_dirs " : resolved_dirs ,
230246 "created" : datetime .now (timezone .utc ).isoformat (),
231247 "last_indexed" : None ,
232248 "chunk_count" : 0 ,
@@ -266,12 +282,15 @@ def update_store(name: str, **kwargs: Any) -> dict[str, Any]:
266282
267283 # Update fields
268284 for key , value in kwargs .items ():
269- if key == "docs_dir" and value is not None :
270- # Ensure docs_dir is stored as absolute path string
271- path = Path (value )
272- if not path .is_absolute ():
273- path = path .resolve ()
274- store_config [key ] = str (path )
285+ if key == "docs_dirs" and value is not None :
286+ # Ensure docs_dirs are stored as absolute path strings
287+ resolved = []
288+ for p in value :
289+ path = Path (p ) if isinstance (p , str ) else p
290+ if not path .is_absolute ():
291+ path = path .resolve ()
292+ resolved .append (str (path ))
293+ store_config [key ] = resolved
275294 else :
276295 store_config [key ] = value
277296
0 commit comments