harnesstap 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +28 -15
  2. package/dist/apply-2GRNKR5H.js +67 -0
  3. package/dist/apply-2GRNKR5H.js.map +1 -0
  4. package/dist/approve-KQNCNH2R.js +181 -0
  5. package/dist/approve-KQNCNH2R.js.map +1 -0
  6. package/dist/audit-SLYOZCMI.js +434 -0
  7. package/dist/audit-SLYOZCMI.js.map +1 -0
  8. package/dist/auth-3IEVICFT.js +220 -0
  9. package/dist/auth-3IEVICFT.js.map +1 -0
  10. package/dist/bin.js +166 -0
  11. package/dist/bin.js.map +1 -0
  12. package/dist/chunk-2EIJYDNI.js +10945 -0
  13. package/dist/chunk-2EIJYDNI.js.map +1 -0
  14. package/dist/chunk-2H7UOFLK.js +11 -0
  15. package/dist/chunk-2H7UOFLK.js.map +1 -0
  16. package/dist/chunk-37E5M4JX.js +34 -0
  17. package/dist/chunk-37E5M4JX.js.map +1 -0
  18. package/dist/chunk-3FIWOI3H.js +98 -0
  19. package/dist/chunk-3FIWOI3H.js.map +1 -0
  20. package/dist/chunk-3IWTJCPA.js +6448 -0
  21. package/dist/chunk-3IWTJCPA.js.map +1 -0
  22. package/dist/chunk-3IZ7SEGT.js +346 -0
  23. package/dist/chunk-3IZ7SEGT.js.map +1 -0
  24. package/dist/chunk-3RBYT7QN.js +540 -0
  25. package/dist/chunk-3RBYT7QN.js.map +1 -0
  26. package/dist/chunk-4KNQZDZC.js +115 -0
  27. package/dist/chunk-4KNQZDZC.js.map +1 -0
  28. package/dist/chunk-5F3LNDZG.js +9 -0
  29. package/dist/chunk-5F3LNDZG.js.map +1 -0
  30. package/dist/chunk-63U7QWNY.js +364 -0
  31. package/dist/chunk-63U7QWNY.js.map +1 -0
  32. package/dist/chunk-6BY4BV5G.js +998 -0
  33. package/dist/chunk-6BY4BV5G.js.map +1 -0
  34. package/dist/chunk-7L2K4N25.js +610 -0
  35. package/dist/chunk-7L2K4N25.js.map +1 -0
  36. package/dist/chunk-7LWH5SWH.js +18 -0
  37. package/dist/chunk-7LWH5SWH.js.map +1 -0
  38. package/dist/chunk-BIBUCC2E.js +696 -0
  39. package/dist/chunk-BIBUCC2E.js.map +1 -0
  40. package/dist/chunk-BSOBXLYI.js +172 -0
  41. package/dist/chunk-BSOBXLYI.js.map +1 -0
  42. package/dist/chunk-C4QBVVEH.js +32 -0
  43. package/dist/chunk-C4QBVVEH.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-DV74UZJI.js +87 -0
  47. package/dist/chunk-DV74UZJI.js.map +1 -0
  48. package/dist/chunk-DWVAR4BP.js +656 -0
  49. package/dist/chunk-DWVAR4BP.js.map +1 -0
  50. package/dist/chunk-DXKAKKLP.js +302 -0
  51. package/dist/chunk-DXKAKKLP.js.map +1 -0
  52. package/dist/chunk-EIWXS4RM.js +235 -0
  53. package/dist/chunk-EIWXS4RM.js.map +1 -0
  54. package/dist/chunk-EWBCFAF3.js +681 -0
  55. package/dist/chunk-EWBCFAF3.js.map +1 -0
  56. package/dist/chunk-F2L4VNQK.js +1759 -0
  57. package/dist/chunk-F2L4VNQK.js.map +1 -0
  58. package/dist/chunk-G26HZZDJ.js +1359 -0
  59. package/dist/chunk-G26HZZDJ.js.map +1 -0
  60. package/dist/chunk-GQKKX7OE.js +818 -0
  61. package/dist/chunk-GQKKX7OE.js.map +1 -0
  62. package/dist/chunk-GRJY22U6.js +691 -0
  63. package/dist/chunk-GRJY22U6.js.map +1 -0
  64. package/dist/chunk-H6DVP2SI.js +682 -0
  65. package/dist/chunk-H6DVP2SI.js.map +1 -0
  66. package/dist/chunk-HVVPTCKR.js +1173 -0
  67. package/dist/chunk-HVVPTCKR.js.map +1 -0
  68. package/dist/chunk-I6XFZLTJ.js +9 -0
  69. package/dist/chunk-I6XFZLTJ.js.map +1 -0
  70. package/dist/chunk-IBOABSIA.js +17 -0
  71. package/dist/chunk-IBOABSIA.js.map +1 -0
  72. package/dist/chunk-IK524ZDW.js +691 -0
  73. package/dist/chunk-IK524ZDW.js.map +1 -0
  74. package/dist/chunk-IRU7NBOT.js +141 -0
  75. package/dist/chunk-IRU7NBOT.js.map +1 -0
  76. package/dist/chunk-J4CKQXQ6.js +806 -0
  77. package/dist/chunk-J4CKQXQ6.js.map +1 -0
  78. package/dist/chunk-JKGSJGCC.js +311 -0
  79. package/dist/chunk-JKGSJGCC.js.map +1 -0
  80. package/dist/chunk-JQOKQKQT.js +158 -0
  81. package/dist/chunk-JQOKQKQT.js.map +1 -0
  82. package/dist/chunk-JRFUTIEH.js +426 -0
  83. package/dist/chunk-JRFUTIEH.js.map +1 -0
  84. package/dist/chunk-K2BPYEH5.js +491 -0
  85. package/dist/chunk-K2BPYEH5.js.map +1 -0
  86. package/dist/chunk-KCQC7YBK.js +7795 -0
  87. package/dist/chunk-KCQC7YBK.js.map +1 -0
  88. package/dist/chunk-KDAV2GUT.js +1357 -0
  89. package/dist/chunk-KDAV2GUT.js.map +1 -0
  90. package/dist/chunk-KDDXZBMC.js +583 -0
  91. package/dist/chunk-KDDXZBMC.js.map +1 -0
  92. package/dist/chunk-KMWHZSEG.js +41 -0
  93. package/dist/chunk-KMWHZSEG.js.map +1 -0
  94. package/dist/chunk-KRI4R7EM.js +25 -0
  95. package/dist/chunk-KRI4R7EM.js.map +1 -0
  96. package/dist/chunk-LNJ3WZZX.js +186 -0
  97. package/dist/chunk-LNJ3WZZX.js.map +1 -0
  98. package/dist/chunk-MWXA4PFE.js +103 -0
  99. package/dist/chunk-MWXA4PFE.js.map +1 -0
  100. package/dist/chunk-MY62SSKC.js +183 -0
  101. package/dist/chunk-MY62SSKC.js.map +1 -0
  102. package/dist/chunk-NAGAJ5UM.js +145 -0
  103. package/dist/chunk-NAGAJ5UM.js.map +1 -0
  104. package/dist/chunk-NJ7WRKIQ.js +532 -0
  105. package/dist/chunk-NJ7WRKIQ.js.map +1 -0
  106. package/dist/chunk-OS6NUIBJ.js +38 -0
  107. package/dist/chunk-OS6NUIBJ.js.map +1 -0
  108. package/dist/chunk-PXU2OS26.js +238 -0
  109. package/dist/chunk-PXU2OS26.js.map +1 -0
  110. package/dist/chunk-QO4LBDVI.js +496 -0
  111. package/dist/chunk-QO4LBDVI.js.map +1 -0
  112. package/dist/chunk-QRZPQNLX.js +65 -0
  113. package/dist/chunk-QRZPQNLX.js.map +1 -0
  114. package/dist/chunk-SNVAMWB7.js +40 -0
  115. package/dist/chunk-SNVAMWB7.js.map +1 -0
  116. package/dist/chunk-SPRVUATR.js +430 -0
  117. package/dist/chunk-SPRVUATR.js.map +1 -0
  118. package/dist/chunk-SY7G5QEI.js +35 -0
  119. package/dist/chunk-SY7G5QEI.js.map +1 -0
  120. package/dist/chunk-SZNBUIDR.js +6438 -0
  121. package/dist/chunk-SZNBUIDR.js.map +1 -0
  122. package/dist/chunk-TQ2NA4Z4.js +24 -0
  123. package/dist/chunk-TQ2NA4Z4.js.map +1 -0
  124. package/dist/chunk-TYULB6ZY.js +2959 -0
  125. package/dist/chunk-TYULB6ZY.js.map +1 -0
  126. package/dist/chunk-UJYFTXHV.js +296 -0
  127. package/dist/chunk-UJYFTXHV.js.map +1 -0
  128. package/dist/chunk-VC6OKCJF.js +184 -0
  129. package/dist/chunk-VC6OKCJF.js.map +1 -0
  130. package/dist/chunk-VL2NWCZV.js +118 -0
  131. package/dist/chunk-VL2NWCZV.js.map +1 -0
  132. package/dist/chunk-VL7BGD47.js +514 -0
  133. package/dist/chunk-VL7BGD47.js.map +1 -0
  134. package/dist/chunk-VQVUJYYY.js +244 -0
  135. package/dist/chunk-VQVUJYYY.js.map +1 -0
  136. package/dist/chunk-VZQG2JDV.js +9 -0
  137. package/dist/chunk-VZQG2JDV.js.map +1 -0
  138. package/dist/chunk-XFZQVYIN.js +115 -0
  139. package/dist/chunk-XFZQVYIN.js.map +1 -0
  140. package/dist/chunk-XGTTOO4R.js +84 -0
  141. package/dist/chunk-XGTTOO4R.js.map +1 -0
  142. package/dist/chunk-XQFT4PEP.js +60 -0
  143. package/dist/chunk-XQFT4PEP.js.map +1 -0
  144. package/dist/chunk-YDD3ES2K.js +571 -0
  145. package/dist/chunk-YDD3ES2K.js.map +1 -0
  146. package/dist/chunk-ZY2MZ2KQ.js +1140 -0
  147. package/dist/chunk-ZY2MZ2KQ.js.map +1 -0
  148. package/dist/compile-57EEIUMB.js +161 -0
  149. package/dist/compile-57EEIUMB.js.map +1 -0
  150. package/dist/config-4EJ3D7QJ.js +438 -0
  151. package/dist/config-4EJ3D7QJ.js.map +1 -0
  152. package/dist/doctor-EEV6P5CH.js +111 -0
  153. package/dist/doctor-EEV6P5CH.js.map +1 -0
  154. package/dist/environment-WFEG4DAT.js +2745 -0
  155. package/dist/environment-WFEG4DAT.js.map +1 -0
  156. package/dist/github-BSMQD72A.js +114 -0
  157. package/dist/github-BSMQD72A.js.map +1 -0
  158. package/dist/harness-VX3PNVQW.js +746 -0
  159. package/dist/harness-VX3PNVQW.js.map +1 -0
  160. package/dist/help-AW2HKX63.js +2079 -0
  161. package/dist/help-AW2HKX63.js.map +1 -0
  162. package/dist/help-BVFOZD7E.js +1892 -0
  163. package/dist/help-BVFOZD7E.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-SPN2GEZ4.js +873 -0
  168. package/dist/init-SPN2GEZ4.js.map +1 -0
  169. package/dist/lock-K2LLUU7H.js +455 -0
  170. package/dist/lock-K2LLUU7H.js.map +1 -0
  171. package/dist/marketplace-VEKSWGX3.js +495 -0
  172. package/dist/marketplace-VEKSWGX3.js.map +1 -0
  173. package/dist/mcp-T6DKIKSF.js +202 -0
  174. package/dist/mcp-T6DKIKSF.js.map +1 -0
  175. package/dist/migrate-OO37WSB2.js +1043 -0
  176. package/dist/migrate-OO37WSB2.js.map +1 -0
  177. package/dist/open-3V3QK5RK.js +32 -0
  178. package/dist/open-3V3QK5RK.js.map +1 -0
  179. package/dist/pack-V32UPC7W.js +99 -0
  180. package/dist/pack-V32UPC7W.js.map +1 -0
  181. package/dist/plugin-KOBNQ7GT.js +64 -0
  182. package/dist/plugin-KOBNQ7GT.js.map +1 -0
  183. package/dist/plugin-from-project-X3VO3MB6.js +16 -0
  184. package/dist/plugin-from-project-X3VO3MB6.js.map +1 -0
  185. package/dist/policy-F5MKZNOC.js +105 -0
  186. package/dist/policy-F5MKZNOC.js.map +1 -0
  187. package/dist/profile-H4PMH4XT.js +1886 -0
  188. package/dist/profile-H4PMH4XT.js.map +1 -0
  189. package/dist/project-QVNEJJGH.js +1392 -0
  190. package/dist/project-QVNEJJGH.js.map +1 -0
  191. package/dist/resource-GL4RLSGI.js +555 -0
  192. package/dist/resource-GL4RLSGI.js.map +1 -0
  193. package/dist/version-PBHZK44K.js +17 -0
  194. package/dist/version-PBHZK44K.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,746 @@
1
+ import {
2
+ resolveHarnessSelection
3
+ } from "./chunk-DV74UZJI.js";
4
+ import {
5
+ parseHarnessList
6
+ } from "./chunk-37E5M4JX.js";
7
+ import "./chunk-JQOKQKQT.js";
8
+ import "./chunk-3FIWOI3H.js";
9
+ import {
10
+ captureManagedSnapshotState,
11
+ collectManagedSkillPlacements,
12
+ extractHostPluginMaterial,
13
+ flattenUniqueFiles,
14
+ generateFiles,
15
+ getGitOrigin,
16
+ isHostPluginTreePlatform,
17
+ materializeFiles,
18
+ materializeFromSource,
19
+ materializeSkillHubPlan,
20
+ normalizeGitUrl,
21
+ persistWrittenMaterializations,
22
+ pinSkillEmitsToExistingLivePaths,
23
+ planPluginSkillHub,
24
+ portableHarnessesForPluginFanout,
25
+ preferSharedSkillEmits,
26
+ projectNameFromUrl,
27
+ replaceWithRelativeSymlink,
28
+ writeFiles
29
+ } from "./chunk-KCQC7YBK.js";
30
+ import "./chunk-PXU2OS26.js";
31
+ import {
32
+ shouldUseWizard
33
+ } from "./chunk-NAGAJ5UM.js";
34
+ import {
35
+ initializeSchema
36
+ } from "./chunk-IK524ZDW.js";
37
+ import "./chunk-SY7G5QEI.js";
38
+ import {
39
+ createSnapshot
40
+ } from "./chunk-XQFT4PEP.js";
41
+ import "./chunk-I6XFZLTJ.js";
42
+ import "./chunk-JRFUTIEH.js";
43
+ import {
44
+ getHarnessPreference,
45
+ getProjectByOrigin,
46
+ getProjectHarnessConfig,
47
+ registeredHarnessesOf,
48
+ setHarnessPreference,
49
+ setProjectHarnessConfig,
50
+ uniqueHarnessTargets,
51
+ upsertProject
52
+ } from "./chunk-UJYFTXHV.js";
53
+ import {
54
+ detectPlatforms,
55
+ dropPluginTranslatedResources,
56
+ getDedicatedSerializerPlatformIds,
57
+ getPlatformSerializer,
58
+ isClaudeLocalMcpResource,
59
+ persistScanResults,
60
+ resourceFingerprint,
61
+ resourceIdentity,
62
+ scanPlatform,
63
+ toPortableEmitResources,
64
+ unionHarnessResources,
65
+ writeHarnessSyncPluginTranslationMarkers
66
+ } from "./chunk-3IWTJCPA.js";
67
+ import "./chunk-SPRVUATR.js";
68
+ import "./chunk-EWBCFAF3.js";
69
+ import {
70
+ getAllPlatforms,
71
+ isHostPluginPinResource,
72
+ resolveHomeRoot
73
+ } from "./chunk-2EIJYDNI.js";
74
+ import "./chunk-6BY4BV5G.js";
75
+ import "./chunk-GQKKX7OE.js";
76
+ import "./chunk-K2BPYEH5.js";
77
+ import {
78
+ configureCommandGroup
79
+ } from "./chunk-G26HZZDJ.js";
80
+ import {
81
+ parseOutputFormat,
82
+ printJson
83
+ } from "./chunk-TQ2NA4Z4.js";
84
+ import {
85
+ fail,
86
+ formatCommand,
87
+ reportNoGitOrigin
88
+ } from "./chunk-DXKAKKLP.js";
89
+ import {
90
+ formatCount,
91
+ ui
92
+ } from "./chunk-YDD3ES2K.js";
93
+ import "./chunk-ZY2MZ2KQ.js";
94
+ import {
95
+ DEFAULT_PLUGIN_RESOURCE_MODE,
96
+ loadSettings,
97
+ parsePluginResourceMode
98
+ } from "./chunk-VQVUJYYY.js";
99
+ import {
100
+ getDb,
101
+ getHarnesstapDir
102
+ } from "./chunk-DWVAR4BP.js";
103
+
104
+ // src/cli/commands/harness.ts
105
+ import { resolve as resolve2 } from "path";
106
+ import { Option } from "commander";
107
+
108
+ // src/services/harness-union-sync.ts
109
+ import { existsSync, statSync } from "fs";
110
+ import { isAbsolute, join as join2, resolve } from "path";
111
+
112
+ // src/services/harness-sync-preview.ts
113
+ function isHostPluginPin(resource) {
114
+ return isHostPluginPinResource({
115
+ type: resource.type,
116
+ metadata: resource.metadata,
117
+ origin_ref: resource.origin_ref ?? ""
118
+ });
119
+ }
120
+ function sliceByIdentity(slice) {
121
+ const byIdentity = /* @__PURE__ */ new Map();
122
+ if (!slice) return byIdentity;
123
+ for (const resource of slice.resources) {
124
+ byIdentity.set(resourceIdentity(resource), resource);
125
+ }
126
+ return byIdentity;
127
+ }
128
+ function sliceSkillNames(slice) {
129
+ const names = /* @__PURE__ */ new Set();
130
+ if (!slice) return names;
131
+ for (const resource of slice.resources) {
132
+ if (resource.type === "skill") names.add(resource.name);
133
+ }
134
+ return names;
135
+ }
136
+ function skipPreviewResource(resource, portable) {
137
+ if (isClaudeLocalMcpResource(resource)) return true;
138
+ if (portable && isHostPluginPin(resource)) return true;
139
+ return false;
140
+ }
141
+ function countHarnessSyncChanges(input) {
142
+ const slices = new Map(
143
+ input.slices.map((slice) => [slice.platformId, slice])
144
+ );
145
+ return input.platforms.map((harness) => {
146
+ const slice = slices.get(harness);
147
+ const current = sliceByIdentity(slice);
148
+ const skillNames = sliceSkillNames(slice);
149
+ const portable = !isHostPluginTreePlatform(harness);
150
+ const planned = /* @__PURE__ */ new Set();
151
+ let added = 0;
152
+ let modified = 0;
153
+ let removed = 0;
154
+ const consider = (resource) => {
155
+ if (skipPreviewResource(resource, portable)) return;
156
+ const identity = resourceIdentity(resource);
157
+ if (planned.has(identity)) return;
158
+ planned.add(identity);
159
+ const existing = current.get(identity);
160
+ if (!existing) {
161
+ added += 1;
162
+ return;
163
+ }
164
+ if (resourceFingerprint(existing) !== resourceFingerprint(resource)) {
165
+ modified += 1;
166
+ }
167
+ };
168
+ for (const resource of input.unionResources) {
169
+ consider(resource);
170
+ }
171
+ if (portable) {
172
+ for (const resource of input.extracted.resources) {
173
+ consider(resource);
174
+ }
175
+ for (const skill of input.extracted.skills) {
176
+ const identity = `skill:${skill.name}:`;
177
+ if (planned.has(identity)) continue;
178
+ planned.add(identity);
179
+ if (!skillNames.has(skill.name)) added += 1;
180
+ }
181
+ }
182
+ for (const [identity, resource] of current) {
183
+ if (skipPreviewResource(resource, portable)) continue;
184
+ if (!planned.has(identity)) removed += 1;
185
+ }
186
+ return {
187
+ harness,
188
+ added,
189
+ removed,
190
+ modified,
191
+ changes: added + removed + modified
192
+ };
193
+ });
194
+ }
195
+
196
+ // src/services/instruction-file-links.ts
197
+ import { mkdirSync } from "fs";
198
+ import { basename, dirname, join, relative } from "path";
199
+ var INSTRUCTION_BASENAMES = /* @__PURE__ */ new Set(["AGENTS.md", "CLAUDE.md"]);
200
+ function posixPath(path) {
201
+ return path.replace(/\\/g, "/");
202
+ }
203
+ function instructionBasename(path) {
204
+ return basename(posixPath(path));
205
+ }
206
+ function isInstructionFile(path) {
207
+ return INSTRUCTION_BASENAMES.has(instructionBasename(path));
208
+ }
209
+ function normalizeInstructionContent(content) {
210
+ return content.replace(/\r\n/g, "\n").replace(/\n+$/, "");
211
+ }
212
+ function pickCanonical(group) {
213
+ const agents = group.find((file) => instructionBasename(file.path) === "AGENTS.md");
214
+ if (agents) return agents;
215
+ const first = group[0];
216
+ if (!first) {
217
+ throw new Error("instruction group is empty");
218
+ }
219
+ return first;
220
+ }
221
+ function pairInstructionFiles(files, mode) {
222
+ if (mode === "copy") {
223
+ return { files: [...files], links: [] };
224
+ }
225
+ const instruction = files.filter((file) => isInstructionFile(file.path));
226
+ if (instruction.length < 2) {
227
+ return { files: [...files], links: [] };
228
+ }
229
+ const rest = files.filter((file) => !isInstructionFile(file.path));
230
+ const groups = /* @__PURE__ */ new Map();
231
+ for (const file of instruction) {
232
+ const key = normalizeInstructionContent(file.content);
233
+ const group = groups.get(key) ?? [];
234
+ group.push(file);
235
+ groups.set(key, group);
236
+ }
237
+ const filesOut = [...rest];
238
+ const links = [];
239
+ for (const group of groups.values()) {
240
+ if (group.length === 1) {
241
+ const only = group[0];
242
+ if (only) filesOut.push(only);
243
+ continue;
244
+ }
245
+ const canonical = pickCanonical(group);
246
+ filesOut.push(canonical);
247
+ for (const file of group) {
248
+ if (posixPath(file.path) === posixPath(canonical.path)) continue;
249
+ links.push({
250
+ path: posixPath(file.path),
251
+ target: posixPath(canonical.path)
252
+ });
253
+ }
254
+ }
255
+ return { files: filesOut, links };
256
+ }
257
+ function applyInstructionLinks(rootPath, links, mode) {
258
+ if (mode === "copy" || links.length === 0) return;
259
+ for (const link of links) {
260
+ const dest = join(rootPath, link.path);
261
+ const canonical = join(rootPath, link.target);
262
+ mkdirSync(dirname(dest), { recursive: true });
263
+ switch (mode) {
264
+ case "symlink": {
265
+ const relativeTarget = relative(dirname(dest), canonical) || basename(canonical);
266
+ replaceWithRelativeSymlink(dest, relativeTarget);
267
+ break;
268
+ }
269
+ case "clone":
270
+ materializeFromSource(dest, canonical, "clone");
271
+ break;
272
+ default: {
273
+ const exhaustive = mode;
274
+ throw new Error(`Unsupported instruction link mode: ${exhaustive}`);
275
+ }
276
+ }
277
+ }
278
+ }
279
+
280
+ // src/services/harness-union-sync.ts
281
+ var HarnessUnionSyncError = class extends Error {
282
+ code;
283
+ constructor(code, message) {
284
+ super(message);
285
+ this.name = "HarnessUnionSyncError";
286
+ this.code = code;
287
+ }
288
+ };
289
+ function resolvePluginResourceMode(override) {
290
+ if (override) return override;
291
+ try {
292
+ return loadSettings(getHarnesstapDir()).harnessSync.pluginResources;
293
+ } catch {
294
+ return DEFAULT_PLUGIN_RESOURCE_MODE;
295
+ }
296
+ }
297
+ function resolveConfiguredSelection(projectRoot) {
298
+ const global = getHarnessPreference();
299
+ if (projectRoot) {
300
+ const gitOrigin = getGitOrigin(projectRoot);
301
+ if (gitOrigin) {
302
+ const project = upsertProject({
303
+ git_origin: normalizeGitUrl(gitOrigin),
304
+ name: projectNameFromUrl(gitOrigin),
305
+ local_path: projectRoot
306
+ });
307
+ const projectConfig = getProjectHarnessConfig(project.id);
308
+ const registered2 = uniqueHarnessTargets(
309
+ projectConfig?.registered_harnesses ?? []
310
+ );
311
+ if (registered2.length > 0) {
312
+ return {
313
+ registered_harnesses: registered2,
314
+ ...projectConfig?.cursor_skill_mode ? { cursor_skill_mode: projectConfig.cursor_skill_mode } : {}
315
+ };
316
+ }
317
+ }
318
+ }
319
+ const registered = uniqueHarnessTargets(global?.registered_harnesses ?? []);
320
+ if (registered.length === 0) {
321
+ throw new HarnessUnionSyncError(
322
+ "no_registered_harnesses",
323
+ "No harnesses configured. Run ht harness set --harnesses <slugs>."
324
+ );
325
+ }
326
+ return { registered_harnesses: registered };
327
+ }
328
+ function resourceMtimeMs(rootPath, source) {
329
+ if (!source) return void 0;
330
+ const full = isAbsolute(source) ? source : join2(rootPath, source);
331
+ try {
332
+ if (!existsSync(full)) return void 0;
333
+ return statSync(full).mtimeMs;
334
+ } catch {
335
+ return void 0;
336
+ }
337
+ }
338
+ async function scanConfiguredSlices(platformIds, target, rootPath) {
339
+ const slices = [];
340
+ for (const platformId of platformIds) {
341
+ let resources;
342
+ if (target === "global") {
343
+ const serializer = getPlatformSerializer(platformId);
344
+ const scanned = serializer.scanGlobal ? await serializer.scanGlobal(rootPath) : await serializer.scan(rootPath);
345
+ resources = dropPluginTranslatedResources(rootPath, scanned);
346
+ } else {
347
+ const scan = await scanPlatform(platformId, rootPath);
348
+ resources = scan.resources;
349
+ }
350
+ const mtimesMs = /* @__PURE__ */ new Map();
351
+ for (const resource of resources) {
352
+ const mtime = resourceMtimeMs(rootPath, resource.source);
353
+ if (mtime !== void 0) {
354
+ mtimesMs.set(resourceIdentity(resource), mtime);
355
+ }
356
+ }
357
+ slices.push({ platformId, resources, mtimesMs });
358
+ }
359
+ return slices;
360
+ }
361
+ async function syncConfiguredHarnesses(options = {}) {
362
+ const scope = options.scope ?? "global";
363
+ const target = scope === "global" ? "global" : "project";
364
+ const projectRoot = options.projectRoot ? resolve(options.projectRoot) : void 0;
365
+ const rootPath = target === "global" ? options.homeRoot ?? resolveHomeRoot() : projectRoot ?? resolve(".");
366
+ const selection = resolveConfiguredSelection(
367
+ target === "project" ? rootPath : void 0
368
+ );
369
+ const platforms = uniqueHarnessTargets(selection.registered_harnesses);
370
+ if (platforms.length < 2) {
371
+ throw new HarnessUnionSyncError(
372
+ "need_two_harnesses",
373
+ "Add another harness to sync."
374
+ );
375
+ }
376
+ const slices = await scanConfiguredSlices(platforms, target, rootPath);
377
+ const unioned = unionHarnessResources(slices, "last-write");
378
+ const emitResources = toPortableEmitResources(unioned.resources);
379
+ const serializeOptions = selection.cursor_skill_mode ? { target, skillCursorMode: selection.cursor_skill_mode } : { target };
380
+ const pluginResourceMode = resolvePluginResourceMode(options.pluginResourceMode);
381
+ const portablePlatforms = portableHarnessesForPluginFanout(platforms);
382
+ const homeRoot = options.homeRoot ?? resolveHomeRoot();
383
+ const previousSkillPlacements = collectManagedSkillPlacements(rootPath);
384
+ const skipSkillNames = new Set(previousSkillPlacements.keys());
385
+ const pinFromPrevious = previousSkillPlacements.size > 0 ? { previousManagedPlacements: previousSkillPlacements } : void 0;
386
+ const generated = await generateFiles(
387
+ emitResources,
388
+ platforms,
389
+ rootPath,
390
+ pinFromPrevious ? { ...serializeOptions, ...pinFromPrevious } : serializeOptions
391
+ );
392
+ const preferred = pinSkillEmitsToExistingLivePaths(
393
+ rootPath,
394
+ preferSharedSkillEmits(generated, platforms, target, { skipSkillNames }),
395
+ platforms,
396
+ target,
397
+ pinFromPrevious
398
+ );
399
+ const extraResults = [];
400
+ let skillHubPlans = [];
401
+ let extracted = {
402
+ skills: [],
403
+ resources: [],
404
+ resourcePlugins: /* @__PURE__ */ new Map()
405
+ };
406
+ if (target === "global" && portablePlatforms.length > 0) {
407
+ const occupied = new Set(unioned.resources.map(resourceIdentity));
408
+ extracted = await extractHostPluginMaterial(
409
+ unioned.resources,
410
+ homeRoot,
411
+ occupied
412
+ );
413
+ if (extracted.resources.length > 0) {
414
+ const extraGenerated = await generateFiles(
415
+ toPortableEmitResources(extracted.resources),
416
+ portablePlatforms,
417
+ rootPath,
418
+ pinFromPrevious ? { ...serializeOptions, ...pinFromPrevious } : serializeOptions
419
+ );
420
+ extraResults.push(
421
+ ...pinSkillEmitsToExistingLivePaths(
422
+ rootPath,
423
+ preferSharedSkillEmits(extraGenerated, portablePlatforms, target, {
424
+ skipSkillNames
425
+ }),
426
+ portablePlatforms,
427
+ target,
428
+ pinFromPrevious
429
+ )
430
+ );
431
+ }
432
+ skillHubPlans = planPluginSkillHub(
433
+ extracted.skills,
434
+ portablePlatforms,
435
+ target
436
+ );
437
+ }
438
+ const paired = pairInstructionFiles(
439
+ flattenUniqueFiles([...preferred, ...extraResults]),
440
+ pluginResourceMode
441
+ );
442
+ const files = paired.files;
443
+ const filePaths = [
444
+ ...files.map((file) => file.path.replace(/\\/g, "/")),
445
+ ...paired.links.map((link) => link.path),
446
+ ...skillHubPlans.map((plan) => plan.skillMdPath)
447
+ ].filter((path, index, all) => all.indexOf(path) === index);
448
+ const harness_changes = countHarnessSyncChanges({
449
+ platforms,
450
+ slices,
451
+ unionResources: unioned.resources,
452
+ extracted
453
+ });
454
+ const payload = {
455
+ registered_harnesses: platforms,
456
+ conflict_policy: "last-write",
457
+ platforms_synced: platforms,
458
+ files_written: filePaths.length,
459
+ harness_changes,
460
+ conflicts: unioned.conflicts,
461
+ files: filePaths,
462
+ plugin_resource_mode: pluginResourceMode,
463
+ surface_warnings: [...preferred, ...extraResults].flatMap(
464
+ (result) => result.surface_warnings ?? []
465
+ )
466
+ };
467
+ if (options.dryRun) {
468
+ return payload;
469
+ }
470
+ let writtenByApply = /* @__PURE__ */ new Set();
471
+ if (target === "project") {
472
+ const gitOrigin = getGitOrigin(rootPath);
473
+ if (gitOrigin) {
474
+ const project = upsertProject({
475
+ git_origin: normalizeGitUrl(gitOrigin),
476
+ name: projectNameFromUrl(gitOrigin),
477
+ local_path: rootPath
478
+ });
479
+ createSnapshot({
480
+ project_id: project.id,
481
+ label: `Before harness sync (${platforms.join(", ")})`,
482
+ state: captureManagedSnapshotState({
483
+ rootPath,
484
+ resources: emitResources,
485
+ generated: preferred
486
+ })
487
+ });
488
+ }
489
+ writeFiles(files, rootPath);
490
+ } else {
491
+ const materialized = await materializeFiles(files, rootPath, {
492
+ conflictPolicy: "replace"
493
+ });
494
+ writtenByApply = new Set(
495
+ materialized.writtenFiles.map((path) => path.replace(/\\/g, "/"))
496
+ );
497
+ }
498
+ applyInstructionLinks(rootPath, paired.links, pluginResourceMode);
499
+ materializeSkillHubPlan(rootPath, skillHubPlans, pluginResourceMode);
500
+ await writeHarnessSyncPluginTranslationMarkers({
501
+ rootPath,
502
+ scope: target === "global" ? "global" : "project",
503
+ extracted,
504
+ skillHubPlans,
505
+ extraResults,
506
+ portablePlatforms,
507
+ target,
508
+ serializeOptions
509
+ });
510
+ persistWrittenMaterializations({
511
+ scope: target === "global" ? "global" : "project",
512
+ project_id: null,
513
+ root_path: rootPath,
514
+ platformResults: preferred.map((result) => ({
515
+ platformId: result.platformId,
516
+ files: result.files,
517
+ writtenPaths: result.files.map((file) => file.path.replace(/\\/g, "/")).filter(
518
+ (path) => target === "project" ? filePaths.includes(path) : writtenByApply.has(path)
519
+ )
520
+ }))
521
+ });
522
+ const afterSlices = await scanConfiguredSlices(platforms, target, rootPath);
523
+ persistScanResults(afterSlices, {
524
+ conflictPolicy: "overwrite",
525
+ originRef: rootPath
526
+ });
527
+ return payload;
528
+ }
529
+
530
+ // src/cli/commands/harness.ts
531
+ var NATIVE_HARNESS_IDS = new Set(getDedicatedSerializerPlatformIds());
532
+ function handleHarnessListCommand(opts = {}) {
533
+ const format = parseOutputFormat(opts.format);
534
+ const platforms = getAllPlatforms().filter(
535
+ (platform) => !opts.supported || NATIVE_HARNESS_IDS.has(platform.id)
536
+ );
537
+ if (format === "json") {
538
+ printJson(
539
+ platforms.map((platform) => ({
540
+ id: platform.id,
541
+ name: platform.name,
542
+ supports: [...platform.supports].sort()
543
+ }))
544
+ );
545
+ return;
546
+ }
547
+ const rows = platforms.map((p) => ({
548
+ id: p.id,
549
+ name: p.name,
550
+ supports: [...p.supports].join(", ")
551
+ }));
552
+ ui.table.print({
553
+ columns: [
554
+ { key: "id", header: "ID", width: 20 },
555
+ { key: "name", header: "NAME", width: 20 },
556
+ { key: "supports", header: "SUPPORTS", width: 40 }
557
+ ],
558
+ rows,
559
+ summary: `${platforms.length} harnesses`,
560
+ empty: "No harnesses found."
561
+ });
562
+ }
563
+ async function handleHarnessSetCommand(opts) {
564
+ const db = getDb();
565
+ initializeSchema(db);
566
+ const useWizard = shouldUseWizard({
567
+ interactive: opts.interactive,
568
+ noInteractive: opts.noInteractive,
569
+ missingRequiredArgs: !opts.harnesses && !opts.main && !opts.aliases
570
+ });
571
+ const selection = await resolveHarnessSelection({
572
+ harnesses: parseHarnessList(opts.harnesses),
573
+ main: opts.main,
574
+ aliases: parseHarnessList(opts.aliases),
575
+ nonInteractive: !useWizard,
576
+ current: getHarnessPreference()
577
+ });
578
+ const saved = setHarnessPreference(selection);
579
+ ui.success(
580
+ `Set harness preference ${ui.icons.hint} ${ui.theme.accent(registeredHarnessesOf(saved).join(", "))}`
581
+ );
582
+ }
583
+ function handleHarnessStatusCommand(opts) {
584
+ const db = getDb();
585
+ initializeSchema(db);
586
+ const format = parseOutputFormat(opts.format);
587
+ const preference = getHarnessPreference();
588
+ if (format === "json") {
589
+ printJson(
590
+ preference ?? {
591
+ registered_harnesses: []
592
+ }
593
+ );
594
+ return;
595
+ }
596
+ if (!preference) {
597
+ ui.dim("No harness preference configured.");
598
+ return;
599
+ }
600
+ ui.panel({
601
+ title: ["HARNESS"],
602
+ rows: [
603
+ ["Registered", registeredHarnessesOf(preference).join(", ") || "(none)"],
604
+ [
605
+ "Plugin resources",
606
+ loadSettings(getHarnesstapDir()).harnessSync.pluginResources
607
+ ]
608
+ ]
609
+ });
610
+ }
611
+ async function handleHarnessProjectSetCommand(opts) {
612
+ const db = getDb();
613
+ initializeSchema(db);
614
+ const projectRoot = resolve2(opts.project);
615
+ const gitOrigin = getGitOrigin(projectRoot);
616
+ if (!gitOrigin) {
617
+ reportNoGitOrigin(`${formatCommand("harness project set --project . --harnesses claude-code,cursor")}`);
618
+ return;
619
+ }
620
+ const project = upsertProject({
621
+ git_origin: normalizeGitUrl(gitOrigin),
622
+ name: projectNameFromUrl(gitOrigin),
623
+ local_path: projectRoot
624
+ });
625
+ const useWizard = shouldUseWizard({
626
+ interactive: opts.interactive,
627
+ noInteractive: opts.noInteractive,
628
+ missingRequiredArgs: !opts.harnesses && !opts.main && !opts.aliases
629
+ });
630
+ const selection = await resolveHarnessSelection({
631
+ harnesses: parseHarnessList(opts.harnesses),
632
+ main: opts.main,
633
+ aliases: parseHarnessList(opts.aliases),
634
+ nonInteractive: !useWizard,
635
+ current: getProjectHarnessConfig(project.id),
636
+ detected: detectPlatforms(projectRoot)
637
+ });
638
+ const saved = setProjectHarnessConfig({
639
+ project_id: project.id,
640
+ registered_harnesses: selection.registered_harnesses,
641
+ ...opts.materializationStrategy ? {
642
+ materialization_strategy: opts.materializationStrategy === "copy" ? "copy" : "symlink-preferred"
643
+ } : {}
644
+ });
645
+ ui.success(
646
+ `Set project harness preference ${ui.icons.hint} ${ui.theme.accent(registeredHarnessesOf(saved).join(", "))}`
647
+ );
648
+ }
649
+ async function handleHarnessSyncCommand(opts) {
650
+ const db = getDb();
651
+ initializeSchema(db);
652
+ const format = parseOutputFormat(opts.format);
653
+ const scope = opts.project ? "project" : "global";
654
+ const pluginResourceMode = opts.pluginResources ? parsePluginResourceMode(opts.pluginResources) : void 0;
655
+ try {
656
+ const result = await syncConfiguredHarnesses({
657
+ scope,
658
+ ...opts.project ? { projectRoot: resolve2(opts.project) } : {},
659
+ dryRun: opts.dryRun,
660
+ ...pluginResourceMode ? { pluginResourceMode } : {}
661
+ });
662
+ if (format === "json") {
663
+ printJson(result);
664
+ return;
665
+ }
666
+ const verb = opts.dryRun ? "Would sync" : "Synced";
667
+ ui.success(
668
+ `${verb} ${result.platforms_synced.join(", ")} ${ui.icons.hint} ${formatCount(result.files_written, "file")}`
669
+ );
670
+ if (result.conflicts.length > 0) {
671
+ ui.dim(
672
+ `${formatCount(result.conflicts.length, "conflict")} resolved with last-write (newest on-disk copy)`
673
+ );
674
+ }
675
+ for (const warning of result.surface_warnings) {
676
+ ui.warn(
677
+ `${warning.harness} surface ${warning.path} is not rematerialized to ${warning.alias_harnesses.join(", ")}: ${warning.message}`
678
+ );
679
+ }
680
+ } catch (error) {
681
+ const message = error instanceof Error ? error.message : String(error);
682
+ process.exitCode = 1;
683
+ fail(message, {
684
+ hints: [formatCommand("harness set --harnesses <slugs>")]
685
+ });
686
+ }
687
+ }
688
+ function handleHarnessProjectStatusCommand(opts) {
689
+ const db = getDb();
690
+ initializeSchema(db);
691
+ const format = parseOutputFormat(opts.format);
692
+ const projectRoot = resolve2(opts.project);
693
+ const gitOrigin = getGitOrigin(projectRoot);
694
+ if (!gitOrigin) {
695
+ reportNoGitOrigin(`${formatCommand("harness project status --project .")}`);
696
+ return;
697
+ }
698
+ const project = getProjectByOrigin(normalizeGitUrl(gitOrigin));
699
+ const config = project ? getProjectHarnessConfig(project.id) : void 0;
700
+ if (format === "json") {
701
+ printJson(
702
+ config ?? {
703
+ registered_harnesses: [],
704
+ materialization_strategy: "symlink-preferred"
705
+ }
706
+ );
707
+ return;
708
+ }
709
+ if (!config) {
710
+ ui.dim("No project harness preference configured.");
711
+ return;
712
+ }
713
+ ui.panel({
714
+ title: ["HARNESS", "project"],
715
+ rows: [
716
+ ["Registered", registeredHarnessesOf(config).join(", ") || "(none)"],
717
+ ["Materialization", config.materialization_strategy]
718
+ ]
719
+ });
720
+ }
721
+ function registerHarnessCommands(root) {
722
+ const harnessCmd = configureCommandGroup(
723
+ root.command("harness").alias("h").description("Manage the registered harness set")
724
+ );
725
+ harnessCmd.command("list").alias("ls").option("--supported", "Only show natively serialized harnesses").option("--format <mode>", "Output format: human or json", "human").description("List supported harnesses").action(handleHarnessListCommand);
726
+ harnessCmd.command("set").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("--interactive", "Prompt instead of relying on explicit flags").description("Set global registered harnesses").action(handleHarnessSetCommand);
727
+ harnessCmd.command("status").option("--format <mode>", "Output format: human or json", "human").description("Show global harness preferences").action(handleHarnessStatusCommand);
728
+ harnessCmd.command("sync").option("--project <path>", "Sync a git-backed project instead of home").option("--dry-run", "Show what would be written without writing files").option(
729
+ "--plugin-resources <mode>",
730
+ `How to materialize Cursor/Claude plugin files into .agents: symlink, copy, or clone (default ${DEFAULT_PLUGIN_RESOURCE_MODE}, or harnessSync.pluginResources in config.jsonc)`
731
+ ).option("--format <mode>", "Output format: human or json", "human").description(
732
+ "Union resources from registered harnesses and materialize with last-write conflicts"
733
+ ).action(handleHarnessSyncCommand);
734
+ const harnessProjectCmd = configureCommandGroup(
735
+ harnessCmd.command("project").description("Manage harness preferences for a git-backed project")
736
+ );
737
+ harnessProjectCmd.command("set").option("--project <path>", "Project directory", ".").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(
738
+ "--materialization-strategy <strategy>",
739
+ "Materialization strategy: symlink-preferred or copy"
740
+ ).option("--interactive", "Prompt instead of relying on explicit flags").description("Set project-scoped registered harnesses").action(handleHarnessProjectSetCommand);
741
+ harnessProjectCmd.command("status").option("--project <path>", "Project directory", ".").option("--format <mode>", "Output format: human or json", "human").description("Show project-scoped harness preferences").action(handleHarnessProjectStatusCommand);
742
+ }
743
+ export {
744
+ registerHarnessCommands
745
+ };
746
+ //# sourceMappingURL=harness-VX3PNVQW.js.map