harnesstap 1.2.0 → 1.3.1
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 +28 -15
- package/dist/apply-2GRNKR5H.js +67 -0
- package/dist/apply-2GRNKR5H.js.map +1 -0
- package/dist/approve-KQNCNH2R.js +181 -0
- package/dist/approve-KQNCNH2R.js.map +1 -0
- package/dist/audit-SLYOZCMI.js +434 -0
- package/dist/audit-SLYOZCMI.js.map +1 -0
- package/dist/auth-3IEVICFT.js +220 -0
- package/dist/auth-3IEVICFT.js.map +1 -0
- package/dist/bin.js +166 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-2EIJYDNI.js +10945 -0
- package/dist/chunk-2EIJYDNI.js.map +1 -0
- package/dist/chunk-2H7UOFLK.js +11 -0
- package/dist/chunk-2H7UOFLK.js.map +1 -0
- package/dist/chunk-37E5M4JX.js +34 -0
- package/dist/chunk-37E5M4JX.js.map +1 -0
- package/dist/chunk-3FIWOI3H.js +98 -0
- package/dist/chunk-3FIWOI3H.js.map +1 -0
- package/dist/chunk-3IWTJCPA.js +6448 -0
- package/dist/chunk-3IWTJCPA.js.map +1 -0
- package/dist/chunk-3IZ7SEGT.js +346 -0
- package/dist/chunk-3IZ7SEGT.js.map +1 -0
- package/dist/chunk-3RBYT7QN.js +540 -0
- package/dist/chunk-3RBYT7QN.js.map +1 -0
- package/dist/chunk-4KNQZDZC.js +115 -0
- package/dist/chunk-4KNQZDZC.js.map +1 -0
- package/dist/chunk-5F3LNDZG.js +9 -0
- package/dist/chunk-5F3LNDZG.js.map +1 -0
- package/dist/chunk-63U7QWNY.js +364 -0
- package/dist/chunk-63U7QWNY.js.map +1 -0
- package/dist/chunk-6BY4BV5G.js +998 -0
- package/dist/chunk-6BY4BV5G.js.map +1 -0
- package/dist/chunk-7L2K4N25.js +610 -0
- package/dist/chunk-7L2K4N25.js.map +1 -0
- package/dist/chunk-7LWH5SWH.js +18 -0
- package/dist/chunk-7LWH5SWH.js.map +1 -0
- package/dist/chunk-BIBUCC2E.js +696 -0
- package/dist/chunk-BIBUCC2E.js.map +1 -0
- package/dist/chunk-BSOBXLYI.js +172 -0
- package/dist/chunk-BSOBXLYI.js.map +1 -0
- package/dist/chunk-C4QBVVEH.js +32 -0
- package/dist/chunk-C4QBVVEH.js.map +1 -0
- package/dist/chunk-CHQGE2HF.js +283 -0
- package/dist/chunk-CHQGE2HF.js.map +1 -0
- package/dist/chunk-DV74UZJI.js +87 -0
- package/dist/chunk-DV74UZJI.js.map +1 -0
- package/dist/chunk-DWVAR4BP.js +656 -0
- package/dist/chunk-DWVAR4BP.js.map +1 -0
- package/dist/chunk-DXKAKKLP.js +302 -0
- package/dist/chunk-DXKAKKLP.js.map +1 -0
- package/dist/chunk-EIWXS4RM.js +235 -0
- package/dist/chunk-EIWXS4RM.js.map +1 -0
- package/dist/chunk-EWBCFAF3.js +681 -0
- package/dist/chunk-EWBCFAF3.js.map +1 -0
- package/dist/chunk-F2L4VNQK.js +1759 -0
- package/dist/chunk-F2L4VNQK.js.map +1 -0
- package/dist/chunk-G26HZZDJ.js +1359 -0
- package/dist/chunk-G26HZZDJ.js.map +1 -0
- package/dist/chunk-GQKKX7OE.js +818 -0
- package/dist/chunk-GQKKX7OE.js.map +1 -0
- package/dist/chunk-GRJY22U6.js +691 -0
- package/dist/chunk-GRJY22U6.js.map +1 -0
- package/dist/chunk-H6DVP2SI.js +682 -0
- package/dist/chunk-H6DVP2SI.js.map +1 -0
- package/dist/chunk-HVVPTCKR.js +1173 -0
- package/dist/chunk-HVVPTCKR.js.map +1 -0
- package/dist/chunk-I6XFZLTJ.js +9 -0
- package/dist/chunk-I6XFZLTJ.js.map +1 -0
- package/dist/chunk-IBOABSIA.js +17 -0
- package/dist/chunk-IBOABSIA.js.map +1 -0
- package/dist/chunk-IK524ZDW.js +691 -0
- package/dist/chunk-IK524ZDW.js.map +1 -0
- package/dist/chunk-IRU7NBOT.js +141 -0
- package/dist/chunk-IRU7NBOT.js.map +1 -0
- package/dist/chunk-J4CKQXQ6.js +806 -0
- package/dist/chunk-J4CKQXQ6.js.map +1 -0
- package/dist/chunk-JKGSJGCC.js +311 -0
- package/dist/chunk-JKGSJGCC.js.map +1 -0
- package/dist/chunk-JQOKQKQT.js +158 -0
- package/dist/chunk-JQOKQKQT.js.map +1 -0
- package/dist/chunk-JRFUTIEH.js +426 -0
- package/dist/chunk-JRFUTIEH.js.map +1 -0
- package/dist/chunk-K2BPYEH5.js +491 -0
- package/dist/chunk-K2BPYEH5.js.map +1 -0
- package/dist/chunk-KCQC7YBK.js +7795 -0
- package/dist/chunk-KCQC7YBK.js.map +1 -0
- package/dist/chunk-KDAV2GUT.js +1357 -0
- package/dist/chunk-KDAV2GUT.js.map +1 -0
- package/dist/chunk-KDDXZBMC.js +583 -0
- package/dist/chunk-KDDXZBMC.js.map +1 -0
- package/dist/chunk-KMWHZSEG.js +41 -0
- package/dist/chunk-KMWHZSEG.js.map +1 -0
- package/dist/chunk-KRI4R7EM.js +25 -0
- package/dist/chunk-KRI4R7EM.js.map +1 -0
- package/dist/chunk-LNJ3WZZX.js +186 -0
- package/dist/chunk-LNJ3WZZX.js.map +1 -0
- package/dist/chunk-MWXA4PFE.js +103 -0
- package/dist/chunk-MWXA4PFE.js.map +1 -0
- package/dist/chunk-MY62SSKC.js +183 -0
- package/dist/chunk-MY62SSKC.js.map +1 -0
- package/dist/chunk-NAGAJ5UM.js +145 -0
- package/dist/chunk-NAGAJ5UM.js.map +1 -0
- package/dist/chunk-NJ7WRKIQ.js +532 -0
- package/dist/chunk-NJ7WRKIQ.js.map +1 -0
- package/dist/chunk-OS6NUIBJ.js +38 -0
- package/dist/chunk-OS6NUIBJ.js.map +1 -0
- package/dist/chunk-PXU2OS26.js +238 -0
- package/dist/chunk-PXU2OS26.js.map +1 -0
- package/dist/chunk-QO4LBDVI.js +496 -0
- package/dist/chunk-QO4LBDVI.js.map +1 -0
- package/dist/chunk-QRZPQNLX.js +65 -0
- package/dist/chunk-QRZPQNLX.js.map +1 -0
- package/dist/chunk-SNVAMWB7.js +40 -0
- package/dist/chunk-SNVAMWB7.js.map +1 -0
- package/dist/chunk-SPRVUATR.js +430 -0
- package/dist/chunk-SPRVUATR.js.map +1 -0
- package/dist/chunk-SY7G5QEI.js +35 -0
- package/dist/chunk-SY7G5QEI.js.map +1 -0
- package/dist/chunk-SZNBUIDR.js +6438 -0
- package/dist/chunk-SZNBUIDR.js.map +1 -0
- package/dist/chunk-TQ2NA4Z4.js +24 -0
- package/dist/chunk-TQ2NA4Z4.js.map +1 -0
- package/dist/chunk-TYULB6ZY.js +2959 -0
- package/dist/chunk-TYULB6ZY.js.map +1 -0
- package/dist/chunk-UJYFTXHV.js +296 -0
- package/dist/chunk-UJYFTXHV.js.map +1 -0
- package/dist/chunk-VC6OKCJF.js +184 -0
- package/dist/chunk-VC6OKCJF.js.map +1 -0
- package/dist/chunk-VL2NWCZV.js +118 -0
- package/dist/chunk-VL2NWCZV.js.map +1 -0
- package/dist/chunk-VL7BGD47.js +514 -0
- package/dist/chunk-VL7BGD47.js.map +1 -0
- package/dist/chunk-VQVUJYYY.js +244 -0
- package/dist/chunk-VQVUJYYY.js.map +1 -0
- package/dist/chunk-VZQG2JDV.js +9 -0
- package/dist/chunk-VZQG2JDV.js.map +1 -0
- package/dist/chunk-XFZQVYIN.js +115 -0
- package/dist/chunk-XFZQVYIN.js.map +1 -0
- package/dist/chunk-XGTTOO4R.js +84 -0
- package/dist/chunk-XGTTOO4R.js.map +1 -0
- package/dist/chunk-XQFT4PEP.js +60 -0
- package/dist/chunk-XQFT4PEP.js.map +1 -0
- package/dist/chunk-YDD3ES2K.js +571 -0
- package/dist/chunk-YDD3ES2K.js.map +1 -0
- package/dist/chunk-ZY2MZ2KQ.js +1140 -0
- package/dist/chunk-ZY2MZ2KQ.js.map +1 -0
- package/dist/compile-57EEIUMB.js +161 -0
- package/dist/compile-57EEIUMB.js.map +1 -0
- package/dist/config-4EJ3D7QJ.js +438 -0
- package/dist/config-4EJ3D7QJ.js.map +1 -0
- package/dist/doctor-EEV6P5CH.js +111 -0
- package/dist/doctor-EEV6P5CH.js.map +1 -0
- package/dist/environment-WFEG4DAT.js +2745 -0
- package/dist/environment-WFEG4DAT.js.map +1 -0
- package/dist/github-BSMQD72A.js +114 -0
- package/dist/github-BSMQD72A.js.map +1 -0
- package/dist/harness-VX3PNVQW.js +746 -0
- package/dist/harness-VX3PNVQW.js.map +1 -0
- package/dist/help-AW2HKX63.js +2079 -0
- package/dist/help-AW2HKX63.js.map +1 -0
- package/dist/help-BVFOZD7E.js +1892 -0
- package/dist/help-BVFOZD7E.js.map +1 -0
- package/dist/index.d.ts +164 -1
- package/dist/index.js +50 -59246
- package/dist/index.js.map +1 -1
- package/dist/init-SPN2GEZ4.js +873 -0
- package/dist/init-SPN2GEZ4.js.map +1 -0
- package/dist/lock-K2LLUU7H.js +455 -0
- package/dist/lock-K2LLUU7H.js.map +1 -0
- package/dist/marketplace-VEKSWGX3.js +495 -0
- package/dist/marketplace-VEKSWGX3.js.map +1 -0
- package/dist/mcp-T6DKIKSF.js +202 -0
- package/dist/mcp-T6DKIKSF.js.map +1 -0
- package/dist/migrate-OO37WSB2.js +1043 -0
- package/dist/migrate-OO37WSB2.js.map +1 -0
- package/dist/open-3V3QK5RK.js +32 -0
- package/dist/open-3V3QK5RK.js.map +1 -0
- package/dist/pack-V32UPC7W.js +99 -0
- package/dist/pack-V32UPC7W.js.map +1 -0
- package/dist/plugin-KOBNQ7GT.js +64 -0
- package/dist/plugin-KOBNQ7GT.js.map +1 -0
- package/dist/plugin-from-project-X3VO3MB6.js +16 -0
- package/dist/plugin-from-project-X3VO3MB6.js.map +1 -0
- package/dist/policy-F5MKZNOC.js +105 -0
- package/dist/policy-F5MKZNOC.js.map +1 -0
- package/dist/profile-H4PMH4XT.js +1886 -0
- package/dist/profile-H4PMH4XT.js.map +1 -0
- package/dist/project-QVNEJJGH.js +1392 -0
- package/dist/project-QVNEJJGH.js.map +1 -0
- package/dist/resource-GL4RLSGI.js +555 -0
- package/dist/resource-GL4RLSGI.js.map +1 -0
- package/dist/version-PBHZK44K.js +17 -0
- package/dist/version-PBHZK44K.js.map +1 -0
- package/package.json +21 -14
- package/schemas/ap-package.v1.json +36 -0
- package/schemas/fixtures/catalog-missing-schema.ap.json +13 -0
- package/schemas/fixtures/confidence.ap.json +13 -0
- package/schemas/fixtures/context7.ap.json +13 -0
- package/schemas/fixtures/minimal-with-schema.ap.json +13 -0
- package/schemas/fixtures/superpowers.ap.json +13 -0
- package/schemas/fixtures/third-party-skills.ap.json +13 -0
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
import {
|
|
2
|
+
detectProjectDriftFromLatest,
|
|
3
|
+
getGitOrigin,
|
|
4
|
+
isMcpConfigManagedPath,
|
|
5
|
+
listGlobalApplySnapshotInstalls,
|
|
6
|
+
listHostNativeMcpNames,
|
|
7
|
+
normalizeGitUrl,
|
|
8
|
+
resourceKeyFromManagedPath
|
|
9
|
+
} from "./chunk-KCQC7YBK.js";
|
|
10
|
+
import {
|
|
11
|
+
getProjectByLocalPath,
|
|
12
|
+
getProjectByOrigin
|
|
13
|
+
} from "./chunk-UJYFTXHV.js";
|
|
14
|
+
import {
|
|
15
|
+
findInstalledRefForCatalogPin,
|
|
16
|
+
getPlatform,
|
|
17
|
+
isClaudeSettingsPath,
|
|
18
|
+
isClaudeUserJsonPath,
|
|
19
|
+
isMuseSettingsPath,
|
|
20
|
+
listCursorPluginFootprintNames,
|
|
21
|
+
listCursorPluginInstalls,
|
|
22
|
+
loadInstalled,
|
|
23
|
+
mcpServerMetadataEquivalent,
|
|
24
|
+
parseHooksJsonContent,
|
|
25
|
+
parseMcpServersDocument
|
|
26
|
+
} from "./chunk-2EIJYDNI.js";
|
|
27
|
+
import {
|
|
28
|
+
parsePluginRef
|
|
29
|
+
} from "./chunk-6BY4BV5G.js";
|
|
30
|
+
|
|
31
|
+
// src/utils/unified-diff.ts
|
|
32
|
+
function splitLines(text) {
|
|
33
|
+
if (text.length === 0) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const parts = text.split("\n");
|
|
37
|
+
if (text.endsWith("\n")) {
|
|
38
|
+
return parts.slice(0, -1);
|
|
39
|
+
}
|
|
40
|
+
return parts;
|
|
41
|
+
}
|
|
42
|
+
function computeOps(oldLines, newLines) {
|
|
43
|
+
const m = oldLines.length;
|
|
44
|
+
const n = newLines.length;
|
|
45
|
+
const dp = Array.from(
|
|
46
|
+
{ length: m + 1 },
|
|
47
|
+
() => Array.from({ length: n + 1 }, () => 0)
|
|
48
|
+
);
|
|
49
|
+
for (let i2 = m - 1; i2 >= 0; i2--) {
|
|
50
|
+
for (let j2 = n - 1; j2 >= 0; j2--) {
|
|
51
|
+
if (oldLines[i2] === newLines[j2]) {
|
|
52
|
+
dp[i2][j2] = (dp[i2 + 1][j2 + 1] ?? 0) + 1;
|
|
53
|
+
} else {
|
|
54
|
+
dp[i2][j2] = Math.max(dp[i2 + 1][j2] ?? 0, dp[i2][j2 + 1] ?? 0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const ops = [];
|
|
59
|
+
let i = 0;
|
|
60
|
+
let j = 0;
|
|
61
|
+
while (i < m && j < n) {
|
|
62
|
+
if (oldLines[i] === newLines[j]) {
|
|
63
|
+
ops.push({ kind: "equal", line: oldLines[i] });
|
|
64
|
+
i++;
|
|
65
|
+
j++;
|
|
66
|
+
} else if ((dp[i + 1][j] ?? 0) >= (dp[i][j + 1] ?? 0)) {
|
|
67
|
+
ops.push({ kind: "delete", line: oldLines[i] });
|
|
68
|
+
i++;
|
|
69
|
+
} else {
|
|
70
|
+
ops.push({ kind: "insert", line: newLines[j] });
|
|
71
|
+
j++;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
while (i < m) {
|
|
75
|
+
ops.push({ kind: "delete", line: oldLines[i] });
|
|
76
|
+
i++;
|
|
77
|
+
}
|
|
78
|
+
while (j < n) {
|
|
79
|
+
ops.push({ kind: "insert", line: newLines[j] });
|
|
80
|
+
j++;
|
|
81
|
+
}
|
|
82
|
+
return ops;
|
|
83
|
+
}
|
|
84
|
+
function advanceLine(op, oldLine, newLine) {
|
|
85
|
+
switch (op.kind) {
|
|
86
|
+
case "equal":
|
|
87
|
+
return { oldLine: oldLine + 1, newLine: newLine + 1 };
|
|
88
|
+
case "delete":
|
|
89
|
+
return { oldLine: oldLine + 1, newLine };
|
|
90
|
+
case "insert":
|
|
91
|
+
return { oldLine, newLine: newLine + 1 };
|
|
92
|
+
default: {
|
|
93
|
+
const _never = op.kind;
|
|
94
|
+
return _never;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function buildUnifiedDiffLines(path, from, to, contextLines = 3) {
|
|
99
|
+
const ops = computeOps(splitLines(from), splitLines(to));
|
|
100
|
+
if (ops.every((op) => op.kind === "equal")) {
|
|
101
|
+
return [{ kind: "meta", text: "(no content differences)" }];
|
|
102
|
+
}
|
|
103
|
+
const result = [
|
|
104
|
+
{ kind: "meta", text: `--- live/${path}` },
|
|
105
|
+
{ kind: "meta", text: `+++ after-apply/${path}` }
|
|
106
|
+
];
|
|
107
|
+
const include = new Array(ops.length).fill(false);
|
|
108
|
+
for (let index = 0; index < ops.length; index++) {
|
|
109
|
+
if (ops[index].kind === "equal") {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
include[index] = true;
|
|
113
|
+
let before = 0;
|
|
114
|
+
for (let k = index - 1; k >= 0 && before < contextLines; k--) {
|
|
115
|
+
include[k] = true;
|
|
116
|
+
if (ops[k].kind === "equal") {
|
|
117
|
+
before++;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
let after = 0;
|
|
121
|
+
for (let k = index + 1; k < ops.length && after < contextLines; k++) {
|
|
122
|
+
include[k] = true;
|
|
123
|
+
if (ops[k].kind === "equal") {
|
|
124
|
+
after++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
let opIndex = 0;
|
|
129
|
+
let oldLine = 1;
|
|
130
|
+
let newLine = 1;
|
|
131
|
+
while (opIndex < ops.length) {
|
|
132
|
+
if (!include[opIndex]) {
|
|
133
|
+
const advanced = advanceLine(ops[opIndex], oldLine, newLine);
|
|
134
|
+
oldLine = advanced.oldLine;
|
|
135
|
+
newLine = advanced.newLine;
|
|
136
|
+
opIndex++;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const hunkStart = opIndex;
|
|
140
|
+
const hunkOldStart = oldLine;
|
|
141
|
+
const hunkNewStart = newLine;
|
|
142
|
+
while (opIndex < ops.length && include[opIndex]) {
|
|
143
|
+
opIndex++;
|
|
144
|
+
}
|
|
145
|
+
const hunkEnd = opIndex;
|
|
146
|
+
let oldCount = 0;
|
|
147
|
+
let newCount = 0;
|
|
148
|
+
const body = [];
|
|
149
|
+
for (let k = hunkStart; k < hunkEnd; k++) {
|
|
150
|
+
const op = ops[k];
|
|
151
|
+
switch (op.kind) {
|
|
152
|
+
case "equal":
|
|
153
|
+
body.push({ kind: "context", text: ` ${op.line}` });
|
|
154
|
+
oldCount++;
|
|
155
|
+
newCount++;
|
|
156
|
+
break;
|
|
157
|
+
case "delete":
|
|
158
|
+
body.push({ kind: "remove", text: `-${op.line}` });
|
|
159
|
+
oldCount++;
|
|
160
|
+
break;
|
|
161
|
+
case "insert":
|
|
162
|
+
body.push({ kind: "add", text: `+${op.line}` });
|
|
163
|
+
newCount++;
|
|
164
|
+
break;
|
|
165
|
+
default: {
|
|
166
|
+
const _never = op.kind;
|
|
167
|
+
return _never;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const advanced = advanceLine(op, oldLine, newLine);
|
|
171
|
+
oldLine = advanced.oldLine;
|
|
172
|
+
newLine = advanced.newLine;
|
|
173
|
+
}
|
|
174
|
+
result.push({
|
|
175
|
+
kind: "hunk",
|
|
176
|
+
text: `@@ -${hunkOldStart},${oldCount} +${hunkNewStart},${newCount} @@`
|
|
177
|
+
});
|
|
178
|
+
result.push(...body);
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
function fileDiffHasContentChange(path, current, expected) {
|
|
183
|
+
const { added, removed } = countUnifiedDiffChanges(
|
|
184
|
+
buildUnifiedDiffLines(path, current, expected)
|
|
185
|
+
);
|
|
186
|
+
return added > 0 || removed > 0;
|
|
187
|
+
}
|
|
188
|
+
function countUnifiedDiffChanges(lines) {
|
|
189
|
+
let added = 0;
|
|
190
|
+
let removed = 0;
|
|
191
|
+
for (const line of lines) {
|
|
192
|
+
switch (line.kind) {
|
|
193
|
+
case "add":
|
|
194
|
+
added++;
|
|
195
|
+
break;
|
|
196
|
+
case "remove":
|
|
197
|
+
removed++;
|
|
198
|
+
break;
|
|
199
|
+
case "meta":
|
|
200
|
+
case "hunk":
|
|
201
|
+
case "context":
|
|
202
|
+
break;
|
|
203
|
+
default: {
|
|
204
|
+
const _never = line.kind;
|
|
205
|
+
return _never;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return { added, removed };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/services/host-config-resource-detail.ts
|
|
213
|
+
var PERMISSION_ACTIONS = ["allow", "deny", "ask"];
|
|
214
|
+
function isRecord(value) {
|
|
215
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
216
|
+
}
|
|
217
|
+
function formatJsonFragment(value) {
|
|
218
|
+
return `${JSON.stringify(value, null, 2)}
|
|
219
|
+
`;
|
|
220
|
+
}
|
|
221
|
+
function parseJsonObject(content) {
|
|
222
|
+
try {
|
|
223
|
+
const parsed = JSON.parse(content);
|
|
224
|
+
return isRecord(parsed) ? parsed : null;
|
|
225
|
+
} catch {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function hostConfigResourcesFromContent(content) {
|
|
230
|
+
const resources = [];
|
|
231
|
+
const seen = /* @__PURE__ */ new Set();
|
|
232
|
+
const add = (type, name) => {
|
|
233
|
+
const trimmed = name.trim();
|
|
234
|
+
if (!trimmed) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const key = `${type}:${trimmed}`;
|
|
238
|
+
if (seen.has(key)) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
seen.add(key);
|
|
242
|
+
resources.push({ type, name: trimmed });
|
|
243
|
+
};
|
|
244
|
+
const document = parseJsonObject(content);
|
|
245
|
+
if (document && isRecord(document.permissions)) {
|
|
246
|
+
for (const action of PERMISSION_ACTIONS) {
|
|
247
|
+
const list = document.permissions[action];
|
|
248
|
+
if (!Array.isArray(list)) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
for (const pattern of list) {
|
|
252
|
+
if (typeof pattern === "string" && pattern.trim()) {
|
|
253
|
+
add("permission", `${action}-${pattern}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
for (const hook of hookResourcesFromContent(content)) {
|
|
259
|
+
add("hook", hook.name);
|
|
260
|
+
}
|
|
261
|
+
if (document && isRecord(document.env)) {
|
|
262
|
+
for (const name of Object.keys(document.env)) {
|
|
263
|
+
add("env_var", name);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return resources;
|
|
267
|
+
}
|
|
268
|
+
function parsePermissionResourceName(name) {
|
|
269
|
+
const trimmed = name.trim();
|
|
270
|
+
for (const action of PERMISSION_ACTIONS) {
|
|
271
|
+
const prefix = `${action}-`;
|
|
272
|
+
if (trimmed.startsWith(prefix) && trimmed.length > prefix.length) {
|
|
273
|
+
return { action, pattern: trimmed.slice(prefix.length) };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
function permissionPatternPresent(permissions, action, pattern) {
|
|
279
|
+
if (!isRecord(permissions)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
const list = permissions[action];
|
|
283
|
+
return Array.isArray(list) && list.some((item) => item === pattern);
|
|
284
|
+
}
|
|
285
|
+
function hookResourcesFromContent(content) {
|
|
286
|
+
const direct = parseHooksJsonContent(content, "");
|
|
287
|
+
if (direct.length > 0) {
|
|
288
|
+
return direct;
|
|
289
|
+
}
|
|
290
|
+
const document = parseJsonObject(content);
|
|
291
|
+
if (!document) {
|
|
292
|
+
return [];
|
|
293
|
+
}
|
|
294
|
+
return parseHooksJsonContent(JSON.stringify({ hooks: document }), "");
|
|
295
|
+
}
|
|
296
|
+
function scopeToPermission(content, name) {
|
|
297
|
+
const parsed = parsePermissionResourceName(name);
|
|
298
|
+
if (!parsed) {
|
|
299
|
+
return content;
|
|
300
|
+
}
|
|
301
|
+
const document = parseJsonObject(content);
|
|
302
|
+
if (!document) {
|
|
303
|
+
return content;
|
|
304
|
+
}
|
|
305
|
+
if (permissionPatternPresent(document.permissions, parsed.action, parsed.pattern)) {
|
|
306
|
+
return formatJsonFragment({
|
|
307
|
+
permissions: { [parsed.action]: [parsed.pattern] }
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return formatJsonFragment({ permissions: {} });
|
|
311
|
+
}
|
|
312
|
+
function scopeToHook(content, name) {
|
|
313
|
+
if (!parseJsonObject(content)) {
|
|
314
|
+
return content;
|
|
315
|
+
}
|
|
316
|
+
const needle = name.trim().toLowerCase();
|
|
317
|
+
const match = hookResourcesFromContent(content).find(
|
|
318
|
+
(resource) => resource.name.toLowerCase() === needle
|
|
319
|
+
);
|
|
320
|
+
if (!match) {
|
|
321
|
+
return formatJsonFragment({ hooks: {} });
|
|
322
|
+
}
|
|
323
|
+
const metadata = match.metadata;
|
|
324
|
+
const entry = metadata.hook_entry ?? { command: match.content };
|
|
325
|
+
return formatJsonFragment({
|
|
326
|
+
hooks: { [metadata.event]: [entry] }
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
function scopeToEnvVar(content, name) {
|
|
330
|
+
const document = parseJsonObject(content);
|
|
331
|
+
if (!document) {
|
|
332
|
+
return content;
|
|
333
|
+
}
|
|
334
|
+
if (!isRecord(document.env) || !Object.hasOwn(document.env, name)) {
|
|
335
|
+
return formatJsonFragment({ env: {} });
|
|
336
|
+
}
|
|
337
|
+
return formatJsonFragment({ env: { [name]: document.env[name] } });
|
|
338
|
+
}
|
|
339
|
+
function scopeHostConfigToResource(content, resource) {
|
|
340
|
+
if (content === null) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
const name = resource.name.trim();
|
|
344
|
+
if (!name) {
|
|
345
|
+
return content;
|
|
346
|
+
}
|
|
347
|
+
switch (resource.type) {
|
|
348
|
+
case "permission":
|
|
349
|
+
return scopeToPermission(content, name);
|
|
350
|
+
case "hook":
|
|
351
|
+
return scopeToHook(content, name);
|
|
352
|
+
case "env_var":
|
|
353
|
+
return scopeToEnvVar(content, name);
|
|
354
|
+
default:
|
|
355
|
+
return content;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// src/services/mcp-resource-detail.ts
|
|
360
|
+
function isRecord2(value) {
|
|
361
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
362
|
+
}
|
|
363
|
+
var MCP_SERVERS_WRAPPER_KEYS = [
|
|
364
|
+
"mcpServers",
|
|
365
|
+
"mcp_servers",
|
|
366
|
+
"mcp"
|
|
367
|
+
];
|
|
368
|
+
function mcpServersWrapperKey(document) {
|
|
369
|
+
for (const key of MCP_SERVERS_WRAPPER_KEYS) {
|
|
370
|
+
if (isRecord2(document[key])) {
|
|
371
|
+
return key;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
function mcpServerNamesFromConfig(content) {
|
|
377
|
+
try {
|
|
378
|
+
const document = JSON.parse(content);
|
|
379
|
+
const servers = mcpServersRecord(document);
|
|
380
|
+
return servers ? Object.keys(servers) : [];
|
|
381
|
+
} catch {
|
|
382
|
+
return [];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function mcpServersRecord(document) {
|
|
386
|
+
if (!isRecord2(document)) {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
const key = mcpServersWrapperKey(document);
|
|
390
|
+
if (!key) {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
const serversRaw = document[key];
|
|
394
|
+
return isRecord2(serversRaw) ? serversRaw : null;
|
|
395
|
+
}
|
|
396
|
+
function formatMcpServersFragment(wrapper, servers) {
|
|
397
|
+
return `${JSON.stringify({ [wrapper]: servers }, null, 2)}
|
|
398
|
+
`;
|
|
399
|
+
}
|
|
400
|
+
function scopeMcpConfigToServer(content, serverName) {
|
|
401
|
+
if (content === null) {
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
const name = serverName.trim();
|
|
405
|
+
if (!name) {
|
|
406
|
+
return content;
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
const document = JSON.parse(content);
|
|
410
|
+
if (!isRecord2(document)) {
|
|
411
|
+
return content;
|
|
412
|
+
}
|
|
413
|
+
const wrapper = mcpServersWrapperKey(document);
|
|
414
|
+
if (!wrapper) {
|
|
415
|
+
return content;
|
|
416
|
+
}
|
|
417
|
+
const servers = document[wrapper];
|
|
418
|
+
if (!isRecord2(servers)) {
|
|
419
|
+
return content;
|
|
420
|
+
}
|
|
421
|
+
const scoped = Object.hasOwn(servers, name) ? { [name]: servers[name] } : {};
|
|
422
|
+
return formatMcpServersFragment(wrapper, scoped);
|
|
423
|
+
} catch {
|
|
424
|
+
return content;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// src/services/scoped-file-content-delta.ts
|
|
429
|
+
function resourceKey(resource) {
|
|
430
|
+
return `${resource.type}:${resource.name}`;
|
|
431
|
+
}
|
|
432
|
+
function collectIdentities(path, contents) {
|
|
433
|
+
const order = [];
|
|
434
|
+
const seen = /* @__PURE__ */ new Set();
|
|
435
|
+
const add = (resource) => {
|
|
436
|
+
const key = resourceKey(resource);
|
|
437
|
+
if (seen.has(key)) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
seen.add(key);
|
|
441
|
+
order.push(resource);
|
|
442
|
+
};
|
|
443
|
+
const mapped = resourceKeyFromManagedPath(path);
|
|
444
|
+
if (mapped) {
|
|
445
|
+
add(mapped);
|
|
446
|
+
}
|
|
447
|
+
const inspectMcp = isMcpConfigManagedPath(path) || isClaudeUserJsonPath(path);
|
|
448
|
+
const inspectHost = isClaudeSettingsPath(path) || isMuseSettingsPath(path);
|
|
449
|
+
for (const content of contents) {
|
|
450
|
+
if (!content) {
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (inspectMcp) {
|
|
454
|
+
for (const name of mcpServerNamesFromConfig(content)) {
|
|
455
|
+
add({ type: "mcp_server", name });
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (inspectHost) {
|
|
459
|
+
for (const resource of hostConfigResourcesFromContent(content)) {
|
|
460
|
+
add(resource);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return order;
|
|
465
|
+
}
|
|
466
|
+
function scopedBodies(expected, current, resource) {
|
|
467
|
+
if (resource.type === "mcp_server") {
|
|
468
|
+
return {
|
|
469
|
+
expected: scopeMcpConfigToServer(expected, resource.name) ?? expected,
|
|
470
|
+
current: scopeMcpConfigToServer(current, resource.name)
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
if (resource.type === "permission" || resource.type === "hook" || resource.type === "env_var") {
|
|
474
|
+
return {
|
|
475
|
+
expected: scopeHostConfigToResource(expected, resource) ?? expected,
|
|
476
|
+
current: scopeHostConfigToResource(current, resource)
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
return { expected, current };
|
|
480
|
+
}
|
|
481
|
+
function scopedContentsDiffer(path, expected, current, resource) {
|
|
482
|
+
const scoped = scopedBodies(expected, current, resource);
|
|
483
|
+
if (scoped.current === null) {
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
return fileDiffHasContentChange(path, scoped.current, scoped.expected);
|
|
487
|
+
}
|
|
488
|
+
function affectedResourcesForManagedFileDiff(input) {
|
|
489
|
+
const identities = collectIdentities(input.path, [input.expected, input.current]);
|
|
490
|
+
const affected = identities.filter(
|
|
491
|
+
(resource) => scopedContentsDiffer(input.path, input.expected, input.current, resource)
|
|
492
|
+
);
|
|
493
|
+
return affected.sort((left, right) => {
|
|
494
|
+
const typeOrder = left.type.localeCompare(right.type);
|
|
495
|
+
return typeOrder !== 0 ? typeOrder : left.name.localeCompare(right.name);
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
function withAffectedResources(change, expected, current) {
|
|
499
|
+
const affected_resources = affectedResourcesForManagedFileDiff({
|
|
500
|
+
path: change.path,
|
|
501
|
+
expected,
|
|
502
|
+
current
|
|
503
|
+
});
|
|
504
|
+
return { ...change, affected_resources };
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// src/services/global-profile-status-panel.ts
|
|
508
|
+
import { existsSync, readFileSync } from "fs";
|
|
509
|
+
import { join, resolve } from "path";
|
|
510
|
+
var PANEL_HARNESS_IDS = ["claude-code", "cursor"];
|
|
511
|
+
function collectOwnedGlobalProfileFiles(snapshotId) {
|
|
512
|
+
if (!snapshotId) {
|
|
513
|
+
return /* @__PURE__ */ new Set();
|
|
514
|
+
}
|
|
515
|
+
const owned = /* @__PURE__ */ new Set();
|
|
516
|
+
for (const install of listGlobalApplySnapshotInstalls(snapshotId)) {
|
|
517
|
+
for (const filePath of install.files) {
|
|
518
|
+
owned.add(filePath);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return owned;
|
|
522
|
+
}
|
|
523
|
+
function classifyGlobalDriftChanges(changes, ownedFiles) {
|
|
524
|
+
const owned = [];
|
|
525
|
+
const nonOwned = [];
|
|
526
|
+
for (const change of changes) {
|
|
527
|
+
if (ownedFiles.has(change.path)) {
|
|
528
|
+
owned.push(change);
|
|
529
|
+
} else {
|
|
530
|
+
nonOwned.push(change);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return { owned, nonOwned };
|
|
534
|
+
}
|
|
535
|
+
function mcpManagedPathsForHarness(harnessId) {
|
|
536
|
+
switch (harnessId) {
|
|
537
|
+
case "cursor":
|
|
538
|
+
return [".cursor/mcp.json"];
|
|
539
|
+
case "claude-code":
|
|
540
|
+
return [".mcp.json", ".claude.json"];
|
|
541
|
+
default:
|
|
542
|
+
return [];
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function declaredMcpFromExpectedFiles(harnessIds, expectedFiles) {
|
|
546
|
+
const namesByHarness = {};
|
|
547
|
+
const configsByHarness = {};
|
|
548
|
+
for (const harnessId of harnessIds) {
|
|
549
|
+
const mcpPaths = new Set(mcpManagedPathsForHarness(harnessId));
|
|
550
|
+
const configs = {};
|
|
551
|
+
if (mcpPaths.size > 0) {
|
|
552
|
+
for (const file of expectedFiles) {
|
|
553
|
+
const normalized = file.path.replace(/\\/g, "/").replace(/^~\//, "");
|
|
554
|
+
if (!mcpPaths.has(normalized)) {
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
try {
|
|
558
|
+
const document = JSON.parse(file.content);
|
|
559
|
+
Object.assign(configs, parseMcpServersDocument(document));
|
|
560
|
+
} catch {
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
namesByHarness[harnessId] = Object.keys(configs);
|
|
565
|
+
configsByHarness[harnessId] = configs;
|
|
566
|
+
}
|
|
567
|
+
return { namesByHarness, configsByHarness };
|
|
568
|
+
}
|
|
569
|
+
function readGlobalMcpServers(homeRoot, harnessId) {
|
|
570
|
+
const platform = getPlatform(harnessId);
|
|
571
|
+
if (!platform) {
|
|
572
|
+
return {};
|
|
573
|
+
}
|
|
574
|
+
const configuredPath = harnessId === "cursor" ? platform.globalPaths.settings : platform.globalPaths.mcp ?? platform.projectPaths.mcp;
|
|
575
|
+
if (!configuredPath) {
|
|
576
|
+
return {};
|
|
577
|
+
}
|
|
578
|
+
const relativePath = configuredPath.startsWith("~/") ? configuredPath.slice(2) : configuredPath;
|
|
579
|
+
const fullPath = join(homeRoot, relativePath);
|
|
580
|
+
if (!existsSync(fullPath)) {
|
|
581
|
+
return {};
|
|
582
|
+
}
|
|
583
|
+
try {
|
|
584
|
+
const document = JSON.parse(readFileSync(fullPath, "utf-8"));
|
|
585
|
+
return parseMcpServersDocument(document);
|
|
586
|
+
} catch {
|
|
587
|
+
return {};
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
function buildHarnessPluginRows(declaredPins, homeRoot) {
|
|
591
|
+
const installed = loadInstalled(homeRoot).filter((row) => row.scope === "user");
|
|
592
|
+
const matchedInstalledRefs = /* @__PURE__ */ new Set();
|
|
593
|
+
const rows = [];
|
|
594
|
+
for (const pin of declaredPins) {
|
|
595
|
+
const installedRef = findInstalledRefForCatalogPin(pin.ref, homeRoot, "user");
|
|
596
|
+
if (installedRef) {
|
|
597
|
+
matchedInstalledRefs.add(installedRef);
|
|
598
|
+
rows.push({ id: pin.ref, state: "installed" });
|
|
599
|
+
} else {
|
|
600
|
+
rows.push({ id: pin.ref, state: "missing" });
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
for (const install of installed) {
|
|
604
|
+
if (!matchedInstalledRefs.has(install.ref)) {
|
|
605
|
+
rows.push({ id: install.ref, state: "extra" });
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return rows;
|
|
609
|
+
}
|
|
610
|
+
function findEnabledCursorInstallForPin(pinRef, installs) {
|
|
611
|
+
const enabled = installs.filter((row) => row.enabled);
|
|
612
|
+
const exact = enabled.find((row) => row.ref === pinRef);
|
|
613
|
+
if (exact) return exact;
|
|
614
|
+
const { name } = parsePluginRef(pinRef);
|
|
615
|
+
return enabled.find((row) => row.name === name);
|
|
616
|
+
}
|
|
617
|
+
function buildCursorHarnessPluginRows(declaredPins, homeRoot) {
|
|
618
|
+
const installs = listCursorPluginInstalls(homeRoot);
|
|
619
|
+
const cursorNames = listCursorPluginFootprintNames(homeRoot);
|
|
620
|
+
const matchedEnabledRefs = /* @__PURE__ */ new Set();
|
|
621
|
+
const rows = [];
|
|
622
|
+
for (const pin of declaredPins) {
|
|
623
|
+
const { name } = parsePluginRef(pin.ref);
|
|
624
|
+
if (!cursorNames.has(name) && !installs.some((row) => row.ref === pin.ref)) {
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
const match = findEnabledCursorInstallForPin(pin.ref, installs);
|
|
628
|
+
if (match) {
|
|
629
|
+
matchedEnabledRefs.add(match.ref);
|
|
630
|
+
rows.push({ id: pin.ref, state: "installed" });
|
|
631
|
+
} else {
|
|
632
|
+
rows.push({ id: pin.ref, state: "missing" });
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
for (const install of installs) {
|
|
636
|
+
if (!install.enabled) continue;
|
|
637
|
+
if (!matchedEnabledRefs.has(install.ref)) {
|
|
638
|
+
rows.push({ id: install.ref, state: "extra" });
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return rows;
|
|
642
|
+
}
|
|
643
|
+
function buildHarnessMcpRows(declaredNames, liveNames, comparison) {
|
|
644
|
+
const declared = new Set(declaredNames);
|
|
645
|
+
const rows = declaredNames.map((name) => {
|
|
646
|
+
if (!liveNames.has(name)) {
|
|
647
|
+
return { name, state: "missing" };
|
|
648
|
+
}
|
|
649
|
+
const expected = comparison?.expected[name];
|
|
650
|
+
const live = comparison?.live[name];
|
|
651
|
+
if (expected && live && !mcpServerMetadataEquivalent(expected, live)) {
|
|
652
|
+
return { name, state: "mismatch" };
|
|
653
|
+
}
|
|
654
|
+
return { name, state: "present" };
|
|
655
|
+
});
|
|
656
|
+
for (const name of liveNames) {
|
|
657
|
+
if (!declared.has(name)) {
|
|
658
|
+
rows.push({ name, state: "extra" });
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return rows;
|
|
662
|
+
}
|
|
663
|
+
function resolveProjectDriftSummary(projectPath) {
|
|
664
|
+
if (!projectPath) {
|
|
665
|
+
return void 0;
|
|
666
|
+
}
|
|
667
|
+
const resolvedRoot = resolve(projectPath);
|
|
668
|
+
const gitOriginRaw = getGitOrigin(resolvedRoot);
|
|
669
|
+
const gitOrigin = gitOriginRaw ? normalizeGitUrl(gitOriginRaw) : null;
|
|
670
|
+
const project = getProjectByLocalPath(resolvedRoot) ?? (gitOrigin ? getProjectByOrigin(gitOrigin) : void 0) ?? null;
|
|
671
|
+
if (!project) {
|
|
672
|
+
return {
|
|
673
|
+
status: "na",
|
|
674
|
+
report: null
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const report = detectProjectDriftFromLatest(resolvedRoot, project.id);
|
|
678
|
+
return {
|
|
679
|
+
status: report?.has_drift ? "drifted" : "clean",
|
|
680
|
+
report
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
function computeGlobalProfilePanelStatus(input) {
|
|
684
|
+
const reasons = [];
|
|
685
|
+
if (input.switchFailed) {
|
|
686
|
+
reasons.push("switch_failed");
|
|
687
|
+
}
|
|
688
|
+
if (input.restoreFailed) {
|
|
689
|
+
reasons.push("restore_failed");
|
|
690
|
+
}
|
|
691
|
+
if (input.warning) {
|
|
692
|
+
reasons.push("status_warning");
|
|
693
|
+
}
|
|
694
|
+
if (input.activeProfile && !input.applied) {
|
|
695
|
+
reasons.push("profile_not_applied");
|
|
696
|
+
}
|
|
697
|
+
if (!input.stackInSync && input.applied) {
|
|
698
|
+
reasons.push("stack_out_of_sync");
|
|
699
|
+
}
|
|
700
|
+
if (input.ownedDriftCount > 0) {
|
|
701
|
+
reasons.push("owned_path_drift");
|
|
702
|
+
}
|
|
703
|
+
if (input.missingPluginCount > 0) {
|
|
704
|
+
reasons.push("missing_plugins");
|
|
705
|
+
}
|
|
706
|
+
if (input.missingMcpCount > 0) {
|
|
707
|
+
reasons.push("missing_mcp");
|
|
708
|
+
}
|
|
709
|
+
const redReasons = /* @__PURE__ */ new Set([
|
|
710
|
+
"switch_failed",
|
|
711
|
+
"restore_failed",
|
|
712
|
+
"profile_not_applied",
|
|
713
|
+
"stack_out_of_sync",
|
|
714
|
+
"owned_path_drift",
|
|
715
|
+
"missing_plugins",
|
|
716
|
+
"missing_mcp"
|
|
717
|
+
]);
|
|
718
|
+
if (reasons.some((reason) => redReasons.has(reason)) || input.warning && input.activeProfile) {
|
|
719
|
+
return { status: "red", reasons };
|
|
720
|
+
}
|
|
721
|
+
if (input.nonOwnedDriftCount > 0) {
|
|
722
|
+
reasons.push("non_owned_drift");
|
|
723
|
+
}
|
|
724
|
+
if (input.projectDrift?.status === "drifted") {
|
|
725
|
+
reasons.push("project_drift");
|
|
726
|
+
}
|
|
727
|
+
if ((input.hostManagedCollisionCount ?? 0) > 0) {
|
|
728
|
+
reasons.push("cursor_host_skill_collision");
|
|
729
|
+
}
|
|
730
|
+
if (input.depth === "fast") {
|
|
731
|
+
reasons.push("fast_depth");
|
|
732
|
+
}
|
|
733
|
+
if (reasons.length > 0) {
|
|
734
|
+
return { status: "yellow", reasons };
|
|
735
|
+
}
|
|
736
|
+
return { status: "green", reasons };
|
|
737
|
+
}
|
|
738
|
+
function buildHarnessLiveStatusMap(input) {
|
|
739
|
+
const harnesses = {};
|
|
740
|
+
for (const harnessId of PANEL_HARNESS_IDS) {
|
|
741
|
+
if (input.depth === "fast") {
|
|
742
|
+
harnesses[harnessId] = { plugins: [], mcp: [] };
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
const declaredMcp = input.declaredMcpByHarness[harnessId] ?? [];
|
|
746
|
+
const liveServers = readGlobalMcpServers(input.homeRoot, harnessId);
|
|
747
|
+
const liveMcp = /* @__PURE__ */ new Set([
|
|
748
|
+
...Object.keys(liveServers),
|
|
749
|
+
...listHostNativeMcpNames(input.homeRoot, harnessId)
|
|
750
|
+
]);
|
|
751
|
+
const expectedServers = input.expectedMcpConfigsByHarness?.[harnessId];
|
|
752
|
+
let plugins = [];
|
|
753
|
+
switch (harnessId) {
|
|
754
|
+
case "claude-code":
|
|
755
|
+
plugins = buildHarnessPluginRows(input.declaredPins, input.homeRoot);
|
|
756
|
+
break;
|
|
757
|
+
case "cursor":
|
|
758
|
+
plugins = buildCursorHarnessPluginRows(
|
|
759
|
+
input.declaredPins,
|
|
760
|
+
input.homeRoot
|
|
761
|
+
);
|
|
762
|
+
break;
|
|
763
|
+
default: {
|
|
764
|
+
const _exhaustive = harnessId;
|
|
765
|
+
void _exhaustive;
|
|
766
|
+
plugins = [];
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
harnesses[harnessId] = {
|
|
771
|
+
plugins,
|
|
772
|
+
mcp: buildHarnessMcpRows(
|
|
773
|
+
declaredMcp,
|
|
774
|
+
liveMcp,
|
|
775
|
+
expectedServers ? { expected: expectedServers, live: liveServers } : void 0
|
|
776
|
+
)
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
return harnesses;
|
|
780
|
+
}
|
|
781
|
+
function countMissingHarnessRows(harnesses) {
|
|
782
|
+
let missingPlugins = 0;
|
|
783
|
+
let missingMcp = 0;
|
|
784
|
+
for (const status of Object.values(harnesses)) {
|
|
785
|
+
missingPlugins += status.plugins.filter((row) => row.state === "missing").length;
|
|
786
|
+
missingMcp += status.mcp.filter(
|
|
787
|
+
(row) => row.state === "missing" || row.state === "mismatch"
|
|
788
|
+
).length;
|
|
789
|
+
}
|
|
790
|
+
return { missingPlugins, missingMcp };
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
export {
|
|
794
|
+
buildUnifiedDiffLines,
|
|
795
|
+
scopeHostConfigToResource,
|
|
796
|
+
scopeMcpConfigToServer,
|
|
797
|
+
withAffectedResources,
|
|
798
|
+
collectOwnedGlobalProfileFiles,
|
|
799
|
+
classifyGlobalDriftChanges,
|
|
800
|
+
declaredMcpFromExpectedFiles,
|
|
801
|
+
resolveProjectDriftSummary,
|
|
802
|
+
computeGlobalProfilePanelStatus,
|
|
803
|
+
buildHarnessLiveStatusMap,
|
|
804
|
+
countMissingHarnessRows
|
|
805
|
+
};
|
|
806
|
+
//# sourceMappingURL=chunk-J4CKQXQ6.js.map
|