@unbrained/pm-cli 2026.11.30 → 2026.12.2

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 (382) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/commander-usage.js +10 -10
  3. package/dist/cli/error-guidance.js +5 -5
  4. package/dist/cli/extension-command-help.js +6 -6
  5. package/dist/cli/help-json-payload.js +7 -7
  6. package/dist/cli/main.js +5 -5
  7. package/dist/cli/register-list-query.js +10 -10
  8. package/dist/cli/register-mutation.js +3 -3
  9. package/dist/cli/runtime/invocation-command-path.js +2 -0
  10. package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
  11. package/dist/cli-bundle/bundle-manifest.json +1 -1
  12. package/dist/cli-bundle/chunks/{chunk-DCWGM7CY.js → chunk-3HKPVOAN.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-Z7YL2SUM.js → chunk-3KEMIPKG.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-TX74QJ4W.js → chunk-4YYFY33T.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-47ZS6RPL.js → chunk-7NAO7I75.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-IGEFPHV7.js → chunk-7V65VACG.js} +52 -52
  17. package/dist/cli-bundle/chunks/chunk-A5ZEMOVR.js +2 -0
  18. package/dist/cli-bundle/chunks/{chunk-5PNOVDVO.js → chunk-AHV3CSQG.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-KCVSSONY.js → chunk-C6WM6ZN4.js} +3 -3
  20. package/dist/cli-bundle/chunks/chunk-CBUC4X7Q.js +127 -0
  21. package/dist/cli-bundle/chunks/{chunk-CCKM5YQM.js → chunk-G6TARHFK.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-TY55UX6M.js → chunk-GOEQXVOI.js} +2 -2
  23. package/dist/cli-bundle/chunks/chunk-I4SPJQQI.js +3 -0
  24. package/dist/cli-bundle/chunks/{chunk-Q4VZSMUL.js → chunk-L2ZSSMYY.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-NHBG5ET3.js → chunk-MZZ4ZJ5Z.js} +2 -2
  26. package/dist/cli-bundle/chunks/chunk-NRQCBUYD.js +113 -0
  27. package/dist/cli-bundle/chunks/{chunk-YVTALIN3.js → chunk-OBPO6V7H.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-KXTKLDKD.js → chunk-OXC5KBIQ.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-HXQ3OHQR.js → chunk-PCDTWL6V.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-AOTI76Q6.js → chunk-Q6K7HWZ7.js} +2 -2
  31. package/dist/cli-bundle/chunks/chunk-QDV7S2QS.js +2 -0
  32. package/dist/cli-bundle/chunks/{chunk-NZSXWIX7.js → chunk-ROTEELDL.js} +7 -7
  33. package/dist/cli-bundle/chunks/{chunk-WFYE34TO.js → chunk-SDXCJZKB.js} +23 -23
  34. package/dist/cli-bundle/chunks/{chunk-2SBTXR6C.js → chunk-SY5C3U32.js} +3 -3
  35. package/dist/cli-bundle/chunks/{chunk-FR7ULTM4.js → chunk-TKUG2X24.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-FECZV72T.js → chunk-UNBW2LF3.js} +2 -2
  37. package/dist/cli-bundle/chunks/chunk-V2S4XAX3.js +2 -0
  38. package/dist/cli-bundle/chunks/chunk-WSEIEDEK.js +2 -0
  39. package/dist/cli-bundle/chunks/{chunk-ZA5NS3PL.js → chunk-ZL6J6JYT.js} +6 -6
  40. package/dist/cli-bundle/chunks/{field-option-collisions-2F2Z7R7B.js → field-option-collisions-BBGTV7AD.js} +2 -2
  41. package/dist/cli-bundle/chunks/item-revision-3LENTXYF.js +2 -0
  42. package/dist/cli-bundle/chunks/item-transaction-56J5OCHA.js +2 -0
  43. package/dist/cli-bundle/chunks/{linked-resource-value-list-WXPPYUVQ.js → linked-resource-value-list-ZBIY4H23.js} +2 -2
  44. package/dist/cli-bundle/chunks/{mutation-actor-UK3QNEEB.js → mutation-actor-NHN33ITJ.js} +2 -2
  45. package/dist/cli-bundle/chunks/{mutation-admission-UTDYPFWP.js → mutation-admission-PGKJTCG6.js} +2 -2
  46. package/dist/cli-bundle/chunks/{register-list-query-DRA3CWHI.js → register-list-query-7S5QWDTI.js} +11 -11
  47. package/dist/cli-bundle/chunks/{register-mutation-WO74VLEQ.js → register-mutation-EK6DVIQK.js} +5 -5
  48. package/dist/cli-bundle/chunks/{register-operations-CRBKH7WN.js → register-operations-6MURXE4V.js} +2 -2
  49. package/dist/cli-bundle/chunks/{register-setup-6V6NQB5C.js → register-setup-RW26X3GJ.js} +2 -2
  50. package/dist/cli-bundle/chunks/{stage-DYEHGASU.js → stage-4ZCF74G4.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-RQYVX2T6.js → chunk-2DGKVXFT.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/chunk-2UWKU2BQ.js +3 -0
  53. package/dist/cli-bundle/focused-chunks/{chunk-A3DORTXS.js → chunk-3COWDIPX.js} +54 -54
  54. package/dist/cli-bundle/focused-chunks/{chunk-UQJ4PY2Y.js → chunk-4SCFAWAW.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-7G7JIXLL.js → chunk-6BKT6XQN.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/chunk-6IY5CVGJ.js +2 -0
  57. package/dist/cli-bundle/focused-chunks/chunk-7A6SEZEY.js +4 -0
  58. package/dist/cli-bundle/focused-chunks/{chunk-IJ3T3W4U.js → chunk-BHNBPCHP.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-LWBZ7UGG.js → chunk-EQCQTYKO.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-FM5WQ6ZU.js → chunk-HTDYNY4L.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-TQQO42C2.js → chunk-J72TRWR5.js} +26 -26
  62. package/dist/cli-bundle/focused-chunks/{chunk-L357ZAES.js → chunk-JPZGC3W4.js} +5 -5
  63. package/dist/cli-bundle/focused-chunks/{chunk-62AMZMR4.js → chunk-KNBGHCIP.js} +3 -3
  64. package/dist/cli-bundle/focused-chunks/chunk-N64AC5G6.js +100 -0
  65. package/dist/cli-bundle/focused-chunks/{chunk-IIVDBAJM.js → chunk-OG57ESZK.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/{chunk-MZNV26XE.js → chunk-P2H3GTJK.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/chunk-QZRYGYTI.js +2 -0
  68. package/dist/cli-bundle/focused-chunks/chunk-SQMOF65W.js +2 -0
  69. package/dist/cli-bundle/focused-chunks/chunk-T3ILWAEV.js +2 -0
  70. package/dist/cli-bundle/focused-chunks/{chunk-SXC3NVZI.js → chunk-TR22GU7M.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{chunk-M57KDG7I.js → chunk-TXTPAFHJ.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/chunk-VK3IE3TS.js +29 -0
  73. package/dist/cli-bundle/focused-chunks/{chunk-NJTKGBSK.js → chunk-VQIC3UZB.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/{chunk-U35K7FSE.js → chunk-W4JMV7GF.js} +2 -2
  75. package/dist/cli-bundle/focused-chunks/{field-option-collisions-7TG7STO7.js → field-option-collisions-2C6DLUC4.js} +2 -2
  76. package/dist/cli-bundle/focused-chunks/item-revision-723XCQPS.js +2 -0
  77. package/dist/cli-bundle/focused-chunks/{item-transaction-2IC2MLML.js → item-transaction-LQLQLZE7.js} +2 -2
  78. package/dist/cli-bundle/focused-chunks/{mutation-actor-LJVF2HVD.js → mutation-actor-DJMZUIZI.js} +2 -2
  79. package/dist/cli-bundle/focused-chunks/mutation-admission-SDWQVVHN.js +2 -0
  80. package/dist/cli-bundle/focused-chunks/{stage-MWR73LTZ.js → stage-QBZIK3T5.js} +2 -2
  81. package/dist/cli-bundle/main.js +27 -27
  82. package/dist/cli-bundle/sdk-authoring.js +1 -1
  83. package/dist/cli-bundle/sdk-contracts.js +1 -1
  84. package/dist/cli-bundle/sdk-core.js +1 -1
  85. package/dist/cli-bundle/sdk-governance.js +1 -1
  86. package/dist/cli-bundle/sdk-graph.js +1 -1
  87. package/dist/cli-bundle/sdk-merge.js +61 -61
  88. package/dist/cli-bundle/sdk-query.js +1 -1
  89. package/dist/cli-bundle/sdk-runtime.js +1 -1
  90. package/dist/cli-bundle/sdk-testing.js +1 -1
  91. package/dist/cli-bundle/sdk.js +2 -2
  92. package/dist/core/extensions/reserved-host-flags.js +1 -1
  93. package/dist/core/shared/secret-rules.d.ts +86 -12
  94. package/dist/core/shared/secret-rules.js +7 -5
  95. package/dist/sdk/cli-bootstrap.js +1 -1
  96. package/dist/sdk/cli-contracts/flag-contracts.d.ts +50 -0
  97. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  98. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -1
  99. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  100. package/dist/sdk/extension/command-options.js +1 -1
  101. package/dist/sdk/extension/install-sources.d.ts +2 -2
  102. package/dist/sdk/extension/install-sources.js +5 -5
  103. package/dist/sdk/lifecycle/expect-hash-admission.d.ts +15 -0
  104. package/dist/sdk/lifecycle/expect-hash-admission.js +2 -0
  105. package/dist/sdk/lifecycle/item-revision.d.ts +4 -1
  106. package/dist/sdk/lifecycle/item-revision.js +1 -1
  107. package/dist/sdk/mutation-guard.js +1 -1
  108. package/dist/sdk/output-contracts.js +1 -1
  109. package/dist/sdk/output-projection.d.ts +1 -1
  110. package/dist/sdk/output-projection.js +1 -1
  111. package/dist/sdk/public-surface.json +1 -1
  112. package/dist/sdk/query/aggregate.js +1 -1
  113. package/dist/sdk/query/context.js +1 -1
  114. package/dist/sdk/query/list.js +1 -1
  115. package/dist/sdk/query/next.js +1 -1
  116. package/dist/sdk/query/search-contracts.js +1 -1
  117. package/dist/sdk/read-output/surfaces.js +1 -1
  118. package/dist/sdk/read-output-budget.d.ts +1 -1
  119. package/dist/sdk/read-output-budget.js +1 -1
  120. package/dist/sdk/read-output-contracts.js +1 -1
  121. package/dist/sdk/read-output-rows.js +1 -1
  122. package/docs/COMMANDS.md +37 -0
  123. package/docs/MUTATION_INTEGRITY.md +226 -10
  124. package/docs/SDK.md +16 -6
  125. package/docs/agent-task-token-baseline.json +1 -1
  126. package/marketplace.json +1 -1
  127. package/node_modules/tar/README.md +1792 -1147
  128. package/node_modules/tar/dist/commonjs/bytes.d.ts +21 -0
  129. package/node_modules/tar/dist/commonjs/bytes.js +83 -0
  130. package/node_modules/tar/dist/commonjs/codec.d.ts +53 -0
  131. package/node_modules/tar/dist/commonjs/codec.js +35 -0
  132. package/node_modules/tar/dist/commonjs/concat.d.ts +3 -0
  133. package/node_modules/tar/dist/commonjs/concat.js +20 -0
  134. package/node_modules/tar/dist/commonjs/create.d.ts +39 -2
  135. package/node_modules/tar/dist/commonjs/create.js +150 -64
  136. package/node_modules/tar/dist/commonjs/dealias.d.ts +79 -0
  137. package/node_modules/tar/dist/commonjs/dealias.js +50 -0
  138. package/node_modules/tar/dist/commonjs/delete.d.ts +19 -0
  139. package/node_modules/tar/dist/commonjs/delete.js +121 -0
  140. package/node_modules/tar/dist/commonjs/entries.d.ts +82 -0
  141. package/node_modules/tar/dist/commonjs/entries.js +398 -0
  142. package/node_modules/tar/dist/commonjs/extract.d.ts +14 -2
  143. package/node_modules/tar/dist/commonjs/extract.js +40 -81
  144. package/node_modules/tar/dist/commonjs/fs.d.ts +201 -0
  145. package/node_modules/tar/dist/commonjs/fs.js +5 -0
  146. package/node_modules/tar/dist/commonjs/header.d.ts +4 -4
  147. package/node_modules/tar/dist/commonjs/header.js +71 -53
  148. package/node_modules/tar/dist/commonjs/index.d.ts +25 -18
  149. package/node_modules/tar/dist/commonjs/index.js +46 -18
  150. package/node_modules/tar/dist/commonjs/index.min.js +2 -3
  151. package/node_modules/tar/dist/commonjs/large-numbers.d.ts +2 -2
  152. package/node_modules/tar/dist/commonjs/large-numbers.js +4 -4
  153. package/node_modules/tar/dist/commonjs/list.d.ts +23 -6
  154. package/node_modules/tar/dist/commonjs/list.js +99 -138
  155. package/node_modules/tar/dist/commonjs/mkdir.d.ts +16 -11
  156. package/node_modules/tar/dist/commonjs/mkdir.js +121 -159
  157. package/node_modules/tar/dist/commonjs/normalize-unicode.js +9 -0
  158. package/node_modules/tar/dist/commonjs/options.d.ts +284 -513
  159. package/node_modules/tar/dist/commonjs/options.js +20 -61
  160. package/node_modules/tar/dist/commonjs/pack.d.ts +150 -96
  161. package/node_modules/tar/dist/commonjs/pack.js +752 -445
  162. package/node_modules/tar/dist/commonjs/parser.d.ts +98 -0
  163. package/node_modules/tar/dist/commonjs/parser.js +452 -0
  164. package/node_modules/tar/dist/commonjs/path-reservations.d.ts +17 -7
  165. package/node_modules/tar/dist/commonjs/path-reservations.js +110 -140
  166. package/node_modules/tar/dist/commonjs/path.d.ts +19 -0
  167. package/node_modules/tar/dist/commonjs/path.js +90 -0
  168. package/node_modules/tar/dist/commonjs/pax.d.ts +3 -1
  169. package/node_modules/tar/dist/commonjs/pax.js +67 -36
  170. package/node_modules/tar/dist/commonjs/read-entry.d.ts +97 -11
  171. package/node_modules/tar/dist/commonjs/read-entry.js +251 -97
  172. package/node_modules/tar/dist/commonjs/read-file.d.ts +22 -0
  173. package/node_modules/tar/dist/commonjs/read-file.js +104 -0
  174. package/node_modules/tar/dist/commonjs/replace.d.ts +45 -1
  175. package/node_modules/tar/dist/commonjs/replace.js +164 -211
  176. package/node_modules/tar/dist/commonjs/server/codecs.d.ts +38 -0
  177. package/node_modules/tar/dist/commonjs/server/codecs.js +252 -0
  178. package/node_modules/tar/dist/commonjs/server/index.d.ts +115 -0
  179. package/node_modules/tar/dist/commonjs/server/index.js +166 -0
  180. package/node_modules/tar/dist/commonjs/server/index.min.js +3 -0
  181. package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +8 -0
  182. package/node_modules/tar/dist/commonjs/strip-absolute-path.js +17 -20
  183. package/node_modules/tar/dist/commonjs/to-stream.d.ts +7 -0
  184. package/node_modules/tar/dist/commonjs/to-stream.js +22 -0
  185. package/node_modules/tar/dist/commonjs/types.d.ts +4 -3
  186. package/node_modules/tar/dist/commonjs/types.js +4 -3
  187. package/node_modules/tar/dist/commonjs/unpack.d.ts +143 -89
  188. package/node_modules/tar/dist/commonjs/unpack.js +780 -725
  189. package/node_modules/tar/dist/commonjs/update.d.ts +11 -1
  190. package/node_modules/tar/dist/commonjs/update.js +37 -28
  191. package/node_modules/tar/dist/commonjs/warn.d.ts +27 -0
  192. package/node_modules/tar/dist/commonjs/warn.js +36 -0
  193. package/node_modules/tar/dist/commonjs/win32-path.d.ts +16 -0
  194. package/node_modules/tar/dist/commonjs/win32-path.js +67 -0
  195. package/node_modules/tar/dist/commonjs/write-entry.d.ts +64 -111
  196. package/node_modules/tar/dist/commonjs/write-entry.js +108 -672
  197. package/node_modules/tar/dist/commonjs/write-flag.d.ts +18 -0
  198. package/node_modules/tar/dist/commonjs/write-flag.js +29 -0
  199. package/node_modules/tar/dist/esm/bytes.d.ts +21 -0
  200. package/node_modules/tar/dist/esm/bytes.js +72 -0
  201. package/node_modules/tar/dist/esm/codec.d.ts +53 -0
  202. package/node_modules/tar/dist/esm/codec.js +32 -0
  203. package/node_modules/tar/dist/esm/concat.d.ts +3 -0
  204. package/node_modules/tar/dist/esm/concat.js +16 -0
  205. package/node_modules/tar/dist/esm/create.d.ts +39 -2
  206. package/node_modules/tar/dist/esm/create.js +144 -61
  207. package/node_modules/tar/dist/esm/dealias.d.ts +79 -0
  208. package/node_modules/tar/dist/esm/dealias.js +46 -0
  209. package/node_modules/tar/dist/esm/delete.d.ts +19 -0
  210. package/node_modules/tar/dist/esm/delete.js +117 -0
  211. package/node_modules/tar/dist/esm/entries.d.ts +82 -0
  212. package/node_modules/tar/dist/esm/entries.js +388 -0
  213. package/node_modules/tar/dist/esm/extract.d.ts +14 -2
  214. package/node_modules/tar/dist/esm/extract.js +37 -44
  215. package/node_modules/tar/dist/esm/fs.d.ts +201 -0
  216. package/node_modules/tar/dist/esm/fs.js +4 -0
  217. package/node_modules/tar/dist/esm/header.d.ts +4 -4
  218. package/node_modules/tar/dist/esm/header.js +71 -53
  219. package/node_modules/tar/dist/esm/index.d.ts +25 -18
  220. package/node_modules/tar/dist/esm/index.js +23 -18
  221. package/node_modules/tar/dist/esm/index.min.js +2 -3
  222. package/node_modules/tar/dist/esm/large-numbers.d.ts +2 -2
  223. package/node_modules/tar/dist/esm/large-numbers.js +4 -4
  224. package/node_modules/tar/dist/esm/list.d.ts +23 -6
  225. package/node_modules/tar/dist/esm/list.js +96 -101
  226. package/node_modules/tar/dist/esm/mkdir.d.ts +16 -11
  227. package/node_modules/tar/dist/esm/mkdir.js +119 -154
  228. package/node_modules/tar/dist/esm/normalize-unicode.js +9 -0
  229. package/node_modules/tar/dist/esm/options.d.ts +284 -513
  230. package/node_modules/tar/dist/esm/options.js +17 -51
  231. package/node_modules/tar/dist/esm/pack.d.ts +150 -96
  232. package/node_modules/tar/dist/esm/pack.js +750 -441
  233. package/node_modules/tar/dist/esm/parser.d.ts +98 -0
  234. package/node_modules/tar/dist/esm/parser.js +448 -0
  235. package/node_modules/tar/dist/esm/path-reservations.d.ts +17 -7
  236. package/node_modules/tar/dist/esm/path-reservations.js +110 -140
  237. package/node_modules/tar/dist/esm/path.d.ts +19 -0
  238. package/node_modules/tar/dist/esm/path.js +80 -0
  239. package/node_modules/tar/dist/esm/pax.d.ts +3 -1
  240. package/node_modules/tar/dist/esm/pax.js +66 -35
  241. package/node_modules/tar/dist/esm/read-entry.d.ts +97 -11
  242. package/node_modules/tar/dist/esm/read-entry.js +248 -96
  243. package/node_modules/tar/dist/esm/read-file.d.ts +22 -0
  244. package/node_modules/tar/dist/esm/read-file.js +99 -0
  245. package/node_modules/tar/dist/esm/replace.d.ts +45 -1
  246. package/node_modules/tar/dist/esm/replace.js +160 -207
  247. package/node_modules/tar/dist/esm/server/codecs.d.ts +38 -0
  248. package/node_modules/tar/dist/esm/server/codecs.js +214 -0
  249. package/node_modules/tar/dist/esm/server/index.d.ts +115 -0
  250. package/node_modules/tar/dist/esm/server/index.js +102 -0
  251. package/node_modules/tar/dist/esm/server/index.min.js +3 -0
  252. package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +8 -0
  253. package/node_modules/tar/dist/esm/strip-absolute-path.js +17 -20
  254. package/node_modules/tar/dist/esm/to-stream.d.ts +7 -0
  255. package/node_modules/tar/dist/esm/to-stream.js +18 -0
  256. package/node_modules/tar/dist/esm/types.d.ts +4 -3
  257. package/node_modules/tar/dist/esm/types.js +4 -3
  258. package/node_modules/tar/dist/esm/unpack.d.ts +143 -89
  259. package/node_modules/tar/dist/esm/unpack.js +776 -719
  260. package/node_modules/tar/dist/esm/update.d.ts +11 -1
  261. package/node_modules/tar/dist/esm/update.js +35 -28
  262. package/node_modules/tar/dist/esm/warn.d.ts +27 -0
  263. package/node_modules/tar/dist/esm/warn.js +31 -0
  264. package/node_modules/tar/dist/esm/win32-path.d.ts +16 -0
  265. package/node_modules/tar/dist/esm/win32-path.js +60 -0
  266. package/node_modules/tar/dist/esm/write-entry.d.ts +64 -111
  267. package/node_modules/tar/dist/esm/write-entry.js +107 -633
  268. package/node_modules/tar/dist/esm/write-flag.d.ts +18 -0
  269. package/node_modules/tar/dist/esm/write-flag.js +25 -0
  270. package/node_modules/tar/package.json +68 -224
  271. package/package.json +2 -2
  272. package/packages/pm-beads/package.json +1 -1
  273. package/packages/pm-calendar/package.json +1 -1
  274. package/packages/pm-command-kit/package.json +1 -1
  275. package/packages/pm-digital-twin/package.json +1 -1
  276. package/packages/pm-governance-audit/package.json +1 -1
  277. package/packages/pm-guide-shell/package.json +1 -1
  278. package/packages/pm-kanban/package.json +1 -1
  279. package/packages/pm-lifecycle-hooks/package.json +1 -1
  280. package/packages/pm-linked-test-adapters/package.json +1 -1
  281. package/packages/pm-search-advanced/package.json +1 -1
  282. package/packages/pm-templates/package.json +1 -1
  283. package/packages/pm-todos/package.json +1 -1
  284. package/packages/pm-vcs/package.json +1 -1
  285. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  286. package/plugins/pm-claude/package.json +1 -1
  287. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  288. package/plugins/pm-codex/package.json +1 -1
  289. package/plugins/pm-codex/plugin.json +1 -1
  290. package/runtime-dependencies.json +1 -1
  291. package/dist/cli-bundle/chunks/chunk-3TXEWHQX.js +0 -125
  292. package/dist/cli-bundle/chunks/chunk-JPJNJHQW.js +0 -2
  293. package/dist/cli-bundle/chunks/chunk-NVYDPNQP.js +0 -2
  294. package/dist/cli-bundle/chunks/chunk-SJWIPGZW.js +0 -113
  295. package/dist/cli-bundle/chunks/chunk-USBTXMKS.js +0 -2
  296. package/dist/cli-bundle/chunks/chunk-VCXQ6A35.js +0 -3
  297. package/dist/cli-bundle/chunks/chunk-YPMNXG2C.js +0 -2
  298. package/dist/cli-bundle/chunks/item-revision-UAF6L47R.js +0 -2
  299. package/dist/cli-bundle/chunks/item-transaction-RJECL53Y.js +0 -2
  300. package/dist/cli-bundle/focused-chunks/chunk-2UUBS4BG.js +0 -2
  301. package/dist/cli-bundle/focused-chunks/chunk-4ER3VMST.js +0 -2
  302. package/dist/cli-bundle/focused-chunks/chunk-4YBMHMBJ.js +0 -2
  303. package/dist/cli-bundle/focused-chunks/chunk-HXM7K6VH.js +0 -100
  304. package/dist/cli-bundle/focused-chunks/chunk-NGHT2LNG.js +0 -3
  305. package/dist/cli-bundle/focused-chunks/chunk-P55AZPFN.js +0 -2
  306. package/dist/cli-bundle/focused-chunks/chunk-WAP3DF4B.js +0 -27
  307. package/dist/cli-bundle/focused-chunks/chunk-XR745UGE.js +0 -4
  308. package/dist/cli-bundle/focused-chunks/item-revision-J7EUGCHR.js +0 -2
  309. package/dist/cli-bundle/focused-chunks/mutation-admission-SLFAUONA.js +0 -2
  310. package/node_modules/@isaacs/fs-minipass/LICENSE +0 -15
  311. package/node_modules/@isaacs/fs-minipass/README.md +0 -71
  312. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +0 -118
  313. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +0 -430
  314. package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +0 -3
  315. package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +0 -118
  316. package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +0 -420
  317. package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +0 -3
  318. package/node_modules/@isaacs/fs-minipass/package.json +0 -72
  319. package/node_modules/chownr/LICENSE.md +0 -63
  320. package/node_modules/chownr/README.md +0 -3
  321. package/node_modules/chownr/dist/commonjs/index.d.ts +0 -3
  322. package/node_modules/chownr/dist/commonjs/index.js +0 -93
  323. package/node_modules/chownr/dist/commonjs/package.json +0 -3
  324. package/node_modules/chownr/dist/esm/index.d.ts +0 -3
  325. package/node_modules/chownr/dist/esm/index.js +0 -85
  326. package/node_modules/chownr/dist/esm/package.json +0 -3
  327. package/node_modules/chownr/package.json +0 -69
  328. package/node_modules/minipass/LICENSE.md +0 -55
  329. package/node_modules/minipass/README.md +0 -825
  330. package/node_modules/minipass/dist/commonjs/index.d.ts +0 -545
  331. package/node_modules/minipass/dist/commonjs/index.js +0 -1038
  332. package/node_modules/minipass/dist/commonjs/package.json +0 -3
  333. package/node_modules/minipass/dist/esm/index.d.ts +0 -545
  334. package/node_modules/minipass/dist/esm/index.js +0 -1020
  335. package/node_modules/minipass/dist/esm/package.json +0 -3
  336. package/node_modules/minipass/package.json +0 -77
  337. package/node_modules/minizlib/LICENSE +0 -26
  338. package/node_modules/minizlib/README.md +0 -64
  339. package/node_modules/minizlib/dist/commonjs/constants.d.ts +0 -2
  340. package/node_modules/minizlib/dist/commonjs/constants.js +0 -123
  341. package/node_modules/minizlib/dist/commonjs/index.d.ts +0 -99
  342. package/node_modules/minizlib/dist/commonjs/index.js +0 -416
  343. package/node_modules/minizlib/dist/commonjs/package.json +0 -3
  344. package/node_modules/minizlib/dist/esm/constants.d.ts +0 -2
  345. package/node_modules/minizlib/dist/esm/constants.js +0 -117
  346. package/node_modules/minizlib/dist/esm/index.d.ts +0 -99
  347. package/node_modules/minizlib/dist/esm/index.js +0 -363
  348. package/node_modules/minizlib/dist/esm/package.json +0 -3
  349. package/node_modules/minizlib/package.json +0 -80
  350. package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +0 -2
  351. package/node_modules/tar/dist/commonjs/get-write-flag.js +0 -32
  352. package/node_modules/tar/dist/commonjs/make-command.d.ts +0 -49
  353. package/node_modules/tar/dist/commonjs/make-command.js +0 -52
  354. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +0 -2
  355. package/node_modules/tar/dist/commonjs/normalize-windows-path.js +0 -12
  356. package/node_modules/tar/dist/commonjs/parse.d.ts +0 -92
  357. package/node_modules/tar/dist/commonjs/parse.js +0 -655
  358. package/node_modules/tar/dist/commonjs/process-umask.d.ts +0 -2
  359. package/node_modules/tar/dist/commonjs/process-umask.js +0 -7
  360. package/node_modules/tar/dist/commonjs/warn-method.d.ts +0 -24
  361. package/node_modules/tar/dist/commonjs/warn-method.js +0 -31
  362. package/node_modules/tar/dist/esm/get-write-flag.d.ts +0 -2
  363. package/node_modules/tar/dist/esm/get-write-flag.js +0 -26
  364. package/node_modules/tar/dist/esm/make-command.d.ts +0 -49
  365. package/node_modules/tar/dist/esm/make-command.js +0 -48
  366. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +0 -2
  367. package/node_modules/tar/dist/esm/normalize-windows-path.js +0 -9
  368. package/node_modules/tar/dist/esm/parse.d.ts +0 -92
  369. package/node_modules/tar/dist/esm/parse.js +0 -651
  370. package/node_modules/tar/dist/esm/process-umask.d.ts +0 -2
  371. package/node_modules/tar/dist/esm/process-umask.js +0 -3
  372. package/node_modules/tar/dist/esm/warn-method.d.ts +0 -24
  373. package/node_modules/tar/dist/esm/warn-method.js +0 -27
  374. package/node_modules/yallist/LICENSE.md +0 -63
  375. package/node_modules/yallist/README.md +0 -205
  376. package/node_modules/yallist/dist/commonjs/index.d.ts +0 -39
  377. package/node_modules/yallist/dist/commonjs/index.js +0 -384
  378. package/node_modules/yallist/dist/commonjs/package.json +0 -3
  379. package/node_modules/yallist/dist/esm/index.d.ts +0 -39
  380. package/node_modules/yallist/dist/esm/index.js +0 -379
  381. package/node_modules/yallist/dist/esm/package.json +0 -3
  382. package/node_modules/yallist/package.json +0 -68
@@ -1,166 +1,136 @@
1
- // A path exclusive reservation system
2
- // reserve([list, of, paths], fn)
3
- // When the fn is first in line for all its paths, it
4
- // is called with a cb that clears the reservation.
5
- //
6
- // Used by async unpack to avoid clobbering paths in use,
7
- // while still allowing maximal safe parallelization.
8
- import { join } from 'node:path';
1
+ // The async extraction does several entries at one time. Two entries
2
+ // must not work on the same path at one time: a link needs its
3
+ // target, and an entry can replace an object of a different type.
9
4
  import { normalizeUnicode } from './normalize-unicode.js';
10
5
  import { stripTrailingSlashes } from './strip-trailing-slashes.js';
11
- const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
12
- const isWindows = platform === 'win32';
13
- // return a set of parent dirs for a given path
14
- // '/a/b/c/d' -> ['/', '/a', '/a/b', '/a/b/c', '/a/b/c/d']
15
- const getDirs = (path) => {
16
- const dirs = path
17
- .split('/')
18
- .slice(0, -1)
19
- .reduce((set, path) => {
20
- const s = set.at(-1);
21
- if (s !== undefined) {
22
- path = join(s, path);
23
- }
24
- set.push(path || '/');
25
- return set;
26
- }, []);
27
- return dirs;
28
- };
6
+ import { join } from './path.js';
7
+ /**
8
+ * Gives each task the exclusive use of its paths, and the shared use
9
+ * of their parent directories. A task starts when each task before
10
+ * it that uses one of its paths, or a directory above or below one,
11
+ * is done.
12
+ *
13
+ * Paths that differ only in case or in Unicode form are the same
14
+ * path, because they can be the same file on disk.
15
+ */
29
16
  export class PathReservations {
30
- // path => [function or Set]
31
- // A Set object means a directory reservation
32
- // A fn is a direct reservation on that path
33
- #queues = new Map();
34
- // fn => {paths:[path,...], dirs:[path, ...]}
17
+ #root = { queue: [], name: '' };
35
18
  #reservations = new Map();
36
- // functions currently running
37
19
  #running = new Set();
20
+ #win32;
21
+ /** @param win32 run one task at a time */
22
+ constructor(win32 = false) {
23
+ this.#win32 = win32;
24
+ }
25
+ /**
26
+ * Call `fn` when it is first in line for each of its paths. The
27
+ * paths are free again when the promise of `fn` settles. Returns a
28
+ * promise with the result of `fn`.
29
+ */
38
30
  reserve(paths, fn) {
39
- paths =
40
- isWindows ?
41
- ['win32 parallelization disabled']
42
- : paths.map(p => {
43
- // don't need normPath, because we skip this entirely for windows
44
- return stripTrailingSlashes(join(normalizeUnicode(p)));
31
+ return new Promise((res, rej) => {
32
+ const handler = () => {
33
+ fn().then(() => {
34
+ this.#clear(handler);
35
+ res();
36
+ }, er => {
37
+ this.#clear(handler);
38
+ rej(er);
45
39
  });
46
- const dirs = new Set(paths.map(path => getDirs(path)).reduce((a, b) => a.concat(b)));
47
- this.#reservations.set(fn, { dirs, paths });
48
- for (const p of paths) {
49
- const q = this.#queues.get(p);
50
- if (!q) {
51
- this.#queues.set(p, [fn]);
52
- }
53
- else {
54
- q.push(fn);
55
- }
56
- }
57
- for (const dir of dirs) {
58
- const q = this.#queues.get(dir);
59
- if (!q) {
60
- this.#queues.set(dir, [new Set([fn])]);
61
- }
62
- else {
63
- const l = q.at(-1);
64
- if (l instanceof Set) {
65
- l.add(fn);
66
- }
67
- else {
68
- q.push(new Set([fn]));
69
- }
40
+ };
41
+ this.#add(paths, handler);
42
+ });
43
+ }
44
+ #add(names, fn) {
45
+ const root = this.#root;
46
+ const paths = new Set();
47
+ const dirs = new Set();
48
+ for (const name of this.#win32 ?
49
+ ['win32 parallelization disabled']
50
+ : names) {
51
+ const path = this.#win32 ? name : (stripTrailingSlashes(join(normalizeUnicode(name))));
52
+ let node = root;
53
+ for (const part of path.split('/')) {
54
+ if (node !== root)
55
+ dirs.add(node);
56
+ const kids = (node.kids ??= new Map());
57
+ let kid = kids.get(part);
58
+ if (!kid)
59
+ kids.set(part, (kid = { queue: [], name: part, up: node }));
60
+ node = kid;
70
61
  }
62
+ paths.add(node);
71
63
  }
72
- return this.#run(fn);
73
- }
74
- // return the queues for each path the function cares about
75
- // fn => {paths, dirs}
76
- #getQueues(fn) {
77
- const res = this.#reservations.get(fn);
78
- /* c8 ignore start */
79
- if (!res) {
80
- throw new Error('function does not have any path reservations');
64
+ // A path of the task is exclusive, so it also covers the use of
65
+ // that path as a parent directory of another path.
66
+ for (const p of paths)
67
+ dirs.delete(p);
68
+ this.#reservations.set(fn, { dirs, paths });
69
+ for (const p of paths)
70
+ p.queue.push(fn);
71
+ for (const { queue } of dirs) {
72
+ const last = queue[queue.length - 1];
73
+ if (last instanceof Set)
74
+ last.add(fn);
75
+ else
76
+ queue.push(new Set([fn]));
81
77
  }
82
- /* c8 ignore stop */
83
- return {
84
- paths: res.paths.map((path) => this.#queues.get(path)),
85
- dirs: [...res.dirs].map(path => this.#queues.get(path)),
86
- };
87
- }
88
- // check if fn is first in line for all its paths, and is
89
- // included in the first set for all its dir queues
90
- check(fn) {
91
- const { paths, dirs } = this.#getQueues(fn);
92
- return (paths.every(q => q && q[0] === fn) &&
93
- dirs.every(q => q && q[0] instanceof Set && q[0].has(fn)));
78
+ this.#run(fn);
94
79
  }
95
- // run the function if it's first in line and not already running
80
+ // Start the task if it is first in line for each path, and in the
81
+ // first set for each directory. A task that waits is never first in
82
+ // line for each of them, so a task starts one time only.
96
83
  #run(fn) {
97
- if (this.#running.has(fn) || !this.check(fn)) {
98
- return false;
84
+ const { paths, dirs } = this.#reservations.get(fn);
85
+ for (const p of paths) {
86
+ if (p.queue[0] !== fn)
87
+ return;
88
+ }
89
+ for (const { queue } of dirs) {
90
+ const first = queue[0];
91
+ if (!(first instanceof Set) || !first.has(fn))
92
+ return;
99
93
  }
100
94
  this.#running.add(fn);
101
- fn(() => this.#clear(fn));
102
- return true;
95
+ fn();
103
96
  }
104
97
  #clear(fn) {
105
- if (!this.#running.has(fn)) {
106
- return false;
107
- }
108
- const res = this.#reservations.get(fn);
109
- /* c8 ignore start */
110
- if (!res) {
111
- throw new Error('invalid reservation');
112
- }
113
- /* c8 ignore stop */
114
- const { paths, dirs } = res;
98
+ const { paths, dirs } = this.#reservations.get(fn);
115
99
  const next = new Set();
116
- for (const path of paths) {
117
- const q = this.#queues.get(path);
118
- /* c8 ignore start */
119
- if (!q || q?.[0] !== fn) {
120
- continue;
121
- }
122
- /* c8 ignore stop */
123
- const q0 = q[1];
124
- if (!q0) {
125
- this.#queues.delete(path);
126
- continue;
127
- }
128
- q.shift();
129
- if (typeof q0 === 'function') {
130
- next.add(q0);
131
- }
132
- else {
133
- for (const f of q0) {
100
+ for (const { queue } of paths) {
101
+ // A running task is first in the queue of each of its paths.
102
+ queue.shift();
103
+ const after = queue[0];
104
+ if (typeof after === 'function')
105
+ next.add(after);
106
+ else if (after)
107
+ for (const f of after)
134
108
  next.add(f);
135
- }
136
- }
137
109
  }
138
- for (const dir of dirs) {
139
- const q = this.#queues.get(dir);
140
- const q0 = q?.[0];
141
- /* c8 ignore next - type safety only */
142
- if (!q || !(q0 instanceof Set))
143
- continue;
144
- if (q0.size === 1 && q.length === 1) {
145
- this.#queues.delete(dir);
146
- continue;
147
- }
148
- else if (q0.size === 1) {
149
- q.shift();
150
- // next one must be a function,
151
- // or else the Set would've been reused
152
- const n = q[0];
153
- if (typeof n === 'function') {
154
- next.add(n);
155
- }
156
- }
110
+ for (const { queue } of dirs) {
111
+ // A running task is in the first set of each of its directories.
112
+ const first = queue[0];
113
+ if (first.size > 1)
114
+ first.delete(fn);
157
115
  else {
158
- q0.delete(fn);
116
+ queue.shift();
117
+ // Two sets in a row would be one set, so this is a function.
118
+ if (queue.length)
119
+ next.add(queue[0]);
120
+ }
121
+ }
122
+ // Remove each node that no task uses. Each directory of the task
123
+ // is above one of its paths.
124
+ for (let node of paths) {
125
+ while (node.up && !node.queue.length && !node.kids?.size) {
126
+ node.up.kids?.delete(node.name);
127
+ node = node.up;
159
128
  }
160
129
  }
161
130
  this.#running.delete(fn);
162
- next.forEach(fn => this.#run(fn));
163
- return true;
131
+ this.#reservations.delete(fn);
132
+ for (const f of next)
133
+ this.#run(f);
164
134
  }
165
135
  }
166
136
  //# sourceMappingURL=path-reservations.js.map
@@ -0,0 +1,19 @@
1
+ /** Resolve `.` and `..` parts, and remove repeated slashes. */
2
+ export declare const normalize: (path: string) => string;
3
+ /** Join the parts with a slash, then normalize the result. */
4
+ export declare const join: (...parts: string[]) => string;
5
+ /** The path without its last part. */
6
+ export declare const dirname: (path: string) => string;
7
+ /** The last part of the path. */
8
+ export declare const basename: (path: string) => string;
9
+ /** True if the path starts with a slash. */
10
+ export declare const isAbsolute: (path: string) => boolean;
11
+ /**
12
+ * Resolve the parts from right to left, up to the first absolute
13
+ * part. There is no working directory here: if no part is absolute,
14
+ * the result is a relative path.
15
+ */
16
+ export declare const resolve: (...parts: string[]) => string;
17
+ /** The relative path from `from` to `to`. */
18
+ export declare const relative: (from: string, to: string) => string;
19
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1,80 @@
1
+ // The POSIX path functions that tar paths need. Each one gives the
2
+ // same result as the function of the same name in `path.posix`.
3
+ /** Resolve `.` and `..` parts, and remove repeated slashes. */
4
+ export const normalize = (path) => {
5
+ const absolute = path.charCodeAt(0) === 47;
6
+ const out = [];
7
+ for (const part of path.split('/')) {
8
+ if (part === '' || part === '.')
9
+ continue;
10
+ if (part !== '..')
11
+ out.push(part);
12
+ else if (out.length && out[out.length - 1] !== '..')
13
+ out.pop();
14
+ else if (!absolute)
15
+ out.push(part);
16
+ }
17
+ const trail = out.length && path.charCodeAt(path.length - 1) === 47;
18
+ const res = out.join('/') + (trail ? '/' : '');
19
+ if (absolute)
20
+ return '/' + res;
21
+ return res || (path.endsWith('/') ? './' : '.');
22
+ };
23
+ /** Join the parts with a slash, then normalize the result. */
24
+ export const join = (...parts) => normalize(parts.filter(p => p).join('/'));
25
+ /** The path without its last part. */
26
+ export const dirname = (path) => {
27
+ let end = path.length;
28
+ while (end > 1 && path.charCodeAt(end - 1) === 47)
29
+ end--;
30
+ const slash = path.lastIndexOf('/', end - 1);
31
+ if (slash === -1)
32
+ return '.';
33
+ if (slash === 0)
34
+ return '/';
35
+ if (slash === 1 && path.charCodeAt(0) === 47)
36
+ return '//';
37
+ return path.slice(0, slash);
38
+ };
39
+ /** The last part of the path. */
40
+ export const basename = (path) => {
41
+ let end = path.length;
42
+ while (end > 0 && path.charCodeAt(end - 1) === 47)
43
+ end--;
44
+ return path.slice(path.lastIndexOf('/', end - 1) + 1, end);
45
+ };
46
+ /** True if the path starts with a slash. */
47
+ export const isAbsolute = (path) => path.charCodeAt(0) === 47;
48
+ /**
49
+ * Resolve the parts from right to left, up to the first absolute
50
+ * part. There is no working directory here: if no part is absolute,
51
+ * the result is a relative path.
52
+ */
53
+ export const resolve = (...parts) => {
54
+ let path = '';
55
+ for (let i = parts.length - 1; i >= 0 && !isAbsolute(path); i--) {
56
+ const part = parts[i];
57
+ if (part)
58
+ path = path ? part + '/' + path : part;
59
+ }
60
+ const res = normalize(path);
61
+ return res.length > 1 && res.endsWith('/') ? res.slice(0, -1) : res;
62
+ };
63
+ /** The relative path from `from` to `to`. */
64
+ export const relative = (from, to) => {
65
+ const f = resolve(from).split('/');
66
+ const t = resolve(to).split('/');
67
+ // The root gives an empty last part.
68
+ if (!f[f.length - 1])
69
+ f.pop();
70
+ if (!t[t.length - 1])
71
+ t.pop();
72
+ let same = 0;
73
+ while (same < f.length && same < t.length && f[same] === t[same])
74
+ same++;
75
+ return [
76
+ ...Array.from({ length: f.length - same }, () => '..'),
77
+ ...t.slice(same),
78
+ ].join('/');
79
+ };
80
+ //# sourceMappingURL=path.js.map
@@ -18,9 +18,11 @@ export declare class Pax implements HeaderData {
18
18
  mode?: number;
19
19
  global: boolean;
20
20
  constructor(obj: HeaderData, global?: boolean);
21
- encode(): Buffer<ArrayBuffer>;
21
+ encode(): Uint8Array<ArrayBuffer>;
22
22
  encodeBody(): string;
23
23
  encodeField(field: keyof Pax): string;
24
24
  static parse(str: string, ex?: HeaderData, g?: boolean): Pax;
25
+ /** Parse the body of a PAX header entry. */
26
+ static parseBytes(buf: Uint8Array, ex?: HeaderData, g?: boolean): Pax;
25
27
  }
26
28
  //# sourceMappingURL=pax.d.ts.map
@@ -1,5 +1,7 @@
1
- import { basename } from 'node:path';
2
1
  import { Header } from './header.js';
2
+ import { decodeUtf8, encodeUtf8Into, utf8Length } from './bytes.js';
3
+ import { basename } from './path.js';
4
+ const SIMPLE_NUMBER = /^\d+$/;
3
5
  export class Pax {
4
6
  atime;
5
7
  mtime;
@@ -39,24 +41,18 @@ export class Pax {
39
41
  encode() {
40
42
  const body = this.encodeBody();
41
43
  if (body === '') {
42
- return Buffer.allocUnsafe(0);
44
+ return new Uint8Array(0);
43
45
  }
44
- const bodyLen = Buffer.byteLength(body);
46
+ const bodyLen = utf8Length(body);
45
47
  // round up to 512 bytes
46
48
  // add 512 for header
47
49
  const bufLen = 512 * Math.ceil(1 + bodyLen / 512);
48
- const buf = Buffer.allocUnsafe(bufLen);
49
- // 0-fill the header section, it might not hit every field
50
- for (let i = 0; i < 512; i++) {
51
- buf[i] = 0;
52
- }
50
+ const buf = new Uint8Array(bufLen);
53
51
  new Header({
54
52
  // XXX split the path
55
53
  // then the path should be PaxHeader + basename, but less than 99,
56
54
  // prepend with the dirname
57
- /* c8 ignore start */
58
55
  path: ('PaxHeader/' + basename(this.path ?? '')).slice(0, 99),
59
- /* c8 ignore stop */
60
56
  mode: this.mode || 0o644,
61
57
  uid: this.uid,
62
58
  gid: this.gid,
@@ -71,11 +67,7 @@ export class Pax {
71
67
  atime: this.atime,
72
68
  ctime: this.ctime,
73
69
  }).encode(buf);
74
- buf.write(body, 512, bodyLen, 'utf8');
75
- // null pad after the body
76
- for (let i = bodyLen + 512; i < buf.length; i++) {
77
- buf[i] = 0;
78
- }
70
+ encodeUtf8Into(body, buf, 512, bodyLen);
79
71
  return buf;
80
72
  }
81
73
  encodeBody() {
@@ -100,7 +92,7 @@ export class Pax {
100
92
  return '';
101
93
  }
102
94
  const r = this[field];
103
- const v = r instanceof Date ? r.getTime() / 1000 : r;
95
+ const v = typeof r === 'object' ? r.getTime() / 1000 : r;
104
96
  const s = ' ' +
105
97
  (field === 'dev' || field === 'ino' || field === 'nlink' ?
106
98
  'SCHILY.'
@@ -109,7 +101,7 @@ export class Pax {
109
101
  '=' +
110
102
  v +
111
103
  '\n';
112
- const byteLen = Buffer.byteLength(s);
104
+ const byteLen = utf8Length(s);
113
105
  // the digits includes the length of the digits in ascii base-10
114
106
  // so if it's 9 characters, then adding 1 for the 9 makes it 10
115
107
  // which makes it 11 chars.
@@ -121,29 +113,56 @@ export class Pax {
121
113
  return len + s;
122
114
  }
123
115
  static parse(str, ex, g = false) {
124
- return new Pax(merge(parseKV(str), ex), g);
116
+ return Pax.parseBytes(new TextEncoder().encode(str), ex, g);
117
+ }
118
+ /** Parse the body of a PAX header entry. */
119
+ static parseBytes(buf, ex, g = false) {
120
+ return new Pax(merge(parseKV(buf), ex), g);
125
121
  }
126
122
  }
127
123
  const merge = (a, b) => b ? Object.assign({}, b, a) : a;
128
- const parseKV = (str) => str
129
- .replace(/\n$/, '')
130
- .split('\n')
131
- .reduce(parseKVLine, Object.create(null));
132
- const parseKVLine = (set, line) => {
133
- const n = parseInt(line, 10);
134
- // XXX Values with \n in them will fail this.
135
- // Refactor to not be a naive line-by-line parse.
136
- if (n !== Buffer.byteLength(line) + 1) {
137
- return set;
124
+ // Each record is "<len> <key>=<value>\n". <len> is the byte length of
125
+ // the whole record. A value can contain a newline, so use the length
126
+ // to find the end of the record. A NUL where a record starts is the
127
+ // end of the records, as it is for GNU tar and Python. A record that
128
+ // is not valid is an error, because the records after it can set the
129
+ // size or the name of the entry.
130
+ const parseKV = (buf) => {
131
+ const set = Object.create(null);
132
+ let pos = 0;
133
+ while (pos < buf.length && buf[pos] !== 0) {
134
+ let sp = pos;
135
+ while (sp < buf.length &&
136
+ buf[sp] >= 0x30 &&
137
+ buf[sp] <= 0x39) {
138
+ sp++;
139
+ }
140
+ const end = pos + Number(decodeUtf8(buf, pos, sp));
141
+ if (sp === pos ||
142
+ buf[sp] !== 0x20 ||
143
+ end <= sp + 1 ||
144
+ end > buf.length ||
145
+ buf[end - 1] !== 0x0a) {
146
+ throw new Error('invalid PAX record');
147
+ }
148
+ parseKVLine(set, decodeUtf8(buf, sp + 1, end - 1));
149
+ pos = end;
138
150
  }
139
- line = line.slice((n + ' ').length);
151
+ return set;
152
+ };
153
+ const parseKVLine = (set, line) => {
140
154
  const kv = line.split('=');
155
+ if (kv.length === 1)
156
+ throw new Error('invalid PAX record');
141
157
  const r = kv.shift();
142
158
  if (!r) {
143
159
  return set;
144
160
  }
145
161
  const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, '$1');
146
- const v = kv.join('=').replace(/\0.*/, '');
162
+ // The value ends at the first NUL.
163
+ const joined = kv.join('=');
164
+ const nul = joined.indexOf('\0');
165
+ const v = nul === -1 ? joined : joined.slice(0, nul);
147
166
  switch (k) {
148
167
  case 'path':
149
168
  case 'linkpath':
@@ -157,12 +176,18 @@ const parseKVLine = (set, line) => {
157
176
  case 'ctime':
158
177
  case 'atime':
159
178
  case 'mtime':
160
- set[k] = new Date(Number(v) * 1000);
179
+ const d = new Date(Number(v) * 1000);
180
+ if (!isNaN(d.getTime()))
181
+ set[k] = d;
161
182
  break;
162
183
  case 'size':
163
- const s = +v;
164
- if (s >= 0)
165
- set[k] = s;
184
+ // The size sets where the next header is. Other tar programs
185
+ // read a value that is not only decimal digits in different
186
+ // ways, so it is an error.
187
+ if (!SIMPLE_NUMBER.test(joined) || !Number.isSafeInteger(+joined)) {
188
+ throw new Error('invalid PAX size');
189
+ }
190
+ set[k] = +joined;
166
191
  break;
167
192
  case 'gid':
168
193
  case 'uid':
@@ -170,7 +195,13 @@ const parseKVLine = (set, line) => {
170
195
  case 'ino':
171
196
  case 'nlink':
172
197
  case 'mode':
173
- set[k] = +v;
198
+ // value must be a string of decimal digits
199
+ if (!SIMPLE_NUMBER.test(v.trim()))
200
+ break;
201
+ const s = +v;
202
+ if (!Number.isSafeInteger(s))
203
+ break;
204
+ set[k] = s;
174
205
  break;
175
206
  }
176
207
  return set;