harnesstap 1.4.0 → 1.6.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 +3 -1
- package/dist/apply-ZGEAY6YZ.js +50 -0
- package/dist/{approve-FBGYQGWN.js → approve-VPVMU2MM.js} +10 -13
- package/dist/{approve-FBGYQGWN.js.map → approve-VPVMU2MM.js.map} +1 -1
- package/dist/{audit-VI4QZ6X2.js → audit-AO7AGET3.js} +11 -15
- package/dist/{audit-VI4QZ6X2.js.map → audit-AO7AGET3.js.map} +1 -1
- package/dist/{auth-4CQCDS2W.js → auth-7YRIJNXU.js} +10 -12
- package/dist/{auth-4CQCDS2W.js.map → auth-7YRIJNXU.js.map} +1 -1
- package/dist/bin.js +13 -34
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-OML4HXKT.js → chunk-262KZULH.js} +16 -22
- package/dist/chunk-262KZULH.js.map +1 -0
- package/dist/{chunk-ZUASVASP.js → chunk-26QGX47N.js} +26097 -16881
- package/dist/chunk-26QGX47N.js.map +1 -0
- package/dist/{chunk-3P6BWL5F.js → chunk-27IPOVKQ.js} +2 -2
- package/dist/{chunk-M4KLHJ6U.js → chunk-2BESDRYP.js} +8 -10
- package/dist/{chunk-M4KLHJ6U.js.map → chunk-2BESDRYP.js.map} +1 -1
- package/dist/{chunk-PCMON7Y2.js → chunk-2BWIEB2G.js} +8 -10
- package/dist/{chunk-PCMON7Y2.js.map → chunk-2BWIEB2G.js.map} +1 -1
- package/dist/{chunk-XTVGCVU4.js → chunk-2NMLWSUH.js} +41 -42
- package/dist/chunk-2NMLWSUH.js.map +1 -0
- package/dist/{chunk-TQ2NA4Z4.js → chunk-4E3G4H5B.js} +8 -2
- package/dist/chunk-4E3G4H5B.js.map +1 -0
- package/dist/chunk-4QCGTUTM.js +61 -0
- package/dist/chunk-4QCGTUTM.js.map +1 -0
- package/dist/{chunk-TPEJFLV7.js → chunk-6RKJZW2N.js} +4 -6
- package/dist/{chunk-TPEJFLV7.js.map → chunk-6RKJZW2N.js.map} +1 -1
- package/dist/{chunk-JQOKQKQT.js → chunk-7IBFH736.js} +2 -2
- package/dist/{chunk-P2C7JPLD.js → chunk-CKJIS2FM.js} +6 -6
- package/dist/{chunk-R7ZOYVN3.js → chunk-CUOEQQFI.js} +187 -59
- package/dist/chunk-CUOEQQFI.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-4ZQ2SCGY.js → chunk-FLYQEB6D.js} +509 -207
- package/dist/chunk-FLYQEB6D.js.map +1 -0
- package/dist/{chunk-U6DXASQP.js → chunk-HC7IZY75.js} +2 -2
- package/dist/{chunk-UVVZHWD2.js → chunk-I4DKV63E.js} +2 -2
- package/dist/{chunk-PNGF5EV2.js → chunk-JEC5PWNH.js} +2 -2
- package/dist/{chunk-MR7IOHSX.js → chunk-KFIRABC7.js} +16 -22
- package/dist/{chunk-MR7IOHSX.js.map → chunk-KFIRABC7.js.map} +1 -1
- package/dist/{chunk-6LTLYV5D.js → chunk-LGWFLVZQ.js} +1064 -265
- package/dist/chunk-LGWFLVZQ.js.map +1 -0
- package/dist/{chunk-RDG5DT7S.js → chunk-LX6PMOOC.js} +54 -40
- package/dist/chunk-LX6PMOOC.js.map +1 -0
- package/dist/{chunk-WGP4GUYZ.js → chunk-MILGCNBK.js} +9 -11
- package/dist/{chunk-WGP4GUYZ.js.map → chunk-MILGCNBK.js.map} +1 -1
- package/dist/chunk-MKLJBW5N.js +14 -0
- package/dist/{chunk-N3ZCH64F.js → chunk-MSKTWYHG.js} +86 -32
- package/dist/chunk-MSKTWYHG.js.map +1 -0
- package/dist/{chunk-WG5A6EAU.js → chunk-MTCCUYBZ.js} +821 -28
- package/dist/chunk-MTCCUYBZ.js.map +1 -0
- package/dist/{chunk-BPWFQKI5.js → chunk-NIFKCS7J.js} +2 -2
- package/dist/{chunk-43BDGVN3.js → chunk-NWOYPK2O.js} +56 -9
- package/dist/chunk-NWOYPK2O.js.map +1 -0
- package/dist/{chunk-3FS775NP.js → chunk-NXILQDJG.js} +85 -4
- package/dist/chunk-NXILQDJG.js.map +1 -0
- package/dist/chunk-QF73VLAW.js +31673 -0
- package/dist/chunk-QF73VLAW.js.map +1 -0
- package/dist/{chunk-RFQ3N7FB.js → chunk-QHCGA6LC.js} +11 -19
- package/dist/chunk-QHCGA6LC.js.map +1 -0
- package/dist/{chunk-L6YZE5MY.js → chunk-QPJZKWML.js} +5 -7
- package/dist/{chunk-L6YZE5MY.js.map → chunk-QPJZKWML.js.map} +1 -1
- package/dist/{chunk-ULCD6DJE.js → chunk-RM7VP6ID.js} +24 -61
- package/dist/chunk-RM7VP6ID.js.map +1 -0
- package/dist/{chunk-7HP6AAI3.js → chunk-SMLO5YPI.js} +2 -2
- package/dist/{chunk-73OJQTBW.js → chunk-T2JBSRGG.js} +2 -2
- package/dist/{chunk-IE7B6Q5K.js → chunk-U5Y6WKKT.js} +17 -18
- package/dist/chunk-U5Y6WKKT.js.map +1 -0
- package/dist/chunk-UEA4NCY2.js +106 -0
- package/dist/chunk-UEA4NCY2.js.map +1 -0
- package/dist/chunk-VAPCU2FX.js +70 -0
- package/dist/chunk-VAPCU2FX.js.map +1 -0
- package/dist/{chunk-RVEXPMM3.js → chunk-WEJVFNRO.js} +3 -5
- package/dist/{chunk-RVEXPMM3.js.map → chunk-WEJVFNRO.js.map} +1 -1
- package/dist/{chunk-IMROMZ2K.js → chunk-WWFVMCTR.js} +19 -14
- package/dist/chunk-WWFVMCTR.js.map +1 -0
- package/dist/chunk-XPONNOBR.js +102 -0
- package/dist/chunk-XPONNOBR.js.map +1 -0
- package/dist/{chunk-N3VGY3T3.js → chunk-Y3HJ2F2W.js} +7 -5
- package/dist/{chunk-N3VGY3T3.js.map → chunk-Y3HJ2F2W.js.map} +1 -1
- package/dist/{chunk-2A36HWDE.js → chunk-Y4I7ZCAE.js} +129 -136
- package/dist/chunk-Y4I7ZCAE.js.map +1 -0
- package/dist/{chunk-GRASK6M6.js → chunk-ZREU2UHM.js} +5 -5
- package/dist/{chunk-QA5U36JN.js → chunk-ZT7ANP3H.js} +774 -364
- package/dist/chunk-ZT7ANP3H.js.map +1 -0
- package/dist/{chunk-EOPFER6N.js → chunk-ZUXFPAVX.js} +19 -5
- package/dist/chunk-ZUXFPAVX.js.map +1 -0
- package/dist/{chunk-D432JAXV.js → chunk-ZWB6YXVQ.js} +153 -25
- package/dist/chunk-ZWB6YXVQ.js.map +1 -0
- package/dist/{chunk-23XSG7LI.js → chunk-ZZQDJGWX.js} +4 -4
- package/dist/{compile-GXADKGH5.js → compile-IMJHVXQO.js} +33 -37
- package/dist/{compile-GXADKGH5.js.map → compile-IMJHVXQO.js.map} +1 -1
- package/dist/{config-JMHNA2U5.js → config-FVVN3NWL.js} +16 -21
- package/dist/{config-JMHNA2U5.js.map → config-FVVN3NWL.js.map} +1 -1
- package/dist/cursor-local-install-JS5KSOES.js +94 -0
- package/dist/{cursor-local-install-46RWRBDT.js.map → cursor-local-install-JS5KSOES.js.map} +1 -1
- package/dist/{cursor-local-install-46RWRBDT.js → cursor-local-install-QU5R2FV5.js} +8 -12
- package/dist/cursor-local-install-QU5R2FV5.js.map +1 -0
- package/dist/{doctor-N7ZULPOL.js → doctor-A7VUJSCP.js} +14 -17
- package/dist/doctor-A7VUJSCP.js.map +1 -0
- package/dist/{environment-OBB3WU5B.js → environment-6INIUBNC.js} +42 -50
- package/dist/environment-6INIUBNC.js.map +1 -0
- package/dist/{github-PBYBGOLH.js → github-TFJT3P53.js} +9 -10
- package/dist/{github-PBYBGOLH.js.map → github-TFJT3P53.js.map} +1 -1
- package/dist/{harness-7KYATIV6.js → harness-WQNC5HPZ.js} +46 -84
- package/dist/harness-WQNC5HPZ.js.map +1 -0
- package/dist/{help-EE3AJQD4.js → help-NMS3EXJB.js} +15 -20
- package/dist/{help-EE3AJQD4.js.map → help-NMS3EXJB.js.map} +1 -1
- package/dist/{help-VXWKLQ6A.js → help-VW4RIICD.js} +57 -575
- package/dist/help-VW4RIICD.js.map +1 -0
- package/dist/host-plugin-view-kept-HYCHDB4D.js +139 -0
- package/dist/host-plugin-view-kept-HYCHDB4D.js.map +1 -0
- package/dist/index.js +12 -16
- package/dist/{init-LBTMPDVJ.js → init-RXYL5ZUE.js} +33 -41
- package/dist/{init-LBTMPDVJ.js.map → init-RXYL5ZUE.js.map} +1 -1
- package/dist/live-read-cache-BHU6L7MA.js +13 -0
- package/dist/live-read-cache-NQU7M2C7.js +12 -0
- package/dist/{lock-WLJRXRVK.js → lock-3H3Z65DS.js} +9 -12
- package/dist/{lock-WLJRXRVK.js.map → lock-3H3Z65DS.js.map} +1 -1
- package/dist/{marketplace-GXSV6QIY.js → marketplace-KW35PJCY.js} +26 -79
- package/dist/marketplace-KW35PJCY.js.map +1 -0
- package/dist/{mcp-XPDWWU75.js → mcp-2HUGVDJ5.js} +33 -37
- package/dist/{mcp-XPDWWU75.js.map → mcp-2HUGVDJ5.js.map} +1 -1
- package/dist/{migrate-SBUIWN3U.js → migrate-6VAPYNXI.js} +93 -34
- package/dist/migrate-6VAPYNXI.js.map +1 -0
- package/dist/notifications-Y7KQCN6K.js +154 -0
- package/dist/notifications-Y7KQCN6K.js.map +1 -0
- package/dist/open-FADABB2S.js +20 -0
- package/dist/{pack-A73LDVOX.js → pack-NTECD3BZ.js} +10 -14
- package/dist/{pack-A73LDVOX.js.map → pack-NTECD3BZ.js.map} +1 -1
- package/dist/plugin-T2YFCYIO.js +47 -0
- package/dist/plugin-from-project-FGX5AHW6.js +15 -0
- package/dist/{policy-6VY3CMSU.js → policy-3FOWB4GR.js} +9 -12
- package/dist/{policy-6VY3CMSU.js.map → policy-3FOWB4GR.js.map} +1 -1
- package/dist/{profile-YCKPMRRU.js → profile-HM3ROXXB.js} +108 -78
- package/dist/profile-HM3ROXXB.js.map +1 -0
- package/dist/{project-KHPPBKPN.js → project-3DTXKMI6.js} +512 -119
- package/dist/project-3DTXKMI6.js.map +1 -0
- package/dist/{resource-IJU3FAN5.js → resource-TZDZAVZ6.js} +55 -45
- package/dist/resource-TZDZAVZ6.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-AMZJHJIB.js} +3 -3
- package/dist/version-AMZJHJIB.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/harness-7KYATIV6.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-ZGEAY6YZ.js.map} +0 -0
- /package/dist/{chunk-3P6BWL5F.js.map → chunk-27IPOVKQ.js.map} +0 -0
- /package/dist/{chunk-JQOKQKQT.js.map → chunk-7IBFH736.js.map} +0 -0
- /package/dist/{chunk-P2C7JPLD.js.map → chunk-CKJIS2FM.js.map} +0 -0
- /package/dist/{chunk-U6DXASQP.js.map → chunk-HC7IZY75.js.map} +0 -0
- /package/dist/{chunk-UVVZHWD2.js.map → chunk-I4DKV63E.js.map} +0 -0
- /package/dist/{chunk-PNGF5EV2.js.map → chunk-JEC5PWNH.js.map} +0 -0
- /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
- /package/dist/{chunk-BPWFQKI5.js.map → chunk-NIFKCS7J.js.map} +0 -0
- /package/dist/{chunk-7HP6AAI3.js.map → chunk-SMLO5YPI.js.map} +0 -0
- /package/dist/{chunk-73OJQTBW.js.map → chunk-T2JBSRGG.js.map} +0 -0
- /package/dist/{chunk-GRASK6M6.js.map → chunk-ZREU2UHM.js.map} +0 -0
- /package/dist/{chunk-23XSG7LI.js.map → chunk-ZZQDJGWX.js.map} +0 -0
- /package/dist/{live-read-cache-TUSP7U3D.js.map → live-read-cache-BHU6L7MA.js.map} +0 -0
- /package/dist/{open-HDGLYYVU.js.map → live-read-cache-NQU7M2C7.js.map} +0 -0
- /package/dist/{plugin-CEO6ZJM5.js.map → open-FADABB2S.js.map} +0 -0
- /package/dist/{plugin-from-project-UK7VJVUP.js.map → plugin-T2YFCYIO.js.map} +0 -0
- /package/dist/{version-Z66FWWMQ.js.map → plugin-from-project-FGX5AHW6.js.map} +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CliUsageError
|
|
3
|
-
} from "./chunk-2A36HWDE.js";
|
|
4
1
|
import {
|
|
5
2
|
CLI_ERRORS,
|
|
6
3
|
CLI_HINTS,
|
|
4
|
+
CliUsageError,
|
|
7
5
|
ensureErrorPrefix,
|
|
8
6
|
gitFailureHint,
|
|
9
7
|
mapGitStderr
|
|
10
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MTCCUYBZ.js";
|
|
11
9
|
|
|
12
10
|
// src/cli/on-conflict.ts
|
|
13
11
|
var ON_CONFLICT_HELP = "What to do when it already exists: replace, skip, prompt or cancel. overwrite, ignore and fail are aliases";
|
|
@@ -182,10 +180,6 @@ function mapUserFacingError(error) {
|
|
|
182
180
|
|
|
183
181
|
// src/cli/shared.ts
|
|
184
182
|
var GUIDE_SCENARIOS_URL = "https://github.com/harnesstap/harnesstap/blob/main/docs/scenarios/scenarios.md";
|
|
185
|
-
var GIT_ORIGIN_HINTS = [
|
|
186
|
-
"Add a remote: git remote add origin <url>",
|
|
187
|
-
"Snapshots, drift, history, and revert require a git repository with origin configured."
|
|
188
|
-
];
|
|
189
183
|
function resolveInvocationName() {
|
|
190
184
|
return basename(process.argv[1] ?? "") === "ht" ? "ht" : "harnesstap";
|
|
191
185
|
}
|
|
@@ -211,12 +205,16 @@ function formatHintCommand(args) {
|
|
|
211
205
|
}
|
|
212
206
|
function fail(message, opts) {
|
|
213
207
|
process.exitCode = opts?.exitCode ?? 1;
|
|
214
|
-
|
|
208
|
+
const error = ensureErrorPrefix(message);
|
|
209
|
+
console.error(error);
|
|
215
210
|
const hints = opts?.hints ?? (opts?.hint ? [opts.hint] : []);
|
|
211
|
+
const printed = /* @__PURE__ */ new Set([error]);
|
|
216
212
|
for (const hint of hints) {
|
|
217
|
-
if (hint.trim().length
|
|
218
|
-
|
|
219
|
-
|
|
213
|
+
if (hint.trim().length === 0) continue;
|
|
214
|
+
const key = ensureErrorPrefix(hint);
|
|
215
|
+
if (printed.has(key)) continue;
|
|
216
|
+
printed.add(key);
|
|
217
|
+
console.error(hint);
|
|
220
218
|
}
|
|
221
219
|
}
|
|
222
220
|
function hintsFromError(error) {
|
|
@@ -252,11 +250,6 @@ function formatScenarioCommand(path) {
|
|
|
252
250
|
function collectRepeatedOption(value, previous) {
|
|
253
251
|
return [...previous, value];
|
|
254
252
|
}
|
|
255
|
-
function reportNoGitOrigin(_retryCommand) {
|
|
256
|
-
fail("No git remote origin configured.", {
|
|
257
|
-
hint: GIT_ORIGIN_HINTS[0]
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
253
|
function isVerboseMode(argv = process.argv) {
|
|
261
254
|
return argv.includes("-v") || argv.includes("--verbose");
|
|
262
255
|
}
|
|
@@ -285,8 +278,7 @@ export {
|
|
|
285
278
|
failCaught,
|
|
286
279
|
formatScenarioCommand,
|
|
287
280
|
collectRepeatedOption,
|
|
288
|
-
reportNoGitOrigin,
|
|
289
281
|
isVerboseMode,
|
|
290
282
|
isGroupedCommandFallbackError
|
|
291
283
|
};
|
|
292
|
-
//# sourceMappingURL=chunk-
|
|
284
|
+
//# sourceMappingURL=chunk-QHCGA6LC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/on-conflict.ts","../src/cli/shared.ts","../src/cli/user-errors.ts"],"sourcesContent":["/** Shared --on-conflict vocabulary (DS-6). Hidden aliases for one release: overwrite, ignore, fail. */\n\nexport const ON_CONFLICT_VALUES = [\"replace\", \"skip\", \"prompt\", \"cancel\"] as const;\nexport type OnConflictValue = (typeof ON_CONFLICT_VALUES)[number];\n\nexport const ON_CONFLICT_HELP =\n \"What to do when it already exists: replace, skip, prompt or cancel. overwrite, ignore and fail are aliases\";\n\nexport const ON_CONFLICT_PLUGIN_IMPORT_HELP =\n \"What to do when it already exists: replace, skip, prompt, cancel or merge. overwrite, ignore and fail are aliases\";\n\n/** Apply, profile, and project: non-interactive default is cancel. Pass --on-conflict replace in CI. */\nexport const ON_CONFLICT_APPLY_HELP =\n \"What to do when it already exists: replace, skip, prompt or cancel. overwrite, ignore and fail are aliases. Non-interactive default: cancel\";\n\nexport const ON_CONFLICT_VALUE_HELP = {\n replace: \"Replace the existing one\",\n skip: \"Keep the existing one and move on\",\n prompt: \"Ask each time\",\n cancel: \"Stop without changing anything\",\n merge: \"Merge with the existing plugin (plugin import only)\",\n} as const;\n\nfunction mapAlias(value: string): string {\n switch (value) {\n case \"overwrite\":\n return \"replace\";\n case \"ignore\":\n return \"skip\";\n case \"fail\":\n return \"cancel\";\n default:\n return value;\n }\n}\n\nexport function parseOnConflict(\n value: string | undefined,\n opts?: { allowMerge?: boolean },\n): OnConflictValue | \"merge\" | undefined {\n if (!value) {\n return undefined;\n }\n const mapped = mapAlias(value);\n switch (mapped) {\n case \"replace\":\n case \"skip\":\n case \"prompt\":\n case \"cancel\":\n return mapped;\n case \"merge\":\n if (opts?.allowMerge) {\n return \"merge\";\n }\n throw new Error(`Invalid --on-conflict value: ${value}. Use replace, skip, prompt or cancel.`);\n default:\n throw new Error(\n opts?.allowMerge\n ? `Invalid --on-conflict value: ${value}. Use replace, skip, prompt, cancel or merge.`\n : `Invalid --on-conflict value: ${value}. Use replace, skip, prompt or cancel.`,\n );\n }\n}\n\nexport function toResourceSyncOnConflict(\n value: OnConflictValue | \"merge\" | undefined,\n): \"overwrite\" | \"ignore\" | \"fail\" | undefined {\n if (!value || value === \"merge\" || value === \"prompt\") {\n return undefined;\n }\n switch (value) {\n case \"replace\":\n return \"overwrite\";\n case \"skip\":\n return \"ignore\";\n case \"cancel\":\n return \"fail\";\n default: {\n const _exhaustive: never = value;\n return _exhaustive;\n }\n }\n}\n\nexport function toPluginImportOnConflict(\n value: OnConflictValue | \"merge\" | undefined,\n): \"overwrite\" | \"cancel\" | \"merge\" | undefined {\n if (!value) {\n return undefined;\n }\n switch (value) {\n case \"replace\":\n return \"overwrite\";\n case \"cancel\":\n case \"skip\":\n return \"cancel\";\n case \"merge\":\n return \"merge\";\n case \"prompt\":\n return \"cancel\";\n default: {\n const _exhaustive: never = value;\n return _exhaustive;\n }\n }\n}\n","import { basename } from \"node:path\";\nimport { CliUsageError } from \"../services/cli-errors.js\";\nimport { ensureErrorPrefix } from \"./messages.js\";\nimport { isCommanderError, mapUserFacingError } from \"./user-errors.js\";\n\nexport const GUIDE_SCENARIOS_URL =\n \"https://github.com/harnesstap/harnesstap/blob/main/docs/scenarios/scenarios.md\";\n\nexport function resolveInvocationName(): \"harnesstap\" | \"ht\" {\n return basename(process.argv[1] ?? \"\") === \"ht\" ? \"ht\" : \"harnesstap\";\n}\n\nexport function shellQuote(value: string): string {\n if (value.length === 0) {\n return '\"\"';\n }\n if (/^[A-Za-z0-9_./:@+=,-]+$/.test(value)) {\n return value;\n }\n return `\"${value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll(\"\\\"\", \"\\\\\\\"\")}\"`;\n}\n\n/** DS-6: hints always say `ht` and shell-quote each argument (W2-1, W3-3). */\nexport function formatCommand(pathOrArgs: string | readonly string[]): string {\n if (typeof pathOrArgs === \"string\") {\n const trimmed = pathOrArgs.trim();\n const stripped = trimmed.replace(/^(?:harnesstap|ht)\\s+/, \"\");\n return stripped.length > 0 ? `ht ${stripped}` : \"ht\";\n }\n return [\"ht\", ...pathOrArgs.map(shellQuote)].join(\" \");\n}\n\nexport function formatHintCommand(args: readonly string[]): string {\n return formatCommand(args);\n}\n\nexport function fail(\n message: string,\n opts?: { hint?: string; hints?: string[]; exitCode?: number },\n): void {\n process.exitCode = opts?.exitCode ?? 1;\n const error = ensureErrorPrefix(message);\n console.error(error);\n const hints = opts?.hints ?? (opts?.hint ? [opts.hint] : []);\n // A hint that only repeats the error (for example a mapped git failure) is skipped.\n const printed = new Set([error]);\n for (const hint of hints) {\n if (hint.trim().length === 0) continue;\n const key = ensureErrorPrefix(hint);\n if (printed.has(key)) continue;\n printed.add(key);\n console.error(hint);\n }\n}\n\nfunction hintsFromError(error: unknown): string[] {\n if (!error || typeof error !== \"object\" || !(\"hints\" in error)) return [];\n const raw = (error as { hints?: unknown }).hints;\n if (!Array.isArray(raw)) return [];\n return raw.filter(\n (hint): hint is string => typeof hint === \"string\" && hint.trim().length > 0,\n );\n}\n\nexport function failCaught(error: unknown, opts?: { exitCode?: number }): void {\n if (error instanceof CliUsageError) {\n fail(error.message, {\n hint: error.hints[0],\n exitCode: opts?.exitCode ?? error.exitCode,\n });\n return;\n }\n const mapped = mapUserFacingError(error);\n const commanderHint = isCommanderError(error)\n ? undefined\n : mapped.hint;\n const ownHints = hintsFromError(error);\n const hints = commanderHint\n ? [commanderHint, ...ownHints.filter((hint) => hint !== commanderHint)]\n : ownHints;\n fail(mapped.message, {\n hints,\n exitCode: opts?.exitCode ?? mapped.exitCode,\n });\n}\n\n/** DS-6: packaged help and scenario playbooks always show `ht`. */\nexport function formatScenarioCommand(path: string): string {\n const trimmed = path.trim();\n const stripped = trimmed.replace(/^(?:harnesstap|ht)\\s+/, \"\");\n return stripped.length > 0 ? `ht ${stripped}` : \"ht\";\n}\n\nexport function collectRepeatedOption(value: string, previous: string[]): string[] {\n return [...previous, value];\n}\n\nexport function isVerboseMode(argv: string[] = process.argv): boolean {\n return argv.includes(\"-v\") || argv.includes(\"--verbose\");\n}\n\nexport function isGroupedCommandFallbackError(error: unknown): error is {\n code: string;\n exitCode: number;\n message: string;\n} {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n\n const candidate = error as {\n code?: unknown;\n exitCode?: unknown;\n message?: unknown;\n };\n\n return candidate.code === \"commander.excessArguments\"\n && candidate.exitCode === 1\n && typeof candidate.message === \"string\"\n && /too many arguments for '(plugin|resource|plugin|auth|migrate|harness|environment|profile)'/i.test(candidate.message);\n}\n","import { CLI_ERRORS, CLI_HINTS } from \"./messages.js\";\nimport { gitFailureHint, mapGitStderr } from \"../utils/git-errors.js\";\n\nexport { gitFailureHint, mapGitStderr } from \"../utils/git-errors.js\";\n\nexport interface MappedCliError {\n message: string;\n hint?: string;\n exitCode: number;\n}\n\nfunction nodePathFromEnoent(error: Error): string | undefined {\n if (\"path\" in error && typeof error.path === \"string\" && error.path.length > 0) {\n return error.path;\n }\n const match = /ENOENT: no such file or directory, (?:stat|open|scandir|mkdir|unlink) '([^']+)'/.exec(\n error.message,\n );\n return match?.[1];\n}\n\nexport function isSqliteUniqueError(error: unknown): boolean {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n const candidate = error as { code?: unknown; message?: unknown };\n const code = typeof candidate.code === \"string\" ? candidate.code : \"\";\n const message = typeof candidate.message === \"string\" ? candidate.message : \"\";\n return (\n code === \"SQLITE_CONSTRAINT_UNIQUE\"\n || code === \"SQLITE_CONSTRAINT\"\n || message.includes(\"UNIQUE constraint failed\")\n );\n}\n\nfunction mapSqliteUnique(message: string): MappedCliError {\n if (message.includes(\"plugins.\")) {\n return {\n message: CLI_ERRORS.uniqueConstraintGeneric.replace(\n \"That name already exists.\",\n \"A plugin with that name already exists.\",\n ),\n hint: CLI_HINTS.onConflictReplace,\n exitCode: 1,\n };\n }\n if (message.includes(\"environments\")) {\n return {\n message: \"An environment with that name already exists.\",\n hint: CLI_HINTS.onConflictReplace,\n exitCode: 1,\n };\n }\n return {\n message: CLI_ERRORS.uniqueConstraintGeneric,\n hint: CLI_HINTS.onConflictReplace,\n exitCode: 1,\n };\n}\n\nfunction commanderExitCode(error: unknown): number {\n if (error && typeof error === \"object\" && \"exitCode\" in error) {\n const raw = (error as { exitCode?: unknown }).exitCode;\n if (typeof raw === \"number\" && raw > 0) {\n return raw;\n }\n }\n return 1;\n}\n\nexport function isCommanderError(error: unknown): boolean {\n if (!error || typeof error !== \"object\" || !(\"code\" in error)) {\n return false;\n }\n return String((error as { code?: unknown }).code ?? \"\").startsWith(\"commander.\");\n}\n\nexport function mapUserFacingError(error: unknown): MappedCliError {\n const exitCode = commanderExitCode(error);\n\n if (error instanceof Error && isSqliteUniqueError(error)) {\n return { ...mapSqliteUnique(error.message), exitCode };\n }\n\n if (error instanceof Error) {\n const code = \"code\" in error ? String((error as { code?: unknown }).code ?? \"\") : \"\";\n if (code === \"ENOENT\") {\n const filePath = nodePathFromEnoent(error);\n return {\n message: CLI_ERRORS.fileNotFound(filePath ?? \"that path\"),\n exitCode,\n };\n }\n const lower = error.message.toLowerCase();\n if (\n lower.includes(\"could not read username\")\n || lower.includes(\"terminal prompts disabled\")\n || lower.includes(\"authentication failed\")\n || /\\bfatal:/.test(lower)\n || error.message.startsWith(\"Couldn't reach\")\n ) {\n return {\n message: mapGitStderr(error.message),\n hint: gitFailureHint(),\n exitCode,\n };\n }\n return { message: error.message, exitCode };\n }\n\n return { message: String(error), exitCode };\n}\n\nexport function commanderHelpHint(commandPath: string): string {\n return CLI_HINTS.seeOptions(commandPath);\n}\n"],"mappings":";;;;;;;;;;AAKO,IAAM,mBACX;AAEK,IAAM,iCACX;AAGK,IAAM,yBACX;AAEK,IAAM,yBAAyB;AAAA,EACpC,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AACT;AAEA,SAAS,SAAS,OAAuB;AACvC,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;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S,aAAa,CAAC,IACpE;AACJ,OAAK,OAAO,SAAS;AAAA,IACnB;AAAA,IACA,UAAU,MAAM,YAAY,OAAO;AAAA,EACrC,CAAC;AACH;AAGO,SAAS,sBAAsB,MAAsB;AAC1D,QAAM,UAAU,KAAK,KAAK;AAC1B,QAAM,WAAW,QAAQ,QAAQ,yBAAyB,EAAE;AAC5D,SAAO,SAAS,SAAS,IAAI,MAAM,QAAQ,KAAK;AAClD;AAEO,SAAS,sBAAsB,OAAe,UAA8B;AACjF,SAAO,CAAC,GAAG,UAAU,KAAK;AAC5B;AAEO,SAAS,cAAc,OAAiB,QAAQ,MAAe;AACpE,SAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,WAAW;AACzD;AAEO,SAAS,8BAA8B,OAI5C;AACA,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO;AAAA,EACT;AAEA,QAAM,YAAY;AAMlB,SAAO,UAAU,SAAS,+BACrB,UAAU,aAAa,KACvB,OAAO,UAAU,YAAY,YAC7B,8FAA8F,KAAK,UAAU,OAAO;AAC3H;","names":[]}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
promptForSearchableMultiSelect
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7IBFH736.js";
|
|
4
4
|
import {
|
|
5
|
+
getAllPlatforms,
|
|
6
|
+
getPlatformIds,
|
|
5
7
|
normalizeRegisteredHarnesses,
|
|
6
8
|
registeredFromLegacyParts,
|
|
7
9
|
registeredHarnessesOf
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
getAllPlatforms,
|
|
11
|
-
getPlatformIds
|
|
12
|
-
} from "./chunk-DF4Z7LAD.js";
|
|
10
|
+
} from "./chunk-26QGX47N.js";
|
|
13
11
|
|
|
14
12
|
// src/services/harness-config.ts
|
|
15
13
|
function unique(values) {
|
|
@@ -84,4 +82,4 @@ async function resolveHarnessSelection(options = {}) {
|
|
|
84
82
|
export {
|
|
85
83
|
resolveHarnessSelection
|
|
86
84
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
85
|
+
//# sourceMappingURL=chunk-QPJZKWML.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/harness-config.ts"],"sourcesContent":["import { getAllPlatforms, getPlatformIds } from \"../platforms/registry.js\";\nimport type { HarnessPreference, HarnessSelection } from \"../types.js\";\nimport {\n normalizeRegisteredHarnesses,\n registeredFromLegacyParts,\n registeredHarnessesOf,\n} from \"./harness-targets.js\";\nimport { promptForSearchableMultiSelect } from \"./wizards/searchable-multi-select.js\";\n\nexport interface ResolveHarnessSelectionOptions {\n current?: HarnessPreference | HarnessSelection;\n detected?: string[];\n harnesses?: string[];\n main?: string;\n aliases?: string[];\n nonInteractive?: boolean;\n message?: string;\n /** @deprecated Use `message`. */\n mainMessage?: string;\n /** @deprecated Ignored; aliases are part of the registered set. */\n aliasMessage?: string;\n}\n\nfunction unique(values: string[]): string[] {\n return [...new Set(values.filter(Boolean))];\n}\n\nfunction validateHarnesses(harnesses: string[]): void {\n const supported = new Set(getPlatformIds());\n const invalid = harnesses.filter((harness) => !supported.has(harness));\n if (invalid.length > 0) {\n throw new Error(`Unsupported harness: ${invalid.join(\", \")}`);\n }\n}\n\nfunction defaultRegistered(\n options: ResolveHarnessSelectionOptions,\n): string[] {\n if (options.harnesses && options.harnesses.length > 0) {\n return normalizeRegisteredHarnesses(options.harnesses);\n }\n const fromFlags = registeredFromLegacyParts(options.main, options.aliases);\n if (fromFlags.length > 0) {\n return fromFlags;\n }\n const current = registeredHarnessesOf(options.current);\n if (current.length > 0) {\n return current;\n }\n const detected = unique(options.detected ?? []);\n if (detected.length > 0) {\n return detected;\n }\n const first = getPlatformIds()[0];\n return first ? [first] : [];\n}\n\nfunction formatCurrentHarnessSummary(\n current: HarnessPreference | HarnessSelection | undefined,\n): string | undefined {\n if (!current) {\n return undefined;\n }\n const registered = registeredHarnessesOf(current);\n return `Current harnesses: ${registered.join(\", \") || \"(none)\"}`;\n}\n\nexport async function resolveHarnessSelection(\n options: ResolveHarnessSelectionOptions = {},\n): Promise<HarnessSelection> {\n const registered = defaultRegistered(options);\n validateHarnesses(registered);\n\n if (options.nonInteractive || !process.stdin.isTTY) {\n return { registered_harnesses: registered };\n }\n\n const detected = unique(options.detected ?? []);\n if (detected.length === 1 && detected[0] && registered.length <= 1) {\n return { registered_harnesses: [detected[0]] };\n }\n\n const harnesses = getAllPlatforms().map((platform) => ({\n name: `${platform.name} (${platform.id})`,\n value: platform.id,\n }));\n\n const currentSummary = formatCurrentHarnessSummary(options.current);\n const selected = await promptForSearchableMultiSelect({\n message: [\n options.message\n ?? options.mainMessage\n ?? \"Select harnesses to keep in sync\",\n currentSummary,\n ].filter(Boolean).join(\"\\n\"),\n default: registered,\n choices: harnesses,\n pageSize: 10,\n loop: false,\n });\n\n const next = normalizeRegisteredHarnesses(selected);\n if (next.length === 0) {\n throw new Error(\"Select at least one harness.\");\n }\n validateHarnesses(next);\n return { registered_harnesses: next };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/services/harness-config.ts"],"sourcesContent":["import { getAllPlatforms, getPlatformIds } from \"../platforms/registry.js\";\nimport type { HarnessPreference, HarnessSelection } from \"../types.js\";\nimport {\n normalizeRegisteredHarnesses,\n registeredFromLegacyParts,\n registeredHarnessesOf,\n} from \"./harness-targets.js\";\nimport { promptForSearchableMultiSelect } from \"./wizards/searchable-multi-select.js\";\n\nexport interface ResolveHarnessSelectionOptions {\n current?: HarnessPreference | HarnessSelection;\n detected?: string[];\n harnesses?: string[];\n main?: string;\n aliases?: string[];\n nonInteractive?: boolean;\n message?: string;\n /** @deprecated Use `message`. */\n mainMessage?: string;\n /** @deprecated Ignored; aliases are part of the registered set. */\n aliasMessage?: string;\n}\n\nfunction unique(values: string[]): string[] {\n return [...new Set(values.filter(Boolean))];\n}\n\nfunction validateHarnesses(harnesses: string[]): void {\n const supported = new Set(getPlatformIds());\n const invalid = harnesses.filter((harness) => !supported.has(harness));\n if (invalid.length > 0) {\n throw new Error(`Unsupported harness: ${invalid.join(\", \")}`);\n }\n}\n\nfunction defaultRegistered(\n options: ResolveHarnessSelectionOptions,\n): string[] {\n if (options.harnesses && options.harnesses.length > 0) {\n return normalizeRegisteredHarnesses(options.harnesses);\n }\n const fromFlags = registeredFromLegacyParts(options.main, options.aliases);\n if (fromFlags.length > 0) {\n return fromFlags;\n }\n const current = registeredHarnessesOf(options.current);\n if (current.length > 0) {\n return current;\n }\n const detected = unique(options.detected ?? []);\n if (detected.length > 0) {\n return detected;\n }\n const first = getPlatformIds()[0];\n return first ? [first] : [];\n}\n\nfunction formatCurrentHarnessSummary(\n current: HarnessPreference | HarnessSelection | undefined,\n): string | undefined {\n if (!current) {\n return undefined;\n }\n const registered = registeredHarnessesOf(current);\n return `Current harnesses: ${registered.join(\", \") || \"(none)\"}`;\n}\n\nexport async function resolveHarnessSelection(\n options: ResolveHarnessSelectionOptions = {},\n): Promise<HarnessSelection> {\n const registered = defaultRegistered(options);\n validateHarnesses(registered);\n\n if (options.nonInteractive || !process.stdin.isTTY) {\n return { registered_harnesses: registered };\n }\n\n const detected = unique(options.detected ?? []);\n if (detected.length === 1 && detected[0] && registered.length <= 1) {\n return { registered_harnesses: [detected[0]] };\n }\n\n const harnesses = getAllPlatforms().map((platform) => ({\n name: `${platform.name} (${platform.id})`,\n value: platform.id,\n }));\n\n const currentSummary = formatCurrentHarnessSummary(options.current);\n const selected = await promptForSearchableMultiSelect({\n message: [\n options.message\n ?? options.mainMessage\n ?? \"Select harnesses to keep in sync\",\n currentSummary,\n ].filter(Boolean).join(\"\\n\"),\n default: registered,\n choices: harnesses,\n pageSize: 10,\n loop: false,\n });\n\n const next = normalizeRegisteredHarnesses(selected);\n if (next.length === 0) {\n throw new Error(\"Select at least one harness.\");\n }\n validateHarnesses(next);\n return { registered_harnesses: next };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAS,OA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YAAY,CAAC,CAAC;AAC9C,MAAI,SAAS,WAAW,KAAK,SAAS,CAAC,KAAK,WAAW,UAAU,GAAG;AAClE,WAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC,EAAE;AAAA,EAC/C;AAEA,QAAM,YAAY,gBAAgB,EAAE,IAAI,CAAC,cAAc;AAAA,IACrD,MAAM,GAAG,SAAS,IAAI,KAAK,SAAS,EAAE;AAAA,IACtC,OAAO,SAAS;AAAA,EAClB,EAAE;AAEF,QAAM,iBAAiB,4BAA4B,QAAQ,OAAO;AAClE,QAAM,WAAW,MAAM,+BAA+B;AAAA,IACpD,SAAS;AAAA,MACP,QAAQ,WACL,QAAQ,eACR;AAAA,MACH;AAAA,IACF,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AAAA,IAC3B,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU;AAAA,IACV,MAAM;AAAA,EACR,CAAC;AAED,QAAM,OAAO,6BAA6B,QAAQ;AAClD,MAAI,KAAK,WAAW,GAAG;AACrB,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AACA,oBAAkB,IAAI;AACtB,SAAO,EAAE,sBAAsB,KAAK;AACtC;","names":[]}
|
|
@@ -3,27 +3,23 @@ import {
|
|
|
3
3
|
parseListSearchQuery
|
|
4
4
|
} from "./chunk-KRI4R7EM.js";
|
|
5
5
|
import {
|
|
6
|
+
RESOURCE_TYPES,
|
|
6
7
|
VIEWPORT_CHROME_LINES,
|
|
7
8
|
computeMaxVisibleTableRows,
|
|
9
|
+
formatHookInventoryLabel,
|
|
10
|
+
getAllPlatforms,
|
|
11
|
+
hookDisplayInputFromResource,
|
|
8
12
|
renderFoldedHintLine,
|
|
9
13
|
resolveSectionViewport
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
RESOURCE_TYPES,
|
|
13
|
-
formatHookInventoryLabel,
|
|
14
|
-
hookDisplayInputFromResource
|
|
15
|
-
} from "./chunk-ZUASVASP.js";
|
|
14
|
+
} from "./chunk-26QGX47N.js";
|
|
16
15
|
import {
|
|
16
|
+
formatCount,
|
|
17
17
|
formatRelativeTime,
|
|
18
18
|
renderTable,
|
|
19
19
|
resolveTableMaxWidth,
|
|
20
20
|
shortenId,
|
|
21
21
|
theme
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import {
|
|
24
|
-
getAllPlatforms,
|
|
25
|
-
resolveHomeRoot
|
|
26
|
-
} from "./chunk-DF4Z7LAD.js";
|
|
22
|
+
} from "./chunk-MTCCUYBZ.js";
|
|
27
23
|
|
|
28
24
|
// src/ui/resource-display.ts
|
|
29
25
|
var AGENTS_INSTRUCTIONS_RESOURCE_NAME = "agents-instructions";
|
|
@@ -84,38 +80,26 @@ function instructionFileName(resource) {
|
|
|
84
80
|
}
|
|
85
81
|
return null;
|
|
86
82
|
}
|
|
87
|
-
function
|
|
83
|
+
function platformForInstructionResource(name) {
|
|
88
84
|
if (!name.endsWith("-instructions") || name === AGENTS_INSTRUCTIONS_RESOURCE_NAME) {
|
|
89
85
|
return null;
|
|
90
86
|
}
|
|
91
87
|
const prefix = name.slice(0, -"-instructions".length);
|
|
92
88
|
const platforms = getAllPlatforms();
|
|
93
|
-
const
|
|
94
|
-
if (exact) {
|
|
95
|
-
return exact.name;
|
|
96
|
-
}
|
|
97
|
-
const withCli = platforms.find((platform) => platform.id === `${prefix}-cli`);
|
|
98
|
-
if (withCli) {
|
|
99
|
-
return withCli.name;
|
|
100
|
-
}
|
|
101
|
-
const withCode = platforms.find(
|
|
89
|
+
const match = platforms.find((platform) => platform.id === prefix) ?? platforms.find((platform) => platform.id === `${prefix}-cli`) ?? platforms.find(
|
|
102
90
|
(platform) => platform.id === `${prefix}-code` || platform.id.startsWith(`${prefix}-`)
|
|
103
91
|
);
|
|
104
|
-
|
|
105
|
-
return withCode.name;
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
92
|
+
return match ? { id: match.id, name: match.name } : null;
|
|
108
93
|
}
|
|
109
|
-
function
|
|
94
|
+
function hasNamespaceQualifier(resource) {
|
|
110
95
|
const namespace = resource.namespace?.trim() ?? "";
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return fromName;
|
|
96
|
+
return namespace.length > 0 && namespace !== GLOBAL_SCOPE_LABEL;
|
|
97
|
+
}
|
|
98
|
+
function instructionQualifier(resource) {
|
|
99
|
+
if (hasNamespaceQualifier(resource)) {
|
|
100
|
+
return resource.namespace?.trim() ?? "";
|
|
117
101
|
}
|
|
118
|
-
return SHARED_INSTRUCTION_SCOPE_LABEL;
|
|
102
|
+
return platformForInstructionResource(resource.name)?.name ?? SHARED_INSTRUCTION_SCOPE_LABEL;
|
|
119
103
|
}
|
|
120
104
|
function formatInstructionInventoryLabel(resource) {
|
|
121
105
|
const file = instructionFileName(resource);
|
|
@@ -353,7 +337,7 @@ function renderGroupedPluginEditViewport(rows, opts) {
|
|
|
353
337
|
}),
|
|
354
338
|
renderViewportOverflowHints(ctx, viewport, maxWidth),
|
|
355
339
|
"",
|
|
356
|
-
theme.info(`${checkedCount} selected \u2022 ${rows.length}
|
|
340
|
+
theme.info(`${checkedCount} selected \u2022 ${formatCount(rows.length, "resource")}`)
|
|
357
341
|
].filter((line) => line.length > 0).join("\n");
|
|
358
342
|
}
|
|
359
343
|
function renderFlatPluginEditViewport(rows, opts) {
|
|
@@ -385,7 +369,7 @@ function renderFlatPluginEditViewport(rows, opts) {
|
|
|
385
369
|
renderTable({
|
|
386
370
|
columns: makeResourceListColumns(opts.showId, false, hasNamespace, true),
|
|
387
371
|
rows: decorateRowsForCheckboxes(visibleRows, { ...opts, activeRowId }),
|
|
388
|
-
summary: `${checkedCount} selected ${theme.muted(`(${opts.navigable.length
|
|
372
|
+
summary: `${checkedCount} selected ${theme.muted(`(${formatCount(opts.navigable.length, "resource")})`)}`,
|
|
389
373
|
...resourceListTableLayout(opts)
|
|
390
374
|
}),
|
|
391
375
|
...hints
|
|
@@ -416,7 +400,7 @@ function renderFlatResourceListViewport(resources, opts) {
|
|
|
416
400
|
renderTable({
|
|
417
401
|
columns,
|
|
418
402
|
rows: decorateRowsForSelection(visibleRows, selectedId),
|
|
419
|
-
summary:
|
|
403
|
+
summary: formatCount(resources.length, "resource"),
|
|
420
404
|
...resourceListTableLayout(opts)
|
|
421
405
|
}),
|
|
422
406
|
...hints
|
|
@@ -642,7 +626,7 @@ function renderGroupedResourceListTables(resources, opts) {
|
|
|
642
626
|
}
|
|
643
627
|
}
|
|
644
628
|
lines.push("");
|
|
645
|
-
lines.push(theme.info(
|
|
629
|
+
lines.push(theme.info(formatCount(resources.length, "resource")));
|
|
646
630
|
return lines.join("\n");
|
|
647
631
|
}
|
|
648
632
|
function renderFlatResourceListTable(resources, opts) {
|
|
@@ -662,7 +646,7 @@ function renderFlatResourceListTable(resources, opts) {
|
|
|
662
646
|
renderTable({
|
|
663
647
|
columns: makeResourceListColumns(opts.showId, false, hasNamespace, highlightSelection),
|
|
664
648
|
rows: decorateRowsForSelection(visible, opts.selectedResourceId),
|
|
665
|
-
summary:
|
|
649
|
+
summary: formatCount(sortedRows.length, "resource"),
|
|
666
650
|
...resourceListTableLayout(opts)
|
|
667
651
|
})
|
|
668
652
|
];
|
|
@@ -672,26 +656,6 @@ function renderFlatResourceListTable(resources, opts) {
|
|
|
672
656
|
return lines.join("\n");
|
|
673
657
|
}
|
|
674
658
|
|
|
675
|
-
// src/utils/home-path.ts
|
|
676
|
-
function shortenHomePath(path, home = resolveHomeRoot()) {
|
|
677
|
-
const trimmed = path.trim();
|
|
678
|
-
if (!trimmed || trimmed === "~" || trimmed.startsWith("~/")) {
|
|
679
|
-
return trimmed;
|
|
680
|
-
}
|
|
681
|
-
const normalized = trimmed.replaceAll("\\", "/");
|
|
682
|
-
const homeNorm = home.trim().replaceAll("\\", "/").replace(/\/+$/, "");
|
|
683
|
-
if (homeNorm.length < 2) {
|
|
684
|
-
return trimmed;
|
|
685
|
-
}
|
|
686
|
-
if (normalized === homeNorm) {
|
|
687
|
-
return "~";
|
|
688
|
-
}
|
|
689
|
-
if (normalized.startsWith(`${homeNorm}/`)) {
|
|
690
|
-
return `~${normalized.slice(homeNorm.length)}`;
|
|
691
|
-
}
|
|
692
|
-
return trimmed;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
659
|
export {
|
|
696
660
|
formatOriginDisplayLabel,
|
|
697
661
|
resourceHumanName,
|
|
@@ -712,7 +676,6 @@ export {
|
|
|
712
676
|
listNavigablePluginEditRows,
|
|
713
677
|
formatResourceSelectionLabel,
|
|
714
678
|
renderGroupedResourceListTables,
|
|
715
|
-
renderFlatResourceListTable
|
|
716
|
-
shortenHomePath
|
|
679
|
+
renderFlatResourceListTable
|
|
717
680
|
};
|
|
718
|
-
//# sourceMappingURL=chunk-
|
|
681
|
+
//# sourceMappingURL=chunk-RM7VP6ID.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/resource-display.ts","../src/ui/resource-list-render.ts"],"sourcesContent":["import { getAllPlatforms } from \"../platforms/registry.js\";\nimport {\n formatHookInventoryLabel,\n hookDisplayInputFromResource,\n type HookDisplayInput,\n} from \"./hook-display.js\";\n\nexport {\n formatHookInventoryLabel,\n formatHookInventoryTooltipLines,\n hookCommandShortToken,\n hookInventoryWireFromResource,\n normalizeHookEventName,\n} from \"./hook-display.js\";\nexport type { HookDisplayInput, HookInventoryWire } from \"./hook-display.js\";\n\nexport const AGENTS_INSTRUCTIONS_RESOURCE_NAME = \"agents-instructions\";\nexport const AGENTS_MD_DISPLAY_NAME = \"AGENTS.md (shared)\";\nexport const GLOBAL_SCOPE_LABEL = \"global\";\nexport const SHARED_INSTRUCTION_SCOPE_LABEL = \"shared\";\n\nconst LOCAL_ORIGIN_KINDS = new Set([\"local\", \"local_snapshot\", \"manual\"]);\n\nconst ORIGIN_KIND_LABELS: Record<string, string> = {\n local: \"Local\",\n marketplace_link: \"Marketplace\",\n untracked: \"Untracked\",\n};\n\nconst PACKAGE_ENTRY_FILE_NAMES = new Set([\"skill.md\", \"plugin.json\"]);\n\nexport function groupedOriginKind(originKind: string): string {\n if (LOCAL_ORIGIN_KINDS.has(originKind)) {\n return \"local\";\n }\n return originKind;\n}\n\nexport function formatOriginKindLabel(originKind: string): string {\n const grouped = groupedOriginKind(originKind);\n return ORIGIN_KIND_LABELS[grouped] ?? grouped.replaceAll(\"_\", \" \");\n}\n\nexport function formatOriginDisplayLabel(\n originKind: string,\n originRef?: string | null,\n options?: { includeRef?: boolean },\n): string {\n const kind = formatOriginKindLabel(originKind);\n const includeRef = options?.includeRef ?? true;\n const ref = originRef?.trim() ?? \"\";\n if (!includeRef || !ref) {\n return kind;\n }\n return `${kind} (${ref})`;\n}\n\nexport function isAgentsMdResource(resource: {\n name: string;\n source?: string | null;\n}): boolean {\n if (resource.name === AGENTS_INSTRUCTIONS_RESOURCE_NAME) {\n return true;\n }\n const source = (resource.source ?? \"\").replaceAll(\"\\\\\", \"/\").replace(/\\/+$/, \"\");\n if (!source) {\n return false;\n }\n return source === \"AGENTS.md\" || source.endsWith(\"/AGENTS.md\");\n}\n\nexport type ResourceDisplaySource = {\n name: string;\n type?: string | null;\n source?: string | null;\n namespace?: string | null;\n content?: string | null;\n hook?: HookDisplayInput[\"hook\"];\n metadata?: unknown;\n};\n\nfunction instructionFileName(resource: ResourceDisplaySource): string | null {\n const source = (resource.source ?? \"\").replaceAll(\"\\\\\", \"/\");\n if (source) {\n const base = source.split(\"/\").filter(Boolean).at(-1);\n if (base) {\n return base;\n }\n }\n if (isAgentsMdResource(resource)) {\n return \"AGENTS.md\";\n }\n if (resource.name === \"claude-instructions\") {\n return \"CLAUDE.md\";\n }\n if (resource.name.endsWith(\"-instructions\")) {\n return \"AGENTS.md\";\n }\n return null;\n}\n\ntype InstructionPlatform = { id: string; name: string };\n\nfunction platformForInstructionResource(name: string): InstructionPlatform | null {\n if (!name.endsWith(\"-instructions\") || name === AGENTS_INSTRUCTIONS_RESOURCE_NAME) {\n return null;\n }\n const prefix = name.slice(0, -\"-instructions\".length);\n const platforms = getAllPlatforms();\n const match =\n platforms.find((platform) => platform.id === prefix) ??\n platforms.find((platform) => platform.id === `${prefix}-cli`) ??\n platforms.find(\n (platform) => platform.id === `${prefix}-code` || platform.id.startsWith(`${prefix}-`),\n );\n return match ? { id: match.id, name: match.name } : null;\n}\n\nfunction hasNamespaceQualifier(resource: ResourceDisplaySource): boolean {\n const namespace = resource.namespace?.trim() ?? \"\";\n return namespace.length > 0 && namespace !== GLOBAL_SCOPE_LABEL;\n}\n\nfunction instructionQualifier(resource: ResourceDisplaySource): string {\n if (hasNamespaceQualifier(resource)) {\n return resource.namespace?.trim() ?? \"\";\n }\n return platformForInstructionResource(resource.name)?.name ?? SHARED_INSTRUCTION_SCOPE_LABEL;\n}\n\nexport type InstructionHarnessParts = {\n /** Bare file name, e.g. `CLAUDE.md`. */\n file: string;\n harnessId: string;\n harnessName: string;\n};\n\n/**\n * Chip form of a harness-specific instruction file: the bare file name plus\n * the harness it belongs to, so a chip can show an icon instead of the\n * `(Claude Code)` suffix. Null for shared or namespaced instructions, which\n * keep the full label so peers stay distinct.\n */\nexport function instructionHarnessParts(\n resource: ResourceDisplaySource,\n): InstructionHarnessParts | null {\n if (resource.type !== \"instruction\" || isAgentsMdResource(resource)) {\n return null;\n }\n if (hasNamespaceQualifier(resource)) {\n return null;\n }\n const platform = platformForInstructionResource(resource.name);\n const file = instructionFileName(resource);\n if (!platform || !file) {\n return null;\n }\n return { file, harnessId: platform.id, harnessName: platform.name };\n}\n\nexport function formatInstructionInventoryLabel(\n resource: ResourceDisplaySource,\n): string {\n const file = instructionFileName(resource);\n if (!file) {\n return resource.name;\n }\n return `${file} (${instructionQualifier(resource)})`;\n}\n\nexport function resourceHumanName(resource: ResourceDisplaySource): string {\n if (resource.type === \"instruction\" || isAgentsMdResource(resource)) {\n return formatInstructionInventoryLabel(resource);\n }\n if (resource.type === \"hook\") {\n return formatHookInventoryLabel(hookDisplayInputFromResource(resource));\n }\n return resource.name;\n}\n\nexport type PluginDisplayOptions = {\n /** When true, plugin refs include `@marketplace` so colliding names stay distinct. */\n disambiguatePlugin?: boolean;\n};\n\n/** Plugin ref names that appear more than once. Authored plugin packages are ignored. */\nexport function duplicatePluginNames(\n resources: readonly {\n name: string;\n type?: string | null;\n listKind?: string | null;\n }[],\n): Set<string> {\n const counts = new Map<string, number>();\n for (const resource of resources) {\n if (resource.type !== \"plugin\" || resource.listKind === \"plugin-package\") {\n continue;\n }\n const name = resource.name.trim();\n if (!name) {\n continue;\n }\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n const duplicates = new Set<string>();\n for (const [name, count] of counts) {\n if (count >= 2) {\n duplicates.add(name);\n }\n }\n return duplicates;\n}\n\nexport function formatResourceDisplayName(\n resource: ResourceDisplaySource & {\n namespace?: string | null;\n origin_ref?: string | null;\n },\n options?: PluginDisplayOptions,\n): string {\n const base = resourceHumanName(resource);\n if (resource.type === \"instruction\" || isAgentsMdResource(resource)) {\n return base;\n }\n if (resource.type === \"plugin\") {\n if (!options?.disambiguatePlugin) {\n return base;\n }\n const ref = resource.origin_ref?.trim() ?? \"\";\n if (ref.includes(\"@\")) {\n return ref;\n }\n const marketplace = resource.namespace?.trim() ?? \"\";\n return marketplace ? `${base}@${marketplace}` : base;\n }\n const namespace = resource.namespace?.trim() ?? \"\";\n return namespace ? `${base}@${namespace}` : base;\n}\n\nexport function formatResourceScopeLabel(namespace?: string | null): string {\n const ns = namespace?.trim() ?? \"\";\n return ns.length > 0 ? ns : GLOBAL_SCOPE_LABEL;\n}\n\nexport function isPackageEntryFileName(fileName: string): boolean {\n return PACKAGE_ENTRY_FILE_NAMES.has(fileName.trim().toLowerCase());\n}\n\n/** Directory shown for SKILL.md / plugin.json package entry files; otherwise the path unchanged. */\nexport function packageDirectoryDisplayPath(path: string): string {\n const trimmed = path.trim();\n if (!trimmed) {\n return trimmed;\n }\n const hasBackslash = trimmed.includes(\"\\\\\") && !trimmed.includes(\"/\");\n const separator = hasBackslash ? \"\\\\\" : \"/\";\n const normalized = trimmed.replace(/[\\\\/]+$/, \"\");\n const parts = normalized.split(/[/\\\\]/);\n const fileName = parts[parts.length - 1] ?? \"\";\n if (!isPackageEntryFileName(fileName) || parts.length < 2) {\n return trimmed;\n }\n return parts.slice(0, -1).join(separator);\n}\n\nexport function inferContainedFileType(relativePath: string): string {\n const top = relativePath.split(\"/\")[0] ?? \"\";\n switch (top) {\n case \"skills\":\n return \"skill\";\n case \"agents\":\n return \"agent\";\n case \"rules\":\n return \"rule\";\n case \"commands\":\n return \"command\";\n case \"hooks\":\n return \"hook\";\n case \"mcp\":\n return \"mcp_server\";\n default:\n return \"file\";\n }\n}\n\nexport function containedFileStem(relativePath: string): string {\n const base = relativePath.split(\"/\").at(-1) ?? relativePath;\n const dot = base.lastIndexOf(\".\");\n if (dot <= 0) {\n return base;\n }\n return base.slice(0, dot);\n}\n","import { formatCount } from \"../copy/plurals.js\";\nimport type { Resource, ResourceType } from \"../types.js\";\nimport { RESOURCE_TYPES } from \"../types.js\";\nimport * as format from \"./format.js\";\nimport {\n matchesListSearchQuery,\n parseListSearchQuery,\n} from \"./list-search.js\";\nimport {\n computeMaxVisibleTableRows,\n renderFoldedHintLine,\n resolveSectionViewport,\n VIEWPORT_CHROME_LINES,\n type SectionViewport,\n} from \"./list-viewport.js\";\nimport {\n duplicatePluginNames,\n formatResourceDisplayName,\n formatResourceScopeLabel,\n resourceHumanName,\n} from \"./resource-display.js\";\nimport { renderTable, resolveTableMaxWidth, type Column } from \"./table.js\";\nimport { theme } from \"./theme.js\";\n\nexport {\n computeMaxVisibleRows,\n computeMaxVisibleTableRows,\n resolveSectionViewport,\n type SectionViewport,\n} from \"./list-viewport.js\";\n\nexport const DEFAULT_RESOURCE_LIST_PER_TYPE_LIMIT = 10;\n\nexport type ResourceListRow = Resource & {\n namespace: string;\n display_name: string;\n};\n\nexport type ResourceListRenderOptions = {\n showId: boolean;\n showAll?: boolean;\n perTypeLimit?: number;\n selectedResourceId?: string;\n maxWidth?: number;\n};\n\nexport type PluginEditTableRow = ResourceListRow & {\n checked: boolean;\n version_constraint?: string;\n};\n\nexport type PluginEditRenderOptions = ResourceListRenderOptions & {\n activeRowId?: string;\n};\n\ntype ResourceListDisplayRow = ResourceListRow & {\n list_display_name: string;\n list_namespace: string;\n};\n\nexport function formatResourceListNamespace(resource: ResourceListRow): string {\n const ns = resource.namespace.trim();\n if (!ns) return formatResourceScopeLabel(ns);\n if (resource.origin_kind === \"marketplace_link\" && resource.origin_ref.includes(\"@\")) {\n const [plugin, marketplace] = resource.origin_ref.split(\"@\", 2);\n if (plugin && marketplace && ns === plugin) {\n return `${marketplace}/${plugin}`;\n }\n }\n return ns;\n}\n\nfunction hasListNamespace(rows: ResourceListRow[]): boolean {\n return rows.some((row) => formatResourceListNamespace(row).length > 0);\n}\n\nexport type ActiveSectionContext = {\n type: ResourceType;\n indexInSection: number;\n sectionRows: ResourceListRow[];\n prevSection?: { type: ResourceType; count: number };\n nextSection?: { type: ResourceType; count: number };\n};\n\nfunction sectionCount(navigable: ResourceListRow[], type: ResourceType): number {\n return navigable.filter((row) => row.type === type).length;\n}\n\nexport function resolveActiveSectionContext(\n navigable: ResourceListRow[],\n active: number,\n): ActiveSectionContext {\n const selected = navigable[active];\n if (!selected) {\n return { type: \"skill\", indexInSection: 0, sectionRows: [] };\n }\n const type = selected.type;\n const sectionRows = navigable.filter((row) => row.type === type);\n const indexInSection = sectionRows.findIndex((row) => row.id === selected.id);\n\n const typeIndex = RESOURCE_TYPES.indexOf(type);\n const prevSection = RESOURCE_TYPES.slice(0, typeIndex)\n .reverse()\n .map((sectionType) => ({\n type: sectionType,\n count: sectionCount(navigable, sectionType),\n }))\n .find((section) => section.count > 0);\n const nextSection = RESOURCE_TYPES.slice(typeIndex + 1)\n .map((sectionType) => ({\n type: sectionType,\n count: sectionCount(navigable, sectionType),\n }))\n .find((section) => section.count > 0);\n\n return { type, indexInSection, sectionRows, prevSection, nextSection };\n}\n\nexport type ResourceListViewportOptions = ResourceListRenderOptions & {\n activeIndex: number;\n navigable: ResourceListRow[];\n terminalRows: number;\n selectedResourceId?: string;\n};\n\nfunction clampIndex(index: number, length: number): number {\n if (length === 0) return 0;\n return Math.max(0, Math.min(index, length - 1));\n}\n\nexport function buildResourceViewportHintSegments(\n ctx: ActiveSectionContext,\n viewport: SectionViewport,\n): string[] {\n const segments: string[] = [];\n const hiddenBelow = ctx.sectionRows.length - viewport.end;\n const hiddenAbove = viewport.start;\n if (hiddenAbove > 0) {\n segments.push(`↑ ${hiddenAbove} above`);\n }\n if (hiddenBelow > 0) {\n segments.push(`↓ ${hiddenBelow} more in ${ctx.type}`);\n }\n if (ctx.nextSection) {\n segments.push(`${ctx.nextSection.type} (${ctx.nextSection.count})`);\n segments.push(\"↓ next type\");\n }\n if (viewport.start === 0 && ctx.prevSection) {\n segments.push(`${ctx.prevSection.type} (${ctx.prevSection.count})`);\n segments.push(\"↑ prev type\");\n }\n return segments;\n}\n\nfunction renderViewportOverflowHints(\n ctx: ActiveSectionContext,\n viewport: SectionViewport,\n maxWidth: number,\n): string {\n const folded = renderFoldedHintLine(\n buildResourceViewportHintSegments(ctx, viewport),\n maxWidth,\n );\n return folded.length > 0 ? theme.muted(folded) : \"\";\n}\n\nexport function renderGroupedResourceListViewport(\n resources: ResourceListRow[],\n opts: ResourceListViewportOptions,\n): string {\n if (resources.length === 0) {\n return \"No resources found.\";\n }\n\n const ctx = resolveActiveSectionContext(opts.navigable, opts.activeIndex);\n if (ctx.sectionRows.length === 0) {\n return \"No resources found.\";\n }\n\n const maxVisibleRows = computeMaxVisibleTableRows(\n opts.terminalRows,\n VIEWPORT_CHROME_LINES.resourceList,\n );\n const viewport = resolveSectionViewport(\n ctx.sectionRows.length,\n ctx.indexInSection,\n maxVisibleRows,\n );\n const visibleRows = ctx.sectionRows.slice(viewport.start, viewport.end);\n const hasNamespace = hasListNamespace(visibleRows);\n const columns = makeResourceListColumns(opts.showId, false, hasNamespace, true);\n\n const maxWidth = resolveTableMaxWidth(opts.maxWidth);\n\n return [\n renderResourceTypeSubheader(ctx.type, ctx.sectionRows.length),\n renderTable({\n columns,\n rows: decorateRowsForSelection(visibleRows, opts.selectedResourceId),\n ...resourceListTableLayout(opts),\n }),\n renderViewportOverflowHints(ctx, viewport, maxWidth),\n ]\n .filter((line) => line.length > 0)\n .join(\"\\n\");\n}\n\nexport type PluginEditViewportOptions = PluginEditRenderOptions & {\n activeIndex: number;\n navigable: PluginEditTableRow[];\n terminalRows: number;\n};\n\nexport function renderGroupedPluginEditViewport(\n rows: PluginEditTableRow[],\n opts: PluginEditViewportOptions,\n): string {\n if (rows.length === 0) {\n return \"No resources found.\";\n }\n\n const ctx = resolveActiveSectionContext(opts.navigable, opts.activeIndex);\n if (ctx.sectionRows.length === 0) {\n return \"No resources found.\";\n }\n\n const maxVisibleRows = computeMaxVisibleTableRows(\n opts.terminalRows,\n VIEWPORT_CHROME_LINES.pluginEdit,\n );\n const viewport = resolveSectionViewport(\n ctx.sectionRows.length,\n ctx.indexInSection,\n maxVisibleRows,\n );\n const visibleRows = ctx.sectionRows.slice(viewport.start, viewport.end) as PluginEditTableRow[];\n const hasNamespace = hasListNamespace(visibleRows);\n const columns = makeResourceListColumns(opts.showId, false, hasNamespace, true);\n const checkedCount = rows.filter((row) => row.checked).length;\n const maxWidth = resolveTableMaxWidth(opts.maxWidth);\n\n return [\n renderResourceTypeSubheader(ctx.type, ctx.sectionRows.length),\n renderTable({\n columns,\n rows: decorateRowsForCheckboxes(visibleRows, opts),\n ...resourceListTableLayout(opts),\n }),\n renderViewportOverflowHints(ctx, viewport, maxWidth),\n \"\",\n theme.info(`${checkedCount} selected • ${formatCount(rows.length, \"resource\")}`),\n ]\n .filter((line) => line.length > 0)\n .join(\"\\n\");\n}\n\nexport function renderFlatPluginEditViewport(\n rows: PluginEditTableRow[],\n opts: PluginEditViewportOptions,\n): string {\n if (rows.length === 0) {\n return \"No resources found.\";\n }\n\n const maxVisibleRows = computeMaxVisibleTableRows(\n opts.terminalRows,\n VIEWPORT_CHROME_LINES.pluginEdit,\n );\n const activeIndex = clampIndex(opts.activeIndex, opts.navigable.length);\n const viewport = resolveSectionViewport(\n opts.navigable.length,\n activeIndex,\n maxVisibleRows,\n );\n const visibleRows = opts.navigable.slice(viewport.start, viewport.end);\n const hasNamespace = hasListNamespace(visibleRows);\n const activeRowId = opts.navigable[activeIndex]?.id;\n const checkedCount = rows.filter((row) => row.checked).length;\n\n const hints: string[] = [];\n if (viewport.start > 0) {\n hints.push(theme.muted(` ↑ ${viewport.start} above`));\n }\n if (viewport.end < opts.navigable.length) {\n hints.push(theme.muted(` ↓ ${opts.navigable.length - viewport.end} more`));\n }\n\n return [\n renderTable({\n columns: makeResourceListColumns(opts.showId, false, hasNamespace, true),\n rows: decorateRowsForCheckboxes(visibleRows, { ...opts, activeRowId }),\n summary: `${checkedCount} selected ${theme.muted(`(${formatCount(opts.navigable.length, \"resource\")})`)}`,\n ...resourceListTableLayout(opts),\n }),\n ...hints,\n ].join(\"\\n\");\n}\n\nexport function renderFlatResourceListViewport(\n resources: ResourceListRow[],\n opts: ResourceListViewportOptions,\n): string {\n if (resources.length === 0) {\n return \"No resources found.\";\n }\n\n const maxVisibleRows = computeMaxVisibleTableRows(\n opts.terminalRows,\n VIEWPORT_CHROME_LINES.resourceList,\n );\n const activeIndex = clampIndex(opts.activeIndex, resources.length);\n const viewport = resolveSectionViewport(resources.length, activeIndex, maxVisibleRows);\n const visibleRows = resources.slice(viewport.start, viewport.end);\n const hasNamespace = hasListNamespace(visibleRows);\n const columns = makeResourceListColumns(opts.showId, false, hasNamespace, true);\n const selectedId = resources[activeIndex]?.id;\n\n const hints: string[] = [];\n if (viewport.start > 0) {\n hints.push(theme.muted(` ↑ ${viewport.start} above`));\n }\n if (viewport.end < resources.length) {\n hints.push(theme.muted(` ↓ ${resources.length - viewport.end} more`));\n }\n\n return [\n renderTable({\n columns,\n rows: decorateRowsForSelection(visibleRows, selectedId),\n summary: formatCount(resources.length, \"resource\"),\n ...resourceListTableLayout(opts),\n }),\n ...hints,\n ].join(\"\\n\");\n}\n\nfunction resourceListTableLayout(opts: ResourceListRenderOptions): {\n maxWidth: number;\n wordWrap: true;\n} {\n return {\n maxWidth: resolveTableMaxWidth(opts.maxWidth),\n wordWrap: true,\n };\n}\n\nfunction makeIdColumn(showId: boolean, width = 13): Column[] {\n return showId\n ? [{\n key: \"id\",\n header: \"ID\",\n width,\n minWidth: width,\n widthShare: 0.18,\n wrapOnWordBoundary: false,\n transform: (value: string) => format.shortenId(String(value)),\n }]\n : [];\n}\n\nfunction makeResourceTypeColumn(width = 14): Column {\n return {\n key: \"type\",\n header: \"TYPE\",\n width,\n style: (value) => theme.resourceType(value),\n };\n}\n\nfunction makeResourceListColumns(\n showId: boolean,\n showType: boolean,\n hasNamespace: boolean,\n highlightSelection: boolean,\n): Column[] {\n return [\n ...makeIdColumn(showId),\n ...(showType ? [makeResourceTypeColumn()] : []),\n {\n key: \"list_display_name\",\n header: \"NAME\",\n width: 28,\n widthShare: 0.45,\n wrapOnWordBoundary: false,\n style: highlightSelection\n ? (value) => (value.startsWith(\"> \") ? theme.accent(value) : value)\n : undefined,\n },\n ...(hasNamespace\n ? [{\n key: \"list_namespace\",\n header: \"NAMESPACE\",\n width: 20,\n widthShare: 0.3,\n style: (value: string) =>\n value ? theme.path(value) : theme.muted(\": \"),\n } as const]\n : []),\n {\n key: \"updated_at\",\n header: \"UPDATED\",\n width: 16,\n fitContent: true,\n transform: (value) => format.formatRelativeTime(String(value)),\n style: (value) => theme.muted(value),\n },\n ];\n}\n\nexport function toResourceListRows(resources: Resource[]): ResourceListRow[] {\n const collidingNames = duplicatePluginNames(resources);\n return resources.map((resource) => ({\n ...resource,\n namespace: resource.namespace ?? \"\",\n display_name: formatResourceDisplayName(resource, {\n disambiguatePlugin: collidingNames.has(resource.name),\n }),\n }));\n}\n\nexport function sortResourcesByUpdatedAt<T extends Pick<Resource, \"updated_at\">>(\n resources: T[],\n): T[] {\n return [...resources].sort(\n (left, right) => Date.parse(right.updated_at) - Date.parse(left.updated_at),\n );\n}\n\nexport function filterResourcesBySearch(\n resources: ResourceListRow[],\n search: string,\n): ResourceListRow[] {\n const parsed = parseListSearchQuery(search);\n if (parsed.raw.length === 0) {\n return resources;\n }\n\n const sectionIsResourceType =\n parsed.section !== undefined\n && (RESOURCE_TYPES as readonly string[]).includes(parsed.section);\n\n const textQuery = sectionIsResourceType\n ? parsed\n : parsed.section !== undefined\n ? { section: undefined, text: parsed.raw, raw: parsed.raw }\n : parsed;\n\n return resources.filter((resource) => {\n if (sectionIsResourceType && resource.type !== parsed.section) {\n return false;\n }\n const haystack = `${resource.name} ${resource.description ?? \"\"} ${resource.display_name} ${formatResourceListNamespace(resource)}`;\n return matchesListSearchQuery(haystack, textQuery);\n });\n}\n\nexport function filterPluginEditRowsBySearch(\n rows: PluginEditTableRow[],\n search: string,\n): PluginEditTableRow[] {\n const normalizedSearch = search.trim().toLowerCase();\n if (normalizedSearch.length === 0) {\n return rows;\n }\n\n return rows.filter((row) =>\n `${row.name} ${row.description ?? \"\"} ${row.display_name} ${row.version_constraint ?? \"\"}`\n .toLowerCase()\n .includes(normalizedSearch),\n );\n}\n\nfunction sortPluginEditRowsForDisplay(rows: PluginEditTableRow[]): PluginEditTableRow[] {\n return [...rows].sort((left, right) => {\n if (left.checked !== right.checked) {\n return left.checked ? -1 : 1;\n }\n return Date.parse(right.updated_at) - Date.parse(left.updated_at);\n });\n}\n\nfunction renderResourceTypeSubheader(type: ResourceType, count: number): string {\n return `${theme.resourceType(type)} ${theme.muted(`(${count})`)}`;\n}\n\nfunction resolvePerTypeLimit(opts: ResourceListRenderOptions): number | undefined {\n if (opts.showAll) {\n return undefined;\n }\n return opts.perTypeLimit ?? DEFAULT_RESOURCE_LIST_PER_TYPE_LIMIT;\n}\n\nfunction limitRows<T extends { id: string }>(\n rows: T[],\n limit: number | undefined,\n selectedResourceId?: string,\n): {\n visible: T[];\n hiddenCount: number;\n} {\n if (limit === undefined || rows.length <= limit) {\n return { visible: rows, hiddenCount: 0 };\n }\n\n let visible = rows.slice(0, limit);\n if (\n selectedResourceId\n && !visible.some((row) => row.id === selectedResourceId)\n ) {\n const selected = rows.find((row) => row.id === selectedResourceId);\n if (selected) {\n visible = [...visible.slice(0, Math.max(0, limit - 1)), selected];\n }\n }\n\n const hiddenCount = rows.length - visible.length;\n return { visible, hiddenCount };\n}\n\nexport function listNavigableResources(\n resources: ResourceListRow[],\n typeFilter?: ResourceType,\n): ResourceListRow[] {\n if (typeFilter) {\n return sortResourcesByUpdatedAt(\n resources.filter((resource) => resource.type === typeFilter),\n );\n }\n\n const ordered: ResourceListRow[] = [];\n for (const type of RESOURCE_TYPES) {\n ordered.push(\n ...sortResourcesByUpdatedAt(\n resources.filter((resource) => resource.type === type),\n ),\n );\n }\n return ordered;\n}\n\nfunction decorateRowsForCheckboxes(\n rows: PluginEditTableRow[],\n opts: PluginEditRenderOptions,\n): ResourceListDisplayRow[] {\n return rows.map((row) => {\n const checkbox = row.checked ? \"[x]\" : \"[ ]\";\n const cursor = row.id === opts.activeRowId ? \">\" : \" \";\n const constraint =\n row.checked && row.version_constraint\n ? ` (${row.version_constraint})`\n : \"\";\n return {\n ...row,\n list_display_name: `${cursor}${checkbox} ${resourceHumanName(row)}${constraint}`,\n list_namespace: formatResourceListNamespace(row),\n };\n });\n}\n\nexport function listNavigablePluginEditRows(\n rows: PluginEditTableRow[],\n typeFilter?: ResourceType,\n): PluginEditTableRow[] {\n if (typeFilter) {\n return sortPluginEditRowsForDisplay(\n rows.filter((row) => row.type === typeFilter),\n );\n }\n\n const ordered: PluginEditTableRow[] = [];\n for (const type of RESOURCE_TYPES) {\n ordered.push(\n ...sortPluginEditRowsForDisplay(\n rows.filter((row) => row.type === type),\n ),\n );\n }\n return ordered;\n}\n\nexport function renderGroupedPluginEditTables(\n rows: PluginEditTableRow[],\n opts: PluginEditRenderOptions,\n): string {\n if (rows.length === 0) {\n return \"No resources found.\";\n }\n\n const hasNamespace = hasListNamespace(rows);\n const columns = makeResourceListColumns(opts.showId, false, hasNamespace, true);\n const perTypeLimit = resolvePerTypeLimit(opts);\n const lines: string[] = [];\n let wroteSection = false;\n\n for (const type of RESOURCE_TYPES) {\n const typeRows = sortPluginEditRowsForDisplay(\n rows.filter((row) => row.type === type),\n );\n if (typeRows.length === 0) {\n continue;\n }\n const { visible, hiddenCount } = limitRows(\n typeRows,\n perTypeLimit,\n opts.activeRowId,\n );\n if (wroteSection) {\n lines.push(\"\");\n }\n wroteSection = true;\n lines.push(renderResourceTypeSubheader(type, typeRows.length));\n lines.push(renderTable({\n columns,\n rows: decorateRowsForCheckboxes(visible, opts),\n ...resourceListTableLayout(opts),\n }));\n if (hiddenCount > 0) {\n lines.push(renderHiddenRowsHint(hiddenCount));\n }\n }\n\n const checkedCount = rows.filter((row) => row.checked).length;\n lines.push(\"\");\n lines.push(theme.info(`${checkedCount} selected • ${formatCount(rows.length, \"resource\")}`));\n return lines.join(\"\\n\");\n}\n\nexport function renderFlatPluginEditTable(\n rows: PluginEditTableRow[],\n opts: PluginEditRenderOptions,\n): string {\n if (rows.length === 0) {\n return \"No resources found.\";\n }\n\n const hasNamespace = hasListNamespace(rows);\n const sortedRows = sortPluginEditRowsForDisplay(rows);\n const perTypeLimit = resolvePerTypeLimit(opts);\n const { visible, hiddenCount } = limitRows(\n sortedRows,\n perTypeLimit,\n opts.activeRowId,\n );\n const checkedCount = rows.filter((row) => row.checked).length;\n const lines = [\n renderTable({\n columns: makeResourceListColumns(opts.showId, false, hasNamespace, true),\n rows: decorateRowsForCheckboxes(visible, opts),\n summary: `${checkedCount} selected ${theme.muted(`(${formatCount(sortedRows.length, \"resource\")})`)}`,\n ...resourceListTableLayout(opts),\n }),\n ];\n if (hiddenCount > 0) {\n lines.push(renderHiddenRowsHint(hiddenCount));\n }\n return lines.join(\"\\n\");\n}\n\nfunction decorateRowsForSelection(\n rows: ResourceListRow[],\n selectedResourceId?: string,\n): ResourceListDisplayRow[] {\n return rows.map((row) => ({\n ...row,\n list_display_name: row.id === selectedResourceId\n ? `> ${resourceHumanName(row)}`\n : ` ${resourceHumanName(row)}`,\n list_namespace: formatResourceListNamespace(row),\n }));\n}\n\nexport function formatResourceSelectionLabel(resource: ResourceListRow): string {\n return `${resource.type} ${resourceHumanName(resource)}`;\n}\n\nfunction renderHiddenRowsHint(hiddenCount: number): string {\n return theme.muted(\n ` ... and ${hiddenCount} more ${hiddenCount === 1 ? \"resource\" : \"resources\"} (use --all to show all)`,\n );\n}\n\nexport function renderGroupedResourceListTables(\n resources: ResourceListRow[],\n opts: ResourceListRenderOptions,\n): string {\n if (resources.length === 0) {\n return \"No resources found.\";\n }\n\n const hasNamespace = hasListNamespace(resources);\n const highlightSelection = Boolean(opts.selectedResourceId);\n const columns = makeResourceListColumns(opts.showId, false, hasNamespace, highlightSelection);\n const perTypeLimit = resolvePerTypeLimit(opts);\n const lines: string[] = [];\n let wroteSection = false;\n\n for (const type of RESOURCE_TYPES) {\n const rows = sortResourcesByUpdatedAt(\n resources.filter((resource) => resource.type === type),\n );\n if (rows.length === 0) {\n continue;\n }\n const { visible, hiddenCount } = limitRows(\n rows,\n perTypeLimit,\n opts.selectedResourceId,\n );\n if (wroteSection) {\n lines.push(\"\");\n }\n wroteSection = true;\n lines.push(renderResourceTypeSubheader(type, rows.length));\n lines.push(renderTable({\n columns,\n rows: decorateRowsForSelection(visible, opts.selectedResourceId),\n ...resourceListTableLayout(opts),\n }));\n if (hiddenCount > 0) {\n lines.push(renderHiddenRowsHint(hiddenCount));\n }\n }\n\n lines.push(\"\");\n lines.push(theme.info(formatCount(resources.length, \"resource\")));\n return lines.join(\"\\n\");\n}\n\nexport function renderFlatResourceListTable(\n resources: ResourceListRow[],\n opts: ResourceListRenderOptions,\n): string {\n if (resources.length === 0) {\n return \"No resources found.\";\n }\n\n const hasNamespace = hasListNamespace(resources);\n const sortedRows = sortResourcesByUpdatedAt(resources);\n const perTypeLimit = resolvePerTypeLimit(opts);\n const highlightSelection = Boolean(opts.selectedResourceId);\n const { visible, hiddenCount } = limitRows(\n sortedRows,\n perTypeLimit,\n opts.selectedResourceId,\n );\n const lines = [\n renderTable({\n columns: makeResourceListColumns(opts.showId, false, hasNamespace, highlightSelection),\n rows: decorateRowsForSelection(visible, opts.selectedResourceId),\n summary: formatCount(sortedRows.length, \"resource\"),\n ...resourceListTableLayout(opts),\n }),\n ];\n if (hiddenCount > 0) {\n lines.push(renderHiddenRowsHint(hiddenCount));\n }\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,oCAAoC;AAE1C,IAAM,qBAAqB;AAC3B,IAAM,iCAAiC;AAE9C,IAAM,qBAAqB,oBAAI,IAAI,CAAC,SAAS,kBAAkB,QAAQ,CAAC;AAExE,IAAM,qBAA6C;AAAA,EACjD,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,WAAW;AACb;AAEA,IAAM,2BAA2B,oBAAI,IAAI,CAAC,YAAY,aAAa,CAAC;AAE7D,SAAS,kBAAkB,YAA4B;AAC5D,MAAI,mBAAmB,IAAI,UAAU,GAAG;AACtC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,SAAS,sBAAsB,YAA4B;AAChE,QAAM,UAAU,kBAAkB,UAAU;AAC5C,SAAO,mBAAmB,OAAO,KAAK,QAAQ,WAAW,KAAK,GAAG;AACnE;AAEO,SAAS,yBACd,YACA,WACA,SACQ;AACR,QAAM,OAAO,sBAAsB,UAAU;AAC7C,QAAM,aAAa,SAAS,cAAc;AAC1C,QAAM,MAAM,WAAW,KAAK,KAAK;AACjC,MAAI,CAAC,cAAc,CAAC,KAAK;AACvB,WAAO;AAAA,EACT;AACA,SAAO,GAAG,IAAI,KAAK,GAAG;AACxB;AAEO,SAAS,mBAAmB,UAGvB;AACV,MAAI,SAAS,SAAS,mCAAmC;AACvD,WAAO;AAAA,EACT;AACA,QAAM,UAAU,SAAS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U,CAAC,CAAC;AAChE,SAAO,MAAM,KAAK,IAAI;AACxB;AAEO,SAAS,4BACd,WACA,MACQ;AACR,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA,EACT;AAEA,QAAM,eAAe,iBAAiB,SAAS;AAC/C,QAAM,aAAa,yBAAyB,SAAS;AACrD,QAAM,eAAe,oBAAoB,IAAI;AAC7C,QAAM,qBAAqB,QAAQ,KAAK,kBAAkB;AAC1D,QAAM,EAAE,SAAS,YAAY,IAAI;AAAA,IAC/B;AAAA,IACA;AAAA,IACA,KAAK;AAAA,EACP;AACA,QAAM,QAAQ;AAAA,IACZ,YAAY;AAAA,MACV,SAAS,wBAAwB,KAAK,QAAQ,OAAO,cAAc,kBAAkB;AAAA,MACrF,MAAM,yBAAyB,SAAS,KAAK,kBAAkB;AAAA,MAC/D,SAAS,YAAY,WAAW,QAAQ,UAAU;AAAA,MAClD,GAAG,wBAAwB,IAAI;AAAA,IACjC,CAAC;AAAA,EACH;AACA,MAAI,cAAc,GAAG;AACnB,UAAM,KAAK,qBAAqB,WAAW,CAAC;AAAA,EAC9C;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
listEnvironments,
|
|
9
9
|
sortStringRecord,
|
|
10
10
|
upsertEnvironmentEnvVar
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-26QGX47N.js";
|
|
12
12
|
|
|
13
13
|
// src/services/environment-import-export.ts
|
|
14
14
|
import { readFileSync } from "fs";
|
|
@@ -138,4 +138,4 @@ export {
|
|
|
138
138
|
importEnvironmentToml,
|
|
139
139
|
formatEnvironmentToml
|
|
140
140
|
};
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
141
|
+
//# sourceMappingURL=chunk-SMLO5YPI.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
PACKAGE_VERSION,
|
|
3
3
|
fetchWithTimeout,
|
|
4
4
|
getHarnesstapDir
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-MTCCUYBZ.js";
|
|
6
6
|
|
|
7
7
|
// src/config/github-session.ts
|
|
8
8
|
import fs from "fs";
|
|
@@ -819,4 +819,4 @@ export {
|
|
|
819
819
|
ensureGithubGitConfigArgs,
|
|
820
820
|
githubHttpsRemoteForAuth
|
|
821
821
|
};
|
|
822
|
-
//# sourceMappingURL=chunk-
|
|
822
|
+
//# sourceMappingURL=chunk-T2JBSRGG.js.map
|
|
@@ -5,29 +5,30 @@ import {
|
|
|
5
5
|
renderExplain,
|
|
6
6
|
splitMcpRegistryIdentity,
|
|
7
7
|
validateApplyOnConflict
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZT7ANP3H.js";
|
|
9
9
|
import {
|
|
10
10
|
printApplyPayload,
|
|
11
11
|
promptMaterializationConflict,
|
|
12
12
|
resolveApplyConflictPolicy,
|
|
13
13
|
resolveUserPath
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-CUOEQQFI.js";
|
|
15
15
|
import {
|
|
16
16
|
initializeSchema
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NXILQDJG.js";
|
|
18
18
|
import {
|
|
19
19
|
parseOutputFormat,
|
|
20
20
|
printJson
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-4E3G4H5B.js";
|
|
22
22
|
import {
|
|
23
23
|
fail,
|
|
24
24
|
formatCommand
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-QHCGA6LC.js";
|
|
26
26
|
import {
|
|
27
27
|
APM_MANIFEST_FILENAME,
|
|
28
28
|
CriticalUnicodeError,
|
|
29
29
|
applyProfilePlugin,
|
|
30
30
|
collectApmAndDevDependencies,
|
|
31
|
+
getPlatform,
|
|
31
32
|
isProfilePlugin,
|
|
32
33
|
parseApmYamlDocument,
|
|
33
34
|
parsePlatformFilter,
|
|
@@ -36,23 +37,20 @@ import {
|
|
|
36
37
|
uniqueHarnessTargets,
|
|
37
38
|
useProfileCommand,
|
|
38
39
|
withProfileApplyLock
|
|
39
|
-
} from "./chunk-
|
|
40
|
-
import {
|
|
41
|
-
trackPluginApplied
|
|
42
|
-
} from "./chunk-N3ZCH64F.js";
|
|
43
|
-
import {
|
|
44
|
-
CliUsageError,
|
|
45
|
-
ui
|
|
46
|
-
} from "./chunk-2A36HWDE.js";
|
|
40
|
+
} from "./chunk-26QGX47N.js";
|
|
47
41
|
import {
|
|
48
|
-
getPlatform,
|
|
49
42
|
resolveHomeRoot
|
|
50
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-LGWFLVZQ.js";
|
|
44
|
+
import {
|
|
45
|
+
trackPluginApplied
|
|
46
|
+
} from "./chunk-MSKTWYHG.js";
|
|
51
47
|
import {
|
|
52
48
|
CLI_HINTS,
|
|
49
|
+
CliUsageError,
|
|
53
50
|
applyCancelledMessage,
|
|
54
|
-
getDb
|
|
55
|
-
|
|
51
|
+
getDb,
|
|
52
|
+
ui
|
|
53
|
+
} from "./chunk-MTCCUYBZ.js";
|
|
56
54
|
|
|
57
55
|
// src/services/apply-scope.ts
|
|
58
56
|
function resolveApplyScope(input) {
|
|
@@ -197,6 +195,7 @@ async function handleGlobalApplyCommand(plugins, opts) {
|
|
|
197
195
|
});
|
|
198
196
|
const applyOptions = {
|
|
199
197
|
dryRun: opts.dryRun,
|
|
198
|
+
planPluginFolders: opts.dryRun,
|
|
200
199
|
harness: opts.harness,
|
|
201
200
|
account: opts.account,
|
|
202
201
|
baseUrl: opts.baseUrl,
|
|
@@ -355,4 +354,4 @@ export {
|
|
|
355
354
|
handleInstallCommand,
|
|
356
355
|
registerInstallCommand
|
|
357
356
|
};
|
|
358
|
-
//# sourceMappingURL=chunk-
|
|
357
|
+
//# sourceMappingURL=chunk-U5Y6WKKT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/apply-scope.ts","../src/services/apm-mcp-manifest.ts","../src/cli/commands/apply.ts"],"sourcesContent":["import type { PlatformPaths } from \"../types.js\";\nimport { getPlatform } from \"../platforms/registry.js\";\nimport { resolveHomeRoot } from \"../utils/home-root.js\";\nimport { resolveUserPath } from \"../utils/user-path.js\";\nimport { ui } from \"../ui/index.js\";\n\nexport type ApplyScope = \"project\" | \"global\";\n\nexport interface ResolvedApplyScope {\n scope: ApplyScope;\n /** Project root for `project`, home root for `global`. */\n root: string;\n /** First line of output, printed in TTY and non-TTY runs alike. */\n destinationLine: string;\n}\n\nexport function resolveApplyScope(input: {\n global?: boolean;\n project?: string;\n platforms: string[];\n}): ResolvedApplyScope {\n if (input.global) {\n const home = resolveHomeRoot();\n const paths = input.platforms\n .map((id) => getPlatform(id))\n .filter((platform): platform is NonNullable<typeof platform> => platform != null)\n .map((platform) => topLevelGlobalPath(platform.globalPaths))\n .filter((path, index, all) => path !== \"\" && all.indexOf(path) === index);\n return {\n scope: \"global\",\n root: home,\n destinationLine: `→ machine home ${paths.map((p) => `~/${p}`).join(\", \")}`.trimEnd(),\n };\n }\n const root = resolveUserPath(input.project ?? \".\", { mustExist: true });\n return { scope: \"project\", root, destinationLine: `→ project ${root}` };\n}\n\nfunction topLevelGlobalPath(paths: PlatformPaths): string {\n for (const value of Object.values(paths)) {\n if (typeof value !== \"string\" || !value) continue;\n const normalized = value.replace(/^~\\//, \"\");\n const segment = normalized.split(\"/\")[0];\n if (segment && segment.startsWith(\".\")) return segment;\n }\n return \"\";\n}\n\nexport function printDestination(resolved: ResolvedApplyScope): void {\n console.log(ui.theme.muted(resolved.destinationLine));\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { stringify as stringifyYaml } from \"yaml\";\nimport { APM_MANIFEST_FILENAME, parseApmYamlDocument } from \"./apm-manifest.js\";\nimport { collectApmAndDevDependencies } from \"./apm-dependencies.js\";\nimport { splitMcpRegistryIdentity } from \"./mcp-registry.js\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nexport function apmManifestPath(projectRoot: string): string {\n return join(projectRoot, APM_MANIFEST_FILENAME);\n}\n\nexport function manifestHasMcpRegistryId(raw: string, registryId: string): boolean {\n const document = parseApmYamlDocument(raw, APM_MANIFEST_FILENAME);\n const { name } = splitMcpRegistryIdentity(registryId);\n const deps = collectApmAndDevDependencies(document);\n return deps.mcp.some((entry) => {\n if (entry.registryId === registryId || entry.registryId === name) {\n return true;\n }\n return entry.raw === registryId || entry.raw === name;\n });\n}\n\nexport function appendMcpRegistryIdToManifest(\n raw: string,\n registryId: string,\n): { next: string; added: boolean } {\n if (manifestHasMcpRegistryId(raw, registryId)) {\n return { next: raw, added: false };\n }\n const document = parseApmYamlDocument(raw, APM_MANIFEST_FILENAME);\n const dependencies = isRecord(document.dependencies) ? { ...document.dependencies } : {};\n const existing = dependencies.mcp;\n const mcp = Array.isArray(existing) ? [...existing, registryId] : [registryId];\n document.dependencies = { ...dependencies, mcp };\n return {\n next: stringifyYaml(document, {\n indent: 2,\n lineWidth: 0,\n defaultKeyType: \"PLAIN\",\n }),\n added: true,\n };\n}\n\nexport async function withMcpManifestAppend(options: {\n projectRoot: string;\n registryId: string;\n dryRun?: boolean;\n run: () => Promise<void>;\n}): Promise<{ added: boolean }> {\n const path = apmManifestPath(options.projectRoot);\n if (!existsSync(path)) {\n throw new Error(\n `No ${APM_MANIFEST_FILENAME} found under ${options.projectRoot}. Run ht config init first.`,\n );\n }\n const previous = readFileSync(path, \"utf8\");\n const { next, added } = appendMcpRegistryIdToManifest(previous, options.registryId);\n if (added) {\n writeFileSync(path, next, \"utf8\");\n }\n const restore = (): void => {\n if (added) {\n writeFileSync(path, previous, \"utf8\");\n }\n };\n try {\n await options.run();\n if ((process.exitCode ?? 0) !== 0 || options.dryRun) {\n restore();\n }\n return { added };\n } catch (error) {\n restore();\n throw error;\n }\n}\n","import type { Command } from \"commander\";\nimport { resolveUserPath } from \"../../utils/user-path.js\";\nimport { getDb } from \"../../db/connection.js\";\nimport { initializeSchema } from \"../../db/schema.js\";\nimport { isProfilePlugin } from \"../../constants/profile.js\";\nimport { resolvePluginSelector } from \"../../models/plugin-model.js\";\nimport {\n addApplyCommandOptions,\n validateApplyOnConflict,\n type ApplyCommandOpts,\n} from \"../../services/apply-command-options.js\";\nimport {\n printDestination,\n resolveApplyScope,\n} from \"../../services/apply-scope.js\";\nimport {\n parsePlatformFilter,\n resolveRegisteredGlobalApplyHarnesses,\n uniqueHarnessTargets,\n} from \"../../services/harness-targets.js\";\nimport { resolveApplyConflictPolicy, promptMaterializationConflict } from \"../../services/materialization-conflicts.js\";\nimport { applyProfilePlugin } from \"../../services/profile-apply.js\";\nimport { withProfileApplyLock } from \"../../services/profile-apply-lock.js\";\nimport { useProfileCommand } from \"../../services/profile-commands.js\";\nimport { CliUsageError } from \"../../services/cli-errors.js\";\nimport { explainPayload, renderExplain } from \"../../services/resolve/explain.js\";\nimport { parseOutputFormat, printJson } from \"../../utils/output-format.js\";\nimport { ui } from \"../../ui/index.js\";\nimport { applyCancelledMessage, CLI_HINTS } from \"../messages.js\";\nimport {\n fail,\n formatCommand,\n} from \"../shared.js\";\nimport { printApplyPayload } from \"../print-apply-summary.js\";\nimport { trackPluginApplied } from \"../../telemetry/index.js\";\nimport { CriticalUnicodeError } from \"../../services/unicode-scan.js\";\nimport { handleProjectApplyCommand } from \"./plugin.js\";\nimport { withMcpManifestAppend } from \"../../services/apm-mcp-manifest.js\";\n\nexport type ApplyCommandActionOpts = ApplyCommandOpts & {\n global?: boolean;\n};\n\nexport type InstallCommandActionOpts = ApplyCommandActionOpts & {\n mcp?: string;\n};\n\nfunction resolveDestinationPlatforms(\n harnessOption: string | undefined,\n forGlobal: boolean,\n): string[] {\n if (forGlobal) {\n return resolveRegisteredGlobalApplyHarnesses(harnessOption);\n }\n return uniqueHarnessTargets(parsePlatformFilter(harnessOption) ?? []);\n}\n\nasync function handleGlobalApplyCommand(\n plugins: string[],\n opts: ApplyCommandActionOpts,\n): Promise<void> {\n const conflictError = validateApplyOnConflict(opts.onConflict);\n if (conflictError) {\n fail(conflictError);\n return;\n }\n\n const db = getDb();\n initializeSchema(db);\n\n const outputFormat = parseOutputFormat(opts.format);\n if (plugins.length === 0) {\n process.exitCode = 1;\n fail(\"Provide exactly one plugin name for --global apply.\", {\n hints: [formatCommand(\"apply <plugin> --global\")],\n });\n return;\n }\n if (plugins.length > 1) {\n process.exitCode = 1;\n fail(\"Global apply accepts exactly one plugin.\", {\n hints: [formatCommand(\"apply <plugin> --global\")],\n });\n return;\n }\n\n const selector = plugins[0];\n if (!selector) {\n process.exitCode = 1;\n fail(\"Provide exactly one plugin name for --global apply.\");\n return;\n }\n\n const plugin = resolvePluginSelector(selector);\n if (!plugin) {\n process.exitCode = 1;\n fail(`Plugin not found: ${selector}`);\n return;\n }\n\n const conflictPolicy = resolveApplyConflictPolicy({\n onConflict: opts.onConflict,\n noInteractive: opts.noInteractive ?? outputFormat === \"json\",\n });\n const applyOptions = {\n dryRun: opts.dryRun,\n planPluginFolders: opts.dryRun,\n harness: opts.harness,\n account: opts.account,\n baseUrl: opts.baseUrl,\n conflictPolicy,\n ...(conflictPolicy === \"prompt\"\n ? { conflictResolver: promptMaterializationConflict }\n : {}),\n ...(opts.force ? { forceUnicode: true } : {}),\n };\n\n try {\n const recordActiveProfile = isProfilePlugin(plugin);\n const payload = recordActiveProfile\n ? await useProfileCommand(selector, applyOptions)\n : await withProfileApplyLock(() =>\n applyProfilePlugin(selector, {\n ...applyOptions,\n recordActiveProfile: false,\n }),\n );\n\n if (!recordActiveProfile && !payload.cancelled) {\n console.warn(\n ui.theme.warn(\n `Applied to machine home, but no active profile was recorded because ${plugin.name} is not a profile plugin.`,\n ),\n );\n }\n\n if (!payload.cancelled && !payload.dry_run) {\n trackPluginApplied({\n pluginSlug: plugin.name,\n harness: payload.harnesses[0],\n });\n }\n\n if (payload.cancelled) {\n process.exitCode = 1;\n }\n\n if (outputFormat === \"json\") {\n const { resolution, ...rest } = payload;\n printJson({\n scope: \"global\",\n ...rest,\n ...(opts.explain && resolution ? { explain: explainPayload(resolution) } : {}),\n });\n return;\n }\n\n if (payload.cancelled) {\n fail(applyCancelledMessage(payload.conflicts, \"apply\"), {\n hint: CLI_HINTS.onConflictReplace,\n });\n return;\n }\n\n if (opts.explain && payload.resolution) {\n console.log(renderExplain(payload.resolution));\n console.log(\"\");\n }\n printApplyPayload(payload);\n } catch (err) {\n process.exitCode = 1;\n if (err instanceof CriticalUnicodeError) {\n fail(err.message, {\n hints: [formatCommand(\"apply --global --force\")],\n });\n return;\n }\n fail(err instanceof Error ? err.message : String(err));\n }\n}\n\nexport async function handleApplyCommand(\n plugins: string[],\n opts: ApplyCommandActionOpts,\n): Promise<void> {\n const conflictError = validateApplyOnConflict(opts.onConflict);\n if (conflictError) {\n fail(conflictError);\n return;\n }\n\n const outputFormat = parseOutputFormat(opts.format);\n let platforms: string[];\n let resolved: ReturnType<typeof resolveApplyScope>;\n try {\n platforms = resolveDestinationPlatforms(opts.harness, Boolean(opts.global));\n resolved = resolveApplyScope({\n global: opts.global,\n project: opts.project,\n platforms,\n });\n } catch (error) {\n if (error instanceof CliUsageError) {\n fail(error.message, { hints: error.hints });\n return;\n }\n fail(error instanceof Error ? error.message : String(error));\n return;\n }\n\n if (outputFormat === \"human\") {\n printDestination(resolved);\n }\n\n if (resolved.scope === \"global\") {\n await handleGlobalApplyCommand(plugins, opts);\n return;\n }\n\n await handleProjectApplyCommand(\n plugins as [string, ...string[]] | [],\n opts,\n );\n}\n\nexport function registerApplyCommand(root: Command): void {\n const apply = root\n .command(\"apply\")\n .argument(\"[plugins...]\", \"Plugins to apply\")\n .option(\"--global\", \"Materialize into machine home instead of the project\")\n .description(\"Resolve a plugin's dependency graph and materialize it\");\n addApplyCommandOptions(apply);\n apply.action(async (plugins: string[], opts: ApplyCommandActionOpts) => {\n await handleApplyCommand(plugins, opts);\n });\n}\n\nexport async function handleInstallCommand(\n extraArgs: string[],\n opts: InstallCommandActionOpts,\n): Promise<void> {\n if (extraArgs.length > 0) {\n process.exitCode = 1;\n fail(\n \"ht install does not take a plugin selector. It reads repo-root apm.yml.\",\n {\n hints: [formatCommand(\"install\"), formatCommand(\"apply <plugin>\")],\n },\n );\n return;\n }\n\n const registryId = opts.mcp?.trim();\n if (registryId) {\n try {\n const result = await withMcpManifestAppend({\n projectRoot: resolveUserPath(opts.project, { mustExist: true }),\n registryId,\n dryRun: opts.dryRun,\n run: () => handleApplyCommand([], opts),\n });\n if (opts.dryRun && result.added) {\n ui.info(`Would add \"${registryId}\" to apm.yml dependencies.mcp.`);\n } else if (result.added && (process.exitCode ?? 0) === 0) {\n ui.info(`Added \"${registryId}\" to apm.yml dependencies.mcp.`);\n }\n } catch (error) {\n process.exitCode = 1;\n fail(error instanceof Error ? error.message : String(error));\n }\n return;\n }\n\n await handleApplyCommand([], opts);\n}\n\nexport function registerInstallCommand(root: Command): void {\n const install = root\n .command(\"install\")\n .description(\n \"Onboard a project from apm.yml (same as apply with no plugin selector)\",\n )\n .allowExcessArguments(true);\n addApplyCommandOptions(install);\n install.option(\n \"--mcp <id>\",\n \"Append an MCP Registry v0.1 identity to apm.yml dependencies.mcp, then install\",\n );\n install.action(async (opts: InstallCommandActionOpts) => {\n await handleInstallCommand(install.args, opts);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO,SAAS,kBAAkB,OAIX;AACrB,MAAI,MAAM,QAAQ;AAChB,UAAM,OAAO,gBAAgB;AAC7B,UAAM,QAAQ,MAAM,UACjB,IAAI,CAAC,OAAO,YAAY,EAAE,CAAC,EAC3B,OAAO,CAAC,aAAuD,YAAY,IAAI,EAC/E,IAAI,CAAC,aAAa,mBAAmB,SAAS,WAAW,CAAC,EAC1D,OAAO,CAAC,MAAM,OAAO,QAAQ,SAAS,MAAM,IAAI,QAAQ,IAAI,MAAM,KAAK;AAC1E,WA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