agent-space-manager 1.0.1 → 1.0.3
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.
- package/CHANGELOG.md +29 -1
- package/README.md +1 -1
- package/README.zh-CN.md +2 -2
- package/index.mjs +1 -0
- package/manager.mjs +196 -20
- package/package.json +1 -1
- package/page/app.js +95 -81
- package/page/index.html +2 -2
- package/smart-tools.middleware.js +285 -19
package/page/app.js
CHANGED
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
const match = files.find((f) => {
|
|
69
69
|
const r = (f.relPath || f.name || "").toLowerCase();
|
|
70
70
|
return r === `skills/${skillName.toLowerCase()}/skill.md` ||
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
r.includes(`skills/${skillName.toLowerCase()}/`) ||
|
|
72
|
+
r.endsWith(`/${skillName.toLowerCase()}/skill.md`);
|
|
73
73
|
});
|
|
74
74
|
if (match) seenFiles.add(match.relPath || match.name);
|
|
75
75
|
items.push({
|
|
@@ -195,10 +195,10 @@
|
|
|
195
195
|
|
|
196
196
|
function getMagpieApi() {
|
|
197
197
|
return globalThis.magpie?.api?.agentSpaceManager ||
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
globalThis.magpie?.api?.["agent-space-manager"] ||
|
|
199
|
+
globalThis.magpie?.api?.smartMiddleware ||
|
|
200
|
+
globalThis.magpie?.api?.["smart-middleware"] ||
|
|
201
|
+
globalThis.magpie?.api;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// Non-blocking toast notifications (Desktop WebView2 Dialog Safety Invariant)
|
|
@@ -309,11 +309,11 @@
|
|
|
309
309
|
mPlugins.forEach(ensurePluginFiles);
|
|
310
310
|
try {
|
|
311
311
|
localStorage.setItem("magpie_plugins_" + norm, JSON.stringify(mPlugins));
|
|
312
|
-
} catch {}
|
|
312
|
+
} catch { }
|
|
313
313
|
return mPlugins;
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
} catch {}
|
|
316
|
+
} catch { }
|
|
317
317
|
|
|
318
318
|
// 2. Local API server dynamically with cache-busting timestamp (when running outside CSP connect-src 'none')
|
|
319
319
|
try {
|
|
@@ -324,14 +324,14 @@
|
|
|
324
324
|
data.plugins.forEach(ensurePluginFiles);
|
|
325
325
|
try {
|
|
326
326
|
localStorage.setItem("magpie_plugins_" + norm, JSON.stringify(data.plugins));
|
|
327
|
-
} catch {}
|
|
327
|
+
} catch { }
|
|
328
328
|
if (data.categories) {
|
|
329
329
|
discoveredCategories = data.categories;
|
|
330
330
|
}
|
|
331
331
|
return data.plugins;
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
-
} catch {}
|
|
334
|
+
} catch { }
|
|
335
335
|
|
|
336
336
|
// 3. Dynamically reload plugins-cache.js via <script> tag (allowed by Magpie iframe CSP script-src 'self'!)
|
|
337
337
|
const currentCacheNorm = normalizePathForCompare(globalThis.__PLUGINS_CACHE__?.path);
|
|
@@ -345,7 +345,7 @@
|
|
|
345
345
|
cached.forEach(ensurePluginFiles);
|
|
346
346
|
try {
|
|
347
347
|
localStorage.setItem("magpie_plugins_" + norm, JSON.stringify(cached));
|
|
348
|
-
} catch {}
|
|
348
|
+
} catch { }
|
|
349
349
|
if (globalThis.__PLUGINS_CACHE__.categories) {
|
|
350
350
|
discoveredCategories = globalThis.__PLUGINS_CACHE__.categories;
|
|
351
351
|
}
|
|
@@ -365,7 +365,7 @@
|
|
|
365
365
|
return cData.plugins;
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
} catch {}
|
|
368
|
+
} catch { }
|
|
369
369
|
|
|
370
370
|
// 6. LocalStorage cached plugins strictly for this exact path
|
|
371
371
|
try {
|
|
@@ -377,7 +377,7 @@
|
|
|
377
377
|
return parsed;
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
} catch {}
|
|
380
|
+
} catch { }
|
|
381
381
|
|
|
382
382
|
return [];
|
|
383
383
|
},
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
const res = await magpieApi.saveConfig(config, options);
|
|
390
390
|
if (res) return res;
|
|
391
391
|
}
|
|
392
|
-
} catch {}
|
|
392
|
+
} catch { }
|
|
393
393
|
try {
|
|
394
394
|
const payload = { config, ...options };
|
|
395
395
|
const res = await fetch(`${API_BASE}/api/save`, {
|
|
@@ -418,7 +418,7 @@
|
|
|
418
418
|
signal: AbortSignal.timeout(5000),
|
|
419
419
|
});
|
|
420
420
|
if (res.ok) return await res.json();
|
|
421
|
-
} catch {}
|
|
421
|
+
} catch { }
|
|
422
422
|
return null;
|
|
423
423
|
},
|
|
424
424
|
|
|
@@ -435,7 +435,7 @@
|
|
|
435
435
|
signal: AbortSignal.timeout(5000),
|
|
436
436
|
});
|
|
437
437
|
if (res.ok) return await res.json();
|
|
438
|
-
} catch {}
|
|
438
|
+
} catch { }
|
|
439
439
|
return null;
|
|
440
440
|
},
|
|
441
441
|
|
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
const res = await magpieApi.resolveDroppedTarget(raw, mode);
|
|
447
447
|
if (res) return res;
|
|
448
448
|
}
|
|
449
|
-
} catch {}
|
|
449
|
+
} catch { }
|
|
450
450
|
try {
|
|
451
451
|
const res = await fetch(`${API_BASE}/api/resolve?path=${encodeURIComponent(raw || "")}&mode=${encodeURIComponent(mode || "ide")}`, { signal: AbortSignal.timeout(10000) });
|
|
452
452
|
if (res.ok) return await res.json();
|
|
@@ -463,7 +463,7 @@
|
|
|
463
463
|
const res = await magpieApi.browseFileSystem(type);
|
|
464
464
|
if (res) return res;
|
|
465
465
|
}
|
|
466
|
-
} catch {}
|
|
466
|
+
} catch { }
|
|
467
467
|
try {
|
|
468
468
|
const res = await fetch(`${API_BASE}/api/browse?type=${encodeURIComponent(type || "file")}`, { signal: AbortSignal.timeout(90000) });
|
|
469
469
|
if (res.ok) return await res.json();
|
|
@@ -480,14 +480,14 @@
|
|
|
480
480
|
const detected = await magpieApi.detectConfigPath(name, exePath);
|
|
481
481
|
if (detected) return detected;
|
|
482
482
|
}
|
|
483
|
-
} catch {}
|
|
483
|
+
} catch { }
|
|
484
484
|
try {
|
|
485
485
|
const res = await fetch(`${API_BASE}/api/detect-config?name=${encodeURIComponent(name || "")}&exePath=${encodeURIComponent(exePath || "")}`, { signal: AbortSignal.timeout(2000) });
|
|
486
486
|
if (res.ok) {
|
|
487
487
|
const data = await res.json();
|
|
488
488
|
return data.configPath;
|
|
489
489
|
}
|
|
490
|
-
} catch {}
|
|
490
|
+
} catch { }
|
|
491
491
|
return null;
|
|
492
492
|
},
|
|
493
493
|
|
|
@@ -498,11 +498,11 @@
|
|
|
498
498
|
const cfg = await magpieApi.getConfig();
|
|
499
499
|
if (cfg && Array.isArray(cfg.ides)) return cfg;
|
|
500
500
|
}
|
|
501
|
-
} catch {}
|
|
501
|
+
} catch { }
|
|
502
502
|
try {
|
|
503
503
|
const res = await fetch(`${API_BASE}/api/config`, { signal: AbortSignal.timeout(2000) });
|
|
504
504
|
if (res.ok) return await res.json();
|
|
505
|
-
} catch {}
|
|
505
|
+
} catch { }
|
|
506
506
|
return null;
|
|
507
507
|
},
|
|
508
508
|
|
|
@@ -513,14 +513,14 @@
|
|
|
513
513
|
const list = await magpieApi.getAgentProfiles();
|
|
514
514
|
if (Array.isArray(list) && list.length > 0) return list;
|
|
515
515
|
}
|
|
516
|
-
} catch {}
|
|
516
|
+
} catch { }
|
|
517
517
|
try {
|
|
518
518
|
const res = await fetch(`${API_BASE}/api/agents`, { signal: AbortSignal.timeout(2000) });
|
|
519
519
|
if (res.ok) {
|
|
520
520
|
const data = await res.json();
|
|
521
521
|
if (Array.isArray(data?.agents)) return data.agents;
|
|
522
522
|
}
|
|
523
|
-
} catch {}
|
|
523
|
+
} catch { }
|
|
524
524
|
return null;
|
|
525
525
|
},
|
|
526
526
|
|
|
@@ -531,11 +531,11 @@
|
|
|
531
531
|
const res = await magpieApi.checkModifications(customHubRoot);
|
|
532
532
|
if (res) return res;
|
|
533
533
|
}
|
|
534
|
-
} catch {}
|
|
534
|
+
} catch { }
|
|
535
535
|
try {
|
|
536
536
|
const res = await fetch(`${API_BASE}/api/check-modifications?path=${encodeURIComponent(customHubRoot || "")}&t=${Date.now()}`, { signal: AbortSignal.timeout(5000) });
|
|
537
537
|
if (res.ok) return await res.json();
|
|
538
|
-
} catch {}
|
|
538
|
+
} catch { }
|
|
539
539
|
return null;
|
|
540
540
|
},
|
|
541
541
|
|
|
@@ -546,7 +546,7 @@
|
|
|
546
546
|
const res = await magpieApi.startupSync(customConfig);
|
|
547
547
|
if (res) return res;
|
|
548
548
|
}
|
|
549
|
-
} catch {}
|
|
549
|
+
} catch { }
|
|
550
550
|
try {
|
|
551
551
|
const res = await fetch(`${API_BASE}/api/startup-sync`, {
|
|
552
552
|
method: "POST",
|
|
@@ -555,7 +555,7 @@
|
|
|
555
555
|
signal: AbortSignal.timeout(10000),
|
|
556
556
|
});
|
|
557
557
|
if (res.ok) return await res.json();
|
|
558
|
-
} catch {}
|
|
558
|
+
} catch { }
|
|
559
559
|
return null;
|
|
560
560
|
},
|
|
561
561
|
|
|
@@ -566,7 +566,7 @@
|
|
|
566
566
|
const res = await magpieApi.recheckStatus(customConfig);
|
|
567
567
|
if (res) return res;
|
|
568
568
|
}
|
|
569
|
-
} catch {}
|
|
569
|
+
} catch { }
|
|
570
570
|
try {
|
|
571
571
|
const res = await fetch(`${API_BASE}/api/recheck-status`, {
|
|
572
572
|
method: "POST",
|
|
@@ -575,7 +575,7 @@
|
|
|
575
575
|
signal: AbortSignal.timeout(8000),
|
|
576
576
|
});
|
|
577
577
|
if (res.ok) return await res.json();
|
|
578
|
-
} catch {}
|
|
578
|
+
} catch { }
|
|
579
579
|
return null;
|
|
580
580
|
},
|
|
581
581
|
|
|
@@ -587,7 +587,7 @@
|
|
|
587
587
|
const res = await magpieApi.connectAgent(target, options);
|
|
588
588
|
if (res) return res;
|
|
589
589
|
}
|
|
590
|
-
} catch {}
|
|
590
|
+
} catch { }
|
|
591
591
|
|
|
592
592
|
// Tier 2: Direct HTTP POST to local API server (if outside CSP connect-src 'none')
|
|
593
593
|
try {
|
|
@@ -629,7 +629,7 @@
|
|
|
629
629
|
if (scriptRes && scriptRes.success !== false) {
|
|
630
630
|
return scriptRes;
|
|
631
631
|
}
|
|
632
|
-
} catch {}
|
|
632
|
+
} catch { }
|
|
633
633
|
|
|
634
634
|
// Tier 4: Magpie options bridge with connect-status.js (allowed under script-src 'self')
|
|
635
635
|
try {
|
|
@@ -723,11 +723,11 @@
|
|
|
723
723
|
const res = await magpieApi.checkCentralizedUpdates(customHubRoot, { force });
|
|
724
724
|
if (res) return res;
|
|
725
725
|
}
|
|
726
|
-
} catch {}
|
|
726
|
+
} catch { }
|
|
727
727
|
try {
|
|
728
728
|
const res = await fetch(`${API_BASE}/api/central-update-check?path=${encodeURIComponent(customHubRoot || "")}&force=${force ? "true" : "false"}&t=${Date.now()}`, { signal: AbortSignal.timeout(5000) });
|
|
729
729
|
if (res.ok) return await res.json();
|
|
730
|
-
} catch {}
|
|
730
|
+
} catch { }
|
|
731
731
|
return null;
|
|
732
732
|
},
|
|
733
733
|
|
|
@@ -738,11 +738,11 @@
|
|
|
738
738
|
const res = await magpieApi.getCentralizedUpdateStatus(customHubRoot);
|
|
739
739
|
if (res) return res;
|
|
740
740
|
}
|
|
741
|
-
} catch {}
|
|
741
|
+
} catch { }
|
|
742
742
|
try {
|
|
743
743
|
const res = await fetch(`${API_BASE}/api/central-update-status?path=${encodeURIComponent(customHubRoot || "")}&t=${Date.now()}`, { signal: AbortSignal.timeout(3000) });
|
|
744
744
|
if (res.ok) return await res.json();
|
|
745
|
-
} catch {}
|
|
745
|
+
} catch { }
|
|
746
746
|
return null;
|
|
747
747
|
},
|
|
748
748
|
|
|
@@ -862,7 +862,7 @@
|
|
|
862
862
|
if (scriptStatus?.checkedAt && (Date.now() - scriptStatus.checkedAt < 12000)) {
|
|
863
863
|
return scriptStatus;
|
|
864
864
|
}
|
|
865
|
-
} catch {}
|
|
865
|
+
} catch { }
|
|
866
866
|
|
|
867
867
|
// 3. Magpie host IPC bridge
|
|
868
868
|
try {
|
|
@@ -871,14 +871,14 @@
|
|
|
871
871
|
const res = await magpieApi.getOmnirouteStatus(customPort);
|
|
872
872
|
if (res) return res;
|
|
873
873
|
}
|
|
874
|
-
} catch {}
|
|
874
|
+
} catch { }
|
|
875
875
|
|
|
876
876
|
// 4. Local API server endpoint
|
|
877
877
|
try {
|
|
878
878
|
const query = customPort ? `?port=${customPort}&t=${Date.now()}` : `?t=${Date.now()}`;
|
|
879
879
|
const res = await fetch(`${API_BASE}/api/omniroute/status${query}`, { signal: AbortSignal.timeout(2000) });
|
|
880
880
|
if (res.ok) return await res.json();
|
|
881
|
-
} catch {}
|
|
881
|
+
} catch { }
|
|
882
882
|
|
|
883
883
|
// 5. Sandboxed Magpie options watcher bridge
|
|
884
884
|
const viaOptions = await this.omnirouteViaOptions("status", customPort, 8000);
|
|
@@ -904,7 +904,7 @@
|
|
|
904
904
|
port: targetPort,
|
|
905
905
|
url: `http://localhost:${targetPort}`,
|
|
906
906
|
};
|
|
907
|
-
} catch {}
|
|
907
|
+
} catch { }
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
910
|
|
|
@@ -931,7 +931,7 @@
|
|
|
931
931
|
if (imgOk) {
|
|
932
932
|
return { installed: true, running: true, port: targetPort, url: `http://localhost:${targetPort}` };
|
|
933
933
|
}
|
|
934
|
-
} catch {}
|
|
934
|
+
} catch { }
|
|
935
935
|
|
|
936
936
|
// If omniroute-status.js has a recently verified state (< 15s), use it
|
|
937
937
|
if (globalThis.__OMNIROUTE_STATUS__?.checkedAt && (Date.now() - globalThis.__OMNIROUTE_STATUS__.checkedAt < 15000)) {
|
|
@@ -950,7 +950,7 @@
|
|
|
950
950
|
const res = await magpieApi.startOmniroute(targetPort);
|
|
951
951
|
if (res && typeof res === "object") return res;
|
|
952
952
|
}
|
|
953
|
-
} catch {}
|
|
953
|
+
} catch { }
|
|
954
954
|
|
|
955
955
|
// 2. Direct simple GET to API server (avoids CORS preflight)
|
|
956
956
|
try {
|
|
@@ -962,7 +962,7 @@
|
|
|
962
962
|
const json = await res.json();
|
|
963
963
|
if (json && (json.running || json.error)) return json;
|
|
964
964
|
}
|
|
965
|
-
} catch {}
|
|
965
|
+
} catch { }
|
|
966
966
|
|
|
967
967
|
// 3. Direct POST to API server
|
|
968
968
|
try {
|
|
@@ -976,7 +976,7 @@
|
|
|
976
976
|
const json = await res.json();
|
|
977
977
|
if (json && (json.running || json.error)) return json;
|
|
978
978
|
}
|
|
979
|
-
} catch {}
|
|
979
|
+
} catch { }
|
|
980
980
|
|
|
981
981
|
// 4. Dynamic script trigger (allowed under CSP script-src)
|
|
982
982
|
try {
|
|
@@ -1001,7 +1001,7 @@
|
|
|
1001
1001
|
document.head.appendChild(s);
|
|
1002
1002
|
});
|
|
1003
1003
|
if (scriptRes?.running) return scriptRes;
|
|
1004
|
-
} catch {}
|
|
1004
|
+
} catch { }
|
|
1005
1005
|
|
|
1006
1006
|
// 5. Sandboxed Magpie options watcher bridge
|
|
1007
1007
|
return await this.omnirouteViaOptions("start", targetPort, 28000);
|
|
@@ -1015,14 +1015,14 @@
|
|
|
1015
1015
|
const res = await magpieApi.stopOmniroute(targetPort);
|
|
1016
1016
|
if (res) return res;
|
|
1017
1017
|
}
|
|
1018
|
-
} catch {}
|
|
1018
|
+
} catch { }
|
|
1019
1019
|
try {
|
|
1020
1020
|
const res = await fetch(`${API_BASE}/api/omniroute/stop?port=${targetPort}&t=${Date.now()}`, {
|
|
1021
1021
|
method: "GET",
|
|
1022
1022
|
signal: AbortSignal.timeout(10000),
|
|
1023
1023
|
});
|
|
1024
1024
|
if (res.ok) return await res.json();
|
|
1025
|
-
} catch {}
|
|
1025
|
+
} catch { }
|
|
1026
1026
|
try {
|
|
1027
1027
|
const res = await fetch(`${API_BASE}/api/omniroute/stop`, {
|
|
1028
1028
|
method: "POST",
|
|
@@ -1032,7 +1032,7 @@
|
|
|
1032
1032
|
keepalive: true,
|
|
1033
1033
|
});
|
|
1034
1034
|
if (res.ok) return await res.json();
|
|
1035
|
-
} catch {}
|
|
1035
|
+
} catch { }
|
|
1036
1036
|
return await this.omnirouteViaOptions("stop", targetPort, 10000);
|
|
1037
1037
|
},
|
|
1038
1038
|
|
|
@@ -1046,7 +1046,7 @@
|
|
|
1046
1046
|
if (win) {
|
|
1047
1047
|
// Opened successfully in browser window
|
|
1048
1048
|
}
|
|
1049
|
-
} catch {}
|
|
1049
|
+
} catch { }
|
|
1050
1050
|
|
|
1051
1051
|
// 2. Direct fast call to local API server endpoint (GET query format avoids preflight)
|
|
1052
1052
|
try {
|
|
@@ -1055,7 +1055,7 @@
|
|
|
1055
1055
|
signal: AbortSignal.timeout(2000),
|
|
1056
1056
|
});
|
|
1057
1057
|
if (getRes.ok) return await getRes.json();
|
|
1058
|
-
} catch {}
|
|
1058
|
+
} catch { }
|
|
1059
1059
|
|
|
1060
1060
|
// 3. Wails v2 runtime Go shell open (standard in Magpie desktop host)
|
|
1061
1061
|
try {
|
|
@@ -1067,7 +1067,7 @@
|
|
|
1067
1067
|
window.wails.runtime.BrowserOpenURL(url);
|
|
1068
1068
|
return { success: true, url, method: "wails-runtime" };
|
|
1069
1069
|
}
|
|
1070
|
-
} catch {}
|
|
1070
|
+
} catch { }
|
|
1071
1071
|
|
|
1072
1072
|
// 4. Magpie host IPC bridge shell open
|
|
1073
1073
|
try {
|
|
@@ -1089,7 +1089,7 @@
|
|
|
1089
1089
|
magpie.openUrl(url);
|
|
1090
1090
|
return { success: true, url, method: "magpie-openUrl" };
|
|
1091
1091
|
}
|
|
1092
|
-
} catch {}
|
|
1092
|
+
} catch { }
|
|
1093
1093
|
|
|
1094
1094
|
// 5. Local API server POST
|
|
1095
1095
|
try {
|
|
@@ -1100,7 +1100,7 @@
|
|
|
1100
1100
|
signal: AbortSignal.timeout(3000),
|
|
1101
1101
|
});
|
|
1102
1102
|
if (res.ok) return await res.json();
|
|
1103
|
-
} catch {}
|
|
1103
|
+
} catch { }
|
|
1104
1104
|
|
|
1105
1105
|
// 6. Sandboxed Magpie frame: the plugin backend opens the OS default browser
|
|
1106
1106
|
try {
|
|
@@ -1108,7 +1108,7 @@
|
|
|
1108
1108
|
if (viaOptions && (viaOptions.opened || viaOptions.action === "open")) {
|
|
1109
1109
|
return { ...viaOptions, success: true, url };
|
|
1110
1110
|
}
|
|
1111
|
-
} catch {}
|
|
1111
|
+
} catch { }
|
|
1112
1112
|
|
|
1113
1113
|
return { success: true, url, method: "fallback" };
|
|
1114
1114
|
},
|
|
@@ -1120,7 +1120,7 @@
|
|
|
1120
1120
|
const res = await magpieApi.scanForeignComponents(agent);
|
|
1121
1121
|
if (res) return res;
|
|
1122
1122
|
}
|
|
1123
|
-
} catch {}
|
|
1123
|
+
} catch { }
|
|
1124
1124
|
try {
|
|
1125
1125
|
const res = await fetch(`${API_BASE}/api/agent/scan-foreign`, {
|
|
1126
1126
|
method: "POST",
|
|
@@ -1129,7 +1129,7 @@
|
|
|
1129
1129
|
signal: AbortSignal.timeout(6000),
|
|
1130
1130
|
});
|
|
1131
1131
|
if (res.ok) return await res.json();
|
|
1132
|
-
} catch {}
|
|
1132
|
+
} catch { }
|
|
1133
1133
|
return null;
|
|
1134
1134
|
},
|
|
1135
1135
|
|
|
@@ -1140,7 +1140,7 @@
|
|
|
1140
1140
|
const res = await magpieApi.cleanForeignComponents(components);
|
|
1141
1141
|
if (res) return res;
|
|
1142
1142
|
}
|
|
1143
|
-
} catch {}
|
|
1143
|
+
} catch { }
|
|
1144
1144
|
try {
|
|
1145
1145
|
const res = await fetch(`${API_BASE}/api/agent/clean-foreign`, {
|
|
1146
1146
|
method: "POST",
|
|
@@ -1149,7 +1149,7 @@
|
|
|
1149
1149
|
signal: AbortSignal.timeout(6000),
|
|
1150
1150
|
});
|
|
1151
1151
|
if (res.ok) return await res.json();
|
|
1152
|
-
} catch {}
|
|
1152
|
+
} catch { }
|
|
1153
1153
|
return null;
|
|
1154
1154
|
},
|
|
1155
1155
|
};
|
|
@@ -1328,7 +1328,7 @@
|
|
|
1328
1328
|
const parsed = JSON.parse(local);
|
|
1329
1329
|
if (parsed?.ides) hubConfig = parsed;
|
|
1330
1330
|
}
|
|
1331
|
-
} catch {}
|
|
1331
|
+
} catch { }
|
|
1332
1332
|
|
|
1333
1333
|
// Ensure default Antigravity IDE is present ONLY on first run if ides was never configured
|
|
1334
1334
|
if (!Array.isArray(hubConfig.ides)) {
|
|
@@ -1351,7 +1351,7 @@
|
|
|
1351
1351
|
if (Array.isArray(liveProfiles) && liveProfiles.length > 0) {
|
|
1352
1352
|
agentProfiles = liveProfiles;
|
|
1353
1353
|
}
|
|
1354
|
-
} catch {}
|
|
1354
|
+
} catch { }
|
|
1355
1355
|
await reloadPluginsFromHub();
|
|
1356
1356
|
|
|
1357
1357
|
// 4b. On startup: check for modification difference in Components Storage Path and recheck status dots for each enabled plugin in each connected agent!
|
|
@@ -1952,8 +1952,8 @@
|
|
|
1952
1952
|
item.dataset.type = "ide";
|
|
1953
1953
|
|
|
1954
1954
|
const prof = agentProfiles.find((p) => p.id === ide.agentType) ||
|
|
1955
|
-
|
|
1956
|
-
|
|
1955
|
+
agentProfiles.find((p) => ide.id?.includes(p.id) || ide.name?.toLowerCase().includes(p.id)) ||
|
|
1956
|
+
agentProfiles[0];
|
|
1957
1957
|
const modeBadge = prof?.mode === "bundle"
|
|
1958
1958
|
? `<span style="font-size:9.5px; padding:1px 5px; border-radius:4px; background:rgba(16,185,129,0.15); color:#10b981; margin-left:6px;">Bundle</span>`
|
|
1959
1959
|
: `<span style="font-size:9.5px; padding:1px 5px; border-radius:4px; background:rgba(59,130,246,0.15); color:#3b82f6; margin-left:6px;">Native Adapter</span>`;
|
|
@@ -1963,7 +1963,8 @@
|
|
|
1963
1963
|
if (syncInfo?.summary) {
|
|
1964
1964
|
const s = syncInfo.summary;
|
|
1965
1965
|
if (syncInfo.mode === "bundle") {
|
|
1966
|
-
|
|
1966
|
+
const conflictSuffix = s.conflicts ? ` · <span style="color:#f59e0b;">${s.conflicts} conflicts</span>` : "";
|
|
1967
|
+
syncSubtitle = `<div style="font-size:10px; color:#10b981; margin-top:2px;">Synced: ${s.plugins || 0} plugin bundles${conflictSuffix}</div>`;
|
|
1967
1968
|
} else {
|
|
1968
1969
|
const parts = [];
|
|
1969
1970
|
if (s.skills !== undefined) parts.push(`${s.skills} skills`);
|
|
@@ -2838,7 +2839,7 @@
|
|
|
2838
2839
|
try {
|
|
2839
2840
|
const detected = await apiClient.detectConfigPath(nameOrAgentType, exePath);
|
|
2840
2841
|
if (detected) return detected;
|
|
2841
|
-
} catch {}
|
|
2842
|
+
} catch { }
|
|
2842
2843
|
|
|
2843
2844
|
const prof = agentProfiles.find((p) => p.id === nameOrAgentType || p.label.toLowerCase() === String(nameOrAgentType || "").toLowerCase());
|
|
2844
2845
|
if (prof && prof.defaultConfigPath) {
|
|
@@ -2926,7 +2927,7 @@
|
|
|
2926
2927
|
try {
|
|
2927
2928
|
await navigator.clipboard.writeText(text);
|
|
2928
2929
|
return true;
|
|
2929
|
-
} catch {}
|
|
2930
|
+
} catch { }
|
|
2930
2931
|
}
|
|
2931
2932
|
try {
|
|
2932
2933
|
const ta = document.createElement("textarea");
|
|
@@ -3121,7 +3122,7 @@
|
|
|
3121
3122
|
if ($("btnPickHubFolder")) {
|
|
3122
3123
|
$("btnPickHubFolder").addEventListener("click", async () => {
|
|
3123
3124
|
if (hubFolderPicker) {
|
|
3124
|
-
try { hubFolderPicker.click(); } catch (err) {}
|
|
3125
|
+
try { hubFolderPicker.click(); } catch (err) { }
|
|
3125
3126
|
}
|
|
3126
3127
|
try {
|
|
3127
3128
|
$("btnPickHubFolder").textContent = "Opening...";
|
|
@@ -3248,7 +3249,7 @@
|
|
|
3248
3249
|
}
|
|
3249
3250
|
|
|
3250
3251
|
// Standardize Storage Structure Prompt Copy Button (with version display)
|
|
3251
|
-
const STORAGE_PROMPT_VERSION = "V1.
|
|
3252
|
+
const STORAGE_PROMPT_VERSION = "V1.6";
|
|
3252
3253
|
const btnCopyPrompt = $("btnCopyStoragePrompt");
|
|
3253
3254
|
if (btnCopyPrompt) {
|
|
3254
3255
|
const originalText = `Copy Prompt (${STORAGE_PROMPT_VERSION})`;
|
|
@@ -3260,7 +3261,7 @@
|
|
|
3260
3261
|
|
|
3261
3262
|
const promptText = `[Components Storage Specification & Upstream Rules Prompt ${STORAGE_PROMPT_VERSION}]
|
|
3262
3263
|
|
|
3263
|
-
Please organize and force our Components Storage file structure to strictly adhere to the standard plugin specification, record mandatory upstream source links, eliminate decentralized component updaters, ensure complete plugin uninstallation cleanup, enforce UTF-8 without BOM encoding, respect one-time rearrangement stability, define universal shared folder specifications, and install a persistent agent rule:
|
|
3264
|
+
Please organize and force our Components Storage file structure to strictly adhere to the standard plugin specification, record mandatory upstream source links, eliminate decentralized component updaters, ensure complete plugin uninstallation cleanup, enforce UTF-8 without BOM encoding, respect one-time rearrangement stability, define universal shared folder specifications, maintain dynamic Smart Middleware intent rules, and install a persistent agent rule:
|
|
3264
3265
|
|
|
3265
3266
|
${targetPathHeader}1. Directory Structure Specification:
|
|
3266
3267
|
Components Storage root (e.g. \`<Components Storage Path>\`) contains plugins, optional standalone skills, hub configuration, and a shared cross-agent communication/data directory:
|
|
@@ -3283,19 +3284,24 @@ Components Storage root (e.g. \`<Components Storage Path>\`) contains plugins, o
|
|
|
3283
3284
|
│ ├── handoff/ # Cross-agent delegation and task handoff inboxes
|
|
3284
3285
|
│ │ └── <agent-id>/ # Target agent inbox queue
|
|
3285
3286
|
│ ├── _upstream_backups/ # Pre-update backups and component snapshots
|
|
3287
|
+
│ ├── middleware-intents.json # Dynamic user & agent Smart Middleware intent keyword registry
|
|
3286
3288
|
│ └── <shared-tool-dirs>/ # Shared runtime states, engines, caches, or browser automation; subfolders are named after their joining skills (e.g. stagehand-fastcrw joining stagehand and fastcrw, omniroute)
|
|
3287
3289
|
├── skills/ # Standalone or migrated skills
|
|
3288
3290
|
├── hub-config.json # Hub configuration
|
|
3289
3291
|
├── plugins.json # Discovered/registered plugins index
|
|
3290
3292
|
└── skills.json # Discovered/registered skills index
|
|
3291
3293
|
|
|
3292
|
-
Duplicate Naming
|
|
3294
|
+
Duplicate Naming, Skill Collision Avoidance & No Duplicate Standalone Rule:
|
|
3295
|
+
- Skill Name Collisions Across Plugins: To avoid skill name collision across plugins, if a skill with the same name exists in two or more different plugins (e.g. a skill called "plan" in 2 different plugins called A and B), name the skill in each plugin by prefixing it with its plugin name (e.g. name the skill "plan" in A as "A-plan", and in B as "B-plan") so each skill has a distinct identifier without namespace collisions.
|
|
3296
|
+
- Other Component Duplicate Collisions: If two or more other components (plugins, agents, rules, MCPs, or standalone skills) coincidentally have the same name, append \`-1\`, \`-2\`, etc. sequentially (e.g. \`<name>-1\`, \`<name>-2\`) so every component has a unique name without colliding or overwriting.
|
|
3297
|
+
- No Duplicate Standalone Copies: NEVER leave or create a standalone copy in \`<Components Storage Path>/skills/\`, \`rules/\`, \`agents/\`, or directly inside IDE native directories (e.g. \`~/.gemini/config/skills/\`, \`~/.gemini/config/rules/\`, \`~/.cursor/rules/\`, \`~/.claude/\`) when that component belongs to a plugin in \`plugins/<plugin-name>/\`. Whenever installing or migrating a plugin, check for existing standalone or unprefixed copies matching the same \`upstream\` URL or base name (e.g. \`trail-code-auto.md\` vs \`trailhq-trail-code-auto.md\`) and move or remove the standalone copy so only the plugin-scoped copy remains.
|
|
3293
3298
|
|
|
3294
3299
|
2. Shared Folder Specification (<Components Storage Path>/shared):
|
|
3295
3300
|
The shared directory serves as the centralized cross-agent IPC, discovery, and shared coordination layer across all supported AI coding agents (Antigravity, Cursor, Windsurf, Claude Code, OpenCode, VS Code Copilot, etc.):
|
|
3296
3301
|
- agent-connectors.json: Global discovery registry tracking connected agent profiles, capability flags, root config paths, and communication bridges.
|
|
3297
3302
|
- handoff/: Inter-agent handoff queues. Enables asynchronous task delegation and context packet transfers between agents across different IDEs.
|
|
3298
3303
|
- _upstream_backups/: Centralized safety backups created prior to weekly upstream component updates or synchronization runs.
|
|
3304
|
+
- middleware-intents.json: Dynamic intent keyword registry for Smart Middleware. Maps tool patterns (e.g. docker, database, git) to user intent keywords so Smart Middleware dynamically surfaces domain tools without exceeding LLM context limits.
|
|
3299
3305
|
- Shared Tooling & State Subfolder Naming: Shared runtime caches, browser automation tools, and routing engines accessible universally across all connected agents without redundant duplication. Any subfolder created in shared/ for collaborating skills MUST be named after the joining skills (e.g. \`stagehand-fastcrw\` representing the joint operation of \`stagehand\` and \`fastcrw\`).
|
|
3300
3306
|
- Invariant: Never treat the shared/ directory or its internal files as loose components, and never delete or clear user-managed handoffs or shared configs during plugin cleanup.
|
|
3301
3307
|
|
|
@@ -3316,7 +3322,8 @@ When the user asks to remove, delete, or uninstall a plugin:
|
|
|
3316
3322
|
* Associated rules in rules/ and any bridged rule files or managed rule sections.
|
|
3317
3323
|
* Associated MCP server definitions in mcp_config.json and their bridged entries.
|
|
3318
3324
|
* Associated hooks in hooks.json and their bridged hook entries.
|
|
3319
|
-
|
|
3325
|
+
* Associated Smart Middleware intent entries in <Components Storage Path>/shared/middleware-intents.json: trim and remove the plugin's registered intent keywords and tool patterns so no dead or stale intent entries remain for uninstalled tools.
|
|
3326
|
+
- Ensure no orphaned components, dangling junctions/symlinks, ghost configuration entries, or leftover intent keywords associated with the removed plugin remain.
|
|
3320
3327
|
|
|
3321
3328
|
5. Centralized Weekly Update Checking (No Decentralized Scripts):
|
|
3322
3329
|
- Remove and DO NOT create individual, local, or decentralized update scripts (such as update_checker.mjs or update_check_state.json) inside component folders.
|
|
@@ -3332,25 +3339,32 @@ When the user asks to remove, delete, or uninstall a plugin:
|
|
|
3332
3339
|
- If the rearrangement of the file structure in Components Storage Path has already been executed once using this prompt, STOP rearranging or moving existing directory/file structures on subsequent runs unless the user explicitly requests a rearrangement.
|
|
3333
3340
|
- Preserve already-organized components in their current locations to prevent directory churn and broken path references.
|
|
3334
3341
|
|
|
3335
|
-
8.
|
|
3342
|
+
8. Dynamic Smart Middleware Intent Lifecycle & Initial Run Seeding (shared/middleware-intents.json):
|
|
3343
|
+
- Initial Run Seeding: On the first initial run of this instruction prompt, or whenever <Components Storage Path>/shared/middleware-intents.json is missing or does not yet include all currently installed components, inspect all existing plugins in plugins/ (and their plugin.json, mcp_config.json, and skill definitions), identify their tool names and capabilities, and generate the initial shared/middleware-intents.json personal layer mapping each existing tool to relevant intent keywords and tool patterns.
|
|
3344
|
+
- Component Addendum: Whenever adding or installing new components with tools, register or update their intent keywords and tool patterns in <Components Storage Path>/shared/middleware-intents.json (e.g. {"<category>": {"toolPatterns": ["..."], "intentKeywords": ["..."]}}).
|
|
3345
|
+
- Component Removal & Trimming: Whenever removing or uninstalling any plugin/component, trim and delete its corresponding intent entries from shared/middleware-intents.json so no stale or orphaned tool mappings remain.
|
|
3346
|
+
- Rationale: Keeps the Smart Middleware dynamic, clean, and user-personalized while keeping the core middleware engine fully updatable from upstream origin.
|
|
3347
|
+
|
|
3348
|
+
9. Mandatory Persistent Agent Rule:
|
|
3336
3349
|
Install and persist a dedicated rule in your agent's rule system (e.g. .agents/rules/components-storage-upstream-rule.md or .cursor/rules/components-storage-upstream-rule.mdc) that is ALWAYS TRIGGERED whenever an addendum, creation, modification, edit, or removal of any component in the Components Storage Path (${storagePath || "Components Storage Path"}):
|
|
3337
3350
|
- Rule Trigger: Addendum, creation, edit, or removal of any component in Components Storage Path.
|
|
3338
|
-
- Rule Invariant 1: Ensure strict compliance with the plugin directory and shared/ directory structures above
|
|
3351
|
+
- Rule Invariant 1: Ensure strict compliance with the plugin directory and shared/ directory structures above; avoid skill name collisions across plugins by prefixing the skill with its plugin name (e.g. a skill called 'plan' in plugins A and B is named 'A-plan' and 'B-plan'), disambiguate any other coincidental duplicate component names by appending -1, -2, etc. sequentially, and never leave duplicate standalone copies in root skills/rules/agents or IDE native config directories when the component belongs to a plugin (remove or migrate any pre-existing standalone/unprefixed copy matching the same upstream URL or base name).
|
|
3339
3352
|
- Rule Invariant 2: Always add and preserve the upstream link in the component's manifest or frontmatter.
|
|
3340
|
-
- Rule Invariant 3: Complete removal cleanup — when removing a plugin, all components related to that plugin (skills, agents, rules, MCP servers, hooks) must
|
|
3353
|
+
- Rule Invariant 3: Complete removal cleanup — when removing a plugin, all components related to that plugin (skills, agents, rules, MCP servers, hooks) AND its entries in shared/middleware-intents.json must be cleanly removed and trimmed with no orphaned leftovers.
|
|
3341
3354
|
- Rule Invariant 4: Never introduce decentralized or component-level update scripts; all update checking is handled centrally by the Agent Space Manager plugin on Monday startup.
|
|
3342
3355
|
- Rule Invariant 5: Never write files with a UTF-8 BOM header; always enforce UTF-8 No BOM encoding.
|
|
3343
3356
|
- Rule Invariant 6: One-Time Rearrangement Stability — if file rearrangement was already performed once, never rearrange or move existing structure again on subsequent prompt runs unless explicitly requested by the user.
|
|
3344
|
-
- Rule Invariant 7: Universal Shared Directory Preservation & Naming — preserve <Components Storage Path>/shared (agent-connectors.json, handoff/, _upstream_backups
|
|
3357
|
+
- Rule Invariant 7: Universal Shared Directory Preservation & Naming — preserve <Components Storage Path>/shared (agent-connectors.json, handoff/, _upstream_backups/, middleware-intents.json) as the designated cross-agent communication and data hub; never treat it as an orphaned or removable plugin; any subfolders in shared/ must be named after their joining skills (e.g. stagehand-fastcrw joining stagehand and fastcrw).
|
|
3358
|
+
- Rule Invariant 8: Dynamic Smart Middleware Intent Lifecycle & Seeding — (a) on initial run, seed shared/middleware-intents.json based on all currently existing plugins and tools in Components Storage; (b) when adding new components with tools, register their intent keywords and tool patterns in shared/middleware-intents.json; (c) when removing components, trim and prune their intent entries from shared/middleware-intents.json so the personal layer remains trimmed and accurate.
|
|
3345
3359
|
|
|
3346
|
-
Please inspect ${storagePath || "Components Storage Path"}, clean up non-conforming or loose files, ensure all component manifests and frontmatters contain their upstream links, ensure all JSON files are valid UTF-8 without BOM, purge any decentralized update checking scripts, ensure removal rules cover all related components, preserve the shared/ cross-agent folder, respect one-time rearrangement stability if already arranged, and persist the rule into your agent's rules.`;
|
|
3360
|
+
Please inspect ${storagePath || "Components Storage Path"}, clean up non-conforming or loose files, ensure all component manifests and frontmatters contain their upstream links, ensure all JSON files are valid UTF-8 without BOM, purge any decentralized update checking scripts, ensure removal rules cover all related components and trim middleware intents, resolve skill name collisions across plugins by prefixing plugin names (e.g. A-plan, B-plan), preserve the shared/ cross-agent folder, seed or update tool intent keywords in shared/middleware-intents.json based on existing installed components, respect one-time rearrangement stability if already arranged, and persist the rule into your agent's rules.`;
|
|
3347
3361
|
|
|
3348
3362
|
let copied = false;
|
|
3349
3363
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
3350
3364
|
try {
|
|
3351
3365
|
await navigator.clipboard.writeText(promptText);
|
|
3352
3366
|
copied = true;
|
|
3353
|
-
} catch {}
|
|
3367
|
+
} catch { }
|
|
3354
3368
|
}
|
|
3355
3369
|
if (!copied) {
|
|
3356
3370
|
try {
|
|
@@ -3363,7 +3377,7 @@ Please inspect ${storagePath || "Components Storage Path"}, clean up non-conform
|
|
|
3363
3377
|
document.execCommand("copy");
|
|
3364
3378
|
document.body.removeChild(ta);
|
|
3365
3379
|
copied = true;
|
|
3366
|
-
} catch {}
|
|
3380
|
+
} catch { }
|
|
3367
3381
|
}
|
|
3368
3382
|
|
|
3369
3383
|
btnCopyPrompt.textContent = copied ? "Copied!" : "Copy Failed";
|
|
@@ -3516,7 +3530,7 @@ Please inspect ${storagePath || "Components Storage Path"}, clean up non-conform
|
|
|
3516
3530
|
if ($("btnBrowseIdeExe")) {
|
|
3517
3531
|
$("btnBrowseIdeExe").addEventListener("click", async () => {
|
|
3518
3532
|
if (ideExePicker) {
|
|
3519
|
-
try { ideExePicker.click(); } catch (err) {}
|
|
3533
|
+
try { ideExePicker.click(); } catch (err) { }
|
|
3520
3534
|
}
|
|
3521
3535
|
try {
|
|
3522
3536
|
$("btnBrowseIdeExe").textContent = "Opening...";
|
|
@@ -3583,7 +3597,7 @@ Please inspect ${storagePath || "Components Storage Path"}, clean up non-conform
|
|
|
3583
3597
|
if ($("btnBrowseProjectPath")) {
|
|
3584
3598
|
$("btnBrowseProjectPath").addEventListener("click", async () => {
|
|
3585
3599
|
if (projectFolderPicker) {
|
|
3586
|
-
try { projectFolderPicker.click(); } catch (err) {}
|
|
3600
|
+
try { projectFolderPicker.click(); } catch (err) { }
|
|
3587
3601
|
}
|
|
3588
3602
|
try {
|
|
3589
3603
|
$("btnBrowseProjectPath").textContent = "Opening...";
|
|
@@ -3923,7 +3937,7 @@ Please inspect ${storagePath || "Components Storage Path"}, clean up non-conform
|
|
|
3923
3937
|
const norm = normalizePathForCompare(effectivePath);
|
|
3924
3938
|
try {
|
|
3925
3939
|
localStorage.removeItem("magpie_plugins_" + norm);
|
|
3926
|
-
} catch {}
|
|
3940
|
+
} catch { }
|
|
3927
3941
|
|
|
3928
3942
|
await new Promise((r) => setTimeout(r, 200));
|
|
3929
3943
|
if (bar) bar.style.width = "40%";
|
|
@@ -4159,7 +4173,7 @@ Please inspect ${storagePath || "Components Storage Path"}, clean up non-conform
|
|
|
4159
4173
|
async function persistConfig(forceRescan = false, options = { connect: false, sync: false }) {
|
|
4160
4174
|
try {
|
|
4161
4175
|
localStorage.setItem("magpie_agent_space_config", JSON.stringify(hubConfig));
|
|
4162
|
-
} catch {}
|
|
4176
|
+
} catch { }
|
|
4163
4177
|
|
|
4164
4178
|
// 1. Try direct API server first (works in browser / unrestricted WebView)
|
|
4165
4179
|
const saveRes = await apiClient.saveConfig(hubConfig, options);
|