@aiyiran/myclaw 1.1.85 → 1.1.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2646,7 +2646,7 @@
2646
2646
  }, 3000);
2647
2647
  }
2648
2648
 
2649
- fetch(MYCLAW_API_BASE + '/api/sync-templates')
2649
+ fetch(MYCLAW_API_BASE + '/api/sync-templates?force=1')
2650
2650
  .then(function (r) { return r.json(); })
2651
2651
  .then(function (sync) {
2652
2652
  headSyncBtn.disabled = false;
package/index.js CHANGED
@@ -1891,8 +1891,18 @@ async function ensureConfig(customName) {
1891
1891
 
1892
1892
  function runSyncTemplates() {
1893
1893
  const http = require('http');
1894
+ const fs = require('fs');
1894
1895
  const apiPort = process.platform === 'linux' ? '8080' : '18800';
1895
1896
 
1897
+ // --force:删除本地 index,强制重新比对
1898
+ if (args.includes('--force')) {
1899
+ const localIndex = path.join(os.homedir(), '.openclaw', 'skills', 'yiran-playground-template-use', 'template-index.json');
1900
+ if (fs.existsSync(localIndex)) {
1901
+ fs.unlinkSync(localIndex);
1902
+ console.log(colors.yellow + '[muban] 已清除本地 index,强制重新检查' + colors.nc);
1903
+ }
1904
+ }
1905
+
1896
1906
  function apiGet(path, cb) {
1897
1907
  http.get('http://127.0.0.1:' + apiPort + path, (res) => {
1898
1908
  let data = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.85",
3
+ "version": "1.1.87",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -872,7 +872,7 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
872
872
  elif path == '/api/file':
873
873
  return self._handle_file(params)
874
874
  elif path == '/api/sync-templates':
875
- return self._handle_sync_templates()
875
+ return self._handle_sync_templates(params)
876
876
  elif path == '/api/sync-status':
877
877
  return self._handle_sync_status()
878
878
  else:
@@ -1264,11 +1264,16 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
1264
1264
  except Exception as e:
1265
1265
  self._send_json({"error": str(e)}, 500)
1266
1266
 
1267
- def _handle_sync_templates(self):
1268
- """GET /api/sync-templates
1267
+ def _handle_sync_templates(self, params=None):
1268
+ """GET /api/sync-templates[?force=1]
1269
1269
  快速比对 CDN index_updated_at 与本地,若一致立即返回 {changed: false}。
1270
1270
  若有变化,启动后台线程下载,立即返回 {changed: true, syncing: true}。
1271
+ force=1:删除本地 index,强制重新全量比对。
1271
1272
  """
1273
+ # force=1:清除本地 index 强制重新下载
1274
+ if params and params.get('force', [''])[0] == '1':
1275
+ if os.path.isfile(TEMPLATE_LOCAL_INDEX):
1276
+ os.remove(TEMPLATE_LOCAL_INDEX)
1272
1277
  # 快速拉取 CDN index(仅 JSON,通常 <1s)
1273
1278
  try:
1274
1279
  import ssl