1414class Config :
1515 """Configuration constants for the documentation updater."""
1616 REPO_FOLDER = "./docs"
17- STATE_FILE = "docs_state.json"
1817 MAX_CHUNK_SIZE = 500
1918 BATCH_SIZE = 50
2019 DELETE_BATCH_SIZE = 20
@@ -28,6 +27,25 @@ class Config:
2827 # OpenAI Configuration
2928 OPENAI_API_KEY = os .getenv ("OPENAI_API_KEY" )
3029 OPENAI_EMBEDDING_MODEL = "text-embedding-3-small"
30+
31+ @classmethod
32+ def get_state_file (cls ) -> str :
33+ """Get environment-specific state file name."""
34+ project_id = cls .FIRESTORE_PROJECT_ID
35+ if not project_id :
36+ return "docs_state_dev.json" # fallback to dev state file
37+
38+ # Extract environment from project ID (assuming naming convention like dreamflow-docs-dev, dreamflow-docs-alpha, dreamflow-docs-prod)
39+ if "dev" in project_id .lower ():
40+ return "docs_state_dev.json"
41+ elif "alpha" in project_id .lower ():
42+ return "docs_state_alpha.json"
43+ elif "prod" in project_id .lower ():
44+ return "docs_state_prod.json"
45+ else :
46+ # Use project ID as suffix for other environments
47+ safe_project_id = project_id .replace ("-" , "_" ).replace ("." , "_" )
48+ return f"docs_state_{ safe_project_id } .json"
3149
3250
3351def get_file_hash (file_path : str ) -> Optional [str ]:
@@ -41,9 +59,10 @@ def get_file_hash(file_path: str) -> Optional[str]:
4159
4260def load_file_state () -> Dict [str , Dict [str , str ]]:
4361 """Load previous file states for change detection."""
44- if os .path .exists (Config .STATE_FILE ):
62+ state_file = Config .get_state_file ()
63+ if os .path .exists (state_file ):
4564 try :
46- with open (Config . STATE_FILE , 'r' ) as f :
65+ with open (state_file , 'r' ) as f :
4766 return json .load (f )
4867 except (json .JSONDecodeError , IOError ):
4968 return {}
@@ -52,13 +71,16 @@ def load_file_state() -> Dict[str, Dict[str, str]]:
5271
5372def save_file_state (state : Dict [str , Dict [str , str ]]) -> None :
5473 """Save current file states."""
55- with open (Config .STATE_FILE , 'w' ) as f :
74+ state_file = Config .get_state_file ()
75+ print (f"💾 Saving state to: { state_file } " )
76+ with open (state_file , 'w' ) as f :
5677 json .dump (state , f , indent = 2 )
5778
5879
5980def get_changed_files () -> Tuple [List [str ], List [str ], Dict [str , str ]]:
6081 """Detect which files have changed since last run."""
61- print ("🔍 Detecting changed files..." )
82+ state_file = Config .get_state_file ()
83+ print (f"🔍 Detecting changed files using state file: { state_file } " )
6284
6385 previous_state = load_file_state ()
6486 current_hashes = {}
0 commit comments