harnesstap 1.4.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +3 -1
  2. package/dist/apply-ZGEAY6YZ.js +50 -0
  3. package/dist/{approve-FBGYQGWN.js → approve-VPVMU2MM.js} +10 -13
  4. package/dist/{approve-FBGYQGWN.js.map → approve-VPVMU2MM.js.map} +1 -1
  5. package/dist/{audit-VI4QZ6X2.js → audit-AO7AGET3.js} +11 -15
  6. package/dist/{audit-VI4QZ6X2.js.map → audit-AO7AGET3.js.map} +1 -1
  7. package/dist/{auth-4CQCDS2W.js → auth-7YRIJNXU.js} +10 -12
  8. package/dist/{auth-4CQCDS2W.js.map → auth-7YRIJNXU.js.map} +1 -1
  9. package/dist/bin.js +13 -34
  10. package/dist/bin.js.map +1 -1
  11. package/dist/{chunk-OML4HXKT.js → chunk-262KZULH.js} +16 -22
  12. package/dist/chunk-262KZULH.js.map +1 -0
  13. package/dist/{chunk-ZUASVASP.js → chunk-26QGX47N.js} +26097 -16881
  14. package/dist/chunk-26QGX47N.js.map +1 -0
  15. package/dist/{chunk-3P6BWL5F.js → chunk-27IPOVKQ.js} +2 -2
  16. package/dist/{chunk-M4KLHJ6U.js → chunk-2BESDRYP.js} +8 -10
  17. package/dist/{chunk-M4KLHJ6U.js.map → chunk-2BESDRYP.js.map} +1 -1
  18. package/dist/{chunk-PCMON7Y2.js → chunk-2BWIEB2G.js} +8 -10
  19. package/dist/{chunk-PCMON7Y2.js.map → chunk-2BWIEB2G.js.map} +1 -1
  20. package/dist/{chunk-XTVGCVU4.js → chunk-2NMLWSUH.js} +41 -42
  21. package/dist/chunk-2NMLWSUH.js.map +1 -0
  22. package/dist/{chunk-TQ2NA4Z4.js → chunk-4E3G4H5B.js} +8 -2
  23. package/dist/chunk-4E3G4H5B.js.map +1 -0
  24. package/dist/chunk-4QCGTUTM.js +61 -0
  25. package/dist/chunk-4QCGTUTM.js.map +1 -0
  26. package/dist/{chunk-TPEJFLV7.js → chunk-6RKJZW2N.js} +4 -6
  27. package/dist/{chunk-TPEJFLV7.js.map → chunk-6RKJZW2N.js.map} +1 -1
  28. package/dist/{chunk-JQOKQKQT.js → chunk-7IBFH736.js} +2 -2
  29. package/dist/{chunk-P2C7JPLD.js → chunk-CKJIS2FM.js} +6 -6
  30. package/dist/{chunk-R7ZOYVN3.js → chunk-CUOEQQFI.js} +187 -59
  31. package/dist/chunk-CUOEQQFI.js.map +1 -0
  32. package/dist/{chunk-REHRUNBB.js → chunk-CWXCZBJR.js} +70 -5
  33. package/dist/chunk-CWXCZBJR.js.map +1 -0
  34. package/dist/{chunk-4ZQ2SCGY.js → chunk-FLYQEB6D.js} +509 -207
  35. package/dist/chunk-FLYQEB6D.js.map +1 -0
  36. package/dist/{chunk-U6DXASQP.js → chunk-HC7IZY75.js} +2 -2
  37. package/dist/{chunk-UVVZHWD2.js → chunk-I4DKV63E.js} +2 -2
  38. package/dist/{chunk-PNGF5EV2.js → chunk-JEC5PWNH.js} +2 -2
  39. package/dist/{chunk-MR7IOHSX.js → chunk-KFIRABC7.js} +16 -22
  40. package/dist/{chunk-MR7IOHSX.js.map → chunk-KFIRABC7.js.map} +1 -1
  41. package/dist/{chunk-6LTLYV5D.js → chunk-LGWFLVZQ.js} +1064 -265
  42. package/dist/chunk-LGWFLVZQ.js.map +1 -0
  43. package/dist/{chunk-RDG5DT7S.js → chunk-LX6PMOOC.js} +54 -40
  44. package/dist/chunk-LX6PMOOC.js.map +1 -0
  45. package/dist/{chunk-WGP4GUYZ.js → chunk-MILGCNBK.js} +9 -11
  46. package/dist/{chunk-WGP4GUYZ.js.map → chunk-MILGCNBK.js.map} +1 -1
  47. package/dist/chunk-MKLJBW5N.js +14 -0
  48. package/dist/{chunk-N3ZCH64F.js → chunk-MSKTWYHG.js} +86 -32
  49. package/dist/chunk-MSKTWYHG.js.map +1 -0
  50. package/dist/{chunk-WG5A6EAU.js → chunk-MTCCUYBZ.js} +821 -28
  51. package/dist/chunk-MTCCUYBZ.js.map +1 -0
  52. package/dist/{chunk-BPWFQKI5.js → chunk-NIFKCS7J.js} +2 -2
  53. package/dist/{chunk-43BDGVN3.js → chunk-NWOYPK2O.js} +56 -9
  54. package/dist/chunk-NWOYPK2O.js.map +1 -0
  55. package/dist/{chunk-3FS775NP.js → chunk-NXILQDJG.js} +85 -4
  56. package/dist/chunk-NXILQDJG.js.map +1 -0
  57. package/dist/chunk-QF73VLAW.js +31673 -0
  58. package/dist/chunk-QF73VLAW.js.map +1 -0
  59. package/dist/{chunk-RFQ3N7FB.js → chunk-QHCGA6LC.js} +11 -19
  60. package/dist/chunk-QHCGA6LC.js.map +1 -0
  61. package/dist/{chunk-L6YZE5MY.js → chunk-QPJZKWML.js} +5 -7
  62. package/dist/{chunk-L6YZE5MY.js.map → chunk-QPJZKWML.js.map} +1 -1
  63. package/dist/{chunk-ULCD6DJE.js → chunk-RM7VP6ID.js} +24 -61
  64. package/dist/chunk-RM7VP6ID.js.map +1 -0
  65. package/dist/{chunk-7HP6AAI3.js → chunk-SMLO5YPI.js} +2 -2
  66. package/dist/{chunk-73OJQTBW.js → chunk-T2JBSRGG.js} +2 -2
  67. package/dist/{chunk-IE7B6Q5K.js → chunk-U5Y6WKKT.js} +17 -18
  68. package/dist/chunk-U5Y6WKKT.js.map +1 -0
  69. package/dist/chunk-UEA4NCY2.js +106 -0
  70. package/dist/chunk-UEA4NCY2.js.map +1 -0
  71. package/dist/chunk-VAPCU2FX.js +70 -0
  72. package/dist/chunk-VAPCU2FX.js.map +1 -0
  73. package/dist/{chunk-RVEXPMM3.js → chunk-WEJVFNRO.js} +3 -5
  74. package/dist/{chunk-RVEXPMM3.js.map → chunk-WEJVFNRO.js.map} +1 -1
  75. package/dist/{chunk-IMROMZ2K.js → chunk-WWFVMCTR.js} +19 -14
  76. package/dist/chunk-WWFVMCTR.js.map +1 -0
  77. package/dist/chunk-XPONNOBR.js +102 -0
  78. package/dist/chunk-XPONNOBR.js.map +1 -0
  79. package/dist/{chunk-N3VGY3T3.js → chunk-Y3HJ2F2W.js} +7 -5
  80. package/dist/{chunk-N3VGY3T3.js.map → chunk-Y3HJ2F2W.js.map} +1 -1
  81. package/dist/{chunk-2A36HWDE.js → chunk-Y4I7ZCAE.js} +129 -136
  82. package/dist/chunk-Y4I7ZCAE.js.map +1 -0
  83. package/dist/{chunk-GRASK6M6.js → chunk-ZREU2UHM.js} +5 -5
  84. package/dist/{chunk-QA5U36JN.js → chunk-ZT7ANP3H.js} +774 -364
  85. package/dist/chunk-ZT7ANP3H.js.map +1 -0
  86. package/dist/{chunk-EOPFER6N.js → chunk-ZUXFPAVX.js} +19 -5
  87. package/dist/chunk-ZUXFPAVX.js.map +1 -0
  88. package/dist/{chunk-D432JAXV.js → chunk-ZWB6YXVQ.js} +153 -25
  89. package/dist/chunk-ZWB6YXVQ.js.map +1 -0
  90. package/dist/{chunk-23XSG7LI.js → chunk-ZZQDJGWX.js} +4 -4
  91. package/dist/{compile-GXADKGH5.js → compile-IMJHVXQO.js} +33 -37
  92. package/dist/{compile-GXADKGH5.js.map → compile-IMJHVXQO.js.map} +1 -1
  93. package/dist/{config-JMHNA2U5.js → config-FVVN3NWL.js} +16 -21
  94. package/dist/{config-JMHNA2U5.js.map → config-FVVN3NWL.js.map} +1 -1
  95. package/dist/cursor-local-install-JS5KSOES.js +94 -0
  96. package/dist/{cursor-local-install-46RWRBDT.js.map → cursor-local-install-JS5KSOES.js.map} +1 -1
  97. package/dist/{cursor-local-install-46RWRBDT.js → cursor-local-install-QU5R2FV5.js} +8 -12
  98. package/dist/cursor-local-install-QU5R2FV5.js.map +1 -0
  99. package/dist/{doctor-N7ZULPOL.js → doctor-A7VUJSCP.js} +14 -17
  100. package/dist/doctor-A7VUJSCP.js.map +1 -0
  101. package/dist/{environment-OBB3WU5B.js → environment-6INIUBNC.js} +42 -50
  102. package/dist/environment-6INIUBNC.js.map +1 -0
  103. package/dist/{github-PBYBGOLH.js → github-TFJT3P53.js} +9 -10
  104. package/dist/{github-PBYBGOLH.js.map → github-TFJT3P53.js.map} +1 -1
  105. package/dist/{harness-7KYATIV6.js → harness-WQNC5HPZ.js} +46 -84
  106. package/dist/harness-WQNC5HPZ.js.map +1 -0
  107. package/dist/{help-EE3AJQD4.js → help-NMS3EXJB.js} +15 -20
  108. package/dist/{help-EE3AJQD4.js.map → help-NMS3EXJB.js.map} +1 -1
  109. package/dist/{help-VXWKLQ6A.js → help-VW4RIICD.js} +57 -575
  110. package/dist/help-VW4RIICD.js.map +1 -0
  111. package/dist/host-plugin-view-kept-HYCHDB4D.js +139 -0
  112. package/dist/host-plugin-view-kept-HYCHDB4D.js.map +1 -0
  113. package/dist/index.js +12 -16
  114. package/dist/{init-LBTMPDVJ.js → init-RXYL5ZUE.js} +33 -41
  115. package/dist/{init-LBTMPDVJ.js.map → init-RXYL5ZUE.js.map} +1 -1
  116. package/dist/live-read-cache-BHU6L7MA.js +13 -0
  117. package/dist/live-read-cache-NQU7M2C7.js +12 -0
  118. package/dist/{lock-WLJRXRVK.js → lock-3H3Z65DS.js} +9 -12
  119. package/dist/{lock-WLJRXRVK.js.map → lock-3H3Z65DS.js.map} +1 -1
  120. package/dist/{marketplace-GXSV6QIY.js → marketplace-KW35PJCY.js} +26 -79
  121. package/dist/marketplace-KW35PJCY.js.map +1 -0
  122. package/dist/{mcp-XPDWWU75.js → mcp-2HUGVDJ5.js} +33 -37
  123. package/dist/{mcp-XPDWWU75.js.map → mcp-2HUGVDJ5.js.map} +1 -1
  124. package/dist/{migrate-SBUIWN3U.js → migrate-6VAPYNXI.js} +93 -34
  125. package/dist/migrate-6VAPYNXI.js.map +1 -0
  126. package/dist/notifications-Y7KQCN6K.js +154 -0
  127. package/dist/notifications-Y7KQCN6K.js.map +1 -0
  128. package/dist/open-FADABB2S.js +20 -0
  129. package/dist/{pack-A73LDVOX.js → pack-NTECD3BZ.js} +10 -14
  130. package/dist/{pack-A73LDVOX.js.map → pack-NTECD3BZ.js.map} +1 -1
  131. package/dist/plugin-T2YFCYIO.js +47 -0
  132. package/dist/plugin-from-project-FGX5AHW6.js +15 -0
  133. package/dist/{policy-6VY3CMSU.js → policy-3FOWB4GR.js} +9 -12
  134. package/dist/{policy-6VY3CMSU.js.map → policy-3FOWB4GR.js.map} +1 -1
  135. package/dist/{profile-YCKPMRRU.js → profile-HM3ROXXB.js} +108 -78
  136. package/dist/profile-HM3ROXXB.js.map +1 -0
  137. package/dist/{project-KHPPBKPN.js → project-3DTXKMI6.js} +512 -119
  138. package/dist/project-3DTXKMI6.js.map +1 -0
  139. package/dist/{resource-IJU3FAN5.js → resource-TZDZAVZ6.js} +55 -45
  140. package/dist/resource-TZDZAVZ6.js.map +1 -0
  141. package/dist/status-refresh-worker.js +1155 -0
  142. package/dist/status-refresh-worker.js.map +1 -0
  143. package/dist/{version-Z66FWWMQ.js → version-AMZJHJIB.js} +3 -3
  144. package/dist/version-AMZJHJIB.js.map +1 -0
  145. package/package.json +16 -11
  146. package/dist/apply-SUNDXRJ3.js +0 -54
  147. package/dist/chunk-2A36HWDE.js.map +0 -1
  148. package/dist/chunk-2H7UOFLK.js +0 -11
  149. package/dist/chunk-3FS775NP.js.map +0 -1
  150. package/dist/chunk-43BDGVN3.js.map +0 -1
  151. package/dist/chunk-4ZQ2SCGY.js.map +0 -1
  152. package/dist/chunk-6LTLYV5D.js.map +0 -1
  153. package/dist/chunk-D432JAXV.js.map +0 -1
  154. package/dist/chunk-DF4Z7LAD.js +0 -3463
  155. package/dist/chunk-DF4Z7LAD.js.map +0 -1
  156. package/dist/chunk-EOPFER6N.js.map +0 -1
  157. package/dist/chunk-G6WKY2W4.js +0 -389
  158. package/dist/chunk-G6WKY2W4.js.map +0 -1
  159. package/dist/chunk-IE7B6Q5K.js.map +0 -1
  160. package/dist/chunk-IMROMZ2K.js.map +0 -1
  161. package/dist/chunk-M2U3J7UX.js +0 -46
  162. package/dist/chunk-M2U3J7UX.js.map +0 -1
  163. package/dist/chunk-N3ZCH64F.js.map +0 -1
  164. package/dist/chunk-NAGAJ5UM.js +0 -145
  165. package/dist/chunk-NAGAJ5UM.js.map +0 -1
  166. package/dist/chunk-OML4HXKT.js.map +0 -1
  167. package/dist/chunk-QA5U36JN.js.map +0 -1
  168. package/dist/chunk-R7ZOYVN3.js.map +0 -1
  169. package/dist/chunk-RDG5DT7S.js.map +0 -1
  170. package/dist/chunk-REHRUNBB.js.map +0 -1
  171. package/dist/chunk-RFQ3N7FB.js.map +0 -1
  172. package/dist/chunk-TQ2NA4Z4.js.map +0 -1
  173. package/dist/chunk-ULCD6DJE.js.map +0 -1
  174. package/dist/chunk-WG5A6EAU.js.map +0 -1
  175. package/dist/chunk-XGTTOO4R.js +0 -84
  176. package/dist/chunk-XGTTOO4R.js.map +0 -1
  177. package/dist/chunk-XTVGCVU4.js.map +0 -1
  178. package/dist/chunk-XUJKZQZA.js +0 -235
  179. package/dist/chunk-XUJKZQZA.js.map +0 -1
  180. package/dist/chunk-ZUASVASP.js.map +0 -1
  181. package/dist/doctor-N7ZULPOL.js.map +0 -1
  182. package/dist/environment-OBB3WU5B.js.map +0 -1
  183. package/dist/harness-7KYATIV6.js.map +0 -1
  184. package/dist/help-VXWKLQ6A.js.map +0 -1
  185. package/dist/live-read-cache-TUSP7U3D.js +0 -10
  186. package/dist/marketplace-GXSV6QIY.js.map +0 -1
  187. package/dist/migrate-SBUIWN3U.js.map +0 -1
  188. package/dist/open-HDGLYYVU.js +0 -24
  189. package/dist/plugin-CEO6ZJM5.js +0 -51
  190. package/dist/plugin-from-project-UK7VJVUP.js +0 -18
  191. package/dist/profile-YCKPMRRU.js.map +0 -1
  192. package/dist/project-KHPPBKPN.js.map +0 -1
  193. package/dist/resource-IJU3FAN5.js.map +0 -1
  194. /package/dist/{apply-SUNDXRJ3.js.map → apply-ZGEAY6YZ.js.map} +0 -0
  195. /package/dist/{chunk-3P6BWL5F.js.map → chunk-27IPOVKQ.js.map} +0 -0
  196. /package/dist/{chunk-JQOKQKQT.js.map → chunk-7IBFH736.js.map} +0 -0
  197. /package/dist/{chunk-P2C7JPLD.js.map → chunk-CKJIS2FM.js.map} +0 -0
  198. /package/dist/{chunk-U6DXASQP.js.map → chunk-HC7IZY75.js.map} +0 -0
  199. /package/dist/{chunk-UVVZHWD2.js.map → chunk-I4DKV63E.js.map} +0 -0
  200. /package/dist/{chunk-PNGF5EV2.js.map → chunk-JEC5PWNH.js.map} +0 -0
  201. /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
  202. /package/dist/{chunk-BPWFQKI5.js.map → chunk-NIFKCS7J.js.map} +0 -0
  203. /package/dist/{chunk-7HP6AAI3.js.map → chunk-SMLO5YPI.js.map} +0 -0
  204. /package/dist/{chunk-73OJQTBW.js.map → chunk-T2JBSRGG.js.map} +0 -0
  205. /package/dist/{chunk-GRASK6M6.js.map → chunk-ZREU2UHM.js.map} +0 -0
  206. /package/dist/{chunk-23XSG7LI.js.map → chunk-ZZQDJGWX.js.map} +0 -0
  207. /package/dist/{live-read-cache-TUSP7U3D.js.map → live-read-cache-BHU6L7MA.js.map} +0 -0
  208. /package/dist/{open-HDGLYYVU.js.map → live-read-cache-NQU7M2C7.js.map} +0 -0
  209. /package/dist/{plugin-CEO6ZJM5.js.map → open-FADABB2S.js.map} +0 -0
  210. /package/dist/{plugin-from-project-UK7VJVUP.js.map → plugin-T2YFCYIO.js.map} +0 -0
  211. /package/dist/{version-Z66FWWMQ.js.map → plugin-from-project-FGX5AHW6.js.map} +0 -0
@@ -3,22 +3,193 @@ import {
3
3
  loadSettings,
4
4
  marketplaceRefreshMaxAgeMs,
5
5
  parseTrackedBranches,
6
+ resolveTelemetryProduct,
6
7
  saveSettings
7
- } from "./chunk-REHRUNBB.js";
8
+ } from "./chunk-CWXCZBJR.js";
8
9
  import {
9
- HOST_PLUGIN_MANIFEST_RELATIVE_PATHS,
10
- lookupApSchema,
11
- readCachedMarketplaceJson,
12
- readFirstHostPluginManifest,
13
- readJsonFile,
14
- refreshGitSource,
15
- runCommandWithTimeout
16
- } from "./chunk-G6WKY2W4.js";
10
+ githubGitConfigArgs,
11
+ githubHttpsRemoteForAuth,
12
+ resolveGithubAccessToken
13
+ } from "./chunk-T2JBSRGG.js";
14
+ import {
15
+ isCommandTimeoutStderr,
16
+ mapGitStderr,
17
+ statusTraceEnabled,
18
+ traceFs
19
+ } from "./chunk-MTCCUYBZ.js";
17
20
 
18
- // src/services/marketplace-registry.ts
21
+ // src/services/status-fs.ts
22
+ import * as fs from "fs";
23
+ var existsSync2 = statusTraceEnabled ? (path) => {
24
+ traceFs("stat");
25
+ return fs.existsSync(path);
26
+ } : fs.existsSync;
27
+ var statSync2 = statusTraceEnabled ? (...args) => {
28
+ traceFs("stat");
29
+ return fs.statSync(...args);
30
+ } : fs.statSync;
31
+ var readdirSync2 = statusTraceEnabled ? (...args) => {
32
+ traceFs("dir");
33
+ return fs.readdirSync(...args);
34
+ } : fs.readdirSync;
35
+ var readFileSync2 = statusTraceEnabled ? (...args) => {
36
+ const result = fs.readFileSync(...args);
37
+ traceFs("read", result.length);
38
+ return result;
39
+ } : fs.readFileSync;
40
+
41
+ // src/plugins/host-plugin-manifest.ts
42
+ import { join } from "path";
43
+
44
+ // src/services/agent-plugins/schema-registry.ts
45
+ var AP_SCHEMA_VERSIONS = {
46
+ "1.0.0": {
47
+ version: "1.0.0",
48
+ plugin: "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
49
+ mcp: "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json"
50
+ }
51
+ };
52
+ var AP_CURRENT_VERSION = AP_SCHEMA_VERSIONS["1.0.0"];
53
+ var AP_SCHEMA_URL = AP_CURRENT_VERSION.plugin;
54
+ var AP_MCP_SCHEMA_URL = AP_CURRENT_VERSION.mcp;
55
+ var AP_LEGACY_SCHEMA_URLS = [
56
+ "https://agentplugins.org/schema/v1/plugin.schema.json",
57
+ "https://agentplugins.org/schemas/v1/plugin.json"
58
+ ];
59
+ var SPEC_SCHEMA_PREFIX = "https://agent-plugins.org/schemas/";
60
+ function lookupApSchema(schema) {
61
+ for (const version of Object.values(AP_SCHEMA_VERSIONS)) {
62
+ if (schema === version.plugin) return { kind: "current", version };
63
+ }
64
+ if (AP_LEGACY_SCHEMA_URLS.includes(schema)) {
65
+ return { kind: "legacy", upgradeTo: AP_SCHEMA_URL };
66
+ }
67
+ if (schema.startsWith(SPEC_SCHEMA_PREFIX)) return { kind: "unsupported-spec" };
68
+ return { kind: "unknown" };
69
+ }
70
+ function isAgentPluginsSchemaId(schema) {
71
+ if (typeof schema !== "string") return false;
72
+ return lookupApSchema(schema).kind !== "unknown";
73
+ }
74
+
75
+ // src/services/status-computation.ts
76
+ import { AsyncLocalStorage } from "async_hooks";
77
+ var storage = new AsyncLocalStorage();
78
+ function runInStatusComputation(fn) {
79
+ return storage.run(/* @__PURE__ */ new Map(), fn);
80
+ }
81
+ var slotsDisabled = false;
82
+ function inStatusComputation() {
83
+ return !slotsDisabled && storage.getStore() !== void 0;
84
+ }
85
+ function computationSlot(key, load) {
86
+ const store = storage.getStore();
87
+ if (!store || slotsDisabled) return load();
88
+ if (store.has(key)) return store.get(key);
89
+ const value = load();
90
+ store.set(key, value);
91
+ return value;
92
+ }
93
+
94
+ // src/plugins/host-plugin-manifest.ts
95
+ var HOST_PLUGIN_MANIFEST_RELATIVE_PATHS = [
96
+ ".claude-plugin/plugin.json",
97
+ ".cursor-plugin/plugin.json",
98
+ ".codex-plugin/plugin.json",
99
+ ".github/plugin/plugin.json",
100
+ ".goose-plugin/plugin.json",
101
+ "plugin.json"
102
+ ];
103
+ function readJsonFile(path) {
104
+ if (!existsSync2(path)) return null;
105
+ try {
106
+ return JSON.parse(readFileSync2(path, "utf-8"));
107
+ } catch {
108
+ return null;
109
+ }
110
+ }
111
+ function readFirstHostPluginManifest(installPath) {
112
+ const manifest = computationSlot(
113
+ `host-plugin-manifest:${installPath}`,
114
+ () => readFirstHostPluginManifestUncached(installPath)
115
+ );
116
+ return manifest ? { ...manifest } : null;
117
+ }
118
+ function readFirstHostPluginManifestUncached(installPath) {
119
+ for (const relativePath of HOST_PLUGIN_MANIFEST_RELATIVE_PATHS) {
120
+ const manifest = readJsonFile(
121
+ join(installPath, relativePath)
122
+ );
123
+ if (manifest?.name) {
124
+ return manifest;
125
+ }
126
+ }
127
+ return null;
128
+ }
129
+ function parsePluginRef(ref) {
130
+ const at = ref.lastIndexOf("@");
131
+ if (at <= 0) return { name: ref, marketplace: "" };
132
+ return { name: ref.slice(0, at), marketplace: ref.slice(at + 1) };
133
+ }
134
+
135
+ // src/utils/home-root.ts
19
136
  import { homedir } from "os";
137
+ var homeRootOverride;
138
+ function resolveHomeRoot() {
139
+ if (homeRootOverride) return homeRootOverride;
140
+ return process.env.HOME ?? process.env.USERPROFILE ?? homedir();
141
+ }
142
+
143
+ // src/services/marketplace-registry.ts
20
144
  import { isAbsolute, resolve } from "path";
21
145
  import { fileURLToPath } from "url";
146
+
147
+ // src/services/builtin-marketplaces.ts
148
+ var CURSOR_PUBLIC_MARKETPLACE = "cursor-public";
149
+ var CURSOR_PUBLIC_GIT_URL = "https://github.com/cursor/plugins.git";
150
+ var CURSOR_PUBLIC_PLATFORMS = [
151
+ "cursor",
152
+ "claude-code"
153
+ ];
154
+ function isCursorPublicMarketplace(name) {
155
+ return name === CURSOR_PUBLIC_MARKETPLACE;
156
+ }
157
+ function builtinMarketplaceGitUrl(name) {
158
+ return isCursorPublicMarketplace(name) ? CURSOR_PUBLIC_GIT_URL : null;
159
+ }
160
+ function builtinMarketplaceEntry() {
161
+ return {
162
+ name: CURSOR_PUBLIC_MARKETPLACE,
163
+ url: CURSOR_PUBLIC_GIT_URL,
164
+ platforms: [...CURSOR_PUBLIC_PLATFORMS]
165
+ };
166
+ }
167
+ var WELL_KNOWN_CLAUDE_MARKETPLACES = {
168
+ "claude-plugins-official": "https://github.com/anthropics/claude-plugins-official.git",
169
+ "karpathy-skills": "https://github.com/forrestchang/andrej-karpathy-skills.git",
170
+ // The rest are named by the public harnesstap-cloud persona profiles. Each
171
+ // URL is the repository whose `.claude-plugin/marketplace.json` declares
172
+ // that marketplace name.
173
+ "addy-agent-skills": "https://github.com/addyosmani/agent-skills.git",
174
+ "agentic-awesome-skills": "https://github.com/sickn33/agentic-awesome-skills.git",
175
+ "cc-dev-tools": "https://github.com/Lucklyric/cc-dev-tools.git",
176
+ "claude-code-workflows": "https://github.com/wshobson/agents.git",
177
+ "claude-orchestration": "https://github.com/TheLobbi/claude.git",
178
+ ecc: "https://github.com/affaan-m/ECC.git",
179
+ "fullstack-dev-skills": "https://github.com/Jeffallan/claude-skills.git",
180
+ impeccable: "https://github.com/pbakaus/impeccable.git",
181
+ "llm-council": "https://github.com/hey-yvan/llm-council-plugin.git",
182
+ mempalace: "https://github.com/MemPalace/mempalace.git",
183
+ "slidev-plugins": "https://github.com/slidevjs/slidev.git",
184
+ thedotmack: "https://github.com/thedotmack/claude-mem.git",
185
+ "ui-ux-pro-max-skill": "https://github.com/nextlevelbuilder/ui-ux-pro-max-skill.git"
186
+ };
187
+ function wellKnownMarketplaceEntry(name) {
188
+ const url = WELL_KNOWN_CLAUDE_MARKETPLACES[name];
189
+ return url ? { name, url, platforms: ["claude-code"] } : void 0;
190
+ }
191
+
192
+ // src/services/marketplace-registry.ts
22
193
  function stripGitSuffix(value) {
23
194
  return value.replace(/\.git$/i, "");
24
195
  }
@@ -44,7 +215,7 @@ function normalizeMarketplaceUrl(url) {
44
215
  }
45
216
  }
46
217
  if (isLocalFilesystemSource(trimmed)) {
47
- const expanded = trimmed.startsWith("~/") ? resolve(homedir(), trimmed.slice(2)) : isAbsolute(trimmed) ? trimmed : resolve(trimmed);
218
+ const expanded = trimmed.startsWith("~/") ? resolve(resolveHomeRoot(), trimmed.slice(2)) : isAbsolute(trimmed) ? trimmed : resolve(trimmed);
48
219
  return stripGitSuffix(expanded);
49
220
  }
50
221
  return stripGitSuffix(trimmed);
@@ -61,6 +232,11 @@ function marketplaceEntryPayload(name, url, platforms, trackedBranches) {
61
232
  function listMarketplaces(harnesstapDir) {
62
233
  return loadSettings(harnesstapDir).plugins.marketplaces;
63
234
  }
235
+ function findKnownMarketplace(harnesstapDir, name) {
236
+ const registered = listMarketplaces(harnesstapDir).find((entry) => entry.name === name);
237
+ if (registered) return registered;
238
+ return builtinMarketplaceGitUrl(name) ? builtinMarketplaceEntry() : void 0;
239
+ }
64
240
  function addMarketplace(harnesstapDir, input) {
65
241
  const url = normalizeMarketplaceUrl(input.url);
66
242
  const name = input.name.trim();
@@ -167,54 +343,615 @@ function updateMarketplace(harnesstapDir, currentName, input) {
167
343
  };
168
344
  }
169
345
 
346
+ // src/services/marketplace-catalog-parse.ts
347
+ import { basename } from "path";
348
+ import semver from "semver";
349
+ function isRecord(value) {
350
+ return typeof value === "object" && value !== null && !Array.isArray(value);
351
+ }
352
+ function readMarketplaceName(raw) {
353
+ if (!isRecord(raw)) return "";
354
+ const name = raw.name;
355
+ return typeof name === "string" ? name : "";
356
+ }
357
+ function buildRef(name, marketplaceName) {
358
+ return marketplaceName ? `${name}@${marketplaceName}` : name;
359
+ }
360
+ function resolveVersion(entry) {
361
+ const version = entry.version;
362
+ if (typeof version === "string" && version.length > 0) return version;
363
+ const source = entry.source;
364
+ if (!isRecord(source)) return void 0;
365
+ const sha = source.sha;
366
+ if (typeof sha === "string" && sha.length > 0) return sha.slice(0, 12);
367
+ const ref = source.ref;
368
+ if (typeof ref === "string" && ref.length > 0) return ref;
369
+ return void 0;
370
+ }
371
+ var COMMIT_SHA = /^[0-9a-f]{7,40}$/i;
372
+ function catalogPluginDisplayVersion(plugin) {
373
+ const version = plugin.version?.trim();
374
+ if (version && !COMMIT_SHA.test(version)) return version;
375
+ const manifestVersion = plugin.manifestVersion?.trim();
376
+ return manifestVersion || void 0;
377
+ }
378
+ function catalogPluginVersionLabel(plugin) {
379
+ const version = catalogPluginDisplayVersion(plugin);
380
+ return version ? `v${version}` : void 0;
381
+ }
382
+ function resolveDescription(entry) {
383
+ const description = entry.description;
384
+ return typeof description === "string" && description.length > 0 ? description : void 0;
385
+ }
386
+ function resolveTags(entry) {
387
+ const tags = entry.tags;
388
+ if (!Array.isArray(tags)) return void 0;
389
+ const next = tags.filter(
390
+ (tag) => typeof tag === "string" && tag.trim().length > 0
391
+ );
392
+ return next.length > 0 ? next : void 0;
393
+ }
394
+ function normalizeMarketplaceSourcePath(value) {
395
+ return value.replaceAll("\\", "/").replace(/^\.\//, "").replace(/\/+$/, "");
396
+ }
397
+ function asMarketplaceSourcePath(value) {
398
+ const trimmed = value.trim().replaceAll("\\", "/");
399
+ if (trimmed === "." || trimmed === "./") return ".";
400
+ const normalized = normalizeMarketplaceSourcePath(trimmed);
401
+ return normalized.length > 0 ? normalized : void 0;
402
+ }
403
+ function resolveSourcePath(entry) {
404
+ const source = entry.source;
405
+ if (typeof source === "string" && source.trim().length > 0) {
406
+ return asMarketplaceSourcePath(source);
407
+ }
408
+ if (isRecord(source)) {
409
+ const nested = source.path;
410
+ if (typeof nested === "string" && nested.trim().length > 0) {
411
+ return asMarketplaceSourcePath(nested);
412
+ }
413
+ }
414
+ const path = entry.path;
415
+ if (typeof path === "string" && path.trim().length > 0) {
416
+ return asMarketplaceSourcePath(path);
417
+ }
418
+ return void 0;
419
+ }
420
+ function parsePluginEntry(entry, marketplaceName, resolveName) {
421
+ if (!isRecord(entry)) return void 0;
422
+ const name = resolveName(entry);
423
+ if (!name) return void 0;
424
+ const version = resolveVersion(entry);
425
+ const description = resolveDescription(entry);
426
+ const tags = resolveTags(entry);
427
+ const sourcePath = resolveSourcePath(entry);
428
+ const ref = buildRef(name, marketplaceName);
429
+ return {
430
+ name,
431
+ ...version !== void 0 ? { version } : {},
432
+ ref,
433
+ ...description !== void 0 ? { description } : {},
434
+ ...tags !== void 0 ? { tags } : {},
435
+ ...sourcePath !== void 0 ? { sourcePath } : {}
436
+ };
437
+ }
438
+ function parsePlugins(raw, marketplaceName, resolveName) {
439
+ if (!isRecord(raw)) return [];
440
+ const plugins = raw.plugins;
441
+ if (!Array.isArray(plugins)) return [];
442
+ const parsed = [];
443
+ for (const entry of plugins) {
444
+ const plugin = parsePluginEntry(entry, marketplaceName, resolveName);
445
+ if (plugin) parsed.push(plugin);
446
+ }
447
+ return parsed;
448
+ }
449
+ function resolveClaudePluginName(entry) {
450
+ const name = entry.name;
451
+ return typeof name === "string" && name.length > 0 ? name : void 0;
452
+ }
453
+ function resolveCursorPluginName(entry) {
454
+ const name = entry.name;
455
+ if (typeof name === "string" && name.length > 0) return name;
456
+ const path = entry.path;
457
+ if (typeof path === "string" && path.length > 0) {
458
+ const derived = basename(path);
459
+ return derived.length > 0 ? derived : void 0;
460
+ }
461
+ return void 0;
462
+ }
463
+ function parseClaudeMarketplaceManifest(raw) {
464
+ const marketplaceName = readMarketplaceName(raw);
465
+ const plugins = parsePlugins(raw, marketplaceName, resolveClaudePluginName);
466
+ return { marketplaceName, plugins };
467
+ }
468
+ function parseCodexMarketplaceManifest(raw) {
469
+ return parseClaudeMarketplaceManifest(raw);
470
+ }
471
+ function sourcePathLeavesMarketplace(sourcePath) {
472
+ if (!sourcePath) return false;
473
+ return sourcePath.replaceAll("\\", "/").split("/").includes("..");
474
+ }
475
+ function escapingMarketplaceSourceWarning(pluginName) {
476
+ return `Skipped ${pluginName}: source path leaves the marketplace repository.`;
477
+ }
478
+ function partitionEscapingCatalogPlugins(plugins) {
479
+ const kept = [];
480
+ const warnings = [];
481
+ for (const plugin of plugins) {
482
+ if (!sourcePathLeavesMarketplace(plugin.sourcePath)) {
483
+ kept.push(plugin);
484
+ continue;
485
+ }
486
+ warnings.push(escapingMarketplaceSourceWarning(plugin.name));
487
+ }
488
+ return { plugins: kept, warnings };
489
+ }
490
+ function parseCursorMarketplaceManifest(raw) {
491
+ const marketplaceName = readMarketplaceName(raw);
492
+ const plugins = parsePlugins(raw, marketplaceName, resolveCursorPluginName);
493
+ return { marketplaceName, plugins };
494
+ }
495
+ function catalogSemver(version) {
496
+ if (!version?.trim()) return null;
497
+ const trimmed = version.trim();
498
+ const withoutV = trimmed.startsWith("v") ? trimmed.slice(1) : trimmed;
499
+ return semver.valid(withoutV);
500
+ }
501
+ function preferCatalogPlugin(current, incoming) {
502
+ const currentRank = catalogSemver(current.version);
503
+ const incomingRank = catalogSemver(incoming.version);
504
+ const preferIncoming = incomingRank !== null && (currentRank === null || semver.rcompare(incomingRank, currentRank) < 0);
505
+ const chosen = preferIncoming ? incoming : current;
506
+ const other = preferIncoming ? current : incoming;
507
+ const tags = uniqueStrings([...chosen.tags ?? [], ...other.tags ?? []]);
508
+ const contents = chosen.contents?.length ? chosen.contents : other.contents;
509
+ return {
510
+ ...chosen,
511
+ version: chosen.version ?? other.version,
512
+ ...chosen.manifestVersion ?? other.manifestVersion ? { manifestVersion: chosen.manifestVersion ?? other.manifestVersion } : {},
513
+ description: chosen.description ?? other.description,
514
+ sourcePath: chosen.sourcePath ?? other.sourcePath,
515
+ ...tags.length > 0 ? { tags } : {},
516
+ ...contents && contents.length > 0 ? { contents } : {}
517
+ };
518
+ }
519
+ function uniqueStrings(values) {
520
+ const seen = /* @__PURE__ */ new Set();
521
+ const next = [];
522
+ for (const value of values) {
523
+ if (seen.has(value)) continue;
524
+ seen.add(value);
525
+ next.push(value);
526
+ }
527
+ return next;
528
+ }
529
+ function catalogPluginIdentity(plugin) {
530
+ return `${plugin.name}\0${plugin.flavor ?? ""}`;
531
+ }
532
+ function mergeCatalogPluginsByIdentity(plugins) {
533
+ const byName = /* @__PURE__ */ new Map();
534
+ for (const plugin of plugins) {
535
+ const identity = catalogPluginIdentity(plugin);
536
+ const existing = byName.get(identity);
537
+ if (!existing) {
538
+ byName.set(identity, plugin);
539
+ continue;
540
+ }
541
+ byName.set(identity, preferCatalogPlugin(existing, plugin));
542
+ }
543
+ return [...byName.values()];
544
+ }
545
+
170
546
  // src/services/marketplace-catalog.ts
171
547
  import {
172
- existsSync as existsSync3,
173
- mkdirSync,
548
+ existsSync as existsSync6,
549
+ mkdirSync as mkdirSync2,
174
550
  mkdtempSync,
175
- readFileSync as readFileSync3,
176
- renameSync,
177
- rmSync,
178
- statSync as statSync3,
551
+ readFileSync as readFileSync5,
552
+ renameSync as renameSync2,
553
+ rmSync as rmSync2,
554
+ statSync as statSync5,
179
555
  writeFileSync
180
556
  } from "fs";
181
557
  import { tmpdir } from "os";
182
- import { dirname, join as join3 } from "path";
558
+ import { dirname, join as join5 } from "path";
183
559
 
184
- // src/services/builtin-marketplaces.ts
185
- var CURSOR_PUBLIC_MARKETPLACE = "cursor-public";
186
- var CURSOR_PUBLIC_GIT_URL = "https://github.com/cursor/plugins.git";
187
- var CURSOR_PUBLIC_PLATFORMS = [
188
- "cursor",
189
- "claude-code"
190
- ];
191
- function isCursorPublicMarketplace(name) {
192
- return name === CURSOR_PUBLIC_MARKETPLACE;
560
+ // src/plugins/refresh.ts
561
+ import { copyFileSync, existsSync as existsSync3, mkdirSync, renameSync, rmSync } from "fs";
562
+ import { join as join2 } from "path";
563
+
564
+ // src/utils/spawn-command.ts
565
+ import { spawn } from "child_process";
566
+
567
+ // src/utils/git-network.ts
568
+ import { execFileSync } from "child_process";
569
+ var GIT_TIMEOUT_ENV = "HARNESSTAP_GIT_TIMEOUT_SECONDS";
570
+ var DEFAULT_GIT_NETWORK_TIMEOUT_MS = 6e4;
571
+ var DEFAULT_CLAUDE_PLUGIN_TIMEOUT_MS = 6e5;
572
+ var DEFAULT_GIT_LOW_SPEED_LIMIT = "1000";
573
+ var DEFAULT_GIT_LOW_SPEED_TIME = "30";
574
+ var NETWORK_SUBCOMMANDS = /* @__PURE__ */ new Set(["clone", "fetch", "ls-remote", "pull", "push"]);
575
+ var OPTIONS_WITH_VALUE = /* @__PURE__ */ new Set(["-c", "-C", "--git-dir", "--work-tree", "--namespace"]);
576
+ var SUBCOMMAND_OPTIONS_WITH_VALUE = /* @__PURE__ */ new Set([
577
+ "-b",
578
+ "--branch",
579
+ "--depth",
580
+ "-o",
581
+ "--origin",
582
+ "--config",
583
+ "--reference",
584
+ "--filter",
585
+ "-j",
586
+ "--jobs",
587
+ "--template",
588
+ "-u",
589
+ "--upload-pack",
590
+ "--shallow-since",
591
+ "--shallow-exclude",
592
+ "--separate-git-dir",
593
+ "--server-option"
594
+ ]);
595
+ function gitTimeoutOverrideMs(env = process.env) {
596
+ const raw = env[GIT_TIMEOUT_ENV]?.trim();
597
+ if (!raw) return void 0;
598
+ const seconds2 = Number(raw);
599
+ if (!Number.isFinite(seconds2) || seconds2 <= 0) return void 0;
600
+ return Math.round(seconds2 * 1e3);
601
+ }
602
+ function gitSubcommand(args) {
603
+ for (let i = 0; i < args.length; i += 1) {
604
+ const arg = args[i] ?? "";
605
+ if (OPTIONS_WITH_VALUE.has(arg)) {
606
+ i += 1;
607
+ continue;
608
+ }
609
+ if (arg.startsWith("-")) continue;
610
+ return { name: arg, rest: args.slice(i + 1) };
611
+ }
612
+ return void 0;
193
613
  }
194
- function builtinMarketplaceGitUrl(name) {
195
- return isCursorPublicMarketplace(name) ? CURSOR_PUBLIC_GIT_URL : null;
614
+ function isGitNetworkCommand(args) {
615
+ const sub = gitSubcommand(args);
616
+ return sub !== void 0 && NETWORK_SUBCOMMANDS.has(sub.name);
196
617
  }
197
- function builtinMarketplaceEntry() {
618
+ function isClaudePluginCommand(command, args) {
619
+ const base = command.split(/[\\/]/).pop() ?? command;
620
+ return /^claude(\.exe|\.cmd)?$/.test(base) && args[0] === "plugin";
621
+ }
622
+ function redactRemote(remote) {
623
+ return remote.replace(/^([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/i, "$1");
624
+ }
625
+ function positionalArgs(rest) {
626
+ const out = [];
627
+ for (let i = 0; i < rest.length; i += 1) {
628
+ const arg = rest[i] ?? "";
629
+ if (SUBCOMMAND_OPTIONS_WITH_VALUE.has(arg)) {
630
+ i += 1;
631
+ continue;
632
+ }
633
+ if (!arg.startsWith("-")) out.push(arg);
634
+ }
635
+ return out;
636
+ }
637
+ function gitDirFromArgs(args, cwd) {
638
+ const at = args.indexOf("-C");
639
+ return at >= 0 && args[at + 1] ? args[at + 1] : cwd;
640
+ }
641
+ function gitRemoteFromArgs(args, cwd) {
642
+ const sub = gitSubcommand(args);
643
+ if (!sub || !NETWORK_SUBCOMMANDS.has(sub.name)) return void 0;
644
+ const remote = positionalArgs(sub.rest)[0] ?? (sub.name === "clone" ? void 0 : "origin");
645
+ if (!remote) return void 0;
646
+ if (/[/:\\]/.test(remote)) return redactRemote(remote);
647
+ const dir = gitDirFromArgs(args, cwd);
648
+ if (!dir) return remote;
649
+ try {
650
+ const url = execFileSync("git", ["-C", dir, "remote", "get-url", remote], {
651
+ encoding: "utf8",
652
+ stdio: ["ignore", "pipe", "ignore"],
653
+ timeout: 5e3,
654
+ env: process.env
655
+ }).trim();
656
+ return url ? redactRemote(url) : remote;
657
+ } catch {
658
+ return remote;
659
+ }
660
+ }
661
+ function withGitLowSpeedEnv(env) {
662
+ return {
663
+ ...env,
664
+ GIT_HTTP_LOW_SPEED_LIMIT: env.GIT_HTTP_LOW_SPEED_LIMIT ?? DEFAULT_GIT_LOW_SPEED_LIMIT,
665
+ GIT_HTTP_LOW_SPEED_TIME: env.GIT_HTTP_LOW_SPEED_TIME ?? DEFAULT_GIT_LOW_SPEED_TIME
666
+ };
667
+ }
668
+ function seconds(ms) {
669
+ const value = ms / 1e3;
670
+ return Number.isInteger(value) ? String(value) : value.toFixed(1);
671
+ }
672
+ function gitTimeoutMessage(command, args, timeoutMs, cwd) {
673
+ const remote = gitRemoteFromArgs(args, cwd);
674
+ const hint = `Set ${GIT_TIMEOUT_ENV} to allow more time.`;
675
+ if (command === "git") {
676
+ const sub = gitSubcommand(args)?.name ?? "command";
677
+ const target = remote ? ` for ${remote}` : "";
678
+ return `git ${sub} timed out after ${seconds(timeoutMs)}s${target}. The remote did not answer in time. ${hint}`;
679
+ }
680
+ const shown = args.map(redactRemote).join(" ");
681
+ return `${command} ${shown} timed out after ${seconds(timeoutMs)}s while git fetched from a remote. ${hint}`;
682
+ }
683
+ function gitStallMessage(args, stderr, cwd) {
684
+ if (!/operation too slow|less than \d+ bytes\/sec/i.test(stderr)) return void 0;
685
+ const remote = gitRemoteFromArgs(args, cwd);
686
+ const sub = gitSubcommand(args)?.name ?? "command";
687
+ const target = remote ? ` for ${remote}` : "";
688
+ return `git ${sub} stalled${target}: the remote stopped sending data and git gave up. Try again, or check the network.`;
689
+ }
690
+
691
+ // src/utils/spawn-command.ts
692
+ var DEFAULT_GIT_CLONE_TIMEOUT_MS = DEFAULT_GIT_NETWORK_TIMEOUT_MS;
693
+ var UNATTENDED_GIT_TIMEOUT_MS = 15e3;
694
+ var UNATTENDED_SSH_CONNECT_TIMEOUT_SEC = 15;
695
+ var inflightChildren = /* @__PURE__ */ new Set();
696
+ function gitCommandEnv(options) {
697
+ const env = withGitLowSpeedEnv({
698
+ ...process.env,
699
+ GIT_TERMINAL_PROMPT: "0",
700
+ GCM_INTERACTIVE: "never"
701
+ });
702
+ if (!options?.unattended) {
703
+ return env;
704
+ }
705
+ const existing = process.env.GIT_SSH_COMMAND?.trim();
706
+ const base = existing && existing.length > 0 ? existing : "ssh";
707
+ const withTimeout = /\bConnectTimeout=/.test(base) ? base : `${base} -o ConnectTimeout=${UNATTENDED_SSH_CONNECT_TIMEOUT_SEC}`;
708
+ env.GIT_SSH_COMMAND = /\bBatchMode=/.test(withTimeout) ? withTimeout : `${withTimeout} -o BatchMode=yes`;
709
+ return env;
710
+ }
711
+ function resolveCommandTimeoutMs(options, command, args = []) {
712
+ if (options?.unattended) {
713
+ return options.timeoutMs ?? UNATTENDED_GIT_TIMEOUT_MS;
714
+ }
715
+ const override = gitTimeoutOverrideMs();
716
+ if (command === "git" && isGitNetworkCommand(args)) {
717
+ return override ?? options?.timeoutMs ?? DEFAULT_GIT_NETWORK_TIMEOUT_MS;
718
+ }
719
+ if (command !== void 0 && isClaudePluginCommand(command, args)) {
720
+ return Math.max(override ?? 0, options?.timeoutMs ?? DEFAULT_CLAUDE_PLUGIN_TIMEOUT_MS);
721
+ }
722
+ return options?.timeoutMs;
723
+ }
724
+ function commandEnv(command, args, options) {
725
+ if (command === "git") return gitCommandEnv(options);
726
+ if (isClaudePluginCommand(command, args)) return withGitLowSpeedEnv(process.env);
727
+ return process.env;
728
+ }
729
+ function spawnCommand(command, args, options) {
730
+ const timeoutMs = resolveCommandTimeoutMs(options, command, args);
731
+ return new Promise((resolve2) => {
732
+ let stdout = "";
733
+ let stderr = "";
734
+ let settled = false;
735
+ const child = spawn(command, args, {
736
+ cwd: options?.cwd,
737
+ env: commandEnv(command, args, options),
738
+ stdio: ["ignore", "pipe", "pipe"]
739
+ });
740
+ inflightChildren.add(child);
741
+ const finish = (result) => {
742
+ if (settled) return;
743
+ settled = true;
744
+ if (timer) clearTimeout(timer);
745
+ inflightChildren.delete(child);
746
+ resolve2(result);
747
+ };
748
+ const timer = timeoutMs === void 0 ? void 0 : setTimeout(() => {
749
+ child.kill("SIGTERM");
750
+ child.stdout?.destroy();
751
+ child.stderr?.destroy();
752
+ const watched = command === "git" && isGitNetworkCommand(args) || isClaudePluginCommand(command, args);
753
+ finish({
754
+ stdout,
755
+ stderr: watched ? gitTimeoutMessage(command, args, timeoutMs, options?.cwd) : `Command timed out after ${timeoutMs}ms: ${command} ${args.join(" ")}`,
756
+ exitCode: 124
757
+ });
758
+ }, timeoutMs);
759
+ child.stdout?.on("data", (chunk) => {
760
+ stdout += chunk.toString();
761
+ });
762
+ child.stderr?.on("data", (chunk) => {
763
+ stderr += chunk.toString();
764
+ });
765
+ child.on("error", (error) => {
766
+ const missing = "code" in error && error.code === "ENOENT";
767
+ finish({
768
+ stdout,
769
+ stderr: missing ? `${command}: command not found` : error.message,
770
+ exitCode: missing ? 127 : 1
771
+ });
772
+ });
773
+ child.on("close", (code) => {
774
+ const stalled = code !== 0 && command === "git" ? gitStallMessage(args, stderr, options?.cwd) : void 0;
775
+ finish({
776
+ stdout,
777
+ stderr: stalled ?? stderr,
778
+ exitCode: code ?? 1
779
+ });
780
+ });
781
+ });
782
+ }
783
+
784
+ // src/utils/run-command-with-timeout.ts
785
+ function runCommandWithTimeout(command, args, options) {
786
+ const timeoutMs = options?.unattended ? options.timeoutMs : options?.timeoutMs ?? DEFAULT_GIT_CLONE_TIMEOUT_MS;
787
+ return spawnCommand(command, args, {
788
+ ...options,
789
+ timeoutMs
790
+ });
791
+ }
792
+
793
+ // src/plugins/run-command.ts
794
+ async function resolveCommandResult(result) {
795
+ return await result;
796
+ }
797
+ var defaultRunCommand = (command, args, options) => {
798
+ return spawnCommand(command, args, options);
799
+ };
800
+
801
+ // src/plugins/refresh.ts
802
+ var COMMIT_LIKE = /^[0-9a-f]{7,40}$/i;
803
+ var FULL_SHA = /^[0-9a-f]{40}$/i;
804
+ async function checkoutCommit(git, url, staging, sha) {
805
+ if (FULL_SHA.test(sha)) {
806
+ const init = await git(["init", "--quiet", staging]);
807
+ if (init.exitCode === 0) {
808
+ const remote = await git(["-C", staging, "remote", "add", "origin", url]);
809
+ const fetch = remote.exitCode === 0 ? await git(["-C", staging, "fetch", "--depth", "1", "origin", sha]) : remote;
810
+ if (fetch.exitCode === 0) {
811
+ const checkout2 = await git(["-C", staging, "checkout", "--quiet", "--detach", "FETCH_HEAD"]);
812
+ if (checkout2.exitCode === 0) return { ok: true, message: "" };
813
+ }
814
+ }
815
+ rmSync(staging, { recursive: true, force: true });
816
+ mkdirSync(staging, { recursive: true });
817
+ }
818
+ const clone = await git(["clone", "--quiet", "--no-checkout", url, staging]);
819
+ if (clone.exitCode !== 0) {
820
+ return { ok: false, message: clone.stderr.trim() || "git clone failed" };
821
+ }
822
+ const resolved = await git(["-C", staging, "rev-parse", "--verify", "--quiet", `${sha}^{commit}`]);
823
+ if (resolved.exitCode !== 0 || !resolved.stdout.trim()) {
824
+ return { ok: false, message: `Commit ${sha} was not found in ${url}` };
825
+ }
826
+ const checkout = await git(["-C", staging, "checkout", "--quiet", "--detach", resolved.stdout.trim()]);
827
+ if (checkout.exitCode !== 0) {
828
+ return { ok: false, message: checkout.stderr.trim() || `git checkout ${sha} failed` };
829
+ }
830
+ return { ok: true, message: "" };
831
+ }
832
+ async function refreshGitSource(opts) {
833
+ const run = opts.runCommand ?? runCommandWithTimeout;
834
+ const unattended = opts.unattended === true;
835
+ const timeoutMs = unattended ? UNATTENDED_GIT_TIMEOUT_MS : DEFAULT_GIT_CLONE_TIMEOUT_MS;
836
+ const staging = `${opts.targetDir}.incoming`;
837
+ if (existsSync3(staging)) {
838
+ rmSync(staging, { recursive: true, force: true });
839
+ }
840
+ mkdirSync(staging, { recursive: true });
841
+ const token = resolveGithubAccessToken().token;
842
+ const url = githubHttpsRemoteForAuth(opts.url, token);
843
+ const git = (args) => resolveCommandResult(run("git", [...githubGitConfigArgs(token), ...args], { timeoutMs, unattended }));
844
+ const fail = (message, timedOut = false) => {
845
+ rmSync(staging, { recursive: true, force: true });
846
+ return { ok: false, message, ...timedOut ? { timedOut: true } : {} };
847
+ };
848
+ const ref = opts.ref?.trim() || void 0;
849
+ let cloned = false;
850
+ let lastError = "git clone failed";
851
+ if (ref && COMMIT_LIKE.test(ref)) {
852
+ const checkedOut = await checkoutCommit(git, url, staging, ref);
853
+ if (checkedOut.ok) {
854
+ cloned = true;
855
+ } else {
856
+ lastError = checkedOut.message;
857
+ rmSync(staging, { recursive: true, force: true });
858
+ mkdirSync(staging, { recursive: true });
859
+ }
860
+ }
861
+ if (!cloned) {
862
+ const cloneArgs = ["clone", "--depth", "1"];
863
+ if (ref) cloneArgs.push("--branch", ref);
864
+ cloneArgs.push(url, staging);
865
+ const clone = await git(cloneArgs);
866
+ if (clone.exitCode !== 0) {
867
+ const stderr = clone.stderr.trim();
868
+ if (ref && /not found|did not match|Remote branch .* not found/i.test(stderr || lastError)) {
869
+ return fail(`Git ref ${ref} was not found in ${opts.url}`, isCommandTimeoutStderr(stderr || lastError));
870
+ }
871
+ return fail(mapGitStderr(stderr || lastError, opts.url), isCommandTimeoutStderr(stderr || lastError));
872
+ }
873
+ }
874
+ const rev = await git(["-C", staging, "rev-parse", "HEAD"]);
875
+ if (rev.exitCode !== 0) {
876
+ return fail(mapGitStderr(rev.stderr.trim() || "git rev-parse failed", opts.url), isCommandTimeoutStderr(rev.stderr));
877
+ }
878
+ if (ref && COMMIT_LIKE.test(ref) && cloned && !rev.stdout.trim().toLowerCase().startsWith(ref.toLowerCase())) {
879
+ return fail(`Checked out ${rev.stdout.trim()} instead of pinned commit ${ref} from ${opts.url}`);
880
+ }
881
+ const backup = `${opts.targetDir}.previous`;
882
+ if (existsSync3(backup)) {
883
+ rmSync(backup, { recursive: true, force: true });
884
+ }
885
+ if (existsSync3(opts.targetDir)) {
886
+ renameSync(opts.targetDir, backup);
887
+ }
888
+ renameSync(staging, opts.targetDir);
889
+ const previousCatalog = join2(backup, "catalog.json");
890
+ const nextCatalog = join2(opts.targetDir, "catalog.json");
891
+ if (existsSync3(previousCatalog) && !existsSync3(nextCatalog)) {
892
+ copyFileSync(previousCatalog, nextCatalog);
893
+ }
894
+ if (existsSync3(backup)) {
895
+ rmSync(backup, { recursive: true, force: true });
896
+ }
198
897
  return {
199
- name: CURSOR_PUBLIC_MARKETPLACE,
200
- url: CURSOR_PUBLIC_GIT_URL,
201
- platforms: [...CURSOR_PUBLIC_PLATFORMS]
898
+ ok: true,
899
+ sha: rev.stdout.trim(),
900
+ message: "Refreshed from git"
202
901
  };
203
902
  }
903
+ function cursorRepoSourceKey(url) {
904
+ return `cursor:repo:${url}`;
905
+ }
906
+ function cursorCacheRoot(homeRoot) {
907
+ return join2(homeRoot, ".cursor", "plugins", "cache");
908
+ }
909
+ function cursorLocalRoot(homeRoot) {
910
+ return join2(homeRoot, ".cursor", "plugins", "local");
911
+ }
912
+ function cursorMarketplacesRoot(homeRoot) {
913
+ return join2(homeRoot, ".cursor", "plugins", "marketplaces");
914
+ }
915
+ function cursorProjectsMcpsRoot(homeRoot) {
916
+ return join2(homeRoot, ".cursor", "projects", "mcps");
917
+ }
204
918
 
205
919
  // src/services/marketplace-catalog-index.ts
206
- import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
207
- import { join as join2 } from "path";
208
- import matter2 from "gray-matter";
920
+ import { existsSync as existsSync5, readdirSync as readdirSync4, readFileSync as readFileSync4, statSync as statSync4 } from "fs";
921
+ import { join as join4 } from "path";
209
922
 
210
- // src/services/skill-discovery.ts
211
- import { existsSync, readdirSync, readFileSync, statSync } from "fs";
212
- import { join, relative } from "path";
923
+ // src/utils/frontmatter.ts
213
924
  import matter from "gray-matter";
925
+ function parseFrontmatter(text) {
926
+ return matter(text, {});
927
+ }
928
+ function parseFrontmatterLenient(text) {
929
+ try {
930
+ return parseFrontmatter(text);
931
+ } catch (error) {
932
+ const match = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(text);
933
+ if (!match) throw error;
934
+ const data = {};
935
+ for (const line of (match[1] ?? "").split(/\r?\n/)) {
936
+ if (line.trim() === "" || line.trimStart().startsWith("#")) continue;
937
+ const field = /^([A-Za-z0-9_-]+):[ \t]*(.*)$/.exec(line);
938
+ if (!field || !field[1]) throw error;
939
+ const value = (field[2] ?? "").trim();
940
+ if (value === "" || /^[[{|>&*!]/.test(value)) throw error;
941
+ data[field[1]] = value;
942
+ }
943
+ const strict = parseFrontmatter("---\n---\n");
944
+ return { ...strict, data, content: text.slice(match[0].length), matter: match[1] ?? "" };
945
+ }
946
+ }
947
+
948
+ // src/services/skill-discovery.ts
949
+ import { existsSync as existsSync4, readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
950
+ import { join as join3, relative } from "path";
214
951
  var SKILL_ROOTS = ["skills", ".agents/skills"];
215
952
  function isDirectory(path) {
216
953
  try {
217
- return statSync(path).isDirectory();
954
+ return statSync3(path).isDirectory();
218
955
  } catch {
219
956
  return false;
220
957
  }
@@ -249,18 +986,18 @@ function parseSkillFrontmatterFallback(raw) {
249
986
  }
250
987
  function parseSkillMarkdown(raw) {
251
988
  try {
252
- const parsed = matter(raw);
989
+ const parsed = parseFrontmatter(raw);
253
990
  return { data: parsed.data, content: parsed.content };
254
991
  } catch {
255
992
  return parseSkillFrontmatterFallback(raw);
256
993
  }
257
994
  }
258
995
  function readSkillMd(skillDir) {
259
- const skillPath = join(skillDir, "SKILL.md");
260
- if (!existsSync(skillPath)) return null;
996
+ const skillPath = join3(skillDir, "SKILL.md");
997
+ if (!existsSync4(skillPath)) return null;
261
998
  let raw;
262
999
  try {
263
- raw = readFileSync(skillPath, "utf-8");
1000
+ raw = readFileSync3(skillPath, "utf-8");
264
1001
  } catch {
265
1002
  return null;
266
1003
  }
@@ -289,19 +1026,19 @@ function walkForSkills(rootPath, currentDir, results) {
289
1026
  });
290
1027
  return;
291
1028
  }
292
- for (const entry of readdirSync(currentDir)) {
1029
+ for (const entry of readdirSync3(currentDir)) {
293
1030
  if (entry.startsWith(".")) continue;
294
- walkForSkills(rootPath, join(currentDir, entry), results);
1031
+ walkForSkills(rootPath, join3(currentDir, entry), results);
295
1032
  }
296
1033
  }
297
1034
  function discoverSkillPackage(rootPath) {
298
1035
  const results = [];
299
1036
  for (const root of SKILL_ROOTS) {
300
- const dir = join(rootPath, root);
1037
+ const dir = join3(rootPath, root);
301
1038
  if (!isDirectory(dir)) continue;
302
- for (const entry of readdirSync(dir)) {
1039
+ for (const entry of readdirSync3(dir)) {
303
1040
  if (entry.startsWith(".")) continue;
304
- walkForSkills(rootPath, join(dir, entry), results);
1041
+ walkForSkills(rootPath, join3(dir, entry), results);
305
1042
  }
306
1043
  }
307
1044
  const byName = /* @__PURE__ */ new Map();
@@ -317,12 +1054,12 @@ var PLUGIN_ROOT_WALK_MAX_DEPTH = 6;
317
1054
  var COMMAND_DIRS = ["commands", ".claude/commands"];
318
1055
  function isDirectory2(path) {
319
1056
  try {
320
- return existsSync2(path) && statSync2(path).isDirectory();
1057
+ return existsSync5(path) && statSync4(path).isDirectory();
321
1058
  } catch {
322
1059
  return false;
323
1060
  }
324
1061
  }
325
- function uniqueStrings(values) {
1062
+ function uniqueStrings2(values) {
326
1063
  const seen = /* @__PURE__ */ new Set();
327
1064
  const next = [];
328
1065
  for (const value of values) {
@@ -333,7 +1070,7 @@ function uniqueStrings(values) {
333
1070
  return next;
334
1071
  }
335
1072
  function agentPluginPackageFormat(pluginRoot) {
336
- const manifest = readJsonFile(join2(pluginRoot, "plugin.json"));
1073
+ const manifest = readJsonFile(join4(pluginRoot, "plugin.json"));
337
1074
  const schema = manifest?.$schema;
338
1075
  if (typeof schema === "string" && lookupApSchema(schema).kind === "current") {
339
1076
  return "agent-plugin";
@@ -342,21 +1079,21 @@ function agentPluginPackageFormat(pluginRoot) {
342
1079
  }
343
1080
  function looksLikePluginRoot(path) {
344
1081
  for (const relative2 of HOST_PLUGIN_MANIFEST_RELATIVE_PATHS) {
345
- if (existsSync2(join2(path, relative2))) return true;
1082
+ if (existsSync5(join4(path, relative2))) return true;
346
1083
  }
347
- return isDirectory2(join2(path, "skills")) || isDirectory2(join2(path, "commands"));
1084
+ return isDirectory2(join4(path, "skills")) || isDirectory2(join4(path, "commands"));
348
1085
  }
349
1086
  function walkNamedPluginRoot(dir, pluginName, depth) {
350
1087
  if (depth > PLUGIN_ROOT_WALK_MAX_DEPTH || !isDirectory2(dir)) {
351
1088
  return void 0;
352
1089
  }
353
1090
  try {
354
- const entries = readdirSync2(dir, { withFileTypes: true });
1091
+ const entries = readdirSync4(dir, { withFileTypes: true });
355
1092
  for (const entry of entries) {
356
1093
  if (!entry.isDirectory() || PLUGIN_ROOT_WALK_SKIP.has(entry.name)) {
357
1094
  continue;
358
1095
  }
359
- const child = join2(dir, entry.name);
1096
+ const child = join4(dir, entry.name);
360
1097
  if (entry.name === pluginName && looksLikePluginRoot(child)) {
361
1098
  return child;
362
1099
  }
@@ -370,14 +1107,14 @@ function walkNamedPluginRoot(dir, pluginName, depth) {
370
1107
  }
371
1108
  function resolveMarketplaceCatalogPluginRoot(marketplaceRoot, plugin) {
372
1109
  if (plugin.sourcePath) {
373
- const fromSource = join2(marketplaceRoot, plugin.sourcePath);
1110
+ const fromSource = join4(marketplaceRoot, plugin.sourcePath);
374
1111
  if (isDirectory2(fromSource)) return fromSource;
375
1112
  }
376
- const underPlugins = join2(marketplaceRoot, "plugins", plugin.name);
1113
+ const underPlugins = join4(marketplaceRoot, "plugins", plugin.name);
377
1114
  if (isDirectory2(underPlugins) && looksLikePluginRoot(underPlugins)) {
378
1115
  return underPlugins;
379
1116
  }
380
- const atRoot = join2(marketplaceRoot, plugin.name);
1117
+ const atRoot = join4(marketplaceRoot, plugin.name);
381
1118
  if (isDirectory2(atRoot) && looksLikePluginRoot(atRoot)) {
382
1119
  return atRoot;
383
1120
  }
@@ -387,22 +1124,22 @@ function commandContents(pluginRoot) {
387
1124
  const contents = [];
388
1125
  const seen = /* @__PURE__ */ new Set();
389
1126
  for (const relative2 of COMMAND_DIRS) {
390
- const dir = join2(pluginRoot, relative2);
1127
+ const dir = join4(pluginRoot, relative2);
391
1128
  if (!isDirectory2(dir)) continue;
392
1129
  let entries;
393
1130
  try {
394
- entries = readdirSync2(dir, { encoding: "utf8" });
1131
+ entries = readdirSync4(dir, { encoding: "utf8" });
395
1132
  } catch {
396
1133
  continue;
397
1134
  }
398
1135
  for (const entry of entries) {
399
1136
  const name = entry.replace(/\.(md|toml)$/, "");
400
1137
  if (name === entry || seen.has(name)) continue;
401
- const absolute = join2(dir, entry);
1138
+ const absolute = join4(dir, entry);
402
1139
  let description;
403
1140
  if (entry.endsWith(".md")) {
404
1141
  try {
405
- const parsed = matter2(readFileSync2(absolute, "utf8"));
1142
+ const parsed = parseFrontmatter(readFileSync4(absolute, "utf8"));
406
1143
  if (typeof parsed.data.description === "string") {
407
1144
  description = parsed.data.description;
408
1145
  }
@@ -423,7 +1160,7 @@ function commandContents(pluginRoot) {
423
1160
  function enrichCatalogPlugin(marketplaceRoot, plugin) {
424
1161
  const pluginRoot = resolveMarketplaceCatalogPluginRoot(marketplaceRoot, plugin);
425
1162
  if (!pluginRoot) {
426
- const { packageFormat: _dropped2, ...rest2 } = plugin;
1163
+ const { packageFormat: _dropped2, manifestVersion: _version2, ...rest2 } = plugin;
427
1164
  return rest2;
428
1165
  }
429
1166
  const manifest = readFirstHostPluginManifest(pluginRoot);
@@ -431,7 +1168,7 @@ function enrichCatalogPlugin(marketplaceRoot, plugin) {
431
1168
  const keywords = (manifest?.keywords ?? []).filter(
432
1169
  (keyword) => typeof keyword === "string" && keyword.trim().length > 0
433
1170
  );
434
- const tags = uniqueStrings([...plugin.tags ?? [], ...keywords]);
1171
+ const tags = uniqueStrings2([...plugin.tags ?? [], ...keywords]);
435
1172
  let skills = [];
436
1173
  try {
437
1174
  skills = discoverSkillPackage(pluginRoot);
@@ -447,9 +1184,11 @@ function enrichCatalogPlugin(marketplaceRoot, plugin) {
447
1184
  ...commandContents(pluginRoot)
448
1185
  ];
449
1186
  const packageFormat = agentPluginPackageFormat(pluginRoot);
450
- const { packageFormat: _dropped, ...rest } = plugin;
1187
+ const manifestVersion = typeof manifest?.version === "string" ? manifest.version.trim() : "";
1188
+ const { packageFormat: _dropped, manifestVersion: _version, ...rest } = plugin;
451
1189
  return {
452
1190
  ...rest,
1191
+ ...manifestVersion ? { manifestVersion } : {},
453
1192
  ...description ? { description } : {},
454
1193
  ...tags.length > 0 ? { tags } : {},
455
1194
  ...contents.length > 0 ? { contents } : {},
@@ -476,196 +1215,66 @@ function catalogPluginMatchesQuery(plugin, query) {
476
1215
  return false;
477
1216
  }
478
1217
 
479
- // src/services/marketplace-catalog-parse.ts
480
- import { basename } from "path";
481
- import semver from "semver";
482
- function isRecord(value) {
483
- return typeof value === "object" && value !== null && !Array.isArray(value);
484
- }
485
- function readMarketplaceName(raw) {
486
- if (!isRecord(raw)) return "";
487
- const name = raw.name;
488
- return typeof name === "string" ? name : "";
489
- }
490
- function buildRef(name, marketplaceName) {
491
- return marketplaceName ? `${name}@${marketplaceName}` : name;
492
- }
493
- function resolveVersion(entry) {
494
- const version = entry.version;
495
- if (typeof version === "string" && version.length > 0) return version;
496
- const source = entry.source;
497
- if (!isRecord(source)) return void 0;
498
- const sha = source.sha;
499
- if (typeof sha === "string" && sha.length > 0) return sha.slice(0, 12);
500
- const ref = source.ref;
501
- if (typeof ref === "string" && ref.length > 0) return ref;
502
- return void 0;
503
- }
504
- function resolveDescription(entry) {
505
- const description = entry.description;
506
- return typeof description === "string" && description.length > 0 ? description : void 0;
507
- }
508
- function resolveTags(entry) {
509
- const tags = entry.tags;
510
- if (!Array.isArray(tags)) return void 0;
511
- const next = tags.filter(
512
- (tag) => typeof tag === "string" && tag.trim().length > 0
513
- );
514
- return next.length > 0 ? next : void 0;
515
- }
516
- function normalizeMarketplaceSourcePath(value) {
517
- return value.replaceAll("\\", "/").replace(/^\.\//, "").replace(/\/+$/, "");
518
- }
519
- function asMarketplaceSourcePath(value) {
520
- const trimmed = value.trim().replaceAll("\\", "/");
521
- if (trimmed === "." || trimmed === "./") return ".";
522
- const normalized = normalizeMarketplaceSourcePath(trimmed);
523
- return normalized.length > 0 ? normalized : void 0;
524
- }
525
- function resolveSourcePath(entry) {
526
- const source = entry.source;
527
- if (typeof source === "string" && source.trim().length > 0) {
528
- return asMarketplaceSourcePath(source);
529
- }
530
- if (isRecord(source)) {
531
- const nested = source.path;
532
- if (typeof nested === "string" && nested.trim().length > 0) {
533
- return asMarketplaceSourcePath(nested);
534
- }
535
- }
536
- const path = entry.path;
537
- if (typeof path === "string" && path.trim().length > 0) {
538
- return asMarketplaceSourcePath(path);
1218
+ // src/services/marketplace-manifest-cache.ts
1219
+ var MAX_ENTRIES = 200;
1220
+ var cache = /* @__PURE__ */ new Map();
1221
+ var namesCache = /* @__PURE__ */ new Map();
1222
+ var manifestLoads = 0;
1223
+ function fileSignature(path) {
1224
+ try {
1225
+ const stat = statSync2(path);
1226
+ if (!stat.isFile()) return null;
1227
+ return `${stat.mtimeMs}:${stat.size}`;
1228
+ } catch {
1229
+ return null;
539
1230
  }
540
- return void 0;
541
- }
542
- function parsePluginEntry(entry, marketplaceName, resolveName) {
543
- if (!isRecord(entry)) return void 0;
544
- const name = resolveName(entry);
545
- if (!name) return void 0;
546
- const version = resolveVersion(entry);
547
- const description = resolveDescription(entry);
548
- const tags = resolveTags(entry);
549
- const sourcePath = resolveSourcePath(entry);
550
- const ref = buildRef(name, marketplaceName);
551
- return {
552
- name,
553
- ...version !== void 0 ? { version } : {},
554
- ref,
555
- ...description !== void 0 ? { description } : {},
556
- ...tags !== void 0 ? { tags } : {},
557
- ...sourcePath !== void 0 ? { sourcePath } : {}
558
- };
559
1231
  }
560
- function parsePlugins(raw, marketplaceName, resolveName) {
561
- if (!isRecord(raw)) return [];
562
- const plugins = raw.plugins;
563
- if (!Array.isArray(plugins)) return [];
564
- const parsed = [];
565
- for (const entry of plugins) {
566
- const plugin = parsePluginEntry(entry, marketplaceName, resolveName);
567
- if (plugin) parsed.push(plugin);
1232
+ function readCachedMarketplaceJson(path) {
1233
+ const sig = fileSignature(path);
1234
+ if (!sig) return void 0;
1235
+ const cached = cache.get(path);
1236
+ if (cached && cached.sig === sig) {
1237
+ return structuredClone(cached.value);
568
1238
  }
569
- return parsed;
570
- }
571
- function resolveClaudePluginName(entry) {
572
- const name = entry.name;
573
- return typeof name === "string" && name.length > 0 ? name : void 0;
574
- }
575
- function resolveCursorPluginName(entry) {
576
- const name = entry.name;
577
- if (typeof name === "string" && name.length > 0) return name;
578
- const path = entry.path;
579
- if (typeof path === "string" && path.length > 0) {
580
- const derived = basename(path);
581
- return derived.length > 0 ? derived : void 0;
1239
+ let parsed;
1240
+ try {
1241
+ parsed = JSON.parse(readFileSync2(path, "utf8"));
1242
+ } catch {
1243
+ return void 0;
582
1244
  }
583
- return void 0;
584
- }
585
- function parseClaudeMarketplaceManifest(raw) {
586
- const marketplaceName = readMarketplaceName(raw);
587
- const plugins = parsePlugins(raw, marketplaceName, resolveClaudePluginName);
588
- return { marketplaceName, plugins };
589
- }
590
- function parseCodexMarketplaceManifest(raw) {
591
- return parseClaudeMarketplaceManifest(raw);
592
- }
593
- function sourcePathLeavesMarketplace(sourcePath) {
594
- if (!sourcePath) return false;
595
- return sourcePath.replaceAll("\\", "/").split("/").includes("..");
596
- }
597
- function escapingMarketplaceSourceWarning(pluginName) {
598
- return `Skipped ${pluginName}: source path leaves the marketplace repository.`;
599
- }
600
- function partitionEscapingCatalogPlugins(plugins) {
601
- const kept = [];
602
- const warnings = [];
603
- for (const plugin of plugins) {
604
- if (!sourcePathLeavesMarketplace(plugin.sourcePath)) {
605
- kept.push(plugin);
606
- continue;
1245
+ manifestLoads += 1;
1246
+ cache.set(path, { sig, value: parsed });
1247
+ if (cache.size > MAX_ENTRIES) {
1248
+ const oldest = cache.keys().next().value;
1249
+ if (oldest) cache.delete(oldest);
1250
+ }
1251
+ return structuredClone(parsed);
1252
+ }
1253
+ function readCachedMarketplacePluginNames(path) {
1254
+ const sig = fileSignature(path);
1255
+ if (!sig) return void 0;
1256
+ const cached = namesCache.get(path);
1257
+ if (cached && cached.sig === sig) return cached.names;
1258
+ const parsed = readCachedMarketplaceJson(path);
1259
+ if (!parsed) return void 0;
1260
+ const names = /* @__PURE__ */ new Set();
1261
+ if (Array.isArray(parsed.plugins)) {
1262
+ for (const entry of parsed.plugins) {
1263
+ if (!entry || typeof entry !== "object") continue;
1264
+ const name = entry.name;
1265
+ if (typeof name === "string" && name.length > 0) names.add(name);
607
1266
  }
608
- warnings.push(escapingMarketplaceSourceWarning(plugin.name));
609
- }
610
- return { plugins: kept, warnings };
611
- }
612
- function parseCursorMarketplaceManifest(raw) {
613
- const marketplaceName = readMarketplaceName(raw);
614
- const plugins = parsePlugins(raw, marketplaceName, resolveCursorPluginName);
615
- return { marketplaceName, plugins };
616
- }
617
- function catalogSemver(version) {
618
- if (!version?.trim()) return null;
619
- const trimmed = version.trim();
620
- const withoutV = trimmed.startsWith("v") ? trimmed.slice(1) : trimmed;
621
- return semver.valid(withoutV);
622
- }
623
- function preferCatalogPlugin(current, incoming) {
624
- const currentRank = catalogSemver(current.version);
625
- const incomingRank = catalogSemver(incoming.version);
626
- const preferIncoming = incomingRank !== null && (currentRank === null || semver.rcompare(incomingRank, currentRank) < 0);
627
- const chosen = preferIncoming ? incoming : current;
628
- const other = preferIncoming ? current : incoming;
629
- const tags = uniqueStrings2([...chosen.tags ?? [], ...other.tags ?? []]);
630
- const contents = chosen.contents?.length ? chosen.contents : other.contents;
631
- return {
632
- ...chosen,
633
- version: chosen.version ?? other.version,
634
- description: chosen.description ?? other.description,
635
- sourcePath: chosen.sourcePath ?? other.sourcePath,
636
- ...tags.length > 0 ? { tags } : {},
637
- ...contents && contents.length > 0 ? { contents } : {}
638
- };
639
- }
640
- function uniqueStrings2(values) {
641
- const seen = /* @__PURE__ */ new Set();
642
- const next = [];
643
- for (const value of values) {
644
- if (seen.has(value)) continue;
645
- seen.add(value);
646
- next.push(value);
647
1267
  }
648
- return next;
649
- }
650
- function catalogPluginIdentity(plugin) {
651
- return `${plugin.name}\0${plugin.flavor ?? ""}`;
652
- }
653
- function mergeCatalogPluginsByIdentity(plugins) {
654
- const byName = /* @__PURE__ */ new Map();
655
- for (const plugin of plugins) {
656
- const identity = catalogPluginIdentity(plugin);
657
- const existing = byName.get(identity);
658
- if (!existing) {
659
- byName.set(identity, plugin);
660
- continue;
661
- }
662
- byName.set(identity, preferCatalogPlugin(existing, plugin));
1268
+ namesCache.set(path, { sig, names });
1269
+ if (namesCache.size > MAX_ENTRIES) {
1270
+ const oldest = namesCache.keys().next().value;
1271
+ if (oldest) namesCache.delete(oldest);
663
1272
  }
664
- return [...byName.values()];
1273
+ return names;
665
1274
  }
666
1275
 
667
1276
  // src/services/marketplace-catalog.ts
668
- var MARKETPLACE_CATALOG_INDEX_VERSION = 1;
1277
+ var MARKETPLACE_CATALOG_INDEX_VERSION = 2;
669
1278
  var MANIFEST_PATHS = [
670
1279
  { path: ".claude-plugin/marketplace.json", flavor: "claude-code" },
671
1280
  { path: ".cursor-plugin/marketplace.json", flavor: "cursor" },
@@ -675,10 +1284,10 @@ var MANIFEST_PATHS = [
675
1284
  ];
676
1285
  var MISSING_MANIFEST_MESSAGE = "No marketplace manifest found (.claude-plugin/marketplace.json, .cursor-plugin/marketplace.json, .github/plugin/marketplace.json, .agents/plugins/marketplace.json, or marketplace.json).";
677
1286
  function marketplaceCacheDir(harnesstapDir, name) {
678
- return join3(harnesstapDir, "cache", "marketplaces", name);
1287
+ return join5(harnesstapDir, "cache", "marketplaces", name);
679
1288
  }
680
1289
  function marketplaceCatalogPath(harnesstapDir, name) {
681
- return join3(marketplaceCacheDir(harnesstapDir, name), "catalog.json");
1290
+ return join5(marketplaceCacheDir(harnesstapDir, name), "catalog.json");
682
1291
  }
683
1292
  var MARKETPLACE_CATALOG_MAX_AGE_MS = marketplaceRefreshMaxAgeMs(
684
1293
  DEFAULT_MARKETPLACE_REFRESH_MAX_AGE_MINUTES
@@ -687,14 +1296,14 @@ function isGooseOnly(platforms) {
687
1296
  return platforms.length === 1 && platforms[0] === "goose";
688
1297
  }
689
1298
  function catalogIsFresh(catalogPath, maxAgeMs) {
690
- if (!existsSync3(catalogPath)) return false;
691
- const ageMs = Date.now() - statSync3(catalogPath).mtimeMs;
1299
+ if (!existsSync6(catalogPath)) return false;
1300
+ const ageMs = Date.now() - statSync5(catalogPath).mtimeMs;
692
1301
  return ageMs < maxAgeMs;
693
1302
  }
694
1303
  function readStoredCatalog(catalogPath) {
695
- if (!existsSync3(catalogPath)) return void 0;
1304
+ if (!existsSync6(catalogPath)) return void 0;
696
1305
  try {
697
- const raw = JSON.parse(readFileSync3(catalogPath, "utf8"));
1306
+ const raw = JSON.parse(readFileSync5(catalogPath, "utf8"));
698
1307
  if (!Array.isArray(raw.plugins)) return void 0;
699
1308
  return raw;
700
1309
  } catch {
@@ -702,7 +1311,7 @@ function readStoredCatalog(catalogPath) {
702
1311
  }
703
1312
  }
704
1313
  function writeStoredCatalog(catalogPath, catalog) {
705
- mkdirSync(dirname(catalogPath), { recursive: true });
1314
+ mkdirSync2(dirname(catalogPath), { recursive: true });
706
1315
  writeFileSync(catalogPath, `${JSON.stringify(catalog, null, 2)}
707
1316
  `, "utf8");
708
1317
  }
@@ -718,8 +1327,8 @@ function rootMarketplaceFlavor(platforms) {
718
1327
  function resolveManifests(cacheDir, platforms) {
719
1328
  const found = [];
720
1329
  for (const candidate of MANIFEST_PATHS) {
721
- const manifestPath = join3(cacheDir, candidate.path);
722
- if (!existsSync3(manifestPath)) continue;
1330
+ const manifestPath = join5(cacheDir, candidate.path);
1331
+ if (!existsSync6(manifestPath)) continue;
723
1332
  if (candidate.flavor) {
724
1333
  found.push({ manifestPath, flavor: candidate.flavor });
725
1334
  continue;
@@ -783,7 +1392,7 @@ function catalogRefreshEntry(harnesstapDir, name) {
783
1392
  }
784
1393
  const url = builtinMarketplaceGitUrl(name);
785
1394
  if (!url) {
786
- return void 0;
1395
+ return wellKnownMarketplaceEntry(name);
787
1396
  }
788
1397
  return builtinMarketplaceEntry();
789
1398
  }
@@ -851,8 +1460,17 @@ var catalogRefreshInflight = /* @__PURE__ */ new Map();
851
1460
  function catalogRefreshKey(harnesstapDir, name) {
852
1461
  return `${harnesstapDir}\0${name}`;
853
1462
  }
854
- function logUnattendedRefreshFailure(name, message) {
855
- console.error(`[ht-agent] marketplace catalog refresh failed for ${name}: ${message}`);
1463
+ function logUnattendedRefreshFailure(name, result) {
1464
+ if (result.timedOut) {
1465
+ const note = `[ht-agent] marketplace catalog refresh for ${name}: ${result.message} Using the cached catalog.`;
1466
+ if (resolveTelemetryProduct() === "desktop") {
1467
+ console.log(note);
1468
+ } else if (process.env.HARNESSTAP_DEBUG === "1") {
1469
+ console.error(note);
1470
+ }
1471
+ return;
1472
+ }
1473
+ console.error(`[ht-agent] marketplace catalog refresh failed for ${name}: ${result.message}`);
856
1474
  }
857
1475
  async function refreshMarketplaceCatalogNow(harnesstapDir, options) {
858
1476
  const entry = catalogRefreshEntry(harnesstapDir, options.name);
@@ -886,7 +1504,11 @@ async function refreshMarketplaceCatalogNow(harnesstapDir, options) {
886
1504
  unattended
887
1505
  });
888
1506
  if (!refresh.ok) {
889
- return { ok: false, message: refresh.message };
1507
+ return {
1508
+ ok: false,
1509
+ message: refresh.message,
1510
+ ...refresh.timedOut ? { timedOut: true } : {}
1511
+ };
890
1512
  }
891
1513
  const defaultCatalog = loadCatalogFromDir(cacheDir, entry.platforms, entry.name);
892
1514
  if (!defaultCatalog.ok) {
@@ -900,7 +1522,7 @@ async function refreshMarketplaceCatalogNow(harnesstapDir, options) {
900
1522
  const pluginBatches = [defaultCatalog.catalog.plugins];
901
1523
  const warnings = [...defaultCatalog.catalog.warnings];
902
1524
  for (const branch of extraBranches) {
903
- const branchDir = mkdtempSync(join3(tmpdir(), "ht-mkt-branch-"));
1525
+ const branchDir = mkdtempSync(join5(tmpdir(), "ht-mkt-branch-"));
904
1526
  try {
905
1527
  const branchRefresh = await refreshGitSource({
906
1528
  url: entry.url,
@@ -911,7 +1533,8 @@ async function refreshMarketplaceCatalogNow(harnesstapDir, options) {
911
1533
  if (!branchRefresh.ok) {
912
1534
  return {
913
1535
  ok: false,
914
- message: `Tracked branch "${branch}": ${branchRefresh.message}`
1536
+ message: `Tracked branch "${branch}": ${branchRefresh.message}`,
1537
+ ...branchRefresh.timedOut ? { timedOut: true } : {}
915
1538
  };
916
1539
  }
917
1540
  const branchCatalog = loadCatalogFromDir(branchDir, entry.platforms, entry.name);
@@ -925,7 +1548,7 @@ async function refreshMarketplaceCatalogNow(harnesstapDir, options) {
925
1548
  warnings.push(...branchCatalog.catalog.warnings);
926
1549
  pluginVersions.push(...versionsFromPlugins(branchCatalog.catalog.plugins, branch));
927
1550
  } finally {
928
- rmSync(branchDir, { recursive: true, force: true });
1551
+ rmSync2(branchDir, { recursive: true, force: true });
929
1552
  }
930
1553
  }
931
1554
  const uniqueWarnings = [...new Set(warnings)];
@@ -1008,7 +1631,7 @@ async function ensureMarketplaceCatalog(harnesstapDir, options) {
1008
1631
  unattended: true
1009
1632
  }).then((result) => {
1010
1633
  if (!result.ok) {
1011
- logUnattendedRefreshFailure(options.name, result.message);
1634
+ logUnattendedRefreshFailure(options.name, result);
1012
1635
  }
1013
1636
  });
1014
1637
  return listCatalogPlugins(harnesstapDir, { name: options.name });
@@ -1098,15 +1721,180 @@ async function searchCatalogPlugins(harnesstapDir, query, options = {}) {
1098
1721
  return results;
1099
1722
  }
1100
1723
 
1724
+ // src/services/wizards/shared.ts
1725
+ import inquirer from "inquirer";
1726
+ import search from "@inquirer/search";
1727
+ function isPromptCancellationError(error) {
1728
+ if (!(error instanceof Error)) {
1729
+ return false;
1730
+ }
1731
+ if (error.name === "ExitPromptError" || error.name === "CancelPromptError" || error.name === "AbortPromptError") {
1732
+ return true;
1733
+ }
1734
+ return /force closed the prompt/i.test(error.message);
1735
+ }
1736
+ var PromptBackError = class extends Error {
1737
+ name = "PromptBackError";
1738
+ };
1739
+ function isPromptBackError(error) {
1740
+ return error instanceof PromptBackError;
1741
+ }
1742
+ async function withPromptBack(prompt) {
1743
+ try {
1744
+ return await prompt();
1745
+ } catch (error) {
1746
+ if (isPromptCancellationError(error)) {
1747
+ throw new PromptBackError();
1748
+ }
1749
+ throw error;
1750
+ }
1751
+ }
1752
+ function shouldUseBrowsePicker(input) {
1753
+ const noInteractive = input.noInteractive ?? process.argv.includes("--no-interactive");
1754
+ const ciValue = process.env.CI?.trim().toLowerCase();
1755
+ const ciEnabled = Boolean(
1756
+ ciValue && ciValue !== "0" && ciValue !== "false" && ciValue !== "no"
1757
+ );
1758
+ const forceWizard = process.env.HARNESSTAP_FORCE_WIZARD === "1";
1759
+ const interactiveTerminal = forceWizard || Boolean(process.stdin.isTTY) && Boolean(process.stdout.isTTY);
1760
+ return Boolean(
1761
+ interactiveTerminal && !ciEnabled && process.env.HARNESSTAP_NO_INTERACTIVE !== "1" && !noInteractive && input.format !== "json"
1762
+ );
1763
+ }
1764
+ function shouldUseWizard(input) {
1765
+ const noInteractive = input.noInteractive ?? process.argv.includes("--no-interactive");
1766
+ const ciValue = process.env.CI?.trim().toLowerCase();
1767
+ const ciEnabled = Boolean(
1768
+ ciValue && ciValue !== "0" && ciValue !== "false" && ciValue !== "no"
1769
+ );
1770
+ const forceWizard = process.env.HARNESSTAP_FORCE_WIZARD === "1";
1771
+ const interactiveTerminal = forceWizard || Boolean(process.stdin.isTTY) && Boolean(process.stdout.isTTY);
1772
+ return Boolean(
1773
+ interactiveTerminal && !ciEnabled && process.env.HARNESSTAP_NO_INTERACTIVE !== "1" && !noInteractive && input.format !== "json" && (input.interactive || input.missingRequiredArgs)
1774
+ );
1775
+ }
1776
+ async function resolveOrPrompt(input) {
1777
+ if (input.value !== void 0) {
1778
+ return input.value;
1779
+ }
1780
+ if (!input.shouldPrompt) {
1781
+ return void 0;
1782
+ }
1783
+ return input.prompt();
1784
+ }
1785
+ async function promptForValue(input) {
1786
+ const { value } = await inquirer.prompt([
1787
+ {
1788
+ type: "input",
1789
+ name: "value",
1790
+ message: input.message,
1791
+ default: input.default,
1792
+ validate: (candidate) => candidate.trim().length > 0 ? true : "A value is required."
1793
+ }
1794
+ ]);
1795
+ return value.trim();
1796
+ }
1797
+ function promptPageSize(choiceCount) {
1798
+ return Math.min(Math.max(choiceCount, 5), 12);
1799
+ }
1800
+ async function promptForChoice(input) {
1801
+ const { value } = await inquirer.prompt([
1802
+ {
1803
+ type: "list",
1804
+ name: "value",
1805
+ message: input.message,
1806
+ default: input.default,
1807
+ choices: input.choices,
1808
+ pageSize: promptPageSize(input.choices.length),
1809
+ loop: false
1810
+ }
1811
+ ]);
1812
+ return value;
1813
+ }
1814
+ function sortChoicesWithDefaultFirst(choices, defaultValue) {
1815
+ if (!defaultValue) {
1816
+ return choices;
1817
+ }
1818
+ const defaultChoice = choices.find((choice) => choice.value === defaultValue);
1819
+ if (!defaultChoice) {
1820
+ return choices;
1821
+ }
1822
+ return [
1823
+ defaultChoice,
1824
+ ...choices.filter((choice) => choice.value !== defaultValue)
1825
+ ];
1826
+ }
1827
+ async function promptForSearchableChoice(input) {
1828
+ return search({
1829
+ message: input.message,
1830
+ pageSize: promptPageSize(input.choices.length),
1831
+ source: async (term) => {
1832
+ const normalizedTerm = term?.trim().toLowerCase();
1833
+ const choices = sortChoicesWithDefaultFirst(input.choices, input.default);
1834
+ if (!normalizedTerm) {
1835
+ return choices;
1836
+ }
1837
+ return choices.filter(
1838
+ (choice) => `${choice.name} ${choice.value}`.toLowerCase().includes(normalizedTerm)
1839
+ );
1840
+ }
1841
+ });
1842
+ }
1843
+ async function promptForConfirmation(input) {
1844
+ const { value } = await inquirer.prompt([
1845
+ {
1846
+ type: "confirm",
1847
+ name: "value",
1848
+ message: input.message,
1849
+ default: input.default ?? false
1850
+ }
1851
+ ]);
1852
+ return value;
1853
+ }
1854
+
1101
1855
  export {
1856
+ runInStatusComputation,
1857
+ inStatusComputation,
1858
+ computationSlot,
1859
+ existsSync2 as existsSync,
1860
+ statSync2 as statSync,
1861
+ readdirSync2 as readdirSync,
1862
+ readFileSync2 as readFileSync,
1863
+ AP_SCHEMA_URL,
1864
+ AP_MCP_SCHEMA_URL,
1865
+ lookupApSchema,
1866
+ isAgentPluginsSchemaId,
1867
+ readJsonFile,
1868
+ readFirstHostPluginManifest,
1869
+ parsePluginRef,
1870
+ DEFAULT_GIT_CLONE_TIMEOUT_MS,
1871
+ runCommandWithTimeout,
1872
+ resolveCommandResult,
1873
+ defaultRunCommand,
1874
+ refreshGitSource,
1875
+ cursorRepoSourceKey,
1876
+ cursorCacheRoot,
1877
+ cursorLocalRoot,
1878
+ cursorMarketplacesRoot,
1879
+ cursorProjectsMcpsRoot,
1880
+ resolveHomeRoot,
1102
1881
  isCursorPublicMarketplace,
1103
1882
  builtinMarketplaceGitUrl,
1104
1883
  builtinMarketplaceEntry,
1884
+ wellKnownMarketplaceEntry,
1885
+ readCachedMarketplaceJson,
1886
+ readCachedMarketplacePluginNames,
1887
+ isLocalFilesystemSource,
1105
1888
  normalizeMarketplaceUrl,
1106
1889
  listMarketplaces,
1890
+ findKnownMarketplace,
1107
1891
  addMarketplace,
1108
1892
  removeMarketplace,
1893
+ parseFrontmatter,
1894
+ parseFrontmatterLenient,
1109
1895
  discoverSkillPackage,
1896
+ catalogPluginDisplayVersion,
1897
+ catalogPluginVersionLabel,
1110
1898
  escapingMarketplaceSourceWarning,
1111
1899
  marketplaceCacheDir,
1112
1900
  refreshMarketplaceCatalog,
@@ -1116,6 +1904,17 @@ export {
1116
1904
  marketplaceRowFlavors,
1117
1905
  alignImplicitMarketplacePlatforms,
1118
1906
  readMarketplaceManifest,
1119
- searchCatalogPlugins
1907
+ searchCatalogPlugins,
1908
+ isPromptCancellationError,
1909
+ PromptBackError,
1910
+ isPromptBackError,
1911
+ withPromptBack,
1912
+ shouldUseBrowsePicker,
1913
+ shouldUseWizard,
1914
+ resolveOrPrompt,
1915
+ promptForValue,
1916
+ promptForChoice,
1917
+ promptForSearchableChoice,
1918
+ promptForConfirmation
1120
1919
  };
1121
- //# sourceMappingURL=chunk-6LTLYV5D.js.map
1920
+ //# sourceMappingURL=chunk-LGWFLVZQ.js.map