harnesstap 1.3.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/apply-FTAIL3X3.js +50 -0
- package/dist/{approve-L7IFSYBO.js → approve-R6AWQB3I.js} +12 -16
- package/dist/{approve-L7IFSYBO.js.map → approve-R6AWQB3I.js.map} +1 -1
- package/dist/{audit-PBJDK7A4.js → audit-2HNKFPSU.js} +26 -39
- package/dist/{audit-PBJDK7A4.js.map → audit-2HNKFPSU.js.map} +1 -1
- package/dist/{auth-OM73RLNS.js → auth-C54KRLNF.js} +17 -21
- package/dist/{auth-OM73RLNS.js.map → auth-C54KRLNF.js.map} +1 -1
- package/dist/bin.js +13 -34
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-R4PTE774.js → chunk-2XDYQXP2.js} +34 -41
- package/dist/chunk-2XDYQXP2.js.map +1 -0
- package/dist/{chunk-G5RWVZZ7.js → chunk-3277RVZT.js} +5 -7
- package/dist/{chunk-G5RWVZZ7.js.map → chunk-3277RVZT.js.map} +1 -1
- package/dist/{chunk-6JMVGKMD.js → chunk-3Q72LZPJ.js} +936 -528
- package/dist/chunk-3Q72LZPJ.js.map +1 -0
- package/dist/{chunk-U472S6IB.js → chunk-42E2MPES.js} +19 -27
- package/dist/chunk-42E2MPES.js.map +1 -0
- package/dist/{chunk-CZ4T75PP.js → chunk-5HACBPK2.js} +622 -252
- package/dist/chunk-5HACBPK2.js.map +1 -0
- package/dist/{chunk-IHW4PCDT.js → chunk-6FXJIKEG.js} +6 -6
- package/dist/{chunk-OPVIX7E4.js → chunk-A3TZT4WT.js} +6 -2
- package/dist/chunk-A3TZT4WT.js.map +1 -0
- package/dist/chunk-BUA7WFI4.js +39327 -0
- package/dist/chunk-BUA7WFI4.js.map +1 -0
- package/dist/{chunk-IAZNF35S.js → chunk-CBSDMRMY.js} +2 -2
- package/dist/{chunk-YVJQ2QDG.js → chunk-CR2TYMKC.js} +65 -55
- package/dist/chunk-CR2TYMKC.js.map +1 -0
- package/dist/{chunk-VQVUJYYY.js → chunk-CWXCZBJR.js} +76 -6
- package/dist/chunk-CWXCZBJR.js.map +1 -0
- package/dist/{chunk-AVZOFMJX.js → chunk-D7R577XZ.js} +381 -138
- package/dist/chunk-D7R577XZ.js.map +1 -0
- package/dist/{chunk-3EGM4IUI.js → chunk-EPXAOEBB.js} +6 -6
- package/dist/{chunk-64R32MG2.js → chunk-GZU4LVFF.js} +179 -26
- package/dist/chunk-GZU4LVFF.js.map +1 -0
- package/dist/chunk-HV3ENT2F.js +61 -0
- package/dist/chunk-HV3ENT2F.js.map +1 -0
- package/dist/{chunk-XCPWLGPB.js → chunk-K4UDZUJ2.js} +2 -2
- package/dist/{chunk-OQ4KBUN2.js → chunk-L6BJCRBU.js} +13 -16
- package/dist/chunk-L6BJCRBU.js.map +1 -0
- package/dist/{chunk-AFKCNFPP.js → chunk-M6FEDSHY.js} +16 -15
- package/dist/chunk-M6FEDSHY.js.map +1 -0
- package/dist/chunk-M7PHQ3UC.js +31491 -0
- package/dist/chunk-M7PHQ3UC.js.map +1 -0
- package/dist/{chunk-FBYAIBHP.js → chunk-MHLAIGIM.js} +2 -2
- package/dist/{chunk-ENHDEB7Z.js → chunk-MHMFF6A5.js} +5 -7
- package/dist/{chunk-ENHDEB7Z.js.map → chunk-MHMFF6A5.js.map} +1 -1
- package/dist/chunk-MKLJBW5N.js +14 -0
- package/dist/{chunk-XRXFJTAT.js → chunk-MQCAPCAF.js} +17 -26
- package/dist/chunk-MQCAPCAF.js.map +1 -0
- package/dist/{chunk-UEHDEADL.js → chunk-MQCH3YZ5.js} +15 -13
- package/dist/chunk-MQCH3YZ5.js.map +1 -0
- package/dist/chunk-OHZNDV4A.js +1707 -0
- package/dist/chunk-OHZNDV4A.js.map +1 -0
- package/dist/{chunk-LGWUTV5Q.js → chunk-OWE3OSX6.js} +11 -13
- package/dist/{chunk-LGWUTV5Q.js.map → chunk-OWE3OSX6.js.map} +1 -1
- package/dist/{chunk-EY4ES5MG.js → chunk-PCNHBMBU.js} +3 -5
- package/dist/{chunk-EY4ES5MG.js.map → chunk-PCNHBMBU.js.map} +1 -1
- package/dist/{chunk-YRGM7RAD.js → chunk-QGTDQNVV.js} +7 -11
- package/dist/{chunk-YRGM7RAD.js.map → chunk-QGTDQNVV.js.map} +1 -1
- package/dist/{chunk-BXSS2S4W.js → chunk-R27VZIF6.js} +2 -2
- package/dist/{chunk-TQ2NA4Z4.js → chunk-R4NV3Q7G.js} +8 -2
- package/dist/chunk-R4NV3Q7G.js.map +1 -0
- package/dist/{chunk-FUV7QYBS.js → chunk-R6VFJKZB.js} +86 -319
- package/dist/chunk-R6VFJKZB.js.map +1 -0
- package/dist/{chunk-QNAIDM6W.js → chunk-RQLVXJH2.js} +132 -4
- package/dist/chunk-RQLVXJH2.js.map +1 -0
- package/dist/{chunk-JQOKQKQT.js → chunk-S2D5PWAO.js} +2 -2
- package/dist/{chunk-JJJJ2RAD.js → chunk-T4EKNX2Q.js} +71 -11
- package/dist/chunk-T4EKNX2Q.js.map +1 -0
- package/dist/{chunk-GWQVYGRD.js → chunk-TERYL7JH.js} +118 -78
- package/dist/chunk-TERYL7JH.js.map +1 -0
- package/dist/chunk-UC27MQ3T.js +1920 -0
- package/dist/chunk-UC27MQ3T.js.map +1 -0
- package/dist/chunk-UEA4NCY2.js +106 -0
- package/dist/chunk-UEA4NCY2.js.map +1 -0
- package/dist/{chunk-WXRPQICX.js → chunk-UK2IV2ZQ.js} +2 -2
- package/dist/{chunk-MFCZN253.js → chunk-UZCAYOIQ.js} +8 -10
- package/dist/{chunk-MFCZN253.js.map → chunk-UZCAYOIQ.js.map} +1 -1
- package/dist/{chunk-IKAGGJEO.js → chunk-V4UNYSZO.js} +558 -18
- package/dist/chunk-V4UNYSZO.js.map +1 -0
- package/dist/chunk-VAPCU2FX.js +70 -0
- package/dist/chunk-VAPCU2FX.js.map +1 -0
- package/dist/{chunk-Y2JGMICO.js → chunk-WGVU3LA5.js} +25 -33
- package/dist/chunk-WGVU3LA5.js.map +1 -0
- package/dist/{chunk-UNRR4KH5.js → chunk-WQ3F4O7U.js} +20 -14
- package/dist/chunk-WQ3F4O7U.js.map +1 -0
- package/dist/chunk-XNS4I3W6.js +102 -0
- package/dist/chunk-XNS4I3W6.js.map +1 -0
- package/dist/{chunk-LDVXYN6F.js → chunk-Y4I7ZCAE.js} +178 -135
- package/dist/chunk-Y4I7ZCAE.js.map +1 -0
- package/dist/{chunk-6I3RY6R5.js → chunk-ZKMSHLXP.js} +11 -15
- package/dist/{chunk-6I3RY6R5.js.map → chunk-ZKMSHLXP.js.map} +1 -1
- package/dist/{compile-SDOASKGL.js → compile-B2QG6BAQ.js} +37 -54
- package/dist/{compile-SDOASKGL.js.map → compile-B2QG6BAQ.js.map} +1 -1
- package/dist/{config-4VZTVZKF.js → config-D3F6ICZ2.js} +21 -39
- package/dist/{config-4VZTVZKF.js.map → config-D3F6ICZ2.js.map} +1 -1
- package/dist/cursor-local-install-4HDIBX22.js +94 -0
- package/dist/cursor-local-install-4HDIBX22.js.map +1 -0
- package/dist/cursor-local-install-LL367GZY.js +94 -0
- package/dist/cursor-local-install-LL367GZY.js.map +1 -0
- package/dist/{doctor-HH6CFBRQ.js → doctor-QSGETVDE.js} +19 -23
- package/dist/doctor-QSGETVDE.js.map +1 -0
- package/dist/{environment-K7YMJJYN.js → environment-2JS4RWQA.js} +69 -88
- package/dist/environment-2JS4RWQA.js.map +1 -0
- package/dist/{github-A6TYG7WS.js → github-JXSTHLY2.js} +14 -15
- package/dist/{github-A6TYG7WS.js.map → github-JXSTHLY2.js.map} +1 -1
- package/dist/{harness-772XBFZQ.js → harness-GBI3AMLH.js} +48 -65
- package/dist/{harness-772XBFZQ.js.map → harness-GBI3AMLH.js.map} +1 -1
- package/dist/{help-QR4VTJZU.js → help-EC52ERIE.js} +43 -52
- package/dist/help-EC52ERIE.js.map +1 -0
- package/dist/{help-TLHNRJJ6.js → help-VIRMBOPJ.js} +73 -551
- package/dist/help-VIRMBOPJ.js.map +1 -0
- package/dist/host-plugin-view-kept-XKHD6NGU.js +139 -0
- package/dist/host-plugin-view-kept-XKHD6NGU.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +10 -22
- package/dist/{init-AOKFPZHG.js → init-OK3K6ILG.js} +49 -70
- package/dist/init-OK3K6ILG.js.map +1 -0
- package/dist/live-read-cache-ESQQJBNS.js +13 -0
- package/dist/live-read-cache-WPUFHVMZ.js +12 -0
- package/dist/{lock-INAXNLMC.js → lock-AA2F4I3K.js} +13 -16
- package/dist/{lock-INAXNLMC.js.map → lock-AA2F4I3K.js.map} +1 -1
- package/dist/{marketplace-TUVLLPBG.js → marketplace-QUYCV23F.js} +75 -94
- package/dist/marketplace-QUYCV23F.js.map +1 -0
- package/dist/{mcp-MMWGRASN.js → mcp-CIHSR4DD.js} +35 -52
- package/dist/{mcp-MMWGRASN.js.map → mcp-CIHSR4DD.js.map} +1 -1
- package/dist/{migrate-55S4XODX.js → migrate-TQPEZYS5.js} +148 -74
- package/dist/migrate-TQPEZYS5.js.map +1 -0
- package/dist/notifications-TAELTPDW.js +154 -0
- package/dist/notifications-TAELTPDW.js.map +1 -0
- package/dist/open-D3GWGDSQ.js +20 -0
- package/dist/{pack-VZIBS42E.js → pack-VUO4UBWL.js} +12 -22
- package/dist/{pack-VZIBS42E.js.map → pack-VUO4UBWL.js.map} +1 -1
- package/dist/plugin-L3466DHK.js +47 -0
- package/dist/plugin-from-project-U5UGKTJH.js +15 -0
- package/dist/plugin-from-project-U5UGKTJH.js.map +1 -0
- package/dist/{policy-P3HGLEZS.js → policy-Z5TL4N3V.js} +11 -15
- package/dist/{policy-P3HGLEZS.js.map → policy-Z5TL4N3V.js.map} +1 -1
- package/dist/{profile-STS3CZUK.js → profile-QFI7SL3S.js} +167 -143
- package/dist/profile-QFI7SL3S.js.map +1 -0
- package/dist/{project-R4DGM3ZG.js → project-3KR3EPYR.js} +506 -94
- package/dist/project-3KR3EPYR.js.map +1 -0
- package/dist/{resource-GJVEDXVZ.js → resource-45BPRQ7V.js} +66 -63
- package/dist/resource-45BPRQ7V.js.map +1 -0
- package/dist/status-refresh-worker.js +1155 -0
- package/dist/status-refresh-worker.js.map +1 -0
- package/dist/{version-FUHV4O6U.js → version-QUJZGTZ5.js} +3 -3
- package/dist/version-QUJZGTZ5.js.map +1 -0
- package/package.json +17 -11
- package/dist/apply-Q5SFF3FY.js +0 -67
- package/dist/chunk-24V5ZSIF.js +0 -658
- package/dist/chunk-24V5ZSIF.js.map +0 -1
- package/dist/chunk-2H7UOFLK.js +0 -11
- package/dist/chunk-3JOPDYQD.js +0 -730
- package/dist/chunk-3JOPDYQD.js.map +0 -1
- package/dist/chunk-555XE3NJ.js +0 -60
- package/dist/chunk-555XE3NJ.js.map +0 -1
- package/dist/chunk-64R32MG2.js.map +0 -1
- package/dist/chunk-6JMVGKMD.js.map +0 -1
- package/dist/chunk-6ZWKF3YZ.js +0 -7795
- package/dist/chunk-6ZWKF3YZ.js.map +0 -1
- package/dist/chunk-AFKCNFPP.js.map +0 -1
- package/dist/chunk-AUWWL6KX.js +0 -296
- package/dist/chunk-AUWWL6KX.js.map +0 -1
- package/dist/chunk-AVZOFMJX.js.map +0 -1
- package/dist/chunk-CZ4T75PP.js.map +0 -1
- package/dist/chunk-FUV7QYBS.js.map +0 -1
- package/dist/chunk-GWQVYGRD.js.map +0 -1
- package/dist/chunk-HENOKIBB.js +0 -346
- package/dist/chunk-HENOKIBB.js.map +0 -1
- package/dist/chunk-HWL67OCJ.js +0 -238
- package/dist/chunk-HWL67OCJ.js.map +0 -1
- package/dist/chunk-IKAGGJEO.js.map +0 -1
- package/dist/chunk-JJJJ2RAD.js.map +0 -1
- package/dist/chunk-JRFUTIEH.js +0 -426
- package/dist/chunk-JRFUTIEH.js.map +0 -1
- package/dist/chunk-KJIFZLHN.js +0 -11066
- package/dist/chunk-KJIFZLHN.js.map +0 -1
- package/dist/chunk-LDVXYN6F.js.map +0 -1
- package/dist/chunk-MHOTXMD2.js +0 -430
- package/dist/chunk-MHOTXMD2.js.map +0 -1
- package/dist/chunk-NAGAJ5UM.js +0 -145
- package/dist/chunk-NAGAJ5UM.js.map +0 -1
- package/dist/chunk-NEPUP33Q.js +0 -35
- package/dist/chunk-NEPUP33Q.js.map +0 -1
- package/dist/chunk-OPVIX7E4.js.map +0 -1
- package/dist/chunk-OQ4KBUN2.js.map +0 -1
- package/dist/chunk-OXVCYRZB.js +0 -491
- package/dist/chunk-OXVCYRZB.js.map +0 -1
- package/dist/chunk-PJQAMC6L.js +0 -183
- package/dist/chunk-PJQAMC6L.js.map +0 -1
- package/dist/chunk-PW5QXRBA.js +0 -1173
- package/dist/chunk-PW5QXRBA.js.map +0 -1
- package/dist/chunk-QNAIDM6W.js.map +0 -1
- package/dist/chunk-R4PTE774.js.map +0 -1
- package/dist/chunk-S2E4KSYW.js +0 -610
- package/dist/chunk-S2E4KSYW.js.map +0 -1
- package/dist/chunk-SNVAMWB7.js +0 -40
- package/dist/chunk-SNVAMWB7.js.map +0 -1
- package/dist/chunk-TQ2NA4Z4.js.map +0 -1
- package/dist/chunk-U472S6IB.js.map +0 -1
- package/dist/chunk-UEHDEADL.js.map +0 -1
- package/dist/chunk-UNRR4KH5.js.map +0 -1
- package/dist/chunk-VQVUJYYY.js.map +0 -1
- package/dist/chunk-XGTTOO4R.js +0 -84
- package/dist/chunk-XGTTOO4R.js.map +0 -1
- package/dist/chunk-XRXFJTAT.js.map +0 -1
- package/dist/chunk-Y2JGMICO.js.map +0 -1
- package/dist/chunk-YVJQ2QDG.js.map +0 -1
- package/dist/chunk-YX7MVSDA.js +0 -235
- package/dist/chunk-YX7MVSDA.js.map +0 -1
- package/dist/chunk-ZGRBIBO7.js +0 -681
- package/dist/chunk-ZGRBIBO7.js.map +0 -1
- package/dist/chunk-ZTBAMBAI.js +0 -6448
- package/dist/chunk-ZTBAMBAI.js.map +0 -1
- package/dist/chunk-ZVANUFPF.js +0 -1035
- package/dist/chunk-ZVANUFPF.js.map +0 -1
- package/dist/doctor-HH6CFBRQ.js.map +0 -1
- package/dist/environment-K7YMJJYN.js.map +0 -1
- package/dist/help-QR4VTJZU.js.map +0 -1
- package/dist/help-TLHNRJJ6.js.map +0 -1
- package/dist/init-AOKFPZHG.js.map +0 -1
- package/dist/marketplace-TUVLLPBG.js.map +0 -1
- package/dist/migrate-55S4XODX.js.map +0 -1
- package/dist/open-SLFQV45J.js +0 -32
- package/dist/plugin-WLEFFBRY.js +0 -64
- package/dist/plugin-from-project-UV2O364T.js +0 -16
- package/dist/profile-STS3CZUK.js.map +0 -1
- package/dist/project-R4DGM3ZG.js.map +0 -1
- package/dist/resource-GJVEDXVZ.js.map +0 -1
- /package/dist/{apply-Q5SFF3FY.js.map → apply-FTAIL3X3.js.map} +0 -0
- /package/dist/{chunk-IHW4PCDT.js.map → chunk-6FXJIKEG.js.map} +0 -0
- /package/dist/{chunk-IAZNF35S.js.map → chunk-CBSDMRMY.js.map} +0 -0
- /package/dist/{chunk-3EGM4IUI.js.map → chunk-EPXAOEBB.js.map} +0 -0
- /package/dist/{chunk-XCPWLGPB.js.map → chunk-K4UDZUJ2.js.map} +0 -0
- /package/dist/{chunk-FBYAIBHP.js.map → chunk-MHLAIGIM.js.map} +0 -0
- /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
- /package/dist/{chunk-BXSS2S4W.js.map → chunk-R27VZIF6.js.map} +0 -0
- /package/dist/{chunk-JQOKQKQT.js.map → chunk-S2D5PWAO.js.map} +0 -0
- /package/dist/{chunk-WXRPQICX.js.map → chunk-UK2IV2ZQ.js.map} +0 -0
- /package/dist/{open-SLFQV45J.js.map → live-read-cache-ESQQJBNS.js.map} +0 -0
- /package/dist/{plugin-WLEFFBRY.js.map → live-read-cache-WPUFHVMZ.js.map} +0 -0
- /package/dist/{plugin-from-project-UV2O364T.js.map → open-D3GWGDSQ.js.map} +0 -0
- /package/dist/{version-FUHV4O6U.js.map → plugin-L3466DHK.js.map} +0 -0
|
@@ -0,0 +1,1707 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/services/package-cache/host-plugin-view-policy.ts
|
|
8
|
+
var forceReplace = false;
|
|
9
|
+
var blocked = [];
|
|
10
|
+
var kept = [];
|
|
11
|
+
var replaced = [];
|
|
12
|
+
function setHostPluginViewForceReplace(force) {
|
|
13
|
+
forceReplace = force;
|
|
14
|
+
}
|
|
15
|
+
function hostPluginViewForceReplace() {
|
|
16
|
+
return forceReplace;
|
|
17
|
+
}
|
|
18
|
+
function recordKeptHostPluginViewFiles(entry) {
|
|
19
|
+
const index = kept.findIndex((existing) => existing.hostView === entry.hostView);
|
|
20
|
+
const earlier = index >= 0 ? kept.splice(index, 1)[0] : void 0;
|
|
21
|
+
const alreadyReported = entry.alreadyReported === true && (earlier === void 0 || earlier.alreadyReported === true);
|
|
22
|
+
kept.push({ ...entry, alreadyReported });
|
|
23
|
+
}
|
|
24
|
+
function recordReplacedHostPluginViewFiles(entry) {
|
|
25
|
+
replaced.push(entry);
|
|
26
|
+
}
|
|
27
|
+
var added = /* @__PURE__ */ new Map();
|
|
28
|
+
function recordAddedHostPluginViewFiles(hostView, paths) {
|
|
29
|
+
if (paths.length === 0) return;
|
|
30
|
+
const files = added.get(hostView) ?? /* @__PURE__ */ new Set();
|
|
31
|
+
for (const path of paths) files.add(path);
|
|
32
|
+
added.set(hostView, files);
|
|
33
|
+
}
|
|
34
|
+
function recordBlockedHostPluginViewFiles(entry) {
|
|
35
|
+
const index = blocked.findIndex((existing) => existing.hostView === entry.hostView);
|
|
36
|
+
if (index >= 0) blocked.splice(index, 1);
|
|
37
|
+
if (entry.files.length > 0) blocked.push(entry);
|
|
38
|
+
}
|
|
39
|
+
function takeBlockedHostPluginViewFiles() {
|
|
40
|
+
return blocked.splice(0, blocked.length);
|
|
41
|
+
}
|
|
42
|
+
function hasHostPluginViewNotices() {
|
|
43
|
+
return kept.length > 0 || replaced.length > 0 || blocked.length > 0 || added.size > 0;
|
|
44
|
+
}
|
|
45
|
+
function hostPluginViewChangeCounts() {
|
|
46
|
+
let addedCount = 0;
|
|
47
|
+
for (const files of added.values()) addedCount += files.size;
|
|
48
|
+
let replacedCount = 0;
|
|
49
|
+
let removedCount = 0;
|
|
50
|
+
for (const entry of replaced) {
|
|
51
|
+
const removedHere = entry.removed?.length ?? 0;
|
|
52
|
+
removedCount += removedHere;
|
|
53
|
+
replacedCount += entry.files.length - removedHere;
|
|
54
|
+
}
|
|
55
|
+
return { replaced: replacedCount, removed: removedCount, added: addedCount };
|
|
56
|
+
}
|
|
57
|
+
function takeReplacedHostPluginViewFiles() {
|
|
58
|
+
added.clear();
|
|
59
|
+
return replaced.splice(0, replaced.length);
|
|
60
|
+
}
|
|
61
|
+
function pendingKeptHostPluginViewPaths() {
|
|
62
|
+
return keptHostPluginViewPaths((entry) => !entry.alreadyReported);
|
|
63
|
+
}
|
|
64
|
+
function allKeptHostPluginViewPaths() {
|
|
65
|
+
return keptHostPluginViewPaths(() => true);
|
|
66
|
+
}
|
|
67
|
+
function keptHostPluginViewPaths(include) {
|
|
68
|
+
return kept.filter(include).flatMap((entry) => {
|
|
69
|
+
const root = entry.homeRoot.replace(/[\\/]+$/, "");
|
|
70
|
+
const folder = entry.hostView.replace(/\\/g, "/");
|
|
71
|
+
const prefix = `${root.replace(/\\/g, "/")}/`;
|
|
72
|
+
if (!folder.startsWith(prefix)) return [];
|
|
73
|
+
const rel = folder.slice(prefix.length).replace(/\/+$/, "");
|
|
74
|
+
return entry.files.map((file) => `${rel}/${file.path.replace(/\\/g, "/")}`);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function takeKeptHostPluginViewFiles() {
|
|
78
|
+
return kept.splice(0, kept.length);
|
|
79
|
+
}
|
|
80
|
+
function hostPluginViewNoticesJson() {
|
|
81
|
+
const out = {};
|
|
82
|
+
if (kept.length > 0) {
|
|
83
|
+
out.kept_plugin_files = kept.flatMap(
|
|
84
|
+
(entry) => entry.files.map((file) => ({
|
|
85
|
+
folder: entry.hostView,
|
|
86
|
+
path: file.path,
|
|
87
|
+
reason: file.reason === "modified" ? "changed_since_written" : "not_written_by_harnesstap",
|
|
88
|
+
in_plugin: file.inPlugin !== false
|
|
89
|
+
}))
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (replaced.length > 0) {
|
|
93
|
+
out.replaced_plugin_files = replaced.map((entry) => ({
|
|
94
|
+
folder: entry.hostView,
|
|
95
|
+
files: entry.files,
|
|
96
|
+
not_written_by_harnesstap: entry.notWrittenByHarnessTap,
|
|
97
|
+
backup_id: entry.backupId
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
if (blocked.length > 0) {
|
|
101
|
+
out.blocked_plugin_files = blocked.flatMap(
|
|
102
|
+
(entry) => entry.files.map((file) => ({
|
|
103
|
+
folder: entry.hostView,
|
|
104
|
+
path: file.path,
|
|
105
|
+
blocked_by: file.blockedBy,
|
|
106
|
+
kind: file.kind
|
|
107
|
+
}))
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/copy/plurals.ts
|
|
114
|
+
function formatCount(count, noun, plural = `${noun}s`) {
|
|
115
|
+
return `${count} ${count === 1 ? noun : plural}`;
|
|
116
|
+
}
|
|
117
|
+
function pluralNoun(count, noun, plural = `${noun}s`) {
|
|
118
|
+
return count === 1 ? noun : plural;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/ui/progress.ts
|
|
122
|
+
import ora from "ora";
|
|
123
|
+
|
|
124
|
+
// src/ui/theme.ts
|
|
125
|
+
import chalk from "chalk";
|
|
126
|
+
function colorEnabled() {
|
|
127
|
+
return !process.env.NO_COLOR && chalk.level > 0;
|
|
128
|
+
}
|
|
129
|
+
function maybe(style) {
|
|
130
|
+
return (value) => colorEnabled() ? style(value) : value;
|
|
131
|
+
}
|
|
132
|
+
var icons = {
|
|
133
|
+
success: "\u2713",
|
|
134
|
+
warn: "\u26A0",
|
|
135
|
+
danger: "\u2717",
|
|
136
|
+
hint: "\u2192",
|
|
137
|
+
bullet: "\xB7",
|
|
138
|
+
profile: "\u25CE",
|
|
139
|
+
added: "+",
|
|
140
|
+
removed: "\u2212",
|
|
141
|
+
modified: "~"
|
|
142
|
+
};
|
|
143
|
+
var resourceTypeStyles = {
|
|
144
|
+
instruction: maybe((value) => chalk.hex("#60a5fa")(value)),
|
|
145
|
+
skill: maybe((value) => chalk.hex("#34d399")(value)),
|
|
146
|
+
rule: maybe((value) => chalk.hex("#fbbf24")(value)),
|
|
147
|
+
mcp_server: maybe((value) => chalk.hex("#a78bfa")(value)),
|
|
148
|
+
permission: maybe((value) => chalk.hex("#f87171")(value)),
|
|
149
|
+
hook: maybe((value) => chalk.hex("#fb923c")(value)),
|
|
150
|
+
agent: maybe((value) => chalk.hex("#c084fc")(value)),
|
|
151
|
+
command: maybe((value) => chalk.hex("#2dd4bf")(value)),
|
|
152
|
+
env_var: maybe((value) => chalk.hex("#94a3b8")(value)),
|
|
153
|
+
model_config: maybe((value) => chalk.hex("#e879f9")(value))
|
|
154
|
+
};
|
|
155
|
+
var mutedStyle = maybe((value) => chalk.hex("#6b7280")(value));
|
|
156
|
+
function styleResourceType(value) {
|
|
157
|
+
const style = resourceTypeStyles[value];
|
|
158
|
+
return style ? style(value) : mutedStyle(value);
|
|
159
|
+
}
|
|
160
|
+
var theme = {
|
|
161
|
+
// Existing tokens for backward compatibility
|
|
162
|
+
primary: maybe((value) => chalk.bold(value)),
|
|
163
|
+
accent: maybe((value) => chalk.hex("#3b82f6")(value)),
|
|
164
|
+
muted: mutedStyle,
|
|
165
|
+
success: maybe((value) => chalk.hex("#14b8a6")(value)),
|
|
166
|
+
warn: maybe((value) => chalk.hex("#e6b84d")(value)),
|
|
167
|
+
danger: maybe((value) => chalk.hex("#ef4444")(value)),
|
|
168
|
+
badge: maybe((value) => chalk.bgHex("#3b82f6").white.bold(` ${value} `)),
|
|
169
|
+
// Role-based tokens
|
|
170
|
+
heading: maybe((value) => chalk.bold.hex("#3b82f6")(value)),
|
|
171
|
+
label: maybe((value) => chalk.hex("#6b7280")(value)),
|
|
172
|
+
command: maybe((value) => chalk.hex("#14b8a6")(value)),
|
|
173
|
+
flag: maybe((value) => chalk.hex("#3b82f6")(value)),
|
|
174
|
+
entity: maybe((value) => chalk.hex("#e6b84d")(value)),
|
|
175
|
+
path: maybe((value) => chalk.hex("#8b5cf6")(value)),
|
|
176
|
+
info: maybe((value) => chalk.hex("#6b7280")(value)),
|
|
177
|
+
border: maybe((value) => chalk.hex("#374151")(value)),
|
|
178
|
+
resourceType: styleResourceType
|
|
179
|
+
};
|
|
180
|
+
function disableColor() {
|
|
181
|
+
process.env.NO_COLOR = "1";
|
|
182
|
+
chalk.level = 0;
|
|
183
|
+
}
|
|
184
|
+
function isTty() {
|
|
185
|
+
return process.stdout.isTTY === true;
|
|
186
|
+
}
|
|
187
|
+
function terminalColumns() {
|
|
188
|
+
return process.stdout.columns ?? 80;
|
|
189
|
+
}
|
|
190
|
+
function terminalRows() {
|
|
191
|
+
return process.stdout.rows ?? 24;
|
|
192
|
+
}
|
|
193
|
+
function getTableChars() {
|
|
194
|
+
return isTty() && !process.env.NO_COLOR ? {} : {
|
|
195
|
+
top: "-",
|
|
196
|
+
"top-mid": "+",
|
|
197
|
+
"top-left": "+",
|
|
198
|
+
"top-right": "+",
|
|
199
|
+
bottom: "-",
|
|
200
|
+
"bottom-mid": "+",
|
|
201
|
+
"bottom-left": "+",
|
|
202
|
+
"bottom-right": "+",
|
|
203
|
+
left: "|",
|
|
204
|
+
"left-mid": "+",
|
|
205
|
+
mid: "-",
|
|
206
|
+
"mid-mid": "+",
|
|
207
|
+
right: "|",
|
|
208
|
+
"right-mid": "+",
|
|
209
|
+
middle: "|"
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/ui/progress.ts
|
|
214
|
+
function createProgress(message) {
|
|
215
|
+
let spinner = null;
|
|
216
|
+
if (isTty() && process.env.NODE_ENV !== "test") {
|
|
217
|
+
spinner = ora(message).start();
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
succeed(verdict) {
|
|
221
|
+
if (spinner) {
|
|
222
|
+
spinner.succeed(verdict);
|
|
223
|
+
spinner = null;
|
|
224
|
+
} else {
|
|
225
|
+
console.log(theme.success(`${icons.success} ${verdict}`));
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
fail(verdict) {
|
|
229
|
+
if (spinner) {
|
|
230
|
+
spinner.fail(verdict);
|
|
231
|
+
spinner = null;
|
|
232
|
+
} else {
|
|
233
|
+
console.error(theme.danger(`${icons.danger} ${verdict}`));
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
stop() {
|
|
237
|
+
spinner?.stop();
|
|
238
|
+
spinner = null;
|
|
239
|
+
},
|
|
240
|
+
update(message2) {
|
|
241
|
+
if (spinner) {
|
|
242
|
+
spinner.text = message2;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
var progress = {
|
|
248
|
+
start: (message) => createProgress(message),
|
|
249
|
+
stop: () => {
|
|
250
|
+
},
|
|
251
|
+
succeed: (message) => {
|
|
252
|
+
console.log(theme.success(`${icons.success} ${message}`));
|
|
253
|
+
},
|
|
254
|
+
fail: (message) => {
|
|
255
|
+
console.error(theme.danger(`${icons.danger} ${message}`));
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// src/ui/format.ts
|
|
260
|
+
var format_exports = {};
|
|
261
|
+
__export(format_exports, {
|
|
262
|
+
formatAbsoluteTime: () => formatAbsoluteTime,
|
|
263
|
+
formatCount: () => formatCount,
|
|
264
|
+
formatRelativeTime: () => formatRelativeTime,
|
|
265
|
+
formatRelativeTimeWithAbsolute: () => formatRelativeTimeWithAbsolute,
|
|
266
|
+
shortenId: () => shortenId,
|
|
267
|
+
truncate: () => truncate
|
|
268
|
+
});
|
|
269
|
+
function truncate(value, width) {
|
|
270
|
+
if (value.length <= width) return value;
|
|
271
|
+
if (width <= 3) return ".".repeat(Math.max(1, width));
|
|
272
|
+
return `${value.slice(0, width - 3)}...`;
|
|
273
|
+
}
|
|
274
|
+
function shortenId(value) {
|
|
275
|
+
if (value.length <= 10) return value;
|
|
276
|
+
return `${value.slice(0, 4)}...${value.slice(-4)}`;
|
|
277
|
+
}
|
|
278
|
+
function formatAbsoluteTime(value, options) {
|
|
279
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
280
|
+
const pad = (part) => String(part).padStart(2, "0");
|
|
281
|
+
const day = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
282
|
+
if (options?.includeTime) {
|
|
283
|
+
return `${day} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
284
|
+
}
|
|
285
|
+
return day;
|
|
286
|
+
}
|
|
287
|
+
function formatRelativeTime(value) {
|
|
288
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
289
|
+
const diffMs = Date.now() - date.getTime();
|
|
290
|
+
const minute = 6e4;
|
|
291
|
+
const hour = 60 * minute;
|
|
292
|
+
const day = 24 * hour;
|
|
293
|
+
if (diffMs < minute) {
|
|
294
|
+
return `${formatCount(Math.max(1, Math.floor(diffMs / 1e3)), "second")} ago`;
|
|
295
|
+
}
|
|
296
|
+
if (diffMs < hour) {
|
|
297
|
+
return `${formatCount(Math.floor(diffMs / minute), "minute")} ago`;
|
|
298
|
+
}
|
|
299
|
+
if (diffMs < day) {
|
|
300
|
+
return `${formatCount(Math.floor(diffMs / hour), "hour")} ago`;
|
|
301
|
+
}
|
|
302
|
+
if (diffMs <= 30 * day) {
|
|
303
|
+
return `${formatCount(Math.floor(diffMs / day), "day")} ago`;
|
|
304
|
+
}
|
|
305
|
+
return formatAbsoluteTime(date);
|
|
306
|
+
}
|
|
307
|
+
function formatRelativeTimeWithAbsolute(value) {
|
|
308
|
+
const relative = formatRelativeTime(value);
|
|
309
|
+
const absolute = formatAbsoluteTime(value, { includeTime: true });
|
|
310
|
+
if (relative === absolute) return relative;
|
|
311
|
+
return `${relative} (${absolute})`;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/ui/kv.ts
|
|
315
|
+
function renderKv(key, value, keyWidth = 20, indent = 2) {
|
|
316
|
+
const spaces = " ".repeat(indent);
|
|
317
|
+
return `${spaces}${theme.muted(key.padEnd(keyWidth))} ${value}`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/ui/table.ts
|
|
321
|
+
import Table from "cli-table3";
|
|
322
|
+
var OFF_TTY_TABLE_WIDTH = 100;
|
|
323
|
+
function resolveTableMaxWidth(explicit) {
|
|
324
|
+
if (explicit !== void 0) {
|
|
325
|
+
return explicit;
|
|
326
|
+
}
|
|
327
|
+
if (isTty() && typeof process.stdout.columns === "number" && process.stdout.columns > 0) {
|
|
328
|
+
return process.stdout.columns;
|
|
329
|
+
}
|
|
330
|
+
if (isTty()) {
|
|
331
|
+
return terminalColumns();
|
|
332
|
+
}
|
|
333
|
+
return OFF_TTY_TABLE_WIDTH;
|
|
334
|
+
}
|
|
335
|
+
var ESC = String.fromCharCode(27);
|
|
336
|
+
var ANSI_SGR = new RegExp(`${ESC}\\[[0-9;]*m`, "g");
|
|
337
|
+
var ANSI_SGR_AT_START = new RegExp(`^${ESC}\\[[0-9;]*m`);
|
|
338
|
+
function visibleLength(value) {
|
|
339
|
+
return value.replace(ANSI_SGR, "").length;
|
|
340
|
+
}
|
|
341
|
+
function truncateTableCell(value, width) {
|
|
342
|
+
if (width <= 0) {
|
|
343
|
+
return "";
|
|
344
|
+
}
|
|
345
|
+
if (visibleLength(value) <= width) {
|
|
346
|
+
return value;
|
|
347
|
+
}
|
|
348
|
+
if (width <= 3) {
|
|
349
|
+
let visible2 = 0;
|
|
350
|
+
let index2 = 0;
|
|
351
|
+
while (index2 < value.length && visible2 < width) {
|
|
352
|
+
const match = value.slice(index2).match(ANSI_SGR_AT_START);
|
|
353
|
+
if (match) {
|
|
354
|
+
index2 += match[0].length;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
visible2 += 1;
|
|
358
|
+
index2 += 1;
|
|
359
|
+
}
|
|
360
|
+
return value.slice(0, index2);
|
|
361
|
+
}
|
|
362
|
+
const budget = width - 3;
|
|
363
|
+
let visible = 0;
|
|
364
|
+
let index = 0;
|
|
365
|
+
while (index < value.length && visible < budget) {
|
|
366
|
+
const match = value.slice(index).match(ANSI_SGR_AT_START);
|
|
367
|
+
if (match) {
|
|
368
|
+
index += match[0].length;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
visible += 1;
|
|
372
|
+
index += 1;
|
|
373
|
+
}
|
|
374
|
+
const sliced = value.slice(0, index);
|
|
375
|
+
const reset = sliced.includes(ESC) ? `${ESC}[0m` : "";
|
|
376
|
+
return `${sliced}...${reset}`;
|
|
377
|
+
}
|
|
378
|
+
function contentWidth(col, rows) {
|
|
379
|
+
return Math.max(
|
|
380
|
+
col.width,
|
|
381
|
+
col.header.length,
|
|
382
|
+
...rows.map((row) => {
|
|
383
|
+
const raw = String(row[col.key] ?? "");
|
|
384
|
+
const transformed = col.transform ? col.transform(raw) : raw;
|
|
385
|
+
return transformed.length;
|
|
386
|
+
})
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
function tableBorderOverhead(columnCount) {
|
|
390
|
+
return columnCount + 1;
|
|
391
|
+
}
|
|
392
|
+
function computeColumnWidths(columns, rows, maxWidth) {
|
|
393
|
+
const contentWidths = columns.map((col) => contentWidth(col, rows) + 2);
|
|
394
|
+
if (maxWidth === void 0) {
|
|
395
|
+
return contentWidths;
|
|
396
|
+
}
|
|
397
|
+
const overhead = tableBorderOverhead(columns.length);
|
|
398
|
+
const available = Math.max(columns.length, maxWidth - overhead);
|
|
399
|
+
const fitIndexes = columns.map((col, index) => col.fitContent ? index : -1).filter((index) => index >= 0);
|
|
400
|
+
const flexibleIndexes = columns.map((col, index) => col.fitContent ? -1 : index).filter((index) => index >= 0);
|
|
401
|
+
const widths = contentWidths.slice();
|
|
402
|
+
if (fitIndexes.length > 0) {
|
|
403
|
+
for (const index of fitIndexes) {
|
|
404
|
+
widths[index] = contentWidths[index] ?? 0;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const fitTotal = fitIndexes.reduce((sum, index) => sum + (widths[index] ?? 0), 0);
|
|
408
|
+
const flexibleBudget = Math.max(flexibleIndexes.length, available - fitTotal);
|
|
409
|
+
if (flexibleIndexes.length === 0) {
|
|
410
|
+
return shrinkToAvailable(widths, columns, available);
|
|
411
|
+
}
|
|
412
|
+
const flexibleColumns = flexibleIndexes.map((index) => columns[index]);
|
|
413
|
+
const flexibleContent = flexibleIndexes.map((index) => contentWidths[index] ?? 0);
|
|
414
|
+
const flexibleWidths = allocateFlexibleColumnWidths(
|
|
415
|
+
flexibleColumns,
|
|
416
|
+
flexibleContent,
|
|
417
|
+
flexibleBudget
|
|
418
|
+
);
|
|
419
|
+
flexibleIndexes.forEach((columnIndex, innerIndex) => {
|
|
420
|
+
widths[columnIndex] = flexibleWidths[innerIndex] ?? widths[columnIndex] ?? 0;
|
|
421
|
+
});
|
|
422
|
+
return shrinkToAvailable(widths, columns, available);
|
|
423
|
+
}
|
|
424
|
+
function shrinkToAvailable(widths, columns, available) {
|
|
425
|
+
let allocated = widths.reduce((sum, width) => sum + width, 0);
|
|
426
|
+
if (allocated <= available) {
|
|
427
|
+
return widths;
|
|
428
|
+
}
|
|
429
|
+
let overflow = allocated - available;
|
|
430
|
+
for (let index = widths.length - 1; index >= 0 && overflow > 0; index--) {
|
|
431
|
+
if (columns[index]?.fitContent) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const floor = columns[index]?.minWidth ?? 1;
|
|
435
|
+
const reducible = Math.max(0, (widths[index] ?? 0) - floor);
|
|
436
|
+
if (reducible <= 0) {
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
const take = Math.min(reducible, overflow);
|
|
440
|
+
widths[index] = (widths[index] ?? 0) - take;
|
|
441
|
+
overflow -= take;
|
|
442
|
+
}
|
|
443
|
+
for (let index = widths.length - 1; index >= 0 && overflow > 0; index--) {
|
|
444
|
+
const floor = 1;
|
|
445
|
+
const reducible = Math.max(0, (widths[index] ?? 0) - floor);
|
|
446
|
+
if (reducible <= 0) {
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
const take = Math.min(reducible, overflow);
|
|
450
|
+
widths[index] = (widths[index] ?? 0) - take;
|
|
451
|
+
overflow -= take;
|
|
452
|
+
}
|
|
453
|
+
return widths;
|
|
454
|
+
}
|
|
455
|
+
function allocateFlexibleColumnWidths(columns, contentWidths, available) {
|
|
456
|
+
if (columns.length === 0) {
|
|
457
|
+
return [];
|
|
458
|
+
}
|
|
459
|
+
const hasWidthShare = columns.some((col) => col.widthShare !== void 0);
|
|
460
|
+
if (hasWidthShare) {
|
|
461
|
+
const floors = columns.map((col) => col.minWidth ?? 0);
|
|
462
|
+
const shareSum = columns.reduce((sum, col) => sum + (col.widthShare ?? 0), 0);
|
|
463
|
+
const widths2 = columns.map((col, index) => {
|
|
464
|
+
const share = shareSum > 0 ? (col.widthShare ?? 0) / shareSum : 1 / columns.length;
|
|
465
|
+
return Math.max(floors[index] ?? 0, Math.floor(available * share));
|
|
466
|
+
});
|
|
467
|
+
let allocated2 = widths2.reduce((sum, width) => sum + width, 0);
|
|
468
|
+
if (allocated2 > available) {
|
|
469
|
+
let overflow = allocated2 - available;
|
|
470
|
+
for (let index = widths2.length - 1; index >= 0 && overflow > 0; index--) {
|
|
471
|
+
const reducible = (widths2[index] ?? 0) - (floors[index] ?? 0);
|
|
472
|
+
if (reducible <= 0) {
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
const take = Math.min(reducible, overflow);
|
|
476
|
+
widths2[index] = (widths2[index] ?? 0) - take;
|
|
477
|
+
overflow -= take;
|
|
478
|
+
}
|
|
479
|
+
allocated2 = widths2.reduce((sum, width) => sum + width, 0);
|
|
480
|
+
}
|
|
481
|
+
if (widths2.length > 0 && allocated2 < available) {
|
|
482
|
+
widths2[0] = (widths2[0] ?? 0) + available - allocated2;
|
|
483
|
+
}
|
|
484
|
+
return widths2;
|
|
485
|
+
}
|
|
486
|
+
const total = contentWidths.reduce((sum, width) => sum + width, 0);
|
|
487
|
+
if (total <= available) {
|
|
488
|
+
return contentWidths;
|
|
489
|
+
}
|
|
490
|
+
const minWidths = columns.map(
|
|
491
|
+
(col, index) => Math.min(col.width + 2, contentWidths[index] ?? col.width + 2)
|
|
492
|
+
);
|
|
493
|
+
const minTotal = minWidths.reduce((sum, width) => sum + width, 0);
|
|
494
|
+
if (minTotal >= available) {
|
|
495
|
+
let remaining = available;
|
|
496
|
+
return minWidths.map((width, index) => {
|
|
497
|
+
if (index === minWidths.length - 1) {
|
|
498
|
+
return remaining;
|
|
499
|
+
}
|
|
500
|
+
const capped = Math.min(width, remaining);
|
|
501
|
+
remaining -= capped;
|
|
502
|
+
return capped;
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
const extra = contentWidths.map((width, index) => width - (minWidths[index] ?? 0));
|
|
506
|
+
const extraTotal = extra.reduce((sum, width) => sum + width, 0);
|
|
507
|
+
const budget = available - minTotal;
|
|
508
|
+
const widths = minWidths.map((min, index) => {
|
|
509
|
+
if (extraTotal === 0) {
|
|
510
|
+
return min;
|
|
511
|
+
}
|
|
512
|
+
return min + Math.floor(budget * (extra[index] ?? 0) / extraTotal);
|
|
513
|
+
});
|
|
514
|
+
const allocated = widths.reduce((sum, width) => sum + width, 0);
|
|
515
|
+
if (widths.length > 0) {
|
|
516
|
+
widths[0] = (widths[0] ?? 0) + available - allocated;
|
|
517
|
+
}
|
|
518
|
+
return widths;
|
|
519
|
+
}
|
|
520
|
+
function renderTable({
|
|
521
|
+
columns,
|
|
522
|
+
rows,
|
|
523
|
+
summary,
|
|
524
|
+
empty,
|
|
525
|
+
maxWidth,
|
|
526
|
+
wordWrap,
|
|
527
|
+
wrapOnWordBoundary
|
|
528
|
+
}) {
|
|
529
|
+
if (rows.length === 0 && empty) {
|
|
530
|
+
return empty;
|
|
531
|
+
}
|
|
532
|
+
const resolvedMaxWidth = resolveTableMaxWidth(maxWidth);
|
|
533
|
+
const colWidths = computeColumnWidths(columns, rows, resolvedMaxWidth);
|
|
534
|
+
const t = new Table({
|
|
535
|
+
head: columns.map((col) => theme.heading(col.header)),
|
|
536
|
+
colWidths,
|
|
537
|
+
chars: getTableChars(),
|
|
538
|
+
truncate: "...",
|
|
539
|
+
style: { head: [], border: [] },
|
|
540
|
+
...wordWrap !== void 0 ? { wordWrap } : {},
|
|
541
|
+
...wrapOnWordBoundary !== void 0 ? { wrapOnWordBoundary } : {}
|
|
542
|
+
});
|
|
543
|
+
for (const row of rows) {
|
|
544
|
+
t.push(
|
|
545
|
+
columns.map((col, index) => {
|
|
546
|
+
const raw = String(row[col.key] ?? "");
|
|
547
|
+
const transformed = col.transform ? col.transform(raw) : raw;
|
|
548
|
+
const innerWidth = Math.max(0, (colWidths[index] ?? col.width) - 2);
|
|
549
|
+
const clipOverflow = Boolean(col.truncate) || Boolean(col.fitContent) || !wordWrap;
|
|
550
|
+
const clipped = clipOverflow ? truncateTableCell(transformed, innerWidth) : transformed;
|
|
551
|
+
const content = col.style ? col.style(clipped) : clipped;
|
|
552
|
+
if (col.wrapOnWordBoundary === false) {
|
|
553
|
+
return { content, wrapOnWordBoundary: false };
|
|
554
|
+
}
|
|
555
|
+
return content;
|
|
556
|
+
})
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
const lines = [t.toString()];
|
|
560
|
+
if (summary) {
|
|
561
|
+
lines.push("");
|
|
562
|
+
lines.push(theme.info(summary));
|
|
563
|
+
}
|
|
564
|
+
return lines.join("\n");
|
|
565
|
+
}
|
|
566
|
+
var table = {
|
|
567
|
+
render: renderTable,
|
|
568
|
+
print: (opts) => console.log(renderTable(opts))
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// src/ui/panel.ts
|
|
572
|
+
function renderPanelTitle(parts) {
|
|
573
|
+
const [head, ...rest] = parts;
|
|
574
|
+
return rest.length === 0 ? theme.primary(head ?? "") : `${theme.primary(head ?? "")} ${rest.map((p) => theme.muted(p)).join(" ")}`;
|
|
575
|
+
}
|
|
576
|
+
function renderPanel(opts) {
|
|
577
|
+
const lines = [renderPanelTitle(opts.title)];
|
|
578
|
+
for (const [key, value] of opts.rows) {
|
|
579
|
+
lines.push(renderKv(key, value));
|
|
580
|
+
}
|
|
581
|
+
return lines.join("\n");
|
|
582
|
+
}
|
|
583
|
+
function panel(opts) {
|
|
584
|
+
console.log(renderPanel(opts));
|
|
585
|
+
}
|
|
586
|
+
function kvBlock(rows, opts) {
|
|
587
|
+
for (const row of rows) {
|
|
588
|
+
console.log(renderKv(row.key, row.value, opts?.keyWidth, opts?.indent));
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// src/ui/diff.ts
|
|
593
|
+
function renderDiffTable({ rows, title }) {
|
|
594
|
+
const lines = [];
|
|
595
|
+
if (title) {
|
|
596
|
+
lines.push(theme.primary(title));
|
|
597
|
+
}
|
|
598
|
+
for (const row of rows) {
|
|
599
|
+
lines.push(` ${theme.muted(row.key)}`);
|
|
600
|
+
lines.push(` ${theme.danger(`${icons.removed} ${row.before}`)}`);
|
|
601
|
+
lines.push(` ${theme.success(`${icons.added} ${row.after}`)}`);
|
|
602
|
+
}
|
|
603
|
+
return lines.join("\n");
|
|
604
|
+
}
|
|
605
|
+
var diffTable = {
|
|
606
|
+
render: renderDiffTable,
|
|
607
|
+
print: (opts) => console.log(renderDiffTable(opts))
|
|
608
|
+
};
|
|
609
|
+
function renderChangeList(changes) {
|
|
610
|
+
return changes.map((change) => {
|
|
611
|
+
const glyph = change.kind === "added" ? icons.added : change.kind === "removed" ? icons.removed : icons.modified;
|
|
612
|
+
const style = change.kind === "added" ? theme.success : change.kind === "removed" ? theme.danger : theme.warn;
|
|
613
|
+
return ` ${style(glyph)} ${change.scope.padEnd(10)} ${change.key.padEnd(28)} ${change.detail}`;
|
|
614
|
+
}).join("\n");
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// src/ui/status.ts
|
|
618
|
+
function line(icon, message) {
|
|
619
|
+
return `${icon} ${message}`;
|
|
620
|
+
}
|
|
621
|
+
function renderSuccess(message, opts) {
|
|
622
|
+
return opts?.hint ? `${theme.success(line(icons.success, message))}
|
|
623
|
+
${theme.info(`${icons.hint} ${opts.hint}`)}` : theme.success(line(icons.success, message));
|
|
624
|
+
}
|
|
625
|
+
function renderWarn(message, opts) {
|
|
626
|
+
return opts?.hint ? `${theme.warn(line(icons.warn, message))}
|
|
627
|
+
${theme.info(`${icons.hint} ${opts.hint}`)}` : theme.warn(line(icons.warn, message));
|
|
628
|
+
}
|
|
629
|
+
function renderDanger(message, opts) {
|
|
630
|
+
const hints = opts?.hints ?? (opts?.hint ? [opts.hint] : []);
|
|
631
|
+
const base = theme.danger(line(icons.danger, message));
|
|
632
|
+
if (hints.length === 0) {
|
|
633
|
+
return base;
|
|
634
|
+
}
|
|
635
|
+
return `${base}
|
|
636
|
+
${hints.map((hint) => ` ${theme.info(`${icons.hint} ${hint}`)}`).join("\n")}`;
|
|
637
|
+
}
|
|
638
|
+
var status = {
|
|
639
|
+
success: (message, opts) => console.log(renderSuccess(message, opts)),
|
|
640
|
+
warn: (message, opts) => console.log(renderWarn(message, opts)),
|
|
641
|
+
danger: (message, opts) => console.error(renderDanger(message, opts)),
|
|
642
|
+
info: (message) => console.log(theme.info(message)),
|
|
643
|
+
dim: (message) => console.log(theme.info(message)),
|
|
644
|
+
hint: (message) => console.log(` ${theme.info(`${icons.hint} ${message}`)}`)
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// src/ui/section.ts
|
|
648
|
+
function renderHeader(title) {
|
|
649
|
+
return theme.heading(title);
|
|
650
|
+
}
|
|
651
|
+
function renderSubheader(title) {
|
|
652
|
+
return theme.label(title);
|
|
653
|
+
}
|
|
654
|
+
function renderRule() {
|
|
655
|
+
return theme.border("\u2500".repeat(terminalColumns()));
|
|
656
|
+
}
|
|
657
|
+
function header(title) {
|
|
658
|
+
console.log(renderHeader(title));
|
|
659
|
+
}
|
|
660
|
+
function subheader(title) {
|
|
661
|
+
console.log(renderSubheader(title));
|
|
662
|
+
}
|
|
663
|
+
function rule() {
|
|
664
|
+
console.log(renderRule());
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// src/ui/index.ts
|
|
668
|
+
var ui = {
|
|
669
|
+
format: format_exports,
|
|
670
|
+
icons,
|
|
671
|
+
theme,
|
|
672
|
+
header,
|
|
673
|
+
renderHeader,
|
|
674
|
+
subheader,
|
|
675
|
+
renderSubheader,
|
|
676
|
+
rule,
|
|
677
|
+
renderRule,
|
|
678
|
+
table,
|
|
679
|
+
renderTable,
|
|
680
|
+
panel,
|
|
681
|
+
renderPanel,
|
|
682
|
+
kvBlock,
|
|
683
|
+
renderKv,
|
|
684
|
+
diffTable,
|
|
685
|
+
renderDiffTable,
|
|
686
|
+
renderChangeList,
|
|
687
|
+
spinner: progress,
|
|
688
|
+
createProgress,
|
|
689
|
+
...status,
|
|
690
|
+
disableColor
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
// src/version.ts
|
|
694
|
+
import { execFileSync } from "child_process";
|
|
695
|
+
|
|
696
|
+
// package.json
|
|
697
|
+
var package_default = {
|
|
698
|
+
name: "harnesstap",
|
|
699
|
+
version: "1.6.0",
|
|
700
|
+
description: "Agent harness configuration toolkit for Claude Code, Codex, Cursor, and other coding CLIs",
|
|
701
|
+
type: "module",
|
|
702
|
+
packageManager: "bun@1.3.9",
|
|
703
|
+
files: [
|
|
704
|
+
"dist",
|
|
705
|
+
"LICENSE",
|
|
706
|
+
"README.md",
|
|
707
|
+
"schemas"
|
|
708
|
+
],
|
|
709
|
+
bin: {
|
|
710
|
+
harnesstap: "./dist/bin.js",
|
|
711
|
+
ht: "./dist/bin.js"
|
|
712
|
+
},
|
|
713
|
+
scripts: {
|
|
714
|
+
build: "bun scripts/generate-scenarios.ts && rm -rf dist && tsup",
|
|
715
|
+
"generate:scenarios": "bun scripts/generate-scenarios.ts",
|
|
716
|
+
"check:packaged-help": "bun scripts/check-packaged-help.ts",
|
|
717
|
+
"snapshot:released-cli": "bun scripts/snapshot-released-cli.ts",
|
|
718
|
+
"build:sidecar": "bash scripts/build-sidecar.sh",
|
|
719
|
+
"check:compiled-sidecar": "bun scripts/check-compiled-sidecar.ts",
|
|
720
|
+
"desktop:cleanup": "bash apps/desktop/scripts/cleanup-stale-dev.sh",
|
|
721
|
+
"desktop:prepare-sidecar": "bash apps/desktop/scripts/prepare-sidecar.sh",
|
|
722
|
+
"desktop:watch-sidecar": "bun apps/desktop/scripts/watch-sidecar.ts",
|
|
723
|
+
"desktop:icons": "cd apps/desktop && bun run icons",
|
|
724
|
+
"desktop:dev": "bash apps/desktop/scripts/desktop-dev.sh",
|
|
725
|
+
"desktop:build": "bun run desktop:prepare-sidecar && cd apps/desktop && bun install && bun run tauri build && bash scripts/reseal-macos-app.sh",
|
|
726
|
+
"desktop:install": "bun apps/desktop/scripts/install-local.ts",
|
|
727
|
+
"desktop:e2e:build": "bash apps/desktop/scripts/e2e-build.sh",
|
|
728
|
+
"desktop:e2e": "bash apps/desktop/scripts/e2e-run.sh",
|
|
729
|
+
"desktop:demo-agent": "bash apps/desktop/scripts/demo-home.sh",
|
|
730
|
+
"desktop:shots": "cd apps/desktop && bun run shots",
|
|
731
|
+
"desktop:check": "bash apps/desktop/scripts/desktop-check.sh",
|
|
732
|
+
dev: "tsup --watch",
|
|
733
|
+
start: "bun src/bin.ts",
|
|
734
|
+
"start:dist": "node dist/bin.js",
|
|
735
|
+
link: "bun run build && bun link",
|
|
736
|
+
unlink: "bun unlink",
|
|
737
|
+
test: "bun test --timeout 30000",
|
|
738
|
+
"test:run": "bun test --dots --timeout 30000",
|
|
739
|
+
"test:core": "bun test --dots --timeout 30000 test/models test/db test/config test/utils test/telemetry test/scripts",
|
|
740
|
+
"test:platforms": "bun test --dots --timeout 30000 test/platforms",
|
|
741
|
+
"test:plugins": "bun test --dots --timeout 30000 test/plugins",
|
|
742
|
+
"test:services": "bun test --dots --timeout 30000 test/services test/integration",
|
|
743
|
+
"test:cli": "bun test --dots --timeout 30000 test/cli test/ui test/helpers",
|
|
744
|
+
"test:agent": "bun test --dots --timeout 30000 test/agent",
|
|
745
|
+
"test:desktop": "bun test --dots --timeout 30000 test/desktop",
|
|
746
|
+
"test:docs": "bun test --dots --timeout 30000 test/docs",
|
|
747
|
+
lint: "biome lint .",
|
|
748
|
+
"lint:fix": "biome lint --write --unsafe .",
|
|
749
|
+
"lint:css": "bun scripts/check-css-tokens.ts",
|
|
750
|
+
"check:cli-error-contract": "bun scripts/check-cli-error-contract.ts",
|
|
751
|
+
"check:copy": "bun scripts/check-copy.ts",
|
|
752
|
+
"check:agent-plugins-spec": "bun test --timeout 30000 test/services/agent-plugins/spec-schema-guard.test.ts test/services/agent-plugins/spec-mcp.test.ts test/services/agent-plugins/spec-load.test.ts",
|
|
753
|
+
typecheck: "tsc --noEmit",
|
|
754
|
+
clean: "rm -rf dist && find . -maxdepth 1 -name '*.bun-build' -delete",
|
|
755
|
+
preflight: "bun run lint && bun run lint:css && bun run check:cli-error-contract && bun run check:copy && bun run typecheck && bun run test:run && bun run build",
|
|
756
|
+
prepublishOnly: "HT_RELEASE=1 bun run build",
|
|
757
|
+
"check:release-version": "bash scripts/check-release-version.sh",
|
|
758
|
+
"docs:vhs": "bash scripts/generate-vhs-scenarios.sh",
|
|
759
|
+
"check:scenario-docs": "bash scripts/check-scenario-docs.sh",
|
|
760
|
+
"check:scenario-smoke": "bun test --timeout 30000 test/cli/scenario-smoke.test.ts",
|
|
761
|
+
"check:sqlite-wal-smoke": "bun scripts/sqlite-wal-write-smoke.ts",
|
|
762
|
+
"sync:cloud-docs": "bash scripts/sync-cloud-cli-docs.sh"
|
|
763
|
+
},
|
|
764
|
+
keywords: [
|
|
765
|
+
"ai",
|
|
766
|
+
"coding-assistant",
|
|
767
|
+
"cli",
|
|
768
|
+
"configuration",
|
|
769
|
+
"claude-code",
|
|
770
|
+
"cursor",
|
|
771
|
+
"codex",
|
|
772
|
+
"skills",
|
|
773
|
+
"layers"
|
|
774
|
+
],
|
|
775
|
+
license: "Apache-2.0",
|
|
776
|
+
repository: {
|
|
777
|
+
type: "git",
|
|
778
|
+
url: "git+https://github.com/harnesstap/harnesstap.git"
|
|
779
|
+
},
|
|
780
|
+
bugs: {
|
|
781
|
+
url: "https://github.com/harnesstap/harnesstap/issues"
|
|
782
|
+
},
|
|
783
|
+
homepage: "https://github.com/harnesstap/harnesstap#readme",
|
|
784
|
+
engines: {
|
|
785
|
+
node: ">=22.12.0"
|
|
786
|
+
},
|
|
787
|
+
dependencies: {
|
|
788
|
+
"@inquirer/core": "^10.3.2",
|
|
789
|
+
"@inquirer/search": "^3.2.2",
|
|
790
|
+
chalk: "^5.4.1",
|
|
791
|
+
"cli-table3": "^0.6.5",
|
|
792
|
+
commander: "^13.1.0",
|
|
793
|
+
"gray-matter": "^4.0.3",
|
|
794
|
+
inquirer: "^12.3.0",
|
|
795
|
+
"jsonc-parser": "^3.3.1",
|
|
796
|
+
ora: "^9.4.0",
|
|
797
|
+
picomatch: "^4.0.2",
|
|
798
|
+
semver: "^7.8.0",
|
|
799
|
+
"smol-toml": "^1.3.1",
|
|
800
|
+
ulid: "^2.3.0",
|
|
801
|
+
yaml: "^2.7.0"
|
|
802
|
+
},
|
|
803
|
+
optionalDependencies: {
|
|
804
|
+
"better-sqlite3": "^12.11.1"
|
|
805
|
+
},
|
|
806
|
+
devDependencies: {
|
|
807
|
+
"@biomejs/biome": "^2.4.10",
|
|
808
|
+
"@inquirer/testing": "^3.3.8",
|
|
809
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
810
|
+
"@types/node": "^22.10.0",
|
|
811
|
+
"@types/semver": "^7.7.1",
|
|
812
|
+
ajv: "^8.20.0",
|
|
813
|
+
"happy-dom": "17.4.4",
|
|
814
|
+
tsup: "^8.3.5",
|
|
815
|
+
typescript: "^5.7.0"
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
// src/version.ts
|
|
820
|
+
var GIT_SHA = /^[0-9a-f]{7,40}$/i;
|
|
821
|
+
function compactGitSha(sha) {
|
|
822
|
+
const trimmed = sha?.trim().toLowerCase();
|
|
823
|
+
if (!trimmed || !GIT_SHA.test(trimmed)) {
|
|
824
|
+
return void 0;
|
|
825
|
+
}
|
|
826
|
+
return trimmed.slice(0, 7);
|
|
827
|
+
}
|
|
828
|
+
function isReleaseBuild(env = process.env) {
|
|
829
|
+
return env.HT_RELEASE === "1" || env.HARNESSTAP_RELEASE === "1";
|
|
830
|
+
}
|
|
831
|
+
function readGitSha(env = process.env, cwd = process.cwd()) {
|
|
832
|
+
const fromEnv = compactGitSha(env.HT_GIT_SHA ?? env.GITHUB_SHA);
|
|
833
|
+
if (fromEnv) {
|
|
834
|
+
return fromEnv;
|
|
835
|
+
}
|
|
836
|
+
try {
|
|
837
|
+
const sha = execFileSync("git", ["rev-parse", "HEAD"], {
|
|
838
|
+
cwd,
|
|
839
|
+
encoding: "utf8",
|
|
840
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
841
|
+
}).trim();
|
|
842
|
+
return compactGitSha(sha);
|
|
843
|
+
} catch {
|
|
844
|
+
return void 0;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
function formatDevBuildVersion(version, options = {}) {
|
|
848
|
+
const trimmed = version.trim();
|
|
849
|
+
if (options.isRelease) {
|
|
850
|
+
return trimmed;
|
|
851
|
+
}
|
|
852
|
+
if (trimmed.includes("-dev+")) {
|
|
853
|
+
return trimmed;
|
|
854
|
+
}
|
|
855
|
+
const sha = compactGitSha(options.gitSha);
|
|
856
|
+
if (!sha) {
|
|
857
|
+
return `${trimmed}-dev`;
|
|
858
|
+
}
|
|
859
|
+
return `${trimmed}-dev+${sha}`;
|
|
860
|
+
}
|
|
861
|
+
function resolveBuildVersion(env = process.env) {
|
|
862
|
+
return formatDevBuildVersion(package_default.version, {
|
|
863
|
+
isRelease: isReleaseBuild(env),
|
|
864
|
+
gitSha: readGitSha(env)
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
function resolvePackageVersion() {
|
|
868
|
+
if ("1.6.0".length > 0) {
|
|
869
|
+
return "1.6.0";
|
|
870
|
+
}
|
|
871
|
+
return resolveBuildVersion();
|
|
872
|
+
}
|
|
873
|
+
var PACKAGE_VERSION = resolvePackageVersion();
|
|
874
|
+
|
|
875
|
+
// src/services/cli-errors.ts
|
|
876
|
+
var CliUsageError = class extends Error {
|
|
877
|
+
constructor(message, hints = [], exitCode = 1) {
|
|
878
|
+
super(message);
|
|
879
|
+
this.hints = hints;
|
|
880
|
+
this.name = "CliUsageError";
|
|
881
|
+
this.exitCode = exitCode;
|
|
882
|
+
}
|
|
883
|
+
exitCode;
|
|
884
|
+
};
|
|
885
|
+
function missingRequiredArg(name, commandPath) {
|
|
886
|
+
return new CliUsageError(
|
|
887
|
+
`missing required argument '${name}'`,
|
|
888
|
+
[`Run ht ${commandPath} --help to see the options.`]
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
function conflictingOptions(a, b) {
|
|
892
|
+
return new CliUsageError(`error: cannot use ${a} together with ${b}`);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// src/copy/cli.ts
|
|
896
|
+
var DRY_RUN_NOTHING_CHANGED = "Dry run. Nothing was changed.";
|
|
897
|
+
var NATIVE_MODULE_MISMATCH_MESSAGE = "HarnessTap was installed under a different Node.js version. Run: npm rebuild -g harnesstap";
|
|
898
|
+
var SQLITE_MODULE_MISSING_MESSAGE = "HarnessTap could not load its SQLite module (better-sqlite3), which did not install for this Node.js. Reinstall on Node 22.12 or newer: npm install -g harnesstap. Or run it on Bun: bun x --bun harnesstap@latest";
|
|
899
|
+
function quoteCliArg(value) {
|
|
900
|
+
if (value.length === 0) {
|
|
901
|
+
return '""';
|
|
902
|
+
}
|
|
903
|
+
if (/^[A-Za-z0-9_./:@+=-]+$/.test(value)) {
|
|
904
|
+
return value;
|
|
905
|
+
}
|
|
906
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
907
|
+
}
|
|
908
|
+
function formatHtCommand(path) {
|
|
909
|
+
return `ht ${path}`.trim();
|
|
910
|
+
}
|
|
911
|
+
function quoted(name) {
|
|
912
|
+
return `"${name}"`;
|
|
913
|
+
}
|
|
914
|
+
function skippedInvalidPluginExport(name) {
|
|
915
|
+
return `Warning: Skipped plugin ${quoted(name)}. Its version is not valid semver.`;
|
|
916
|
+
}
|
|
917
|
+
function marketplaceUnreachable(source) {
|
|
918
|
+
return `Error: Couldn't reach ${source}.`;
|
|
919
|
+
}
|
|
920
|
+
function marketplaceUnreachableHint() {
|
|
921
|
+
return "Check the URL, or sign in with ht github login if it's private.";
|
|
922
|
+
}
|
|
923
|
+
function marketplacePathMissing(path) {
|
|
924
|
+
return `Error: Couldn't find a marketplace at ${quoted(path)}.`;
|
|
925
|
+
}
|
|
926
|
+
function marketplacePathNotMarketplace(path) {
|
|
927
|
+
return `Error: ${quoted(path)} is not a marketplace. It needs a marketplace.json file.`;
|
|
928
|
+
}
|
|
929
|
+
function marketplaceAddFailedNothingSaved() {
|
|
930
|
+
return "Nothing was saved.";
|
|
931
|
+
}
|
|
932
|
+
function installPinnedPluginsNeedsYes() {
|
|
933
|
+
return "Error: Pass --yes to install pinned plugins without a prompt.";
|
|
934
|
+
}
|
|
935
|
+
function installPinnedPluginsHint(profileName) {
|
|
936
|
+
if (profileName) {
|
|
937
|
+
return `Run ht profile use ${quoted(profileName)} --yes to install them.`;
|
|
938
|
+
}
|
|
939
|
+
return "Run ht profile use --yes to install them.";
|
|
940
|
+
}
|
|
941
|
+
function skippedHostPluginHook(hookName) {
|
|
942
|
+
return `Skipped hook ${hookName}. It only works when the plugin is installed as a host plugin.`;
|
|
943
|
+
}
|
|
944
|
+
function skippedDuplicateCommand(name) {
|
|
945
|
+
return `Skipped command ${quoted(name)}. A skill already uses that name.`;
|
|
946
|
+
}
|
|
947
|
+
function quoteName(name) {
|
|
948
|
+
return `"${name.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
949
|
+
}
|
|
950
|
+
function hintToken(value) {
|
|
951
|
+
if (/^[A-Za-z0-9_./:@+=,-]+$/.test(value)) {
|
|
952
|
+
return value;
|
|
953
|
+
}
|
|
954
|
+
return quoteName(value);
|
|
955
|
+
}
|
|
956
|
+
function formatHtArgs(args) {
|
|
957
|
+
return ["ht", ...args.map(hintToken)].join(" ");
|
|
958
|
+
}
|
|
959
|
+
function plainTerminalText(value) {
|
|
960
|
+
return value.replace(
|
|
961
|
+
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
962
|
+
(_match, label, target) => {
|
|
963
|
+
if (target.startsWith("http://") || target.startsWith("https://")) {
|
|
964
|
+
return `${label} (${target})`;
|
|
965
|
+
}
|
|
966
|
+
return label;
|
|
967
|
+
}
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
function ensureErrorPrefix(message) {
|
|
971
|
+
const stripped = message.replace(/^error:\s*/i, "").trim();
|
|
972
|
+
if (stripped.length === 0) {
|
|
973
|
+
return "Error: Something went wrong.";
|
|
974
|
+
}
|
|
975
|
+
const sentence = /[.!?]$/.test(stripped) ? stripped : `${stripped}.`;
|
|
976
|
+
return `Error: ${sentence}`;
|
|
977
|
+
}
|
|
978
|
+
var CLI_HINTS = {
|
|
979
|
+
seeOptions: (commandPath) => commandPath.trim().length > 0 ? `Run ht ${commandPath.trim()} --help to see the options.` : "Run ht --help to see the options.",
|
|
980
|
+
pluginList: "Run ht plugin list to see your plugins.",
|
|
981
|
+
resourceList: "Run ht resource list to see your resources.",
|
|
982
|
+
profileUseExample: 'For example: ht profile use "global default"',
|
|
983
|
+
authLogin: "Run ht auth login to sign in.",
|
|
984
|
+
githubLogin: marketplaceUnreachableHint(),
|
|
985
|
+
onConflictReplace: "Use --on-conflict replace to replace it.",
|
|
986
|
+
unsavedChanges: "Run again with --changes save, stash or discard.",
|
|
987
|
+
updateNpm: "Update with: npm i -g harnesstap",
|
|
988
|
+
mcpSearch: (name) => `Run ht mcp search ${hintToken(name)} to find it.`,
|
|
989
|
+
scopeAdd: (name, harnesses) => `Run ht resource scope ${hintToken(name)} --add ${hintToken(harnesses)}.`,
|
|
990
|
+
portableMcpTip: (name, harnessList, command) => `Tip: ${quoteName(name)} also works on ${harnessList}. Run ${command}.`,
|
|
991
|
+
forceRemove: "To remove them too, run the command again with --force-remove.",
|
|
992
|
+
forceRemoveAlreadyUsed: "HarnessTap never removes these, even with --force-remove.",
|
|
993
|
+
revert: "Snapshot saved. Undo with: ht revert",
|
|
994
|
+
stashPop: "Bring them back with: ht profile stash pop",
|
|
995
|
+
harnessSet: "Run ht harness set to pick your harnesses.",
|
|
996
|
+
harnessSetOrFlag: "Run ht harness set, or pass --harness <slugs>."
|
|
997
|
+
};
|
|
998
|
+
var CLI_ERRORS = {
|
|
999
|
+
pluginNotFound: (name) => `No plugin named ${quoteName(name)}.`,
|
|
1000
|
+
resourceNotFound: (name) => `No resource named ${quoteName(name)}.`,
|
|
1001
|
+
invalidResourceType: (value, valid) => `${quoteName(value)} isn't a resource type. Valid: ${valid.join(", ")}.`,
|
|
1002
|
+
conflictingResourceTypes: (a, b) => `Conflicting type filters: ${quoteName(a)} and ${quoteName(b)}.`,
|
|
1003
|
+
pluginAlreadyExists: (name) => `A plugin named ${quoteName(name)} already exists.`,
|
|
1004
|
+
environmentAlreadyExists: (name) => `An environment named ${quoteName(name)} already exists.`,
|
|
1005
|
+
notAuthenticated: "Not authenticated to HarnessTap Cloud.",
|
|
1006
|
+
directoryNotFound: (path) => `Directory not found: ${path}.`,
|
|
1007
|
+
fileNotFound: (path) => `File not found: ${path}.`,
|
|
1008
|
+
gitUnreachable: (url) => `Couldn't reach ${url}.`,
|
|
1009
|
+
gitUnreachableGeneric: "Couldn't reach that git repository.",
|
|
1010
|
+
uniqueConstraintGeneric: "That name already exists.",
|
|
1011
|
+
missingProfileName: "Pass a profile name.",
|
|
1012
|
+
noProfileNamed: (name) => `No profile named ${quoteName(name)}.`,
|
|
1013
|
+
invalidPluginName: (name) => `${quoteName(name)} isn't a valid plugin name. Use a non-empty name without /, \\, .. or control characters.`,
|
|
1014
|
+
emptyPluginName: "Pass a plugin name.",
|
|
1015
|
+
invalidFormat: (value) => `Invalid --format value: ${value}. Use human or json.`,
|
|
1016
|
+
mcpNotInLibrary: (name) => `${quoteName(name)} isn't in your library.`,
|
|
1017
|
+
newerSchema: "This data was saved by a newer HarnessTap.",
|
|
1018
|
+
noHarnesses: "Not set up for any harness yet.",
|
|
1019
|
+
unsavedChanges: (name, count) => `${quoteName(name)} has ${count} unsaved change${count === 1 ? "" : "s"}.`,
|
|
1020
|
+
resourceSyncFailed: (refs) => `Could not install ${[...new Set(refs)].join(", ")}.`,
|
|
1021
|
+
resourceSyncStale: (count) => `${count} linked resource${count === 1 ? "" : "s"} ${count === 1 ? "is" : "are"} stale.`
|
|
1022
|
+
};
|
|
1023
|
+
var SWITCH_CHANGES_VALUES = ["save", "stash", "discard"];
|
|
1024
|
+
var SWITCH_CHANGES_FLAG_HELP = "What to do with unsaved changes: save, stash or discard";
|
|
1025
|
+
var DEVICE_LOGIN_WAITING = "Waiting for you to approve in the browser. The code expires in 15 minutes. Press Ctrl+C to cancel.";
|
|
1026
|
+
function initPickHarnessesLine() {
|
|
1027
|
+
return `Pick your harnesses: ${formatHtCommand("harness set")}`;
|
|
1028
|
+
}
|
|
1029
|
+
function initCompletionHintLine(shell) {
|
|
1030
|
+
switch (shell) {
|
|
1031
|
+
case "bash":
|
|
1032
|
+
return `Enable tab completion: ${formatHtCommand("init completion bash >> ~/.bashrc")}`;
|
|
1033
|
+
case "zsh":
|
|
1034
|
+
return `Enable tab completion: ${formatHtCommand("init completion zsh >> ~/.zshrc")}`;
|
|
1035
|
+
case "fish":
|
|
1036
|
+
return `Enable tab completion: ${formatHtCommand("init completion fish > ~/.config/fish/completions/ht.fish")}`;
|
|
1037
|
+
default:
|
|
1038
|
+
return `Enable tab completion: ${formatHtCommand("init completion <bash|zsh|fish>")}`;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
var CLI_COPY = {
|
|
1042
|
+
dryRunNothingChanged: DRY_RUN_NOTHING_CHANGED,
|
|
1043
|
+
everythingUpToDate: "Everything is up to date.",
|
|
1044
|
+
snapshotSavedUndo: "Snapshot saved. Undo with:",
|
|
1045
|
+
keptYouChanged: "you changed it",
|
|
1046
|
+
keptClaudeChanged: "Claude Code changed it",
|
|
1047
|
+
keptNotMade: "not made by HarnessTap",
|
|
1048
|
+
viewSnapshot: "View snapshot",
|
|
1049
|
+
keptFilesIntro: "you changed or that HarnessTap didn't create:"
|
|
1050
|
+
};
|
|
1051
|
+
function onConflictReplaceHint(conflicts) {
|
|
1052
|
+
const count = new Set(
|
|
1053
|
+
conflicts.map((path) => path.trim()).filter((path) => path.length > 0)
|
|
1054
|
+
).size;
|
|
1055
|
+
if (count > 1) {
|
|
1056
|
+
return "Use --on-conflict replace to replace them.";
|
|
1057
|
+
}
|
|
1058
|
+
return CLI_HINTS.onConflictReplace;
|
|
1059
|
+
}
|
|
1060
|
+
function applyCancelledMessage(conflicts, scope = "apply") {
|
|
1061
|
+
const paths = [
|
|
1062
|
+
...new Set(
|
|
1063
|
+
conflicts.map((path) => path.trim()).filter((path) => path.length > 0)
|
|
1064
|
+
)
|
|
1065
|
+
];
|
|
1066
|
+
const lead = scope === "profile" ? "Profile apply cancelled." : "Apply cancelled.";
|
|
1067
|
+
if (paths.length === 0) {
|
|
1068
|
+
return lead;
|
|
1069
|
+
}
|
|
1070
|
+
const listed = paths.map((path) => quoteCliArg(path)).join(", ");
|
|
1071
|
+
if (paths.length === 1) {
|
|
1072
|
+
return `${lead} ${listed} would change.`;
|
|
1073
|
+
}
|
|
1074
|
+
return `${lead} These files would change: ${listed}.`;
|
|
1075
|
+
}
|
|
1076
|
+
function unsavedChangesLine(profileName, count) {
|
|
1077
|
+
return CLI_ERRORS.unsavedChanges(profileName, count);
|
|
1078
|
+
}
|
|
1079
|
+
function unsavedChangesFlagHint() {
|
|
1080
|
+
return CLI_HINTS.unsavedChanges;
|
|
1081
|
+
}
|
|
1082
|
+
function savedChangesLine(profileName, count) {
|
|
1083
|
+
return `Saved ${count} ${pluralNoun(count, "change")} to ${quoteName(profileName)}.`;
|
|
1084
|
+
}
|
|
1085
|
+
function stashedChangesLine(count, popCommand) {
|
|
1086
|
+
return `Stashed ${count} ${pluralNoun(count, "change")}. Bring ${count === 1 ? "it" : "them"} back with: ${popCommand}`;
|
|
1087
|
+
}
|
|
1088
|
+
function discardedChangesLine(count) {
|
|
1089
|
+
return `Discarded ${count} ${pluralNoun(count, "change")}.`;
|
|
1090
|
+
}
|
|
1091
|
+
function discardConfirm(count) {
|
|
1092
|
+
return `Discard ${count} ${pluralNoun(count, "change")}? A snapshot keeps a copy.`;
|
|
1093
|
+
}
|
|
1094
|
+
function applyWroteLine(input) {
|
|
1095
|
+
if (input.wrote === 0 && input.removed === 0 && input.kept === 0) {
|
|
1096
|
+
return input.unchanged !== void 0 ? `${CLI_COPY.everythingUpToDate} ${input.unchanged} unchanged.` : CLI_COPY.everythingUpToDate;
|
|
1097
|
+
}
|
|
1098
|
+
if (input.wrote === 0 && input.removed === 0) {
|
|
1099
|
+
const line2 = `Wrote 0, removed 0, kept ${input.kept}`;
|
|
1100
|
+
if (!input.omitUnchanged && input.unchanged !== void 0 && input.unchanged > 0) {
|
|
1101
|
+
return `${line2}, unchanged ${input.unchanged}.`;
|
|
1102
|
+
}
|
|
1103
|
+
return `${line2}.`;
|
|
1104
|
+
}
|
|
1105
|
+
const parts = [];
|
|
1106
|
+
if (input.wrote > 0) parts.push(`Wrote ${input.wrote}`);
|
|
1107
|
+
if (input.removed > 0) parts.push(`removed ${input.removed}`);
|
|
1108
|
+
if (input.kept > 0) parts.push(`kept ${input.kept}`);
|
|
1109
|
+
if (parts.length === 0) {
|
|
1110
|
+
return input.unchanged !== void 0 ? `${CLI_COPY.everythingUpToDate} ${input.unchanged} unchanged.` : CLI_COPY.everythingUpToDate;
|
|
1111
|
+
}
|
|
1112
|
+
if (!input.omitUnchanged && input.unchanged !== void 0 && input.unchanged > 0) {
|
|
1113
|
+
parts.push(`unchanged ${input.unchanged}`);
|
|
1114
|
+
}
|
|
1115
|
+
const [first, ...rest] = parts;
|
|
1116
|
+
const head = first ? `${first.charAt(0).toUpperCase()}${first.slice(1)}` : "";
|
|
1117
|
+
if (rest.length === 0) {
|
|
1118
|
+
return `${head}.`;
|
|
1119
|
+
}
|
|
1120
|
+
return `${head}, ${rest.join(", ")}.`;
|
|
1121
|
+
}
|
|
1122
|
+
function applyHeaderLine(profileName, harnessCount) {
|
|
1123
|
+
const noun = harnessCount === 1 ? "harness" : "harnesses";
|
|
1124
|
+
return `Applied "${profileName}" to ${harnessCount} ${noun}.`;
|
|
1125
|
+
}
|
|
1126
|
+
function dryRunWouldLine(input) {
|
|
1127
|
+
return `Would write ${input.write}, remove ${input.remove}, keep ${input.keep}. ${input.unchanged} unchanged.`;
|
|
1128
|
+
}
|
|
1129
|
+
function dryRunStashLine(count, profileName) {
|
|
1130
|
+
return `Dry run. Would stash ${count} ${pluralNoun(count, "change")} from "${profileName}".`;
|
|
1131
|
+
}
|
|
1132
|
+
function snapshotSavedUndoLine(revertCommand) {
|
|
1133
|
+
return `${CLI_COPY.snapshotSavedUndo} ${revertCommand}`;
|
|
1134
|
+
}
|
|
1135
|
+
function keptFilesHeader(count) {
|
|
1136
|
+
return `Kept ${count} ${pluralNoun(count, "file")} ${CLI_COPY.keptFilesIntro}`;
|
|
1137
|
+
}
|
|
1138
|
+
function keptReportedBeforeLine(count) {
|
|
1139
|
+
return `${count} more kept ${pluralNoun(count, "file")} in a plugin folder ${count === 1 ? "was" : "were"} listed by an earlier apply. \`ht profile status\` lists every kept file.`;
|
|
1140
|
+
}
|
|
1141
|
+
function keptLinkOutsideRoot(path) {
|
|
1142
|
+
return `Kept ${path}: it is your link to a file outside your home, and HarnessTap never writes through it.`;
|
|
1143
|
+
}
|
|
1144
|
+
function skippedRemovalOutsideRoot(path) {
|
|
1145
|
+
return `Skipped removing ${path} (a folder above it links outside your home).`;
|
|
1146
|
+
}
|
|
1147
|
+
function forceRemoveHintLine(count) {
|
|
1148
|
+
return `To remove ${count === 1 ? "it" : "them"} too, run the command again with --force-remove.`;
|
|
1149
|
+
}
|
|
1150
|
+
function restoredRemovedLine(restored, removed, options = {}) {
|
|
1151
|
+
if (options.dryRun) {
|
|
1152
|
+
return `Would restore ${restored}, would remove ${removed}.`;
|
|
1153
|
+
}
|
|
1154
|
+
return `Restored ${restored}, removed ${removed}.`;
|
|
1155
|
+
}
|
|
1156
|
+
function dryRunSectionHeader(kind, count) {
|
|
1157
|
+
switch (kind) {
|
|
1158
|
+
case "write":
|
|
1159
|
+
return `Would write (${count})`;
|
|
1160
|
+
case "remove":
|
|
1161
|
+
return `Would remove (${count})`;
|
|
1162
|
+
case "keep":
|
|
1163
|
+
return `Would keep (${count})`;
|
|
1164
|
+
default: {
|
|
1165
|
+
const _exhaustive = kind;
|
|
1166
|
+
return _exhaustive;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
function isClaudePluginStorePath(path) {
|
|
1171
|
+
return path.replaceAll("\\", "/").startsWith(".claude/plugins/");
|
|
1172
|
+
}
|
|
1173
|
+
function keptReasonLabel(reason, path) {
|
|
1174
|
+
switch (reason) {
|
|
1175
|
+
case "modified":
|
|
1176
|
+
return path && isClaudePluginStorePath(path) ? CLI_COPY.keptClaudeChanged : CLI_COPY.keptYouChanged;
|
|
1177
|
+
case "unmanaged":
|
|
1178
|
+
return CLI_COPY.keptNotMade;
|
|
1179
|
+
default: {
|
|
1180
|
+
const _exhaustive = reason;
|
|
1181
|
+
return _exhaustive;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// src/db/native-module.ts
|
|
1187
|
+
function shouldShowNativeModuleDetails() {
|
|
1188
|
+
if (process.env.HARNESSTAP_DEBUG === "1") {
|
|
1189
|
+
return true;
|
|
1190
|
+
}
|
|
1191
|
+
return process.argv.includes("-v") || process.argv.includes("--verbose");
|
|
1192
|
+
}
|
|
1193
|
+
function isNativeModuleMismatch(error) {
|
|
1194
|
+
if (!error || typeof error !== "object") {
|
|
1195
|
+
return false;
|
|
1196
|
+
}
|
|
1197
|
+
const err = error;
|
|
1198
|
+
const code = typeof err.code === "string" ? err.code : "";
|
|
1199
|
+
const message = typeof err.message === "string" ? err.message : String(error);
|
|
1200
|
+
if (code === "ERR_DLOPEN_FAILED") {
|
|
1201
|
+
return true;
|
|
1202
|
+
}
|
|
1203
|
+
return message.includes("NODE_MODULE_VERSION") || message.includes("ERR_DLOPEN");
|
|
1204
|
+
}
|
|
1205
|
+
function reportNativeModuleMismatch(cause) {
|
|
1206
|
+
if (shouldShowNativeModuleDetails() && cause !== void 0) {
|
|
1207
|
+
console.error(cause);
|
|
1208
|
+
}
|
|
1209
|
+
console.error(NATIVE_MODULE_MISMATCH_MESSAGE);
|
|
1210
|
+
process.exit(1);
|
|
1211
|
+
}
|
|
1212
|
+
function isSqliteModuleMissing(error) {
|
|
1213
|
+
if (!error || typeof error !== "object") {
|
|
1214
|
+
return false;
|
|
1215
|
+
}
|
|
1216
|
+
const err = error;
|
|
1217
|
+
const message = typeof err.message === "string" ? err.message : "";
|
|
1218
|
+
if (!message.includes("better-sqlite3") && !message.includes("better_sqlite3")) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
return err.code === "MODULE_NOT_FOUND" || err.code === "ERR_MODULE_NOT_FOUND" || message.includes("Could not locate the bindings file") || message.includes("Cannot find module");
|
|
1222
|
+
}
|
|
1223
|
+
function reportSqliteModuleMissing(cause) {
|
|
1224
|
+
if (shouldShowNativeModuleDetails() && cause !== void 0) {
|
|
1225
|
+
console.error(cause);
|
|
1226
|
+
}
|
|
1227
|
+
console.error(SQLITE_MODULE_MISSING_MESSAGE);
|
|
1228
|
+
process.exit(1);
|
|
1229
|
+
}
|
|
1230
|
+
function withNativeModuleGuard(load) {
|
|
1231
|
+
try {
|
|
1232
|
+
return load();
|
|
1233
|
+
} catch (error) {
|
|
1234
|
+
if (isNativeModuleMismatch(error)) {
|
|
1235
|
+
reportNativeModuleMismatch(error);
|
|
1236
|
+
}
|
|
1237
|
+
if (isSqliteModuleMissing(error)) {
|
|
1238
|
+
reportSqliteModuleMissing(error);
|
|
1239
|
+
}
|
|
1240
|
+
throw error;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// src/db/connection.ts
|
|
1245
|
+
import { existsSync, mkdirSync } from "fs";
|
|
1246
|
+
import { createRequire } from "module";
|
|
1247
|
+
import { join } from "path";
|
|
1248
|
+
import { homedir } from "os";
|
|
1249
|
+
|
|
1250
|
+
// src/services/status-trace.ts
|
|
1251
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
1252
|
+
var statusTraceEnabled = process.env.HARNESSTAP_STATUS_CACHE_DEBUG === "1";
|
|
1253
|
+
var TOP_ITEMS = 6;
|
|
1254
|
+
var storage = new AsyncLocalStorage();
|
|
1255
|
+
function stats(trace, phase) {
|
|
1256
|
+
let entry = trace.phases.get(phase);
|
|
1257
|
+
if (!entry) {
|
|
1258
|
+
entry = {
|
|
1259
|
+
ms: 0,
|
|
1260
|
+
childMs: 0,
|
|
1261
|
+
calls: 0,
|
|
1262
|
+
dirs: 0,
|
|
1263
|
+
stats: 0,
|
|
1264
|
+
reads: 0,
|
|
1265
|
+
readBytes: 0,
|
|
1266
|
+
dbQueries: 0,
|
|
1267
|
+
dbMs: 0,
|
|
1268
|
+
top: [],
|
|
1269
|
+
counts: /* @__PURE__ */ new Map()
|
|
1270
|
+
};
|
|
1271
|
+
trace.phases.set(phase, entry);
|
|
1272
|
+
}
|
|
1273
|
+
return entry;
|
|
1274
|
+
}
|
|
1275
|
+
function innermost(trace) {
|
|
1276
|
+
const frame = trace.stack[trace.stack.length - 1];
|
|
1277
|
+
return stats(trace, frame ? frame.phase : "(other)");
|
|
1278
|
+
}
|
|
1279
|
+
function noteTop(entry, item, ms) {
|
|
1280
|
+
const top = entry.top;
|
|
1281
|
+
const existing = top.find((row) => row.item === item);
|
|
1282
|
+
if (existing) {
|
|
1283
|
+
existing.ms += ms;
|
|
1284
|
+
} else if (top.length < TOP_ITEMS) {
|
|
1285
|
+
top.push({ item, ms });
|
|
1286
|
+
} else if (ms > top[top.length - 1].ms) {
|
|
1287
|
+
top[top.length - 1] = { item, ms };
|
|
1288
|
+
} else {
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
top.sort((left, right) => right.ms - left.ms);
|
|
1292
|
+
}
|
|
1293
|
+
function finishFrame(trace, frame, item) {
|
|
1294
|
+
const elapsed = performance.now() - frame.started;
|
|
1295
|
+
const index = trace.stack.lastIndexOf(frame);
|
|
1296
|
+
if (index >= 0) trace.stack.splice(index, 1);
|
|
1297
|
+
const entry = stats(trace, frame.phase);
|
|
1298
|
+
entry.ms += elapsed;
|
|
1299
|
+
entry.childMs += frame.childMs;
|
|
1300
|
+
entry.calls += 1;
|
|
1301
|
+
if (item !== void 0) noteTop(entry, item, elapsed);
|
|
1302
|
+
const parent = trace.stack[index - 1];
|
|
1303
|
+
if (parent) parent.childMs += elapsed;
|
|
1304
|
+
}
|
|
1305
|
+
function traceSpan(phase, fn, item) {
|
|
1306
|
+
if (!statusTraceEnabled) return fn();
|
|
1307
|
+
const trace = storage.getStore();
|
|
1308
|
+
if (!trace) return fn();
|
|
1309
|
+
const frame = { phase, started: performance.now(), childMs: 0 };
|
|
1310
|
+
trace.stack.push(frame);
|
|
1311
|
+
let result;
|
|
1312
|
+
try {
|
|
1313
|
+
result = fn();
|
|
1314
|
+
} catch (error) {
|
|
1315
|
+
finishFrame(trace, frame, item);
|
|
1316
|
+
throw error;
|
|
1317
|
+
}
|
|
1318
|
+
if (result && typeof result.then === "function") {
|
|
1319
|
+
return result.finally(() => finishFrame(trace, frame, item));
|
|
1320
|
+
}
|
|
1321
|
+
finishFrame(trace, frame, item);
|
|
1322
|
+
return result;
|
|
1323
|
+
}
|
|
1324
|
+
function traceCount(phase, counter, n = 1) {
|
|
1325
|
+
if (!statusTraceEnabled) return;
|
|
1326
|
+
const trace = storage.getStore();
|
|
1327
|
+
if (!trace) return;
|
|
1328
|
+
const entry = stats(trace, phase);
|
|
1329
|
+
entry.counts.set(counter, (entry.counts.get(counter) ?? 0) + n);
|
|
1330
|
+
}
|
|
1331
|
+
function traceRecord(label, fields) {
|
|
1332
|
+
if (!statusTraceEnabled) return;
|
|
1333
|
+
const parts = Object.entries(fields).map(
|
|
1334
|
+
([key, value]) => `${key}=${typeof value === "number" ? value.toFixed(1) : value}`
|
|
1335
|
+
);
|
|
1336
|
+
console.error(`[status-trace] ${label} ${parts.join(" ")}`);
|
|
1337
|
+
}
|
|
1338
|
+
function traceDb(sql, ms) {
|
|
1339
|
+
const trace = storage.getStore();
|
|
1340
|
+
if (!trace) return;
|
|
1341
|
+
const entry = innermost(trace);
|
|
1342
|
+
entry.dbQueries += 1;
|
|
1343
|
+
entry.dbMs += ms;
|
|
1344
|
+
const key = sql.replace(/\s+/g, " ").trim().slice(0, 60);
|
|
1345
|
+
const row = trace.slowSql.get(key) ?? { n: 0, ms: 0 };
|
|
1346
|
+
row.n += 1;
|
|
1347
|
+
row.ms += ms;
|
|
1348
|
+
trace.slowSql.set(key, row);
|
|
1349
|
+
}
|
|
1350
|
+
function traceFs(kind, bytes = 0) {
|
|
1351
|
+
if (!statusTraceEnabled) return;
|
|
1352
|
+
const trace = storage.getStore();
|
|
1353
|
+
if (!trace) return;
|
|
1354
|
+
const entry = innermost(trace);
|
|
1355
|
+
if (kind === "dir") entry.dirs += 1;
|
|
1356
|
+
else if (kind === "stat") entry.stats += 1;
|
|
1357
|
+
else {
|
|
1358
|
+
entry.reads += 1;
|
|
1359
|
+
entry.readBytes += bytes;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
// src/db/write-generation.ts
|
|
1364
|
+
var statusWriteGeneration = 0;
|
|
1365
|
+
var WRITE_STATEMENT = /^\s*(?:WITH\b[\s\S]*?\b)?(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)\b/i;
|
|
1366
|
+
var STATUS_IRRELEVANT_WRITE = /^\s*(?:INSERT\s+INTO\s+resources\b|(?:INSERT\s+(?:OR\s+\w+\s+)?INTO|UPDATE|DELETE\s+FROM)\s+(?:upstream_checks|notifications)\b)/i;
|
|
1367
|
+
function statementAffectsStatus(sql) {
|
|
1368
|
+
if (!WRITE_STATEMENT.test(sql)) return false;
|
|
1369
|
+
return !STATUS_IRRELEVANT_WRITE.test(sql);
|
|
1370
|
+
}
|
|
1371
|
+
function scriptAffectsStatus(sql) {
|
|
1372
|
+
return sql.split(";").some((part) => part.trim().length > 0 && !/^\s*PRAGMA\b/i.test(part) && statementAffectsStatus(part));
|
|
1373
|
+
}
|
|
1374
|
+
function readStatusWriteGeneration() {
|
|
1375
|
+
return statusWriteGeneration;
|
|
1376
|
+
}
|
|
1377
|
+
function trackStatusWrites(db) {
|
|
1378
|
+
const statements = /* @__PURE__ */ new Map();
|
|
1379
|
+
const prepareTracked = (sql) => {
|
|
1380
|
+
const statement = statusTraceEnabled ? timedStatement(sql, db.prepare(sql)) : db.prepare(sql);
|
|
1381
|
+
if (!statementAffectsStatus(sql)) return statement;
|
|
1382
|
+
return {
|
|
1383
|
+
run: (...params) => {
|
|
1384
|
+
const result = statement.run(...params);
|
|
1385
|
+
if (result.changes > 0) statusWriteGeneration += 1;
|
|
1386
|
+
return result;
|
|
1387
|
+
},
|
|
1388
|
+
get: (...params) => statement.get(...params),
|
|
1389
|
+
all: (...params) => statement.all(...params)
|
|
1390
|
+
};
|
|
1391
|
+
};
|
|
1392
|
+
return {
|
|
1393
|
+
prepare(sql) {
|
|
1394
|
+
const cached = statements.get(sql);
|
|
1395
|
+
if (cached) return cached;
|
|
1396
|
+
const statement = prepareTracked(sql);
|
|
1397
|
+
if (statements.size >= 512) statements.clear();
|
|
1398
|
+
statements.set(sql, statement);
|
|
1399
|
+
return statement;
|
|
1400
|
+
},
|
|
1401
|
+
exec: (sql) => {
|
|
1402
|
+
if (/\b(CREATE|DROP|ALTER)\b/i.test(sql)) statements.clear();
|
|
1403
|
+
db.exec(sql);
|
|
1404
|
+
if (scriptAffectsStatus(sql)) statusWriteGeneration += 1;
|
|
1405
|
+
},
|
|
1406
|
+
transaction: (fn) => db.transaction(fn),
|
|
1407
|
+
close: () => {
|
|
1408
|
+
statements.clear();
|
|
1409
|
+
db.close();
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
function timedStatement(sql, statement) {
|
|
1414
|
+
const timed = (fn) => {
|
|
1415
|
+
const started = performance.now();
|
|
1416
|
+
try {
|
|
1417
|
+
return fn();
|
|
1418
|
+
} finally {
|
|
1419
|
+
traceDb(sql, performance.now() - started);
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
return {
|
|
1423
|
+
run: (...params) => timed(() => statement.run(...params)),
|
|
1424
|
+
get: (...params) => timed(() => statement.get(...params)),
|
|
1425
|
+
all: (...params) => timed(() => statement.all(...params))
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// src/db/connection.ts
|
|
1430
|
+
var require2 = createRequire(import.meta.url);
|
|
1431
|
+
var instance = null;
|
|
1432
|
+
var instancePath = null;
|
|
1433
|
+
function loadBetterSqlite3() {
|
|
1434
|
+
return withNativeModuleGuard(
|
|
1435
|
+
() => require2("better-sqlite3")
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
function resolveDatabaseConstructor() {
|
|
1439
|
+
if ("Bun" in globalThis) {
|
|
1440
|
+
return require2("bun:sqlite").Database;
|
|
1441
|
+
}
|
|
1442
|
+
return loadBetterSqlite3();
|
|
1443
|
+
}
|
|
1444
|
+
function usesBunSqlite() {
|
|
1445
|
+
return "Bun" in globalThis;
|
|
1446
|
+
}
|
|
1447
|
+
function wrapDatabase(db) {
|
|
1448
|
+
return {
|
|
1449
|
+
prepare(sql) {
|
|
1450
|
+
const statement = db.prepare(sql);
|
|
1451
|
+
return {
|
|
1452
|
+
run: (...params) => statement.run(...params),
|
|
1453
|
+
get: (...params) => {
|
|
1454
|
+
const row = statement.get(...params);
|
|
1455
|
+
return row ?? void 0;
|
|
1456
|
+
},
|
|
1457
|
+
all: (...params) => statement.all(...params)
|
|
1458
|
+
};
|
|
1459
|
+
},
|
|
1460
|
+
exec: (sql) => db.exec(sql),
|
|
1461
|
+
transaction: (fn) => db.transaction(fn),
|
|
1462
|
+
close: () => db.close()
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
function resolveHarnesstapDir() {
|
|
1466
|
+
if (process.env.HARNESSTAP_HOME) {
|
|
1467
|
+
return process.env.HARNESSTAP_HOME;
|
|
1468
|
+
}
|
|
1469
|
+
const homePath = process.env.HOME ?? process.env.USERPROFILE ?? homedir();
|
|
1470
|
+
return join(homePath, ".harnesstap");
|
|
1471
|
+
}
|
|
1472
|
+
function harnesstapDirForHomeRoot(homeRoot) {
|
|
1473
|
+
if (process.env.HARNESSTAP_HOME) {
|
|
1474
|
+
return process.env.HARNESSTAP_HOME;
|
|
1475
|
+
}
|
|
1476
|
+
return join(homeRoot, ".harnesstap");
|
|
1477
|
+
}
|
|
1478
|
+
function resolveDbPath() {
|
|
1479
|
+
return join(resolveHarnesstapDir(), "harnesstap.db");
|
|
1480
|
+
}
|
|
1481
|
+
function getDbPath() {
|
|
1482
|
+
return resolveDbPath();
|
|
1483
|
+
}
|
|
1484
|
+
function getHarnesstapDir() {
|
|
1485
|
+
return resolveHarnesstapDir();
|
|
1486
|
+
}
|
|
1487
|
+
function isCompletionMode() {
|
|
1488
|
+
return process.env.HARNESSTAP_COMPLETE === "1";
|
|
1489
|
+
}
|
|
1490
|
+
function getDb() {
|
|
1491
|
+
const dbPath = resolveDbPath();
|
|
1492
|
+
const completionMode = isCompletionMode();
|
|
1493
|
+
if (instance && instancePath === dbPath) {
|
|
1494
|
+
return instance;
|
|
1495
|
+
}
|
|
1496
|
+
if (instance) {
|
|
1497
|
+
instance.close();
|
|
1498
|
+
instance = null;
|
|
1499
|
+
instancePath = null;
|
|
1500
|
+
}
|
|
1501
|
+
if (completionMode) {
|
|
1502
|
+
if (!existsSync(dbPath)) {
|
|
1503
|
+
throw new Error(`HarnessTap database not found: ${dbPath}`);
|
|
1504
|
+
}
|
|
1505
|
+
} else {
|
|
1506
|
+
mkdirSync(resolveHarnesstapDir(), { recursive: true });
|
|
1507
|
+
}
|
|
1508
|
+
const Database = resolveDatabaseConstructor();
|
|
1509
|
+
const rawDb = withNativeModuleGuard(
|
|
1510
|
+
() => completionMode ? new Database(dbPath, { readonly: true }) : new Database(dbPath)
|
|
1511
|
+
);
|
|
1512
|
+
instance = trackStatusWrites(usesBunSqlite() ? wrapDatabase(rawDb) : rawDb);
|
|
1513
|
+
instancePath = dbPath;
|
|
1514
|
+
if (!completionMode) {
|
|
1515
|
+
instance.exec("PRAGMA journal_mode = WAL");
|
|
1516
|
+
instance.exec("PRAGMA busy_timeout = 5000");
|
|
1517
|
+
}
|
|
1518
|
+
instance.exec("PRAGMA foreign_keys = ON");
|
|
1519
|
+
return instance;
|
|
1520
|
+
}
|
|
1521
|
+
function readDbDataVersion() {
|
|
1522
|
+
try {
|
|
1523
|
+
const row = getDb().prepare("PRAGMA data_version").get();
|
|
1524
|
+
return row?.data_version ?? 0;
|
|
1525
|
+
} catch {
|
|
1526
|
+
return -1;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
function closeDb() {
|
|
1530
|
+
if (instance) {
|
|
1531
|
+
instance.close();
|
|
1532
|
+
instance = null;
|
|
1533
|
+
instancePath = null;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
// src/utils/fetch-with-timeout.ts
|
|
1538
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
1539
|
+
var DEFAULT_RETRIES = 2;
|
|
1540
|
+
var CATALOG_LIST_TIMEOUT_MESSAGE = "Catalog request timed out (30s). Try again, or list local plugins without --remote.";
|
|
1541
|
+
async function fetchWithTimeout(input, init) {
|
|
1542
|
+
const timeoutMs = init?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
1543
|
+
const retries = init?.retries ?? DEFAULT_RETRIES;
|
|
1544
|
+
let lastError;
|
|
1545
|
+
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
1546
|
+
const controller = new AbortController();
|
|
1547
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
1548
|
+
try {
|
|
1549
|
+
const { timeoutMs: _t, retries: _r, ...fetchInit } = init ?? {};
|
|
1550
|
+
return await fetch(input, { ...fetchInit, signal: controller.signal });
|
|
1551
|
+
} catch (error) {
|
|
1552
|
+
lastError = error;
|
|
1553
|
+
if (attempt === retries) break;
|
|
1554
|
+
await new Promise((r) => setTimeout(r, 250 * (attempt + 1)));
|
|
1555
|
+
} finally {
|
|
1556
|
+
clearTimeout(timer);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
throw new Error(
|
|
1560
|
+
`Request timed out after ${timeoutMs}ms (${retries + 1} attempts): ${String(input)}`,
|
|
1561
|
+
{ cause: lastError }
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
function isRequestTimeoutError(error) {
|
|
1565
|
+
return error instanceof Error && error.message.startsWith("Request timed out after");
|
|
1566
|
+
}
|
|
1567
|
+
function formatCatalogRequestError(error) {
|
|
1568
|
+
if (isRequestTimeoutError(error)) {
|
|
1569
|
+
return CATALOG_LIST_TIMEOUT_MESSAGE;
|
|
1570
|
+
}
|
|
1571
|
+
return error instanceof Error ? error.message : String(error);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// src/utils/git-errors.ts
|
|
1575
|
+
var COMMAND_TIMED_OUT = /^Command timed out after (\d+)ms/;
|
|
1576
|
+
function isCommandTimeoutStderr(stderr) {
|
|
1577
|
+
return COMMAND_TIMED_OUT.test(stderr);
|
|
1578
|
+
}
|
|
1579
|
+
function mapGitStderr(stderr, url) {
|
|
1580
|
+
const timedOut = stderr.match(COMMAND_TIMED_OUT);
|
|
1581
|
+
if (timedOut) {
|
|
1582
|
+
const seconds = Math.max(1, Math.round(Number(timedOut[1]) / 1e3));
|
|
1583
|
+
return `Timed out after ${seconds}s reaching ${url ?? "that git repository"}.`;
|
|
1584
|
+
}
|
|
1585
|
+
if (stderr.startsWith("Couldn't reach")) {
|
|
1586
|
+
return stderr.endsWith(".") ? stderr : `${stderr}.`;
|
|
1587
|
+
}
|
|
1588
|
+
if (url) {
|
|
1589
|
+
return `Couldn't reach ${url}.`;
|
|
1590
|
+
}
|
|
1591
|
+
return "Couldn't reach that git repository.";
|
|
1592
|
+
}
|
|
1593
|
+
function gitFailureHint() {
|
|
1594
|
+
return "Check the URL, or sign in with ht github login if it's private.";
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
export {
|
|
1598
|
+
setHostPluginViewForceReplace,
|
|
1599
|
+
hostPluginViewForceReplace,
|
|
1600
|
+
recordKeptHostPluginViewFiles,
|
|
1601
|
+
recordReplacedHostPluginViewFiles,
|
|
1602
|
+
recordAddedHostPluginViewFiles,
|
|
1603
|
+
recordBlockedHostPluginViewFiles,
|
|
1604
|
+
takeBlockedHostPluginViewFiles,
|
|
1605
|
+
hasHostPluginViewNotices,
|
|
1606
|
+
hostPluginViewChangeCounts,
|
|
1607
|
+
takeReplacedHostPluginViewFiles,
|
|
1608
|
+
pendingKeptHostPluginViewPaths,
|
|
1609
|
+
allKeptHostPluginViewPaths,
|
|
1610
|
+
takeKeptHostPluginViewFiles,
|
|
1611
|
+
hostPluginViewNoticesJson,
|
|
1612
|
+
formatCount,
|
|
1613
|
+
shortenId,
|
|
1614
|
+
formatRelativeTime,
|
|
1615
|
+
formatRelativeTimeWithAbsolute,
|
|
1616
|
+
icons,
|
|
1617
|
+
styleResourceType,
|
|
1618
|
+
theme,
|
|
1619
|
+
isTty,
|
|
1620
|
+
terminalColumns,
|
|
1621
|
+
terminalRows,
|
|
1622
|
+
resolveTableMaxWidth,
|
|
1623
|
+
renderTable,
|
|
1624
|
+
table,
|
|
1625
|
+
renderPanel,
|
|
1626
|
+
panel,
|
|
1627
|
+
kvBlock,
|
|
1628
|
+
createProgress,
|
|
1629
|
+
status,
|
|
1630
|
+
renderSubheader,
|
|
1631
|
+
subheader,
|
|
1632
|
+
ui,
|
|
1633
|
+
isReleaseBuild,
|
|
1634
|
+
readGitSha,
|
|
1635
|
+
formatDevBuildVersion,
|
|
1636
|
+
resolveBuildVersion,
|
|
1637
|
+
PACKAGE_VERSION,
|
|
1638
|
+
CliUsageError,
|
|
1639
|
+
missingRequiredArg,
|
|
1640
|
+
conflictingOptions,
|
|
1641
|
+
quoteCliArg,
|
|
1642
|
+
formatHtCommand,
|
|
1643
|
+
skippedInvalidPluginExport,
|
|
1644
|
+
marketplaceUnreachable,
|
|
1645
|
+
marketplaceUnreachableHint,
|
|
1646
|
+
marketplacePathMissing,
|
|
1647
|
+
marketplacePathNotMarketplace,
|
|
1648
|
+
marketplaceAddFailedNothingSaved,
|
|
1649
|
+
installPinnedPluginsNeedsYes,
|
|
1650
|
+
installPinnedPluginsHint,
|
|
1651
|
+
skippedHostPluginHook,
|
|
1652
|
+
skippedDuplicateCommand,
|
|
1653
|
+
quoteName,
|
|
1654
|
+
formatHtArgs,
|
|
1655
|
+
plainTerminalText,
|
|
1656
|
+
ensureErrorPrefix,
|
|
1657
|
+
CLI_HINTS,
|
|
1658
|
+
CLI_ERRORS,
|
|
1659
|
+
SWITCH_CHANGES_VALUES,
|
|
1660
|
+
SWITCH_CHANGES_FLAG_HELP,
|
|
1661
|
+
DEVICE_LOGIN_WAITING,
|
|
1662
|
+
initPickHarnessesLine,
|
|
1663
|
+
initCompletionHintLine,
|
|
1664
|
+
CLI_COPY,
|
|
1665
|
+
onConflictReplaceHint,
|
|
1666
|
+
applyCancelledMessage,
|
|
1667
|
+
unsavedChangesLine,
|
|
1668
|
+
unsavedChangesFlagHint,
|
|
1669
|
+
savedChangesLine,
|
|
1670
|
+
stashedChangesLine,
|
|
1671
|
+
discardedChangesLine,
|
|
1672
|
+
discardConfirm,
|
|
1673
|
+
applyWroteLine,
|
|
1674
|
+
applyHeaderLine,
|
|
1675
|
+
dryRunWouldLine,
|
|
1676
|
+
dryRunStashLine,
|
|
1677
|
+
snapshotSavedUndoLine,
|
|
1678
|
+
keptFilesHeader,
|
|
1679
|
+
keptReportedBeforeLine,
|
|
1680
|
+
keptLinkOutsideRoot,
|
|
1681
|
+
skippedRemovalOutsideRoot,
|
|
1682
|
+
forceRemoveHintLine,
|
|
1683
|
+
restoredRemovedLine,
|
|
1684
|
+
dryRunSectionHeader,
|
|
1685
|
+
keptReasonLabel,
|
|
1686
|
+
isCommandTimeoutStderr,
|
|
1687
|
+
mapGitStderr,
|
|
1688
|
+
gitFailureHint,
|
|
1689
|
+
isNativeModuleMismatch,
|
|
1690
|
+
reportNativeModuleMismatch,
|
|
1691
|
+
isSqliteModuleMissing,
|
|
1692
|
+
statusTraceEnabled,
|
|
1693
|
+
traceSpan,
|
|
1694
|
+
traceCount,
|
|
1695
|
+
traceRecord,
|
|
1696
|
+
traceFs,
|
|
1697
|
+
readStatusWriteGeneration,
|
|
1698
|
+
harnesstapDirForHomeRoot,
|
|
1699
|
+
getDbPath,
|
|
1700
|
+
getHarnesstapDir,
|
|
1701
|
+
getDb,
|
|
1702
|
+
readDbDataVersion,
|
|
1703
|
+
closeDb,
|
|
1704
|
+
fetchWithTimeout,
|
|
1705
|
+
formatCatalogRequestError
|
|
1706
|
+
};
|
|
1707
|
+
//# sourceMappingURL=chunk-OHZNDV4A.js.map
|