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.
Files changed (202) hide show
  1. package/README.md +28 -15
  2. package/dist/apply-QSS4242W.js +67 -0
  3. package/dist/apply-QSS4242W.js.map +1 -0
  4. package/dist/approve-CNYQY6DC.js +181 -0
  5. package/dist/approve-CNYQY6DC.js.map +1 -0
  6. package/dist/audit-V4SUV7KA.js +434 -0
  7. package/dist/audit-V4SUV7KA.js.map +1 -0
  8. package/dist/auth-63FOHIQ3.js +220 -0
  9. package/dist/auth-63FOHIQ3.js.map +1 -0
  10. package/dist/bin.js +166 -0
  11. package/dist/bin.js.map +1 -0
  12. package/dist/chunk-2H7UOFLK.js +11 -0
  13. package/dist/chunk-2H7UOFLK.js.map +1 -0
  14. package/dist/chunk-2NE3QYMP.js +103 -0
  15. package/dist/chunk-2NE3QYMP.js.map +1 -0
  16. package/dist/chunk-2P2EOYEW.js +1140 -0
  17. package/dist/chunk-2P2EOYEW.js.map +1 -0
  18. package/dist/chunk-37E5M4JX.js +34 -0
  19. package/dist/chunk-37E5M4JX.js.map +1 -0
  20. package/dist/chunk-37LQQWMF.js +496 -0
  21. package/dist/chunk-37LQQWMF.js.map +1 -0
  22. package/dist/chunk-3FIWOI3H.js +98 -0
  23. package/dist/chunk-3FIWOI3H.js.map +1 -0
  24. package/dist/chunk-3PGC6OA3.js +540 -0
  25. package/dist/chunk-3PGC6OA3.js.map +1 -0
  26. package/dist/chunk-4IHKBIY3.js +118 -0
  27. package/dist/chunk-4IHKBIY3.js.map +1 -0
  28. package/dist/chunk-4ZUBRLSP.js +17 -0
  29. package/dist/chunk-4ZUBRLSP.js.map +1 -0
  30. package/dist/chunk-5F3LNDZG.js +9 -0
  31. package/dist/chunk-5F3LNDZG.js.map +1 -0
  32. package/dist/chunk-5TXI6BI2.js +1359 -0
  33. package/dist/chunk-5TXI6BI2.js.map +1 -0
  34. package/dist/chunk-6P5IO4BX.js +235 -0
  35. package/dist/chunk-6P5IO4BX.js.map +1 -0
  36. package/dist/chunk-ABXUKHAU.js +571 -0
  37. package/dist/chunk-ABXUKHAU.js.map +1 -0
  38. package/dist/chunk-AOUDSNRK.js +1357 -0
  39. package/dist/chunk-AOUDSNRK.js.map +1 -0
  40. package/dist/chunk-BNDJJAEI.js +311 -0
  41. package/dist/chunk-BNDJJAEI.js.map +1 -0
  42. package/dist/chunk-C2IWSFF5.js +818 -0
  43. package/dist/chunk-C2IWSFF5.js.map +1 -0
  44. package/dist/chunk-CHQGE2HF.js +283 -0
  45. package/dist/chunk-CHQGE2HF.js.map +1 -0
  46. package/dist/chunk-DEJLP7QJ.js +681 -0
  47. package/dist/chunk-DEJLP7QJ.js.map +1 -0
  48. package/dist/chunk-DJ6FN6EW.js +532 -0
  49. package/dist/chunk-DJ6FN6EW.js.map +1 -0
  50. package/dist/chunk-E4WRTRMH.js +1173 -0
  51. package/dist/chunk-E4WRTRMH.js.map +1 -0
  52. package/dist/chunk-E5QXNU3K.js +238 -0
  53. package/dist/chunk-E5QXNU3K.js.map +1 -0
  54. package/dist/chunk-EMTBGOR3.js +2959 -0
  55. package/dist/chunk-EMTBGOR3.js.map +1 -0
  56. package/dist/chunk-FFWYIGQ4.js +18 -0
  57. package/dist/chunk-FFWYIGQ4.js.map +1 -0
  58. package/dist/chunk-I6XFZLTJ.js +9 -0
  59. package/dist/chunk-I6XFZLTJ.js.map +1 -0
  60. package/dist/chunk-IHWAOIAU.js +172 -0
  61. package/dist/chunk-IHWAOIAU.js.map +1 -0
  62. package/dist/chunk-IHZUYG66.js +583 -0
  63. package/dist/chunk-IHZUYG66.js.map +1 -0
  64. package/dist/chunk-JQOKQKQT.js +158 -0
  65. package/dist/chunk-JQOKQKQT.js.map +1 -0
  66. package/dist/chunk-JRFUTIEH.js +426 -0
  67. package/dist/chunk-JRFUTIEH.js.map +1 -0
  68. package/dist/chunk-KCBI6JQC.js +115 -0
  69. package/dist/chunk-KCBI6JQC.js.map +1 -0
  70. package/dist/chunk-KDUQMINL.js +60 -0
  71. package/dist/chunk-KDUQMINL.js.map +1 -0
  72. package/dist/chunk-KLR2DURP.js +656 -0
  73. package/dist/chunk-KLR2DURP.js.map +1 -0
  74. package/dist/chunk-KRI4R7EM.js +25 -0
  75. package/dist/chunk-KRI4R7EM.js.map +1 -0
  76. package/dist/chunk-LYQMK6SV.js +87 -0
  77. package/dist/chunk-LYQMK6SV.js.map +1 -0
  78. package/dist/chunk-MK3Q37ZN.js +183 -0
  79. package/dist/chunk-MK3Q37ZN.js.map +1 -0
  80. package/dist/chunk-MSGAGV7B.js +346 -0
  81. package/dist/chunk-MSGAGV7B.js.map +1 -0
  82. package/dist/chunk-MZQRSERO.js +430 -0
  83. package/dist/chunk-MZQRSERO.js.map +1 -0
  84. package/dist/chunk-N3WIJXXM.js +691 -0
  85. package/dist/chunk-N3WIJXXM.js.map +1 -0
  86. package/dist/chunk-NAGAJ5UM.js +145 -0
  87. package/dist/chunk-NAGAJ5UM.js.map +1 -0
  88. package/dist/chunk-NFYPBTKO.js +302 -0
  89. package/dist/chunk-NFYPBTKO.js.map +1 -0
  90. package/dist/chunk-NPO2IG6G.js +491 -0
  91. package/dist/chunk-NPO2IG6G.js.map +1 -0
  92. package/dist/chunk-OS6NUIBJ.js +38 -0
  93. package/dist/chunk-OS6NUIBJ.js.map +1 -0
  94. package/dist/chunk-PFUK3HJ4.js +296 -0
  95. package/dist/chunk-PFUK3HJ4.js.map +1 -0
  96. package/dist/chunk-PMQ55GDB.js +115 -0
  97. package/dist/chunk-PMQ55GDB.js.map +1 -0
  98. package/dist/chunk-QIVE2YFJ.js +514 -0
  99. package/dist/chunk-QIVE2YFJ.js.map +1 -0
  100. package/dist/chunk-QKXD3EUF.js +691 -0
  101. package/dist/chunk-QKXD3EUF.js.map +1 -0
  102. package/dist/chunk-RNQYUWF6.js +32 -0
  103. package/dist/chunk-RNQYUWF6.js.map +1 -0
  104. package/dist/chunk-S2E4SSQV.js +41 -0
  105. package/dist/chunk-S2E4SSQV.js.map +1 -0
  106. package/dist/chunk-SN4BXX3B.js +186 -0
  107. package/dist/chunk-SN4BXX3B.js.map +1 -0
  108. package/dist/chunk-SNVAMWB7.js +40 -0
  109. package/dist/chunk-SNVAMWB7.js.map +1 -0
  110. package/dist/chunk-T5VRREN4.js +696 -0
  111. package/dist/chunk-T5VRREN4.js.map +1 -0
  112. package/dist/chunk-TKBMHZTS.js +10945 -0
  113. package/dist/chunk-TKBMHZTS.js.map +1 -0
  114. package/dist/chunk-TNJPTUE4.js +35 -0
  115. package/dist/chunk-TNJPTUE4.js.map +1 -0
  116. package/dist/chunk-TQ2NA4Z4.js +24 -0
  117. package/dist/chunk-TQ2NA4Z4.js.map +1 -0
  118. package/dist/chunk-TXXDMDPN.js +998 -0
  119. package/dist/chunk-TXXDMDPN.js.map +1 -0
  120. package/dist/chunk-UWXUBU7V.js +184 -0
  121. package/dist/chunk-UWXUBU7V.js.map +1 -0
  122. package/dist/chunk-UYRK2H24.js +141 -0
  123. package/dist/chunk-UYRK2H24.js.map +1 -0
  124. package/dist/chunk-V4IXIM3C.js +806 -0
  125. package/dist/chunk-V4IXIM3C.js.map +1 -0
  126. package/dist/chunk-VFHVXXP4.js +6438 -0
  127. package/dist/chunk-VFHVXXP4.js.map +1 -0
  128. package/dist/chunk-VQVUJYYY.js +244 -0
  129. package/dist/chunk-VQVUJYYY.js.map +1 -0
  130. package/dist/chunk-VZQG2JDV.js +9 -0
  131. package/dist/chunk-VZQG2JDV.js.map +1 -0
  132. package/dist/chunk-W7HQ5X3S.js +610 -0
  133. package/dist/chunk-W7HQ5X3S.js.map +1 -0
  134. package/dist/chunk-WMSQAFK5.js +65 -0
  135. package/dist/chunk-WMSQAFK5.js.map +1 -0
  136. package/dist/chunk-WMYTBJPB.js +364 -0
  137. package/dist/chunk-WMYTBJPB.js.map +1 -0
  138. package/dist/chunk-WNLFNCOH.js +7795 -0
  139. package/dist/chunk-WNLFNCOH.js.map +1 -0
  140. package/dist/chunk-WRX7CB2M.js +6448 -0
  141. package/dist/chunk-WRX7CB2M.js.map +1 -0
  142. package/dist/chunk-XGTTOO4R.js +84 -0
  143. package/dist/chunk-XGTTOO4R.js.map +1 -0
  144. package/dist/chunk-YSXRBUR4.js +682 -0
  145. package/dist/chunk-YSXRBUR4.js.map +1 -0
  146. package/dist/chunk-YTC2EG64.js +1759 -0
  147. package/dist/chunk-YTC2EG64.js.map +1 -0
  148. package/dist/compile-J3UGQSS3.js +161 -0
  149. package/dist/compile-J3UGQSS3.js.map +1 -0
  150. package/dist/config-5BPSZND3.js +438 -0
  151. package/dist/config-5BPSZND3.js.map +1 -0
  152. package/dist/doctor-BVFKLJVO.js +111 -0
  153. package/dist/doctor-BVFKLJVO.js.map +1 -0
  154. package/dist/environment-3RI5H32O.js +2745 -0
  155. package/dist/environment-3RI5H32O.js.map +1 -0
  156. package/dist/github-YFJQVH5K.js +114 -0
  157. package/dist/github-YFJQVH5K.js.map +1 -0
  158. package/dist/harness-ECGHPEKA.js +746 -0
  159. package/dist/harness-ECGHPEKA.js.map +1 -0
  160. package/dist/help-ELPNPPEM.js +2079 -0
  161. package/dist/help-ELPNPPEM.js.map +1 -0
  162. package/dist/help-UL5XLY3I.js +1892 -0
  163. package/dist/help-UL5XLY3I.js.map +1 -0
  164. package/dist/index.d.ts +164 -1
  165. package/dist/index.js +50 -59246
  166. package/dist/index.js.map +1 -1
  167. package/dist/init-UJQTDHW7.js +873 -0
  168. package/dist/init-UJQTDHW7.js.map +1 -0
  169. package/dist/lock-XUMJ63NZ.js +455 -0
  170. package/dist/lock-XUMJ63NZ.js.map +1 -0
  171. package/dist/marketplace-ZUMOLVXE.js +495 -0
  172. package/dist/marketplace-ZUMOLVXE.js.map +1 -0
  173. package/dist/mcp-RZA5O2ND.js +202 -0
  174. package/dist/mcp-RZA5O2ND.js.map +1 -0
  175. package/dist/migrate-CYQI2FH6.js +1043 -0
  176. package/dist/migrate-CYQI2FH6.js.map +1 -0
  177. package/dist/open-AWOAWLKO.js +32 -0
  178. package/dist/open-AWOAWLKO.js.map +1 -0
  179. package/dist/pack-2QD5ZUIO.js +99 -0
  180. package/dist/pack-2QD5ZUIO.js.map +1 -0
  181. package/dist/plugin-GQSSSFX4.js +64 -0
  182. package/dist/plugin-GQSSSFX4.js.map +1 -0
  183. package/dist/plugin-from-project-SIQUFYIO.js +16 -0
  184. package/dist/plugin-from-project-SIQUFYIO.js.map +1 -0
  185. package/dist/policy-CT4JRCJI.js +105 -0
  186. package/dist/policy-CT4JRCJI.js.map +1 -0
  187. package/dist/profile-4JQ6LECP.js +1886 -0
  188. package/dist/profile-4JQ6LECP.js.map +1 -0
  189. package/dist/project-JG7QWXRG.js +1392 -0
  190. package/dist/project-JG7QWXRG.js.map +1 -0
  191. package/dist/resource-QRMR6CSD.js +555 -0
  192. package/dist/resource-QRMR6CSD.js.map +1 -0
  193. package/dist/version-LZ5POOXY.js +17 -0
  194. package/dist/version-LZ5POOXY.js.map +1 -0
  195. package/package.json +21 -14
  196. package/schemas/ap-package.v1.json +36 -0
  197. package/schemas/fixtures/catalog-missing-schema.ap.json +13 -0
  198. package/schemas/fixtures/confidence.ap.json +13 -0
  199. package/schemas/fixtures/context7.ap.json +13 -0
  200. package/schemas/fixtures/minimal-with-schema.ap.json +13 -0
  201. package/schemas/fixtures/superpowers.ap.json +13 -0
  202. package/schemas/fixtures/third-party-skills.ap.json +13 -0
@@ -0,0 +1,682 @@
1
+ import {
2
+ catalogPluginKey,
3
+ renderCatalogListViewport,
4
+ renderCatalogPluginShow,
5
+ renderCatalogSearchViewport
6
+ } from "./chunk-6P5IO4BX.js";
7
+ import {
8
+ useTerminalSize
9
+ } from "./chunk-S2E4SSQV.js";
10
+ import {
11
+ buildHelpLine,
12
+ clampActiveIndex,
13
+ interactivePromptTheme,
14
+ isEscapeKey,
15
+ isSearchCharacter
16
+ } from "./chunk-3FIWOI3H.js";
17
+ import {
18
+ projectNameFromUrl
19
+ } from "./chunk-WNLFNCOH.js";
20
+ import {
21
+ APM_MANIFEST_FILENAME
22
+ } from "./chunk-W7HQ5X3S.js";
23
+ import {
24
+ createImportedSnapshot,
25
+ detectPlatforms,
26
+ hasPluginSourceLayout
27
+ } from "./chunk-WRX7CB2M.js";
28
+ import {
29
+ getAllPlatforms,
30
+ normalizeResourceInput,
31
+ skillMetadataFromDir,
32
+ upsertResource
33
+ } from "./chunk-TKBMHZTS.js";
34
+ import {
35
+ discoverSkillPackage,
36
+ refreshGitSource
37
+ } from "./chunk-TXXDMDPN.js";
38
+ import {
39
+ theme
40
+ } from "./chunk-ABXUKHAU.js";
41
+ import {
42
+ formatCanonicalPublishedSelectorWithVersion
43
+ } from "./chunk-2P2EOYEW.js";
44
+
45
+ // src/services/repo-profile.ts
46
+ import { existsSync } from "fs";
47
+ import { join } from "path";
48
+ function classifyRepo(rootPath) {
49
+ const profiles = [];
50
+ if (discoverSkillPackage(rootPath).length > 0) {
51
+ profiles.push("skill-package");
52
+ }
53
+ if (hasPluginSourceLayout(rootPath)) {
54
+ profiles.push("plugin-source");
55
+ }
56
+ if (existsSync(join(rootPath, APM_MANIFEST_FILENAME))) {
57
+ profiles.push("project-config");
58
+ }
59
+ if (detectPlatforms(rootPath).length > 0) {
60
+ profiles.push("harness-project");
61
+ }
62
+ const primary = profiles.includes("skill-package") ? "skill-package" : profiles.includes("plugin-source") ? "plugin-source" : profiles.includes("project-config") ? "project-config" : profiles.includes("harness-project") ? "harness-project" : "unknown";
63
+ return { primary, profiles };
64
+ }
65
+
66
+ // src/services/source-resolver.ts
67
+ import { existsSync as existsSync2 } from "fs";
68
+ import { basename, resolve } from "path";
69
+ var GITHUB_SHORTHAND = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
70
+ function parseOwnerRepo(label) {
71
+ const [owner, repo] = label.split("/");
72
+ if (!owner || !repo) {
73
+ throw new Error(`Invalid source: ${label}`);
74
+ }
75
+ return { owner, repo };
76
+ }
77
+ function resolveRemoteSource(input) {
78
+ const trimmed = input.trim();
79
+ if (existsSync2(trimmed)) {
80
+ return {
81
+ kind: "local",
82
+ path: resolve(trimmed),
83
+ label: basename(resolve(trimmed))
84
+ };
85
+ }
86
+ if (GITHUB_SHORTHAND.test(trimmed)) {
87
+ const { owner, repo } = parseOwnerRepo(trimmed);
88
+ return {
89
+ kind: "git",
90
+ url: `https://github.com/${owner}/${repo}.git`,
91
+ label: trimmed,
92
+ owner,
93
+ repo
94
+ };
95
+ }
96
+ if (trimmed.startsWith("git@") || trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
97
+ const label = projectNameFromUrl(trimmed);
98
+ const { owner, repo } = parseOwnerRepo(label);
99
+ const url = trimmed.endsWith(".git") ? trimmed : `${trimmed.replace(/\/$/, "")}.git`;
100
+ return { kind: "git", url, label, owner, repo };
101
+ }
102
+ throw new Error(
103
+ `Unrecognized source "${input}". Use owner/repo, a Git URL, or a local path.`
104
+ );
105
+ }
106
+ function sourceCacheDir(harnesstapDir, owner, repo) {
107
+ return `${harnesstapDir}/cache/sources/${owner}/${repo}`;
108
+ }
109
+
110
+ // src/services/skill-package-resolve.ts
111
+ var DEFAULT_EXCLUDED_SKILL_CATEGORIES = ["dbt-migration"];
112
+ function skillPackageHint(primary) {
113
+ return `Source is not a skill package (detected: ${primary}). Use a repo with skills/ or .agents/skills/ containing SKILL.md files.`;
114
+ }
115
+ function defaultInteractiveSkillNames(discovered, excludeCategories = DEFAULT_EXCLUDED_SKILL_CATEGORIES) {
116
+ const excluded = new Set(excludeCategories);
117
+ return discovered.filter((skill) => !excluded.has(skill.category)).map((skill) => skill.name);
118
+ }
119
+ function resolveSkillPackageCheckout(source, harnesstapDir) {
120
+ const resolved = resolveRemoteSource(source);
121
+ let checkoutRoot;
122
+ let gitUrl;
123
+ let gitSha;
124
+ if (resolved.kind === "git") {
125
+ const cacheDir = sourceCacheDir(
126
+ harnesstapDir,
127
+ resolved.owner,
128
+ resolved.repo
129
+ );
130
+ const refresh = refreshGitSource({
131
+ url: resolved.url,
132
+ targetDir: cacheDir
133
+ });
134
+ if (!refresh.ok) {
135
+ throw new Error(refresh.message);
136
+ }
137
+ checkoutRoot = cacheDir;
138
+ gitUrl = resolved.url;
139
+ gitSha = refresh.sha;
140
+ } else {
141
+ checkoutRoot = resolved.path;
142
+ }
143
+ const classification = classifyRepo(checkoutRoot);
144
+ if (classification.primary !== "skill-package") {
145
+ throw new Error(skillPackageHint(classification.primary));
146
+ }
147
+ const discovered = discoverSkillPackage(checkoutRoot);
148
+ if (discovered.length === 0) {
149
+ throw new Error(`No skills found in skill package: ${checkoutRoot}`);
150
+ }
151
+ return {
152
+ checkoutRoot,
153
+ namespace: resolved.label,
154
+ gitUrl,
155
+ gitSha,
156
+ discovered
157
+ };
158
+ }
159
+ function resolveSelectedSkills(discovered, options) {
160
+ const discoveredNames = new Set(discovered.map((skill) => skill.name));
161
+ const excludeCategories = new Set(options.excludeCategories ?? []);
162
+ const applyCategoryExclusions = (skills) => {
163
+ if (excludeCategories.size === 0) {
164
+ return skills;
165
+ }
166
+ return skills.filter((skill) => !excludeCategories.has(skill.category));
167
+ };
168
+ if (options.all) {
169
+ const selected = applyCategoryExclusions(discovered);
170
+ if (selected.length === 0) {
171
+ throw new Error("No skills selected after applying category exclusions.");
172
+ }
173
+ return selected;
174
+ }
175
+ if (options.skillNames && options.skillNames.length > 0) {
176
+ const missing = options.skillNames.filter((name) => !discoveredNames.has(name));
177
+ if (missing.length > 0) {
178
+ throw new Error(`Skill(s) not found: ${missing.join(", ")}`);
179
+ }
180
+ const selected = new Set(options.skillNames);
181
+ const skills = discovered.filter((skill) => selected.has(skill.name));
182
+ const filtered = applyCategoryExclusions(skills);
183
+ if (filtered.length === 0) {
184
+ throw new Error("No skills selected after applying category exclusions.");
185
+ }
186
+ return filtered;
187
+ }
188
+ throw new Error(
189
+ "No skills selected. Pass --skill <names>, --all, or use the wizard."
190
+ );
191
+ }
192
+
193
+ // src/services/skill-package-import.ts
194
+ import { readFileSync } from "fs";
195
+ import { isAbsolute, join as join2 } from "path";
196
+ import matter from "gray-matter";
197
+ function assertSafeResourceName(name, filePath) {
198
+ const trimmed = name.trim();
199
+ if (trimmed.length === 0 || trimmed === "." || trimmed === ".." || trimmed.includes("/") || trimmed.includes("\\") || isAbsolute(trimmed)) {
200
+ throw new Error(`Invalid imported resource name in ${filePath}: ${name}`);
201
+ }
202
+ return trimmed;
203
+ }
204
+ function resolvePluginDisplayName(sourceLabel, pluginDisplayName) {
205
+ if (pluginDisplayName?.trim()) {
206
+ return pluginDisplayName.trim();
207
+ }
208
+ const segment = sourceLabel.split("/").pop();
209
+ return segment?.trim() || sourceLabel;
210
+ }
211
+ function buildCategoriesMap(skills) {
212
+ const categories = {};
213
+ for (const skill of skills) {
214
+ let bucket = categories[skill.category];
215
+ if (!bucket) {
216
+ bucket = [];
217
+ categories[skill.category] = bucket;
218
+ }
219
+ bucket.push(skill.name);
220
+ }
221
+ for (const names of Object.values(categories)) {
222
+ names.sort((a, b) => a.localeCompare(b));
223
+ }
224
+ return categories;
225
+ }
226
+ function buildProvenance(input) {
227
+ return {
228
+ source_kind: "skill-package",
229
+ source_label: input.sourceLabel,
230
+ plugin_name: input.pluginName,
231
+ source_plugin_kind: "skill-package",
232
+ relative_path: input.relativePath,
233
+ imported_at: input.importedAt
234
+ };
235
+ }
236
+ function buildSkillResource(input) {
237
+ const skillPath = join2(input.rootPath, input.skill.skillMdRelative);
238
+ const raw = readFileSync(skillPath, "utf-8");
239
+ let parsed;
240
+ try {
241
+ parsed = matter(raw);
242
+ } catch {
243
+ throw new Error(`Malformed resource frontmatter: ${skillPath}`);
244
+ }
245
+ if (raw.startsWith("---") && parsed.content === raw) {
246
+ throw new Error(`Malformed resource frontmatter: ${skillPath}`);
247
+ }
248
+ const skillDir = join2(input.rootPath, input.skill.skillDirRelative);
249
+ const provenance = buildProvenance({
250
+ importedAt: input.importedAt,
251
+ sourceLabel: input.sourceLabel,
252
+ pluginName: input.pluginName,
253
+ relativePath: input.skill.skillMdRelative
254
+ });
255
+ const metadata = {
256
+ ...skillMetadataFromDir(skillDir),
257
+ imported_from: provenance
258
+ };
259
+ return {
260
+ type: "skill",
261
+ name: assertSafeResourceName(
262
+ typeof parsed.data.name === "string" && parsed.data.name.trim() ? parsed.data.name : input.skill.name,
263
+ skillPath
264
+ ),
265
+ description: typeof parsed.data.description === "string" ? parsed.data.description : "",
266
+ content: parsed.content.trim(),
267
+ source: input.skill.skillMdRelative,
268
+ metadata
269
+ };
270
+ }
271
+ async function importSkillPackage(options) {
272
+ const { rootPath, sourceLabel, gitUrl, gitSha, pluginDisplayName } = options;
273
+ const skills = discoverSkillPackage(rootPath);
274
+ if (skills.length === 0) {
275
+ throw new Error(`No skills found in skill package: ${rootPath}`);
276
+ }
277
+ const pluginName = resolvePluginDisplayName(sourceLabel, pluginDisplayName);
278
+ const importedAt = (/* @__PURE__ */ new Date()).toISOString();
279
+ const originRef = `${sourceLabel}@${gitSha ?? "local"}`;
280
+ const resourceInputs = skills.map(
281
+ (skill) => buildSkillResource({
282
+ rootPath,
283
+ skill,
284
+ sourceLabel,
285
+ pluginName,
286
+ importedAt
287
+ })
288
+ );
289
+ const resources = [];
290
+ const resourceIds = [];
291
+ for (const resource of resourceInputs) {
292
+ const upserted = upsertResource(
293
+ normalizeResourceInput({
294
+ ...resource,
295
+ namespace: sourceLabel,
296
+ origin_kind: "local_snapshot",
297
+ origin_ref: originRef
298
+ }),
299
+ { policy: "overwrite" }
300
+ );
301
+ const saved = upserted.action === "skipped" ? upserted.existing : upserted.resource;
302
+ resourceIds.push(saved.id);
303
+ resources.push(saved);
304
+ }
305
+ const snapshot = createImportedSnapshot({
306
+ source_kind: "skill-package",
307
+ source_label: sourceLabel,
308
+ plugin_name: pluginName,
309
+ resource_ids: resourceIds,
310
+ metadata: {
311
+ git_url: gitUrl,
312
+ git_sha: gitSha,
313
+ categories: buildCategoriesMap(skills)
314
+ }
315
+ });
316
+ return { snapshot, resources };
317
+ }
318
+
319
+ // src/services/skill-install.ts
320
+ import { cpSync, existsSync as existsSync3, mkdirSync, rmSync, symlinkSync } from "fs";
321
+ import { dirname, join as join3, relative, resolve as resolve2 } from "path";
322
+ function resolveConfiguredPath(baseRoot, configured) {
323
+ return configured.startsWith("~/") ? join3(baseRoot, configured.slice(2)) : join3(baseRoot, configured);
324
+ }
325
+ function resolveGlobalSkillPath(homeRoot, platformId) {
326
+ const platform = getAllPlatforms().find((p) => p.id === platformId);
327
+ const configured = platform?.globalPaths.skills;
328
+ if (!configured) return void 0;
329
+ return resolveConfiguredPath(homeRoot, configured);
330
+ }
331
+ function resolveProjectSkillPath(projectRoot, platformId) {
332
+ const platform = getAllPlatforms().find((p) => p.id === platformId);
333
+ const configured = platform?.projectPaths.skills;
334
+ if (!configured) return void 0;
335
+ return join3(projectRoot, configured);
336
+ }
337
+ function ensureSymlink(linkPath, targetPath) {
338
+ mkdirSync(dirname(linkPath), { recursive: true });
339
+ if (existsSync3(linkPath)) {
340
+ rmSync(linkPath, { recursive: true, force: true });
341
+ }
342
+ symlinkSync(resolve2(targetPath), linkPath);
343
+ }
344
+ function installSkillAtPath(linkPath, targetPath, method) {
345
+ if (method === "copy") {
346
+ mkdirSync(linkPath, { recursive: true });
347
+ cpSync(targetPath, linkPath, { recursive: true });
348
+ return;
349
+ }
350
+ ensureSymlink(linkPath, targetPath);
351
+ }
352
+ function resolveEffectiveMethod(method, materializationStrategy) {
353
+ if (materializationStrategy === "copy") {
354
+ return "copy";
355
+ }
356
+ if (materializationStrategy === "symlink-preferred") {
357
+ return "symlink";
358
+ }
359
+ return method;
360
+ }
361
+ function relativeFromRoot(root, absolutePath) {
362
+ const prefix = root.endsWith("/") ? root : `${root}/`;
363
+ return absolutePath.startsWith(prefix) ? absolutePath.slice(prefix.length) : relative(root, absolutePath);
364
+ }
365
+ async function installSkillsToGlobal(options) {
366
+ const installed = [];
367
+ const files = [];
368
+ for (const skill of options.skills) {
369
+ const sourceDir = join3(options.checkoutRoot, skill.skillDirRelative);
370
+ const hubDir = join3(options.homeRoot, ".agents/skills", skill.name);
371
+ installSkillAtPath(hubDir, sourceDir, options.method);
372
+ files.push(join3(".agents/skills", skill.name));
373
+ installed.push(skill.name);
374
+ for (const harness of options.harnesses) {
375
+ const targetRoot = resolveGlobalSkillPath(options.homeRoot, harness);
376
+ if (!targetRoot) continue;
377
+ const targetDir = join3(targetRoot, skill.name);
378
+ if (targetDir === hubDir) continue;
379
+ installSkillAtPath(targetDir, hubDir, options.method);
380
+ files.push(relativeFromRoot(options.homeRoot, targetDir));
381
+ }
382
+ }
383
+ return { installed, files };
384
+ }
385
+ async function installSkillsToProject(options) {
386
+ const effectiveMethod = resolveEffectiveMethod(options.method, options.materializationStrategy);
387
+ const installed = [];
388
+ const files = [];
389
+ for (const skill of options.skills) {
390
+ const sourceDir = join3(options.checkoutRoot, skill.skillDirRelative);
391
+ const hubDir = join3(options.projectRoot, ".agents/skills", skill.name);
392
+ installSkillAtPath(hubDir, sourceDir, effectiveMethod);
393
+ files.push(join3(".agents/skills", skill.name));
394
+ installed.push(skill.name);
395
+ for (const harness of options.harnesses) {
396
+ const targetRoot = resolveProjectSkillPath(options.projectRoot, harness);
397
+ if (!targetRoot) continue;
398
+ const targetDir = join3(targetRoot, skill.name);
399
+ if (targetDir === hubDir) continue;
400
+ installSkillAtPath(targetDir, hubDir, effectiveMethod);
401
+ files.push(relativeFromRoot(options.projectRoot, targetDir));
402
+ }
403
+ }
404
+ return { installed, files };
405
+ }
406
+
407
+ // src/services/wizards/prompts/hooks/use-debounced-remote-search.ts
408
+ import { useEffect, useRef, useState } from "@inquirer/core";
409
+ function createDebouncedRemoteSearchRunner(config) {
410
+ const debounceMs = config.debounceMs ?? 300;
411
+ const requestRef = { current: 0 };
412
+ const debounceRef = { current: null };
413
+ async function runSearch(nextQuery) {
414
+ const requestId = ++requestRef.current;
415
+ config.setLoading(true);
416
+ config.setError(null);
417
+ try {
418
+ const results = await config.searchFn(nextQuery, config.limitFor(nextQuery));
419
+ if (requestId !== requestRef.current) {
420
+ return;
421
+ }
422
+ config.setItems(results);
423
+ } catch (searchError) {
424
+ if (requestId !== requestRef.current) {
425
+ return;
426
+ }
427
+ config.setItems([]);
428
+ config.setError(searchError instanceof Error ? searchError.message : String(searchError));
429
+ } finally {
430
+ if (requestId === requestRef.current) {
431
+ config.setLoading(false);
432
+ }
433
+ }
434
+ }
435
+ function scheduleSearch(nextQuery) {
436
+ if (debounceRef.current) {
437
+ clearTimeout(debounceRef.current);
438
+ }
439
+ debounceRef.current = setTimeout(() => {
440
+ void runSearch(nextQuery);
441
+ }, debounceMs);
442
+ }
443
+ function invalidate() {
444
+ requestRef.current += 1;
445
+ if (debounceRef.current) {
446
+ clearTimeout(debounceRef.current);
447
+ debounceRef.current = null;
448
+ }
449
+ }
450
+ return { runSearch, scheduleSearch, invalidate };
451
+ }
452
+ function useDebouncedRemoteSearch(config) {
453
+ const [items, setItems] = useState([]);
454
+ const [loading, setLoading] = useState(true);
455
+ const [error, setError] = useState(null);
456
+ const runnerRef = useRef(null);
457
+ const limitForRef = useRef(config.limitFor);
458
+ limitForRef.current = config.limitFor;
459
+ if (!runnerRef.current) {
460
+ runnerRef.current = createDebouncedRemoteSearchRunner({
461
+ debounceMs: config.debounceMs,
462
+ limitFor: (query) => limitForRef.current(query),
463
+ searchFn: config.searchFn,
464
+ setItems,
465
+ setLoading,
466
+ setError
467
+ });
468
+ }
469
+ const { runSearch, scheduleSearch, invalidate } = runnerRef.current;
470
+ useEffect(() => {
471
+ void runSearch(config.initialQuery ?? "");
472
+ return invalidate;
473
+ }, []);
474
+ return { items, loading, error, scheduleSearch };
475
+ }
476
+
477
+ // src/services/wizards/prompts/create-remote-catalog-list-prompt.ts
478
+ import {
479
+ createPrompt,
480
+ ExitPromptError,
481
+ isBackspaceKey,
482
+ isDownKey,
483
+ isEnterKey,
484
+ isSpaceKey,
485
+ isUpKey,
486
+ makeTheme,
487
+ useKeypress,
488
+ usePrefix,
489
+ useState as useState2
490
+ } from "@inquirer/core";
491
+ function toSelection(plugin) {
492
+ return {
493
+ orgSlug: plugin.orgSlug,
494
+ catalogSlug: plugin.catalogSlug,
495
+ slug: plugin.slug,
496
+ version: plugin.latestVersion,
497
+ selector: formatCanonicalPublishedSelectorWithVersion({
498
+ org: plugin.orgSlug,
499
+ catalog: plugin.catalogSlug,
500
+ name: plugin.slug,
501
+ version: plugin.latestVersion ?? void 0
502
+ })
503
+ };
504
+ }
505
+ var createRemoteCatalogListPrompt = createPrompt((config, done) => {
506
+ const isApplyMode = config.mode.kind === "apply";
507
+ const promptTheme = makeTheme(interactivePromptTheme, {});
508
+ const prefix = usePrefix({ status: "idle", theme: promptTheme });
509
+ const [query, setQuery] = useState2(config.initialQuery ?? "");
510
+ const [active, setActive] = useState2(0);
511
+ const [checkedPlugins, setCheckedPlugins] = useState2(
512
+ () => /* @__PURE__ */ new Map()
513
+ );
514
+ const [view, setView] = useState2("browse");
515
+ const [showingPlugin, setShowingPlugin] = useState2(null);
516
+ const [pendingExitMessage, setPendingExitMessage] = useState2(null);
517
+ const { width: terminalWidth, height: terminalRows } = useTerminalSize();
518
+ const { items: plugins, loading, error, scheduleSearch } = useDebouncedRemoteSearch({
519
+ initialQuery: config.initialQuery,
520
+ limitFor: (nextQuery) => nextQuery.trim() ? 25 : 10,
521
+ searchFn: (nextQuery, limit) => config.listPlugins({ q: nextQuery, limit })
522
+ });
523
+ const clampedActive = clampActiveIndex(active, plugins.length);
524
+ const activePlugin = plugins[clampedActive];
525
+ const activePluginKey = activePlugin ? catalogPluginKey(activePlugin) : void 0;
526
+ function togglePlugin(plugin) {
527
+ const key = catalogPluginKey(plugin);
528
+ const next = new Map(checkedPlugins);
529
+ if (next.has(key)) {
530
+ next.delete(key);
531
+ } else {
532
+ next.set(key, plugin);
533
+ }
534
+ setCheckedPlugins(next);
535
+ }
536
+ function selectVisiblePlugins() {
537
+ const next = new Map(checkedPlugins);
538
+ for (const plugin of plugins) {
539
+ next.set(catalogPluginKey(plugin), plugin);
540
+ }
541
+ setCheckedPlugins(next);
542
+ }
543
+ function clearVisiblePlugins() {
544
+ const next = new Map(checkedPlugins);
545
+ for (const plugin of plugins) {
546
+ next.delete(catalogPluginKey(plugin));
547
+ }
548
+ setCheckedPlugins(next);
549
+ }
550
+ function finishInstall(plugin) {
551
+ const result = toSelection(plugin);
552
+ done(result);
553
+ }
554
+ function finishApply() {
555
+ const result = {
556
+ selections: [...checkedPlugins.values()].map(toSelection)
557
+ };
558
+ done(result);
559
+ }
560
+ useKeypress((key) => {
561
+ if (isApplyMode && view === "show") {
562
+ if (isEscapeKey(key)) {
563
+ setView("browse");
564
+ setShowingPlugin(null);
565
+ }
566
+ return;
567
+ }
568
+ if (isEscapeKey(key)) {
569
+ setPendingExitMessage(
570
+ isApplyMode ? "Catalog search cancelled." : "Catalog browse cancelled."
571
+ );
572
+ return;
573
+ }
574
+ if (isApplyMode && key.ctrl && key.name === "s") {
575
+ if (checkedPlugins.size > 0) {
576
+ finishApply();
577
+ }
578
+ return;
579
+ }
580
+ if (isEnterKey(key)) {
581
+ if (!activePlugin) {
582
+ return;
583
+ }
584
+ if (isApplyMode) {
585
+ setShowingPlugin(activePlugin);
586
+ setView("show");
587
+ } else {
588
+ finishInstall(activePlugin);
589
+ }
590
+ return;
591
+ }
592
+ if (plugins.length > 0 && (isUpKey(key) || isDownKey(key))) {
593
+ const direction = isUpKey(key) ? -1 : 1;
594
+ setActive(clampActiveIndex(clampedActive + direction, plugins.length));
595
+ return;
596
+ }
597
+ if (isApplyMode && plugins.length > 0 && isSpaceKey(key) && activePlugin) {
598
+ togglePlugin(activePlugin);
599
+ return;
600
+ }
601
+ if (isApplyMode && key.ctrl && key.name === "a") {
602
+ selectVisiblePlugins();
603
+ return;
604
+ }
605
+ if (isApplyMode && key.ctrl && key.name === "x") {
606
+ clearVisiblePlugins();
607
+ return;
608
+ }
609
+ if (isBackspaceKey(key)) {
610
+ const nextQuery = query.slice(0, -1);
611
+ setQuery(nextQuery);
612
+ setActive(0);
613
+ scheduleSearch(nextQuery);
614
+ return;
615
+ }
616
+ if (isSearchCharacter(key)) {
617
+ const nextQuery = query + key.sequence;
618
+ setQuery(nextQuery);
619
+ setActive(0);
620
+ scheduleSearch(nextQuery);
621
+ }
622
+ });
623
+ if (pendingExitMessage) {
624
+ throw new ExitPromptError(pendingExitMessage);
625
+ }
626
+ if (isApplyMode && view === "show" && showingPlugin) {
627
+ const helpLine2 = buildHelpLine([["esc", "back"]]);
628
+ return [renderCatalogPluginShow(showingPlugin), "", helpLine2].join("\n");
629
+ }
630
+ const helpLine = isApplyMode ? buildHelpLine([
631
+ ["\u2191\u2193", "navigate"],
632
+ ["space", "toggle"],
633
+ ["type", "search"],
634
+ ["\u232B", "erase"],
635
+ ["\u23CE", "show"],
636
+ ["ctrl+s", "apply"],
637
+ ["esc", "cancel"],
638
+ ["ctrl+a", "all"],
639
+ ["ctrl+x", "none"]
640
+ ]) : buildHelpLine([
641
+ ["\u2191\u2193", "select"],
642
+ ["type", "search"],
643
+ ["\u232B", "erase"],
644
+ ["\u23CE", "install"],
645
+ ["esc", "cancel"]
646
+ ]);
647
+ const tableSection = error ? theme.danger(error) : isApplyMode ? renderCatalogSearchViewport(plugins, new Set(checkedPlugins.keys()), {
648
+ activePluginKey,
649
+ activeIndex: clampedActive,
650
+ terminalRows,
651
+ maxWidth: terminalWidth
652
+ }) : renderCatalogListViewport(plugins, {
653
+ activeIndex: clampedActive,
654
+ terminalRows,
655
+ maxWidth: terminalWidth
656
+ });
657
+ return [
658
+ `${prefix} ${promptTheme.style.message(config.message, "idle")}`,
659
+ theme.muted(`Catalog: ${config.scopeLabel}`),
660
+ ...isApplyMode ? [theme.muted("Apply writes harness files: choose project or global scope after selecting")] : [],
661
+ `${theme.label("Search:")} ${query ? theme.entity(query) : theme.muted("(type to filter)")}`,
662
+ ...isApplyMode ? [`Selected: ${checkedPlugins.size} to apply`] : [],
663
+ ...loading && plugins.length === 0 ? [theme.muted("Loading plugins...")] : [],
664
+ "",
665
+ tableSection,
666
+ "",
667
+ helpLine
668
+ ].join("\n");
669
+ });
670
+
671
+ export {
672
+ useDebouncedRemoteSearch,
673
+ createRemoteCatalogListPrompt,
674
+ importSkillPackage,
675
+ installSkillsToGlobal,
676
+ installSkillsToProject,
677
+ DEFAULT_EXCLUDED_SKILL_CATEGORIES,
678
+ defaultInteractiveSkillNames,
679
+ resolveSkillPackageCheckout,
680
+ resolveSelectedSkills
681
+ };
682
+ //# sourceMappingURL=chunk-YSXRBUR4.js.map