kacapower commited on
Commit
dd04a48
·
verified ·
1 Parent(s): 14d4369

Upload sync.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. sync.py +17 -1
sync.py CHANGED
@@ -11,6 +11,7 @@ TOKEN = os.getenv("HF_TOKEN")
11
  # Core directories
12
  WORKSPACE_DIR = Path("/home/node/workspace")
13
  OPENCODE_DIR = Path("/home/node/.local/share/opencode") # Default Linux storage
 
14
  CACHE_DIR = Path("/home/node/.sync_cache")
15
  INTERVAL = 30 * 60 # 30 minutes in seconds
16
 
@@ -36,6 +37,11 @@ def initial_pull():
36
  if ds_opencode.exists():
37
  shutil.copytree(ds_opencode, OPENCODE_DIR, dirs_exist_ok=True)
38
 
 
 
 
 
 
39
  # Create an initial cache to track future deletions
40
  shutil.copytree(OPENCODE_DIR, CACHE_DIR, dirs_exist_ok=True)
41
  print("Restoration complete.")
@@ -86,7 +92,17 @@ def push_to_dataset():
86
  token=TOKEN
87
  )
88
 
89
- # 3. Rebuild local deletion cache
 
 
 
 
 
 
 
 
 
 
90
  if CACHE_DIR.exists():
91
  shutil.rmtree(CACHE_DIR)
92
  shutil.copytree(OPENCODE_DIR, CACHE_DIR, dirs_exist_ok=True)
 
11
  # Core directories
12
  WORKSPACE_DIR = Path("/home/node/workspace")
13
  OPENCODE_DIR = Path("/home/node/.local/share/opencode") # Default Linux storage
14
+ GLOBAL_CONFIG_DIR = Path("/home/node/.config/opencode") # Global AGENTS.md + skills
15
  CACHE_DIR = Path("/home/node/.sync_cache")
16
  INTERVAL = 30 * 60 # 30 minutes in seconds
17
 
 
37
  if ds_opencode.exists():
38
  shutil.copytree(ds_opencode, OPENCODE_DIR, dirs_exist_ok=True)
39
 
40
+ # Restore global config (AGENTS.md and skills)
41
+ ds_global = Path(local_dir) / "global"
42
+ if ds_global.exists():
43
+ shutil.copytree(ds_global, GLOBAL_CONFIG_DIR, dirs_exist_ok=True)
44
+
45
  # Create an initial cache to track future deletions
46
  shutil.copytree(OPENCODE_DIR, CACHE_DIR, dirs_exist_ok=True)
47
  print("Restoration complete.")
 
92
  token=TOKEN
93
  )
94
 
95
+ # 3. Sync global config (AGENTS.md and skills)
96
+ api.upload_folder(
97
+ folder_path=str(GLOBAL_CONFIG_DIR),
98
+ path_in_repo="global",
99
+ repo_id=REPO_ID,
100
+ repo_type="dataset",
101
+ token=TOKEN,
102
+ ignore_patterns=["node_modules", "**/node_modules/*", "*.log"]
103
+ )
104
+
105
+ # 4. Rebuild local deletion cache
106
  if CACHE_DIR.exists():
107
  shutil.rmtree(CACHE_DIR)
108
  shutil.copytree(OPENCODE_DIR, CACHE_DIR, dirs_exist_ok=True)