harnesstap 1.4.0 → 1.6.0
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/README.md +2 -0
- package/dist/apply-FTAIL3X3.js +50 -0
- package/dist/{approve-FBGYQGWN.js → approve-R6AWQB3I.js} +10 -13
- package/dist/{approve-FBGYQGWN.js.map → approve-R6AWQB3I.js.map} +1 -1
- package/dist/{audit-VI4QZ6X2.js → audit-2HNKFPSU.js} +11 -15
- package/dist/{audit-VI4QZ6X2.js.map → audit-2HNKFPSU.js.map} +1 -1
- package/dist/{auth-4CQCDS2W.js → auth-C54KRLNF.js} +10 -12
- package/dist/{auth-4CQCDS2W.js.map → auth-C54KRLNF.js.map} +1 -1
- package/dist/bin.js +13 -34
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-IE7B6Q5K.js → chunk-2XDYQXP2.js} +17 -18
- package/dist/chunk-2XDYQXP2.js.map +1 -0
- package/dist/{chunk-L6YZE5MY.js → chunk-3277RVZT.js} +5 -7
- package/dist/{chunk-L6YZE5MY.js.map → chunk-3277RVZT.js.map} +1 -1
- package/dist/{chunk-QA5U36JN.js → chunk-3Q72LZPJ.js} +764 -340
- package/dist/chunk-3Q72LZPJ.js.map +1 -0
- package/dist/{chunk-OML4HXKT.js → chunk-42E2MPES.js} +16 -22
- package/dist/chunk-42E2MPES.js.map +1 -0
- package/dist/{chunk-4ZQ2SCGY.js → chunk-5HACBPK2.js} +509 -207
- package/dist/chunk-5HACBPK2.js.map +1 -0
- package/dist/{chunk-GRASK6M6.js → chunk-6FXJIKEG.js} +5 -5
- package/dist/{chunk-73OJQTBW.js → chunk-A3TZT4WT.js} +2 -2
- package/dist/{chunk-ZUASVASP.js → chunk-BUA7WFI4.js} +27034 -18024
- package/dist/chunk-BUA7WFI4.js.map +1 -0
- package/dist/{chunk-U6DXASQP.js → chunk-CBSDMRMY.js} +2 -2
- package/dist/{chunk-RDG5DT7S.js → chunk-CR2TYMKC.js} +54 -40
- package/dist/chunk-CR2TYMKC.js.map +1 -0
- package/dist/{chunk-REHRUNBB.js → chunk-CWXCZBJR.js} +70 -5
- package/dist/chunk-CWXCZBJR.js.map +1 -0
- package/dist/{chunk-R7ZOYVN3.js → chunk-D7R577XZ.js} +187 -59
- package/dist/chunk-D7R577XZ.js.map +1 -0
- package/dist/{chunk-P2C7JPLD.js → chunk-EPXAOEBB.js} +6 -6
- package/dist/{chunk-D432JAXV.js → chunk-GZU4LVFF.js} +153 -25
- package/dist/chunk-GZU4LVFF.js.map +1 -0
- package/dist/chunk-HV3ENT2F.js +61 -0
- package/dist/chunk-HV3ENT2F.js.map +1 -0
- package/dist/{chunk-3P6BWL5F.js → chunk-K4UDZUJ2.js} +2 -2
- package/dist/{chunk-ULCD6DJE.js → chunk-L6BJCRBU.js} +14 -39
- package/dist/chunk-L6BJCRBU.js.map +1 -0
- package/dist/{chunk-M4KLHJ6U.js → chunk-M6FEDSHY.js} +8 -10
- package/dist/{chunk-M4KLHJ6U.js.map → chunk-M6FEDSHY.js.map} +1 -1
- package/dist/chunk-M7PHQ3UC.js +31491 -0
- package/dist/chunk-M7PHQ3UC.js.map +1 -0
- package/dist/{chunk-PNGF5EV2.js → chunk-MHLAIGIM.js} +2 -2
- package/dist/{chunk-BPWFQKI5.js → chunk-MHMFF6A5.js} +2 -2
- package/dist/chunk-MKLJBW5N.js +14 -0
- package/dist/{chunk-MR7IOHSX.js → chunk-MQCAPCAF.js} +16 -22
- package/dist/{chunk-MR7IOHSX.js.map → chunk-MQCAPCAF.js.map} +1 -1
- package/dist/{chunk-N3VGY3T3.js → chunk-MQCH3YZ5.js} +7 -5
- package/dist/{chunk-N3VGY3T3.js.map → chunk-MQCH3YZ5.js.map} +1 -1
- package/dist/{chunk-WG5A6EAU.js → chunk-OHZNDV4A.js} +821 -28
- package/dist/chunk-OHZNDV4A.js.map +1 -0
- package/dist/{chunk-WGP4GUYZ.js → chunk-OWE3OSX6.js} +9 -11
- package/dist/{chunk-WGP4GUYZ.js.map → chunk-OWE3OSX6.js.map} +1 -1
- package/dist/{chunk-RVEXPMM3.js → chunk-PCNHBMBU.js} +3 -5
- package/dist/{chunk-RVEXPMM3.js.map → chunk-PCNHBMBU.js.map} +1 -1
- package/dist/{chunk-23XSG7LI.js → chunk-QGTDQNVV.js} +4 -4
- package/dist/{chunk-UVVZHWD2.js → chunk-R27VZIF6.js} +2 -2
- package/dist/{chunk-TQ2NA4Z4.js → chunk-R4NV3Q7G.js} +8 -2
- package/dist/chunk-R4NV3Q7G.js.map +1 -0
- package/dist/{chunk-EOPFER6N.js → chunk-R6VFJKZB.js} +19 -5
- package/dist/chunk-R6VFJKZB.js.map +1 -0
- package/dist/{chunk-3FS775NP.js → chunk-RQLVXJH2.js} +85 -4
- package/dist/chunk-RQLVXJH2.js.map +1 -0
- package/dist/{chunk-JQOKQKQT.js → chunk-S2D5PWAO.js} +2 -2
- package/dist/{chunk-43BDGVN3.js → chunk-T4EKNX2Q.js} +56 -9
- package/dist/chunk-T4EKNX2Q.js.map +1 -0
- package/dist/{chunk-XTVGCVU4.js → chunk-TERYL7JH.js} +36 -37
- package/dist/chunk-TERYL7JH.js.map +1 -0
- package/dist/{chunk-6LTLYV5D.js → chunk-UC27MQ3T.js} +1064 -265
- package/dist/chunk-UC27MQ3T.js.map +1 -0
- package/dist/chunk-UEA4NCY2.js +106 -0
- package/dist/chunk-UEA4NCY2.js.map +1 -0
- package/dist/{chunk-7HP6AAI3.js → chunk-UK2IV2ZQ.js} +2 -2
- package/dist/{chunk-PCMON7Y2.js → chunk-UZCAYOIQ.js} +8 -10
- package/dist/{chunk-PCMON7Y2.js.map → chunk-UZCAYOIQ.js.map} +1 -1
- package/dist/{chunk-N3ZCH64F.js → chunk-V4UNYSZO.js} +86 -32
- package/dist/chunk-V4UNYSZO.js.map +1 -0
- package/dist/chunk-VAPCU2FX.js +70 -0
- package/dist/chunk-VAPCU2FX.js.map +1 -0
- package/dist/{chunk-RFQ3N7FB.js → chunk-WGVU3LA5.js} +11 -9
- package/dist/chunk-WGVU3LA5.js.map +1 -0
- package/dist/{chunk-IMROMZ2K.js → chunk-WQ3F4O7U.js} +19 -14
- package/dist/chunk-WQ3F4O7U.js.map +1 -0
- package/dist/chunk-XNS4I3W6.js +102 -0
- package/dist/chunk-XNS4I3W6.js.map +1 -0
- package/dist/{chunk-2A36HWDE.js → chunk-Y4I7ZCAE.js} +129 -136
- package/dist/chunk-Y4I7ZCAE.js.map +1 -0
- package/dist/{chunk-TPEJFLV7.js → chunk-ZKMSHLXP.js} +4 -6
- package/dist/{chunk-TPEJFLV7.js.map → chunk-ZKMSHLXP.js.map} +1 -1
- package/dist/{compile-GXADKGH5.js → compile-B2QG6BAQ.js} +33 -37
- package/dist/{compile-GXADKGH5.js.map → compile-B2QG6BAQ.js.map} +1 -1
- package/dist/{config-JMHNA2U5.js → config-D3F6ICZ2.js} +16 -21
- package/dist/{config-JMHNA2U5.js.map → config-D3F6ICZ2.js.map} +1 -1
- package/dist/{cursor-local-install-46RWRBDT.js → cursor-local-install-4HDIBX22.js} +8 -12
- package/dist/{cursor-local-install-46RWRBDT.js.map → cursor-local-install-4HDIBX22.js.map} +1 -1
- package/dist/cursor-local-install-LL367GZY.js +94 -0
- package/dist/cursor-local-install-LL367GZY.js.map +1 -0
- package/dist/{doctor-N7ZULPOL.js → doctor-QSGETVDE.js} +14 -17
- package/dist/doctor-QSGETVDE.js.map +1 -0
- package/dist/{environment-OBB3WU5B.js → environment-2JS4RWQA.js} +42 -50
- package/dist/environment-2JS4RWQA.js.map +1 -0
- package/dist/{github-PBYBGOLH.js → github-JXSTHLY2.js} +9 -10
- package/dist/{github-PBYBGOLH.js.map → github-JXSTHLY2.js.map} +1 -1
- package/dist/{harness-7KYATIV6.js → harness-GBI3AMLH.js} +25 -31
- package/dist/{harness-7KYATIV6.js.map → harness-GBI3AMLH.js.map} +1 -1
- package/dist/{help-EE3AJQD4.js → help-EC52ERIE.js} +15 -20
- package/dist/{help-EE3AJQD4.js.map → help-EC52ERIE.js.map} +1 -1
- package/dist/{help-VXWKLQ6A.js → help-VIRMBOPJ.js} +57 -575
- package/dist/help-VIRMBOPJ.js.map +1 -0
- package/dist/host-plugin-view-kept-XKHD6NGU.js +139 -0
- package/dist/host-plugin-view-kept-XKHD6NGU.js.map +1 -0
- package/dist/index.js +12 -16
- package/dist/{init-LBTMPDVJ.js → init-OK3K6ILG.js} +33 -41
- package/dist/{init-LBTMPDVJ.js.map → init-OK3K6ILG.js.map} +1 -1
- package/dist/live-read-cache-ESQQJBNS.js +13 -0
- package/dist/live-read-cache-WPUFHVMZ.js +12 -0
- package/dist/{lock-WLJRXRVK.js → lock-AA2F4I3K.js} +9 -12
- package/dist/{lock-WLJRXRVK.js.map → lock-AA2F4I3K.js.map} +1 -1
- package/dist/{marketplace-GXSV6QIY.js → marketplace-QUYCV23F.js} +26 -79
- package/dist/marketplace-QUYCV23F.js.map +1 -0
- package/dist/{mcp-XPDWWU75.js → mcp-CIHSR4DD.js} +33 -37
- package/dist/{mcp-XPDWWU75.js.map → mcp-CIHSR4DD.js.map} +1 -1
- package/dist/{migrate-SBUIWN3U.js → migrate-TQPEZYS5.js} +93 -34
- package/dist/migrate-TQPEZYS5.js.map +1 -0
- package/dist/notifications-TAELTPDW.js +154 -0
- package/dist/notifications-TAELTPDW.js.map +1 -0
- package/dist/open-D3GWGDSQ.js +20 -0
- package/dist/{pack-A73LDVOX.js → pack-VUO4UBWL.js} +10 -14
- package/dist/{pack-A73LDVOX.js.map → pack-VUO4UBWL.js.map} +1 -1
- package/dist/plugin-L3466DHK.js +47 -0
- package/dist/plugin-from-project-U5UGKTJH.js +15 -0
- package/dist/{policy-6VY3CMSU.js → policy-Z5TL4N3V.js} +9 -12
- package/dist/{policy-6VY3CMSU.js.map → policy-Z5TL4N3V.js.map} +1 -1
- package/dist/{profile-YCKPMRRU.js → profile-QFI7SL3S.js} +108 -78
- package/dist/profile-QFI7SL3S.js.map +1 -0
- package/dist/{project-KHPPBKPN.js → project-3KR3EPYR.js} +486 -60
- package/dist/project-3KR3EPYR.js.map +1 -0
- package/dist/{resource-IJU3FAN5.js → resource-45BPRQ7V.js} +55 -45
- package/dist/resource-45BPRQ7V.js.map +1 -0
- package/dist/status-refresh-worker.js +1155 -0
- package/dist/status-refresh-worker.js.map +1 -0
- package/dist/{version-Z66FWWMQ.js → version-QUJZGTZ5.js} +3 -3
- package/dist/version-QUJZGTZ5.js.map +1 -0
- package/package.json +16 -11
- package/dist/apply-SUNDXRJ3.js +0 -54
- package/dist/chunk-2A36HWDE.js.map +0 -1
- package/dist/chunk-2H7UOFLK.js +0 -11
- package/dist/chunk-3FS775NP.js.map +0 -1
- package/dist/chunk-43BDGVN3.js.map +0 -1
- package/dist/chunk-4ZQ2SCGY.js.map +0 -1
- package/dist/chunk-6LTLYV5D.js.map +0 -1
- package/dist/chunk-D432JAXV.js.map +0 -1
- package/dist/chunk-DF4Z7LAD.js +0 -3463
- package/dist/chunk-DF4Z7LAD.js.map +0 -1
- package/dist/chunk-EOPFER6N.js.map +0 -1
- package/dist/chunk-G6WKY2W4.js +0 -389
- package/dist/chunk-G6WKY2W4.js.map +0 -1
- package/dist/chunk-IE7B6Q5K.js.map +0 -1
- package/dist/chunk-IMROMZ2K.js.map +0 -1
- package/dist/chunk-M2U3J7UX.js +0 -46
- package/dist/chunk-M2U3J7UX.js.map +0 -1
- package/dist/chunk-N3ZCH64F.js.map +0 -1
- package/dist/chunk-NAGAJ5UM.js +0 -145
- package/dist/chunk-NAGAJ5UM.js.map +0 -1
- package/dist/chunk-OML4HXKT.js.map +0 -1
- package/dist/chunk-QA5U36JN.js.map +0 -1
- package/dist/chunk-R7ZOYVN3.js.map +0 -1
- package/dist/chunk-RDG5DT7S.js.map +0 -1
- package/dist/chunk-REHRUNBB.js.map +0 -1
- package/dist/chunk-RFQ3N7FB.js.map +0 -1
- package/dist/chunk-TQ2NA4Z4.js.map +0 -1
- package/dist/chunk-ULCD6DJE.js.map +0 -1
- package/dist/chunk-WG5A6EAU.js.map +0 -1
- package/dist/chunk-XGTTOO4R.js +0 -84
- package/dist/chunk-XGTTOO4R.js.map +0 -1
- package/dist/chunk-XTVGCVU4.js.map +0 -1
- package/dist/chunk-XUJKZQZA.js +0 -235
- package/dist/chunk-XUJKZQZA.js.map +0 -1
- package/dist/chunk-ZUASVASP.js.map +0 -1
- package/dist/doctor-N7ZULPOL.js.map +0 -1
- package/dist/environment-OBB3WU5B.js.map +0 -1
- package/dist/help-VXWKLQ6A.js.map +0 -1
- package/dist/live-read-cache-TUSP7U3D.js +0 -10
- package/dist/marketplace-GXSV6QIY.js.map +0 -1
- package/dist/migrate-SBUIWN3U.js.map +0 -1
- package/dist/open-HDGLYYVU.js +0 -24
- package/dist/plugin-CEO6ZJM5.js +0 -51
- package/dist/plugin-from-project-UK7VJVUP.js +0 -18
- package/dist/profile-YCKPMRRU.js.map +0 -1
- package/dist/project-KHPPBKPN.js.map +0 -1
- package/dist/resource-IJU3FAN5.js.map +0 -1
- /package/dist/{apply-SUNDXRJ3.js.map → apply-FTAIL3X3.js.map} +0 -0
- /package/dist/{chunk-GRASK6M6.js.map → chunk-6FXJIKEG.js.map} +0 -0
- /package/dist/{chunk-73OJQTBW.js.map → chunk-A3TZT4WT.js.map} +0 -0
- /package/dist/{chunk-U6DXASQP.js.map → chunk-CBSDMRMY.js.map} +0 -0
- /package/dist/{chunk-P2C7JPLD.js.map → chunk-EPXAOEBB.js.map} +0 -0
- /package/dist/{chunk-3P6BWL5F.js.map → chunk-K4UDZUJ2.js.map} +0 -0
- /package/dist/{chunk-PNGF5EV2.js.map → chunk-MHLAIGIM.js.map} +0 -0
- /package/dist/{chunk-BPWFQKI5.js.map → chunk-MHMFF6A5.js.map} +0 -0
- /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
- /package/dist/{chunk-23XSG7LI.js.map → chunk-QGTDQNVV.js.map} +0 -0
- /package/dist/{chunk-UVVZHWD2.js.map → chunk-R27VZIF6.js.map} +0 -0
- /package/dist/{chunk-JQOKQKQT.js.map → chunk-S2D5PWAO.js.map} +0 -0
- /package/dist/{chunk-7HP6AAI3.js.map → chunk-UK2IV2ZQ.js.map} +0 -0
- /package/dist/{live-read-cache-TUSP7U3D.js.map → live-read-cache-ESQQJBNS.js.map} +0 -0
- /package/dist/{open-HDGLYYVU.js.map → live-read-cache-WPUFHVMZ.js.map} +0 -0
- /package/dist/{plugin-CEO6ZJM5.js.map → open-D3GWGDSQ.js.map} +0 -0
- /package/dist/{plugin-from-project-UK7VJVUP.js.map → plugin-L3466DHK.js.map} +0 -0
- /package/dist/{version-Z66FWWMQ.js.map → plugin-from-project-U5UGKTJH.js.map} +0 -0
package/dist/chunk-DF4Z7LAD.js
DELETED
|
@@ -1,3463 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AP_MCP_SCHEMA_URL,
|
|
3
|
-
computationSlot,
|
|
4
|
-
cursorCacheRoot,
|
|
5
|
-
cursorLocalRoot,
|
|
6
|
-
cursorMarketplacesRoot,
|
|
7
|
-
cursorProjectsMcpsRoot,
|
|
8
|
-
cursorRepoSourceKey,
|
|
9
|
-
defaultRunCommand,
|
|
10
|
-
existsSync,
|
|
11
|
-
isAgentPluginsSchemaId,
|
|
12
|
-
parsePluginRef,
|
|
13
|
-
readCachedMarketplacePluginNames,
|
|
14
|
-
readFileSync,
|
|
15
|
-
readFirstHostPluginManifest,
|
|
16
|
-
readJsonFile,
|
|
17
|
-
readdirSync,
|
|
18
|
-
refreshGitSource,
|
|
19
|
-
resolveCommandResult,
|
|
20
|
-
statSync
|
|
21
|
-
} from "./chunk-G6WKY2W4.js";
|
|
22
|
-
import {
|
|
23
|
-
getDb,
|
|
24
|
-
getHarnesstapDir,
|
|
25
|
-
readDbDataVersion,
|
|
26
|
-
readStatusWriteGeneration,
|
|
27
|
-
statusTraceEnabled,
|
|
28
|
-
traceCount,
|
|
29
|
-
traceRecord,
|
|
30
|
-
traceSpan
|
|
31
|
-
} from "./chunk-WG5A6EAU.js";
|
|
32
|
-
|
|
33
|
-
// src/plugins/cursor-inventory.ts
|
|
34
|
-
import { isAbsolute, join as join3, relative as relative2 } from "path";
|
|
35
|
-
|
|
36
|
-
// src/services/file-signature.ts
|
|
37
|
-
function fileSignature(path) {
|
|
38
|
-
try {
|
|
39
|
-
const stat = statSync(path);
|
|
40
|
-
const kind = stat.isDirectory() ? "d" : "f";
|
|
41
|
-
return `${stat.mtimeMs}:${stat.size}:${kind}`;
|
|
42
|
-
} catch {
|
|
43
|
-
return "missing";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/plugins/cursor-enablement.ts
|
|
48
|
-
import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "fs";
|
|
49
|
-
import { homedir } from "os";
|
|
50
|
-
import { join } from "path";
|
|
51
|
-
var INSTALLED_PLUGIN_JSON_FILES = [
|
|
52
|
-
join(".cursor", "plugins", "installed.json"),
|
|
53
|
-
join(".cursor", "plugins", "installed_plugins.json")
|
|
54
|
-
];
|
|
55
|
-
function pluginNameFromMcpFolder(folder) {
|
|
56
|
-
if (!folder.startsWith("plugin-")) return null;
|
|
57
|
-
const rest = folder.slice("plugin-".length);
|
|
58
|
-
if (!rest) return null;
|
|
59
|
-
const infix = "-plugin-";
|
|
60
|
-
const infixAt = rest.lastIndexOf(infix);
|
|
61
|
-
if (infixAt > 0) {
|
|
62
|
-
const left = rest.slice(0, infixAt);
|
|
63
|
-
const right = rest.slice(infixAt + infix.length);
|
|
64
|
-
if (left.length > 0 && left === right) return left;
|
|
65
|
-
}
|
|
66
|
-
for (let index = 1; index < rest.length - 1; index += 1) {
|
|
67
|
-
if (rest[index] !== "-") continue;
|
|
68
|
-
const left = rest.slice(0, index);
|
|
69
|
-
const right = rest.slice(index + 1);
|
|
70
|
-
if (left === right) return left;
|
|
71
|
-
}
|
|
72
|
-
return rest;
|
|
73
|
-
}
|
|
74
|
-
function pluginNamesFromMcpFolders(folderNames) {
|
|
75
|
-
const names = /* @__PURE__ */ new Set();
|
|
76
|
-
for (const folder of folderNames) {
|
|
77
|
-
const name = pluginNameFromMcpFolder(folder);
|
|
78
|
-
if (name) names.add(name);
|
|
79
|
-
}
|
|
80
|
-
return names;
|
|
81
|
-
}
|
|
82
|
-
var MCP_FOLDER_MANIFESTS = [
|
|
83
|
-
"SERVER_METADATA.json",
|
|
84
|
-
".cursor-plugin/plugin.json",
|
|
85
|
-
".claude-plugin/plugin.json",
|
|
86
|
-
"plugin.json"
|
|
87
|
-
];
|
|
88
|
-
function pluginRefFromCacheLayout(rawPath) {
|
|
89
|
-
const normalized = rawPath.replaceAll("\\", "/");
|
|
90
|
-
const marker = "/.cursor/plugins/cache/";
|
|
91
|
-
const at = normalized.lastIndexOf(marker);
|
|
92
|
-
if (at < 0) return null;
|
|
93
|
-
const parts = normalized.slice(at + marker.length).split("/").filter((part) => part.length > 0);
|
|
94
|
-
const marketplace = parts[0];
|
|
95
|
-
const name = parts[1];
|
|
96
|
-
if (!marketplace || !name) return null;
|
|
97
|
-
return { name, ref: `${name}@${marketplace}` };
|
|
98
|
-
}
|
|
99
|
-
function stringField(record, key) {
|
|
100
|
-
const value = record[key];
|
|
101
|
-
if (typeof value !== "string") return null;
|
|
102
|
-
const trimmed = value.trim();
|
|
103
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
104
|
-
}
|
|
105
|
-
function manifestPluginRef(folderPath) {
|
|
106
|
-
for (const relativePath of MCP_FOLDER_MANIFESTS) {
|
|
107
|
-
const parsed = readJsonObject(join(folderPath, relativePath));
|
|
108
|
-
if (!parsed) continue;
|
|
109
|
-
for (const key of ["pluginPath", "installPath", "path", "serverPath"]) {
|
|
110
|
-
const raw = stringField(parsed, key);
|
|
111
|
-
if (!raw) continue;
|
|
112
|
-
const fromCache = pluginRefFromCacheLayout(raw);
|
|
113
|
-
if (fromCache) return fromCache;
|
|
114
|
-
}
|
|
115
|
-
for (const key of ["pluginRef", "ref", "pluginId"]) {
|
|
116
|
-
const raw = stringField(parsed, key);
|
|
117
|
-
if (!raw || !raw.includes("@")) continue;
|
|
118
|
-
const parsedRef = parsePluginRef(raw);
|
|
119
|
-
if (!parsedRef.name) continue;
|
|
120
|
-
return { name: parsedRef.name, ref: raw };
|
|
121
|
-
}
|
|
122
|
-
for (const key of ["pluginName", "plugin", "name"]) {
|
|
123
|
-
const raw = stringField(parsed, key);
|
|
124
|
-
if (!raw || raw.startsWith("plugin-")) continue;
|
|
125
|
-
return { name: raw, ref: `${raw}@cursor` };
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
function cacheMatchScore(folderName, pluginName, marketplace) {
|
|
131
|
-
if (!pluginName) return 0;
|
|
132
|
-
if (folderName === `plugin-${pluginName}-plugin-${pluginName}`) return 4;
|
|
133
|
-
if (folderName === `plugin-${pluginName}-${pluginName}`) return 3;
|
|
134
|
-
if (marketplace && folderName === `plugin-${marketplace}-${pluginName}`) return 2;
|
|
135
|
-
if (folderName === `plugin-${pluginName}`) return 1;
|
|
136
|
-
return 0;
|
|
137
|
-
}
|
|
138
|
-
function resolveCursorMcpFolderPlugin(homeRoot, folderName, cached) {
|
|
139
|
-
if (!folderName.startsWith("plugin-")) return null;
|
|
140
|
-
const fromManifest = manifestPluginRef(
|
|
141
|
-
join(cursorProjectsMcpsRoot(homeRoot), folderName)
|
|
142
|
-
);
|
|
143
|
-
if (fromManifest) return fromManifest;
|
|
144
|
-
let best = null;
|
|
145
|
-
for (const row of cached) {
|
|
146
|
-
const marketplace = parsePluginRef(row.ref).marketplace;
|
|
147
|
-
const score = cacheMatchScore(folderName, row.name, marketplace);
|
|
148
|
-
if (score === 0) continue;
|
|
149
|
-
if (!best || score > best.score) {
|
|
150
|
-
best = { name: row.name, ref: row.ref, score };
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (best) return { name: best.name, ref: best.ref };
|
|
154
|
-
const name = pluginNameFromMcpFolder(folderName);
|
|
155
|
-
if (!name) return null;
|
|
156
|
-
return { name, ref: `${name}@cursor` };
|
|
157
|
-
}
|
|
158
|
-
function listMcpPluginFolderNames(homeRoot) {
|
|
159
|
-
const root = cursorProjectsMcpsRoot(homeRoot);
|
|
160
|
-
if (!existsSync2(root)) return [];
|
|
161
|
-
try {
|
|
162
|
-
return readdirSync2(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("plugin-")).map((entry) => entry.name);
|
|
163
|
-
} catch {
|
|
164
|
-
return [];
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
function listCursorNativeMcpPluginNames(homeRoot) {
|
|
168
|
-
return pluginNamesFromMcpFolders(listMcpPluginFolderNames(homeRoot));
|
|
169
|
-
}
|
|
170
|
-
function cursorUserDataDir(homeRoot) {
|
|
171
|
-
if (homeRoot !== homedir()) {
|
|
172
|
-
return join(homeRoot, ".config", "Cursor");
|
|
173
|
-
}
|
|
174
|
-
if (process.platform === "darwin") {
|
|
175
|
-
return join(homedir(), "Library", "Application Support", "Cursor");
|
|
176
|
-
}
|
|
177
|
-
if (process.platform === "win32") {
|
|
178
|
-
const appData = process.env.APPDATA ?? join(homedir(), "AppData", "Roaming");
|
|
179
|
-
return join(appData, "Cursor");
|
|
180
|
-
}
|
|
181
|
-
return join(homedir(), ".config", "Cursor");
|
|
182
|
-
}
|
|
183
|
-
function readJsonObject(path) {
|
|
184
|
-
if (!existsSync2(path)) return null;
|
|
185
|
-
try {
|
|
186
|
-
const parsed = JSON.parse(readFileSync2(path, "utf-8"));
|
|
187
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
190
|
-
return parsed;
|
|
191
|
-
} catch {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// src/plugins/cursor-local-plugin.ts
|
|
197
|
-
import { existsSync as existsSync3, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "fs";
|
|
198
|
-
import { join as join2, relative, sep } from "path";
|
|
199
|
-
var CURSOR_LOCAL_PLUGIN_SCHEMA = "urn:harnesstap:cursor-local-plugin:v1";
|
|
200
|
-
var CURSOR_LOCAL_PLUGIN_SIDECAR = ".harnesstap-plugin.json";
|
|
201
|
-
var CURSOR_LOCAL_PLUGINS_RELATIVE_ROOT = ".cursor/plugins/local";
|
|
202
|
-
function sanitizeCursorLocalFolderSegment(value) {
|
|
203
|
-
const cleaned = value.trim().replace(/[\\/]/g, "-").replace(/^\.+/, "");
|
|
204
|
-
return cleaned || "plugin";
|
|
205
|
-
}
|
|
206
|
-
function cursorLocalPluginFolderName(name, marketplace, duplicateName) {
|
|
207
|
-
const plugin = sanitizeCursorLocalFolderSegment(name);
|
|
208
|
-
if (!duplicateName) {
|
|
209
|
-
return plugin;
|
|
210
|
-
}
|
|
211
|
-
const market = sanitizeCursorLocalFolderSegment(
|
|
212
|
-
marketplace === "" ? "local" : marketplace
|
|
213
|
-
);
|
|
214
|
-
return `${plugin}--${market}`;
|
|
215
|
-
}
|
|
216
|
-
function cursorLocalPluginSidecarDocument(originRef) {
|
|
217
|
-
return {
|
|
218
|
-
schema: CURSOR_LOCAL_PLUGIN_SCHEMA,
|
|
219
|
-
origin_ref: originRef
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
function cursorLocalPluginSidecarContent(originRef) {
|
|
223
|
-
return `${JSON.stringify(cursorLocalPluginSidecarDocument(originRef), null, 2)}
|
|
224
|
-
`;
|
|
225
|
-
}
|
|
226
|
-
function readCursorLocalPluginSidecar(installPath) {
|
|
227
|
-
const path = join2(installPath, CURSOR_LOCAL_PLUGIN_SIDECAR);
|
|
228
|
-
if (!existsSync3(path)) return null;
|
|
229
|
-
try {
|
|
230
|
-
const parsed = JSON.parse(readFileSync3(path, "utf-8"));
|
|
231
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
const record = parsed;
|
|
235
|
-
if (record.schema !== CURSOR_LOCAL_PLUGIN_SCHEMA) return null;
|
|
236
|
-
if (typeof record.origin_ref !== "string" || !record.origin_ref.includes("@")) {
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
return {
|
|
240
|
-
schema: CURSOR_LOCAL_PLUGIN_SCHEMA,
|
|
241
|
-
origin_ref: record.origin_ref
|
|
242
|
-
};
|
|
243
|
-
} catch {
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
function findCursorLocalPluginDirectory(homeRoot, originRef) {
|
|
248
|
-
const root = join2(homeRoot, CURSOR_LOCAL_PLUGINS_RELATIVE_ROOT);
|
|
249
|
-
if (!existsSync3(root)) return null;
|
|
250
|
-
let entries = [];
|
|
251
|
-
try {
|
|
252
|
-
entries = readdirSync3(root, { withFileTypes: true });
|
|
253
|
-
} catch {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
for (const entry of entries) {
|
|
257
|
-
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
258
|
-
const installPath = join2(root, entry.name);
|
|
259
|
-
const sidecar = readCursorLocalPluginSidecar(installPath);
|
|
260
|
-
if (sidecar?.origin_ref === originRef) return installPath;
|
|
261
|
-
}
|
|
262
|
-
return null;
|
|
263
|
-
}
|
|
264
|
-
function originRefFromSidecarContent(content) {
|
|
265
|
-
try {
|
|
266
|
-
const parsed = JSON.parse(content);
|
|
267
|
-
if (parsed.schema !== CURSOR_LOCAL_PLUGIN_SCHEMA) return null;
|
|
268
|
-
if (typeof parsed.origin_ref !== "string" || !parsed.origin_ref.includes("@")) {
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
return parsed.origin_ref;
|
|
272
|
-
} catch {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
function cursorLocalPluginFolderFromRelative(path) {
|
|
277
|
-
const normalized = path.replaceAll("\\", "/");
|
|
278
|
-
const prefix = `${CURSOR_LOCAL_PLUGINS_RELATIVE_ROOT}/`;
|
|
279
|
-
if (!normalized.startsWith(prefix)) return null;
|
|
280
|
-
const folder = normalized.slice(prefix.length).split("/")[0];
|
|
281
|
-
return folder || null;
|
|
282
|
-
}
|
|
283
|
-
function pruneManagedCursorLocalPlugins(rootPath, files) {
|
|
284
|
-
const undesired = [];
|
|
285
|
-
const desiredByFolder = /* @__PURE__ */ new Map();
|
|
286
|
-
for (const file of files) {
|
|
287
|
-
const folder = cursorLocalPluginFolderFromRelative(file.path);
|
|
288
|
-
if (!folder) continue;
|
|
289
|
-
const desired = desiredByFolder.get(folder) ?? /* @__PURE__ */ new Set();
|
|
290
|
-
desired.add(file.path.replaceAll("\\", "/"));
|
|
291
|
-
desiredByFolder.set(folder, desired);
|
|
292
|
-
}
|
|
293
|
-
for (const [folder, desired] of desiredByFolder) {
|
|
294
|
-
const sidecarPath = `${CURSOR_LOCAL_PLUGINS_RELATIVE_ROOT}/${folder}/${CURSOR_LOCAL_PLUGIN_SIDECAR}`;
|
|
295
|
-
if (!desired.has(sidecarPath)) continue;
|
|
296
|
-
const sidecar = files.find((file) => file.path.replaceAll("\\", "/") === sidecarPath);
|
|
297
|
-
const originRef = sidecar ? originRefFromSidecarContent(sidecar.content) : null;
|
|
298
|
-
if (originRef) {
|
|
299
|
-
const previous = findCursorLocalPluginDirectory(rootPath, originRef);
|
|
300
|
-
const absoluteNext = join2(rootPath, CURSOR_LOCAL_PLUGINS_RELATIVE_ROOT, folder);
|
|
301
|
-
if (previous && previous !== absoluteNext) {
|
|
302
|
-
const previousRelative = relative(rootPath, previous).split(sep).join("/");
|
|
303
|
-
if (previousRelative && !previousRelative.startsWith("..")) {
|
|
304
|
-
collectUndesiredFiles(previous, previousRelative, /* @__PURE__ */ new Set(), undesired);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
const absoluteFolder = join2(rootPath, CURSOR_LOCAL_PLUGINS_RELATIVE_ROOT, folder);
|
|
309
|
-
if (!existsSync3(absoluteFolder)) continue;
|
|
310
|
-
collectUndesiredFiles(
|
|
311
|
-
absoluteFolder,
|
|
312
|
-
`${CURSOR_LOCAL_PLUGINS_RELATIVE_ROOT}/${folder}`,
|
|
313
|
-
desired,
|
|
314
|
-
undesired
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
return undesired;
|
|
318
|
-
}
|
|
319
|
-
function collectUndesiredFiles(absoluteDir, relativeDir, desired, undesired) {
|
|
320
|
-
let entries = [];
|
|
321
|
-
try {
|
|
322
|
-
entries = readdirSync3(absoluteDir, { withFileTypes: true });
|
|
323
|
-
} catch {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
for (const entry of entries) {
|
|
327
|
-
const absolute = join2(absoluteDir, entry.name);
|
|
328
|
-
const relativePath = `${relativeDir}/${entry.name}`;
|
|
329
|
-
if (entry.isDirectory()) {
|
|
330
|
-
collectUndesiredFiles(absolute, relativePath, desired, undesired);
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
if (!entry.isFile()) continue;
|
|
334
|
-
if (desired.has(relativePath)) continue;
|
|
335
|
-
undesired.push(relativePath);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// src/plugins/cursor-inventory.ts
|
|
340
|
-
function readJson(path) {
|
|
341
|
-
if (!existsSync(path)) return null;
|
|
342
|
-
try {
|
|
343
|
-
return JSON.parse(readFileSync(path, "utf-8"));
|
|
344
|
-
} catch {
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
function isAgentPluginManifest(manifest, installPath) {
|
|
349
|
-
if (isAgentPluginsSchemaId(manifest.$schema)) {
|
|
350
|
-
return true;
|
|
351
|
-
}
|
|
352
|
-
return existsSync(join3(installPath, "skills")) || existsSync(join3(installPath, "mcp.json"));
|
|
353
|
-
}
|
|
354
|
-
function readInstallManifest(installPath) {
|
|
355
|
-
const cursorManifest = readJson(
|
|
356
|
-
join3(installPath, ".cursor-plugin", "plugin.json")
|
|
357
|
-
);
|
|
358
|
-
if (cursorManifest?.name) return cursorManifest;
|
|
359
|
-
const rootManifest = readJson(
|
|
360
|
-
join3(installPath, "plugin.json")
|
|
361
|
-
);
|
|
362
|
-
if (rootManifest?.name && isAgentPluginManifest(rootManifest, installPath)) {
|
|
363
|
-
return rootManifest;
|
|
364
|
-
}
|
|
365
|
-
const claudeManifest = readJson(
|
|
366
|
-
join3(installPath, ".claude-plugin", "plugin.json")
|
|
367
|
-
);
|
|
368
|
-
if (claudeManifest?.name) return claudeManifest;
|
|
369
|
-
return null;
|
|
370
|
-
}
|
|
371
|
-
function toInstall(input) {
|
|
372
|
-
const version = input.manifest.version ?? input.versionDirName ?? "unknown";
|
|
373
|
-
return {
|
|
374
|
-
ref: input.ref ?? `${input.manifest.name}@${input.marketplace}`,
|
|
375
|
-
platformId: "cursor",
|
|
376
|
-
name: input.manifest.name,
|
|
377
|
-
version,
|
|
378
|
-
versionSource: input.manifest.version ? "manifest" : "git_sha",
|
|
379
|
-
scope: input.scope,
|
|
380
|
-
enabled: input.enabled,
|
|
381
|
-
installPath: input.installPath,
|
|
382
|
-
metadata: {
|
|
383
|
-
description: input.manifest.description,
|
|
384
|
-
repository: input.manifest.repository,
|
|
385
|
-
homepage: input.manifest.homepage
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
function isUnderCursorPluginsRoot(homeRoot, installPath) {
|
|
390
|
-
const pluginsRoot = join3(homeRoot, ".cursor", "plugins");
|
|
391
|
-
const rel = relative2(pluginsRoot, installPath);
|
|
392
|
-
return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
|
|
393
|
-
}
|
|
394
|
-
function isInventoriedCursorInstall(install, homeRoot) {
|
|
395
|
-
if (!install.installPath) return true;
|
|
396
|
-
return isUnderCursorPluginsRoot(homeRoot, install.installPath);
|
|
397
|
-
}
|
|
398
|
-
function newestVersionDir(parent) {
|
|
399
|
-
let entries = [];
|
|
400
|
-
try {
|
|
401
|
-
entries = readdirSync(parent, { withFileTypes: true });
|
|
402
|
-
} catch {
|
|
403
|
-
return null;
|
|
404
|
-
}
|
|
405
|
-
let best = null;
|
|
406
|
-
for (const entry of entries) {
|
|
407
|
-
if (!entry.isDirectory()) continue;
|
|
408
|
-
const path = join3(parent, entry.name);
|
|
409
|
-
let mtimeMs = 0;
|
|
410
|
-
try {
|
|
411
|
-
mtimeMs = statSync(path).mtimeMs;
|
|
412
|
-
} catch {
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
if (!best || mtimeMs > best.mtimeMs || mtimeMs === best.mtimeMs && entry.name > best.name) {
|
|
416
|
-
best = { name: entry.name, path, mtimeMs };
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return best ? { name: best.name, path: best.path } : null;
|
|
420
|
-
}
|
|
421
|
-
function scanCacheInstalls(homeRoot) {
|
|
422
|
-
const cacheRoot = cursorCacheRoot(homeRoot);
|
|
423
|
-
if (!existsSync(cacheRoot)) return [];
|
|
424
|
-
const installs = [];
|
|
425
|
-
for (const marketplace of readdirSync(cacheRoot, { withFileTypes: true })) {
|
|
426
|
-
if (!marketplace.isDirectory()) continue;
|
|
427
|
-
const marketplaceDir = join3(cacheRoot, marketplace.name);
|
|
428
|
-
for (const pluginDir of readdirSync(marketplaceDir, {
|
|
429
|
-
withFileTypes: true
|
|
430
|
-
})) {
|
|
431
|
-
if (!pluginDir.isDirectory()) continue;
|
|
432
|
-
const versionDir = newestVersionDir(join3(marketplaceDir, pluginDir.name));
|
|
433
|
-
if (!versionDir) continue;
|
|
434
|
-
const manifest = readInstallManifest(versionDir.path);
|
|
435
|
-
if (!manifest?.name) continue;
|
|
436
|
-
installs.push(
|
|
437
|
-
toInstall({
|
|
438
|
-
manifest,
|
|
439
|
-
marketplace: marketplace.name,
|
|
440
|
-
installPath: versionDir.path,
|
|
441
|
-
versionDirName: versionDir.name,
|
|
442
|
-
scope: "user",
|
|
443
|
-
enabled: true
|
|
444
|
-
})
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
return installs;
|
|
449
|
-
}
|
|
450
|
-
function scanLocalInstalls(homeRoot) {
|
|
451
|
-
const localRoot = cursorLocalRoot(homeRoot);
|
|
452
|
-
if (!existsSync(localRoot)) return [];
|
|
453
|
-
const installs = [];
|
|
454
|
-
for (const entry of readdirSync(localRoot, { withFileTypes: true })) {
|
|
455
|
-
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
456
|
-
const installPath = join3(localRoot, entry.name);
|
|
457
|
-
const manifest = readInstallManifest(installPath);
|
|
458
|
-
if (!manifest?.name) continue;
|
|
459
|
-
const sidecar = readCursorLocalPluginSidecar(installPath);
|
|
460
|
-
const origin = sidecar ? parsePluginRef(sidecar.origin_ref) : { name: manifest.name, marketplace: "local" };
|
|
461
|
-
installs.push(
|
|
462
|
-
toInstall({
|
|
463
|
-
manifest,
|
|
464
|
-
marketplace: origin.marketplace || "local",
|
|
465
|
-
ref: sidecar?.origin_ref ?? `${manifest.name}@local`,
|
|
466
|
-
installPath,
|
|
467
|
-
scope: "local",
|
|
468
|
-
enabled: true
|
|
469
|
-
})
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
return installs;
|
|
473
|
-
}
|
|
474
|
-
function scanMarketplaceInstalls(homeRoot, existingRefs) {
|
|
475
|
-
const marketplacesRoot = cursorMarketplacesRoot(homeRoot);
|
|
476
|
-
const hostRoot = join3(marketplacesRoot, "github.com");
|
|
477
|
-
if (!existsSync(hostRoot)) return [];
|
|
478
|
-
const installs = [];
|
|
479
|
-
for (const owner of readdirSync(hostRoot, { withFileTypes: true })) {
|
|
480
|
-
if (!owner.isDirectory() || owner.name.startsWith("_")) continue;
|
|
481
|
-
const ownerDir = join3(hostRoot, owner.name);
|
|
482
|
-
for (const repo of readdirSync(ownerDir, { withFileTypes: true })) {
|
|
483
|
-
if (!repo.isDirectory()) continue;
|
|
484
|
-
const versionDir = newestVersionDir(join3(ownerDir, repo.name));
|
|
485
|
-
if (!versionDir) continue;
|
|
486
|
-
const manifest = readInstallManifest(versionDir.path);
|
|
487
|
-
if (!manifest?.name) continue;
|
|
488
|
-
const ref = `${manifest.name}@${owner.name}`;
|
|
489
|
-
if (existingRefs.has(ref)) continue;
|
|
490
|
-
const alreadyCached = [...existingRefs].some(
|
|
491
|
-
(existing) => existing.startsWith(`${manifest.name}@`)
|
|
492
|
-
);
|
|
493
|
-
if (alreadyCached) continue;
|
|
494
|
-
installs.push(
|
|
495
|
-
toInstall({
|
|
496
|
-
manifest,
|
|
497
|
-
marketplace: owner.name,
|
|
498
|
-
installPath: versionDir.path,
|
|
499
|
-
versionDirName: versionDir.name,
|
|
500
|
-
scope: "user",
|
|
501
|
-
enabled: true
|
|
502
|
-
})
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
return installs;
|
|
507
|
-
}
|
|
508
|
-
function scanMcpOnlyInstalls(homeRoot, existing) {
|
|
509
|
-
const root = cursorProjectsMcpsRoot(homeRoot);
|
|
510
|
-
let folders = [];
|
|
511
|
-
try {
|
|
512
|
-
folders = readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith("plugin-")).map((entry) => entry.name);
|
|
513
|
-
} catch {
|
|
514
|
-
return [];
|
|
515
|
-
}
|
|
516
|
-
const existingNames = new Set(existing.map((row) => row.name));
|
|
517
|
-
const existingRefs = new Set(existing.map((row) => row.ref));
|
|
518
|
-
const installs = [];
|
|
519
|
-
for (const folder of folders) {
|
|
520
|
-
const resolved = resolveCursorMcpFolderPlugin(homeRoot, folder, existing);
|
|
521
|
-
if (!resolved) continue;
|
|
522
|
-
if (existingNames.has(resolved.name) || existingRefs.has(resolved.ref)) continue;
|
|
523
|
-
existingNames.add(resolved.name);
|
|
524
|
-
existingRefs.add(resolved.ref);
|
|
525
|
-
installs.push({
|
|
526
|
-
ref: resolved.ref,
|
|
527
|
-
platformId: "cursor",
|
|
528
|
-
name: resolved.name,
|
|
529
|
-
version: "unknown",
|
|
530
|
-
versionSource: "unknown",
|
|
531
|
-
scope: "user",
|
|
532
|
-
enabled: true
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
return installs;
|
|
536
|
-
}
|
|
537
|
-
function listCursorPluginFootprintNames(homeRoot) {
|
|
538
|
-
const names = /* @__PURE__ */ new Set();
|
|
539
|
-
for (const install of listCursorPluginInstalls(homeRoot)) {
|
|
540
|
-
names.add(install.name);
|
|
541
|
-
}
|
|
542
|
-
return names;
|
|
543
|
-
}
|
|
544
|
-
function cloneInstall(install) {
|
|
545
|
-
return {
|
|
546
|
-
...install,
|
|
547
|
-
...install.metadata ? { metadata: { ...install.metadata } } : {}
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
function cursorInventoryInputSignature(homeRoot) {
|
|
551
|
-
const plugins = join3(homeRoot, ".cursor", "plugins");
|
|
552
|
-
return [
|
|
553
|
-
fileSignature(plugins),
|
|
554
|
-
fileSignature(join3(plugins, "cache")),
|
|
555
|
-
fileSignature(join3(plugins, "marketplaces")),
|
|
556
|
-
fileSignature(join3(plugins, "local")),
|
|
557
|
-
fileSignature(cursorProjectsMcpsRoot(homeRoot))
|
|
558
|
-
].join("|");
|
|
559
|
-
}
|
|
560
|
-
var cursorInstallsCache = /* @__PURE__ */ new Map();
|
|
561
|
-
function clearCursorPluginInstallsCache() {
|
|
562
|
-
cursorInstallsCache.clear();
|
|
563
|
-
}
|
|
564
|
-
function scanCursorPluginInstalls(homeRoot) {
|
|
565
|
-
const cache = traceSpan("scan.cursor.cache", () => scanCacheInstalls(homeRoot), "~/.cursor/plugins/cache");
|
|
566
|
-
const local = traceSpan("scan.cursor.local", () => scanLocalInstalls(homeRoot), "~/.cursor/plugins/local");
|
|
567
|
-
const refs = new Set(cache.map((row) => row.ref));
|
|
568
|
-
const marketplaces = traceSpan(
|
|
569
|
-
"scan.cursor.marketplaces",
|
|
570
|
-
() => scanMarketplaceInstalls(homeRoot, refs),
|
|
571
|
-
"~/.cursor/plugins/marketplaces"
|
|
572
|
-
);
|
|
573
|
-
const installed = [...cache, ...local, ...marketplaces];
|
|
574
|
-
const mcp = traceSpan("scan.cursor.mcp-folders", () => scanMcpOnlyInstalls(homeRoot, installed), "~/.cursor/projects/mcps");
|
|
575
|
-
traceCount("scan.cursor.cache", "plugins", cache.length);
|
|
576
|
-
traceCount("scan.cursor.local", "plugins", local.length);
|
|
577
|
-
traceCount("scan.cursor.marketplaces", "plugins", marketplaces.length);
|
|
578
|
-
traceCount("scan.cursor.mcp-folders", "plugins", mcp.length);
|
|
579
|
-
return [...cache, ...local, ...marketplaces, ...mcp].filter(
|
|
580
|
-
(install) => isInventoriedCursorInstall(install, homeRoot)
|
|
581
|
-
);
|
|
582
|
-
}
|
|
583
|
-
function listCursorPluginInstalls(homeRoot) {
|
|
584
|
-
const installs = computationSlot(`cursor-inventory:${homeRoot}`, () => {
|
|
585
|
-
const sig = traceSpan("scan.cursor.signature", () => cursorInventoryInputSignature(homeRoot));
|
|
586
|
-
const cached = cursorInstallsCache.get(homeRoot);
|
|
587
|
-
if (cached && cached.sig === sig) {
|
|
588
|
-
traceCount("scan.cursor.signature", "reused");
|
|
589
|
-
return cached.installs;
|
|
590
|
-
}
|
|
591
|
-
const scanned = scanCursorPluginInstalls(homeRoot);
|
|
592
|
-
cursorInstallsCache.set(homeRoot, { sig, installs: scanned });
|
|
593
|
-
return scanned;
|
|
594
|
-
});
|
|
595
|
-
return installs.map(cloneInstall);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
// src/services/status-refresh-error.ts
|
|
599
|
-
function describeStatusRefreshError(error) {
|
|
600
|
-
if (error instanceof Error) {
|
|
601
|
-
return { message: error.message || error.name || "Error", ...error.stack ? { stack: error.stack } : {} };
|
|
602
|
-
}
|
|
603
|
-
if (error && typeof error === "object" && typeof error.message === "string") {
|
|
604
|
-
const shaped = error;
|
|
605
|
-
return { message: shaped.message, ...typeof shaped.stack === "string" ? { stack: shaped.stack } : {} };
|
|
606
|
-
}
|
|
607
|
-
return { message: String(error) };
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// src/services/status-read-cache.ts
|
|
611
|
-
import { existsSync as existsSync10, readdirSync as readdirSync4, readFileSync as readFileSync9, statSync as statSync2, watch } from "fs";
|
|
612
|
-
import { basename as basename2, dirname as dirname2, join as join12, sep as sep2 } from "path";
|
|
613
|
-
import { Worker, parentPort } from "worker_threads";
|
|
614
|
-
|
|
615
|
-
// src/platforms/registry.ts
|
|
616
|
-
function def(id, name, features, projectPaths, globalPaths, options) {
|
|
617
|
-
const normalized = typeof options === "string" || options === void 0 ? { skillEmission: options } : options;
|
|
618
|
-
return {
|
|
619
|
-
id,
|
|
620
|
-
name,
|
|
621
|
-
supports: new Set(features),
|
|
622
|
-
projectPaths,
|
|
623
|
-
globalPaths,
|
|
624
|
-
...normalized.skillEmission ? { skillEmission: normalized.skillEmission } : {},
|
|
625
|
-
...normalized.hostManagedPaths ? { hostManagedPaths: normalized.hostManagedPaths } : {},
|
|
626
|
-
...normalized.relatedLocations ? { relatedLocations: normalized.relatedLocations } : {},
|
|
627
|
-
...normalized.hostPluginRuntimeModules ? { hostPluginRuntimeModules: true } : {},
|
|
628
|
-
...normalized.detectionPaths ? { detectionPaths: normalized.detectionPaths } : {}
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
var ALL = [
|
|
632
|
-
"instructions",
|
|
633
|
-
"skills",
|
|
634
|
-
"rules",
|
|
635
|
-
"mcp",
|
|
636
|
-
"permissions",
|
|
637
|
-
"hooks",
|
|
638
|
-
"agents",
|
|
639
|
-
"commands",
|
|
640
|
-
"env_vars",
|
|
641
|
-
"model_config"
|
|
642
|
-
];
|
|
643
|
-
var PLATFORMS = [
|
|
644
|
-
// ── Full-featured platforms ──────────────────────────────────────────
|
|
645
|
-
def("claude-code", "Claude Code", ALL, {
|
|
646
|
-
instructions: "CLAUDE.md",
|
|
647
|
-
skills: ".claude/skills/",
|
|
648
|
-
rules: ".claude/rules/",
|
|
649
|
-
mcp: ".mcp.json",
|
|
650
|
-
permissions: ".claude/settings.json",
|
|
651
|
-
hooks: ".claude/settings.json",
|
|
652
|
-
agents: ".claude/agents/",
|
|
653
|
-
commands: ".claude/commands/",
|
|
654
|
-
settings: ".claude/settings.json"
|
|
655
|
-
}, {
|
|
656
|
-
instructions: "~/.claude/CLAUDE.md",
|
|
657
|
-
skills: "~/.claude/skills/",
|
|
658
|
-
rules: "~/.claude/rules/",
|
|
659
|
-
mcp: "~/.claude.json",
|
|
660
|
-
agents: "~/.claude/agents/",
|
|
661
|
-
commands: "~/.claude/commands/",
|
|
662
|
-
settings: "~/.claude/settings.json",
|
|
663
|
-
plugins: "~/.claude/plugins/"
|
|
664
|
-
}, { hostPluginRuntimeModules: true }),
|
|
665
|
-
def("codex", "Codex", [
|
|
666
|
-
"instructions",
|
|
667
|
-
"skills",
|
|
668
|
-
"rules",
|
|
669
|
-
"mcp",
|
|
670
|
-
"permissions",
|
|
671
|
-
"hooks",
|
|
672
|
-
"agents",
|
|
673
|
-
"commands",
|
|
674
|
-
"env_vars",
|
|
675
|
-
"model_config"
|
|
676
|
-
], {
|
|
677
|
-
instructions: "AGENTS.md",
|
|
678
|
-
skills: ".agents/skills/",
|
|
679
|
-
mcp: ".codex/config.toml",
|
|
680
|
-
permissions: ".codex/config.toml",
|
|
681
|
-
hooks: ".codex/hooks.json",
|
|
682
|
-
agents: ".codex/agents/",
|
|
683
|
-
commands: ".codex/prompts/",
|
|
684
|
-
settings: ".codex/config.toml"
|
|
685
|
-
}, {
|
|
686
|
-
instructions: "~/.codex/AGENTS.md",
|
|
687
|
-
skills: "~/.agents/skills/",
|
|
688
|
-
settings: "~/.codex/config.toml",
|
|
689
|
-
agents: "~/.codex/agents/",
|
|
690
|
-
commands: "~/.codex/prompts/"
|
|
691
|
-
}),
|
|
692
|
-
def("cursor", "Cursor", [
|
|
693
|
-
"instructions",
|
|
694
|
-
"skills",
|
|
695
|
-
"rules",
|
|
696
|
-
"mcp",
|
|
697
|
-
"agents",
|
|
698
|
-
"hooks"
|
|
699
|
-
], {
|
|
700
|
-
instructions: "AGENTS.md",
|
|
701
|
-
legacy_instructions: ".cursorrules",
|
|
702
|
-
rules: ".cursor/rules/",
|
|
703
|
-
skills: ".agents/skills/",
|
|
704
|
-
mcp: ".cursor/mcp.json",
|
|
705
|
-
agents: ".cursor/agents/",
|
|
706
|
-
hooks: ".cursor/hooks.json"
|
|
707
|
-
}, {
|
|
708
|
-
rules: "~/.cursor/rules/",
|
|
709
|
-
skills: "~/.cursor/skills/",
|
|
710
|
-
settings: "~/.cursor/mcp.json",
|
|
711
|
-
agents: "~/.cursor/agents/",
|
|
712
|
-
hooks: "~/.cursor/hooks.json",
|
|
713
|
-
plugins: "~/.cursor/plugins/"
|
|
714
|
-
}, {
|
|
715
|
-
hostManagedPaths: {
|
|
716
|
-
skills: "~/.cursor/skills-cursor/"
|
|
717
|
-
},
|
|
718
|
-
relatedLocations: [
|
|
719
|
-
// Shown on the Cursor harness only while Cursor still loads third-party
|
|
720
|
-
// Plugins, Skills, and other configs. Cursor does not load Claude's
|
|
721
|
-
// plugin install tree as its own plugins.
|
|
722
|
-
{ path: "~/.claude/plugins/", surfaces: ["plugins"] },
|
|
723
|
-
{ path: "~/.claude/skills/", surfaces: ["skills"] }
|
|
724
|
-
]
|
|
725
|
-
}),
|
|
726
|
-
// ── Platforms using .agents/ convention ──────────────────────────────
|
|
727
|
-
def("warp", "Warp", ["instructions", "skills"], {
|
|
728
|
-
instructions: "AGENTS.md",
|
|
729
|
-
skills: ".agents/skills/"
|
|
730
|
-
}, {
|
|
731
|
-
skills: "~/.agents/skills/"
|
|
732
|
-
}, {
|
|
733
|
-
detectionPaths: {
|
|
734
|
-
project: [".warp/"],
|
|
735
|
-
global: ["~/.warp"]
|
|
736
|
-
}
|
|
737
|
-
}),
|
|
738
|
-
def("opencode", "OpenCode", ["instructions", "skills", "mcp", "agents", "commands"], {
|
|
739
|
-
instructions: "AGENTS.md",
|
|
740
|
-
skills: ".opencode/skills/",
|
|
741
|
-
agents: ".opencode/agents/",
|
|
742
|
-
commands: ".opencode/commands/",
|
|
743
|
-
pathAlternates: {
|
|
744
|
-
commands: [".opencode/command/"],
|
|
745
|
-
agents: [".opencode/agent/"],
|
|
746
|
-
skills: [".agents/skills/"]
|
|
747
|
-
},
|
|
748
|
-
mcp: "opencode.json"
|
|
749
|
-
}, {
|
|
750
|
-
skills: "~/.config/opencode/skills/",
|
|
751
|
-
agents: "~/.config/opencode/agents/",
|
|
752
|
-
commands: "~/.config/opencode/commands/",
|
|
753
|
-
settings: "~/.config/opencode/opencode.json",
|
|
754
|
-
pathAlternates: {
|
|
755
|
-
commands: ["~/.config/opencode/command/"],
|
|
756
|
-
agents: ["~/.config/opencode/agent/"]
|
|
757
|
-
}
|
|
758
|
-
}, {
|
|
759
|
-
relatedLocations: [
|
|
760
|
-
{ path: "~/.agents/skills/", surfaces: ["skills"] },
|
|
761
|
-
{ path: "~/.claude/skills/", surfaces: ["skills"] },
|
|
762
|
-
{ path: "~/.agents/AGENTS.md", surfaces: ["instructions"] }
|
|
763
|
-
]
|
|
764
|
-
}),
|
|
765
|
-
def("github-copilot", "GitHub Copilot", ["instructions", "skills", "mcp", "agents"], {
|
|
766
|
-
instructions: ".github/copilot-instructions.md",
|
|
767
|
-
skills: ".agents/skills/",
|
|
768
|
-
agents: ".github/agents/"
|
|
769
|
-
}, {
|
|
770
|
-
skills: "~/.copilot/skills/",
|
|
771
|
-
settings: "~/.copilot/mcp-config.json"
|
|
772
|
-
}, "instruction-only"),
|
|
773
|
-
def("copilot-cli", "Copilot CLI", ["instructions", "skills", "mcp", "agents"], {
|
|
774
|
-
instructions: "AGENTS.md",
|
|
775
|
-
skills: ".agents/skills/",
|
|
776
|
-
mcp: ".copilot/mcp-config.json",
|
|
777
|
-
agents: ".github/agents/"
|
|
778
|
-
}, {
|
|
779
|
-
skills: "~/.copilot/skills/",
|
|
780
|
-
settings: "~/.copilot/mcp-config.json",
|
|
781
|
-
plugins: "~/.copilot/installed-plugins/",
|
|
782
|
-
pathAlternates: {
|
|
783
|
-
settings: ["~/.copilot/settings.json"]
|
|
784
|
-
}
|
|
785
|
-
}),
|
|
786
|
-
def("gemini-cli", "Gemini CLI", ["instructions", "skills", "commands"], {
|
|
787
|
-
instructions: "AGENTS.md",
|
|
788
|
-
skills: ".agents/skills/",
|
|
789
|
-
commands: "commands/",
|
|
790
|
-
settings: "gemini-extension.json"
|
|
791
|
-
}, {
|
|
792
|
-
skills: "~/.gemini/skills/"
|
|
793
|
-
}, "instruction-only"),
|
|
794
|
-
def("windsurf", "Windsurf", ["instructions", "skills", "rules", "mcp"], {
|
|
795
|
-
instructions: ".windsurfrules",
|
|
796
|
-
rules: ".windsurf/rules/",
|
|
797
|
-
skills: ".agents/skills/"
|
|
798
|
-
}, {
|
|
799
|
-
skills: "~/.codeium/windsurf/skills/",
|
|
800
|
-
settings: "~/.codeium/windsurf/mcp_config.json"
|
|
801
|
-
}, "instruction-only"),
|
|
802
|
-
def("cline", "Cline", ["instructions", "skills", "rules", "mcp"], {
|
|
803
|
-
instructions: "AGENTS.md",
|
|
804
|
-
rules: ".clinerules/",
|
|
805
|
-
legacy_rules: ".clinerules",
|
|
806
|
-
skills: ".agents/skills/"
|
|
807
|
-
}, {
|
|
808
|
-
skills: "~/.agents/skills/",
|
|
809
|
-
settings: "~/.cline/data/settings/cline_mcp_settings.json"
|
|
810
|
-
}, "instruction-only"),
|
|
811
|
-
def("roo", "Roo Code", ["instructions", "skills", "rules", "mcp"], {
|
|
812
|
-
instructions: "AGENTS.md",
|
|
813
|
-
rules: ".roomodes",
|
|
814
|
-
skills: ".roo/skills/",
|
|
815
|
-
mcp: ".roo/mcp.json"
|
|
816
|
-
}, {
|
|
817
|
-
skills: "~/.roo/skills/",
|
|
818
|
-
settings: "~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json"
|
|
819
|
-
}),
|
|
820
|
-
def("continue", "Continue", ["instructions", "skills", "mcp"], {
|
|
821
|
-
instructions: "AGENTS.md",
|
|
822
|
-
skills: ".continue/skills/",
|
|
823
|
-
mcp: ".continue/mcp.json"
|
|
824
|
-
}, {
|
|
825
|
-
skills: "~/.continue/skills/"
|
|
826
|
-
}),
|
|
827
|
-
def("goose", "Goose", ["instructions", "skills", "mcp", "hooks", "commands"], {
|
|
828
|
-
instructions: "AGENTS.md",
|
|
829
|
-
skills: ".agents/skills/",
|
|
830
|
-
commands: "recipes/",
|
|
831
|
-
mcp: ".config/goose/config.yaml",
|
|
832
|
-
pathAlternates: {
|
|
833
|
-
instructions: [".goosehints"],
|
|
834
|
-
skills: [".goose/skills/"]
|
|
835
|
-
}
|
|
836
|
-
}, {
|
|
837
|
-
instructions: "~/.config/goose/.goosehints",
|
|
838
|
-
skills: "~/.agents/skills/",
|
|
839
|
-
settings: "~/.config/goose/config.yaml",
|
|
840
|
-
plugins: "~/.agents/plugins/"
|
|
841
|
-
}),
|
|
842
|
-
def("trae", "Trae", ["instructions", "skills", "rules", "mcp"], {
|
|
843
|
-
instructions: "AGENTS.md",
|
|
844
|
-
rules: ".traerules",
|
|
845
|
-
skills: ".trae/skills/",
|
|
846
|
-
mcp: ".trae/mcp.json"
|
|
847
|
-
}, {
|
|
848
|
-
skills: "~/.trae/skills/"
|
|
849
|
-
}),
|
|
850
|
-
def("openhands", "OpenHands", ["instructions", "skills", "mcp"], {
|
|
851
|
-
instructions: "AGENTS.md",
|
|
852
|
-
skills: ".openhands/skills/"
|
|
853
|
-
}, {
|
|
854
|
-
skills: "~/.openhands/skills/",
|
|
855
|
-
settings: "~/.openhands/mcp.json"
|
|
856
|
-
}),
|
|
857
|
-
def("kiro", "Kiro", ["instructions", "skills", "rules"], {
|
|
858
|
-
instructions: "AGENTS.md",
|
|
859
|
-
rules: ".kiro/steering/",
|
|
860
|
-
skills: ".agents/skills/"
|
|
861
|
-
}, {
|
|
862
|
-
skills: "~/.kiro/skills/"
|
|
863
|
-
}, "instruction-only"),
|
|
864
|
-
// Pi extensions install via `pi install git:...`, not plugin apply.
|
|
865
|
-
// HarnessTap can scan `.agents/skills/` but cannot materialize pi-extension/index.js.
|
|
866
|
-
def("pi", "Pi", ["instructions", "skills"], {
|
|
867
|
-
instructions: "AGENTS.md",
|
|
868
|
-
skills: ".agents/skills/"
|
|
869
|
-
}, {}),
|
|
870
|
-
// Google Antigravity (IDE / CLI / AGY) share the same workspace layout.
|
|
871
|
-
def("antigravity", "Antigravity", [
|
|
872
|
-
"instructions",
|
|
873
|
-
"skills",
|
|
874
|
-
"rules",
|
|
875
|
-
"mcp",
|
|
876
|
-
"commands"
|
|
877
|
-
], {
|
|
878
|
-
instructions: "AGENTS.md",
|
|
879
|
-
rules: ".agents/rules/",
|
|
880
|
-
skills: ".agents/skills/",
|
|
881
|
-
commands: ".agents/workflows/",
|
|
882
|
-
mcp: ".agents/mcp_config.json",
|
|
883
|
-
pathAlternates: {
|
|
884
|
-
instructions: ["GEMINI.md"]
|
|
885
|
-
}
|
|
886
|
-
}, {
|
|
887
|
-
instructions: "~/.gemini/GEMINI.md",
|
|
888
|
-
skills: "~/.gemini/skills/",
|
|
889
|
-
commands: "~/.gemini/config/global_workflows/",
|
|
890
|
-
settings: "~/.gemini/config/mcp_config.json"
|
|
891
|
-
}),
|
|
892
|
-
def("amazon-q", "Amazon Q Developer", ["instructions", "rules", "mcp"], {
|
|
893
|
-
instructions: "AmazonQ.md",
|
|
894
|
-
rules: ".amazonq/rules/",
|
|
895
|
-
mcp: ".amazonq/mcp.json",
|
|
896
|
-
pathAlternates: {
|
|
897
|
-
instructions: ["AGENTS.md"]
|
|
898
|
-
}
|
|
899
|
-
}, {
|
|
900
|
-
settings: "~/.aws/amazonq/mcp.json"
|
|
901
|
-
}),
|
|
902
|
-
def("aider", "Aider", ["instructions"], {
|
|
903
|
-
instructions: "CONVENTIONS.md",
|
|
904
|
-
settings: ".aider.conf.yml",
|
|
905
|
-
pathAlternates: {
|
|
906
|
-
instructions: ["AGENTS.md"]
|
|
907
|
-
}
|
|
908
|
-
}, {
|
|
909
|
-
settings: "~/.aider.conf.yml"
|
|
910
|
-
}),
|
|
911
|
-
def("zed", "Zed", ["instructions", "skills"], {
|
|
912
|
-
instructions: "AGENTS.md",
|
|
913
|
-
skills: ".agents/skills/",
|
|
914
|
-
pathAlternates: {
|
|
915
|
-
instructions: [".rules"]
|
|
916
|
-
}
|
|
917
|
-
}, {
|
|
918
|
-
instructions: "~/.config/zed/AGENTS.md",
|
|
919
|
-
skills: "~/.agents/skills/"
|
|
920
|
-
}),
|
|
921
|
-
def("devin", "Devin", ["instructions", "skills"], {
|
|
922
|
-
instructions: "AGENTS.md",
|
|
923
|
-
skills: ".agents/skills/",
|
|
924
|
-
settings: ".devin/config.json",
|
|
925
|
-
pathAlternates: {
|
|
926
|
-
instructions: ["AGENTS.local.md", "AGENT.md"]
|
|
927
|
-
}
|
|
928
|
-
}, {
|
|
929
|
-
instructions: "~/.config/devin/AGENTS.md",
|
|
930
|
-
skills: "~/.agents/skills/",
|
|
931
|
-
settings: "~/.config/devin/config.json"
|
|
932
|
-
}),
|
|
933
|
-
def("jules", "Jules", ["instructions", "skills"], {
|
|
934
|
-
instructions: "AGENTS.md",
|
|
935
|
-
skills: ".agents/skills/",
|
|
936
|
-
pathAlternates: {
|
|
937
|
-
instructions: ["JULES.md"]
|
|
938
|
-
}
|
|
939
|
-
}, {
|
|
940
|
-
skills: "~/.agents/skills/"
|
|
941
|
-
}, {
|
|
942
|
-
detectionPaths: {
|
|
943
|
-
project: ["JULES.md"],
|
|
944
|
-
global: ["~/.jules", "~/JULES.md"]
|
|
945
|
-
}
|
|
946
|
-
}),
|
|
947
|
-
def("cody", "Sourcegraph Cody", ["instructions", "mcp"], {
|
|
948
|
-
instructions: "AGENTS.md",
|
|
949
|
-
settings: "cody.json"
|
|
950
|
-
}, {
|
|
951
|
-
settings: "~/.config/sourcegraph/cody.json"
|
|
952
|
-
}),
|
|
953
|
-
def("grok-build", "Grok Build", [
|
|
954
|
-
"instructions",
|
|
955
|
-
"skills",
|
|
956
|
-
"mcp",
|
|
957
|
-
"permissions",
|
|
958
|
-
"hooks",
|
|
959
|
-
"agents",
|
|
960
|
-
"commands",
|
|
961
|
-
"model_config"
|
|
962
|
-
], {
|
|
963
|
-
instructions: "AGENTS.md",
|
|
964
|
-
skills: ".grok/skills/",
|
|
965
|
-
agents: ".grok/agents/",
|
|
966
|
-
hooks: ".grok/hooks/",
|
|
967
|
-
commands: ".agents/commands/",
|
|
968
|
-
mcp: ".grok/config.toml",
|
|
969
|
-
permissions: ".grok/config.toml",
|
|
970
|
-
settings: ".grok/config.toml",
|
|
971
|
-
pathAlternates: {
|
|
972
|
-
instructions: ["AGENT.md", "Agents.md"],
|
|
973
|
-
skills: [".agents/skills/"]
|
|
974
|
-
}
|
|
975
|
-
}, {
|
|
976
|
-
skills: "~/.grok/skills/",
|
|
977
|
-
agents: "~/.grok/agents/",
|
|
978
|
-
hooks: "~/.grok/hooks/",
|
|
979
|
-
commands: "~/.agents/commands/",
|
|
980
|
-
settings: "~/.grok/config.toml",
|
|
981
|
-
pathAlternates: {
|
|
982
|
-
skills: ["~/.agents/skills/"]
|
|
983
|
-
}
|
|
984
|
-
}, {
|
|
985
|
-
relatedLocations: [
|
|
986
|
-
{ path: "~/.claude/skills/", surfaces: ["skills"] }
|
|
987
|
-
]
|
|
988
|
-
}),
|
|
989
|
-
def("deepseek-harness", "DeepSeek Harness", [
|
|
990
|
-
"instructions",
|
|
991
|
-
"skills",
|
|
992
|
-
"mcp",
|
|
993
|
-
"permissions",
|
|
994
|
-
"hooks",
|
|
995
|
-
"agents",
|
|
996
|
-
"model_config"
|
|
997
|
-
], {
|
|
998
|
-
instructions: "AGENTS.md",
|
|
999
|
-
skills: ".dsh/skills/",
|
|
1000
|
-
hooks: ".dsh/hooks/",
|
|
1001
|
-
pathAlternates: {
|
|
1002
|
-
skills: [".agents/skills/"]
|
|
1003
|
-
}
|
|
1004
|
-
}, {
|
|
1005
|
-
instructions: "~/.dsh/AGENTS.md",
|
|
1006
|
-
skills: "~/.dsh/skills/",
|
|
1007
|
-
hooks: "~/.dsh/hooks/",
|
|
1008
|
-
mcp: "~/.dsh/cordis.patch.yml",
|
|
1009
|
-
settings: "~/.dsh/settings.yaml",
|
|
1010
|
-
agents: "~/.dsh/.agent-presets/",
|
|
1011
|
-
plugins: "~/.dsh/profiles/web/"
|
|
1012
|
-
}),
|
|
1013
|
-
def("muse-code", "Muse Code", ["instructions", "skills", "mcp", "hooks"], {
|
|
1014
|
-
instructions: "AGENTS.md",
|
|
1015
|
-
skills: ".agents/skills/",
|
|
1016
|
-
hooks: ".muse/hooks.json"
|
|
1017
|
-
}, {
|
|
1018
|
-
settings: "~/.config/muse/settings.json",
|
|
1019
|
-
mcp: "~/.config/muse/settings.json",
|
|
1020
|
-
skills: "~/.config/muse/skills/",
|
|
1021
|
-
pathAlternates: {
|
|
1022
|
-
settings: ["~/.config/muse/"]
|
|
1023
|
-
}
|
|
1024
|
-
}, {
|
|
1025
|
-
relatedLocations: [
|
|
1026
|
-
{ path: "~/.agents/skills/", surfaces: ["skills"] },
|
|
1027
|
-
{ path: "~/.claude/skills/", surfaces: ["skills"] },
|
|
1028
|
-
{ path: "~/.codex/skills/", surfaces: ["skills"] }
|
|
1029
|
-
]
|
|
1030
|
-
}),
|
|
1031
|
-
def("minimax-code", "MiniMax Code", ["instructions", "skills", "mcp"], {
|
|
1032
|
-
instructions: "AGENTS.md",
|
|
1033
|
-
skills: ".minimax/skills/",
|
|
1034
|
-
plugins: ".minimax-plugin/",
|
|
1035
|
-
pathAlternates: {
|
|
1036
|
-
skills: [".agents/skills/"]
|
|
1037
|
-
}
|
|
1038
|
-
}, {
|
|
1039
|
-
settings: "~/.minimax/config.yaml",
|
|
1040
|
-
mcp: "~/.minimax/mcp.json",
|
|
1041
|
-
skills: "~/.minimax/skills/",
|
|
1042
|
-
plugins: "~/.minimax/plugins/",
|
|
1043
|
-
pathAlternates: {
|
|
1044
|
-
settings: ["~/.minimax/", "~/.mavis/"]
|
|
1045
|
-
}
|
|
1046
|
-
}, {
|
|
1047
|
-
relatedLocations: [
|
|
1048
|
-
{ path: "~/.agents/skills/", surfaces: ["skills"] },
|
|
1049
|
-
{ path: "~/.claude/skills/", surfaces: ["skills"] },
|
|
1050
|
-
{ path: "~/.codex/skills/", surfaces: ["skills"] }
|
|
1051
|
-
]
|
|
1052
|
-
}),
|
|
1053
|
-
// ── .agents/ convention platforms (skills + instructions) ───────────
|
|
1054
|
-
...[
|
|
1055
|
-
["amp", "Amp", ".agents/skills/", "~/.config/agents/skills/"],
|
|
1056
|
-
["kilo", "Kilo Code", ".kilocode/skills/", "~/.kilocode/skills/"],
|
|
1057
|
-
["augment", "Augment", ".augment/skills/", "~/.augment/skills/"],
|
|
1058
|
-
["firebender", "Firebender", ".agents/skills/", "~/.firebender/skills/"],
|
|
1059
|
-
["junie", "Junie", ".junie/skills/", "~/.junie/skills/"],
|
|
1060
|
-
["zencoder", "Zencoder", ".zencoder/skills/", "~/.zencoder/skills/"],
|
|
1061
|
-
["deepagents", "Deep Agents", ".agents/skills/", "~/.deepagents/agent/skills/"],
|
|
1062
|
-
["qwen-code", "Qwen Code", ".qwen/skills/", "~/.qwen/skills/"],
|
|
1063
|
-
["crush", "Crush", ".crush/skills/", "~/.config/crush/skills/"],
|
|
1064
|
-
["droid", "Droid", ".factory/skills/", "~/.factory/skills/"],
|
|
1065
|
-
["codebuddy", "CodeBuddy", ".codebuddy/skills/", "~/.codebuddy/skills/"],
|
|
1066
|
-
["mux", "Mux", ".mux/skills/", "~/.mux/skills/"],
|
|
1067
|
-
["kode", "Kode", ".kode/skills/", "~/.kode/skills/"],
|
|
1068
|
-
["command-code", "Command Code", ".commandcode/skills/", "~/.commandcode/skills/"],
|
|
1069
|
-
["cortex", "Cortex Code", ".cortex/skills/", "~/.snowflake/cortex/skills/"],
|
|
1070
|
-
["neovate", "Neovate", ".neovate/skills/", "~/.neovate/skills/"]
|
|
1071
|
-
].map(
|
|
1072
|
-
([id, name, projSkills, globalSkills]) => def(id, name, ["instructions", "skills"], {
|
|
1073
|
-
instructions: "AGENTS.md",
|
|
1074
|
-
skills: projSkills
|
|
1075
|
-
}, {
|
|
1076
|
-
skills: globalSkills
|
|
1077
|
-
})
|
|
1078
|
-
)
|
|
1079
|
-
];
|
|
1080
|
-
var platformMap = new Map(
|
|
1081
|
-
PLATFORMS.map((p) => [p.id, p])
|
|
1082
|
-
);
|
|
1083
|
-
function getPlatform(id) {
|
|
1084
|
-
return platformMap.get(id);
|
|
1085
|
-
}
|
|
1086
|
-
function getAllPlatforms() {
|
|
1087
|
-
return [...PLATFORMS];
|
|
1088
|
-
}
|
|
1089
|
-
function getPlatformIds() {
|
|
1090
|
-
return PLATFORMS.map((p) => p.id);
|
|
1091
|
-
}
|
|
1092
|
-
var RESOURCE_CLASSES = {
|
|
1093
|
-
skill: "set",
|
|
1094
|
-
rule: "set",
|
|
1095
|
-
agent: "set",
|
|
1096
|
-
command: "set",
|
|
1097
|
-
hook: "set",
|
|
1098
|
-
mcp_server: "set",
|
|
1099
|
-
instruction: "singleton",
|
|
1100
|
-
model_config: "singleton",
|
|
1101
|
-
permission: "singleton",
|
|
1102
|
-
env_var: "singleton"
|
|
1103
|
-
};
|
|
1104
|
-
function resourceClass(type) {
|
|
1105
|
-
return RESOURCE_CLASSES[type];
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
// src/utils/home-root.ts
|
|
1109
|
-
import { homedir as homedir2 } from "os";
|
|
1110
|
-
var homeRootOverride;
|
|
1111
|
-
function resolveHomeRoot() {
|
|
1112
|
-
if (homeRootOverride) return homeRootOverride;
|
|
1113
|
-
return process.env.HOME ?? process.env.USERPROFILE ?? homedir2();
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
// src/services/active-profile.ts
|
|
1117
|
-
import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync4, rmSync, writeFileSync } from "fs";
|
|
1118
|
-
import { join as join4 } from "path";
|
|
1119
|
-
function getActiveProfilePath() {
|
|
1120
|
-
return join4(getHarnesstapDir(), "active-profile.json");
|
|
1121
|
-
}
|
|
1122
|
-
function getActiveProfileName() {
|
|
1123
|
-
const filePath = getActiveProfilePath();
|
|
1124
|
-
if (!existsSync4(filePath)) {
|
|
1125
|
-
return void 0;
|
|
1126
|
-
}
|
|
1127
|
-
try {
|
|
1128
|
-
const parsed = JSON.parse(readFileSync4(filePath, "utf-8"));
|
|
1129
|
-
if (typeof parsed.name === "string" && parsed.name.length > 0) {
|
|
1130
|
-
if (parsed.name.trim() === "empty") {
|
|
1131
|
-
return void 0;
|
|
1132
|
-
}
|
|
1133
|
-
return parsed.name;
|
|
1134
|
-
}
|
|
1135
|
-
} catch {
|
|
1136
|
-
return void 0;
|
|
1137
|
-
}
|
|
1138
|
-
return void 0;
|
|
1139
|
-
}
|
|
1140
|
-
function setActiveProfileName(name) {
|
|
1141
|
-
const home = getHarnesstapDir();
|
|
1142
|
-
mkdirSync(home, { recursive: true });
|
|
1143
|
-
writeFileSync(
|
|
1144
|
-
getActiveProfilePath(),
|
|
1145
|
-
`${JSON.stringify({ name }, null, 2)}
|
|
1146
|
-
`,
|
|
1147
|
-
"utf-8"
|
|
1148
|
-
);
|
|
1149
|
-
}
|
|
1150
|
-
function clearActiveProfileName() {
|
|
1151
|
-
rmSync(getActiveProfilePath(), { force: true });
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
// src/services/global-profile-status-panel.ts
|
|
1155
|
-
import { existsSync as existsSync9, readFileSync as readFileSync8 } from "fs";
|
|
1156
|
-
import { join as join11, resolve as resolve2 } from "path";
|
|
1157
|
-
|
|
1158
|
-
// src/plugins/claude-plugin-ref.ts
|
|
1159
|
-
import { join as join6 } from "path";
|
|
1160
|
-
|
|
1161
|
-
// src/plugins/claude-installed.ts
|
|
1162
|
-
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
1163
|
-
import { dirname, join as join5 } from "path";
|
|
1164
|
-
|
|
1165
|
-
// src/plugins/host-plugin-pins.ts
|
|
1166
|
-
import { existsSync as existsSync5 } from "fs";
|
|
1167
|
-
function hasInstallPath(install) {
|
|
1168
|
-
if (!install.installPath) return false;
|
|
1169
|
-
return existsSync5(install.installPath);
|
|
1170
|
-
}
|
|
1171
|
-
function pluginInstallToPinInput(install, source) {
|
|
1172
|
-
const { name, marketplace } = parsePluginRef(install.ref);
|
|
1173
|
-
const metadata = {
|
|
1174
|
-
source_kind: marketplace && marketplace !== "local" ? "marketplace" : "local",
|
|
1175
|
-
...marketplace && marketplace !== "local" ? { marketplace_name: marketplace } : {},
|
|
1176
|
-
...install.version && install.version !== "unknown" ? { resolved_version: install.version } : {},
|
|
1177
|
-
sync_status: "never_synced",
|
|
1178
|
-
portable: "reference"
|
|
1179
|
-
};
|
|
1180
|
-
return {
|
|
1181
|
-
type: "plugin",
|
|
1182
|
-
name: install.name || name,
|
|
1183
|
-
namespace: marketplace,
|
|
1184
|
-
description: install.metadata?.description?.trim() || `Plugin pin: ${install.ref}`,
|
|
1185
|
-
content: "{}",
|
|
1186
|
-
metadata,
|
|
1187
|
-
source,
|
|
1188
|
-
origin_kind: marketplace && marketplace !== "local" ? "marketplace_link" : "manual",
|
|
1189
|
-
origin_ref: install.ref
|
|
1190
|
-
};
|
|
1191
|
-
}
|
|
1192
|
-
function preferPluginInstall(current, candidate) {
|
|
1193
|
-
if (!current) {
|
|
1194
|
-
return true;
|
|
1195
|
-
}
|
|
1196
|
-
if (candidate.enabled && !current.enabled) {
|
|
1197
|
-
return true;
|
|
1198
|
-
}
|
|
1199
|
-
if (!candidate.enabled && current.enabled) {
|
|
1200
|
-
return false;
|
|
1201
|
-
}
|
|
1202
|
-
if (candidate.scope === "user" && current.scope !== "user") {
|
|
1203
|
-
return true;
|
|
1204
|
-
}
|
|
1205
|
-
return false;
|
|
1206
|
-
}
|
|
1207
|
-
function dedupePluginInstalls(installs) {
|
|
1208
|
-
const byRef = /* @__PURE__ */ new Map();
|
|
1209
|
-
for (const install of installs) {
|
|
1210
|
-
const current = byRef.get(install.ref);
|
|
1211
|
-
if (preferPluginInstall(current, install)) {
|
|
1212
|
-
byRef.set(install.ref, install);
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
return [...byRef.values()].sort(
|
|
1216
|
-
(left, right) => left.ref.localeCompare(right.ref)
|
|
1217
|
-
);
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
// src/plugins/claude-installed.ts
|
|
1221
|
-
function claudePluginsDir(homeRoot) {
|
|
1222
|
-
return join5(homeRoot, ".claude", "plugins");
|
|
1223
|
-
}
|
|
1224
|
-
function readManifestVersion(installPath) {
|
|
1225
|
-
const manifest = readFirstHostPluginManifest(installPath);
|
|
1226
|
-
if (!manifest) {
|
|
1227
|
-
return { version: "unknown", versionSource: "unknown" };
|
|
1228
|
-
}
|
|
1229
|
-
const metadata = {
|
|
1230
|
-
description: manifest.description,
|
|
1231
|
-
repository: manifest.repository,
|
|
1232
|
-
homepage: manifest.homepage
|
|
1233
|
-
};
|
|
1234
|
-
if (manifest.version) {
|
|
1235
|
-
return {
|
|
1236
|
-
version: manifest.version,
|
|
1237
|
-
versionSource: "manifest",
|
|
1238
|
-
metadata
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
return { version: "unknown", versionSource: "unknown", metadata };
|
|
1242
|
-
}
|
|
1243
|
-
function resolveInstalledRecordPath(homeRoot, record) {
|
|
1244
|
-
return record.installPath.startsWith("/") ? record.installPath : join5(claudePluginsDir(homeRoot), record.installPath);
|
|
1245
|
-
}
|
|
1246
|
-
function readInstalledPluginsFile(homeRoot) {
|
|
1247
|
-
const path = join5(claudePluginsDir(homeRoot), "installed_plugins.json");
|
|
1248
|
-
return readJsonFile(path);
|
|
1249
|
-
}
|
|
1250
|
-
function readInstalledPluginsFileShared(homeRoot) {
|
|
1251
|
-
return computationSlot(`claude-installed-file:${homeRoot}`, () => readInstalledPluginsFile(homeRoot));
|
|
1252
|
-
}
|
|
1253
|
-
function getInstalledPluginRecord(homeRoot, ref) {
|
|
1254
|
-
const file = readInstalledPluginsFileShared(homeRoot);
|
|
1255
|
-
const record = file?.plugins[ref]?.[0];
|
|
1256
|
-
return record ? { ...record } : null;
|
|
1257
|
-
}
|
|
1258
|
-
function getInstalledPluginInstallPath(homeRoot, ref, candidateRefs) {
|
|
1259
|
-
const file = readInstalledPluginsFileShared(homeRoot);
|
|
1260
|
-
if (!file?.plugins) {
|
|
1261
|
-
return null;
|
|
1262
|
-
}
|
|
1263
|
-
const refs = candidateRefs?.length ? candidateRefs : [ref];
|
|
1264
|
-
for (const candidate of refs) {
|
|
1265
|
-
const record = file.plugins[candidate]?.[0];
|
|
1266
|
-
if (!record?.installPath) {
|
|
1267
|
-
continue;
|
|
1268
|
-
}
|
|
1269
|
-
return resolveInstalledRecordPath(homeRoot, record);
|
|
1270
|
-
}
|
|
1271
|
-
return null;
|
|
1272
|
-
}
|
|
1273
|
-
function loadInstalledShared(homeRoot) {
|
|
1274
|
-
return computationSlot(
|
|
1275
|
-
`claude-installed:${homeRoot}`,
|
|
1276
|
-
() => traceSpan("scan.claude.installed-plugins", () => loadInstalledUncached(homeRoot), "~/.claude/plugins/installed_plugins.json")
|
|
1277
|
-
);
|
|
1278
|
-
}
|
|
1279
|
-
function listInstalledRefScopes(homeRoot) {
|
|
1280
|
-
return loadInstalledShared(homeRoot);
|
|
1281
|
-
}
|
|
1282
|
-
function loadInstalled(homeRoot) {
|
|
1283
|
-
return loadInstalledShared(homeRoot).map((install) => ({
|
|
1284
|
-
...install,
|
|
1285
|
-
...install.metadata ? { metadata: { ...install.metadata } } : {}
|
|
1286
|
-
}));
|
|
1287
|
-
}
|
|
1288
|
-
function loadInstalledUncached(homeRoot) {
|
|
1289
|
-
const path = join5(claudePluginsDir(homeRoot), "installed_plugins.json");
|
|
1290
|
-
const file = readJsonFile(path);
|
|
1291
|
-
if (!file?.plugins) return [];
|
|
1292
|
-
const installs = [];
|
|
1293
|
-
for (const [ref, records] of Object.entries(file.plugins)) {
|
|
1294
|
-
for (const record of records) {
|
|
1295
|
-
const resolvedPath = resolveInstalledRecordPath(homeRoot, record);
|
|
1296
|
-
const manifest = record.installPath ? readManifestVersion(resolvedPath) : { version: record.version, versionSource: "unknown" };
|
|
1297
|
-
const version = manifest.version !== "unknown" ? manifest.version : record.version;
|
|
1298
|
-
installs.push({
|
|
1299
|
-
ref,
|
|
1300
|
-
platformId: "claude-code",
|
|
1301
|
-
name: parsePluginRef(ref).name,
|
|
1302
|
-
version,
|
|
1303
|
-
versionSource: record.gitCommitSha && version === record.version ? "git_sha" : manifest.versionSource,
|
|
1304
|
-
scope: record.scope,
|
|
1305
|
-
enabled: true,
|
|
1306
|
-
installPath: resolvedPath,
|
|
1307
|
-
metadata: manifest.metadata
|
|
1308
|
-
});
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
return installs;
|
|
1312
|
-
}
|
|
1313
|
-
function listInstalledPluginPinCreateInputs(homeRoot) {
|
|
1314
|
-
return dedupePluginInstalls(loadInstalled(homeRoot)).filter(hasInstallPath).map(
|
|
1315
|
-
(install) => pluginInstallToPinInput(
|
|
1316
|
-
install,
|
|
1317
|
-
"~/.claude/plugins/installed_plugins.json"
|
|
1318
|
-
)
|
|
1319
|
-
);
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
// src/plugins/claude-plugin-ref.ts
|
|
1323
|
-
var CATALOG_AUTHOR_MARKETPLACES = {
|
|
1324
|
-
anthropics: ["claude-plugins-official"],
|
|
1325
|
-
obra: ["claude-plugins-official", "superpowers-dev"],
|
|
1326
|
-
"multica-ai": ["karpathy-skills"]
|
|
1327
|
-
};
|
|
1328
|
-
var CATALOG_PLUGIN_INSTALL_HINTS = {
|
|
1329
|
-
superpowers: {
|
|
1330
|
-
installRefs: ["superpowers@claude-plugins-official", "superpowers@superpowers-dev"]
|
|
1331
|
-
},
|
|
1332
|
-
context7: {
|
|
1333
|
-
installRefs: ["context7@claude-plugins-official"]
|
|
1334
|
-
},
|
|
1335
|
-
"security-guidance": {
|
|
1336
|
-
installRefs: ["security-guidance@claude-plugins-official"]
|
|
1337
|
-
},
|
|
1338
|
-
"andrej-karpathy-skills": {
|
|
1339
|
-
installRefs: ["andrej-karpathy-skills@karpathy-skills"],
|
|
1340
|
-
marketplaces: [
|
|
1341
|
-
{ name: "karpathy-skills", repo: "forrestchang/andrej-karpathy-skills" }
|
|
1342
|
-
]
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
var DEFAULT_MARKETPLACES = ["claude-plugins-official"];
|
|
1346
|
-
function marketplaceManifestPath(homeRoot, marketplace) {
|
|
1347
|
-
return join6(
|
|
1348
|
-
claudePluginsDir(homeRoot),
|
|
1349
|
-
"marketplaces",
|
|
1350
|
-
marketplace,
|
|
1351
|
-
".claude-plugin",
|
|
1352
|
-
"marketplace.json"
|
|
1353
|
-
);
|
|
1354
|
-
}
|
|
1355
|
-
function marketplaceIsConfigured(homeRoot, marketplace) {
|
|
1356
|
-
return existsSync(marketplaceManifestPath(homeRoot, marketplace));
|
|
1357
|
-
}
|
|
1358
|
-
function marketplaceHasPlugin(homeRoot, marketplace, pluginName) {
|
|
1359
|
-
const path = marketplaceManifestPath(homeRoot, marketplace);
|
|
1360
|
-
const names = computationSlot(
|
|
1361
|
-
`marketplace-names:${path}`,
|
|
1362
|
-
() => traceSpan("scan.claude.marketplace-manifests", () => readCachedMarketplacePluginNames(path), marketplace)
|
|
1363
|
-
);
|
|
1364
|
-
return names?.has(pluginName) ?? false;
|
|
1365
|
-
}
|
|
1366
|
-
function listConfiguredMarketplaceNames(homeRoot) {
|
|
1367
|
-
return [
|
|
1368
|
-
...computationSlot(`claude-marketplaces:${homeRoot}`, () => listConfiguredMarketplaceNamesUncached(homeRoot))
|
|
1369
|
-
];
|
|
1370
|
-
}
|
|
1371
|
-
function listConfiguredMarketplaceNamesUncached(homeRoot) {
|
|
1372
|
-
const root = join6(claudePluginsDir(homeRoot), "marketplaces");
|
|
1373
|
-
if (!existsSync(root)) {
|
|
1374
|
-
return [];
|
|
1375
|
-
}
|
|
1376
|
-
return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
1377
|
-
}
|
|
1378
|
-
function addCandidate(ordered, seen, candidate) {
|
|
1379
|
-
if (seen.has(candidate)) {
|
|
1380
|
-
return;
|
|
1381
|
-
}
|
|
1382
|
-
seen.add(candidate);
|
|
1383
|
-
ordered.push(candidate);
|
|
1384
|
-
}
|
|
1385
|
-
function resolveClaudeInstallRefCandidates(ref, homeRoot) {
|
|
1386
|
-
const { name, marketplace } = parsePluginRef(ref);
|
|
1387
|
-
const ordered = [];
|
|
1388
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1389
|
-
const hint = CATALOG_PLUGIN_INSTALL_HINTS[name];
|
|
1390
|
-
for (const candidate of hint?.installRefs ?? []) {
|
|
1391
|
-
addCandidate(ordered, seen, candidate);
|
|
1392
|
-
}
|
|
1393
|
-
addCandidate(ordered, seen, ref);
|
|
1394
|
-
if (marketplace) {
|
|
1395
|
-
for (const alias of CATALOG_AUTHOR_MARKETPLACES[marketplace] ?? DEFAULT_MARKETPLACES) {
|
|
1396
|
-
addCandidate(ordered, seen, `${name}@${alias}`);
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
for (const localMarketplace of listConfiguredMarketplaceNames(homeRoot)) {
|
|
1400
|
-
if (marketplaceHasPlugin(homeRoot, localMarketplace, name)) {
|
|
1401
|
-
addCandidate(ordered, seen, `${name}@${localMarketplace}`);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
return ordered;
|
|
1405
|
-
}
|
|
1406
|
-
function resolveCatalogPluginMarketplaceBootstrap(ref) {
|
|
1407
|
-
const { name } = parsePluginRef(ref);
|
|
1408
|
-
return CATALOG_PLUGIN_INSTALL_HINTS[name]?.marketplaces ?? [];
|
|
1409
|
-
}
|
|
1410
|
-
function resolveClaudeEnabledPluginRef(ref, homeRoot) {
|
|
1411
|
-
const candidates = resolveClaudeInstallRefCandidates(ref, homeRoot);
|
|
1412
|
-
const installed = listInstalledRefScopes(homeRoot);
|
|
1413
|
-
for (const candidate of candidates) {
|
|
1414
|
-
if (installed.some((row) => row.ref === candidate)) {
|
|
1415
|
-
return candidate;
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
return candidates[0] ?? ref;
|
|
1419
|
-
}
|
|
1420
|
-
function findInstalledRefForCatalogPin(ref, homeRoot, scope) {
|
|
1421
|
-
const candidates = resolveClaudeInstallRefCandidates(ref, homeRoot);
|
|
1422
|
-
const installed = listInstalledRefScopes(homeRoot);
|
|
1423
|
-
for (const candidate of candidates) {
|
|
1424
|
-
const match = installed.find(
|
|
1425
|
-
(row) => row.ref === candidate && (scope === void 0 || row.scope === scope)
|
|
1426
|
-
);
|
|
1427
|
-
if (match) {
|
|
1428
|
-
return candidate;
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
return void 0;
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
// src/plugins/providers/cursor.ts
|
|
1435
|
-
import { join as join8 } from "path";
|
|
1436
|
-
|
|
1437
|
-
// src/plugins/refresh-cache.ts
|
|
1438
|
-
import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
1439
|
-
import { join as join7 } from "path";
|
|
1440
|
-
function markSourceRefreshed(cache, sourceKey, at = /* @__PURE__ */ new Date()) {
|
|
1441
|
-
return {
|
|
1442
|
-
sources: {
|
|
1443
|
-
...cache.sources,
|
|
1444
|
-
[sourceKey]: { lastRefreshedAt: at.toISOString() }
|
|
1445
|
-
}
|
|
1446
|
-
};
|
|
1447
|
-
}
|
|
1448
|
-
function isSourceStale(cache, sourceKey, maxAgeHours, now = /* @__PURE__ */ new Date()) {
|
|
1449
|
-
const entry = cache.sources[sourceKey];
|
|
1450
|
-
if (!entry?.lastRefreshedAt) return true;
|
|
1451
|
-
const refreshed = new Date(entry.lastRefreshedAt);
|
|
1452
|
-
const ageMs = now.getTime() - refreshed.getTime();
|
|
1453
|
-
return ageMs > maxAgeHours * 60 * 60 * 1e3;
|
|
1454
|
-
}
|
|
1455
|
-
function getSourcesToRefresh(sourceKeys, cache, maxAgeHours, forceRefresh, now = /* @__PURE__ */ new Date()) {
|
|
1456
|
-
if (forceRefresh) return [...sourceKeys];
|
|
1457
|
-
return sourceKeys.filter((key) => isSourceStale(cache, key, maxAgeHours, now));
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
// src/plugins/providers/cursor.ts
|
|
1461
|
-
var CursorPluginProvider = class {
|
|
1462
|
-
constructor(deps = {}) {
|
|
1463
|
-
this.deps = deps;
|
|
1464
|
-
}
|
|
1465
|
-
platformId = "cursor";
|
|
1466
|
-
capabilities = {
|
|
1467
|
-
inventory: true,
|
|
1468
|
-
check: true,
|
|
1469
|
-
update: true,
|
|
1470
|
-
install: true,
|
|
1471
|
-
updateMethod: "git",
|
|
1472
|
-
installMethod: "unsupported"
|
|
1473
|
-
};
|
|
1474
|
-
async list(ctx) {
|
|
1475
|
-
return listCursorPluginInstalls(ctx.homeRoot);
|
|
1476
|
-
}
|
|
1477
|
-
async check(ctx, opts) {
|
|
1478
|
-
const installs = listCursorPluginInstalls(ctx.homeRoot);
|
|
1479
|
-
const results = [];
|
|
1480
|
-
for (const install of installs) {
|
|
1481
|
-
if (opts.scopes && !opts.scopes.includes(install.scope)) continue;
|
|
1482
|
-
const repo = install.metadata?.repository;
|
|
1483
|
-
if (!repo) {
|
|
1484
|
-
results.push({
|
|
1485
|
-
...install,
|
|
1486
|
-
status: "unknown",
|
|
1487
|
-
message: "No repository URL; update via Cursor IDE",
|
|
1488
|
-
refreshSkipped: true
|
|
1489
|
-
});
|
|
1490
|
-
continue;
|
|
1491
|
-
}
|
|
1492
|
-
const sourceKey = cursorRepoSourceKey(repo);
|
|
1493
|
-
const shouldRefresh = getSourcesToRefresh(
|
|
1494
|
-
[sourceKey],
|
|
1495
|
-
opts.refreshCache,
|
|
1496
|
-
opts.maxAgeHours,
|
|
1497
|
-
opts.forceRefresh
|
|
1498
|
-
).includes(sourceKey);
|
|
1499
|
-
let latestVersion;
|
|
1500
|
-
if (shouldRefresh) {
|
|
1501
|
-
const tmpParent = join8(ctx.harnesstapDir, "tmp-refresh");
|
|
1502
|
-
const refresh = await refreshGitSource({
|
|
1503
|
-
url: repo,
|
|
1504
|
-
targetDir: join8(tmpParent, install.name),
|
|
1505
|
-
runCommand: this.deps.runCommand
|
|
1506
|
-
});
|
|
1507
|
-
if (refresh.ok && refresh.sha) {
|
|
1508
|
-
latestVersion = refresh.sha.slice(0, 12);
|
|
1509
|
-
Object.assign(
|
|
1510
|
-
opts.refreshCache,
|
|
1511
|
-
markSourceRefreshed(opts.refreshCache, sourceKey)
|
|
1512
|
-
);
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
const installedHash = install.installPath?.split("/").pop();
|
|
1516
|
-
const status = latestVersion && installedHash ? latestVersion === installedHash.slice(0, 12) || installedHash.startsWith(latestVersion) ? "current" : "outdated" : "unknown";
|
|
1517
|
-
results.push({
|
|
1518
|
-
...install,
|
|
1519
|
-
status,
|
|
1520
|
-
latestVersion,
|
|
1521
|
-
latestSource: sourceKey,
|
|
1522
|
-
refreshSkipped: !shouldRefresh
|
|
1523
|
-
});
|
|
1524
|
-
}
|
|
1525
|
-
return results;
|
|
1526
|
-
}
|
|
1527
|
-
async update(ctx, opts) {
|
|
1528
|
-
const installs = listCursorPluginInstalls(ctx.homeRoot);
|
|
1529
|
-
const targets = opts.ref ? installs.filter((i) => i.ref === opts.ref) : installs;
|
|
1530
|
-
const results = [];
|
|
1531
|
-
for (const install of targets) {
|
|
1532
|
-
const repo = install.metadata?.repository;
|
|
1533
|
-
if (!repo) {
|
|
1534
|
-
results.push({
|
|
1535
|
-
ref: install.ref,
|
|
1536
|
-
platformId: this.platformId,
|
|
1537
|
-
scope: install.scope,
|
|
1538
|
-
status: "unsupported",
|
|
1539
|
-
message: "No repository URL; update via Cursor IDE"
|
|
1540
|
-
});
|
|
1541
|
-
continue;
|
|
1542
|
-
}
|
|
1543
|
-
if (!install.installPath) {
|
|
1544
|
-
results.push({
|
|
1545
|
-
ref: install.ref,
|
|
1546
|
-
platformId: this.platformId,
|
|
1547
|
-
scope: install.scope,
|
|
1548
|
-
status: "failed",
|
|
1549
|
-
message: "Missing install path"
|
|
1550
|
-
});
|
|
1551
|
-
continue;
|
|
1552
|
-
}
|
|
1553
|
-
const parent = join8(install.installPath, "..");
|
|
1554
|
-
const refresh = await refreshGitSource({
|
|
1555
|
-
url: repo,
|
|
1556
|
-
targetDir: join8(parent, ".refresh-staging"),
|
|
1557
|
-
runCommand: this.deps.runCommand
|
|
1558
|
-
});
|
|
1559
|
-
if (!refresh.ok || !refresh.sha) {
|
|
1560
|
-
results.push({
|
|
1561
|
-
ref: install.ref,
|
|
1562
|
-
platformId: this.platformId,
|
|
1563
|
-
scope: install.scope,
|
|
1564
|
-
status: "failed",
|
|
1565
|
-
previousVersion: install.version,
|
|
1566
|
-
message: refresh.message
|
|
1567
|
-
});
|
|
1568
|
-
continue;
|
|
1569
|
-
}
|
|
1570
|
-
const newDir = join8(parent, refresh.sha.slice(0, 12));
|
|
1571
|
-
const staging = join8(parent, ".refresh-staging");
|
|
1572
|
-
const move = await resolveCommandResult(
|
|
1573
|
-
(this.deps.runCommand ?? defaultRunCommand)("mv", [staging, newDir])
|
|
1574
|
-
);
|
|
1575
|
-
if (move.exitCode !== 0) {
|
|
1576
|
-
results.push({
|
|
1577
|
-
ref: install.ref,
|
|
1578
|
-
platformId: this.platformId,
|
|
1579
|
-
scope: install.scope,
|
|
1580
|
-
status: "failed",
|
|
1581
|
-
message: move.stderr.trim() || "Failed to move refreshed plugin"
|
|
1582
|
-
});
|
|
1583
|
-
continue;
|
|
1584
|
-
}
|
|
1585
|
-
results.push({
|
|
1586
|
-
ref: install.ref,
|
|
1587
|
-
platformId: this.platformId,
|
|
1588
|
-
scope: install.scope,
|
|
1589
|
-
status: "updated",
|
|
1590
|
-
previousVersion: install.version,
|
|
1591
|
-
newVersion: refresh.sha.slice(0, 12),
|
|
1592
|
-
message: "Refreshed from git repository"
|
|
1593
|
-
});
|
|
1594
|
-
}
|
|
1595
|
-
return results;
|
|
1596
|
-
}
|
|
1597
|
-
async install(ctx, opts) {
|
|
1598
|
-
const { installCursorLocalPlugin } = await import("./cursor-local-install-46RWRBDT.js");
|
|
1599
|
-
return installCursorLocalPlugin(ctx, opts);
|
|
1600
|
-
}
|
|
1601
|
-
};
|
|
1602
|
-
|
|
1603
|
-
// src/models/global-apply-snapshot.ts
|
|
1604
|
-
import { ulid } from "ulid";
|
|
1605
|
-
function parseState(raw) {
|
|
1606
|
-
if (!raw || raw === "{}") {
|
|
1607
|
-
return void 0;
|
|
1608
|
-
}
|
|
1609
|
-
try {
|
|
1610
|
-
return JSON.parse(raw);
|
|
1611
|
-
} catch {
|
|
1612
|
-
return void 0;
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
function rowToGlobalApplySnapshot(row) {
|
|
1616
|
-
const state = parseState(row.state);
|
|
1617
|
-
return {
|
|
1618
|
-
id: row.id,
|
|
1619
|
-
profile_name: row.profile_name,
|
|
1620
|
-
plugin_ids: JSON.parse(row.plugin_ids),
|
|
1621
|
-
resolved_set: JSON.parse(row.resolved_set ?? "[]"),
|
|
1622
|
-
created_at: row.created_at,
|
|
1623
|
-
...state ? { state } : {}
|
|
1624
|
-
};
|
|
1625
|
-
}
|
|
1626
|
-
function rowToGlobalApplySnapshotInstall(row) {
|
|
1627
|
-
return {
|
|
1628
|
-
...row,
|
|
1629
|
-
files: JSON.parse(row.files)
|
|
1630
|
-
};
|
|
1631
|
-
}
|
|
1632
|
-
function createGlobalApplySnapshot(input) {
|
|
1633
|
-
const db = getDb();
|
|
1634
|
-
const snapshot = {
|
|
1635
|
-
id: ulid(),
|
|
1636
|
-
profile_name: input.profile_name,
|
|
1637
|
-
plugin_ids: input.plugin_ids,
|
|
1638
|
-
resolved_set: input.resolved_set ?? [],
|
|
1639
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1640
|
-
...input.state ? { state: input.state } : {}
|
|
1641
|
-
};
|
|
1642
|
-
db.prepare(
|
|
1643
|
-
`INSERT INTO global_apply_snapshots (id, profile_name, plugin_ids, resolved_set, created_at, state)
|
|
1644
|
-
VALUES (?, ?, ?, ?, ?, ?)`
|
|
1645
|
-
).run(
|
|
1646
|
-
snapshot.id,
|
|
1647
|
-
snapshot.profile_name,
|
|
1648
|
-
JSON.stringify(snapshot.plugin_ids),
|
|
1649
|
-
JSON.stringify(snapshot.resolved_set),
|
|
1650
|
-
snapshot.created_at,
|
|
1651
|
-
JSON.stringify(input.state ?? {})
|
|
1652
|
-
);
|
|
1653
|
-
return snapshot;
|
|
1654
|
-
}
|
|
1655
|
-
function recordGlobalApplySnapshotInstall(input) {
|
|
1656
|
-
const db = getDb();
|
|
1657
|
-
const install = {
|
|
1658
|
-
...input,
|
|
1659
|
-
installed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1660
|
-
};
|
|
1661
|
-
db.prepare(
|
|
1662
|
-
`INSERT INTO global_apply_snapshot_installs (
|
|
1663
|
-
snapshot_id,
|
|
1664
|
-
platform_id,
|
|
1665
|
-
files,
|
|
1666
|
-
installed_at
|
|
1667
|
-
) VALUES (?, ?, ?, ?)
|
|
1668
|
-
ON CONFLICT(snapshot_id, platform_id) DO UPDATE SET
|
|
1669
|
-
files = excluded.files,
|
|
1670
|
-
installed_at = excluded.installed_at`
|
|
1671
|
-
).run(
|
|
1672
|
-
install.snapshot_id,
|
|
1673
|
-
install.platform_id,
|
|
1674
|
-
JSON.stringify(install.files),
|
|
1675
|
-
install.installed_at
|
|
1676
|
-
);
|
|
1677
|
-
return install;
|
|
1678
|
-
}
|
|
1679
|
-
function getGlobalApplySnapshot(snapshotId) {
|
|
1680
|
-
const db = getDb();
|
|
1681
|
-
const row = db.prepare("SELECT * FROM global_apply_snapshots WHERE id = ?").get(snapshotId);
|
|
1682
|
-
return row ? rowToGlobalApplySnapshot(row) : void 0;
|
|
1683
|
-
}
|
|
1684
|
-
function listGlobalApplySnapshots() {
|
|
1685
|
-
const db = getDb();
|
|
1686
|
-
const rows = db.prepare("SELECT * FROM global_apply_snapshots ORDER BY created_at DESC, id DESC").all();
|
|
1687
|
-
return rows.map(rowToGlobalApplySnapshot);
|
|
1688
|
-
}
|
|
1689
|
-
function getLatestGlobalApplySnapshotForProfile(profileName) {
|
|
1690
|
-
return computationSlot(`latest-global-apply-snapshot:${profileName}`, () => {
|
|
1691
|
-
const head = getDb().prepare(
|
|
1692
|
-
`SELECT id FROM global_apply_snapshots WHERE profile_name = ?
|
|
1693
|
-
ORDER BY created_at DESC, id DESC LIMIT 1`
|
|
1694
|
-
).get(profileName);
|
|
1695
|
-
if (!head) return void 0;
|
|
1696
|
-
const parsed = parsedSnapshotById.get(head.id);
|
|
1697
|
-
if (parsed) {
|
|
1698
|
-
parsedSnapshotById.delete(head.id);
|
|
1699
|
-
parsedSnapshotById.set(head.id, parsed);
|
|
1700
|
-
return { ...parsed, profile_name: profileName };
|
|
1701
|
-
}
|
|
1702
|
-
const snapshot = getGlobalApplySnapshot(head.id);
|
|
1703
|
-
if (!snapshot) return void 0;
|
|
1704
|
-
parsedSnapshotById.set(head.id, snapshot);
|
|
1705
|
-
if (parsedSnapshotById.size > PARSED_SNAPSHOT_CACHE_MAX) {
|
|
1706
|
-
const oldest = parsedSnapshotById.keys().next().value;
|
|
1707
|
-
if (oldest !== void 0) parsedSnapshotById.delete(oldest);
|
|
1708
|
-
}
|
|
1709
|
-
return { ...snapshot };
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
var PARSED_SNAPSHOT_CACHE_MAX = 8;
|
|
1713
|
-
var parsedSnapshotById = /* @__PURE__ */ new Map();
|
|
1714
|
-
function listGlobalApplySnapshotHeads() {
|
|
1715
|
-
return computationSlot("global-apply-snapshot-heads", () => getDb().prepare(
|
|
1716
|
-
`SELECT id, profile_name FROM global_apply_snapshots
|
|
1717
|
-
ORDER BY created_at DESC, id DESC`
|
|
1718
|
-
).all());
|
|
1719
|
-
}
|
|
1720
|
-
function renameGlobalApplySnapshotsProfile(oldName, newName) {
|
|
1721
|
-
const db = getDb();
|
|
1722
|
-
const result = db.prepare(
|
|
1723
|
-
`UPDATE global_apply_snapshots SET profile_name = ? WHERE profile_name = ?`
|
|
1724
|
-
).run(newName, oldName);
|
|
1725
|
-
return result.changes;
|
|
1726
|
-
}
|
|
1727
|
-
function listGlobalApplySnapshotInstalls(snapshotId) {
|
|
1728
|
-
const db = getDb();
|
|
1729
|
-
const rows = db.prepare(
|
|
1730
|
-
`SELECT snapshot_id, platform_id, files, installed_at
|
|
1731
|
-
FROM global_apply_snapshot_installs
|
|
1732
|
-
WHERE snapshot_id = ?
|
|
1733
|
-
ORDER BY installed_at DESC, platform_id ASC`
|
|
1734
|
-
).all(snapshotId);
|
|
1735
|
-
return rows.map(rowToGlobalApplySnapshotInstall);
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
|
-
// src/models/project.ts
|
|
1739
|
-
import { resolve } from "path";
|
|
1740
|
-
import { ulid as ulid2 } from "ulid";
|
|
1741
|
-
function createProject(input) {
|
|
1742
|
-
const db = getDb();
|
|
1743
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1744
|
-
const id = ulid2();
|
|
1745
|
-
db.prepare(
|
|
1746
|
-
`INSERT INTO projects (id, git_origin, name, local_path, created_at)
|
|
1747
|
-
VALUES (?, ?, ?, ?, ?)`
|
|
1748
|
-
).run(id, input.git_origin, input.name, input.local_path, now);
|
|
1749
|
-
return { id, ...input, created_at: now };
|
|
1750
|
-
}
|
|
1751
|
-
function getProjectByOrigin(gitOrigin) {
|
|
1752
|
-
const db = getDb();
|
|
1753
|
-
return db.prepare("SELECT * FROM projects WHERE git_origin = ?").get(gitOrigin);
|
|
1754
|
-
}
|
|
1755
|
-
function getProject(id) {
|
|
1756
|
-
const db = getDb();
|
|
1757
|
-
return db.prepare("SELECT * FROM projects WHERE id = ?").get(id);
|
|
1758
|
-
}
|
|
1759
|
-
function upsertProject(input) {
|
|
1760
|
-
const existing = getProjectByOrigin(input.git_origin);
|
|
1761
|
-
if (existing) {
|
|
1762
|
-
const db = getDb();
|
|
1763
|
-
db.prepare("UPDATE projects SET local_path = ?, name = ? WHERE id = ?").run(
|
|
1764
|
-
input.local_path,
|
|
1765
|
-
input.name,
|
|
1766
|
-
existing.id
|
|
1767
|
-
);
|
|
1768
|
-
return { ...existing, local_path: input.local_path, name: input.name };
|
|
1769
|
-
}
|
|
1770
|
-
return createProject(input);
|
|
1771
|
-
}
|
|
1772
|
-
function listProjects() {
|
|
1773
|
-
const db = getDb();
|
|
1774
|
-
return db.prepare("SELECT * FROM projects ORDER BY name").all();
|
|
1775
|
-
}
|
|
1776
|
-
function getProjectByLocalPath(localPath) {
|
|
1777
|
-
const normalized = resolve(localPath);
|
|
1778
|
-
return listProjects().find((project) => resolve(project.local_path) === normalized);
|
|
1779
|
-
}
|
|
1780
|
-
function applyPluginToProject(input) {
|
|
1781
|
-
const db = getDb();
|
|
1782
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1783
|
-
db.prepare(
|
|
1784
|
-
`INSERT OR REPLACE INTO project_plugins (project_id, plugin_id, platforms, applied_at)
|
|
1785
|
-
VALUES (?, ?, ?, ?)`
|
|
1786
|
-
).run(input.project_id, input.plugin_id, JSON.stringify(input.platforms), now);
|
|
1787
|
-
}
|
|
1788
|
-
function applyConfiguredPluginToProject(input) {
|
|
1789
|
-
applyPluginToProject({
|
|
1790
|
-
project_id: input.project_id,
|
|
1791
|
-
plugin_id: input.configured_plugin_id,
|
|
1792
|
-
platforms: input.platforms
|
|
1793
|
-
});
|
|
1794
|
-
}
|
|
1795
|
-
function getProjectPlugins(projectId) {
|
|
1796
|
-
const db = getDb();
|
|
1797
|
-
const rows = db.prepare(
|
|
1798
|
-
"SELECT * FROM project_plugins WHERE project_id = ? ORDER BY applied_at DESC"
|
|
1799
|
-
).all(projectId);
|
|
1800
|
-
return rows.map((row) => ({
|
|
1801
|
-
...row,
|
|
1802
|
-
platforms: JSON.parse(row.platforms)
|
|
1803
|
-
}));
|
|
1804
|
-
}
|
|
1805
|
-
function getProjectConfiguredPlugins(projectId) {
|
|
1806
|
-
return getProjectPlugins(projectId);
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
// src/models/snapshot.ts
|
|
1810
|
-
import { ulid as ulid3 } from "ulid";
|
|
1811
|
-
function rowToSnapshot(row) {
|
|
1812
|
-
return {
|
|
1813
|
-
...row,
|
|
1814
|
-
state: JSON.parse(row.state)
|
|
1815
|
-
};
|
|
1816
|
-
}
|
|
1817
|
-
function createSnapshot(input) {
|
|
1818
|
-
const db = getDb();
|
|
1819
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1820
|
-
const id = ulid3();
|
|
1821
|
-
db.prepare(
|
|
1822
|
-
`INSERT INTO snapshots (id, project_id, label, state, created_at)
|
|
1823
|
-
VALUES (?, ?, ?, ?, ?)`
|
|
1824
|
-
).run(id, input.project_id, input.label, JSON.stringify(input.state), now);
|
|
1825
|
-
return { id, ...input, created_at: now };
|
|
1826
|
-
}
|
|
1827
|
-
function getSnapshot(id) {
|
|
1828
|
-
const db = getDb();
|
|
1829
|
-
const row = db.prepare("SELECT * FROM snapshots WHERE id = ?").get(id);
|
|
1830
|
-
return row ? rowToSnapshot(row) : void 0;
|
|
1831
|
-
}
|
|
1832
|
-
function findSnapshotById(id, minPrefix = 8) {
|
|
1833
|
-
const exact = getSnapshot(id);
|
|
1834
|
-
if (exact) {
|
|
1835
|
-
return exact;
|
|
1836
|
-
}
|
|
1837
|
-
if (id.length < minPrefix) {
|
|
1838
|
-
return void 0;
|
|
1839
|
-
}
|
|
1840
|
-
const db = getDb();
|
|
1841
|
-
const rows = db.prepare("SELECT * FROM snapshots WHERE id LIKE ?").all(`${id}%`);
|
|
1842
|
-
if (rows.length !== 1) {
|
|
1843
|
-
return void 0;
|
|
1844
|
-
}
|
|
1845
|
-
const row = rows[0];
|
|
1846
|
-
return row ? rowToSnapshot(row) : void 0;
|
|
1847
|
-
}
|
|
1848
|
-
function listSnapshots(projectId) {
|
|
1849
|
-
const db = getDb();
|
|
1850
|
-
const rows = db.prepare("SELECT * FROM snapshots WHERE project_id = ? ORDER BY created_at DESC").all(projectId);
|
|
1851
|
-
return rows.map(rowToSnapshot);
|
|
1852
|
-
}
|
|
1853
|
-
function getLatestSnapshot(projectId) {
|
|
1854
|
-
const snapshots = listSnapshots(projectId);
|
|
1855
|
-
return snapshots[0];
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
// src/services/git.ts
|
|
1859
|
-
import { execSync } from "child_process";
|
|
1860
|
-
import { basename } from "path";
|
|
1861
|
-
function getGitOrigin(projectRoot) {
|
|
1862
|
-
try {
|
|
1863
|
-
const url = execSync("git config --get remote.origin.url", {
|
|
1864
|
-
cwd: projectRoot,
|
|
1865
|
-
encoding: "utf-8",
|
|
1866
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
1867
|
-
}).trim();
|
|
1868
|
-
return url || void 0;
|
|
1869
|
-
} catch {
|
|
1870
|
-
return void 0;
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
function normalizeGitUrl(url) {
|
|
1874
|
-
let normalized = url.trim();
|
|
1875
|
-
if (normalized.startsWith("git@")) {
|
|
1876
|
-
return normalized;
|
|
1877
|
-
}
|
|
1878
|
-
if (normalized.endsWith(".git")) {
|
|
1879
|
-
normalized = normalized.slice(0, -4);
|
|
1880
|
-
}
|
|
1881
|
-
return normalized;
|
|
1882
|
-
}
|
|
1883
|
-
function projectNameFromUrl(url) {
|
|
1884
|
-
const sshMatch = url.match(/:([^/]+\/[^/]+?)(?:\.git)?$/);
|
|
1885
|
-
if (sshMatch?.[1]) return sshMatch[1];
|
|
1886
|
-
try {
|
|
1887
|
-
const parsed = new URL(url);
|
|
1888
|
-
const path = parsed.pathname.replace(/^\//, "").replace(/\.git$/, "");
|
|
1889
|
-
return path || basename(url);
|
|
1890
|
-
} catch {
|
|
1891
|
-
return basename(url).replace(/\.git$/, "");
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
// src/services/host-native-mcp.ts
|
|
1896
|
-
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "fs";
|
|
1897
|
-
import { join as join9 } from "path";
|
|
1898
|
-
|
|
1899
|
-
// src/services/environment-var-substitution.ts
|
|
1900
|
-
var VAR_PATTERN = /\$\{([A-Z_][A-Z0-9_]*)\}/g;
|
|
1901
|
-
function uniqueSorted(values) {
|
|
1902
|
-
return [...new Set(values)].sort();
|
|
1903
|
-
}
|
|
1904
|
-
function substituteEnvironmentVars(template, vars) {
|
|
1905
|
-
const missing = /* @__PURE__ */ new Set();
|
|
1906
|
-
const value = template.replace(VAR_PATTERN, (match, key) => {
|
|
1907
|
-
if (Object.hasOwn(vars, key)) {
|
|
1908
|
-
const resolved = vars[key];
|
|
1909
|
-
if (resolved !== void 0) {
|
|
1910
|
-
return resolved;
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
missing.add(key);
|
|
1914
|
-
return match;
|
|
1915
|
-
});
|
|
1916
|
-
return { value, missing: uniqueSorted(missing) };
|
|
1917
|
-
}
|
|
1918
|
-
function collectEnvironmentVarPlaceholders(template) {
|
|
1919
|
-
return substituteEnvironmentVars(template, {}).missing;
|
|
1920
|
-
}
|
|
1921
|
-
function substituteResourceMetadata(resource, vars) {
|
|
1922
|
-
switch (resource.type) {
|
|
1923
|
-
case "mcp_server": {
|
|
1924
|
-
const { metadata, missing } = substituteMcpServerMetadata(
|
|
1925
|
-
resource.metadata,
|
|
1926
|
-
vars
|
|
1927
|
-
);
|
|
1928
|
-
return {
|
|
1929
|
-
resource: { ...resource, metadata },
|
|
1930
|
-
missing
|
|
1931
|
-
};
|
|
1932
|
-
}
|
|
1933
|
-
default:
|
|
1934
|
-
return { resource, missing: [] };
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
function substituteResourcesForApply(resources, vars) {
|
|
1938
|
-
const missing = /* @__PURE__ */ new Set();
|
|
1939
|
-
const substitutedResources = resources.map((resource) => {
|
|
1940
|
-
if (resource.type !== "mcp_server") {
|
|
1941
|
-
return resource;
|
|
1942
|
-
}
|
|
1943
|
-
const { resource: updated, missing: resourceMissing } = substituteResourceMetadata(
|
|
1944
|
-
resource,
|
|
1945
|
-
vars
|
|
1946
|
-
);
|
|
1947
|
-
for (const key of resourceMissing) {
|
|
1948
|
-
missing.add(key);
|
|
1949
|
-
}
|
|
1950
|
-
return { ...resource, metadata: updated.metadata };
|
|
1951
|
-
});
|
|
1952
|
-
return {
|
|
1953
|
-
resources: substitutedResources,
|
|
1954
|
-
missing: uniqueSorted(missing)
|
|
1955
|
-
};
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
// src/services/mcp-config-bridge.ts
|
|
1959
|
-
function isRecord(value) {
|
|
1960
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1961
|
-
}
|
|
1962
|
-
function uniqueSorted2(values) {
|
|
1963
|
-
return [...new Set(values)].sort();
|
|
1964
|
-
}
|
|
1965
|
-
function parseStringRecord(value) {
|
|
1966
|
-
if (!isRecord(value)) {
|
|
1967
|
-
return void 0;
|
|
1968
|
-
}
|
|
1969
|
-
const result = {};
|
|
1970
|
-
for (const [key, entryValue] of Object.entries(value)) {
|
|
1971
|
-
if (typeof entryValue === "string") {
|
|
1972
|
-
result[key] = entryValue;
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
return Object.keys(result).length > 0 ? result : void 0;
|
|
1976
|
-
}
|
|
1977
|
-
function parseAuthMetadata(value) {
|
|
1978
|
-
if (!isRecord(value)) {
|
|
1979
|
-
return void 0;
|
|
1980
|
-
}
|
|
1981
|
-
const auth = {};
|
|
1982
|
-
if (typeof value.CLIENT_ID === "string") {
|
|
1983
|
-
auth.CLIENT_ID = value.CLIENT_ID;
|
|
1984
|
-
}
|
|
1985
|
-
if (typeof value.CLIENT_SECRET === "string") {
|
|
1986
|
-
auth.CLIENT_SECRET = value.CLIENT_SECRET;
|
|
1987
|
-
}
|
|
1988
|
-
if (Array.isArray(value.scopes)) {
|
|
1989
|
-
const scopes = value.scopes.filter((scope) => typeof scope === "string");
|
|
1990
|
-
if (scopes.length > 0) {
|
|
1991
|
-
auth.scopes = scopes;
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
return Object.keys(auth).length > 0 ? auth : void 0;
|
|
1995
|
-
}
|
|
1996
|
-
function inferMcpTransport(entry) {
|
|
1997
|
-
const typeValue = entry.type ?? entry.transport;
|
|
1998
|
-
if (typeof typeValue === "string") {
|
|
1999
|
-
const normalized = typeValue.toLowerCase();
|
|
2000
|
-
if (normalized === "http" || normalized === "remote" || normalized === "sse" || normalized === "streamable_http" || normalized === "streamable-http") {
|
|
2001
|
-
return "http";
|
|
2002
|
-
}
|
|
2003
|
-
if (normalized === "stdio") {
|
|
2004
|
-
return "stdio";
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
if (entry.protocol === "sse") {
|
|
2008
|
-
return "http";
|
|
2009
|
-
}
|
|
2010
|
-
if (typeof entry.url === "string" || typeof entry.uri === "string") {
|
|
2011
|
-
return "http";
|
|
2012
|
-
}
|
|
2013
|
-
return "stdio";
|
|
2014
|
-
}
|
|
2015
|
-
function parseMcpServerEntry(entry) {
|
|
2016
|
-
if (!isRecord(entry)) {
|
|
2017
|
-
return null;
|
|
2018
|
-
}
|
|
2019
|
-
const transport = inferMcpTransport(entry);
|
|
2020
|
-
let command;
|
|
2021
|
-
let args;
|
|
2022
|
-
const rawCommand = entry.command ?? entry.cmd;
|
|
2023
|
-
if (Array.isArray(rawCommand)) {
|
|
2024
|
-
command = typeof rawCommand[0] === "string" ? rawCommand[0] : void 0;
|
|
2025
|
-
args = rawCommand.slice(1).filter((arg) => typeof arg === "string");
|
|
2026
|
-
} else if (typeof rawCommand === "string") {
|
|
2027
|
-
command = rawCommand;
|
|
2028
|
-
}
|
|
2029
|
-
if (Array.isArray(entry.args)) {
|
|
2030
|
-
args = entry.args.filter((arg) => typeof arg === "string");
|
|
2031
|
-
}
|
|
2032
|
-
const url = typeof entry.url === "string" ? entry.url : typeof entry.uri === "string" ? entry.uri : void 0;
|
|
2033
|
-
const env = parseStringRecord(entry.env ?? entry.envs ?? entry.environment);
|
|
2034
|
-
const headers = parseStringRecord(entry.headers);
|
|
2035
|
-
const auth = parseAuthMetadata(entry.auth);
|
|
2036
|
-
const rawType = typeof entry.type === "string" ? entry.type : void 0;
|
|
2037
|
-
const http_transport = rawType === "streamable-http" || rawType === "sse" ? rawType : void 0;
|
|
2038
|
-
const connection_type = rawType;
|
|
2039
|
-
const cwd = typeof entry.cwd === "string" ? entry.cwd : void 0;
|
|
2040
|
-
const env_file = typeof entry.envFile === "string" ? entry.envFile : typeof entry.env_file === "string" ? entry.env_file : void 0;
|
|
2041
|
-
return {
|
|
2042
|
-
transport,
|
|
2043
|
-
...command !== void 0 ? { command } : {},
|
|
2044
|
-
...url !== void 0 ? { url } : {},
|
|
2045
|
-
...args !== void 0 && args.length > 0 ? { args } : {},
|
|
2046
|
-
...env !== void 0 ? { env } : {},
|
|
2047
|
-
...headers !== void 0 ? { headers } : {},
|
|
2048
|
-
...http_transport !== void 0 ? { http_transport } : {},
|
|
2049
|
-
...cwd !== void 0 ? { cwd } : {},
|
|
2050
|
-
...connection_type !== void 0 ? { connection_type } : {},
|
|
2051
|
-
...env_file !== void 0 ? { env_file } : {},
|
|
2052
|
-
...auth !== void 0 ? { auth } : {}
|
|
2053
|
-
};
|
|
2054
|
-
}
|
|
2055
|
-
function parseMcpServersDocument(document) {
|
|
2056
|
-
if (!isRecord(document)) {
|
|
2057
|
-
return {};
|
|
2058
|
-
}
|
|
2059
|
-
const serversRaw = document.mcpServers ?? document.mcp_servers ?? document.mcp;
|
|
2060
|
-
if (!isRecord(serversRaw)) {
|
|
2061
|
-
return {};
|
|
2062
|
-
}
|
|
2063
|
-
const isAgentPluginsMcp = document.$schema === AP_MCP_SCHEMA_URL;
|
|
2064
|
-
const result = {};
|
|
2065
|
-
for (const [name, serverEntry] of Object.entries(serversRaw)) {
|
|
2066
|
-
const metadata = parseMcpServerEntry(serverEntry);
|
|
2067
|
-
if (metadata) {
|
|
2068
|
-
if (isAgentPluginsMcp && metadata.connection_type !== "sse") {
|
|
2069
|
-
delete metadata.connection_type;
|
|
2070
|
-
}
|
|
2071
|
-
result[name] = metadata;
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
return result;
|
|
2075
|
-
}
|
|
2076
|
-
function mcpServerEquivalenceKey(metadata) {
|
|
2077
|
-
return JSON.stringify({
|
|
2078
|
-
transport: metadata.transport,
|
|
2079
|
-
command: metadata.command ?? null,
|
|
2080
|
-
url: metadata.url ?? null,
|
|
2081
|
-
args: metadata.args ?? null,
|
|
2082
|
-
env: metadata.env ?? null,
|
|
2083
|
-
headers: metadata.headers ?? null,
|
|
2084
|
-
env_file: metadata.env_file ?? null,
|
|
2085
|
-
auth: metadata.auth ?? null
|
|
2086
|
-
});
|
|
2087
|
-
}
|
|
2088
|
-
function mcpServerMetadataEquivalent(left, right) {
|
|
2089
|
-
return mcpServerEquivalenceKey(left) === mcpServerEquivalenceKey(right);
|
|
2090
|
-
}
|
|
2091
|
-
function mcpConfigContentsEquivalent(left, right) {
|
|
2092
|
-
let leftDocument;
|
|
2093
|
-
let rightDocument;
|
|
2094
|
-
try {
|
|
2095
|
-
leftDocument = JSON.parse(left);
|
|
2096
|
-
rightDocument = JSON.parse(right);
|
|
2097
|
-
} catch {
|
|
2098
|
-
return false;
|
|
2099
|
-
}
|
|
2100
|
-
const leftServers = parseMcpServersDocument(leftDocument);
|
|
2101
|
-
const rightServers = parseMcpServersDocument(rightDocument);
|
|
2102
|
-
const leftNames = Object.keys(leftServers).sort();
|
|
2103
|
-
const rightNames = Object.keys(rightServers).sort();
|
|
2104
|
-
if (leftNames.length !== rightNames.length) {
|
|
2105
|
-
return false;
|
|
2106
|
-
}
|
|
2107
|
-
for (let index = 0; index < leftNames.length; index += 1) {
|
|
2108
|
-
const name = leftNames[index];
|
|
2109
|
-
const otherName = rightNames[index];
|
|
2110
|
-
if (name === void 0 || otherName === void 0 || name !== otherName) {
|
|
2111
|
-
return false;
|
|
2112
|
-
}
|
|
2113
|
-
const leftMeta = leftServers[name];
|
|
2114
|
-
const rightMeta = rightServers[name];
|
|
2115
|
-
if (!leftMeta || !rightMeta || !mcpServerMetadataEquivalent(leftMeta, rightMeta)) {
|
|
2116
|
-
return false;
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
return true;
|
|
2120
|
-
}
|
|
2121
|
-
function substituteMcpServerMetadata(metadata, vars) {
|
|
2122
|
-
const missing = /* @__PURE__ */ new Set();
|
|
2123
|
-
const substituteString = (template) => {
|
|
2124
|
-
if (template === void 0) {
|
|
2125
|
-
return void 0;
|
|
2126
|
-
}
|
|
2127
|
-
const substituted = substituteEnvironmentVars(template, vars);
|
|
2128
|
-
for (const key of substituted.missing) {
|
|
2129
|
-
missing.add(key);
|
|
2130
|
-
}
|
|
2131
|
-
return substituted.value;
|
|
2132
|
-
};
|
|
2133
|
-
const command = substituteString(metadata.command);
|
|
2134
|
-
let args = metadata.args;
|
|
2135
|
-
if (args !== void 0) {
|
|
2136
|
-
args = args.map((arg) => {
|
|
2137
|
-
const substituted = substituteEnvironmentVars(arg, vars);
|
|
2138
|
-
for (const key of substituted.missing) {
|
|
2139
|
-
missing.add(key);
|
|
2140
|
-
}
|
|
2141
|
-
return substituted.value;
|
|
2142
|
-
});
|
|
2143
|
-
}
|
|
2144
|
-
const url = substituteString(metadata.url);
|
|
2145
|
-
let env = metadata.env;
|
|
2146
|
-
if (env !== void 0) {
|
|
2147
|
-
env = Object.fromEntries(
|
|
2148
|
-
Object.entries(env).map(([envKey, envValue]) => {
|
|
2149
|
-
const substituted = substituteEnvironmentVars(envValue, vars);
|
|
2150
|
-
for (const key of substituted.missing) {
|
|
2151
|
-
missing.add(key);
|
|
2152
|
-
}
|
|
2153
|
-
return [envKey, substituted.value];
|
|
2154
|
-
})
|
|
2155
|
-
);
|
|
2156
|
-
}
|
|
2157
|
-
let headers = metadata.headers;
|
|
2158
|
-
if (headers !== void 0) {
|
|
2159
|
-
headers = Object.fromEntries(
|
|
2160
|
-
Object.entries(headers).map(([headerKey, headerValue]) => {
|
|
2161
|
-
const substituted = substituteEnvironmentVars(headerValue, vars);
|
|
2162
|
-
for (const key of substituted.missing) {
|
|
2163
|
-
missing.add(key);
|
|
2164
|
-
}
|
|
2165
|
-
return [headerKey, substituted.value];
|
|
2166
|
-
})
|
|
2167
|
-
);
|
|
2168
|
-
}
|
|
2169
|
-
let auth = metadata.auth;
|
|
2170
|
-
if (auth !== void 0) {
|
|
2171
|
-
const clientId = substituteString(auth.CLIENT_ID);
|
|
2172
|
-
const clientSecret = substituteString(auth.CLIENT_SECRET);
|
|
2173
|
-
auth = {
|
|
2174
|
-
...clientId !== void 0 ? { CLIENT_ID: clientId } : {},
|
|
2175
|
-
...clientSecret !== void 0 ? { CLIENT_SECRET: clientSecret } : {},
|
|
2176
|
-
...auth.scopes !== void 0 ? { scopes: auth.scopes } : {}
|
|
2177
|
-
};
|
|
2178
|
-
}
|
|
2179
|
-
return {
|
|
2180
|
-
metadata: {
|
|
2181
|
-
...metadata,
|
|
2182
|
-
...command !== void 0 ? { command } : {},
|
|
2183
|
-
...url !== void 0 ? { url } : {},
|
|
2184
|
-
...args !== void 0 ? { args } : {},
|
|
2185
|
-
...env !== void 0 ? { env } : {},
|
|
2186
|
-
...headers !== void 0 ? { headers } : {},
|
|
2187
|
-
...auth !== void 0 ? { auth } : {}
|
|
2188
|
-
},
|
|
2189
|
-
missing: uniqueSorted2(missing)
|
|
2190
|
-
};
|
|
2191
|
-
}
|
|
2192
|
-
function emitCursorMcpServerEntry(metadata) {
|
|
2193
|
-
const entry = {};
|
|
2194
|
-
if (metadata.transport === "http" || metadata.url) {
|
|
2195
|
-
if (metadata.url !== void 0) {
|
|
2196
|
-
entry.url = metadata.url;
|
|
2197
|
-
}
|
|
2198
|
-
if (metadata.headers !== void 0 && Object.keys(metadata.headers).length > 0) {
|
|
2199
|
-
entry.headers = metadata.headers;
|
|
2200
|
-
}
|
|
2201
|
-
if (metadata.auth !== void 0) {
|
|
2202
|
-
const auth = {};
|
|
2203
|
-
if (metadata.auth.CLIENT_ID !== void 0) {
|
|
2204
|
-
auth.CLIENT_ID = metadata.auth.CLIENT_ID;
|
|
2205
|
-
}
|
|
2206
|
-
if (metadata.auth.CLIENT_SECRET !== void 0) {
|
|
2207
|
-
auth.CLIENT_SECRET = metadata.auth.CLIENT_SECRET;
|
|
2208
|
-
}
|
|
2209
|
-
if (metadata.auth.scopes !== void 0 && metadata.auth.scopes.length > 0) {
|
|
2210
|
-
auth.scopes = metadata.auth.scopes;
|
|
2211
|
-
}
|
|
2212
|
-
if (Object.keys(auth).length > 0) {
|
|
2213
|
-
entry.auth = auth;
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
return entry;
|
|
2217
|
-
}
|
|
2218
|
-
entry.type = "stdio";
|
|
2219
|
-
if (metadata.command !== void 0) {
|
|
2220
|
-
entry.command = metadata.command;
|
|
2221
|
-
}
|
|
2222
|
-
if (metadata.args !== void 0 && metadata.args.length > 0) {
|
|
2223
|
-
entry.args = metadata.args;
|
|
2224
|
-
}
|
|
2225
|
-
if (metadata.env !== void 0 && Object.keys(metadata.env).length > 0) {
|
|
2226
|
-
entry.env = metadata.env;
|
|
2227
|
-
}
|
|
2228
|
-
if (metadata.env_file !== void 0) {
|
|
2229
|
-
entry.envFile = metadata.env_file;
|
|
2230
|
-
}
|
|
2231
|
-
return entry;
|
|
2232
|
-
}
|
|
2233
|
-
|
|
2234
|
-
// src/services/host-native-mcp.ts
|
|
2235
|
-
var PLUGIN_MCP_FILES = ["mcp.json", ".mcp.json"];
|
|
2236
|
-
function mcpNamesFromInstallPath(installPath) {
|
|
2237
|
-
const names = [];
|
|
2238
|
-
for (const fileName of PLUGIN_MCP_FILES) {
|
|
2239
|
-
const fullPath = join9(installPath, fileName);
|
|
2240
|
-
if (!existsSync7(fullPath)) {
|
|
2241
|
-
continue;
|
|
2242
|
-
}
|
|
2243
|
-
try {
|
|
2244
|
-
const document = JSON.parse(readFileSync6(fullPath, "utf-8"));
|
|
2245
|
-
names.push(...Object.keys(parseMcpServersDocument(document)));
|
|
2246
|
-
} catch {
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
|
-
return names;
|
|
2250
|
-
}
|
|
2251
|
-
function listHostNativeMcpNames(homeRoot, harnessId) {
|
|
2252
|
-
const names = /* @__PURE__ */ new Set();
|
|
2253
|
-
switch (harnessId) {
|
|
2254
|
-
case "cursor": {
|
|
2255
|
-
for (const name of listCursorNativeMcpPluginNames(homeRoot)) {
|
|
2256
|
-
names.add(name);
|
|
2257
|
-
}
|
|
2258
|
-
for (const install of listCursorPluginInstalls(homeRoot)) {
|
|
2259
|
-
if (!install.installPath) {
|
|
2260
|
-
continue;
|
|
2261
|
-
}
|
|
2262
|
-
for (const name of mcpNamesFromInstallPath(install.installPath)) {
|
|
2263
|
-
names.add(name);
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
break;
|
|
2267
|
-
}
|
|
2268
|
-
case "claude-code": {
|
|
2269
|
-
for (const install of loadInstalled(homeRoot)) {
|
|
2270
|
-
if (!install.installPath) {
|
|
2271
|
-
continue;
|
|
2272
|
-
}
|
|
2273
|
-
for (const name of mcpNamesFromInstallPath(install.installPath)) {
|
|
2274
|
-
names.add(name);
|
|
2275
|
-
}
|
|
2276
|
-
}
|
|
2277
|
-
break;
|
|
2278
|
-
}
|
|
2279
|
-
default:
|
|
2280
|
-
break;
|
|
2281
|
-
}
|
|
2282
|
-
return names;
|
|
2283
|
-
}
|
|
2284
|
-
function hostPluginPinIsInstalled(homeRoot, pinRef) {
|
|
2285
|
-
if (findInstalledRefForCatalogPin(pinRef, homeRoot)) {
|
|
2286
|
-
return true;
|
|
2287
|
-
}
|
|
2288
|
-
const { name } = parsePluginRef(pinRef);
|
|
2289
|
-
return listCursorPluginInstalls(homeRoot).some(
|
|
2290
|
-
(row) => row.ref === pinRef || row.name === name
|
|
2291
|
-
);
|
|
2292
|
-
}
|
|
2293
|
-
|
|
2294
|
-
// src/services/project-drift.ts
|
|
2295
|
-
import { existsSync as existsSync8, readFileSync as readFileSync7 } from "fs";
|
|
2296
|
-
import { join as join10 } from "path";
|
|
2297
|
-
function driftChangeIsKept(change) {
|
|
2298
|
-
return change.removal_group === "owned_modified" || change.removal_group === "unmanaged";
|
|
2299
|
-
}
|
|
2300
|
-
function readProjectFile(projectRoot, relativePath) {
|
|
2301
|
-
const fullPath = join10(projectRoot, relativePath);
|
|
2302
|
-
if (!existsSync8(fullPath)) return null;
|
|
2303
|
-
try {
|
|
2304
|
-
return readFileSync7(fullPath, "utf-8");
|
|
2305
|
-
} catch {
|
|
2306
|
-
return null;
|
|
2307
|
-
}
|
|
2308
|
-
}
|
|
2309
|
-
function detectProjectDrift(projectRoot, snapshot) {
|
|
2310
|
-
const changes = [];
|
|
2311
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2312
|
-
for (const [platformId, files] of Object.entries(snapshot.state?.platform_files ?? {})) {
|
|
2313
|
-
for (const [relativePath, expectedContent] of Object.entries(files)) {
|
|
2314
|
-
seen.add(relativePath);
|
|
2315
|
-
const current = readProjectFile(projectRoot, relativePath);
|
|
2316
|
-
if (current === null) {
|
|
2317
|
-
changes.push({ path: relativePath, type: "deleted", platform: platformId });
|
|
2318
|
-
continue;
|
|
2319
|
-
}
|
|
2320
|
-
if (current !== expectedContent) {
|
|
2321
|
-
changes.push({ path: relativePath, type: "modified", platform: platformId });
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
return {
|
|
2326
|
-
project_root: projectRoot,
|
|
2327
|
-
snapshot_id: snapshot.id,
|
|
2328
|
-
snapshot_label: snapshot.label,
|
|
2329
|
-
has_drift: changes.length > 0,
|
|
2330
|
-
changes
|
|
2331
|
-
};
|
|
2332
|
-
}
|
|
2333
|
-
function detectProjectDriftFromLatest(projectRoot, projectId) {
|
|
2334
|
-
const snapshot = getLatestSnapshot(projectId);
|
|
2335
|
-
if (!snapshot) {
|
|
2336
|
-
return {
|
|
2337
|
-
project_root: projectRoot,
|
|
2338
|
-
snapshot_id: null,
|
|
2339
|
-
snapshot_label: null,
|
|
2340
|
-
has_drift: false,
|
|
2341
|
-
changes: []
|
|
2342
|
-
};
|
|
2343
|
-
}
|
|
2344
|
-
return detectProjectDrift(projectRoot, snapshot);
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
|
-
// src/services/global-profile-status-panel.ts
|
|
2348
|
-
var PANEL_HARNESS_IDS = ["claude-code", "cursor"];
|
|
2349
|
-
function collectOwnedGlobalProfileFiles(snapshotId) {
|
|
2350
|
-
if (!snapshotId) {
|
|
2351
|
-
return /* @__PURE__ */ new Set();
|
|
2352
|
-
}
|
|
2353
|
-
const owned = /* @__PURE__ */ new Set();
|
|
2354
|
-
for (const install of listGlobalApplySnapshotInstalls(snapshotId)) {
|
|
2355
|
-
for (const filePath of install.files) {
|
|
2356
|
-
owned.add(filePath);
|
|
2357
|
-
}
|
|
2358
|
-
}
|
|
2359
|
-
return owned;
|
|
2360
|
-
}
|
|
2361
|
-
function classifyGlobalDriftChanges(changes, ownedFiles) {
|
|
2362
|
-
const owned = [];
|
|
2363
|
-
const nonOwned = [];
|
|
2364
|
-
for (const change of changes) {
|
|
2365
|
-
if (ownedFiles.has(change.path)) {
|
|
2366
|
-
owned.push(change);
|
|
2367
|
-
} else {
|
|
2368
|
-
nonOwned.push(change);
|
|
2369
|
-
}
|
|
2370
|
-
}
|
|
2371
|
-
return { owned, nonOwned };
|
|
2372
|
-
}
|
|
2373
|
-
function mcpManagedPathsForHarness(harnessId) {
|
|
2374
|
-
switch (harnessId) {
|
|
2375
|
-
case "cursor":
|
|
2376
|
-
return [".cursor/mcp.json"];
|
|
2377
|
-
case "claude-code":
|
|
2378
|
-
return [".mcp.json", ".claude.json"];
|
|
2379
|
-
default:
|
|
2380
|
-
return [];
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
function declaredMcpFromExpectedFiles(harnessIds, expectedFiles) {
|
|
2384
|
-
const namesByHarness = {};
|
|
2385
|
-
const configsByHarness = {};
|
|
2386
|
-
for (const harnessId of harnessIds) {
|
|
2387
|
-
const mcpPaths = new Set(mcpManagedPathsForHarness(harnessId));
|
|
2388
|
-
const configs = {};
|
|
2389
|
-
if (mcpPaths.size > 0) {
|
|
2390
|
-
for (const file of expectedFiles) {
|
|
2391
|
-
const normalized = file.path.replace(/\\/g, "/").replace(/^~\//, "");
|
|
2392
|
-
if (!mcpPaths.has(normalized)) {
|
|
2393
|
-
continue;
|
|
2394
|
-
}
|
|
2395
|
-
try {
|
|
2396
|
-
const document = JSON.parse(file.content);
|
|
2397
|
-
Object.assign(configs, parseMcpServersDocument(document));
|
|
2398
|
-
} catch {
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
namesByHarness[harnessId] = Object.keys(configs);
|
|
2403
|
-
configsByHarness[harnessId] = configs;
|
|
2404
|
-
}
|
|
2405
|
-
return { namesByHarness, configsByHarness };
|
|
2406
|
-
}
|
|
2407
|
-
function readGlobalMcpServers(homeRoot, harnessId) {
|
|
2408
|
-
const platform = getPlatform(harnessId);
|
|
2409
|
-
if (!platform) {
|
|
2410
|
-
return {};
|
|
2411
|
-
}
|
|
2412
|
-
const configuredPath = harnessId === "cursor" ? platform.globalPaths.settings : platform.globalPaths.mcp ?? platform.projectPaths.mcp;
|
|
2413
|
-
if (!configuredPath) {
|
|
2414
|
-
return {};
|
|
2415
|
-
}
|
|
2416
|
-
const relativePath = configuredPath.startsWith("~/") ? configuredPath.slice(2) : configuredPath;
|
|
2417
|
-
const fullPath = join11(homeRoot, relativePath);
|
|
2418
|
-
if (!existsSync9(fullPath)) {
|
|
2419
|
-
return {};
|
|
2420
|
-
}
|
|
2421
|
-
try {
|
|
2422
|
-
const document = JSON.parse(readFileSync8(fullPath, "utf-8"));
|
|
2423
|
-
return parseMcpServersDocument(document);
|
|
2424
|
-
} catch {
|
|
2425
|
-
return {};
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
function buildHarnessPluginRows(declaredPins, homeRoot) {
|
|
2429
|
-
const installed = loadInstalled(homeRoot).filter((row) => row.scope === "user");
|
|
2430
|
-
const matchedInstalledRefs = /* @__PURE__ */ new Set();
|
|
2431
|
-
const rows = [];
|
|
2432
|
-
for (const pin of declaredPins) {
|
|
2433
|
-
const installedRef = findInstalledRefForCatalogPin(pin.ref, homeRoot, "user");
|
|
2434
|
-
if (installedRef) {
|
|
2435
|
-
matchedInstalledRefs.add(installedRef);
|
|
2436
|
-
rows.push({ id: pin.ref, state: "installed" });
|
|
2437
|
-
} else {
|
|
2438
|
-
rows.push({ id: pin.ref, state: "missing" });
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
for (const install of installed) {
|
|
2442
|
-
if (!matchedInstalledRefs.has(install.ref)) {
|
|
2443
|
-
rows.push({ id: install.ref, state: "extra" });
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
return rows;
|
|
2447
|
-
}
|
|
2448
|
-
function findEnabledCursorInstallForPin(pinRef, installs) {
|
|
2449
|
-
const enabled = installs.filter((row) => row.enabled);
|
|
2450
|
-
const exact = enabled.find((row) => row.ref === pinRef);
|
|
2451
|
-
if (exact) return exact;
|
|
2452
|
-
const { name } = parsePluginRef(pinRef);
|
|
2453
|
-
return enabled.find((row) => row.name === name);
|
|
2454
|
-
}
|
|
2455
|
-
function buildCursorHarnessPluginRows(declaredPins, homeRoot) {
|
|
2456
|
-
const installs = listCursorPluginInstalls(homeRoot);
|
|
2457
|
-
const cursorNames = listCursorPluginFootprintNames(homeRoot);
|
|
2458
|
-
const matchedEnabledRefs = /* @__PURE__ */ new Set();
|
|
2459
|
-
const rows = [];
|
|
2460
|
-
for (const pin of declaredPins) {
|
|
2461
|
-
const { name } = parsePluginRef(pin.ref);
|
|
2462
|
-
if (!cursorNames.has(name) && !installs.some((row) => row.ref === pin.ref)) {
|
|
2463
|
-
continue;
|
|
2464
|
-
}
|
|
2465
|
-
const match = findEnabledCursorInstallForPin(pin.ref, installs);
|
|
2466
|
-
if (match) {
|
|
2467
|
-
matchedEnabledRefs.add(match.ref);
|
|
2468
|
-
rows.push({ id: pin.ref, state: "installed" });
|
|
2469
|
-
} else {
|
|
2470
|
-
rows.push({ id: pin.ref, state: "missing" });
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
for (const install of installs) {
|
|
2474
|
-
if (!install.enabled) continue;
|
|
2475
|
-
if (!matchedEnabledRefs.has(install.ref)) {
|
|
2476
|
-
rows.push({ id: install.ref, state: "extra" });
|
|
2477
|
-
}
|
|
2478
|
-
}
|
|
2479
|
-
return rows;
|
|
2480
|
-
}
|
|
2481
|
-
function buildHarnessMcpRows(declaredNames, liveNames, comparison) {
|
|
2482
|
-
const declared = new Set(declaredNames);
|
|
2483
|
-
const rows = declaredNames.map((name) => {
|
|
2484
|
-
if (!liveNames.has(name)) {
|
|
2485
|
-
return { name, state: "missing" };
|
|
2486
|
-
}
|
|
2487
|
-
const expected = comparison?.expected[name];
|
|
2488
|
-
const live = comparison?.live[name];
|
|
2489
|
-
if (expected && live && !mcpServerMetadataEquivalent(expected, live)) {
|
|
2490
|
-
return { name, state: "mismatch" };
|
|
2491
|
-
}
|
|
2492
|
-
return { name, state: "present" };
|
|
2493
|
-
});
|
|
2494
|
-
for (const name of liveNames) {
|
|
2495
|
-
if (!declared.has(name)) {
|
|
2496
|
-
rows.push({ name, state: "extra" });
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
return rows;
|
|
2500
|
-
}
|
|
2501
|
-
function projectForDriftPath(projectPath) {
|
|
2502
|
-
const resolvedRoot = resolve2(projectPath);
|
|
2503
|
-
const gitOriginRaw = getGitOrigin(resolvedRoot);
|
|
2504
|
-
const gitOrigin = gitOriginRaw ? normalizeGitUrl(gitOriginRaw) : null;
|
|
2505
|
-
const project = getProjectByLocalPath(resolvedRoot) ?? (gitOrigin ? getProjectByOrigin(gitOrigin) : void 0) ?? null;
|
|
2506
|
-
if (!project) return null;
|
|
2507
|
-
return { root: resolvedRoot, id: project.id };
|
|
2508
|
-
}
|
|
2509
|
-
function projectDriftWatchPaths(projectPath) {
|
|
2510
|
-
if (!projectPath) return [];
|
|
2511
|
-
const project = projectForDriftPath(projectPath);
|
|
2512
|
-
if (!project) return [];
|
|
2513
|
-
const snapshot = getLatestSnapshot(project.id);
|
|
2514
|
-
if (!snapshot) return [];
|
|
2515
|
-
const paths = [];
|
|
2516
|
-
for (const files of Object.values(snapshot.state?.platform_files ?? {})) {
|
|
2517
|
-
for (const relativePath of Object.keys(files)) {
|
|
2518
|
-
paths.push(join11(project.root, relativePath));
|
|
2519
|
-
}
|
|
2520
|
-
}
|
|
2521
|
-
return paths;
|
|
2522
|
-
}
|
|
2523
|
-
function resolveProjectDriftSummary(projectPath) {
|
|
2524
|
-
if (!projectPath) {
|
|
2525
|
-
return void 0;
|
|
2526
|
-
}
|
|
2527
|
-
const project = projectForDriftPath(projectPath);
|
|
2528
|
-
if (!project) {
|
|
2529
|
-
return {
|
|
2530
|
-
status: "na",
|
|
2531
|
-
report: null
|
|
2532
|
-
};
|
|
2533
|
-
}
|
|
2534
|
-
const resolvedRoot = project.root;
|
|
2535
|
-
const report = detectProjectDriftFromLatest(resolvedRoot, project.id);
|
|
2536
|
-
return {
|
|
2537
|
-
status: report?.has_drift ? "drifted" : "clean",
|
|
2538
|
-
report
|
|
2539
|
-
};
|
|
2540
|
-
}
|
|
2541
|
-
function computeGlobalProfilePanelStatus(input) {
|
|
2542
|
-
const reasons = [];
|
|
2543
|
-
if (input.switchFailed) {
|
|
2544
|
-
reasons.push("switch_failed");
|
|
2545
|
-
}
|
|
2546
|
-
if (input.restoreFailed) {
|
|
2547
|
-
reasons.push("restore_failed");
|
|
2548
|
-
}
|
|
2549
|
-
if (input.warning) {
|
|
2550
|
-
reasons.push("status_warning");
|
|
2551
|
-
}
|
|
2552
|
-
if (input.activeProfile && !input.applied) {
|
|
2553
|
-
reasons.push("profile_not_applied");
|
|
2554
|
-
}
|
|
2555
|
-
if (!input.stackInSync && input.applied) {
|
|
2556
|
-
reasons.push("stack_out_of_sync");
|
|
2557
|
-
}
|
|
2558
|
-
if (input.ownedDriftCount > 0) {
|
|
2559
|
-
reasons.push("owned_path_drift");
|
|
2560
|
-
}
|
|
2561
|
-
if (input.missingPluginCount > 0) {
|
|
2562
|
-
reasons.push("missing_plugins");
|
|
2563
|
-
}
|
|
2564
|
-
if (input.missingMcpCount > 0) {
|
|
2565
|
-
reasons.push("missing_mcp");
|
|
2566
|
-
}
|
|
2567
|
-
const redReasons = /* @__PURE__ */ new Set([
|
|
2568
|
-
"switch_failed",
|
|
2569
|
-
"restore_failed",
|
|
2570
|
-
"profile_not_applied",
|
|
2571
|
-
"stack_out_of_sync",
|
|
2572
|
-
"owned_path_drift",
|
|
2573
|
-
"missing_plugins",
|
|
2574
|
-
"missing_mcp"
|
|
2575
|
-
]);
|
|
2576
|
-
if (reasons.some((reason) => redReasons.has(reason)) || input.warning && input.activeProfile) {
|
|
2577
|
-
return { status: "red", reasons };
|
|
2578
|
-
}
|
|
2579
|
-
if (input.nonOwnedDriftCount > 0) {
|
|
2580
|
-
reasons.push("non_owned_drift");
|
|
2581
|
-
}
|
|
2582
|
-
if (input.projectDrift?.status === "drifted") {
|
|
2583
|
-
reasons.push("project_drift");
|
|
2584
|
-
}
|
|
2585
|
-
if ((input.hostManagedCollisionCount ?? 0) > 0) {
|
|
2586
|
-
reasons.push("cursor_host_skill_collision");
|
|
2587
|
-
}
|
|
2588
|
-
if (input.depth === "fast") {
|
|
2589
|
-
reasons.push("fast_depth");
|
|
2590
|
-
}
|
|
2591
|
-
if (reasons.length > 0) {
|
|
2592
|
-
return { status: "yellow", reasons };
|
|
2593
|
-
}
|
|
2594
|
-
return { status: "green", reasons };
|
|
2595
|
-
}
|
|
2596
|
-
function buildHarnessLiveStatusMap(input) {
|
|
2597
|
-
const harnesses = {};
|
|
2598
|
-
for (const harnessId of PANEL_HARNESS_IDS) {
|
|
2599
|
-
if (input.depth === "fast") {
|
|
2600
|
-
harnesses[harnessId] = { plugins: [], mcp: [] };
|
|
2601
|
-
continue;
|
|
2602
|
-
}
|
|
2603
|
-
const declaredMcp = input.declaredMcpByHarness[harnessId] ?? [];
|
|
2604
|
-
const liveServers = traceSpan("base.harness-live-status.mcp", () => readGlobalMcpServers(input.homeRoot, harnessId), harnessId);
|
|
2605
|
-
const liveMcp = /* @__PURE__ */ new Set([
|
|
2606
|
-
...Object.keys(liveServers),
|
|
2607
|
-
...traceSpan("base.harness-live-status.native-mcp", () => listHostNativeMcpNames(input.homeRoot, harnessId), harnessId)
|
|
2608
|
-
]);
|
|
2609
|
-
const expectedServers = input.expectedMcpConfigsByHarness?.[harnessId];
|
|
2610
|
-
let plugins = [];
|
|
2611
|
-
switch (harnessId) {
|
|
2612
|
-
case "claude-code":
|
|
2613
|
-
plugins = traceSpan(
|
|
2614
|
-
"base.harness-live-status.plugins",
|
|
2615
|
-
() => buildHarnessPluginRows(input.declaredPins, input.homeRoot),
|
|
2616
|
-
harnessId
|
|
2617
|
-
);
|
|
2618
|
-
break;
|
|
2619
|
-
case "cursor":
|
|
2620
|
-
plugins = traceSpan(
|
|
2621
|
-
"base.harness-live-status.plugins",
|
|
2622
|
-
() => buildCursorHarnessPluginRows(input.declaredPins, input.homeRoot),
|
|
2623
|
-
harnessId
|
|
2624
|
-
);
|
|
2625
|
-
break;
|
|
2626
|
-
default: {
|
|
2627
|
-
const _exhaustive = harnessId;
|
|
2628
|
-
void _exhaustive;
|
|
2629
|
-
plugins = [];
|
|
2630
|
-
break;
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
harnesses[harnessId] = {
|
|
2634
|
-
plugins,
|
|
2635
|
-
mcp: buildHarnessMcpRows(
|
|
2636
|
-
declaredMcp,
|
|
2637
|
-
liveMcp,
|
|
2638
|
-
expectedServers ? { expected: expectedServers, live: liveServers } : void 0
|
|
2639
|
-
)
|
|
2640
|
-
};
|
|
2641
|
-
}
|
|
2642
|
-
return harnesses;
|
|
2643
|
-
}
|
|
2644
|
-
function countMissingHarnessRows(harnesses) {
|
|
2645
|
-
let missingPlugins = 0;
|
|
2646
|
-
let missingMcp = 0;
|
|
2647
|
-
for (const status of Object.values(harnesses)) {
|
|
2648
|
-
missingPlugins += status.plugins.filter((row) => row.state === "missing").length;
|
|
2649
|
-
missingMcp += status.mcp.filter(
|
|
2650
|
-
(row) => row.state === "missing" || row.state === "mismatch"
|
|
2651
|
-
).length;
|
|
2652
|
-
}
|
|
2653
|
-
return { missingPlugins, missingMcp };
|
|
2654
|
-
}
|
|
2655
|
-
|
|
2656
|
-
// src/services/status-read-cache.ts
|
|
2657
|
-
var armedPaths = /* @__PURE__ */ new Set();
|
|
2658
|
-
var pendingWatchPaths = [];
|
|
2659
|
-
var pendingWatchSet = /* @__PURE__ */ new Set();
|
|
2660
|
-
var pendingRecursive = /* @__PURE__ */ new Set();
|
|
2661
|
-
var pendingHome = "";
|
|
2662
|
-
var watchArmTimer = null;
|
|
2663
|
-
var retainedForHome = "";
|
|
2664
|
-
var MANIFEST_RELATIVE_PATHS = [
|
|
2665
|
-
".claude-plugin/marketplace.json",
|
|
2666
|
-
".cursor-plugin/marketplace.json",
|
|
2667
|
-
".github/plugin/marketplace.json",
|
|
2668
|
-
".agents/plugins/marketplace.json",
|
|
2669
|
-
"marketplace.json"
|
|
2670
|
-
];
|
|
2671
|
-
var debugCache = process.env.HARNESSTAP_STATUS_CACHE_DEBUG === "1";
|
|
2672
|
-
var buckets = /* @__PURE__ */ new Map();
|
|
2673
|
-
var inflight = /* @__PURE__ */ new Map();
|
|
2674
|
-
var watchers = /* @__PURE__ */ new Map();
|
|
2675
|
-
var parentOnlyWatches = /* @__PURE__ */ new Map();
|
|
2676
|
-
var generation = 0;
|
|
2677
|
-
var epoch = 0;
|
|
2678
|
-
var watchersHealthy = true;
|
|
2679
|
-
var ignoreWatchDirt = false;
|
|
2680
|
-
function clearGlobalProfileStatusCache() {
|
|
2681
|
-
generation += 1;
|
|
2682
|
-
epoch += 1;
|
|
2683
|
-
buckets.clear();
|
|
2684
|
-
inflight.clear();
|
|
2685
|
-
watchersHealthy = true;
|
|
2686
|
-
ignoreWatchDirt = false;
|
|
2687
|
-
}
|
|
2688
|
-
var statusRefreshDelayMs = 0;
|
|
2689
|
-
var watcherCreates = 0;
|
|
2690
|
-
var refreshCompletions = 0;
|
|
2691
|
-
function watcherPath(key) {
|
|
2692
|
-
return key.slice(2);
|
|
2693
|
-
}
|
|
2694
|
-
function markDirty() {
|
|
2695
|
-
epoch += 1;
|
|
2696
|
-
}
|
|
2697
|
-
function expandHomePath(value, home) {
|
|
2698
|
-
if (value === "~") return home;
|
|
2699
|
-
if (value.startsWith("~/")) return join12(home, value.slice(2));
|
|
2700
|
-
return value;
|
|
2701
|
-
}
|
|
2702
|
-
function pushPath(paths, value, home) {
|
|
2703
|
-
if (typeof value === "string" && value.length > 0) {
|
|
2704
|
-
paths.push(expandHomePath(value, home));
|
|
2705
|
-
return;
|
|
2706
|
-
}
|
|
2707
|
-
if (!Array.isArray(value)) return;
|
|
2708
|
-
for (const item of value) {
|
|
2709
|
-
if (typeof item === "string" && item.length > 0) {
|
|
2710
|
-
paths.push(expandHomePath(item, home));
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
|
-
}
|
|
2714
|
-
function harnessConfigPaths(home) {
|
|
2715
|
-
const paths = [];
|
|
2716
|
-
for (const platform of getAllPlatforms()) {
|
|
2717
|
-
const { pathAlternates, ...files } = platform.globalPaths;
|
|
2718
|
-
for (const value of Object.values(files)) {
|
|
2719
|
-
pushPath(paths, value, home);
|
|
2720
|
-
}
|
|
2721
|
-
if (pathAlternates) {
|
|
2722
|
-
for (const value of Object.values(pathAlternates)) {
|
|
2723
|
-
pushPath(paths, value, home);
|
|
2724
|
-
}
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
|
-
return paths;
|
|
2728
|
-
}
|
|
2729
|
-
function marketplaceInstallRoots(home) {
|
|
2730
|
-
const knownPath = join12(home, ".claude", "plugins", "known_marketplaces.json");
|
|
2731
|
-
let parsed;
|
|
2732
|
-
try {
|
|
2733
|
-
parsed = JSON.parse(readFileSync9(knownPath, "utf8"));
|
|
2734
|
-
} catch {
|
|
2735
|
-
return [];
|
|
2736
|
-
}
|
|
2737
|
-
if (!parsed || typeof parsed !== "object") return [];
|
|
2738
|
-
const roots = [];
|
|
2739
|
-
for (const value of Object.values(parsed)) {
|
|
2740
|
-
if (!value || typeof value !== "object") continue;
|
|
2741
|
-
const location = value.installLocation;
|
|
2742
|
-
if (typeof location === "string" && location.trim()) {
|
|
2743
|
-
roots.push(location.trim());
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
return roots;
|
|
2747
|
-
}
|
|
2748
|
-
function manifestPathsUnder(root) {
|
|
2749
|
-
const found = [];
|
|
2750
|
-
for (const relative3 of MANIFEST_RELATIVE_PATHS) {
|
|
2751
|
-
const path = join12(root, relative3);
|
|
2752
|
-
if (existsSync10(path)) found.push(path);
|
|
2753
|
-
}
|
|
2754
|
-
return found;
|
|
2755
|
-
}
|
|
2756
|
-
function marketplaceManifestPaths(home) {
|
|
2757
|
-
const roots = [
|
|
2758
|
-
join12(home, ".claude", "plugins", "marketplaces"),
|
|
2759
|
-
...marketplaceInstallRoots(home)
|
|
2760
|
-
];
|
|
2761
|
-
const found = [];
|
|
2762
|
-
for (const root of roots) {
|
|
2763
|
-
let names = [];
|
|
2764
|
-
try {
|
|
2765
|
-
names = readdirSync4(root);
|
|
2766
|
-
} catch {
|
|
2767
|
-
found.push(...manifestPathsUnder(root));
|
|
2768
|
-
continue;
|
|
2769
|
-
}
|
|
2770
|
-
for (const name of names) {
|
|
2771
|
-
const child = join12(root, name);
|
|
2772
|
-
try {
|
|
2773
|
-
if (!statSync2(child).isDirectory()) continue;
|
|
2774
|
-
} catch {
|
|
2775
|
-
continue;
|
|
2776
|
-
}
|
|
2777
|
-
found.push(...manifestPathsUnder(child));
|
|
2778
|
-
}
|
|
2779
|
-
}
|
|
2780
|
-
return found;
|
|
2781
|
-
}
|
|
2782
|
-
function recursiveWatchPaths(home) {
|
|
2783
|
-
const plugins = join12(home, ".cursor", "plugins");
|
|
2784
|
-
const paths = /* @__PURE__ */ new Set([
|
|
2785
|
-
plugins,
|
|
2786
|
-
join12(plugins, "local"),
|
|
2787
|
-
join12(plugins, "cache"),
|
|
2788
|
-
join12(home, ".claude", "plugins", "marketplaces")
|
|
2789
|
-
]);
|
|
2790
|
-
for (const root of marketplaceInstallRoots(home)) {
|
|
2791
|
-
paths.add(root);
|
|
2792
|
-
}
|
|
2793
|
-
return paths;
|
|
2794
|
-
}
|
|
2795
|
-
function isSidecarOwnedPath(path) {
|
|
2796
|
-
const dir = getHarnesstapDir();
|
|
2797
|
-
return path === dir || path.startsWith(dir.endsWith(sep2) ? dir : `${dir}${sep2}`);
|
|
2798
|
-
}
|
|
2799
|
-
function collectFingerprintPaths(projectPath, extra) {
|
|
2800
|
-
const home = resolveHomeRoot();
|
|
2801
|
-
const plugins = join12(home, ".cursor", "plugins");
|
|
2802
|
-
const paths = [
|
|
2803
|
-
plugins,
|
|
2804
|
-
join12(plugins, "installed.json"),
|
|
2805
|
-
join12(plugins, "installed_plugins.json"),
|
|
2806
|
-
join12(plugins, "local"),
|
|
2807
|
-
join12(home, ".claude", "plugins", "installed_plugins.json"),
|
|
2808
|
-
join12(home, ".claude", "plugins", "known_marketplaces.json"),
|
|
2809
|
-
join12(home, ".claude", "plugins", "marketplaces"),
|
|
2810
|
-
join12(cursorUserDataDir(home), "User", "settings.json"),
|
|
2811
|
-
join12(home, ".cursor", "projects", "mcps"),
|
|
2812
|
-
...harnessConfigPaths(home),
|
|
2813
|
-
...marketplaceManifestPaths(home),
|
|
2814
|
-
...projectDriftWatchPaths(projectPath),
|
|
2815
|
-
...extra
|
|
2816
|
-
];
|
|
2817
|
-
return { paths: uniquePaths(paths), recursive: recursiveWatchPaths(home) };
|
|
2818
|
-
}
|
|
2819
|
-
function uniquePaths(paths) {
|
|
2820
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2821
|
-
const unique = [];
|
|
2822
|
-
for (const path of paths) {
|
|
2823
|
-
if (!path || seen.has(path) || isSidecarOwnedPath(path)) continue;
|
|
2824
|
-
seen.add(path);
|
|
2825
|
-
unique.push(path);
|
|
2826
|
-
}
|
|
2827
|
-
unique.sort();
|
|
2828
|
-
return unique;
|
|
2829
|
-
}
|
|
2830
|
-
function fingerprintPaths(paths) {
|
|
2831
|
-
return paths.map((path) => `${path}=${fileSignature(path)}`).join("\n");
|
|
2832
|
-
}
|
|
2833
|
-
function notifyWatchDirty(path, file) {
|
|
2834
|
-
if (path !== void 0 && typeof file === "string") {
|
|
2835
|
-
const wanted = parentOnlyWatches.get(path);
|
|
2836
|
-
if (wanted && !wanted.has(basename2(file))) return;
|
|
2837
|
-
}
|
|
2838
|
-
if (debugCache) console.error(`[status-cache] watch dirty ${path ?? ""} ${file ?? ""}`);
|
|
2839
|
-
if (parentPort) {
|
|
2840
|
-
parentPort.postMessage({ op: "dirty", home: resolveHomeRoot() });
|
|
2841
|
-
return;
|
|
2842
|
-
}
|
|
2843
|
-
markDirty();
|
|
2844
|
-
}
|
|
2845
|
-
function notifyWatchUnhealthy() {
|
|
2846
|
-
markWatchersUnhealthy();
|
|
2847
|
-
if (parentPort) parentPort.postMessage({ op: "unhealthy" });
|
|
2848
|
-
}
|
|
2849
|
-
function startWatcher(path, recursive) {
|
|
2850
|
-
watcherCreates += 1;
|
|
2851
|
-
const ignoreUntil = performance.now() + 100;
|
|
2852
|
-
const watcher = watch(path, { persistent: false, recursive }, (_event, file) => {
|
|
2853
|
-
if (performance.now() < ignoreUntil) return;
|
|
2854
|
-
notifyWatchDirty(path, typeof file === "string" ? file : null);
|
|
2855
|
-
});
|
|
2856
|
-
watcher.on("error", () => {
|
|
2857
|
-
notifyWatchDirty();
|
|
2858
|
-
watcher.close();
|
|
2859
|
-
watchers.delete(watcherKey(path, recursive));
|
|
2860
|
-
armedPaths.delete(path);
|
|
2861
|
-
parentOnlyWatches.delete(path);
|
|
2862
|
-
});
|
|
2863
|
-
return watcher;
|
|
2864
|
-
}
|
|
2865
|
-
function watcherKey(path, recursive) {
|
|
2866
|
-
return `${recursive ? "r" : "n"}\0${path}`;
|
|
2867
|
-
}
|
|
2868
|
-
function snapshotPathSignatures() {
|
|
2869
|
-
for (const entry of buckets.values()) {
|
|
2870
|
-
if (entry.pathSig === "") {
|
|
2871
|
-
entry.pathSig = fingerprintPaths(entry.paths);
|
|
2872
|
-
}
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
|
-
function markWatchersUnhealthy() {
|
|
2876
|
-
if (!watchersHealthy) return;
|
|
2877
|
-
watchersHealthy = false;
|
|
2878
|
-
snapshotPathSignatures();
|
|
2879
|
-
}
|
|
2880
|
-
function watchOne(path, recursive) {
|
|
2881
|
-
try {
|
|
2882
|
-
if (!statSync2(path).isDirectory()) recursive = false;
|
|
2883
|
-
} catch {
|
|
2884
|
-
return;
|
|
2885
|
-
}
|
|
2886
|
-
const key = watcherKey(path, recursive);
|
|
2887
|
-
if (watchers.has(key) || watchers.has(watcherKey(path, true)) || watchers.has(watcherKey(path, false))) {
|
|
2888
|
-
return;
|
|
2889
|
-
}
|
|
2890
|
-
try {
|
|
2891
|
-
watchers.set(key, startWatcher(path, recursive));
|
|
2892
|
-
} catch {
|
|
2893
|
-
if (!recursive) {
|
|
2894
|
-
notifyWatchUnhealthy();
|
|
2895
|
-
return;
|
|
2896
|
-
}
|
|
2897
|
-
try {
|
|
2898
|
-
watchers.set(watcherKey(path, false), startWatcher(path, false));
|
|
2899
|
-
} catch {
|
|
2900
|
-
notifyWatchUnhealthy();
|
|
2901
|
-
return;
|
|
2902
|
-
}
|
|
2903
|
-
notifyWatchUnhealthy();
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2906
|
-
function hasWatcher(path) {
|
|
2907
|
-
return watchers.has(watcherKey(path, true)) || watchers.has(watcherKey(path, false));
|
|
2908
|
-
}
|
|
2909
|
-
function isUnderHome(path, home) {
|
|
2910
|
-
const prefix = home.endsWith(sep2) ? home : `${home}${sep2}`;
|
|
2911
|
-
return path === home || path.startsWith(prefix);
|
|
2912
|
-
}
|
|
2913
|
-
function retainWatchersForHome(home) {
|
|
2914
|
-
for (const [key, watcher] of watchers) {
|
|
2915
|
-
const path = watcherPath(key);
|
|
2916
|
-
if (isUnderHome(path, home)) continue;
|
|
2917
|
-
watcher.close();
|
|
2918
|
-
watchers.delete(key);
|
|
2919
|
-
armedPaths.delete(path);
|
|
2920
|
-
parentOnlyWatches.delete(path);
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
function ensureWatchers(paths, recursive, home) {
|
|
2924
|
-
for (const path of paths) {
|
|
2925
|
-
if (isSidecarOwnedPath(path)) continue;
|
|
2926
|
-
if (hasWatcher(path)) {
|
|
2927
|
-
parentOnlyWatches.delete(path);
|
|
2928
|
-
continue;
|
|
2929
|
-
}
|
|
2930
|
-
let isDirectory = false;
|
|
2931
|
-
try {
|
|
2932
|
-
isDirectory = statSync2(path).isDirectory();
|
|
2933
|
-
} catch {
|
|
2934
|
-
const parent = dirname2(path);
|
|
2935
|
-
if (parent === path || parent === home || parent === dirname2(home)) continue;
|
|
2936
|
-
if (isSidecarOwnedPath(parent)) continue;
|
|
2937
|
-
const directlyWatched = hasWatcher(parent) && !parentOnlyWatches.has(parent);
|
|
2938
|
-
if (!directlyWatched && !paths.includes(parent)) {
|
|
2939
|
-
const wanted = parentOnlyWatches.get(parent) ?? /* @__PURE__ */ new Set();
|
|
2940
|
-
wanted.add(basename2(path));
|
|
2941
|
-
parentOnlyWatches.set(parent, wanted);
|
|
2942
|
-
}
|
|
2943
|
-
watchOne(parent, false);
|
|
2944
|
-
continue;
|
|
2945
|
-
}
|
|
2946
|
-
watchOne(path, isDirectory && recursive.has(path));
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
function scheduleWatchers(paths, recursive, home) {
|
|
2950
|
-
if (home !== retainedForHome) {
|
|
2951
|
-
retainWatchersForHome(home);
|
|
2952
|
-
retainedForHome = home;
|
|
2953
|
-
}
|
|
2954
|
-
let added = false;
|
|
2955
|
-
for (const path of paths) {
|
|
2956
|
-
if (armedPaths.has(path) || pendingWatchSet.has(path)) continue;
|
|
2957
|
-
pendingWatchPaths.push(path);
|
|
2958
|
-
pendingWatchSet.add(path);
|
|
2959
|
-
added = true;
|
|
2960
|
-
}
|
|
2961
|
-
for (const path of recursive) pendingRecursive.add(path);
|
|
2962
|
-
pendingHome = home;
|
|
2963
|
-
if (!added || watchArmTimer) return;
|
|
2964
|
-
watchArmTimer = setTimeout(() => {
|
|
2965
|
-
watchArmTimer = null;
|
|
2966
|
-
const batch = pendingWatchPaths.splice(0, pendingWatchPaths.length);
|
|
2967
|
-
pendingWatchSet.clear();
|
|
2968
|
-
const recursiveNow = pendingRecursive;
|
|
2969
|
-
pendingRecursive = /* @__PURE__ */ new Set();
|
|
2970
|
-
const homeNow = pendingHome;
|
|
2971
|
-
for (const path of batch) armedPaths.add(path);
|
|
2972
|
-
ensureWatchers(batch, recursiveNow, homeNow);
|
|
2973
|
-
}, 0);
|
|
2974
|
-
}
|
|
2975
|
-
var cacheHits = 0;
|
|
2976
|
-
var cacheMisses = 0;
|
|
2977
|
-
var lastMissReason = "";
|
|
2978
|
-
function noteMiss(reason) {
|
|
2979
|
-
cacheMisses += 1;
|
|
2980
|
-
lastMissReason = reason;
|
|
2981
|
-
if (debugCache) console.error(`[status-cache] miss reason=${reason}`);
|
|
2982
|
-
}
|
|
2983
|
-
function noteHit(startedAt) {
|
|
2984
|
-
cacheHits += 1;
|
|
2985
|
-
if (debugCache) {
|
|
2986
|
-
console.error(`[status-cache] hit ${(performance.now() - startedAt).toFixed(2)}ms`);
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
function databaseStateMatches(entry) {
|
|
2990
|
-
if (entry.writeGen !== readStatusWriteGeneration()) return "write";
|
|
2991
|
-
if (entry.dataVersion !== readDbDataVersion()) return "data_version";
|
|
2992
|
-
return null;
|
|
2993
|
-
}
|
|
2994
|
-
function staleReason(entry) {
|
|
2995
|
-
const dbReason = databaseStateMatches(entry);
|
|
2996
|
-
if (dbReason) return dbReason;
|
|
2997
|
-
if (entry.epoch !== epoch) return "epoch";
|
|
2998
|
-
return entryIsCurrent(entry) ? null : "fingerprint";
|
|
2999
|
-
}
|
|
3000
|
-
function entryIsCurrent(entry) {
|
|
3001
|
-
if (entry.epoch !== epoch) return false;
|
|
3002
|
-
if (!watchersHealthy) {
|
|
3003
|
-
const sig = fingerprintPaths(entry.paths);
|
|
3004
|
-
if (entry.pathSig === "") {
|
|
3005
|
-
entry.pathSig = sig;
|
|
3006
|
-
return false;
|
|
3007
|
-
}
|
|
3008
|
-
return sig === entry.pathSig;
|
|
3009
|
-
}
|
|
3010
|
-
return true;
|
|
3011
|
-
}
|
|
3012
|
-
function deepFreeze(value) {
|
|
3013
|
-
if (value === null || typeof value !== "object") return value;
|
|
3014
|
-
if (Object.isFrozen(value)) return value;
|
|
3015
|
-
for (const nested of Object.values(value)) {
|
|
3016
|
-
deepFreeze(nested);
|
|
3017
|
-
}
|
|
3018
|
-
return Object.freeze(value);
|
|
3019
|
-
}
|
|
3020
|
-
function present(value, refreshing) {
|
|
3021
|
-
return { ...value, refreshing };
|
|
3022
|
-
}
|
|
3023
|
-
function requestKey(input) {
|
|
3024
|
-
const profile = getActiveProfileName() ?? "";
|
|
3025
|
-
const depth = input.includeDepth === false ? "*" : input.depth ?? "full";
|
|
3026
|
-
return [
|
|
3027
|
-
resolveHomeRoot(),
|
|
3028
|
-
depth,
|
|
3029
|
-
input.harness ?? "",
|
|
3030
|
-
input.projectPath ?? "",
|
|
3031
|
-
profile
|
|
3032
|
-
].join("\0");
|
|
3033
|
-
}
|
|
3034
|
-
function remember(key, projectPath, loaded, epochAtStart, writeGen, watchPaths) {
|
|
3035
|
-
const home = resolveHomeRoot();
|
|
3036
|
-
const collected = watchPaths ? { paths: [...watchPaths], recursive: /* @__PURE__ */ new Set() } : collectFingerprintPaths(projectPath, loaded.watchedPaths);
|
|
3037
|
-
if (!watchPaths) scheduleWatchers(collected.paths, collected.recursive, home);
|
|
3038
|
-
const next = {
|
|
3039
|
-
paths: collected.paths,
|
|
3040
|
-
pathSig: watchersHealthy ? "" : fingerprintPaths(collected.paths),
|
|
3041
|
-
epoch,
|
|
3042
|
-
writeGen,
|
|
3043
|
-
// Read after the snapshot so the worker's own commits are not a change.
|
|
3044
|
-
dataVersion: readDbDataVersion(),
|
|
3045
|
-
value: deepFreeze(loaded.value)
|
|
3046
|
-
};
|
|
3047
|
-
buckets.set(key, next);
|
|
3048
|
-
if (epoch !== epochAtStart) {
|
|
3049
|
-
next.epoch = epochAtStart;
|
|
3050
|
-
}
|
|
3051
|
-
if (buckets.size > 16) {
|
|
3052
|
-
const oldest = buckets.keys().next().value;
|
|
3053
|
-
if (oldest) buckets.delete(oldest);
|
|
3054
|
-
}
|
|
3055
|
-
}
|
|
3056
|
-
var refreshWorker = null;
|
|
3057
|
-
var refreshSeq = 0;
|
|
3058
|
-
var refreshJobs = /* @__PURE__ */ new Map();
|
|
3059
|
-
var workerFailed = false;
|
|
3060
|
-
var keepStatusWorkerAlive = false;
|
|
3061
|
-
var workerCreates = 0;
|
|
3062
|
-
var respawnAttempts = 0;
|
|
3063
|
-
var respawnTimer = null;
|
|
3064
|
-
function releaseRefreshJobs(error) {
|
|
3065
|
-
const jobs = [...refreshJobs.values()];
|
|
3066
|
-
refreshJobs.clear();
|
|
3067
|
-
for (const job of jobs) job.resolve({ ok: false, error });
|
|
3068
|
-
}
|
|
3069
|
-
function scheduleWorkerRespawn() {
|
|
3070
|
-
if (!keepStatusWorkerAlive || respawnTimer || respawnAttempts >= 3) return;
|
|
3071
|
-
respawnAttempts += 1;
|
|
3072
|
-
const timer = setTimeout(() => {
|
|
3073
|
-
respawnTimer = null;
|
|
3074
|
-
if (refreshWorker || !keepStatusWorkerAlive) return;
|
|
3075
|
-
workerFailed = false;
|
|
3076
|
-
try {
|
|
3077
|
-
statusWorker();
|
|
3078
|
-
} catch {
|
|
3079
|
-
workerFailed = true;
|
|
3080
|
-
}
|
|
3081
|
-
}, 0);
|
|
3082
|
-
respawnTimer = timer;
|
|
3083
|
-
timer.unref();
|
|
3084
|
-
}
|
|
3085
|
-
var workerTargetOverride;
|
|
3086
|
-
function statusRefreshWorkerTarget() {
|
|
3087
|
-
if (workerTargetOverride !== void 0) return workerTargetOverride;
|
|
3088
|
-
const main = globalThis.Bun?.main ?? "";
|
|
3089
|
-
const url = decodeURIComponent(import.meta.url);
|
|
3090
|
-
const compiled = [main, url].some((value) => value.includes("$bunfs") || value.includes("~BUN"));
|
|
3091
|
-
if (compiled) {
|
|
3092
|
-
if (process.platform === "win32") return null;
|
|
3093
|
-
return "./services/status-refresh-worker.ts";
|
|
3094
|
-
}
|
|
3095
|
-
return new URL("./status-refresh-worker.ts", import.meta.url);
|
|
3096
|
-
}
|
|
3097
|
-
function completeRefreshJob(job, message) {
|
|
3098
|
-
if (message.value === void 0 || !message.watchedPaths) return;
|
|
3099
|
-
if (message.trace && job.postedAt !== void 0) {
|
|
3100
|
-
const roundTrip = performance.now() - job.postedAt;
|
|
3101
|
-
traceRecord(`phase=worker.round-trip job=${message.id}`, {
|
|
3102
|
-
ms: roundTrip,
|
|
3103
|
-
compute: message.trace.computeMs,
|
|
3104
|
-
json: message.trace.jsonMs,
|
|
3105
|
-
overhead: roundTrip - message.trace.computeMs - message.trace.jsonMs,
|
|
3106
|
-
kb: Math.round(message.trace.bytes / 1024)
|
|
3107
|
-
});
|
|
3108
|
-
}
|
|
3109
|
-
const freezeStarted = statusTraceEnabled ? performance.now() : 0;
|
|
3110
|
-
const frozen = deepFreeze(message.value);
|
|
3111
|
-
if (statusTraceEnabled) traceRecord(`phase=main.freeze job=${message.id}`, { ms: performance.now() - freezeStarted });
|
|
3112
|
-
if (job.home === process.env.HOME && job.generation === generation) {
|
|
3113
|
-
remember(job.key, job.projectPath, {
|
|
3114
|
-
value: frozen,
|
|
3115
|
-
watchedPaths: message.watchedPaths
|
|
3116
|
-
}, job.epochAtStart, job.writeGenAtStart, message.watchPaths);
|
|
3117
|
-
refreshCompletions += 1;
|
|
3118
|
-
respawnAttempts = 0;
|
|
3119
|
-
}
|
|
3120
|
-
job.resolve({
|
|
3121
|
-
ok: true,
|
|
3122
|
-
value: frozen,
|
|
3123
|
-
watchedPaths: message.watchedPaths
|
|
3124
|
-
});
|
|
3125
|
-
}
|
|
3126
|
-
var STATUS_WORKER_REPLY_TIMEOUT_MS = Number(process.env.HT_STATUS_WORKER_TIMEOUT_MS) || 8e3;
|
|
3127
|
-
var workerOnline = /* @__PURE__ */ new WeakSet();
|
|
3128
|
-
var compiledWorkerSkipLogged = false;
|
|
3129
|
-
function abandonUnresponsiveWorker(worker, waitedMs) {
|
|
3130
|
-
if (refreshWorker !== worker) return;
|
|
3131
|
-
refreshWorker = null;
|
|
3132
|
-
workerFailed = true;
|
|
3133
|
-
const state = workerOnline.has(worker) ? "started but did not reply" : "never started";
|
|
3134
|
-
const message = `status refresh worker ${state} within ${waitedMs}ms`;
|
|
3135
|
-
console.error(`[status-cache] refresh worker error: ${message}`);
|
|
3136
|
-
releaseRefreshJobs({ message });
|
|
3137
|
-
worker.removeAllListeners();
|
|
3138
|
-
void worker.terminate().catch(() => void 0);
|
|
3139
|
-
if (workerOnline.has(worker)) scheduleWorkerRespawn();
|
|
3140
|
-
else respawnAttempts = Number.POSITIVE_INFINITY;
|
|
3141
|
-
}
|
|
3142
|
-
function statusWorker() {
|
|
3143
|
-
if (refreshWorker) return refreshWorker;
|
|
3144
|
-
workerCreates += 1;
|
|
3145
|
-
const target = statusRefreshWorkerTarget();
|
|
3146
|
-
if (target === null) {
|
|
3147
|
-
if (!compiledWorkerSkipLogged) {
|
|
3148
|
-
compiledWorkerSkipLogged = true;
|
|
3149
|
-
console.error("[status-cache] compiled sidecar on Windows: computing status on the agent thread (no refresh worker)");
|
|
3150
|
-
}
|
|
3151
|
-
throw new Error("status refresh worker is not available in this build");
|
|
3152
|
-
}
|
|
3153
|
-
const worker = new Worker(target);
|
|
3154
|
-
worker.unref();
|
|
3155
|
-
worker.once("online", () => workerOnline.add(worker));
|
|
3156
|
-
worker.on("message", (message) => {
|
|
3157
|
-
switch (message.op) {
|
|
3158
|
-
case "dirty":
|
|
3159
|
-
if (message.home && message.home !== resolveHomeRoot()) return;
|
|
3160
|
-
if (!ignoreWatchDirt) markDirty();
|
|
3161
|
-
return;
|
|
3162
|
-
case "unhealthy":
|
|
3163
|
-
if (!ignoreWatchDirt) markWatchersUnhealthy();
|
|
3164
|
-
return;
|
|
3165
|
-
case "watch-report":
|
|
3166
|
-
watcherCreates += message.created;
|
|
3167
|
-
return;
|
|
3168
|
-
case void 0:
|
|
3169
|
-
break;
|
|
3170
|
-
default: {
|
|
3171
|
-
const _exhaustive = message;
|
|
3172
|
-
return _exhaustive;
|
|
3173
|
-
}
|
|
3174
|
-
}
|
|
3175
|
-
const job = refreshJobs.get(message.id);
|
|
3176
|
-
if (!job) return;
|
|
3177
|
-
refreshJobs.delete(message.id);
|
|
3178
|
-
try {
|
|
3179
|
-
if (!message.ok || message.value === void 0 || !message.watchedPaths) {
|
|
3180
|
-
const reported = message.error;
|
|
3181
|
-
job.resolve({
|
|
3182
|
-
ok: false,
|
|
3183
|
-
error: typeof reported === "string" ? { message: reported } : reported ?? { message: message.ok ? "status refresh worker returned no value" : "status refresh worker failed without an error" }
|
|
3184
|
-
});
|
|
3185
|
-
} else {
|
|
3186
|
-
completeRefreshJob(job, message);
|
|
3187
|
-
}
|
|
3188
|
-
} catch (error) {
|
|
3189
|
-
job.resolve({ ok: false, error: describeStatusRefreshError(error) });
|
|
3190
|
-
}
|
|
3191
|
-
if (refreshJobs.size === 0) worker.unref();
|
|
3192
|
-
releaseIdleWorker(worker);
|
|
3193
|
-
});
|
|
3194
|
-
worker.on("error", (error) => {
|
|
3195
|
-
if (refreshWorker === worker) refreshWorker = null;
|
|
3196
|
-
workerFailed = true;
|
|
3197
|
-
const described = describeStatusRefreshError(error);
|
|
3198
|
-
console.error(`[status-cache] refresh worker error: ${described.stack ?? described.message}`);
|
|
3199
|
-
releaseRefreshJobs({ message: `status refresh worker crashed: ${described.message}`, ...described.stack ? { stack: described.stack } : {} });
|
|
3200
|
-
scheduleWorkerRespawn();
|
|
3201
|
-
});
|
|
3202
|
-
worker.on("exit", (code) => {
|
|
3203
|
-
if (refreshWorker !== worker) return;
|
|
3204
|
-
refreshWorker = null;
|
|
3205
|
-
releaseRefreshJobs({ message: `status refresh worker exited with code ${code} before replying` });
|
|
3206
|
-
scheduleWorkerRespawn();
|
|
3207
|
-
});
|
|
3208
|
-
refreshWorker = worker;
|
|
3209
|
-
return worker;
|
|
3210
|
-
}
|
|
3211
|
-
function releaseIdleWorker(worker) {
|
|
3212
|
-
if (keepStatusWorkerAlive || refreshJobs.size > 0 || refreshWorker !== worker) return;
|
|
3213
|
-
setTimeout(() => {
|
|
3214
|
-
if (keepStatusWorkerAlive || refreshJobs.size > 0 || refreshWorker !== worker) return;
|
|
3215
|
-
refreshWorker = null;
|
|
3216
|
-
void worker.terminate();
|
|
3217
|
-
}, 0);
|
|
3218
|
-
}
|
|
3219
|
-
function blockRefreshDelay() {
|
|
3220
|
-
if (statusRefreshDelayMs <= 0) return;
|
|
3221
|
-
const shared = new SharedArrayBuffer(4);
|
|
3222
|
-
Atomics.wait(new Int32Array(shared), 0, 0, statusRefreshDelayMs);
|
|
3223
|
-
}
|
|
3224
|
-
function enqueueStatusRefresh(key, projectPath, input, load, epochAtStart, gen) {
|
|
3225
|
-
const home = process.env.HOME;
|
|
3226
|
-
return new Promise((resolve3) => {
|
|
3227
|
-
const runInProcess = () => {
|
|
3228
|
-
setTimeout(() => {
|
|
3229
|
-
void (async () => {
|
|
3230
|
-
try {
|
|
3231
|
-
blockRefreshDelay();
|
|
3232
|
-
const loaded = await load();
|
|
3233
|
-
if (gen === generation && home === process.env.HOME) {
|
|
3234
|
-
remember(key, projectPath, loaded, epochAtStart, readStatusWriteGeneration());
|
|
3235
|
-
refreshCompletions += 1;
|
|
3236
|
-
}
|
|
3237
|
-
resolve3({
|
|
3238
|
-
ok: true,
|
|
3239
|
-
value: deepFreeze(loaded.value),
|
|
3240
|
-
watchedPaths: [...loaded.watchedPaths]
|
|
3241
|
-
});
|
|
3242
|
-
} catch (error) {
|
|
3243
|
-
resolve3({ ok: false, error: describeStatusRefreshError(error) });
|
|
3244
|
-
}
|
|
3245
|
-
})();
|
|
3246
|
-
}, 0);
|
|
3247
|
-
};
|
|
3248
|
-
if (workerFailed && !refreshWorker) {
|
|
3249
|
-
runInProcess();
|
|
3250
|
-
return;
|
|
3251
|
-
}
|
|
3252
|
-
let worker;
|
|
3253
|
-
try {
|
|
3254
|
-
worker = statusWorker();
|
|
3255
|
-
} catch {
|
|
3256
|
-
workerFailed = true;
|
|
3257
|
-
runInProcess();
|
|
3258
|
-
return;
|
|
3259
|
-
}
|
|
3260
|
-
const id = ++refreshSeq;
|
|
3261
|
-
refreshJobs.set(id, {
|
|
3262
|
-
key,
|
|
3263
|
-
projectPath,
|
|
3264
|
-
generation: gen,
|
|
3265
|
-
epochAtStart,
|
|
3266
|
-
writeGenAtStart: readStatusWriteGeneration(),
|
|
3267
|
-
home,
|
|
3268
|
-
...statusTraceEnabled ? { postedAt: performance.now() } : {},
|
|
3269
|
-
resolve: (outcome) => {
|
|
3270
|
-
if (outcome.ok) {
|
|
3271
|
-
resolve3(outcome);
|
|
3272
|
-
return;
|
|
3273
|
-
}
|
|
3274
|
-
const reason = outcome.error?.stack ?? outcome.error?.message ?? "no error was reported";
|
|
3275
|
-
console.error(`[status-cache] refresh worker failed, computing status on this thread: ${reason}`);
|
|
3276
|
-
runInProcess();
|
|
3277
|
-
}
|
|
3278
|
-
});
|
|
3279
|
-
worker.ref();
|
|
3280
|
-
const waitMs = STATUS_WORKER_REPLY_TIMEOUT_MS + statusRefreshDelayMs;
|
|
3281
|
-
const replyTimer = setTimeout(() => {
|
|
3282
|
-
if (refreshJobs.has(id)) abandonUnresponsiveWorker(worker, waitMs);
|
|
3283
|
-
}, waitMs);
|
|
3284
|
-
replyTimer.unref?.();
|
|
3285
|
-
const job = refreshJobs.get(id);
|
|
3286
|
-
if (job) {
|
|
3287
|
-
const settle = job.resolve;
|
|
3288
|
-
job.resolve = (outcome) => {
|
|
3289
|
-
clearTimeout(replyTimer);
|
|
3290
|
-
settle(outcome);
|
|
3291
|
-
};
|
|
3292
|
-
}
|
|
3293
|
-
try {
|
|
3294
|
-
worker.postMessage({
|
|
3295
|
-
id,
|
|
3296
|
-
home,
|
|
3297
|
-
userProfile: process.env.USERPROFILE,
|
|
3298
|
-
harnesstapHome: process.env.HARNESSTAP_HOME,
|
|
3299
|
-
depth: input.depth,
|
|
3300
|
-
harness: input.harness,
|
|
3301
|
-
projectPath: input.projectPath,
|
|
3302
|
-
delayMs: statusRefreshDelayMs
|
|
3303
|
-
});
|
|
3304
|
-
} catch {
|
|
3305
|
-
refreshJobs.delete(id);
|
|
3306
|
-
worker.unref();
|
|
3307
|
-
workerFailed = true;
|
|
3308
|
-
refreshWorker = null;
|
|
3309
|
-
runInProcess();
|
|
3310
|
-
}
|
|
3311
|
-
});
|
|
3312
|
-
}
|
|
3313
|
-
function trackRefresh(key, projectPath, input, load, gen) {
|
|
3314
|
-
let resolveDone = () => {
|
|
3315
|
-
};
|
|
3316
|
-
const promise = new Promise((resolve3) => {
|
|
3317
|
-
resolveDone = resolve3;
|
|
3318
|
-
});
|
|
3319
|
-
inflight.set(key, { generation: gen, promise });
|
|
3320
|
-
const epochAtStart = epoch;
|
|
3321
|
-
return enqueueStatusRefresh(key, projectPath, input, load, epochAtStart, gen).finally(() => {
|
|
3322
|
-
resolveDone();
|
|
3323
|
-
const current = inflight.get(key);
|
|
3324
|
-
if (current?.promise === promise) inflight.delete(key);
|
|
3325
|
-
});
|
|
3326
|
-
}
|
|
3327
|
-
function scheduleRefresh(key, projectPath, input, load) {
|
|
3328
|
-
const gen = generation;
|
|
3329
|
-
const pending = inflight.get(key);
|
|
3330
|
-
if (pending && pending.generation === gen) return;
|
|
3331
|
-
void trackRefresh(key, projectPath, input, load, gen);
|
|
3332
|
-
}
|
|
3333
|
-
async function loadNow(key, projectPath, input, load) {
|
|
3334
|
-
const gen = generation;
|
|
3335
|
-
const pending = inflight.get(key);
|
|
3336
|
-
if (pending && pending.generation === gen) {
|
|
3337
|
-
await pending.promise;
|
|
3338
|
-
const cached2 = buckets.get(key);
|
|
3339
|
-
if (cached2 && staleReason(cached2) === null) {
|
|
3340
|
-
return present(cached2.value, false);
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
const outcome = await trackRefresh(key, projectPath, input, load, gen);
|
|
3344
|
-
const cached = buckets.get(key);
|
|
3345
|
-
if (cached && gen === generation && entryIsCurrent(cached)) {
|
|
3346
|
-
return present(cached.value, false);
|
|
3347
|
-
}
|
|
3348
|
-
if (outcome.ok && outcome.value !== void 0) {
|
|
3349
|
-
return present(outcome.value, false);
|
|
3350
|
-
}
|
|
3351
|
-
const cause = outcome.error ?? { message: "no error was reported" };
|
|
3352
|
-
const where = projectPath ? ` (projectPath=${projectPath})` : "";
|
|
3353
|
-
console.error(`[status-cache] status read failed${where}: ${cause.stack ?? cause.message}`);
|
|
3354
|
-
const failure = new Error(`Status read failed: ${cause.message}`);
|
|
3355
|
-
if (cause.stack) failure.stack = `Error: Status read failed: ${cause.message}
|
|
3356
|
-
Caused by: ${cause.stack}`;
|
|
3357
|
-
throw failure;
|
|
3358
|
-
}
|
|
3359
|
-
async function withStatusReadCache(input, load, options) {
|
|
3360
|
-
const startedAt = performance.now();
|
|
3361
|
-
const key = requestKey(input);
|
|
3362
|
-
const cached = buckets.get(key);
|
|
3363
|
-
const reason = cached ? staleReason(cached) : "cold";
|
|
3364
|
-
if (cached && reason === null) {
|
|
3365
|
-
noteHit(startedAt);
|
|
3366
|
-
return present(cached.value, false);
|
|
3367
|
-
}
|
|
3368
|
-
noteMiss(reason ?? "cold");
|
|
3369
|
-
if (reason === "write" || reason === "data_version") {
|
|
3370
|
-
generation += 1;
|
|
3371
|
-
buckets.clear();
|
|
3372
|
-
return loadNow(key, input.projectPath, input, load);
|
|
3373
|
-
}
|
|
3374
|
-
if (options?.staleWhileRefresh && cached) {
|
|
3375
|
-
scheduleRefresh(key, input.projectPath, input, load);
|
|
3376
|
-
return present(cached.value, true);
|
|
3377
|
-
}
|
|
3378
|
-
return loadNow(key, input.projectPath, input, load);
|
|
3379
|
-
}
|
|
3380
|
-
|
|
3381
|
-
// src/services/live-read-cache.ts
|
|
3382
|
-
function clearLiveReadCaches() {
|
|
3383
|
-
clearGlobalProfileStatusCache();
|
|
3384
|
-
clearCursorPluginInstallsCache();
|
|
3385
|
-
}
|
|
3386
|
-
|
|
3387
|
-
export {
|
|
3388
|
-
CURSOR_LOCAL_PLUGIN_SIDECAR,
|
|
3389
|
-
CURSOR_LOCAL_PLUGINS_RELATIVE_ROOT,
|
|
3390
|
-
sanitizeCursorLocalFolderSegment,
|
|
3391
|
-
cursorLocalPluginFolderName,
|
|
3392
|
-
cursorLocalPluginSidecarContent,
|
|
3393
|
-
pruneManagedCursorLocalPlugins,
|
|
3394
|
-
listCursorPluginInstalls,
|
|
3395
|
-
getPlatform,
|
|
3396
|
-
getAllPlatforms,
|
|
3397
|
-
getPlatformIds,
|
|
3398
|
-
resourceClass,
|
|
3399
|
-
collectEnvironmentVarPlaceholders,
|
|
3400
|
-
substituteResourcesForApply,
|
|
3401
|
-
parseMcpServerEntry,
|
|
3402
|
-
parseMcpServersDocument,
|
|
3403
|
-
mcpConfigContentsEquivalent,
|
|
3404
|
-
emitCursorMcpServerEntry,
|
|
3405
|
-
resolveHomeRoot,
|
|
3406
|
-
getProjectByOrigin,
|
|
3407
|
-
getProject,
|
|
3408
|
-
upsertProject,
|
|
3409
|
-
listProjects,
|
|
3410
|
-
getProjectByLocalPath,
|
|
3411
|
-
applyConfiguredPluginToProject,
|
|
3412
|
-
getProjectConfiguredPlugins,
|
|
3413
|
-
hasInstallPath,
|
|
3414
|
-
pluginInstallToPinInput,
|
|
3415
|
-
dedupePluginInstalls,
|
|
3416
|
-
claudePluginsDir,
|
|
3417
|
-
readManifestVersion,
|
|
3418
|
-
resolveInstalledRecordPath,
|
|
3419
|
-
getInstalledPluginRecord,
|
|
3420
|
-
getInstalledPluginInstallPath,
|
|
3421
|
-
loadInstalled,
|
|
3422
|
-
listInstalledPluginPinCreateInputs,
|
|
3423
|
-
marketplaceIsConfigured,
|
|
3424
|
-
resolveClaudeInstallRefCandidates,
|
|
3425
|
-
resolveCatalogPluginMarketplaceBootstrap,
|
|
3426
|
-
resolveClaudeEnabledPluginRef,
|
|
3427
|
-
findInstalledRefForCatalogPin,
|
|
3428
|
-
createGlobalApplySnapshot,
|
|
3429
|
-
recordGlobalApplySnapshotInstall,
|
|
3430
|
-
getGlobalApplySnapshot,
|
|
3431
|
-
listGlobalApplySnapshots,
|
|
3432
|
-
getLatestGlobalApplySnapshotForProfile,
|
|
3433
|
-
listGlobalApplySnapshotHeads,
|
|
3434
|
-
renameGlobalApplySnapshotsProfile,
|
|
3435
|
-
listGlobalApplySnapshotInstalls,
|
|
3436
|
-
getActiveProfileName,
|
|
3437
|
-
setActiveProfileName,
|
|
3438
|
-
clearActiveProfileName,
|
|
3439
|
-
markSourceRefreshed,
|
|
3440
|
-
getSourcesToRefresh,
|
|
3441
|
-
listHostNativeMcpNames,
|
|
3442
|
-
hostPluginPinIsInstalled,
|
|
3443
|
-
CursorPluginProvider,
|
|
3444
|
-
createSnapshot,
|
|
3445
|
-
findSnapshotById,
|
|
3446
|
-
listSnapshots,
|
|
3447
|
-
getLatestSnapshot,
|
|
3448
|
-
getGitOrigin,
|
|
3449
|
-
normalizeGitUrl,
|
|
3450
|
-
projectNameFromUrl,
|
|
3451
|
-
driftChangeIsKept,
|
|
3452
|
-
detectProjectDriftFromLatest,
|
|
3453
|
-
collectOwnedGlobalProfileFiles,
|
|
3454
|
-
classifyGlobalDriftChanges,
|
|
3455
|
-
declaredMcpFromExpectedFiles,
|
|
3456
|
-
resolveProjectDriftSummary,
|
|
3457
|
-
computeGlobalProfilePanelStatus,
|
|
3458
|
-
buildHarnessLiveStatusMap,
|
|
3459
|
-
countMissingHarnessRows,
|
|
3460
|
-
withStatusReadCache,
|
|
3461
|
-
clearLiveReadCaches
|
|
3462
|
-
};
|
|
3463
|
-
//# sourceMappingURL=chunk-DF4Z7LAD.js.map
|