harnesstap 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +2 -0
  2. package/dist/apply-SUNDXRJ3.js +54 -0
  3. package/dist/{approve-L7IFSYBO.js → approve-FBGYQGWN.js} +14 -15
  4. package/dist/{approve-L7IFSYBO.js.map → approve-FBGYQGWN.js.map} +1 -1
  5. package/dist/{audit-PBJDK7A4.js → audit-VI4QZ6X2.js} +30 -39
  6. package/dist/{audit-PBJDK7A4.js.map → audit-VI4QZ6X2.js.map} +1 -1
  7. package/dist/{auth-OM73RLNS.js → auth-4CQCDS2W.js} +17 -19
  8. package/dist/{auth-OM73RLNS.js.map → auth-4CQCDS2W.js.map} +1 -1
  9. package/dist/bin.js +3 -3
  10. package/dist/{chunk-YRGM7RAD.js → chunk-23XSG7LI.js} +7 -11
  11. package/dist/{chunk-YRGM7RAD.js.map → chunk-23XSG7LI.js.map} +1 -1
  12. package/dist/{chunk-LDVXYN6F.js → chunk-2A36HWDE.js} +63 -13
  13. package/dist/chunk-2A36HWDE.js.map +1 -0
  14. package/dist/{chunk-QNAIDM6W.js → chunk-3FS775NP.js} +51 -4
  15. package/dist/chunk-3FS775NP.js.map +1 -0
  16. package/dist/{chunk-XCPWLGPB.js → chunk-3P6BWL5F.js} +2 -2
  17. package/dist/{chunk-JJJJ2RAD.js → chunk-43BDGVN3.js} +19 -6
  18. package/dist/chunk-43BDGVN3.js.map +1 -0
  19. package/dist/{chunk-CZ4T75PP.js → chunk-4ZQ2SCGY.js} +146 -78
  20. package/dist/chunk-4ZQ2SCGY.js.map +1 -0
  21. package/dist/{chunk-ZVANUFPF.js → chunk-6LTLYV5D.js} +353 -267
  22. package/dist/chunk-6LTLYV5D.js.map +1 -0
  23. package/dist/{chunk-OPVIX7E4.js → chunk-73OJQTBW.js} +6 -2
  24. package/dist/chunk-73OJQTBW.js.map +1 -0
  25. package/dist/{chunk-WXRPQICX.js → chunk-7HP6AAI3.js} +2 -2
  26. package/dist/{chunk-ENHDEB7Z.js → chunk-BPWFQKI5.js} +5 -7
  27. package/dist/{chunk-ENHDEB7Z.js.map → chunk-BPWFQKI5.js.map} +1 -1
  28. package/dist/{chunk-64R32MG2.js → chunk-D432JAXV.js} +44 -19
  29. package/dist/chunk-D432JAXV.js.map +1 -0
  30. package/dist/chunk-DF4Z7LAD.js +3463 -0
  31. package/dist/chunk-DF4Z7LAD.js.map +1 -0
  32. package/dist/{chunk-FUV7QYBS.js → chunk-EOPFER6N.js} +71 -318
  33. package/dist/chunk-EOPFER6N.js.map +1 -0
  34. package/dist/chunk-G6WKY2W4.js +389 -0
  35. package/dist/chunk-G6WKY2W4.js.map +1 -0
  36. package/dist/{chunk-IHW4PCDT.js → chunk-GRASK6M6.js} +5 -5
  37. package/dist/{chunk-R4PTE774.js → chunk-IE7B6Q5K.js} +33 -39
  38. package/dist/chunk-IE7B6Q5K.js.map +1 -0
  39. package/dist/{chunk-UNRR4KH5.js → chunk-IMROMZ2K.js} +6 -5
  40. package/dist/{chunk-UNRR4KH5.js.map → chunk-IMROMZ2K.js.map} +1 -1
  41. package/dist/{chunk-G5RWVZZ7.js → chunk-L6YZE5MY.js} +3 -3
  42. package/dist/{chunk-SNVAMWB7.js → chunk-M2U3J7UX.js} +7 -1
  43. package/dist/chunk-M2U3J7UX.js.map +1 -0
  44. package/dist/{chunk-AFKCNFPP.js → chunk-M4KLHJ6U.js} +16 -13
  45. package/dist/chunk-M4KLHJ6U.js.map +1 -0
  46. package/dist/{chunk-XRXFJTAT.js → chunk-MR7IOHSX.js} +16 -19
  47. package/dist/chunk-MR7IOHSX.js.map +1 -0
  48. package/dist/{chunk-UEHDEADL.js → chunk-N3VGY3T3.js} +15 -15
  49. package/dist/chunk-N3VGY3T3.js.map +1 -0
  50. package/dist/{chunk-IKAGGJEO.js → chunk-N3ZCH64F.js} +496 -10
  51. package/dist/chunk-N3ZCH64F.js.map +1 -0
  52. package/dist/{chunk-U472S6IB.js → chunk-OML4HXKT.js} +20 -22
  53. package/dist/chunk-OML4HXKT.js.map +1 -0
  54. package/dist/{chunk-3EGM4IUI.js → chunk-P2C7JPLD.js} +3 -3
  55. package/dist/{chunk-MFCZN253.js → chunk-PCMON7Y2.js} +7 -7
  56. package/dist/{chunk-FBYAIBHP.js → chunk-PNGF5EV2.js} +2 -2
  57. package/dist/{chunk-6JMVGKMD.js → chunk-QA5U36JN.js} +187 -203
  58. package/dist/chunk-QA5U36JN.js.map +1 -0
  59. package/dist/{chunk-AVZOFMJX.js → chunk-R7ZOYVN3.js} +241 -126
  60. package/dist/chunk-R7ZOYVN3.js.map +1 -0
  61. package/dist/{chunk-YVJQ2QDG.js → chunk-RDG5DT7S.js} +45 -49
  62. package/dist/{chunk-YVJQ2QDG.js.map → chunk-RDG5DT7S.js.map} +1 -1
  63. package/dist/{chunk-VQVUJYYY.js → chunk-REHRUNBB.js} +8 -3
  64. package/dist/chunk-REHRUNBB.js.map +1 -0
  65. package/dist/{chunk-Y2JGMICO.js → chunk-RFQ3N7FB.js} +19 -29
  66. package/dist/chunk-RFQ3N7FB.js.map +1 -0
  67. package/dist/{chunk-EY4ES5MG.js → chunk-RVEXPMM3.js} +3 -3
  68. package/dist/{chunk-6I3RY6R5.js → chunk-TPEJFLV7.js} +13 -15
  69. package/dist/{chunk-6I3RY6R5.js.map → chunk-TPEJFLV7.js.map} +1 -1
  70. package/dist/{chunk-IAZNF35S.js → chunk-U6DXASQP.js} +2 -2
  71. package/dist/{chunk-OQ4KBUN2.js → chunk-ULCD6DJE.js} +30 -8
  72. package/dist/chunk-ULCD6DJE.js.map +1 -0
  73. package/dist/{chunk-BXSS2S4W.js → chunk-UVVZHWD2.js} +2 -2
  74. package/dist/{chunk-24V5ZSIF.js → chunk-WG5A6EAU.js} +269 -13
  75. package/dist/chunk-WG5A6EAU.js.map +1 -0
  76. package/dist/{chunk-LGWUTV5Q.js → chunk-WGP4GUYZ.js} +10 -10
  77. package/dist/{chunk-GWQVYGRD.js → chunk-XTVGCVU4.js} +124 -83
  78. package/dist/chunk-XTVGCVU4.js.map +1 -0
  79. package/dist/{chunk-YX7MVSDA.js → chunk-XUJKZQZA.js} +8 -8
  80. package/dist/chunk-XUJKZQZA.js.map +1 -0
  81. package/dist/chunk-ZUASVASP.js +30317 -0
  82. package/dist/chunk-ZUASVASP.js.map +1 -0
  83. package/dist/{compile-SDOASKGL.js → compile-GXADKGH5.js} +37 -50
  84. package/dist/{compile-SDOASKGL.js.map → compile-GXADKGH5.js.map} +1 -1
  85. package/dist/{config-4VZTVZKF.js → config-JMHNA2U5.js} +22 -35
  86. package/dist/{config-4VZTVZKF.js.map → config-JMHNA2U5.js.map} +1 -1
  87. package/dist/cursor-local-install-46RWRBDT.js +98 -0
  88. package/dist/cursor-local-install-46RWRBDT.js.map +1 -0
  89. package/dist/{doctor-HH6CFBRQ.js → doctor-N7ZULPOL.js} +18 -19
  90. package/dist/{doctor-HH6CFBRQ.js.map → doctor-N7ZULPOL.js.map} +1 -1
  91. package/dist/{environment-K7YMJJYN.js → environment-OBB3WU5B.js} +60 -71
  92. package/dist/{environment-K7YMJJYN.js.map → environment-OBB3WU5B.js.map} +1 -1
  93. package/dist/{github-A6TYG7WS.js → github-PBYBGOLH.js} +17 -17
  94. package/dist/{harness-772XBFZQ.js → harness-7KYATIV6.js} +56 -67
  95. package/dist/{harness-772XBFZQ.js.map → harness-7KYATIV6.js.map} +1 -1
  96. package/dist/{help-QR4VTJZU.js → help-EE3AJQD4.js} +48 -52
  97. package/dist/help-EE3AJQD4.js.map +1 -0
  98. package/dist/{help-TLHNRJJ6.js → help-VXWKLQ6A.js} +55 -15
  99. package/dist/help-VXWKLQ6A.js.map +1 -0
  100. package/dist/index.d.ts +7 -0
  101. package/dist/index.js +16 -24
  102. package/dist/{init-AOKFPZHG.js → init-LBTMPDVJ.js} +43 -56
  103. package/dist/init-LBTMPDVJ.js.map +1 -0
  104. package/dist/live-read-cache-TUSP7U3D.js +10 -0
  105. package/dist/{lock-INAXNLMC.js → lock-WLJRXRVK.js} +16 -16
  106. package/dist/{marketplace-TUVLLPBG.js → marketplace-GXSV6QIY.js} +62 -28
  107. package/dist/marketplace-GXSV6QIY.js.map +1 -0
  108. package/dist/{mcp-MMWGRASN.js → mcp-XPDWWU75.js} +35 -48
  109. package/dist/{mcp-MMWGRASN.js.map → mcp-XPDWWU75.js.map} +1 -1
  110. package/dist/{migrate-55S4XODX.js → migrate-SBUIWN3U.js} +79 -64
  111. package/dist/migrate-SBUIWN3U.js.map +1 -0
  112. package/dist/open-HDGLYYVU.js +24 -0
  113. package/dist/{pack-VZIBS42E.js → pack-A73LDVOX.js} +16 -22
  114. package/dist/{pack-VZIBS42E.js.map → pack-A73LDVOX.js.map} +1 -1
  115. package/dist/plugin-CEO6ZJM5.js +51 -0
  116. package/dist/plugin-from-project-UK7VJVUP.js +18 -0
  117. package/dist/{policy-P3HGLEZS.js → policy-6VY3CMSU.js} +13 -14
  118. package/dist/{policy-P3HGLEZS.js.map → policy-6VY3CMSU.js.map} +1 -1
  119. package/dist/{profile-STS3CZUK.js → profile-YCKPMRRU.js} +96 -102
  120. package/dist/profile-YCKPMRRU.js.map +1 -0
  121. package/dist/{project-R4DGM3ZG.js → project-KHPPBKPN.js} +63 -77
  122. package/dist/{project-R4DGM3ZG.js.map → project-KHPPBKPN.js.map} +1 -1
  123. package/dist/{resource-GJVEDXVZ.js → resource-IJU3FAN5.js} +42 -49
  124. package/dist/{resource-GJVEDXVZ.js.map → resource-IJU3FAN5.js.map} +1 -1
  125. package/dist/{version-FUHV4O6U.js → version-Z66FWWMQ.js} +2 -2
  126. package/dist/version-Z66FWWMQ.js.map +1 -0
  127. package/package.json +3 -2
  128. package/dist/apply-Q5SFF3FY.js +0 -67
  129. package/dist/chunk-24V5ZSIF.js.map +0 -1
  130. package/dist/chunk-3JOPDYQD.js +0 -730
  131. package/dist/chunk-3JOPDYQD.js.map +0 -1
  132. package/dist/chunk-555XE3NJ.js +0 -60
  133. package/dist/chunk-555XE3NJ.js.map +0 -1
  134. package/dist/chunk-64R32MG2.js.map +0 -1
  135. package/dist/chunk-6JMVGKMD.js.map +0 -1
  136. package/dist/chunk-6ZWKF3YZ.js +0 -7795
  137. package/dist/chunk-6ZWKF3YZ.js.map +0 -1
  138. package/dist/chunk-AFKCNFPP.js.map +0 -1
  139. package/dist/chunk-AUWWL6KX.js +0 -296
  140. package/dist/chunk-AUWWL6KX.js.map +0 -1
  141. package/dist/chunk-AVZOFMJX.js.map +0 -1
  142. package/dist/chunk-CZ4T75PP.js.map +0 -1
  143. package/dist/chunk-FUV7QYBS.js.map +0 -1
  144. package/dist/chunk-GWQVYGRD.js.map +0 -1
  145. package/dist/chunk-HENOKIBB.js +0 -346
  146. package/dist/chunk-HENOKIBB.js.map +0 -1
  147. package/dist/chunk-HWL67OCJ.js +0 -238
  148. package/dist/chunk-HWL67OCJ.js.map +0 -1
  149. package/dist/chunk-IKAGGJEO.js.map +0 -1
  150. package/dist/chunk-JJJJ2RAD.js.map +0 -1
  151. package/dist/chunk-JRFUTIEH.js +0 -426
  152. package/dist/chunk-JRFUTIEH.js.map +0 -1
  153. package/dist/chunk-KJIFZLHN.js +0 -11066
  154. package/dist/chunk-KJIFZLHN.js.map +0 -1
  155. package/dist/chunk-LDVXYN6F.js.map +0 -1
  156. package/dist/chunk-MHOTXMD2.js +0 -430
  157. package/dist/chunk-MHOTXMD2.js.map +0 -1
  158. package/dist/chunk-NEPUP33Q.js +0 -35
  159. package/dist/chunk-NEPUP33Q.js.map +0 -1
  160. package/dist/chunk-OPVIX7E4.js.map +0 -1
  161. package/dist/chunk-OQ4KBUN2.js.map +0 -1
  162. package/dist/chunk-OXVCYRZB.js +0 -491
  163. package/dist/chunk-OXVCYRZB.js.map +0 -1
  164. package/dist/chunk-PJQAMC6L.js +0 -183
  165. package/dist/chunk-PJQAMC6L.js.map +0 -1
  166. package/dist/chunk-PW5QXRBA.js +0 -1173
  167. package/dist/chunk-PW5QXRBA.js.map +0 -1
  168. package/dist/chunk-QNAIDM6W.js.map +0 -1
  169. package/dist/chunk-R4PTE774.js.map +0 -1
  170. package/dist/chunk-S2E4KSYW.js +0 -610
  171. package/dist/chunk-S2E4KSYW.js.map +0 -1
  172. package/dist/chunk-SNVAMWB7.js.map +0 -1
  173. package/dist/chunk-U472S6IB.js.map +0 -1
  174. package/dist/chunk-UEHDEADL.js.map +0 -1
  175. package/dist/chunk-VQVUJYYY.js.map +0 -1
  176. package/dist/chunk-XRXFJTAT.js.map +0 -1
  177. package/dist/chunk-Y2JGMICO.js.map +0 -1
  178. package/dist/chunk-YX7MVSDA.js.map +0 -1
  179. package/dist/chunk-ZGRBIBO7.js +0 -681
  180. package/dist/chunk-ZGRBIBO7.js.map +0 -1
  181. package/dist/chunk-ZTBAMBAI.js +0 -6448
  182. package/dist/chunk-ZTBAMBAI.js.map +0 -1
  183. package/dist/chunk-ZVANUFPF.js.map +0 -1
  184. package/dist/help-QR4VTJZU.js.map +0 -1
  185. package/dist/help-TLHNRJJ6.js.map +0 -1
  186. package/dist/init-AOKFPZHG.js.map +0 -1
  187. package/dist/marketplace-TUVLLPBG.js.map +0 -1
  188. package/dist/migrate-55S4XODX.js.map +0 -1
  189. package/dist/open-SLFQV45J.js +0 -32
  190. package/dist/plugin-WLEFFBRY.js +0 -64
  191. package/dist/plugin-from-project-UV2O364T.js +0 -16
  192. package/dist/profile-STS3CZUK.js.map +0 -1
  193. /package/dist/{apply-Q5SFF3FY.js.map → apply-SUNDXRJ3.js.map} +0 -0
  194. /package/dist/{chunk-XCPWLGPB.js.map → chunk-3P6BWL5F.js.map} +0 -0
  195. /package/dist/{chunk-WXRPQICX.js.map → chunk-7HP6AAI3.js.map} +0 -0
  196. /package/dist/{chunk-IHW4PCDT.js.map → chunk-GRASK6M6.js.map} +0 -0
  197. /package/dist/{chunk-G5RWVZZ7.js.map → chunk-L6YZE5MY.js.map} +0 -0
  198. /package/dist/{chunk-3EGM4IUI.js.map → chunk-P2C7JPLD.js.map} +0 -0
  199. /package/dist/{chunk-MFCZN253.js.map → chunk-PCMON7Y2.js.map} +0 -0
  200. /package/dist/{chunk-FBYAIBHP.js.map → chunk-PNGF5EV2.js.map} +0 -0
  201. /package/dist/{chunk-EY4ES5MG.js.map → chunk-RVEXPMM3.js.map} +0 -0
  202. /package/dist/{chunk-IAZNF35S.js.map → chunk-U6DXASQP.js.map} +0 -0
  203. /package/dist/{chunk-BXSS2S4W.js.map → chunk-UVVZHWD2.js.map} +0 -0
  204. /package/dist/{chunk-LGWUTV5Q.js.map → chunk-WGP4GUYZ.js.map} +0 -0
  205. /package/dist/{github-A6TYG7WS.js.map → github-PBYBGOLH.js.map} +0 -0
  206. /package/dist/{open-SLFQV45J.js.map → live-read-cache-TUSP7U3D.js.map} +0 -0
  207. /package/dist/{lock-INAXNLMC.js.map → lock-WLJRXRVK.js.map} +0 -0
  208. /package/dist/{plugin-WLEFFBRY.js.map → open-HDGLYYVU.js.map} +0 -0
  209. /package/dist/{plugin-from-project-UV2O364T.js.map → plugin-CEO6ZJM5.js.map} +0 -0
  210. /package/dist/{version-FUHV4O6U.js.map → plugin-from-project-UK7VJVUP.js.map} +0 -0
@@ -1,730 +0,0 @@
1
- import {
2
- findProjectConfig
3
- } from "./chunk-HENOKIBB.js";
4
- import {
5
- hasCriticalUnicode,
6
- scanUnicodeBuffer
7
- } from "./chunk-JRFUTIEH.js";
8
- import {
9
- skippedRootSourceWarning
10
- } from "./chunk-PW5QXRBA.js";
11
- import {
12
- APM_LOCKFILE_FILENAME
13
- } from "./chunk-MHOTXMD2.js";
14
- import {
15
- BundleSymlinkError,
16
- HT_MCP_EXTRAS_PATH,
17
- PathEscapeError,
18
- assertContainedPath,
19
- buildSpecMcpJson,
20
- formatMcpExtrasToml,
21
- formatSpecMcpJson,
22
- isSpecMcpDocument,
23
- isValidApName,
24
- parseMcpServersDocument,
25
- slugifyApName,
26
- validateApManifest
27
- } from "./chunk-KJIFZLHN.js";
28
- import {
29
- AP_SCHEMA_URL,
30
- lookupApSchema
31
- } from "./chunk-ZVANUFPF.js";
32
-
33
- // src/services/apm-pack.ts
34
- import { createHash } from "crypto";
35
- import {
36
- existsSync,
37
- lstatSync,
38
- mkdirSync,
39
- readFileSync,
40
- readdirSync,
41
- rmSync,
42
- writeFileSync
43
- } from "fs";
44
- import { dirname, join, relative, resolve, sep } from "path";
45
- import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
46
-
47
- // src/utils/zip-archive.ts
48
- import { deflateRawSync, inflateRawSync } from "zlib";
49
- var LOCAL_SIG = 67324752;
50
- var CENTRAL_SIG = 33639248;
51
- var EOCD_SIG = 101010256;
52
- var UNIX_MADE_BY = 3 << 8;
53
- var S_IFLNK = 40960;
54
- var S_IFREG = 32768;
55
- var MODE_FILE = S_IFREG | 420;
56
- var CRC_TABLE = new Uint32Array(256);
57
- for (let n = 0; n < 256; n++) {
58
- let c = n;
59
- for (let k = 0; k < 8; k++) {
60
- c = (c & 1) !== 0 ? 3988292384 ^ c >>> 1 : c >>> 1;
61
- }
62
- CRC_TABLE[n] = c >>> 0;
63
- }
64
- function crc32(buffer) {
65
- let c = 4294967295;
66
- for (let i = 0; i < buffer.length; i++) {
67
- c = CRC_TABLE[(c ^ (buffer[i] ?? 0)) & 255] ^ c >>> 8;
68
- }
69
- return (c ^ 4294967295) >>> 0;
70
- }
71
- var ZipSymlinkError = class extends Error {
72
- entry;
73
- constructor(entry) {
74
- super(`Symlinks are not allowed in a bundle: ${entry}`);
75
- this.name = "ZipSymlinkError";
76
- this.entry = entry;
77
- }
78
- };
79
- function unixMode(externalAttributes) {
80
- return externalAttributes >>> 16 & 61440;
81
- }
82
- function writeU16(buffer, offset, value) {
83
- buffer.writeUInt16LE(value, offset);
84
- }
85
- function writeU32(buffer, offset, value) {
86
- buffer.writeUInt32LE(value >>> 0, offset);
87
- }
88
- function readU16(buffer, offset) {
89
- return buffer.readUInt16LE(offset);
90
- }
91
- function readU32(buffer, offset) {
92
- return buffer.readUInt32LE(offset);
93
- }
94
- function normalizeZipPath(entry) {
95
- const trimmed = entry.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
96
- if (!trimmed || trimmed === ".") {
97
- return "";
98
- }
99
- assertContainedPath(".", trimmed);
100
- if (trimmed.split("/").includes("..")) {
101
- throw new PathEscapeError(trimmed, ".");
102
- }
103
- return trimmed;
104
- }
105
- function writeZipArchive(files) {
106
- const locals = [];
107
- const centrals = [];
108
- let offset = 0;
109
- const sorted = [...files].sort((left, right) => left.path.localeCompare(right.path));
110
- for (const file of sorted) {
111
- const name = normalizeZipPath(file.path);
112
- if (!name) continue;
113
- const nameBytes = Buffer.from(name, "utf8");
114
- const uncompressed = file.data;
115
- const compressed = deflateRawSync(uncompressed);
116
- const checksum = crc32(uncompressed);
117
- const local = Buffer.alloc(30 + nameBytes.length);
118
- writeU32(local, 0, LOCAL_SIG);
119
- writeU16(local, 4, 20);
120
- writeU16(local, 6, 0);
121
- writeU16(local, 8, 8);
122
- writeU16(local, 10, 0);
123
- writeU16(local, 12, 0);
124
- writeU32(local, 14, checksum);
125
- writeU32(local, 18, compressed.length);
126
- writeU32(local, 22, uncompressed.length);
127
- writeU16(local, 26, nameBytes.length);
128
- writeU16(local, 28, 0);
129
- nameBytes.copy(local, 30);
130
- const central = Buffer.alloc(46 + nameBytes.length);
131
- writeU32(central, 0, CENTRAL_SIG);
132
- writeU16(central, 4, UNIX_MADE_BY | 20);
133
- writeU16(central, 6, 20);
134
- writeU16(central, 8, 0);
135
- writeU16(central, 10, 8);
136
- writeU16(central, 12, 0);
137
- writeU16(central, 14, 0);
138
- writeU32(central, 16, checksum);
139
- writeU32(central, 20, compressed.length);
140
- writeU32(central, 24, uncompressed.length);
141
- writeU16(central, 28, nameBytes.length);
142
- writeU16(central, 30, 0);
143
- writeU16(central, 32, 0);
144
- writeU16(central, 34, 0);
145
- writeU16(central, 36, 0);
146
- writeU32(central, 38, MODE_FILE << 16);
147
- writeU32(central, 42, offset);
148
- nameBytes.copy(central, 46);
149
- locals.push(local, compressed);
150
- centrals.push(central);
151
- offset += local.length + compressed.length;
152
- }
153
- const centralDirectory = Buffer.concat(centrals);
154
- const eocd = Buffer.alloc(22);
155
- writeU32(eocd, 0, EOCD_SIG);
156
- writeU16(eocd, 4, 0);
157
- writeU16(eocd, 6, 0);
158
- writeU16(eocd, 8, centrals.length);
159
- writeU16(eocd, 10, centrals.length);
160
- writeU32(eocd, 12, centralDirectory.length);
161
- writeU32(eocd, 16, offset);
162
- writeU16(eocd, 20, 0);
163
- return Buffer.concat([...locals, centralDirectory, eocd]);
164
- }
165
- function findEocdOffset(buffer) {
166
- const min = Math.max(0, buffer.length - 22 - 65535);
167
- for (let i = buffer.length - 22; i >= min; i--) {
168
- if (readU32(buffer, i) === EOCD_SIG) {
169
- return i;
170
- }
171
- }
172
- throw new Error("Invalid zip archive: missing end of central directory");
173
- }
174
- function stripSingleRoot(files) {
175
- if (files.length === 0) return files;
176
- const first = files[0]?.path.split("/")[0];
177
- if (!first) return files;
178
- const prefix = `${first}/`;
179
- if (!files.every((file) => file.path === first || file.path.startsWith(prefix))) {
180
- return files;
181
- }
182
- if (!files.some((file) => file.path === `${prefix}plugin.json` || file.path === "plugin.json")) {
183
- return files;
184
- }
185
- const stripped = [];
186
- for (const file of files) {
187
- if (file.path === first) continue;
188
- stripped.push({ path: file.path.slice(prefix.length), data: file.data });
189
- }
190
- return stripped;
191
- }
192
- function readZipArchive(buffer) {
193
- if (buffer.length < 22) {
194
- throw new Error("Invalid zip archive");
195
- }
196
- const eocd = findEocdOffset(buffer);
197
- const count = readU16(buffer, eocd + 10);
198
- const centralSize = readU32(buffer, eocd + 12);
199
- const centralOffset = readU32(buffer, eocd + 16);
200
- if (centralOffset + centralSize > buffer.length) {
201
- throw new Error("Invalid zip archive: truncated central directory");
202
- }
203
- const files = [];
204
- let cursor = centralOffset;
205
- for (let i = 0; i < count; i++) {
206
- if (readU32(buffer, cursor) !== CENTRAL_SIG) {
207
- throw new Error("Invalid zip archive: bad central directory entry");
208
- }
209
- const madeBy = readU16(buffer, cursor + 4);
210
- const compression = readU16(buffer, cursor + 10);
211
- const compressedSize = readU32(buffer, cursor + 20);
212
- const uncompressedSize = readU32(buffer, cursor + 24);
213
- const nameLength = readU16(buffer, cursor + 28);
214
- const extraLength = readU16(buffer, cursor + 30);
215
- const commentLength = readU16(buffer, cursor + 32);
216
- const externalAttributes = readU32(buffer, cursor + 38);
217
- const localOffset = readU32(buffer, cursor + 42);
218
- const name = buffer.subarray(cursor + 46, cursor + 46 + nameLength).toString("utf8");
219
- cursor += 46 + nameLength + extraLength + commentLength;
220
- const posixName = name.replace(/\\/g, "/");
221
- if (posixName.endsWith("/")) {
222
- continue;
223
- }
224
- const relativePath = normalizeZipPath(posixName);
225
- if (!relativePath) continue;
226
- const unixHost = madeBy >> 8 === 3;
227
- if (unixHost && unixMode(externalAttributes) === S_IFLNK) {
228
- throw new ZipSymlinkError(relativePath);
229
- }
230
- if (readU32(buffer, localOffset) !== LOCAL_SIG) {
231
- throw new Error(`Invalid zip archive: bad local header for ${relativePath}`);
232
- }
233
- const localNameLength = readU16(buffer, localOffset + 26);
234
- const localExtraLength = readU16(buffer, localOffset + 28);
235
- const dataStart = localOffset + 30 + localNameLength + localExtraLength;
236
- const payload = buffer.subarray(dataStart, dataStart + compressedSize);
237
- let data;
238
- if (compression === 0) {
239
- data = Buffer.from(payload);
240
- } else if (compression === 8) {
241
- data = inflateRawSync(payload);
242
- } else {
243
- throw new Error(`Unsupported zip compression method ${compression} for ${relativePath}`);
244
- }
245
- if (data.length !== uncompressedSize) {
246
- throw new Error(`Zip size mismatch for ${relativePath}`);
247
- }
248
- files.push({ path: relativePath, data });
249
- }
250
- return stripSingleRoot(files);
251
- }
252
-
253
- // src/services/apm-pack.ts
254
- var PLUGIN_NATIVE_DIRS = ["agents", "skills", "commands", "hooks"];
255
- var PACK_LOCKFILE_NAME = APM_LOCKFILE_FILENAME;
256
- var APM_CACHE_DIR = "apm_modules";
257
- var AUTHORED_PLUGIN_JSON_PATHS = [
258
- "plugin.json",
259
- ".github/plugin/plugin.json",
260
- ".claude-plugin/plugin.json",
261
- ".cursor-plugin/plugin.json"
262
- ];
263
- var PackError = class extends Error {
264
- constructor(message) {
265
- super(message);
266
- this.name = "PackError";
267
- }
268
- };
269
- function isRecord(value) {
270
- return value !== null && typeof value === "object" && !Array.isArray(value);
271
- }
272
- function posixRelative(from, to) {
273
- return relative(from, to).split(sep).join("/");
274
- }
275
- function sha256Hex(bytes) {
276
- return createHash("sha256").update(bytes).digest("hex");
277
- }
278
- function normalizeSha256(value) {
279
- return value.replace(/^sha256:/i, "").toLowerCase();
280
- }
281
- function isPluginNativeDir(value) {
282
- return PLUGIN_NATIVE_DIRS.includes(value);
283
- }
284
- function isSymlink(path) {
285
- try {
286
- return lstatSync(path).isSymbolicLink();
287
- } catch {
288
- return false;
289
- }
290
- }
291
- function assertNotSymlink(path, relativePath) {
292
- if (isSymlink(path)) {
293
- throw new BundleSymlinkError(relativePath);
294
- }
295
- }
296
- function walkRegularFiles(root, current, files) {
297
- assertNotSymlink(current, posixRelative(root, current) || ".");
298
- for (const entry of readdirSync(current, { withFileTypes: true })) {
299
- if (entry.name.startsWith(".")) continue;
300
- const absolute = join(current, entry.name);
301
- const relativePath = posixRelative(root, absolute);
302
- if (entry.isSymbolicLink() || isSymlink(absolute)) {
303
- throw new BundleSymlinkError(relativePath);
304
- }
305
- if (entry.isDirectory()) {
306
- walkRegularFiles(root, absolute, files);
307
- continue;
308
- }
309
- if (!entry.isFile()) {
310
- throw new BundleSymlinkError(relativePath);
311
- }
312
- files.push(relativePath);
313
- }
314
- }
315
- function readBytes(root, relativePath) {
316
- assertContainedPath(root, relativePath);
317
- const absolute = join(root, relativePath);
318
- assertNotSymlink(absolute, relativePath);
319
- return readFileSync(absolute);
320
- }
321
- function remapLocalPath(relativePath, fromApm) {
322
- const posix = relativePath.split("\\").join("/");
323
- if (fromApm) {
324
- if (!posix.startsWith(".apm/")) return void 0;
325
- const rest = posix.slice(".apm/".length);
326
- const kind2 = rest.split("/")[0] ?? "";
327
- if (!isPluginNativeDir(kind2) || rest === kind2) return void 0;
328
- return rest;
329
- }
330
- const kind = posix.split("/")[0] ?? "";
331
- if (!isPluginNativeDir(kind) || posix === kind) return void 0;
332
- return posix;
333
- }
334
- function remapDependencyPath(relativePath) {
335
- const posix = relativePath.split("\\").join("/");
336
- if (posix === ".mcp.json" || posix === "mcp.json") return "mcp.json";
337
- const fromApm = remapLocalPath(posix, true);
338
- if (fromApm) return fromApm;
339
- return remapLocalPath(posix, false);
340
- }
341
- function putFile(files, relativePath, bytes, remappedFrom) {
342
- if (relativePath.split("/").includes("..")) {
343
- throw new PathEscapeError(relativePath, ".");
344
- }
345
- assertContainedPath(".", relativePath);
346
- files.set(relativePath, {
347
- relativePath,
348
- bytes,
349
- ...remappedFrom && remappedFrom !== relativePath ? { remappedFrom } : {}
350
- });
351
- }
352
- function collectDir(projectRoot, sourceRelative, fromApm, files) {
353
- const sourceDir = join(projectRoot, sourceRelative);
354
- if (!existsSync(sourceDir)) return;
355
- assertNotSymlink(sourceDir, sourceRelative);
356
- const found = [];
357
- walkRegularFiles(sourceDir, sourceDir, found);
358
- for (const child of found) {
359
- const sourcePath = posixRelative(projectRoot, join(sourceDir, child));
360
- const mapped = remapLocalPath(sourcePath, fromApm);
361
- if (!mapped) continue;
362
- putFile(files, mapped, readBytes(projectRoot, sourcePath), sourcePath);
363
- }
364
- }
365
- function collectLocalPrimitives(projectRoot, files, warnings) {
366
- const apmDir = join(projectRoot, ".apm");
367
- const apmPresent = existsSync(apmDir);
368
- if (apmPresent) {
369
- assertNotSymlink(apmDir, ".apm");
370
- for (const dir of PLUGIN_NATIVE_DIRS) {
371
- collectDir(projectRoot, join(".apm", dir), true, files);
372
- }
373
- for (const dir of PLUGIN_NATIVE_DIRS) {
374
- if (existsSync(join(projectRoot, dir))) {
375
- warnings.push(skippedRootSourceWarning(dir));
376
- }
377
- }
378
- return;
379
- }
380
- for (const dir of PLUGIN_NATIVE_DIRS) {
381
- collectDir(projectRoot, dir, false, files);
382
- }
383
- }
384
- function collectExplicitIncludes(projectRoot, includes, files) {
385
- for (const include of includes) {
386
- const relativePath = include.split("\\").join("/").replace(/^\.\//, "");
387
- const absolute = join(projectRoot, relativePath);
388
- if (!existsSync(absolute)) {
389
- throw new PackError(
390
- `includes path ${include} is missing and cannot be packed`
391
- );
392
- }
393
- assertNotSymlink(absolute, relativePath);
394
- const stat = lstatSync(absolute);
395
- if (stat.isDirectory()) {
396
- const found = [];
397
- walkRegularFiles(absolute, absolute, found);
398
- for (const child of found) {
399
- const sourcePath = posixRelative(projectRoot, join(absolute, child));
400
- const mapped2 = remapDependencyPath(sourcePath) ?? sourcePath;
401
- putFile(files, mapped2, readBytes(projectRoot, sourcePath), sourcePath);
402
- }
403
- continue;
404
- }
405
- const mapped = remapDependencyPath(relativePath) ?? relativePath;
406
- putFile(files, mapped, readBytes(projectRoot, relativePath), relativePath);
407
- }
408
- }
409
- function parseIncludes(document) {
410
- if (!document || document.includes === void 0 || document.includes === null) {
411
- return "auto";
412
- }
413
- if (document.includes === "auto") {
414
- return "auto";
415
- }
416
- if (Array.isArray(document.includes) && document.includes.every((entry) => typeof entry === "string")) {
417
- return document.includes;
418
- }
419
- throw new PackError('apm.yml field includes must be "auto" or a list of paths');
420
- }
421
- function asAuthor(value) {
422
- if (typeof value === "string" && value.trim()) {
423
- return { name: value.trim() };
424
- }
425
- if (isRecord(value)) {
426
- const name = typeof value.name === "string" ? value.name : void 0;
427
- if (!name) return void 0;
428
- return {
429
- name,
430
- ...typeof value.email === "string" ? { email: value.email } : {},
431
- ...typeof value.url === "string" ? { url: value.url } : {}
432
- };
433
- }
434
- return void 0;
435
- }
436
- function asString(value) {
437
- return typeof value === "string" && value.length > 0 ? value : void 0;
438
- }
439
- function asKeywords(value) {
440
- if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
441
- return void 0;
442
- }
443
- return value;
444
- }
445
- function repositoryUrl(value) {
446
- if (typeof value === "string" && value.length > 0) return value;
447
- if (isRecord(value) && typeof value.url === "string") return value.url;
448
- return void 0;
449
- }
450
- function synthesizePluginManifest(config) {
451
- const document = config.apm_document ?? {};
452
- const rawName = config.apm_name ?? "plugin";
453
- const name = isValidApName(rawName) ? rawName : slugifyApName(rawName);
454
- const version = config.apm_version ?? "1.0.0";
455
- const author = asAuthor(document.author);
456
- const keywords = asKeywords(document.keywords);
457
- const homepage = asString(document.homepage);
458
- const repository = repositoryUrl(document.repository);
459
- const license = asString(document.license);
460
- const description = config.apm_description ?? asString(document.description);
461
- const manifest = {
462
- $schema: AP_SCHEMA_URL,
463
- name,
464
- version,
465
- ...description ? { description } : {},
466
- ...author ? { author } : {},
467
- ...homepage ? { homepage } : {},
468
- ...repository ? { repository } : {},
469
- ...license ? { license } : {},
470
- ...keywords && keywords.length > 0 ? { keywords } : {}
471
- };
472
- validateApManifest(manifest);
473
- return manifest;
474
- }
475
- function loadAuthoredPluginJson(projectRoot) {
476
- for (const relativePath of AUTHORED_PLUGIN_JSON_PATHS) {
477
- const absolute = join(projectRoot, relativePath);
478
- if (!existsSync(absolute)) continue;
479
- assertNotSymlink(absolute, relativePath);
480
- const bytes = readFileSync(absolute);
481
- let parsed;
482
- try {
483
- parsed = JSON.parse(bytes.toString("utf8"));
484
- } catch {
485
- throw new PackError(`Invalid JSON in ${relativePath}`);
486
- }
487
- if (!isRecord(parsed)) {
488
- throw new PackError(`${relativePath} must be a JSON object`);
489
- }
490
- if (typeof parsed.$schema !== "string" || parsed.$schema.length === 0) {
491
- parsed.$schema = AP_SCHEMA_URL;
492
- } else if (lookupApSchema(parsed.$schema).kind === "legacy") {
493
- parsed.$schema = AP_SCHEMA_URL;
494
- }
495
- validateApManifest(parsed);
496
- return Buffer.from(`${JSON.stringify(parsed, null, 2)}
497
- `, "utf8");
498
- }
499
- return void 0;
500
- }
501
- function collectMcpJson(projectRoot, files) {
502
- for (const source of [".mcp.json", "mcp.json"]) {
503
- const absolute = join(projectRoot, source);
504
- if (!existsSync(absolute)) continue;
505
- assertNotSymlink(absolute, source);
506
- putFile(files, "mcp.json", readFileSync(absolute), source);
507
- return;
508
- }
509
- }
510
- function normalizePackedMcpJson(files, warnings) {
511
- const packed = files.get("mcp.json");
512
- if (!packed) return;
513
- let document;
514
- try {
515
- document = JSON.parse(packed.bytes.toString("utf8"));
516
- } catch {
517
- warnings.push(
518
- `${packed.remappedFrom ?? "mcp.json"} is not valid JSON; packed as is (not a valid Agent Plugins mcp.json)`
519
- );
520
- return;
521
- }
522
- if (isSpecMcpDocument(document)) return;
523
- const { document: spec, extras } = buildSpecMcpJson(parseMcpServersDocument(document), {
524
- carry: ["env_file", "auth", "enabled", "mode", "framing"]
525
- });
526
- putFile(
527
- files,
528
- "mcp.json",
529
- Buffer.from(`${formatSpecMcpJson(spec)}
530
- `, "utf8"),
531
- packed.remappedFrom
532
- );
533
- if (Object.keys(extras).length > 0) {
534
- putFile(files, HT_MCP_EXTRAS_PATH, Buffer.from(formatMcpExtrasToml(extras), "utf8"));
535
- }
536
- }
537
- function lockDocument(projectRoot) {
538
- const path = join(projectRoot, APM_LOCKFILE_FILENAME);
539
- if (!existsSync(path)) return void 0;
540
- assertNotSymlink(path, APM_LOCKFILE_FILENAME);
541
- const parsed = parseYaml(readFileSync(path, "utf8"));
542
- if (!isRecord(parsed)) {
543
- throw new PackError(`Invalid lockfile in ${path}: expected a YAML mapping`);
544
- }
545
- return parsed;
546
- }
547
- function collectAttestedDependencies(projectRoot, config, lock, files, warnings) {
548
- const cacheDir = join(projectRoot, APM_CACHE_DIR);
549
- if (existsSync(cacheDir)) {
550
- warnings.push(
551
- `${APM_CACHE_DIR}/ is never packed; dependency content is taken only from lockfile-attested deployed_files`
552
- );
553
- }
554
- const fileBackedDeps = config.apmDependencies.filter(
555
- (dependency) => dependency.sourceKind === "git" || dependency.sourceKind === "marketplace" || dependency.sourceKind === "catalog" || dependency.sourceKind === "local"
556
- );
557
- const lockDeps = Array.isArray(lock?.dependencies) ? lock.dependencies.filter(isRecord) : [];
558
- for (const dependency of fileBackedDeps) {
559
- if (dependency.sourceKind === "local" && !dependency.originRef.includes("/") && !dependency.originRef.startsWith(".")) {
560
- continue;
561
- }
562
- const lockEntry = lockDeps.find((entry) => {
563
- const name = String(entry.name ?? "");
564
- const repo = String(entry.repo_url ?? "");
565
- return name === dependency.name || repo.includes(dependency.name);
566
- });
567
- const deployedFiles = lockEntry && Array.isArray(lockEntry.deployed_files) ? lockEntry.deployed_files.map(String) : [];
568
- const hashes = lockEntry && isRecord(lockEntry.deployed_file_hashes) ? Object.fromEntries(
569
- Object.entries(lockEntry.deployed_file_hashes).map(([path, hash]) => [
570
- path,
571
- String(hash)
572
- ])
573
- ) : {};
574
- if (deployedFiles.length === 0) {
575
- if (existsSync(cacheDir)) {
576
- throw new PackError(
577
- `Dependency ${dependency.name} has cached primitives but no deployed_files in ${APM_LOCKFILE_FILENAME}. Run ht apply so the content is attested.`
578
- );
579
- }
580
- continue;
581
- }
582
- for (const deployed of deployedFiles) {
583
- const relativePath = deployed.split("\\").join("/");
584
- const absolute = join(projectRoot, relativePath);
585
- if (!existsSync(absolute)) {
586
- throw new PackError(
587
- `Attested file ${relativePath} from ${dependency.name} is missing. Run ht apply to restore it.`
588
- );
589
- }
590
- assertNotSymlink(absolute, relativePath);
591
- const bytes = readFileSync(absolute);
592
- const expected = hashes[relativePath];
593
- if (expected && normalizeSha256(expected) !== sha256Hex(bytes)) {
594
- throw new PackError(
595
- `${relativePath} does not match the hash recorded in ${APM_LOCKFILE_FILENAME}`
596
- );
597
- }
598
- const mapped = remapDependencyPath(relativePath);
599
- if (!mapped) continue;
600
- putFile(files, mapped, bytes, relativePath);
601
- }
602
- }
603
- }
604
- function embedLockfile(lock, files) {
605
- const bundleFiles = {};
606
- for (const file of [...files.values()].sort(
607
- (left, right) => left.relativePath.localeCompare(right.relativePath)
608
- )) {
609
- bundleFiles[file.relativePath] = sha256Hex(file.bytes);
610
- }
611
- const document = {
612
- ...lock ?? { lockfile_version: "1" },
613
- pack: {
614
- format: "plugin",
615
- packed_at: (/* @__PURE__ */ new Date()).toISOString(),
616
- bundle_files: bundleFiles
617
- }
618
- };
619
- const yaml = stringifyYaml(document, {
620
- indent: 2,
621
- lineWidth: 0,
622
- defaultKeyType: "PLAIN"
623
- });
624
- putFile(files, PACK_LOCKFILE_NAME, Buffer.from(yaml, "utf8"));
625
- }
626
- function writeDirectory(targetDir, files) {
627
- if (existsSync(targetDir)) {
628
- rmSync(targetDir, { recursive: true, force: true });
629
- }
630
- mkdirSync(targetDir, { recursive: true });
631
- for (const file of files) {
632
- const absolute = join(targetDir, file.relativePath);
633
- mkdirSync(dirname(absolute), { recursive: true });
634
- writeFileSync(absolute, file.bytes);
635
- }
636
- }
637
- function packProject(options = {}) {
638
- const start = resolve(options.projectRoot ?? process.cwd());
639
- const config = findProjectConfig(start);
640
- if (!config) {
641
- throw new PackError(
642
- `No apm.yml found under ${start}. Run ht config init or add an apm.yml at the project root.`
643
- );
644
- }
645
- const warnings = [];
646
- const files = /* @__PURE__ */ new Map();
647
- const includes = parseIncludes(config.apm_document);
648
- if (includes === "auto") {
649
- collectLocalPrimitives(config.rootPath, files, warnings);
650
- collectMcpJson(config.rootPath, files);
651
- } else {
652
- collectExplicitIncludes(config.rootPath, includes, files);
653
- }
654
- const lock = lockDocument(config.rootPath);
655
- collectAttestedDependencies(config.rootPath, config, lock, files, warnings);
656
- normalizePackedMcpJson(files, warnings);
657
- const authored = loadAuthoredPluginJson(config.rootPath);
658
- const manifestBytes = authored ?? Buffer.from(`${JSON.stringify(synthesizePluginManifest(config), null, 2)}
659
- `, "utf8");
660
- putFile(files, "plugin.json", manifestBytes, authored ? void 0 : "apm.yml");
661
- const unicodeFindings = [];
662
- for (const file of files.values()) {
663
- unicodeFindings.push(...scanUnicodeBuffer(file.bytes, file.relativePath));
664
- }
665
- if (hasCriticalUnicode(unicodeFindings)) {
666
- const critical = unicodeFindings.filter((finding) => finding.severity === "critical");
667
- const first = critical[0];
668
- throw new PackError(
669
- `Pack blocked: critical hidden Unicode in ${first?.file ?? "bundle"} (${first?.codepoint ?? "U+????"} ${first?.description ?? "critical character"}).`
670
- );
671
- }
672
- for (const finding of unicodeFindings.filter((entry) => entry.severity === "warning")) {
673
- warnings.push(
674
- `${finding.file}:${finding.line}:${finding.column} ${finding.codepoint} ${finding.description}`
675
- );
676
- }
677
- embedLockfile(lock, files);
678
- const packed = [...files.values()].sort(
679
- (left, right) => left.relativePath.localeCompare(right.relativePath)
680
- );
681
- let manifest;
682
- const pluginJson = files.get("plugin.json");
683
- if (!pluginJson) {
684
- throw new PackError("Packed bundle is missing plugin.json");
685
- }
686
- try {
687
- manifest = JSON.parse(pluginJson.bytes.toString("utf8"));
688
- } catch {
689
- throw new PackError("Packed plugin.json is not valid JSON");
690
- }
691
- const name = manifest.name;
692
- const version = manifest.version;
693
- const outputRoot = resolve(config.rootPath, options.outputDir ?? "build");
694
- const outputPath = options.archive ? join(outputRoot, `${name}-${version}.zip`) : join(outputRoot, name);
695
- if (!options.dryRun) {
696
- mkdirSync(outputRoot, { recursive: true });
697
- if (options.archive) {
698
- writeFileSync(
699
- outputPath,
700
- writeZipArchive(packed.map((file) => ({ path: file.relativePath, data: file.bytes })))
701
- );
702
- } else {
703
- writeDirectory(outputPath, packed);
704
- }
705
- }
706
- return {
707
- name,
708
- version,
709
- outputPath,
710
- archive: Boolean(options.archive),
711
- dryRun: Boolean(options.dryRun),
712
- fileCount: packed.length,
713
- files: packed.map((file) => ({
714
- path: file.relativePath,
715
- ...file.remappedFrom ? { remappedFrom: file.remappedFrom } : {}
716
- })),
717
- warnings,
718
- unicodeFindings
719
- };
720
- }
721
-
722
- export {
723
- readZipArchive,
724
- PACK_LOCKFILE_NAME,
725
- PackError,
726
- sha256Hex,
727
- normalizeSha256,
728
- packProject
729
- };
730
- //# sourceMappingURL=chunk-3JOPDYQD.js.map