harnesstap 1.2.0 → 1.3.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 +28 -15
- package/dist/apply-QSS4242W.js +67 -0
- package/dist/apply-QSS4242W.js.map +1 -0
- package/dist/approve-CNYQY6DC.js +181 -0
- package/dist/approve-CNYQY6DC.js.map +1 -0
- package/dist/audit-V4SUV7KA.js +434 -0
- package/dist/audit-V4SUV7KA.js.map +1 -0
- package/dist/auth-63FOHIQ3.js +220 -0
- package/dist/auth-63FOHIQ3.js.map +1 -0
- package/dist/bin.js +166 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-2H7UOFLK.js +11 -0
- package/dist/chunk-2H7UOFLK.js.map +1 -0
- package/dist/chunk-2NE3QYMP.js +103 -0
- package/dist/chunk-2NE3QYMP.js.map +1 -0
- package/dist/chunk-2P2EOYEW.js +1140 -0
- package/dist/chunk-2P2EOYEW.js.map +1 -0
- package/dist/chunk-37E5M4JX.js +34 -0
- package/dist/chunk-37E5M4JX.js.map +1 -0
- package/dist/chunk-37LQQWMF.js +496 -0
- package/dist/chunk-37LQQWMF.js.map +1 -0
- package/dist/chunk-3FIWOI3H.js +98 -0
- package/dist/chunk-3FIWOI3H.js.map +1 -0
- package/dist/chunk-3PGC6OA3.js +540 -0
- package/dist/chunk-3PGC6OA3.js.map +1 -0
- package/dist/chunk-4IHKBIY3.js +118 -0
- package/dist/chunk-4IHKBIY3.js.map +1 -0
- package/dist/chunk-4ZUBRLSP.js +17 -0
- package/dist/chunk-4ZUBRLSP.js.map +1 -0
- package/dist/chunk-5F3LNDZG.js +9 -0
- package/dist/chunk-5F3LNDZG.js.map +1 -0
- package/dist/chunk-5TXI6BI2.js +1359 -0
- package/dist/chunk-5TXI6BI2.js.map +1 -0
- package/dist/chunk-6P5IO4BX.js +235 -0
- package/dist/chunk-6P5IO4BX.js.map +1 -0
- package/dist/chunk-ABXUKHAU.js +571 -0
- package/dist/chunk-ABXUKHAU.js.map +1 -0
- package/dist/chunk-AOUDSNRK.js +1357 -0
- package/dist/chunk-AOUDSNRK.js.map +1 -0
- package/dist/chunk-BNDJJAEI.js +311 -0
- package/dist/chunk-BNDJJAEI.js.map +1 -0
- package/dist/chunk-C2IWSFF5.js +818 -0
- package/dist/chunk-C2IWSFF5.js.map +1 -0
- package/dist/chunk-CHQGE2HF.js +283 -0
- package/dist/chunk-CHQGE2HF.js.map +1 -0
- package/dist/chunk-DEJLP7QJ.js +681 -0
- package/dist/chunk-DEJLP7QJ.js.map +1 -0
- package/dist/chunk-DJ6FN6EW.js +532 -0
- package/dist/chunk-DJ6FN6EW.js.map +1 -0
- package/dist/chunk-E4WRTRMH.js +1173 -0
- package/dist/chunk-E4WRTRMH.js.map +1 -0
- package/dist/chunk-E5QXNU3K.js +238 -0
- package/dist/chunk-E5QXNU3K.js.map +1 -0
- package/dist/chunk-EMTBGOR3.js +2959 -0
- package/dist/chunk-EMTBGOR3.js.map +1 -0
- package/dist/chunk-FFWYIGQ4.js +18 -0
- package/dist/chunk-FFWYIGQ4.js.map +1 -0
- package/dist/chunk-I6XFZLTJ.js +9 -0
- package/dist/chunk-I6XFZLTJ.js.map +1 -0
- package/dist/chunk-IHWAOIAU.js +172 -0
- package/dist/chunk-IHWAOIAU.js.map +1 -0
- package/dist/chunk-IHZUYG66.js +583 -0
- package/dist/chunk-IHZUYG66.js.map +1 -0
- package/dist/chunk-JQOKQKQT.js +158 -0
- package/dist/chunk-JQOKQKQT.js.map +1 -0
- package/dist/chunk-JRFUTIEH.js +426 -0
- package/dist/chunk-JRFUTIEH.js.map +1 -0
- package/dist/chunk-KCBI6JQC.js +115 -0
- package/dist/chunk-KCBI6JQC.js.map +1 -0
- package/dist/chunk-KDUQMINL.js +60 -0
- package/dist/chunk-KDUQMINL.js.map +1 -0
- package/dist/chunk-KLR2DURP.js +656 -0
- package/dist/chunk-KLR2DURP.js.map +1 -0
- package/dist/chunk-KRI4R7EM.js +25 -0
- package/dist/chunk-KRI4R7EM.js.map +1 -0
- package/dist/chunk-LYQMK6SV.js +87 -0
- package/dist/chunk-LYQMK6SV.js.map +1 -0
- package/dist/chunk-MK3Q37ZN.js +183 -0
- package/dist/chunk-MK3Q37ZN.js.map +1 -0
- package/dist/chunk-MSGAGV7B.js +346 -0
- package/dist/chunk-MSGAGV7B.js.map +1 -0
- package/dist/chunk-MZQRSERO.js +430 -0
- package/dist/chunk-MZQRSERO.js.map +1 -0
- package/dist/chunk-N3WIJXXM.js +691 -0
- package/dist/chunk-N3WIJXXM.js.map +1 -0
- package/dist/chunk-NAGAJ5UM.js +145 -0
- package/dist/chunk-NAGAJ5UM.js.map +1 -0
- package/dist/chunk-NFYPBTKO.js +302 -0
- package/dist/chunk-NFYPBTKO.js.map +1 -0
- package/dist/chunk-NPO2IG6G.js +491 -0
- package/dist/chunk-NPO2IG6G.js.map +1 -0
- package/dist/chunk-OS6NUIBJ.js +38 -0
- package/dist/chunk-OS6NUIBJ.js.map +1 -0
- package/dist/chunk-PFUK3HJ4.js +296 -0
- package/dist/chunk-PFUK3HJ4.js.map +1 -0
- package/dist/chunk-PMQ55GDB.js +115 -0
- package/dist/chunk-PMQ55GDB.js.map +1 -0
- package/dist/chunk-QIVE2YFJ.js +514 -0
- package/dist/chunk-QIVE2YFJ.js.map +1 -0
- package/dist/chunk-QKXD3EUF.js +691 -0
- package/dist/chunk-QKXD3EUF.js.map +1 -0
- package/dist/chunk-RNQYUWF6.js +32 -0
- package/dist/chunk-RNQYUWF6.js.map +1 -0
- package/dist/chunk-S2E4SSQV.js +41 -0
- package/dist/chunk-S2E4SSQV.js.map +1 -0
- package/dist/chunk-SN4BXX3B.js +186 -0
- package/dist/chunk-SN4BXX3B.js.map +1 -0
- package/dist/chunk-SNVAMWB7.js +40 -0
- package/dist/chunk-SNVAMWB7.js.map +1 -0
- package/dist/chunk-T5VRREN4.js +696 -0
- package/dist/chunk-T5VRREN4.js.map +1 -0
- package/dist/chunk-TKBMHZTS.js +10945 -0
- package/dist/chunk-TKBMHZTS.js.map +1 -0
- package/dist/chunk-TNJPTUE4.js +35 -0
- package/dist/chunk-TNJPTUE4.js.map +1 -0
- package/dist/chunk-TQ2NA4Z4.js +24 -0
- package/dist/chunk-TQ2NA4Z4.js.map +1 -0
- package/dist/chunk-TXXDMDPN.js +998 -0
- package/dist/chunk-TXXDMDPN.js.map +1 -0
- package/dist/chunk-UWXUBU7V.js +184 -0
- package/dist/chunk-UWXUBU7V.js.map +1 -0
- package/dist/chunk-UYRK2H24.js +141 -0
- package/dist/chunk-UYRK2H24.js.map +1 -0
- package/dist/chunk-V4IXIM3C.js +806 -0
- package/dist/chunk-V4IXIM3C.js.map +1 -0
- package/dist/chunk-VFHVXXP4.js +6438 -0
- package/dist/chunk-VFHVXXP4.js.map +1 -0
- package/dist/chunk-VQVUJYYY.js +244 -0
- package/dist/chunk-VQVUJYYY.js.map +1 -0
- package/dist/chunk-VZQG2JDV.js +9 -0
- package/dist/chunk-VZQG2JDV.js.map +1 -0
- package/dist/chunk-W7HQ5X3S.js +610 -0
- package/dist/chunk-W7HQ5X3S.js.map +1 -0
- package/dist/chunk-WMSQAFK5.js +65 -0
- package/dist/chunk-WMSQAFK5.js.map +1 -0
- package/dist/chunk-WMYTBJPB.js +364 -0
- package/dist/chunk-WMYTBJPB.js.map +1 -0
- package/dist/chunk-WNLFNCOH.js +7795 -0
- package/dist/chunk-WNLFNCOH.js.map +1 -0
- package/dist/chunk-WRX7CB2M.js +6448 -0
- package/dist/chunk-WRX7CB2M.js.map +1 -0
- package/dist/chunk-XGTTOO4R.js +84 -0
- package/dist/chunk-XGTTOO4R.js.map +1 -0
- package/dist/chunk-YSXRBUR4.js +682 -0
- package/dist/chunk-YSXRBUR4.js.map +1 -0
- package/dist/chunk-YTC2EG64.js +1759 -0
- package/dist/chunk-YTC2EG64.js.map +1 -0
- package/dist/compile-J3UGQSS3.js +161 -0
- package/dist/compile-J3UGQSS3.js.map +1 -0
- package/dist/config-5BPSZND3.js +438 -0
- package/dist/config-5BPSZND3.js.map +1 -0
- package/dist/doctor-BVFKLJVO.js +111 -0
- package/dist/doctor-BVFKLJVO.js.map +1 -0
- package/dist/environment-3RI5H32O.js +2745 -0
- package/dist/environment-3RI5H32O.js.map +1 -0
- package/dist/github-YFJQVH5K.js +114 -0
- package/dist/github-YFJQVH5K.js.map +1 -0
- package/dist/harness-ECGHPEKA.js +746 -0
- package/dist/harness-ECGHPEKA.js.map +1 -0
- package/dist/help-ELPNPPEM.js +2079 -0
- package/dist/help-ELPNPPEM.js.map +1 -0
- package/dist/help-UL5XLY3I.js +1892 -0
- package/dist/help-UL5XLY3I.js.map +1 -0
- package/dist/index.d.ts +164 -1
- package/dist/index.js +50 -59246
- package/dist/index.js.map +1 -1
- package/dist/init-UJQTDHW7.js +873 -0
- package/dist/init-UJQTDHW7.js.map +1 -0
- package/dist/lock-XUMJ63NZ.js +455 -0
- package/dist/lock-XUMJ63NZ.js.map +1 -0
- package/dist/marketplace-ZUMOLVXE.js +495 -0
- package/dist/marketplace-ZUMOLVXE.js.map +1 -0
- package/dist/mcp-RZA5O2ND.js +202 -0
- package/dist/mcp-RZA5O2ND.js.map +1 -0
- package/dist/migrate-CYQI2FH6.js +1043 -0
- package/dist/migrate-CYQI2FH6.js.map +1 -0
- package/dist/open-AWOAWLKO.js +32 -0
- package/dist/open-AWOAWLKO.js.map +1 -0
- package/dist/pack-2QD5ZUIO.js +99 -0
- package/dist/pack-2QD5ZUIO.js.map +1 -0
- package/dist/plugin-GQSSSFX4.js +64 -0
- package/dist/plugin-GQSSSFX4.js.map +1 -0
- package/dist/plugin-from-project-SIQUFYIO.js +16 -0
- package/dist/plugin-from-project-SIQUFYIO.js.map +1 -0
- package/dist/policy-CT4JRCJI.js +105 -0
- package/dist/policy-CT4JRCJI.js.map +1 -0
- package/dist/profile-4JQ6LECP.js +1886 -0
- package/dist/profile-4JQ6LECP.js.map +1 -0
- package/dist/project-JG7QWXRG.js +1392 -0
- package/dist/project-JG7QWXRG.js.map +1 -0
- package/dist/resource-QRMR6CSD.js +555 -0
- package/dist/resource-QRMR6CSD.js.map +1 -0
- package/dist/version-LZ5POOXY.js +17 -0
- package/dist/version-LZ5POOXY.js.map +1 -0
- package/package.json +21 -14
- package/schemas/ap-package.v1.json +36 -0
- package/schemas/fixtures/catalog-missing-schema.ap.json +13 -0
- package/schemas/fixtures/confidence.ap.json +13 -0
- package/schemas/fixtures/context7.ap.json +13 -0
- package/schemas/fixtures/minimal-with-schema.ap.json +13 -0
- package/schemas/fixtures/superpowers.ap.json +13 -0
- package/schemas/fixtures/third-party-skills.ap.json +13 -0
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
import {
|
|
2
|
+
printResourceTrackedDirectoriesList
|
|
3
|
+
} from "./chunk-SN4BXX3B.js";
|
|
4
|
+
import {
|
|
5
|
+
ensureDefaultEnvironment,
|
|
6
|
+
seedDefaultProfileFromLibrary
|
|
7
|
+
} from "./chunk-KCBI6JQC.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveHarnessSelection
|
|
10
|
+
} from "./chunk-LYQMK6SV.js";
|
|
11
|
+
import {
|
|
12
|
+
CANONICAL_CATALOG_BASELINE,
|
|
13
|
+
CANONICAL_CATALOG_SEARCH_HINT
|
|
14
|
+
} from "./chunk-5F3LNDZG.js";
|
|
15
|
+
import {
|
|
16
|
+
createRemoteCatalogListPrompt,
|
|
17
|
+
importSkillPackage,
|
|
18
|
+
installSkillsToGlobal,
|
|
19
|
+
installSkillsToProject,
|
|
20
|
+
resolveSelectedSkills,
|
|
21
|
+
resolveSkillPackageCheckout
|
|
22
|
+
} from "./chunk-YSXRBUR4.js";
|
|
23
|
+
import "./chunk-6P5IO4BX.js";
|
|
24
|
+
import {
|
|
25
|
+
listResourceTrackedDirectories
|
|
26
|
+
} from "./chunk-BNDJJAEI.js";
|
|
27
|
+
import "./chunk-S2E4SSQV.js";
|
|
28
|
+
import "./chunk-XGTTOO4R.js";
|
|
29
|
+
import {
|
|
30
|
+
parseCommaSeparatedList,
|
|
31
|
+
parseHarnessList,
|
|
32
|
+
resolveAddScope
|
|
33
|
+
} from "./chunk-37E5M4JX.js";
|
|
34
|
+
import {
|
|
35
|
+
promptForSearchableMultiSelect
|
|
36
|
+
} from "./chunk-JQOKQKQT.js";
|
|
37
|
+
import "./chunk-3FIWOI3H.js";
|
|
38
|
+
import {
|
|
39
|
+
installPluginFromCatalog
|
|
40
|
+
} from "./chunk-WNLFNCOH.js";
|
|
41
|
+
import "./chunk-E5QXNU3K.js";
|
|
42
|
+
import {
|
|
43
|
+
isPromptCancellationError,
|
|
44
|
+
promptForChoice,
|
|
45
|
+
promptForConfirmation,
|
|
46
|
+
promptForValue,
|
|
47
|
+
resolveOrPrompt,
|
|
48
|
+
shouldUseWizard
|
|
49
|
+
} from "./chunk-NAGAJ5UM.js";
|
|
50
|
+
import {
|
|
51
|
+
initializeSchema
|
|
52
|
+
} from "./chunk-N3WIJXXM.js";
|
|
53
|
+
import {
|
|
54
|
+
GLOBAL_DEFAULT_PROFILE_NAME
|
|
55
|
+
} from "./chunk-TNJPTUE4.js";
|
|
56
|
+
import "./chunk-KDUQMINL.js";
|
|
57
|
+
import "./chunk-I6XFZLTJ.js";
|
|
58
|
+
import "./chunk-W7HQ5X3S.js";
|
|
59
|
+
import "./chunk-JRFUTIEH.js";
|
|
60
|
+
import {
|
|
61
|
+
assertSupportedHarnessTargets,
|
|
62
|
+
getHarnessPreference,
|
|
63
|
+
registeredHarnessesOf,
|
|
64
|
+
resolveScanGlobalHarnessTargets,
|
|
65
|
+
setHarnessPreference
|
|
66
|
+
} from "./chunk-PFUK3HJ4.js";
|
|
67
|
+
import {
|
|
68
|
+
getImportedSnapshot,
|
|
69
|
+
recordImportedSnapshotInstall,
|
|
70
|
+
scanAndPersistHomeDefaults
|
|
71
|
+
} from "./chunk-WRX7CB2M.js";
|
|
72
|
+
import "./chunk-E4WRTRMH.js";
|
|
73
|
+
import "./chunk-MZQRSERO.js";
|
|
74
|
+
import "./chunk-DEJLP7QJ.js";
|
|
75
|
+
import {
|
|
76
|
+
addPluginAttachment,
|
|
77
|
+
createPlugin,
|
|
78
|
+
getAllPlatforms,
|
|
79
|
+
getPlugin,
|
|
80
|
+
listPlugins,
|
|
81
|
+
listPluginsInScope,
|
|
82
|
+
resolveHomeRoot
|
|
83
|
+
} from "./chunk-TKBMHZTS.js";
|
|
84
|
+
import "./chunk-TXXDMDPN.js";
|
|
85
|
+
import "./chunk-C2IWSFF5.js";
|
|
86
|
+
import "./chunk-NPO2IG6G.js";
|
|
87
|
+
import "./chunk-5TXI6BI2.js";
|
|
88
|
+
import {
|
|
89
|
+
parseOutputFormat,
|
|
90
|
+
printJson
|
|
91
|
+
} from "./chunk-TQ2NA4Z4.js";
|
|
92
|
+
import {
|
|
93
|
+
fail,
|
|
94
|
+
failCaught,
|
|
95
|
+
formatCommand
|
|
96
|
+
} from "./chunk-NFYPBTKO.js";
|
|
97
|
+
import {
|
|
98
|
+
formatCount,
|
|
99
|
+
ui
|
|
100
|
+
} from "./chunk-ABXUKHAU.js";
|
|
101
|
+
import {
|
|
102
|
+
formatCatalogScopeLabel,
|
|
103
|
+
resolveCatalogScope,
|
|
104
|
+
resolvedRemotePluginFromCatalog
|
|
105
|
+
} from "./chunk-2P2EOYEW.js";
|
|
106
|
+
import "./chunk-VQVUJYYY.js";
|
|
107
|
+
import {
|
|
108
|
+
getDb,
|
|
109
|
+
getDbPath,
|
|
110
|
+
getHarnesstapDir,
|
|
111
|
+
initCompletionHintLine,
|
|
112
|
+
initPickHarnessesLine
|
|
113
|
+
} from "./chunk-KLR2DURP.js";
|
|
114
|
+
|
|
115
|
+
// src/cli/commands/init.ts
|
|
116
|
+
import { existsSync as existsSync3 } from "fs";
|
|
117
|
+
import { resolve as resolve2 } from "path";
|
|
118
|
+
import { Option } from "commander";
|
|
119
|
+
|
|
120
|
+
// src/services/add-package.ts
|
|
121
|
+
import { resolve } from "path";
|
|
122
|
+
function resolveHarnessTargets(options) {
|
|
123
|
+
if (options.harnesses && options.harnesses.length > 0) {
|
|
124
|
+
return options.harnesses;
|
|
125
|
+
}
|
|
126
|
+
return resolveScanGlobalHarnessTargets(void 0, options.homeRoot);
|
|
127
|
+
}
|
|
128
|
+
function updateSnapshotInstalledSkillNames(snapshotId, installedSkillNames) {
|
|
129
|
+
const snapshot = getImportedSnapshot(snapshotId);
|
|
130
|
+
if (!snapshot) return;
|
|
131
|
+
const db = getDb();
|
|
132
|
+
const metadata = {
|
|
133
|
+
...snapshot.metadata,
|
|
134
|
+
installed_skill_names: installedSkillNames
|
|
135
|
+
};
|
|
136
|
+
db.prepare("UPDATE imported_snapshots SET metadata = ? WHERE id = ?").run(
|
|
137
|
+
JSON.stringify(metadata),
|
|
138
|
+
snapshotId
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
async function addSkillPackage(options) {
|
|
142
|
+
const resolved = resolveSkillPackageCheckout(
|
|
143
|
+
options.source,
|
|
144
|
+
options.harnesstapDir
|
|
145
|
+
);
|
|
146
|
+
const importedSkills = resolved.discovered.map((skill) => skill.name);
|
|
147
|
+
const skillsToInstall = resolveSelectedSkills(resolved.discovered, options);
|
|
148
|
+
const installedSkillNames = skillsToInstall.map((skill) => skill.name);
|
|
149
|
+
const namespace = resolved.namespace;
|
|
150
|
+
if (options.dryRun) {
|
|
151
|
+
return {
|
|
152
|
+
namespace,
|
|
153
|
+
importedSkills,
|
|
154
|
+
installedSkills: installedSkillNames,
|
|
155
|
+
snapshotId: ""
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const importResult = await importSkillPackage({
|
|
159
|
+
rootPath: resolved.checkoutRoot,
|
|
160
|
+
sourceLabel: namespace,
|
|
161
|
+
gitUrl: resolved.gitUrl,
|
|
162
|
+
gitSha: resolved.gitSha
|
|
163
|
+
});
|
|
164
|
+
const harnesses = resolveHarnessTargets(options);
|
|
165
|
+
let installedSkills;
|
|
166
|
+
if (options.scope === "global") {
|
|
167
|
+
const installResult = await installSkillsToGlobal({
|
|
168
|
+
checkoutRoot: resolved.checkoutRoot,
|
|
169
|
+
skills: skillsToInstall,
|
|
170
|
+
harnesses,
|
|
171
|
+
homeRoot: options.homeRoot,
|
|
172
|
+
method: options.method
|
|
173
|
+
});
|
|
174
|
+
installedSkills = installResult.installed;
|
|
175
|
+
recordImportedSnapshotInstall({
|
|
176
|
+
snapshot_id: importResult.snapshot.id,
|
|
177
|
+
platform_id: "hub",
|
|
178
|
+
files: installResult.files
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
const projectRoot = resolve(options.projectRoot ?? ".");
|
|
182
|
+
const installResult = await installSkillsToProject({
|
|
183
|
+
checkoutRoot: resolved.checkoutRoot,
|
|
184
|
+
skills: skillsToInstall,
|
|
185
|
+
harnesses,
|
|
186
|
+
projectRoot,
|
|
187
|
+
method: options.method
|
|
188
|
+
});
|
|
189
|
+
installedSkills = installResult.installed;
|
|
190
|
+
recordImportedSnapshotInstall({
|
|
191
|
+
snapshot_id: importResult.snapshot.id,
|
|
192
|
+
platform_id: "project",
|
|
193
|
+
files: installResult.files
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
updateSnapshotInstalledSkillNames(importResult.snapshot.id, installedSkills);
|
|
197
|
+
let attachedPlugin;
|
|
198
|
+
const pluginName = options.createPlugin ?? options.plugin;
|
|
199
|
+
if (pluginName) {
|
|
200
|
+
const targetPlugin = options.createPlugin ? createPlugin({ name: options.createPlugin }) : getPlugin(pluginName);
|
|
201
|
+
if (!targetPlugin) {
|
|
202
|
+
throw new Error(`Plugin not found: ${options.plugin}`);
|
|
203
|
+
}
|
|
204
|
+
for (const skillName of installedSkills) {
|
|
205
|
+
await addPluginAttachment({
|
|
206
|
+
plugin: targetPlugin,
|
|
207
|
+
selector: `skill:${skillName}@${namespace}`,
|
|
208
|
+
type: "skill"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
attachedPlugin = targetPlugin.name;
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
namespace,
|
|
215
|
+
importedSkills,
|
|
216
|
+
installedSkills,
|
|
217
|
+
snapshotId: importResult.snapshot.id,
|
|
218
|
+
...attachedPlugin ? { plugin: attachedPlugin } : {}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/services/bootstrap-local-library.ts
|
|
223
|
+
import { existsSync } from "fs";
|
|
224
|
+
async function bootstrapLocalLibrary(options = {}) {
|
|
225
|
+
const firstRun = !existsSync(getDbPath());
|
|
226
|
+
initializeSchema(getDb());
|
|
227
|
+
ensureDefaultEnvironment();
|
|
228
|
+
const homeDefaults = await scanAndPersistHomeDefaults();
|
|
229
|
+
if (options.seedDefaultProfile !== false) {
|
|
230
|
+
seedDefaultProfileFromLibrary();
|
|
231
|
+
}
|
|
232
|
+
return { firstRun, homeDefaults };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/services/wizards/interactive-catalog-browser.ts
|
|
236
|
+
var promptForInteractiveCatalogBrowser = (config, context) => createRemoteCatalogListPrompt(
|
|
237
|
+
{ ...config, mode: { kind: "install" } },
|
|
238
|
+
context
|
|
239
|
+
);
|
|
240
|
+
async function runInteractiveCatalogBrowser(input) {
|
|
241
|
+
return promptForInteractiveCatalogBrowser(input);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/services/init-catalog-prompt.ts
|
|
245
|
+
async function maybePromptInitCatalogInstall(input) {
|
|
246
|
+
if (input.format !== "human" || !input.interactive) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (listPlugins().length > 0) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const choice = await promptForChoice({
|
|
253
|
+
message: "Browse public catalog plugins now?",
|
|
254
|
+
choices: [
|
|
255
|
+
{ name: "Yes: install a plugin into the local library", value: "yes" },
|
|
256
|
+
{ name: "No: I'll use plugin list / apply later", value: "no" }
|
|
257
|
+
]
|
|
258
|
+
});
|
|
259
|
+
if (choice === "no") {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const scope = resolveCatalogScope();
|
|
263
|
+
const selected = await runInteractiveCatalogBrowser({
|
|
264
|
+
message: "Select a catalog plugin to install",
|
|
265
|
+
scopeLabel: formatCatalogScopeLabel(scope),
|
|
266
|
+
listPlugins: ({ q, limit }) => listPluginsInScope({ q, limit, sort: "updated" })
|
|
267
|
+
});
|
|
268
|
+
const parsed = resolvedRemotePluginFromCatalog({
|
|
269
|
+
org: selected.orgSlug,
|
|
270
|
+
catalog: selected.catalogSlug,
|
|
271
|
+
name: selected.slug,
|
|
272
|
+
version: selected.version
|
|
273
|
+
});
|
|
274
|
+
const installed = await installPluginFromCatalog(parsed, {});
|
|
275
|
+
ui.success(
|
|
276
|
+
`Installed plugin ${ui.theme.accent(installed.pluginName)} from catalog (${installed.sourceLabel})`
|
|
277
|
+
);
|
|
278
|
+
ui.hint(`Apply it with: ht apply ${installed.pluginName}`);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/services/init-completion-install.ts
|
|
282
|
+
import { existsSync as existsSync2 } from "fs";
|
|
283
|
+
import { appendFile, mkdir, readFile, writeFile } from "fs/promises";
|
|
284
|
+
import { dirname, join } from "path";
|
|
285
|
+
|
|
286
|
+
// src/services/shell-completion.ts
|
|
287
|
+
function bashCompletion() {
|
|
288
|
+
return `# harnesstap bash completion
|
|
289
|
+
_harnesstap_completions() {
|
|
290
|
+
local line="\${COMP_LINE:0:$COMP_POINT}"
|
|
291
|
+
mapfile -t COMPREPLY < <(ht __complete bash -- "$line" 2>/dev/null)
|
|
292
|
+
}
|
|
293
|
+
complete -F _harnesstap_completions ht harnesstap
|
|
294
|
+
`;
|
|
295
|
+
}
|
|
296
|
+
function zshCompletion() {
|
|
297
|
+
return `#compdef ht harnesstap
|
|
298
|
+
|
|
299
|
+
_harnesstap() {
|
|
300
|
+
local -a suggestions args descr
|
|
301
|
+
local line has_descr=0
|
|
302
|
+
suggestions=("\${(@f)$(ht __complete zsh -- "\${BUFFER[1,$CURSOR]}" 2>/dev/null)}")
|
|
303
|
+
if (( \${#suggestions} )); then
|
|
304
|
+
for line in $suggestions; do
|
|
305
|
+
if [[ $line == *$'\\t'* ]]; then
|
|
306
|
+
args+=(\${line%%$'\\t'*})
|
|
307
|
+
descr+=(\${line#*$'\\t'})
|
|
308
|
+
else
|
|
309
|
+
args+=($line)
|
|
310
|
+
descr+=("")
|
|
311
|
+
fi
|
|
312
|
+
done
|
|
313
|
+
for line in $descr; do
|
|
314
|
+
if [[ -n $line ]]; then
|
|
315
|
+
has_descr=1
|
|
316
|
+
break
|
|
317
|
+
fi
|
|
318
|
+
done
|
|
319
|
+
if (( has_descr )); then
|
|
320
|
+
compadd -d descr -a args
|
|
321
|
+
else
|
|
322
|
+
compadd -a args
|
|
323
|
+
fi
|
|
324
|
+
fi
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
compdef _harnesstap ht harnesstap
|
|
328
|
+
`;
|
|
329
|
+
}
|
|
330
|
+
function fishCompletion() {
|
|
331
|
+
return `# harnesstap fish completion
|
|
332
|
+
function __harnesstap_complete
|
|
333
|
+
ht __complete fish -- (commandline -cp) 2>/dev/null
|
|
334
|
+
end
|
|
335
|
+
complete -c ht -f -a "(__harnesstap_complete)"
|
|
336
|
+
complete -c harnesstap -f -a "(__harnesstap_complete)"
|
|
337
|
+
`;
|
|
338
|
+
}
|
|
339
|
+
function renderShellCompletion(shell, _program) {
|
|
340
|
+
switch (shell) {
|
|
341
|
+
case "bash":
|
|
342
|
+
return bashCompletion();
|
|
343
|
+
case "zsh":
|
|
344
|
+
return zshCompletion();
|
|
345
|
+
case "fish":
|
|
346
|
+
return fishCompletion();
|
|
347
|
+
default:
|
|
348
|
+
throw new Error(`Unsupported shell: ${shell}. Use bash, zsh, or fish.`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// src/services/init-completion-install.ts
|
|
353
|
+
var COMPLETION_MARKERS = {
|
|
354
|
+
bash: "# harnesstap bash completion",
|
|
355
|
+
zsh: "#compdef ht harnesstap",
|
|
356
|
+
fish: "# harnesstap fish completion"
|
|
357
|
+
};
|
|
358
|
+
function detectShellFromEnv(env = process.env) {
|
|
359
|
+
const base = (env.SHELL ?? "").split("/").pop()?.toLowerCase();
|
|
360
|
+
if (base === "bash" || base === "zsh" || base === "fish") return base;
|
|
361
|
+
return void 0;
|
|
362
|
+
}
|
|
363
|
+
function resolveCompletionTargetPath(shell, homeRoot) {
|
|
364
|
+
switch (shell) {
|
|
365
|
+
case "bash":
|
|
366
|
+
return join(homeRoot, ".bashrc");
|
|
367
|
+
case "zsh":
|
|
368
|
+
return join(homeRoot, ".zshrc");
|
|
369
|
+
case "fish":
|
|
370
|
+
return join(homeRoot, ".config", "fish", "completions", "ht.fish");
|
|
371
|
+
default: {
|
|
372
|
+
const _exhaustive = shell;
|
|
373
|
+
return _exhaustive;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function completionAlreadyInstalled(shell, contents) {
|
|
378
|
+
return contents.includes(COMPLETION_MARKERS[shell]);
|
|
379
|
+
}
|
|
380
|
+
async function installShellCompletion(input) {
|
|
381
|
+
const path = resolveCompletionTargetPath(input.shell, input.homeRoot);
|
|
382
|
+
await mkdir(dirname(path), { recursive: true });
|
|
383
|
+
if (input.shell === "fish") {
|
|
384
|
+
if (existsSync2(path)) {
|
|
385
|
+
const existing2 = await readFile(path, "utf8");
|
|
386
|
+
if (completionAlreadyInstalled("fish", existing2)) {
|
|
387
|
+
return { status: "already_installed", path };
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
await writeFile(path, input.script.endsWith("\n") ? input.script : `${input.script}
|
|
391
|
+
`, "utf8");
|
|
392
|
+
return { status: "installed", path };
|
|
393
|
+
}
|
|
394
|
+
const existing = existsSync2(path) ? await readFile(path, "utf8") : "";
|
|
395
|
+
if (completionAlreadyInstalled(input.shell, existing)) {
|
|
396
|
+
return { status: "already_installed", path };
|
|
397
|
+
}
|
|
398
|
+
const prefix = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
399
|
+
const body = input.script.endsWith("\n") ? input.script : `${input.script}
|
|
400
|
+
`;
|
|
401
|
+
await appendFile(path, `${prefix}${body}`, "utf8");
|
|
402
|
+
return { status: "installed", path };
|
|
403
|
+
}
|
|
404
|
+
async function maybePromptInitCompletionInstall(input) {
|
|
405
|
+
if (input.format !== "human" || !input.interactive) return;
|
|
406
|
+
const env = input.env ?? process.env;
|
|
407
|
+
const shell = detectShellFromEnv(env);
|
|
408
|
+
if (!shell) {
|
|
409
|
+
ui.dim(
|
|
410
|
+
"Skip tab completion setup (unknown $SHELL). Use: ht init completion <bash|zsh|fish>"
|
|
411
|
+
);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const homeRoot = input.homeRoot ?? resolveHomeRoot();
|
|
415
|
+
const target = resolveCompletionTargetPath(shell, homeRoot);
|
|
416
|
+
const confirm = input.confirm ?? ((message) => promptForConfirmation({ message, default: true }));
|
|
417
|
+
const ok = await confirm(
|
|
418
|
+
`Enable tab completion for ${shell}? (writes ${target})`
|
|
419
|
+
);
|
|
420
|
+
if (!ok) return;
|
|
421
|
+
const script = renderShellCompletion(shell, {});
|
|
422
|
+
const result = await installShellCompletion({ shell, homeRoot, script });
|
|
423
|
+
if (result.status === "already_installed") {
|
|
424
|
+
ui.dim(`Tab completion already present in ${result.path}`);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
ui.success(`Tab completion installed \u2192 ${result.path}`);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// src/services/wizards/add-package.ts
|
|
431
|
+
function defaultHarnessSelection() {
|
|
432
|
+
const preference = getHarnessPreference();
|
|
433
|
+
if (preference) {
|
|
434
|
+
return registeredHarnessesOf(preference);
|
|
435
|
+
}
|
|
436
|
+
return [];
|
|
437
|
+
}
|
|
438
|
+
function buildSkillChoices(discovered) {
|
|
439
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
440
|
+
for (const skill of discovered) {
|
|
441
|
+
const category = skill.category || "general";
|
|
442
|
+
const group = byCategory.get(category) ?? [];
|
|
443
|
+
group.push(skill);
|
|
444
|
+
byCategory.set(category, group);
|
|
445
|
+
}
|
|
446
|
+
const categories = [...byCategory.keys()].sort((a, b) => a.localeCompare(b));
|
|
447
|
+
const choices = [];
|
|
448
|
+
for (const category of categories) {
|
|
449
|
+
const skills = byCategory.get(category) ?? [];
|
|
450
|
+
for (const skill of skills.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
451
|
+
const description = skill.description.trim() || void 0;
|
|
452
|
+
choices.push({
|
|
453
|
+
name: `[${category}] ${skill.name}`,
|
|
454
|
+
value: skill.name,
|
|
455
|
+
description
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return choices;
|
|
460
|
+
}
|
|
461
|
+
function resolvePluginStepChoice(input) {
|
|
462
|
+
if (input.createPlugin) return "create";
|
|
463
|
+
if (input.plugin) return "existing";
|
|
464
|
+
return void 0;
|
|
465
|
+
}
|
|
466
|
+
async function runAddPackageWizard(input) {
|
|
467
|
+
const method = input.method ?? "symlink";
|
|
468
|
+
if (!input.shouldPrompt) {
|
|
469
|
+
if (!input.scope) {
|
|
470
|
+
throw new Error("Scope required. Pass --global or --project.");
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
skillNames: input.skillNames,
|
|
474
|
+
all: input.all,
|
|
475
|
+
scope: input.scope,
|
|
476
|
+
projectRoot: input.projectRoot,
|
|
477
|
+
method,
|
|
478
|
+
harnesses: input.harnesses,
|
|
479
|
+
createPlugin: input.createPlugin,
|
|
480
|
+
plugin: input.plugin,
|
|
481
|
+
confirmed: true
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
let skillNames = input.skillNames;
|
|
485
|
+
let all = input.all;
|
|
486
|
+
if (!all && (!skillNames || skillNames.length === 0)) {
|
|
487
|
+
const selected = await promptForSearchableMultiSelect({
|
|
488
|
+
message: "Which skills do you want to install?",
|
|
489
|
+
choices: buildSkillChoices(input.discovered),
|
|
490
|
+
default: input.discovered.map((skill) => skill.name),
|
|
491
|
+
pageSize: 12,
|
|
492
|
+
loop: false
|
|
493
|
+
});
|
|
494
|
+
if (selected.length === 0) {
|
|
495
|
+
throw new Error("No skills selected.");
|
|
496
|
+
}
|
|
497
|
+
if (selected.length === input.discovered.length) {
|
|
498
|
+
all = true;
|
|
499
|
+
skillNames = void 0;
|
|
500
|
+
} else {
|
|
501
|
+
skillNames = selected;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const harnessChoices = getAllPlatforms().map((platform) => ({
|
|
505
|
+
name: `${platform.name} (${platform.id})`,
|
|
506
|
+
value: platform.id
|
|
507
|
+
}));
|
|
508
|
+
const defaultHarnesses = input.harnesses ?? defaultHarnessSelection();
|
|
509
|
+
const harnesses = await resolveOrPrompt({
|
|
510
|
+
value: input.harnesses,
|
|
511
|
+
shouldPrompt: input.shouldPrompt,
|
|
512
|
+
prompt: async () => promptForSearchableMultiSelect({
|
|
513
|
+
message: "Which harnesses should receive the installed skills?",
|
|
514
|
+
choices: harnessChoices,
|
|
515
|
+
default: defaultHarnesses,
|
|
516
|
+
pageSize: 10,
|
|
517
|
+
loop: false
|
|
518
|
+
})
|
|
519
|
+
});
|
|
520
|
+
const scope = await resolveOrPrompt({
|
|
521
|
+
value: input.scope,
|
|
522
|
+
shouldPrompt: input.shouldPrompt,
|
|
523
|
+
prompt: async () => promptForChoice({
|
|
524
|
+
message: "Where should skills be installed?",
|
|
525
|
+
choices: [
|
|
526
|
+
{ name: "Global (user home)", value: "global" },
|
|
527
|
+
{ name: "Project directory", value: "project" }
|
|
528
|
+
],
|
|
529
|
+
default: "global"
|
|
530
|
+
})
|
|
531
|
+
});
|
|
532
|
+
if (!scope) {
|
|
533
|
+
throw new Error("Scope required. Pass --global or --project.");
|
|
534
|
+
}
|
|
535
|
+
let projectRoot = input.projectRoot;
|
|
536
|
+
if (scope === "project" && !projectRoot) {
|
|
537
|
+
projectRoot = await promptForValue({
|
|
538
|
+
message: "Project directory",
|
|
539
|
+
default: "."
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
const installMethod = await resolveOrPrompt({
|
|
543
|
+
value: input.method,
|
|
544
|
+
shouldPrompt: input.shouldPrompt,
|
|
545
|
+
prompt: async () => promptForChoice({
|
|
546
|
+
message: "Installation method",
|
|
547
|
+
choices: [
|
|
548
|
+
{ name: "Symlink (recommended)", value: "symlink" },
|
|
549
|
+
{ name: "Copy files", value: "copy" }
|
|
550
|
+
],
|
|
551
|
+
default: "symlink"
|
|
552
|
+
})
|
|
553
|
+
});
|
|
554
|
+
let createPlugin2 = input.createPlugin;
|
|
555
|
+
let plugin = input.plugin;
|
|
556
|
+
const pluginStep = resolvePluginStepChoice(input);
|
|
557
|
+
if (!pluginStep) {
|
|
558
|
+
const pluginChoice = await promptForChoice({
|
|
559
|
+
message: "Attach skills to a plugin?",
|
|
560
|
+
choices: [
|
|
561
|
+
{ name: "Skip", value: "skip" },
|
|
562
|
+
{
|
|
563
|
+
name: "Create a new plugin",
|
|
564
|
+
value: "create"
|
|
565
|
+
},
|
|
566
|
+
{ name: "Add to an existing plugin", value: "existing" }
|
|
567
|
+
],
|
|
568
|
+
default: "skip"
|
|
569
|
+
});
|
|
570
|
+
if (pluginChoice === "create") {
|
|
571
|
+
createPlugin2 = await promptForValue({
|
|
572
|
+
message: "New plugin name",
|
|
573
|
+
default: input.sourceLabel?.replace(/[^\w-]+/g, "-").replace(/^-+|-+$/g, "") || void 0
|
|
574
|
+
});
|
|
575
|
+
} else if (pluginChoice === "existing") {
|
|
576
|
+
const plugins = listPlugins();
|
|
577
|
+
if (plugins.length > 0) {
|
|
578
|
+
plugin = await promptForChoice({
|
|
579
|
+
message: "Which plugin?",
|
|
580
|
+
choices: plugins.map((entry) => ({
|
|
581
|
+
name: `${entry.name}@${entry.version}`,
|
|
582
|
+
value: entry.name
|
|
583
|
+
}))
|
|
584
|
+
});
|
|
585
|
+
} else {
|
|
586
|
+
plugin = await promptForValue({
|
|
587
|
+
message: "Existing plugin name"
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const confirmed = await promptForConfirmation({
|
|
593
|
+
message: "Proceed with installation?",
|
|
594
|
+
default: true
|
|
595
|
+
});
|
|
596
|
+
return {
|
|
597
|
+
skillNames,
|
|
598
|
+
all,
|
|
599
|
+
scope,
|
|
600
|
+
projectRoot,
|
|
601
|
+
method: installMethod ?? method,
|
|
602
|
+
harnesses,
|
|
603
|
+
createPlugin: createPlugin2,
|
|
604
|
+
plugin,
|
|
605
|
+
confirmed
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/cli/commands/init.ts
|
|
610
|
+
function printQuickStartGuide(env = process.env) {
|
|
611
|
+
console.log("");
|
|
612
|
+
ui.subheader("NEXT STEPS");
|
|
613
|
+
console.log("");
|
|
614
|
+
console.log(` ${initPickHarnessesLine()}`);
|
|
615
|
+
console.log(` ${formatCommand(["profile", "use", GLOBAL_DEFAULT_PROFILE_NAME])}`);
|
|
616
|
+
console.log(
|
|
617
|
+
` ${formatCommand([
|
|
618
|
+
"plugin",
|
|
619
|
+
"list",
|
|
620
|
+
"--search",
|
|
621
|
+
CANONICAL_CATALOG_SEARCH_HINT,
|
|
622
|
+
"--remote-only"
|
|
623
|
+
])}`
|
|
624
|
+
);
|
|
625
|
+
console.log(
|
|
626
|
+
` ${formatCommand(["apply", CANONICAL_CATALOG_BASELINE])}`
|
|
627
|
+
);
|
|
628
|
+
console.log(` ${formatCommand("help")}`);
|
|
629
|
+
ui.dim(initCompletionHintLine(detectShellFromEnv(env)));
|
|
630
|
+
}
|
|
631
|
+
async function handleAddCommand(source, opts) {
|
|
632
|
+
const format = parseOutputFormat(opts.format);
|
|
633
|
+
const harnesstapDir = getHarnesstapDir();
|
|
634
|
+
const homeRoot = resolveHomeRoot();
|
|
635
|
+
if (opts.plugin && opts.createPlugin) {
|
|
636
|
+
throw new Error("Pass only one of --plugin or --create-plugin.");
|
|
637
|
+
}
|
|
638
|
+
const method = opts.method === "copy" ? "copy" : opts.method === "symlink" || !opts.method ? "symlink" : (() => {
|
|
639
|
+
throw new Error(`Invalid --method value: ${opts.method}. Use symlink or copy.`);
|
|
640
|
+
})();
|
|
641
|
+
const resolvedPackage = resolveSkillPackageCheckout(source, harnesstapDir);
|
|
642
|
+
const { namespace } = resolvedPackage;
|
|
643
|
+
const discovered = resolvedPackage.discovered;
|
|
644
|
+
if (opts.list) {
|
|
645
|
+
const payload2 = {
|
|
646
|
+
source,
|
|
647
|
+
namespace,
|
|
648
|
+
primary: "skill-package",
|
|
649
|
+
skills: discovered
|
|
650
|
+
};
|
|
651
|
+
if (format === "json") {
|
|
652
|
+
printJson(payload2);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
ui.subheader("DISCOVERED SKILLS");
|
|
656
|
+
console.log("");
|
|
657
|
+
for (const skill of discovered) {
|
|
658
|
+
const description = skill.description.trim();
|
|
659
|
+
console.log(
|
|
660
|
+
` ${ui.theme.accent(skill.name)} ${ui.theme.muted(`[${skill.category}]`)}`
|
|
661
|
+
);
|
|
662
|
+
if (description) {
|
|
663
|
+
ui.dim(` ${description}`);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
const db = getDb();
|
|
669
|
+
initializeSchema(db);
|
|
670
|
+
const scopeFromFlags = resolveAddScope({
|
|
671
|
+
global: opts.global,
|
|
672
|
+
project: opts.project
|
|
673
|
+
});
|
|
674
|
+
const skillNames = parseCommaSeparatedList(opts.skill);
|
|
675
|
+
const harnesses = parseCommaSeparatedList(opts.harness);
|
|
676
|
+
if (harnesses) {
|
|
677
|
+
assertSupportedHarnessTargets(harnesses);
|
|
678
|
+
}
|
|
679
|
+
const shouldPrompt = shouldUseWizard({
|
|
680
|
+
noInteractive: opts.yes,
|
|
681
|
+
format,
|
|
682
|
+
missingRequiredArgs: !scopeFromFlags || !opts.all && (!skillNames || skillNames.length === 0)
|
|
683
|
+
});
|
|
684
|
+
const wizard = await runAddPackageWizard({
|
|
685
|
+
discovered,
|
|
686
|
+
skillNames,
|
|
687
|
+
all: opts.all,
|
|
688
|
+
scope: scopeFromFlags?.scope,
|
|
689
|
+
projectRoot: scopeFromFlags?.projectRoot,
|
|
690
|
+
method,
|
|
691
|
+
harnesses,
|
|
692
|
+
createPlugin: opts.createPlugin,
|
|
693
|
+
plugin: opts.plugin,
|
|
694
|
+
sourceLabel: namespace,
|
|
695
|
+
shouldPrompt
|
|
696
|
+
});
|
|
697
|
+
if (!wizard.confirmed) {
|
|
698
|
+
ui.warn("Installation cancelled.");
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
const result = await addSkillPackage({
|
|
702
|
+
source,
|
|
703
|
+
skillNames: wizard.skillNames,
|
|
704
|
+
all: wizard.all,
|
|
705
|
+
scope: wizard.scope,
|
|
706
|
+
projectRoot: wizard.projectRoot,
|
|
707
|
+
method: wizard.method,
|
|
708
|
+
harnesses: wizard.harnesses,
|
|
709
|
+
homeRoot,
|
|
710
|
+
harnesstapDir,
|
|
711
|
+
createPlugin: wizard.createPlugin,
|
|
712
|
+
plugin: wizard.plugin,
|
|
713
|
+
dryRun: opts.dryRun
|
|
714
|
+
});
|
|
715
|
+
const payload = {
|
|
716
|
+
source,
|
|
717
|
+
namespace: result.namespace,
|
|
718
|
+
discovered: discovered.map((skill) => skill.name),
|
|
719
|
+
imported: result.importedSkills,
|
|
720
|
+
installed: result.installedSkills,
|
|
721
|
+
snapshot_id: result.snapshotId,
|
|
722
|
+
...result.plugin ? { plugin: result.plugin } : {}
|
|
723
|
+
};
|
|
724
|
+
if (format === "json") {
|
|
725
|
+
printJson(payload);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
if (opts.dryRun) {
|
|
729
|
+
ui.success(
|
|
730
|
+
`Dry run ${ui.icons.hint} would install ${result.installedSkills.join(", ")} from ${result.namespace}`
|
|
731
|
+
);
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
ui.success(
|
|
735
|
+
`Installed ${formatCount(result.installedSkills.length, "skill")} from ${result.namespace}`
|
|
736
|
+
);
|
|
737
|
+
console.log("");
|
|
738
|
+
ui.kvBlock([
|
|
739
|
+
{ key: "Skills", value: result.installedSkills.join(", ") },
|
|
740
|
+
{ key: "Scope", value: wizard.scope },
|
|
741
|
+
...wizard.scope === "project" ? [{ key: "Project", value: resolve2(wizard.projectRoot ?? ".") }] : [],
|
|
742
|
+
{ key: "Snapshot", value: result.snapshotId }
|
|
743
|
+
]);
|
|
744
|
+
}
|
|
745
|
+
async function handleInitCommand(opts = {}) {
|
|
746
|
+
const dbPath = getDbPath();
|
|
747
|
+
const hadExistingStore = existsSync3(dbPath);
|
|
748
|
+
const { homeDefaults } = await bootstrapLocalLibrary({
|
|
749
|
+
seedDefaultProfile: opts.defaultProfile !== false
|
|
750
|
+
});
|
|
751
|
+
const format = parseOutputFormat(opts.format);
|
|
752
|
+
if (format === "human" && hadExistingStore) {
|
|
753
|
+
const preference = getHarnessPreference();
|
|
754
|
+
ui.warn(
|
|
755
|
+
"~/.harnesstap already exists. Harness preferences stay unchanged unless you pass --harnesses, --main, or --aliases."
|
|
756
|
+
);
|
|
757
|
+
if (preference) {
|
|
758
|
+
ui.dim(
|
|
759
|
+
`Current defaults: ${registeredHarnessesOf(preference).join(", ") || "(none)"}`
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
console.log("");
|
|
763
|
+
}
|
|
764
|
+
const useWizard = shouldUseWizard({
|
|
765
|
+
interactive: opts.interactive,
|
|
766
|
+
noInteractive: opts.noInteractive,
|
|
767
|
+
format,
|
|
768
|
+
missingRequiredArgs: !opts.harnesses && !opts.main && !opts.aliases
|
|
769
|
+
});
|
|
770
|
+
const shouldSelectHarness = useWizard || Boolean(opts.harnesses) || Boolean(opts.main) || Boolean(opts.aliases);
|
|
771
|
+
const currentHarnessPreference = getHarnessPreference();
|
|
772
|
+
let savedHarnessPreference;
|
|
773
|
+
if (shouldSelectHarness) {
|
|
774
|
+
const selection = await resolveHarnessSelection({
|
|
775
|
+
harnesses: parseHarnessList(opts.harnesses),
|
|
776
|
+
main: opts.main,
|
|
777
|
+
aliases: parseHarnessList(opts.aliases),
|
|
778
|
+
nonInteractive: !useWizard,
|
|
779
|
+
current: currentHarnessPreference,
|
|
780
|
+
detected: homeDefaults.detected.map((result) => result.platformId),
|
|
781
|
+
message: "Select harnesses to keep in sync"
|
|
782
|
+
});
|
|
783
|
+
savedHarnessPreference = setHarnessPreference(selection);
|
|
784
|
+
}
|
|
785
|
+
if (format === "json") {
|
|
786
|
+
printJson({
|
|
787
|
+
home_defaults: homeDefaults.results,
|
|
788
|
+
tracked_directories: listResourceTrackedDirectories(),
|
|
789
|
+
database_path: getDbPath(),
|
|
790
|
+
...savedHarnessPreference ? { harness_preference: savedHarnessPreference } : {}
|
|
791
|
+
});
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
if (shouldSelectHarness && currentHarnessPreference) {
|
|
795
|
+
ui.warn(
|
|
796
|
+
`Existing harness defaults will be overwritten (${registeredHarnessesOf(currentHarnessPreference).join(", ") || "(none)"}).`
|
|
797
|
+
);
|
|
798
|
+
console.log("");
|
|
799
|
+
}
|
|
800
|
+
ui.success("HarnessTap initialized");
|
|
801
|
+
console.log("");
|
|
802
|
+
ui.kvBlock([
|
|
803
|
+
{ key: "Database", value: getDbPath() }
|
|
804
|
+
]);
|
|
805
|
+
console.log("");
|
|
806
|
+
ui.subheader("TRACKED DIRECTORIES");
|
|
807
|
+
console.log("");
|
|
808
|
+
printResourceTrackedDirectoriesList();
|
|
809
|
+
if (savedHarnessPreference) {
|
|
810
|
+
console.log("");
|
|
811
|
+
ui.kvBlock([
|
|
812
|
+
{ key: "HARNESSES", value: registeredHarnessesOf(savedHarnessPreference).join(", ") || "(none)" }
|
|
813
|
+
], { keyWidth: 14 });
|
|
814
|
+
}
|
|
815
|
+
printQuickStartGuide();
|
|
816
|
+
const canPromptCompletion = format === "human" && !opts.noInteractive && !process.argv.includes("--no-interactive") && Boolean(process.stdin.isTTY && process.stdout.isTTY) && !["1", "true", "yes"].includes(process.env.CI?.trim().toLowerCase() ?? "") && (opts.interactive === true || useWizard);
|
|
817
|
+
if (canPromptCompletion) {
|
|
818
|
+
try {
|
|
819
|
+
await maybePromptInitCompletionInstall({
|
|
820
|
+
format,
|
|
821
|
+
interactive: true
|
|
822
|
+
});
|
|
823
|
+
} catch (err) {
|
|
824
|
+
if (!isPromptCancellationError(err)) throw err;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
const canPromptCatalog = format === "human" && !opts.noInteractive && !process.argv.includes("--no-interactive") && Boolean(process.stdin.isTTY && process.stdout.isTTY) && !["1", "true", "yes"].includes(process.env.CI?.trim().toLowerCase() ?? "") && (opts.interactive === true || useWizard) && listPlugins().length === 0;
|
|
828
|
+
if (canPromptCatalog) {
|
|
829
|
+
try {
|
|
830
|
+
await maybePromptInitCatalogInstall({
|
|
831
|
+
interactive: true,
|
|
832
|
+
noInteractive: opts.noInteractive,
|
|
833
|
+
format
|
|
834
|
+
});
|
|
835
|
+
} catch (err) {
|
|
836
|
+
if (!isPromptCancellationError(err)) {
|
|
837
|
+
throw err;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
function registerInitCommands(root) {
|
|
843
|
+
const initCmd = root.command("init").description("Initialize the harnesstap database and config directory").option("--format <mode>", "Output format: human or json", "human").option("--harnesses <slugs>", "Comma-separated registered harness slugs").addOption(new Option("--main <slug>", "Deprecated: prepended to the registered set").hideHelp()).addOption(new Option("--aliases <slugs>", "Deprecated: appended to the registered set").hideHelp()).option("--no-default-profile", "Skip creating and activating the global default profile plugin").option(
|
|
844
|
+
"--interactive",
|
|
845
|
+
"Prompt for harness selection instead of relying on explicit flags"
|
|
846
|
+
).action(async (opts) => {
|
|
847
|
+
await handleInitCommand(opts);
|
|
848
|
+
});
|
|
849
|
+
initCmd.command("completion").argument("<shell>", "Target shell: bash, zsh, or fish (must match your interactive shell)").description(
|
|
850
|
+
"Print shell completion script to stdout (redirect into ~/.bashrc, ~/.zshrc, or fish completions)"
|
|
851
|
+
).action((shell) => {
|
|
852
|
+
try {
|
|
853
|
+
process.stdout.write(renderShellCompletion(shell, root));
|
|
854
|
+
} catch (err) {
|
|
855
|
+
process.exitCode = 1;
|
|
856
|
+
fail(err instanceof Error ? err.message : String(err));
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
root.command("add").argument("<source>", "GitHub owner/repo, Git URL, or local path").option("--skill <names>", "Skills to install (comma-separated)").option("--all", "Install all discovered skills").option("--harness <slugs>", "Target harnesses").option("--global", "Install to user home").option("--project [path]", "Install to project directory").option("--method <mode>", "symlink or copy", "symlink").option("--plugin <name>", "Combine into existing plugin").option("--create-plugin <name>", "Create plugin and attach skills").option("--list", "List discovered skills only").option("--dry-run", "Show plan without writing").option("-y, --yes", "Skip prompts").option("--format <mode>", "human or json", "human").description("Add skills from a remote or local source").action(async (source, opts) => {
|
|
860
|
+
try {
|
|
861
|
+
await handleAddCommand(source, opts);
|
|
862
|
+
} catch (err) {
|
|
863
|
+
if (isPromptCancellationError(err)) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
failCaught(err);
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
export {
|
|
871
|
+
registerInitCommands
|
|
872
|
+
};
|
|
873
|
+
//# sourceMappingURL=init-UJQTDHW7.js.map
|