@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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/commander-usage.js +10 -10
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/extension-command-help.js +6 -6
- package/dist/cli/help-json-payload.js +7 -7
- package/dist/cli/main.js +5 -5
- package/dist/cli/register-list-query.js +10 -10
- package/dist/cli/register-mutation.js +3 -3
- package/dist/cli/runtime/invocation-command-path.js +2 -0
- package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-DCWGM7CY.js → chunk-3HKPVOAN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Z7YL2SUM.js → chunk-3KEMIPKG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TX74QJ4W.js → chunk-4YYFY33T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-47ZS6RPL.js → chunk-7NAO7I75.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-IGEFPHV7.js → chunk-7V65VACG.js} +52 -52
- package/dist/cli-bundle/chunks/chunk-A5ZEMOVR.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-5PNOVDVO.js → chunk-AHV3CSQG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KCVSSONY.js → chunk-C6WM6ZN4.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-CBUC4X7Q.js +127 -0
- package/dist/cli-bundle/chunks/{chunk-CCKM5YQM.js → chunk-G6TARHFK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TY55UX6M.js → chunk-GOEQXVOI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-I4SPJQQI.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-Q4VZSMUL.js → chunk-L2ZSSMYY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NHBG5ET3.js → chunk-MZZ4ZJ5Z.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NRQCBUYD.js +113 -0
- package/dist/cli-bundle/chunks/{chunk-YVTALIN3.js → chunk-OBPO6V7H.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KXTKLDKD.js → chunk-OXC5KBIQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HXQ3OHQR.js → chunk-PCDTWL6V.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AOTI76Q6.js → chunk-Q6K7HWZ7.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-QDV7S2QS.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-NZSXWIX7.js → chunk-ROTEELDL.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-WFYE34TO.js → chunk-SDXCJZKB.js} +23 -23
- package/dist/cli-bundle/chunks/{chunk-2SBTXR6C.js → chunk-SY5C3U32.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FR7ULTM4.js → chunk-TKUG2X24.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FECZV72T.js → chunk-UNBW2LF3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-V2S4XAX3.js +2 -0
- package/dist/cli-bundle/chunks/chunk-WSEIEDEK.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZA5NS3PL.js → chunk-ZL6J6JYT.js} +6 -6
- package/dist/cli-bundle/chunks/{field-option-collisions-2F2Z7R7B.js → field-option-collisions-BBGTV7AD.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-3LENTXYF.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-56J5OCHA.js +2 -0
- package/dist/cli-bundle/chunks/{linked-resource-value-list-WXPPYUVQ.js → linked-resource-value-list-ZBIY4H23.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-actor-UK3QNEEB.js → mutation-actor-NHN33ITJ.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-UTDYPFWP.js → mutation-admission-PGKJTCG6.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-DRA3CWHI.js → register-list-query-7S5QWDTI.js} +11 -11
- package/dist/cli-bundle/chunks/{register-mutation-WO74VLEQ.js → register-mutation-EK6DVIQK.js} +5 -5
- package/dist/cli-bundle/chunks/{register-operations-CRBKH7WN.js → register-operations-6MURXE4V.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-6V6NQB5C.js → register-setup-RW26X3GJ.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-DYEHGASU.js → stage-4ZCF74G4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RQYVX2T6.js → chunk-2DGKVXFT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-2UWKU2BQ.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-A3DORTXS.js → chunk-3COWDIPX.js} +54 -54
- package/dist/cli-bundle/focused-chunks/{chunk-UQJ4PY2Y.js → chunk-4SCFAWAW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7G7JIXLL.js → chunk-6BKT6XQN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-6IY5CVGJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-7A6SEZEY.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IJ3T3W4U.js → chunk-BHNBPCHP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LWBZ7UGG.js → chunk-EQCQTYKO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FM5WQ6ZU.js → chunk-HTDYNY4L.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TQQO42C2.js → chunk-J72TRWR5.js} +26 -26
- package/dist/cli-bundle/focused-chunks/{chunk-L357ZAES.js → chunk-JPZGC3W4.js} +5 -5
- package/dist/cli-bundle/focused-chunks/{chunk-62AMZMR4.js → chunk-KNBGHCIP.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-N64AC5G6.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IIVDBAJM.js → chunk-OG57ESZK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MZNV26XE.js → chunk-P2H3GTJK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QZRYGYTI.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-SQMOF65W.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-T3ILWAEV.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-SXC3NVZI.js → chunk-TR22GU7M.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-M57KDG7I.js → chunk-TXTPAFHJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-VK3IE3TS.js +29 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NJTKGBSK.js → chunk-VQIC3UZB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-U35K7FSE.js → chunk-W4JMV7GF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-7TG7STO7.js → field-option-collisions-2C6DLUC4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-723XCQPS.js +2 -0
- package/dist/cli-bundle/focused-chunks/{item-transaction-2IC2MLML.js → item-transaction-LQLQLZE7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-LJVF2HVD.js → mutation-actor-DJMZUIZI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-SDWQVVHN.js +2 -0
- package/dist/cli-bundle/focused-chunks/{stage-MWR73LTZ.js → stage-QBZIK3T5.js} +2 -2
- package/dist/cli-bundle/main.js +27 -27
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +61 -61
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +2 -2
- package/dist/core/extensions/reserved-host-flags.js +1 -1
- package/dist/core/shared/secret-rules.d.ts +86 -12
- package/dist/core/shared/secret-rules.js +7 -5
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +50 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension/install-sources.d.ts +2 -2
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/lifecycle/expect-hash-admission.d.ts +15 -0
- package/dist/sdk/lifecycle/expect-hash-admission.js +2 -0
- package/dist/sdk/lifecycle/item-revision.d.ts +4 -1
- package/dist/sdk/lifecycle/item-revision.js +1 -1
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/output-contracts.js +1 -1
- package/dist/sdk/output-projection.d.ts +1 -1
- package/dist/sdk/output-projection.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/aggregate.js +1 -1
- package/dist/sdk/query/context.js +1 -1
- package/dist/sdk/query/list.js +1 -1
- package/dist/sdk/query/next.js +1 -1
- package/dist/sdk/query/search-contracts.js +1 -1
- package/dist/sdk/read-output/surfaces.js +1 -1
- package/dist/sdk/read-output-budget.d.ts +1 -1
- package/dist/sdk/read-output-budget.js +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/read-output-rows.js +1 -1
- package/docs/COMMANDS.md +37 -0
- package/docs/MUTATION_INTEGRITY.md +226 -10
- package/docs/SDK.md +16 -6
- package/docs/agent-task-token-baseline.json +1 -1
- package/marketplace.json +1 -1
- package/node_modules/tar/README.md +1792 -1147
- package/node_modules/tar/dist/commonjs/bytes.d.ts +21 -0
- package/node_modules/tar/dist/commonjs/bytes.js +83 -0
- package/node_modules/tar/dist/commonjs/codec.d.ts +53 -0
- package/node_modules/tar/dist/commonjs/codec.js +35 -0
- package/node_modules/tar/dist/commonjs/concat.d.ts +3 -0
- package/node_modules/tar/dist/commonjs/concat.js +20 -0
- package/node_modules/tar/dist/commonjs/create.d.ts +39 -2
- package/node_modules/tar/dist/commonjs/create.js +150 -64
- package/node_modules/tar/dist/commonjs/dealias.d.ts +79 -0
- package/node_modules/tar/dist/commonjs/dealias.js +50 -0
- package/node_modules/tar/dist/commonjs/delete.d.ts +19 -0
- package/node_modules/tar/dist/commonjs/delete.js +121 -0
- package/node_modules/tar/dist/commonjs/entries.d.ts +82 -0
- package/node_modules/tar/dist/commonjs/entries.js +398 -0
- package/node_modules/tar/dist/commonjs/extract.d.ts +14 -2
- package/node_modules/tar/dist/commonjs/extract.js +40 -81
- package/node_modules/tar/dist/commonjs/fs.d.ts +201 -0
- package/node_modules/tar/dist/commonjs/fs.js +5 -0
- package/node_modules/tar/dist/commonjs/header.d.ts +4 -4
- package/node_modules/tar/dist/commonjs/header.js +71 -53
- package/node_modules/tar/dist/commonjs/index.d.ts +25 -18
- package/node_modules/tar/dist/commonjs/index.js +46 -18
- package/node_modules/tar/dist/commonjs/index.min.js +2 -3
- package/node_modules/tar/dist/commonjs/large-numbers.d.ts +2 -2
- package/node_modules/tar/dist/commonjs/large-numbers.js +4 -4
- package/node_modules/tar/dist/commonjs/list.d.ts +23 -6
- package/node_modules/tar/dist/commonjs/list.js +99 -138
- package/node_modules/tar/dist/commonjs/mkdir.d.ts +16 -11
- package/node_modules/tar/dist/commonjs/mkdir.js +121 -159
- package/node_modules/tar/dist/commonjs/normalize-unicode.js +9 -0
- package/node_modules/tar/dist/commonjs/options.d.ts +284 -513
- package/node_modules/tar/dist/commonjs/options.js +20 -61
- package/node_modules/tar/dist/commonjs/pack.d.ts +150 -96
- package/node_modules/tar/dist/commonjs/pack.js +752 -445
- package/node_modules/tar/dist/commonjs/parser.d.ts +98 -0
- package/node_modules/tar/dist/commonjs/parser.js +452 -0
- package/node_modules/tar/dist/commonjs/path-reservations.d.ts +17 -7
- package/node_modules/tar/dist/commonjs/path-reservations.js +110 -140
- package/node_modules/tar/dist/commonjs/path.d.ts +19 -0
- package/node_modules/tar/dist/commonjs/path.js +90 -0
- package/node_modules/tar/dist/commonjs/pax.d.ts +3 -1
- package/node_modules/tar/dist/commonjs/pax.js +67 -36
- package/node_modules/tar/dist/commonjs/read-entry.d.ts +97 -11
- package/node_modules/tar/dist/commonjs/read-entry.js +251 -97
- package/node_modules/tar/dist/commonjs/read-file.d.ts +22 -0
- package/node_modules/tar/dist/commonjs/read-file.js +104 -0
- package/node_modules/tar/dist/commonjs/replace.d.ts +45 -1
- package/node_modules/tar/dist/commonjs/replace.js +164 -211
- package/node_modules/tar/dist/commonjs/server/codecs.d.ts +38 -0
- package/node_modules/tar/dist/commonjs/server/codecs.js +252 -0
- package/node_modules/tar/dist/commonjs/server/index.d.ts +115 -0
- package/node_modules/tar/dist/commonjs/server/index.js +166 -0
- package/node_modules/tar/dist/commonjs/server/index.min.js +3 -0
- package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +8 -0
- package/node_modules/tar/dist/commonjs/strip-absolute-path.js +17 -20
- package/node_modules/tar/dist/commonjs/to-stream.d.ts +7 -0
- package/node_modules/tar/dist/commonjs/to-stream.js +22 -0
- package/node_modules/tar/dist/commonjs/types.d.ts +4 -3
- package/node_modules/tar/dist/commonjs/types.js +4 -3
- package/node_modules/tar/dist/commonjs/unpack.d.ts +143 -89
- package/node_modules/tar/dist/commonjs/unpack.js +780 -725
- package/node_modules/tar/dist/commonjs/update.d.ts +11 -1
- package/node_modules/tar/dist/commonjs/update.js +37 -28
- package/node_modules/tar/dist/commonjs/warn.d.ts +27 -0
- package/node_modules/tar/dist/commonjs/warn.js +36 -0
- package/node_modules/tar/dist/commonjs/win32-path.d.ts +16 -0
- package/node_modules/tar/dist/commonjs/win32-path.js +67 -0
- package/node_modules/tar/dist/commonjs/write-entry.d.ts +64 -111
- package/node_modules/tar/dist/commonjs/write-entry.js +108 -672
- package/node_modules/tar/dist/commonjs/write-flag.d.ts +18 -0
- package/node_modules/tar/dist/commonjs/write-flag.js +29 -0
- package/node_modules/tar/dist/esm/bytes.d.ts +21 -0
- package/node_modules/tar/dist/esm/bytes.js +72 -0
- package/node_modules/tar/dist/esm/codec.d.ts +53 -0
- package/node_modules/tar/dist/esm/codec.js +32 -0
- package/node_modules/tar/dist/esm/concat.d.ts +3 -0
- package/node_modules/tar/dist/esm/concat.js +16 -0
- package/node_modules/tar/dist/esm/create.d.ts +39 -2
- package/node_modules/tar/dist/esm/create.js +144 -61
- package/node_modules/tar/dist/esm/dealias.d.ts +79 -0
- package/node_modules/tar/dist/esm/dealias.js +46 -0
- package/node_modules/tar/dist/esm/delete.d.ts +19 -0
- package/node_modules/tar/dist/esm/delete.js +117 -0
- package/node_modules/tar/dist/esm/entries.d.ts +82 -0
- package/node_modules/tar/dist/esm/entries.js +388 -0
- package/node_modules/tar/dist/esm/extract.d.ts +14 -2
- package/node_modules/tar/dist/esm/extract.js +37 -44
- package/node_modules/tar/dist/esm/fs.d.ts +201 -0
- package/node_modules/tar/dist/esm/fs.js +4 -0
- package/node_modules/tar/dist/esm/header.d.ts +4 -4
- package/node_modules/tar/dist/esm/header.js +71 -53
- package/node_modules/tar/dist/esm/index.d.ts +25 -18
- package/node_modules/tar/dist/esm/index.js +23 -18
- package/node_modules/tar/dist/esm/index.min.js +2 -3
- package/node_modules/tar/dist/esm/large-numbers.d.ts +2 -2
- package/node_modules/tar/dist/esm/large-numbers.js +4 -4
- package/node_modules/tar/dist/esm/list.d.ts +23 -6
- package/node_modules/tar/dist/esm/list.js +96 -101
- package/node_modules/tar/dist/esm/mkdir.d.ts +16 -11
- package/node_modules/tar/dist/esm/mkdir.js +119 -154
- package/node_modules/tar/dist/esm/normalize-unicode.js +9 -0
- package/node_modules/tar/dist/esm/options.d.ts +284 -513
- package/node_modules/tar/dist/esm/options.js +17 -51
- package/node_modules/tar/dist/esm/pack.d.ts +150 -96
- package/node_modules/tar/dist/esm/pack.js +750 -441
- package/node_modules/tar/dist/esm/parser.d.ts +98 -0
- package/node_modules/tar/dist/esm/parser.js +448 -0
- package/node_modules/tar/dist/esm/path-reservations.d.ts +17 -7
- package/node_modules/tar/dist/esm/path-reservations.js +110 -140
- package/node_modules/tar/dist/esm/path.d.ts +19 -0
- package/node_modules/tar/dist/esm/path.js +80 -0
- package/node_modules/tar/dist/esm/pax.d.ts +3 -1
- package/node_modules/tar/dist/esm/pax.js +66 -35
- package/node_modules/tar/dist/esm/read-entry.d.ts +97 -11
- package/node_modules/tar/dist/esm/read-entry.js +248 -96
- package/node_modules/tar/dist/esm/read-file.d.ts +22 -0
- package/node_modules/tar/dist/esm/read-file.js +99 -0
- package/node_modules/tar/dist/esm/replace.d.ts +45 -1
- package/node_modules/tar/dist/esm/replace.js +160 -207
- package/node_modules/tar/dist/esm/server/codecs.d.ts +38 -0
- package/node_modules/tar/dist/esm/server/codecs.js +214 -0
- package/node_modules/tar/dist/esm/server/index.d.ts +115 -0
- package/node_modules/tar/dist/esm/server/index.js +102 -0
- package/node_modules/tar/dist/esm/server/index.min.js +3 -0
- package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +8 -0
- package/node_modules/tar/dist/esm/strip-absolute-path.js +17 -20
- package/node_modules/tar/dist/esm/to-stream.d.ts +7 -0
- package/node_modules/tar/dist/esm/to-stream.js +18 -0
- package/node_modules/tar/dist/esm/types.d.ts +4 -3
- package/node_modules/tar/dist/esm/types.js +4 -3
- package/node_modules/tar/dist/esm/unpack.d.ts +143 -89
- package/node_modules/tar/dist/esm/unpack.js +776 -719
- package/node_modules/tar/dist/esm/update.d.ts +11 -1
- package/node_modules/tar/dist/esm/update.js +35 -28
- package/node_modules/tar/dist/esm/warn.d.ts +27 -0
- package/node_modules/tar/dist/esm/warn.js +31 -0
- package/node_modules/tar/dist/esm/win32-path.d.ts +16 -0
- package/node_modules/tar/dist/esm/win32-path.js +60 -0
- package/node_modules/tar/dist/esm/write-entry.d.ts +64 -111
- package/node_modules/tar/dist/esm/write-entry.js +107 -633
- package/node_modules/tar/dist/esm/write-flag.d.ts +18 -0
- package/node_modules/tar/dist/esm/write-flag.js +25 -0
- package/node_modules/tar/package.json +68 -224
- package/package.json +2 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3TXEWHQX.js +0 -125
- package/dist/cli-bundle/chunks/chunk-JPJNJHQW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NVYDPNQP.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SJWIPGZW.js +0 -113
- package/dist/cli-bundle/chunks/chunk-USBTXMKS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-VCXQ6A35.js +0 -3
- package/dist/cli-bundle/chunks/chunk-YPMNXG2C.js +0 -2
- package/dist/cli-bundle/chunks/item-revision-UAF6L47R.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-RJECL53Y.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2UUBS4BG.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4ER3VMST.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4YBMHMBJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HXM7K6VH.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-NGHT2LNG.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-P55AZPFN.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-WAP3DF4B.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-XR745UGE.js +0 -4
- package/dist/cli-bundle/focused-chunks/item-revision-J7EUGCHR.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-SLFAUONA.js +0 -2
- package/node_modules/@isaacs/fs-minipass/LICENSE +0 -15
- package/node_modules/@isaacs/fs-minipass/README.md +0 -71
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +0 -118
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +0 -430
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +0 -3
- package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +0 -118
- package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +0 -420
- package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +0 -3
- package/node_modules/@isaacs/fs-minipass/package.json +0 -72
- package/node_modules/chownr/LICENSE.md +0 -63
- package/node_modules/chownr/README.md +0 -3
- package/node_modules/chownr/dist/commonjs/index.d.ts +0 -3
- package/node_modules/chownr/dist/commonjs/index.js +0 -93
- package/node_modules/chownr/dist/commonjs/package.json +0 -3
- package/node_modules/chownr/dist/esm/index.d.ts +0 -3
- package/node_modules/chownr/dist/esm/index.js +0 -85
- package/node_modules/chownr/dist/esm/package.json +0 -3
- package/node_modules/chownr/package.json +0 -69
- package/node_modules/minipass/LICENSE.md +0 -55
- package/node_modules/minipass/README.md +0 -825
- package/node_modules/minipass/dist/commonjs/index.d.ts +0 -545
- package/node_modules/minipass/dist/commonjs/index.js +0 -1038
- package/node_modules/minipass/dist/commonjs/package.json +0 -3
- package/node_modules/minipass/dist/esm/index.d.ts +0 -545
- package/node_modules/minipass/dist/esm/index.js +0 -1020
- package/node_modules/minipass/dist/esm/package.json +0 -3
- package/node_modules/minipass/package.json +0 -77
- package/node_modules/minizlib/LICENSE +0 -26
- package/node_modules/minizlib/README.md +0 -64
- package/node_modules/minizlib/dist/commonjs/constants.d.ts +0 -2
- package/node_modules/minizlib/dist/commonjs/constants.js +0 -123
- package/node_modules/minizlib/dist/commonjs/index.d.ts +0 -99
- package/node_modules/minizlib/dist/commonjs/index.js +0 -416
- package/node_modules/minizlib/dist/commonjs/package.json +0 -3
- package/node_modules/minizlib/dist/esm/constants.d.ts +0 -2
- package/node_modules/minizlib/dist/esm/constants.js +0 -117
- package/node_modules/minizlib/dist/esm/index.d.ts +0 -99
- package/node_modules/minizlib/dist/esm/index.js +0 -363
- package/node_modules/minizlib/dist/esm/package.json +0 -3
- package/node_modules/minizlib/package.json +0 -80
- package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/get-write-flag.js +0 -32
- package/node_modules/tar/dist/commonjs/make-command.d.ts +0 -49
- package/node_modules/tar/dist/commonjs/make-command.js +0 -52
- package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/normalize-windows-path.js +0 -12
- package/node_modules/tar/dist/commonjs/parse.d.ts +0 -92
- package/node_modules/tar/dist/commonjs/parse.js +0 -655
- package/node_modules/tar/dist/commonjs/process-umask.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/process-umask.js +0 -7
- package/node_modules/tar/dist/commonjs/warn-method.d.ts +0 -24
- package/node_modules/tar/dist/commonjs/warn-method.js +0 -31
- package/node_modules/tar/dist/esm/get-write-flag.d.ts +0 -2
- package/node_modules/tar/dist/esm/get-write-flag.js +0 -26
- package/node_modules/tar/dist/esm/make-command.d.ts +0 -49
- package/node_modules/tar/dist/esm/make-command.js +0 -48
- package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +0 -2
- package/node_modules/tar/dist/esm/normalize-windows-path.js +0 -9
- package/node_modules/tar/dist/esm/parse.d.ts +0 -92
- package/node_modules/tar/dist/esm/parse.js +0 -651
- package/node_modules/tar/dist/esm/process-umask.d.ts +0 -2
- package/node_modules/tar/dist/esm/process-umask.js +0 -3
- package/node_modules/tar/dist/esm/warn-method.d.ts +0 -24
- package/node_modules/tar/dist/esm/warn-method.js +0 -27
- package/node_modules/yallist/LICENSE.md +0 -63
- package/node_modules/yallist/README.md +0 -205
- package/node_modules/yallist/dist/commonjs/index.d.ts +0 -39
- package/node_modules/yallist/dist/commonjs/index.js +0 -384
- package/node_modules/yallist/dist/commonjs/package.json +0 -3
- package/node_modules/yallist/dist/esm/index.d.ts +0 -39
- package/node_modules/yallist/dist/esm/index.js +0 -379
- package/node_modules/yallist/dist/esm/package.json +0 -3
- package/node_modules/yallist/package.json +0 -68
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isDeepStrictEqual as k}from"node:util";import{resolvePmCommandOperation as z}from"../cli-contracts/command-aliases.js";import{describeFlagScalarValueFailure as N,resolveExtensionFlagValueContract as F,resolveExtensionLongFlagName as L,EXIT_CODE as m,PmCliError as y,flattenFlagListValue as B,resolveFlagValueKind as pe}from"../runtime-primitives.js";import{RESERVED_EXTENSION_HOST_FLAG_NAMES as ge}from"../../core/extensions/reserved-host-flags.js";const he=new Set(["__proto__","prototype","constructor"]),x=Symbol("looseOptionOccurrences");function h(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,o)=>o.toUpperCase())}function me(e,n,t){const o=e[n];if(o===void 0){e[n]=t;return}if(Array.isArray(o)){o.push(t),e[n]=o;return}e[n]=[o,t]}function V(e,n){const t=e[n];if(!t.startsWith("-")||t==="-"||t==="--")return null;if(!t.startsWith("--")){const i=t.indexOf("=");if(i>=0)return{consumed:1,key:t.slice(1,i).trim(),value:t.slice(i+1),attached:!0};const l=t.slice(1).trim(),a=e[n+1];return typeof a=="string"&&!a.startsWith("-")?{consumed:2,key:l,value:a}:{consumed:1,key:l,value:!0}}const o=t.indexOf("=");if(o>=0)return{consumed:1,key:t.slice(2,o).trim(),value:t.slice(o+1),attached:!0};if(t.startsWith("--no-"))return{consumed:1,key:t.slice(5).trim(),value:!1};const r=t.slice(2).trim(),s=e[n+1];return typeof s=="string"&&!s.startsWith("-")?{consumed:2,key:r,value:s}:{consumed:1,key:r,value:!0}}function E(e){return he.has(e)}function K(e){const n=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return pe(n)}function S(e){const n=[],t=L(e.long)??"",o=typeof e.short=="string"?e.short.trim():"";if(t.startsWith("--")){const r=h(t.slice(2));r.length>0&&!E(r)&&n.push(r)}if(o.startsWith("-")&&!o.startsWith("--")){const r=h(o.slice(1));r.length>0&&!E(r)&&n.push(r)}return[...new Set(n)]}function He(e){const n=new Set;for(const t of e)for(const o of S(t))n.add(o);return n}function O(e){const n=L(e.long)??"";if(n.startsWith("--")){const t=h(n.slice(2));if(t.length>0&&!E(t))return t}return S(e)[0]??null}function $(e){const n=L(e.long)??"";if(n.startsWith("--")&&n.length>2)return n;const t=typeof e.short=="string"?e.short.trim():"";return t.startsWith("-")&&!t.startsWith("--")&&t.length>1?t:null}function U(e,n){return[...(n.definitions??e).map(o=>$(o)).filter(o=>o!==null),...n.inheritedFlags??[]]}function Je(e,n,t,o={}){if(n.length===0)return;const r=new Set,s=new Map,i=[],l=U(n,o);for(const a of n){const u=S(a),c=$(a);for(const g of u)r.add(g),a.enabled===!1&&s.set(g,c);a.required===!0&&a.enabled!==!1&&u.length>0&&i.push({keys:u,label:c,definition:a})}for(const a of Object.keys(e)){r.has(a)||I(`--${a}`,`--${a}`,t,l);const u=s.get(a);u&&G(u,t)}for(const a of i){const u=c=>Object.hasOwn(e,c)&&(a.definition.list!==!0||q(a.definition,e[c]));a.keys.some(u)||H(a.definition,a.keys[0],a.label,t)}}function I(e,n,t,o){const r=o.length>0?` Expected one of: ${[...new Set(o)].join(", ")}.`:"";throw new y(`Unknown option '${e}' for extension command '${t}'.${r}`,m.USAGE,{code:"unknown_option",flag:n,required:`Use a flag the command accepts; run pm contracts --command ${t} --flags-only --json to list them.`})}function G(e,n){throw new y(`Option '${e}' is disabled for extension command '${n}'.`,m.USAGE,{code:"extension_option_disabled",flag:e,required:`Remove ${e}; the command declares it with enabled: false.`,why:"A disabled declaration keeps the flag in the contract while refusing every value for it.",examples:[`pm ${n} --help`],nextSteps:[`Run pm contracts --command ${n} --flags-only --json to list the flags this command accepts.`]})}function H(e,n,t,o){const r=F(e),s=r.value_arity==="none"?t:r.value_arity==="optional"?`${t} [${r.value_name}]`:`${t} <${r.value_name}>`;throw new y(`Missing required option '${t}' for extension command '${o}'.`,m.USAGE,{code:"missing_required_option",flag:t,field:n,required:`Pass ${s}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${o} ${s}`],nextSteps:[`Run pm contracts --command ${o} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[t]}})}function ye(e){return typeof e=="string"||e==null?e:String(e)}function Oe(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){const n=Number(e);return Number.isFinite(n)?n:e}return e}function J(e){if(typeof e=="boolean")return e;if(typeof e=="string"){const n=e.trim().toLowerCase();if(n==="true"||n==="1")return!0;if(n==="false"||n==="0")return!1}return e}const be={string:ye,number:Oe,boolean:J};function b(e,n){return Array.isArray(e)?e.map(t=>b(t,n)):be[n](e)}function D(e,n,t){const o=t?(Array.isArray(e)?e.flat(1/0):[e]).filter(r=>r!=null&&r!==""):B(e);return n?o.map(r=>b(r,n)):o}function q(e,n){return D(n,null,e.repeatable===!0).length>0}function ve(e,n,t,o){return t?D(e,n,o):n?b(e,n):e}function we(e,n,t){const o=Y(e,n);return o.length===0?t:o.map(r=>r.value)}function X(e){return F(e).value_arity==="none"}function R(e,n,t,o,r){const s=$(e),i=r?` for extension command '${r}'`:"",l=t===!0?"no value":JSON.stringify(t);throw new y(`Option '${s}'${i} expects ${o}; received ${l}.`,m.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} ${n==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${n} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${n} value for ${s}.`,`Run pm ${r??"<command>"} --help to review the declared flag contract.`]})}function W(e,n){return e.value_validation==="strict"&&n!=="string"}function Y(e,n){const t=e[x];if(!t)return[];const o=new Set(n);return t.filter(r=>o.has(r.key))}function Se(e,n,t,o){if(X(e))for(const r of Y(t,n)){if(r.attached!==!0)continue;const s=e.list===!0&&e.repeatable!==!0?B(r.value):[r.value];for(const i of s){const l=N(b(i,"boolean"),"boolean");l!==null&&R(e,"boolean",i,l.expected,o)}}}function $e(e,n,t,o,r){const s=Array.isArray(t)?t.flat(1/0):[t],i=o?s:s.flatMap(l=>typeof l=="string"?l.split(","):[l]);for(const l of i)if(typeof l=="string"&&l.trim().length===0){const a=N(l,n);R(e,n,l,a.expected,r)}}function M(e,n,t,o){if(!W(e,t))return n;const r=t==="boolean"&&X(e),s=i=>{const l=N(i,t);return l===null?i:r&&typeof i=="string"?!0:R(e,t,i,l.expected,o)};return Array.isArray(n)?n.map(s):s(n)}function xe(e,n,t,o){for(const r of t)if(!(r===n||!Object.hasOwn(e,r))){if(Object.hasOwn(e,n)){if(o){const s=e[n],i=e[r];e[n]=[...Array.isArray(s)?s:[s],...Array.isArray(i)?i:[i]].filter(l=>l!=null)}delete e[r];continue}e[n]=e[r],delete e[r]}}function Z(e,n,t=e,o){if(n.length===0)return e;const r=Object.create(null);for(const[i,l]of Object.entries(e))r[i]=l;const s=new Set(n.map(i=>O(i)).filter(i=>i!==null));for(const i of n){const l=O(i);if(l){const a=S(i).filter(u=>u===l||!s.has(u));Ae(r,i,l,a,t,o)}}return r}function Ae(e,n,t,o,r,s){const i=n.list===!0,l=K(n);l&&!i&&_e(e,n,t,o,l,s),xe(e,t,o,i);const a=n.repeatable===!0;if(!Object.hasOwn(e,t)){n.default!==void 0&&(e[t]=ve(n.default,l,i,a));return}if(l==="boolean"&&W(n,l)&&Se(n,o,r,s),i){e[t]=Le(n,o,r,e[t],l,a,s);return}l&&(e[t]=M(n,b(e[t],l),l,s))}function _e(e,n,t,o,r,s){for(const i of o)i!==t&&Object.hasOwn(e,i)&&M(n,b(e[i],r),r,s)}function Le(e,n,t,o,r,s,i){const l=we(t,n,o);r&&W(e,r)&&$e(e,r,l,s,i);const a=D(l,r,s);return r?M(e,a,r,i):a}function Xe(e){const n=Object.create(null),t=[];Object.defineProperty(n,x,{value:t});let o=0;for(;o<e.length;){const r=V(e,o);if(!r){o+=1;continue}const s=h(r.key);if(s.length===0||E(s)){o+=r.consumed;continue}me(n,s,r.value),t.push({...r,key:s}),o+=r.consumed}return n}function Ye(e){const n=[];let t=0;for(;t<e.length;){if(e[t]==="--"){n.push(...e.slice(t+1));break}const o=V(e,t);if(o){t+=Math.max(1,o.consumed);continue}n.push(e[t]),t+=1}return n}function Ze(e,n){if(n.length===0)return[...e];const t=new Set,o=new Set;for(const i of n){const l=K(i);for(const a of S(i))t.add(a),l==="boolean"&&o.add(a)}if(t.size===0)return[...e];const r=[];let s=0;for(;s<e.length;){if(e[s]==="--"){r.push(...e.slice(s+1));break}const i=V(e,s);if(i){const l=h(i.key);if(t.has(l)){const a=e[s],u=o.has(l)&&!a.includes("=")?1:i.consumed;s+=u;continue}}r.push(e[s]),s+=1}return r}function Qe(e){return O(e)}function Q(e){return e.trim().toLowerCase().split(/\s+/u).filter(n=>n.length>0).join(" ")}function Pe(e,n){const t=Q(n);if(t.length===0)return[];const o=z(t);return e.flags.filter(r=>z(Q(r.target_command))===o).flatMap(r=>[...r.flags])}function P(e,n,t,o){const r=$(e),[s,i]=t;throw new y(`Options '${s}' and '${i}' both set ${r} for extension command '${o}' with different values.`,m.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${r} once, under the handler key '${n}'.`,why:`'${s}' and '${i}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${i}' and pass one value as '${n}'.`,`Run pm contracts --command ${o} --flags-only --json to read each flag's sdk_option key.`]})}function en(e,n,t,o={}){if(n.length===0)return e;const r=n.map(c=>c.repeatable===!0&&c.list!==!0?{...c,list:!0}:c),s=re(r),i=Ne(e,s,t),l=new Set([...s.long.values()].map(({handlerKey:c})=>c)),a=Object.create(null),u=Object.create(null);for(const[c,g]of Object.entries(i))l.has(c)?a[c]=g:g===void 0||o.undeclaredKeys==="pass"||Ke(c)?u[c]=g:I(c,Ce(c),t,U(r,{}));return ne(a,r,t),Object.assign(u,Z(a,r,ee(a,s),t))}function ee(e,n){const t=new Set([...n.long.values()].map(({handlerKey:s})=>s)),o=Object.entries(e).filter(([s])=>t.has(s)).flatMap(([s,i])=>(Array.isArray(i)?i.flat(1/0):[i]).map(l=>({consumed:1,key:s,value:l,attached:!0}))),r=Object.create(null);return Object.defineProperty(r,x,{value:o}),r}function ne(e,n,t){for(const o of n){const r=O(o);if(r===null)continue;const s=$(o),i=e[r],l=Object.hasOwn(e,r);o.enabled===!1&&l&&G(s,t);const a=l&&(o.list!==!0||q(o,i));o.required===!0&&o.enabled!==!1&&!a&&H(o,r,s,t),o.list!==!0&&Array.isArray(i)&&Ee(s,t)}}function Ee(e,n){throw new y(`Option '${e}' for extension command '${n}' takes one value; received an array.`,m.USAGE,{code:"extension_flag_value_invalid",flag:e,required:`Pass one value for ${e}, or ask the package to declare it with list: true or repeatable: true.`,why:"The flag is not declared list or repeatable, so pm refuses an array before the extension handler runs instead of handing it a value of the wrong shape.",nextSteps:[`Run pm contracts --command ${n} --flags-only --json to read each flag's value contract.`]})}const te=new Set([...[...ge].flatMap(e=>{const n=e.replace(/^--/u,"");return[n,...n.startsWith("no-")?[n.slice(3)]:[]].flatMap(o=>[h(o),o.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function Ke(e){return te.has(e)||te.has(h(e.replace(/^-{1,2}/u,"")))}function Ce(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function re(e){const n={long:new Map,short:new Map},t=(o,r,s)=>{r.length>0&&!o.has(r)&&o.set(r,s)};for(const o of e){const r=O(o);if(r===null)continue;const s={handlerKey:r,definition:o};t(n.long,r,s);const i=typeof o.short=="string"?o.short.trim():"";i.startsWith("-")&&!i.startsWith("--")&&t(n.short,i.slice(1),s)}return n}function C(e,n){return e.long.get(n)??e.short.get(n.replace(/^-(?!-)/u,""))??e.long.get(h(n.replace(/^-{1,2}/u,"")))}function oe(e,n,t,o){const r=/^(?:--)?no-(.+)$/u.exec(n)?.[1];if(r===void 0||C(e,n)!==void 0)return{spelling:n,value:t};const s=C(e,r);return s===void 0||K(s.definition)!=="boolean"?{spelling:n,value:t}:(s.definition.list===!0||s.definition.repeatable===!0)&&Array.isArray(t)?{spelling:r,value:t.flat(1/0).map(i=>se(n,s.definition,i,o))}:s.definition.list===!0&&t!==void 0?{spelling:r,value:se(n,s.definition,t,o)}:{spelling:r,value:t===void 0?t:j(n,s.definition,t,o)}}function nn(e,n,t){const o=re(e);try{const r=oe(o,n,t,"");if(r.spelling===n)return;const s=C(o,r.spelling);return(s.definition.list===!0||s.definition.repeatable===!0)&&!q(s.definition,r.value)?void 0:{key:s.handlerKey,value:r.value}}catch{return}}function se(e,n,t,o){const r=s=>s.trim().length===0?s:String(j(e,n,s.trim(),o));return t==null?t:typeof t!="string"?j(e,n,t,o):t.trim().length===0?t:n.repeatable===!0||!t.includes(",")?j(e,n,t,o):t.split(",").map(r).join(",")}function j(e,n,t,o){const r=J(t);return typeof r=="boolean"?!r:je(e,n,t,o)}function je(e,n,t,o){const r=$(n);throw new y(`Option '${e}' for extension command '${o}' negates ${r} and expects true, false, 1, or 0; received ${JSON.stringify(t)}.`,m.USAGE,{code:"extension_flag_value_invalid",flag:r,required:`Pass ${r} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${r}, so only a boolean value can be inverted before the extension handler runs.`,nextSteps:[`Run pm contracts --command ${o} --flags-only --json to read each flag's value contract.`]})}function Ne(e,n,t){const o=Object.create(null),r=new Map;for(const[s,i]of Object.entries(e)){const{spelling:l,value:a}=oe(n,s,i,t),u=C(n,l);if(u===void 0)o[l]=a;else if(a!==void 0){const c=r.get(u.handlerKey);c===void 0?(r.set(u.handlerKey,l),o[u.handlerKey]=a):k(ie(u.definition,u.handlerKey,o[u.handlerKey],n,t),ie(u.definition,u.handlerKey,a,n,t))||P(u.definition,u.handlerKey,[c,l],t)}}return o}function ie(e,n,t,o,r){const s={[n]:t};return ne(s,[e],r),Z(s,[e],ee(s,o),r)[n]}function le(e){const n=new Map;for(const t of e){const o=O(t);if(o===null)continue;const r={definition:t,handlerKey:o,kind:K(t),arity:F(t).value_arity,scalar:t.list!==!0},s=[L(t.long),typeof t.short=="string"?t.short.trim():""];for(const i of s.filter(l=>l?.startsWith("-")===!0))n.has(i)||n.set(i,r)}return n}function ae(e,n,t,o=ke){const r=e.optionOf(t),s=n.get(t),i=s!==void 0&&o(s)?s:void 0;if(r!==void 0){const l={arity:r.arity,...r.variadic===!0?{variadic:!0}:{}};if(i?.handlerKey===r.key)return{...l,declared:i};if(s!==void 0)return l;const a=Te(n,t,r,o);return a===void 0?l:{...l,declared:a,negates:!0}}if(!(!e.includesLooseFlags||s===void 0))return i===void 0?{arity:s.arity,loose:!0}:{arity:s.arity,declared:i,loose:!0}}function T(e){return e.length>1&&e.startsWith("-")}const ue=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function ce(e,n,t){const{tokens:o}=e;let r=0,s,i=!1,l=!1;for(;r<o.length||s!==void 0;){const a=s??o[r++];if(a==="--")return;if(l&&s===void 0&&Fe(e,a))continue;const u=T(a)?De(e,a,o[r],n,t):{consumedByCommander:!1,consumed:0};if(r+=u.consumed,s=u.group,l=u.variadic===!0,!u.consumedByCommander){if(Ve(e.stop,a,i))return;i=!0}}}function Fe(e,n){return!T(n)||e.negativeNumbersAreValues&&ue.test(n)}function Ve(e,n,t){return e!==void 0&&(e.atFirstUnrecognized||!t&&e.atSubcommand(n))}function De(e,n,t,o,r){const s=qe(n,t,o);if(s!==void 0)return r(s.spelling,s.entry,s.value,"loose"),{consumedByCommander:!1,consumed:s.consumed};const i=o(n);if(i!==void 0){const l=i.arity==="required"||i.arity==="optional"&&t!==void 0&&(!T(t)||e.negativeNumbersAreValues&&ue.test(t));return r(n,i,i.negates===!0?!1:l?t:!0,"commander"),{consumedByCommander:!0,consumed:l?1:0,variadic:i.variadic===!0}}return n[1]!=="-"?{consumed:0,...Re(n,o,r)}:{consumedByCommander:We(n,o,r,e.includesLooseFlags?r:()=>{}),consumed:0}}function qe(e,n,t){const o=e.indexOf("="),r=o>1?e.slice(0,o):e,s=t(r);if(s?.loose===!0)return o>1?{spelling:r,entry:s,value:e.slice(o+1),consumed:0}:n!==void 0&&!n.startsWith("-")?{spelling:r,entry:s,value:n,consumed:1}:{spelling:r,entry:s,value:!0,consumed:0};const i=o<0&&e.startsWith("--no-")?t(`--${e.slice(5)}`):void 0;return i?.loose===!0&&i.declared?.kind==="boolean"?{spelling:e,entry:i,value:!1,consumed:0}:void 0}function Re(e,n,t){const o=e.slice(0,2),r=e.length>2?n(o):void 0;return r===void 0||r.loose===!0?{consumedByCommander:!1}:r.arity!=="none"?(t(o,r,e.slice(2),"commander"),{consumedByCommander:!0}):(t(o,r,!0,"commander"),{consumedByCommander:!0,group:`-${e.slice(2)}`})}function We(e,n,t,o){const r=e.indexOf("=");if(r>2){const i=e.slice(0,r),l=n(i);return l!==void 0&&l.arity!=="none"?(t(i,l,e.slice(r+1),"commander"),!0):(l?.declared?.kind==="boolean"&&o(i,l,e.slice(r+1),"loose"),!1)}const s=e.startsWith("--no-")?n(`--${e.slice(5)}`):void 0;return s?.declared?.kind==="boolean"&&o(e,s,!1,"loose"),!1}function tn(e,n,t){const o=le(n),r=new Map;for(const s of e)ce(s,i=>ae(s,o,i),(i,l,a)=>{l.declared!==void 0&&Me(r,l.declared,i,a,t)})}function Me(e,n,t,o,r){const{definition:s,handlerKey:i,kind:l}=n,a=l?b(o,l):o,u=e.get(i)??new Map,c=[...u].find(([g,f])=>g!==t&&!k(f,a));c!==void 0&&P(s,i,[c[0],t],r),u.set(t,a),e.set(i,u)}function Te(e,n,t,o){const r=n.startsWith("--no-")?e.get(`--${n.slice(5)}`):void 0;return r!==void 0&&o(r)&&r.kind==="boolean"&&r.handlerKey===t.key?r:void 0}function ke(e){return e.scalar}function fe(e){return!e.scalar&&e.kind==="boolean"&&e.arity==="none"}function rn(e,n,t){const o=le(t),r=[...new Set(o.values())].filter(fe);if(r.length===0)return e;const s=new Set(t.map(f=>O(f)).filter(f=>f!==null)),i=f=>S(f.definition).filter(d=>d===f.handlerKey||!s.has(d)),l=new Map([...r].reverse().flatMap(f=>i(f).map(d=>[d,f]))),a=new Map;for(const f of n)ce(f,d=>ae(f,o,d,fe)??ze(f,l,d),(d,v,w,A)=>{if(v.declared===void 0)return;const _=a.get(v.declared)??[];_.push(A==="commander"?{value:w}:null),a.set(v.declared,_)});const u=[...a].filter(([,f])=>f.some(d=>d!==null));if(u.length===0)return e;let c=e[x]??[];for(const[f,d]of u){const v=new Set(i(f)),w=c.filter(({key:p})=>v.has(p));if(w.length===0)continue;const A=p=>({consumed:0,key:f.handlerKey,value:p.value});let _=0;const de=d.filter(p=>p===null).length===w.length?d.map(p=>p===null?w[_++]:A(p)):[...w,...d.filter(p=>p!==null).map(A)];c=[...c.filter(({key:p})=>!v.has(p)),...de]}const g=Object.assign(Object.create(null),e);return Object.defineProperty(g,x,{value:c}),g}function ze(e,n,t){const o=!t.startsWith("--")&&e.optionOf(t.slice(0,2))!==void 0;if(!e.includesLooseFlags||o)return;const r=n.get(h(t.replace(/^-+/u,"")));return r===void 0?void 0:{arity:r.arity,declared:r,loose:!0}}export{Z as coerceLooseCommandOptionsWithFlagDefinitions,Pe as collectExtensionFlagDefinitionsForCommand,He as collectLooseCommandOptionKeysForDefinitions,Ye as collectLoosePositionalArgs,en as normalizeDirectExtensionCommandOptions,rn as orderArgvRepeatableSwitchOccurrences,Xe as parseLooseCommandOptions,tn as refuseConflictingArgvOptionSpellings,Qe as resolveExtensionFlagOptionKey,K as resolveLooseOptionCoercionKind,nn as resolveNegatedDeclaredBooleanOption,Ze as stripLooseCommandOptionTokens,Je as validateLooseCommandOptionsWithFlagDefinitions};
|
|
1
|
+
import{isDeepStrictEqual as k}from"node:util";import{resolvePmCommandOperation as z}from"../cli-contracts/command-aliases.js";import{describeFlagScalarValueFailure as N,resolveExtensionFlagValueContract as F,resolveExtensionLongFlagName as L,EXIT_CODE as m,PmCliError as y,flattenFlagListValue as B,resolveFlagValueKind as pe}from"../runtime-primitives.js";import{RESERVED_EXTENSION_HOST_FLAG_NAMES as ge}from"../../core/extensions/reserved-host-flags.js";const he=new Set(["__proto__","prototype","constructor"]),x=Symbol("looseOptionOccurrences");function h(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,o)=>o.toUpperCase())}function me(e,n,t){const o=e[n];if(o===void 0){e[n]=t;return}if(Array.isArray(o)){o.push(t),e[n]=o;return}e[n]=[o,t]}function V(e,n){const t=e[n];if(!t.startsWith("-")||t==="-"||t==="--")return null;if(!t.startsWith("--")){const i=t.indexOf("=");if(i>=0)return{consumed:1,key:t.slice(1,i).trim(),value:t.slice(i+1),attached:!0};const l=t.slice(1).trim(),a=e[n+1];return typeof a=="string"&&!a.startsWith("-")?{consumed:2,key:l,value:a}:{consumed:1,key:l,value:!0}}const o=t.indexOf("=");if(o>=0)return{consumed:1,key:t.slice(2,o).trim(),value:t.slice(o+1),attached:!0};if(t.startsWith("--no-"))return{consumed:1,key:t.slice(5).trim(),value:!1};const r=t.slice(2).trim(),s=e[n+1];return typeof s=="string"&&!s.startsWith("-")?{consumed:2,key:r,value:s}:{consumed:1,key:r,value:!0}}function E(e){return he.has(e)}function K(e){const n=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return pe(n)}function S(e){const n=[],t=L(e.long)??"",o=typeof e.short=="string"?e.short.trim():"";if(t.startsWith("--")){const r=h(t.slice(2));r.length>0&&!E(r)&&n.push(r)}if(o.startsWith("-")&&!o.startsWith("--")){const r=h(o.slice(1));r.length>0&&!E(r)&&n.push(r)}return[...new Set(n)]}function He(e){const n=new Set;for(const t of e)for(const o of S(t))n.add(o);return n}function O(e){const n=L(e.long)??"";if(n.startsWith("--")){const t=h(n.slice(2));if(t.length>0&&!E(t))return t}return S(e)[0]??null}function $(e){const n=L(e.long)??"";if(n.startsWith("--")&&n.length>2)return n;const t=typeof e.short=="string"?e.short.trim():"";return t.startsWith("-")&&!t.startsWith("--")&&t.length>1?t:null}function U(e,n){return[...(n.definitions??e).map(o=>$(o)).filter(o=>o!==null),...n.inheritedFlags??[]]}function Je(e,n,t,o={}){if(n.length===0)return;const r=new Set,s=new Map,i=[],l=U(n,o);for(const a of n){const u=S(a),c=$(a);for(const g of u)r.add(g),a.enabled===!1&&s.set(g,c);a.required===!0&&a.enabled!==!1&&u.length>0&&i.push({keys:u,label:c,definition:a})}for(const a of Object.keys(e)){r.has(a)||I(`--${a}`,`--${a}`,t,l);const u=s.get(a);u&&G(u,t)}for(const a of i){const u=c=>Object.hasOwn(e,c)&&(a.definition.list!==!0||W(a.definition,e[c]));a.keys.some(u)||H(a.definition,a.keys[0],a.label,t)}}function I(e,n,t,o){const r=o.length>0?` Expected one of: ${[...new Set(o)].join(", ")}.`:"";throw new y(`Unknown option '${e}' for extension command '${t}'.${r}`,m.USAGE,{code:"unknown_option",flag:n,required:`Use a flag the command accepts; run pm contracts --command ${t} --flags-only --json to list them.`})}function G(e,n){throw new y(`Option '${e}' is disabled for extension command '${n}'.`,m.USAGE,{code:"extension_option_disabled",flag:e,required:`Remove ${e}; the command declares it with enabled: false.`,why:"A disabled declaration keeps the flag in the contract while refusing every value for it.",examples:[`pm ${n} --help`],nextSteps:[`Run pm contracts --command ${n} --flags-only --json to list the flags this command accepts.`]})}function H(e,n,t,o){const r=F(e),s=r.value_arity==="none"?t:r.value_arity==="optional"?`${t} [${r.value_name}]`:`${t} <${r.value_name}>`;throw new y(`Missing required option '${t}' for extension command '${o}'.`,m.USAGE,{code:"missing_required_option",flag:t,field:n,required:`Pass ${s}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${o} ${s}`],nextSteps:[`Run pm contracts --command ${o} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[t]}})}function ye(e){return typeof e=="string"||e==null?e:String(e)}function Oe(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){const n=Number(e);return Number.isFinite(n)?n:e}return e}function J(e){if(typeof e=="boolean")return e;if(typeof e=="string"){const n=e.trim().toLowerCase();if(n==="true"||n==="1")return!0;if(n==="false"||n==="0")return!1}return e}const be={string:ye,number:Oe,boolean:J};function b(e,n){return Array.isArray(e)?e.map(t=>b(t,n)):be[n](e)}function D(e,n,t){const o=t?(Array.isArray(e)?e.flat(1/0):[e]).filter(r=>r!=null&&r!==""):B(e);return n?o.map(r=>b(r,n)):o}function W(e,n){return D(n,null,e.repeatable===!0).length>0}function ve(e,n,t,o){return t?D(e,n,o):n?b(e,n):e}function we(e,n,t){const o=Y(e,n);return o.length===0?t:o.map(r=>r.value)}function X(e){return F(e).value_arity==="none"}function q(e,n,t,o,r){const s=$(e),i=r?` for extension command '${r}'`:"",l=t===!0?"no value":JSON.stringify(t);throw new y(`Option '${s}'${i} expects ${o}; received ${l}.`,m.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} ${n==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${n} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${n} value for ${s}.`,`Run pm ${r??"<command>"} --help to review the declared flag contract.`]})}function R(e,n){return e.value_validation==="strict"&&n!=="string"}function Y(e,n){const t=e[x];if(!t)return[];const o=new Set(n);return t.filter(r=>o.has(r.key))}function Se(e,n,t,o){if(X(e))for(const r of Y(t,n)){if(r.attached!==!0)continue;const s=e.list===!0&&e.repeatable!==!0?B(r.value):[r.value];for(const i of s){const l=N(b(i,"boolean"),"boolean");l!==null&&q(e,"boolean",i,l.expected,o)}}}function $e(e,n,t,o,r){const s=Array.isArray(t)?t.flat(1/0):[t],i=o?s:s.flatMap(l=>typeof l=="string"?l.split(","):[l]);for(const l of i)if(typeof l=="string"&&l.trim().length===0){const a=N(l,n);q(e,n,l,a.expected,r)}}function M(e,n,t,o){if(!R(e,t))return n;const r=t==="boolean"&&X(e),s=i=>{const l=N(i,t);return l===null?i:r&&typeof i=="string"?!0:q(e,t,i,l.expected,o)};return Array.isArray(n)?n.map(s):s(n)}function xe(e,n,t,o){for(const r of t)if(!(r===n||!Object.hasOwn(e,r))){if(Object.hasOwn(e,n)){if(o){const s=e[n],i=e[r];e[n]=[...Array.isArray(s)?s:[s],...Array.isArray(i)?i:[i]].filter(l=>l!=null)}delete e[r];continue}e[n]=e[r],delete e[r]}}function Z(e,n,t=e,o){if(n.length===0)return e;const r=Object.create(null);for(const[i,l]of Object.entries(e))r[i]=l;const s=new Set(n.map(i=>O(i)).filter(i=>i!==null));for(const i of n){const l=O(i);if(l){const a=S(i).filter(u=>u===l||!s.has(u));Ae(r,i,l,a,t,o)}}return r}function Ae(e,n,t,o,r,s){const i=n.list===!0,l=K(n);l&&!i&&_e(e,n,t,o,l,s),xe(e,t,o,i);const a=n.repeatable===!0;if(!Object.hasOwn(e,t)){n.default!==void 0&&(e[t]=ve(n.default,l,i,a));return}if(l==="boolean"&&R(n,l)&&Se(n,o,r,s),i){e[t]=Le(n,o,r,e[t],l,a,s);return}l&&(e[t]=M(n,b(e[t],l),l,s))}function _e(e,n,t,o,r,s){for(const i of o)i!==t&&Object.hasOwn(e,i)&&M(n,b(e[i],r),r,s)}function Le(e,n,t,o,r,s,i){const l=we(t,n,o);r&&R(e,r)&&$e(e,r,l,s,i);const a=D(l,r,s);return r?M(e,a,r,i):a}function Xe(e){const n=Object.create(null),t=[];Object.defineProperty(n,x,{value:t});let o=0;for(;o<e.length;){const r=V(e,o);if(!r){o+=1;continue}const s=h(r.key);if(s.length===0||E(s)){o+=r.consumed;continue}me(n,s,r.value),t.push({...r,key:s}),o+=r.consumed}return n}function Ye(e){const n=[];let t=0;for(;t<e.length;){if(e[t]==="--"){n.push(...e.slice(t+1));break}const o=V(e,t);if(o){t+=Math.max(1,o.consumed);continue}n.push(e[t]),t+=1}return n}function Ze(e,n){if(n.length===0)return[...e];const t=new Set,o=new Set;for(const i of n){const l=K(i);for(const a of S(i))t.add(a),l==="boolean"&&o.add(a)}if(t.size===0)return[...e];const r=[];let s=0;for(;s<e.length;){if(e[s]==="--"){r.push(...e.slice(s+1));break}const i=V(e,s);if(i){const l=h(i.key);if(t.has(l)){const a=e[s],u=o.has(l)&&!a.includes("=")?1:i.consumed;s+=u;continue}}r.push(e[s]),s+=1}return r}function Qe(e){return O(e)}function Q(e){return e.trim().toLowerCase().split(/\s+/u).filter(n=>n.length>0).join(" ")}function Pe(e,n){const t=Q(n);if(t.length===0)return[];const o=z(t);return e.flags.filter(r=>z(Q(r.target_command))===o).flatMap(r=>[...r.flags])}function P(e,n,t,o){const r=$(e),[s,i]=t;throw new y(`Options '${s}' and '${i}' both set ${r} for extension command '${o}' with different values.`,m.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${r} once, under the handler key '${n}'.`,why:`'${s}' and '${i}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${i}' and pass one value as '${n}'.`,`Run pm contracts --command ${o} --flags-only --json to read each flag's sdk_option key.`]})}function en(e,n,t,o={}){if(n.length===0)return e;const r=n.map(c=>c.repeatable===!0&&c.list!==!0?{...c,list:!0}:c),s=re(r),i=Ne(e,s,t),l=new Set([...s.long.values()].map(({handlerKey:c})=>c)),a=Object.create(null),u=Object.create(null);for(const[c,g]of Object.entries(i))l.has(c)?a[c]=g:g===void 0||o.undeclaredKeys==="pass"||Ke(c)?u[c]=g:I(c,Ce(c),t,U(r,{}));return ne(a,r,t),Object.assign(u,Z(a,r,ee(a,s),t))}function ee(e,n){const t=new Set([...n.long.values()].map(({handlerKey:s})=>s)),o=Object.entries(e).filter(([s])=>t.has(s)).flatMap(([s,i])=>(Array.isArray(i)?i.flat(1/0):[i]).map(l=>({consumed:1,key:s,value:l,attached:!0}))),r=Object.create(null);return Object.defineProperty(r,x,{value:o}),r}function ne(e,n,t){for(const o of n){const r=O(o);if(r===null)continue;const s=$(o),i=e[r],l=Object.hasOwn(e,r);o.enabled===!1&&l&&G(s,t);const a=l&&(o.list!==!0||W(o,i));o.required===!0&&o.enabled!==!1&&!a&&H(o,r,s,t),o.list!==!0&&Array.isArray(i)&&Ee(s,t)}}function Ee(e,n){throw new y(`Option '${e}' for extension command '${n}' takes one value; received an array.`,m.USAGE,{code:"extension_flag_value_invalid",flag:e,required:`Pass one value for ${e}, or ask the package to declare it with list: true or repeatable: true.`,why:"The flag is not declared list or repeatable, so pm refuses an array before the extension handler runs instead of handing it a value of the wrong shape.",nextSteps:[`Run pm contracts --command ${n} --flags-only --json to read each flag's value contract.`]})}const te=new Set([...[...ge].filter(e=>e.startsWith("--")).flatMap(e=>{const n=e.replace(/^--/u,"");return[n,...n.startsWith("no-")?[n.slice(3)]:[]].flatMap(o=>[h(o),o.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function Ke(e){return te.has(e)||te.has(h(e.replace(/^-{1,2}/u,"")))}function Ce(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function re(e){const n={long:new Map,short:new Map},t=(o,r,s)=>{r.length>0&&!o.has(r)&&o.set(r,s)};for(const o of e){const r=O(o);if(r===null)continue;const s={handlerKey:r,definition:o};t(n.long,r,s);const i=typeof o.short=="string"?o.short.trim():"";i.startsWith("-")&&!i.startsWith("--")&&t(n.short,i.slice(1),s)}return n}function C(e,n){return e.long.get(n)??e.short.get(n.replace(/^-(?!-)/u,""))??e.long.get(h(n.replace(/^-{1,2}/u,"")))}function oe(e,n,t,o){const r=/^(?:--)?no-(.+)$/u.exec(n)?.[1];if(r===void 0||C(e,n)!==void 0)return{spelling:n,value:t};const s=C(e,r);return s===void 0||K(s.definition)!=="boolean"?{spelling:n,value:t}:(s.definition.list===!0||s.definition.repeatable===!0)&&Array.isArray(t)?{spelling:r,value:t.flat(1/0).map(i=>se(n,s.definition,i,o))}:s.definition.list===!0&&t!==void 0?{spelling:r,value:se(n,s.definition,t,o)}:{spelling:r,value:t===void 0?t:j(n,s.definition,t,o)}}function nn(e,n,t){const o=re(e);try{const r=oe(o,n,t,"");if(r.spelling===n)return;const s=C(o,r.spelling);return(s.definition.list===!0||s.definition.repeatable===!0)&&!W(s.definition,r.value)?void 0:{key:s.handlerKey,value:r.value}}catch{return}}function se(e,n,t,o){const r=s=>s.trim().length===0?s:String(j(e,n,s.trim(),o));return t==null?t:typeof t!="string"?j(e,n,t,o):t.trim().length===0?t:n.repeatable===!0||!t.includes(",")?j(e,n,t,o):t.split(",").map(r).join(",")}function j(e,n,t,o){const r=J(t);return typeof r=="boolean"?!r:je(e,n,t,o)}function je(e,n,t,o){const r=$(n);throw new y(`Option '${e}' for extension command '${o}' negates ${r} and expects true, false, 1, or 0; received ${JSON.stringify(t)}.`,m.USAGE,{code:"extension_flag_value_invalid",flag:r,required:`Pass ${r} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${r}, so only a boolean value can be inverted before the extension handler runs.`,nextSteps:[`Run pm contracts --command ${o} --flags-only --json to read each flag's value contract.`]})}function Ne(e,n,t){const o=Object.create(null),r=new Map;for(const[s,i]of Object.entries(e)){const{spelling:l,value:a}=oe(n,s,i,t),u=C(n,l);if(u===void 0)o[l]=a;else if(a!==void 0){const c=r.get(u.handlerKey);c===void 0?(r.set(u.handlerKey,l),o[u.handlerKey]=a):k(ie(u.definition,u.handlerKey,o[u.handlerKey],n,t),ie(u.definition,u.handlerKey,a,n,t))||P(u.definition,u.handlerKey,[c,l],t)}}return o}function ie(e,n,t,o,r){const s={[n]:t};return ne(s,[e],r),Z(s,[e],ee(s,o),r)[n]}function le(e){const n=new Map;for(const t of e){const o=O(t);if(o===null)continue;const r={definition:t,handlerKey:o,kind:K(t),arity:F(t).value_arity,scalar:t.list!==!0},s=[L(t.long),typeof t.short=="string"?t.short.trim():""];for(const i of s.filter(l=>l?.startsWith("-")===!0))n.has(i)||n.set(i,r)}return n}function ae(e,n,t,o=ke){const r=e.optionOf(t),s=n.get(t),i=s!==void 0&&o(s)?s:void 0;if(r!==void 0){const l={arity:r.arity,...r.variadic===!0?{variadic:!0}:{}};if(i?.handlerKey===r.key)return{...l,declared:i};if(s!==void 0)return l;const a=Te(n,t,r,o);return a===void 0?l:{...l,declared:a,negates:!0}}if(!(!e.includesLooseFlags||s===void 0))return i===void 0?{arity:s.arity,loose:!0}:{arity:s.arity,declared:i,loose:!0}}function T(e){return e.length>1&&e.startsWith("-")}const ue=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function ce(e,n,t){const{tokens:o}=e;let r=0,s,i=!1,l=!1;for(;r<o.length||s!==void 0;){const a=s??o[r++];if(a==="--")return;if(l&&s===void 0&&Fe(e,a))continue;const u=T(a)?De(e,a,o[r],n,t):{consumedByCommander:!1,consumed:0};if(r+=u.consumed,s=u.group,l=u.variadic===!0,!u.consumedByCommander){if(Ve(e.stop,a,i))return;i=!0}}}function Fe(e,n){return!T(n)||e.negativeNumbersAreValues&&ue.test(n)}function Ve(e,n,t){return e!==void 0&&(e.atFirstUnrecognized||!t&&e.atSubcommand(n))}function De(e,n,t,o,r){const s=We(n,t,o);if(s!==void 0)return r(s.spelling,s.entry,s.value,"loose"),{consumedByCommander:!1,consumed:s.consumed};const i=o(n);if(i!==void 0){const l=i.arity==="required"||i.arity==="optional"&&t!==void 0&&(!T(t)||e.negativeNumbersAreValues&&ue.test(t));return r(n,i,i.negates===!0?!1:l?t:!0,"commander"),{consumedByCommander:!0,consumed:l?1:0,variadic:i.variadic===!0}}return n[1]!=="-"?{consumed:0,...qe(n,o,r)}:{consumedByCommander:Re(n,o,r,e.includesLooseFlags?r:()=>{}),consumed:0}}function We(e,n,t){const o=e.indexOf("="),r=o>1?e.slice(0,o):e,s=t(r);if(s?.loose===!0)return o>1?{spelling:r,entry:s,value:e.slice(o+1),consumed:0}:n!==void 0&&!n.startsWith("-")?{spelling:r,entry:s,value:n,consumed:1}:{spelling:r,entry:s,value:!0,consumed:0};const i=o<0&&e.startsWith("--no-")?t(`--${e.slice(5)}`):void 0;return i?.loose===!0&&i.declared?.kind==="boolean"?{spelling:e,entry:i,value:!1,consumed:0}:void 0}function qe(e,n,t){const o=e.slice(0,2),r=e.length>2?n(o):void 0;return r===void 0||r.loose===!0?{consumedByCommander:!1}:r.arity!=="none"?(t(o,r,e.slice(2),"commander"),{consumedByCommander:!0}):(t(o,r,!0,"commander"),{consumedByCommander:!0,group:`-${e.slice(2)}`})}function Re(e,n,t,o){const r=e.indexOf("=");if(r>2){const i=e.slice(0,r),l=n(i);return l!==void 0&&l.arity!=="none"?(t(i,l,e.slice(r+1),"commander"),!0):(l?.declared?.kind==="boolean"&&o(i,l,e.slice(r+1),"loose"),!1)}const s=e.startsWith("--no-")?n(`--${e.slice(5)}`):void 0;return s?.declared?.kind==="boolean"&&o(e,s,!1,"loose"),!1}function tn(e,n,t){const o=le(n),r=new Map;for(const s of e)ce(s,i=>ae(s,o,i),(i,l,a)=>{l.declared!==void 0&&Me(r,l.declared,i,a,t)})}function Me(e,n,t,o,r){const{definition:s,handlerKey:i,kind:l}=n,a=l?b(o,l):o,u=e.get(i)??new Map,c=[...u].find(([g,f])=>g!==t&&!k(f,a));c!==void 0&&P(s,i,[c[0],t],r),u.set(t,a),e.set(i,u)}function Te(e,n,t,o){const r=n.startsWith("--no-")?e.get(`--${n.slice(5)}`):void 0;return r!==void 0&&o(r)&&r.kind==="boolean"&&r.handlerKey===t.key?r:void 0}function ke(e){return e.scalar}function fe(e){return!e.scalar&&e.kind==="boolean"&&e.arity==="none"}function rn(e,n,t){const o=le(t),r=[...new Set(o.values())].filter(fe);if(r.length===0)return e;const s=new Set(t.map(f=>O(f)).filter(f=>f!==null)),i=f=>S(f.definition).filter(d=>d===f.handlerKey||!s.has(d)),l=new Map([...r].reverse().flatMap(f=>i(f).map(d=>[d,f]))),a=new Map;for(const f of n)ce(f,d=>ae(f,o,d,fe)??ze(f,l,d),(d,v,w,A)=>{if(v.declared===void 0)return;const _=a.get(v.declared)??[];_.push(A==="commander"?{value:w}:null),a.set(v.declared,_)});const u=[...a].filter(([,f])=>f.some(d=>d!==null));if(u.length===0)return e;let c=e[x]??[];for(const[f,d]of u){const v=new Set(i(f)),w=c.filter(({key:p})=>v.has(p));if(w.length===0)continue;const A=p=>({consumed:0,key:f.handlerKey,value:p.value});let _=0;const de=d.filter(p=>p===null).length===w.length?d.map(p=>p===null?w[_++]:A(p)):[...w,...d.filter(p=>p!==null).map(A)];c=[...c.filter(({key:p})=>!v.has(p)),...de]}const g=Object.assign(Object.create(null),e);return Object.defineProperty(g,x,{value:c}),g}function ze(e,n,t){const o=!t.startsWith("--")&&e.optionOf(t.slice(0,2))!==void 0;if(!e.includesLooseFlags||o)return;const r=n.get(h(t.replace(/^-+/u,"")));return r===void 0?void 0:{arity:r.arity,declared:r,loose:!0}}export{Z as coerceLooseCommandOptionsWithFlagDefinitions,Pe as collectExtensionFlagDefinitionsForCommand,He as collectLooseCommandOptionKeysForDefinitions,Ye as collectLoosePositionalArgs,en as normalizeDirectExtensionCommandOptions,rn as orderArgvRepeatableSwitchOccurrences,Xe as parseLooseCommandOptions,tn as refuseConflictingArgvOptionSpellings,Qe as resolveExtensionFlagOptionKey,K as resolveLooseOptionCoercionKind,nn as resolveNegatedDeclaredBooleanOption,Ze as stripLooseCommandOptionTokens,Je as validateLooseCommandOptionsWithFlagDefinitions};
|
|
2
2
|
//# sourceMappingURL=command-options.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Implements extension package-management support for Install Sources.
|
|
5
5
|
*/
|
|
6
|
-
import{execFile}from "node:child_process";import{type
|
|
6
|
+
import{execFile}from "node:child_process";import{type EntryData}from "tar";import{PmCliError,type PmCliErrorContext}from "../../core/shared/errors.js";declare const execFileAsync:typeof execFile.__promisify__;interface LocalPackageArchiveLimits{maxArchiveBytes:number;maxEntries:number;maxExpandedBytes:number;maxEntryBytes:number;}
|
|
7
7
|
/** Parsed filesystem install source. */
|
|
8
8
|
export interface LocalInstallSource{
|
|
9
9
|
/** Discriminator for a filesystem source. */
|
|
@@ -91,7 +91,7 @@ export declare function normalizeNpmLocalFileAliasSpec(spec:string,cwd?:string):
|
|
|
91
91
|
* share the same bounded validation, dependency installation, and cleanup
|
|
92
92
|
* contract. Registry artifacts must also exist inside the requested pack root.
|
|
93
93
|
*/
|
|
94
|
-
declare function resolveNpmSourceDirectoryWithRunner(source:NpmInstallSource,npmRunner:typeof runNpmCommand):Promise<{directory:string;package?:string;version?:string;cleanup:()=> Promise<void>;}>;declare function validateLocalPackageArchiveEntry(entry:
|
|
94
|
+
declare function resolveNpmSourceDirectoryWithRunner(source:NpmInstallSource,npmRunner:typeof runNpmCommand):Promise<{directory:string;package?:string;version?:string;cleanup:()=> Promise<void>;}>;declare function validateLocalPackageArchiveEntry(entry:EntryData,limits:LocalPackageArchiveLimits,state:{entries:number;expandedBytes:number;packageJsonEntries:number;}):void;
|
|
95
95
|
/** Validate and extract one local npm package archive into an isolated temporary root. */
|
|
96
96
|
declare function extractLocalPackageArchive(archivePath:string,limits?:LocalPackageArchiveLimits):Promise<{directory:string;package?:string;version?:string;cleanup:()=> Promise<void>;}>;declare function installNpmPackageRuntimeDependencies(packageRoot:string,npmRunner?:typeof runNpmCommand):Promise<void>;declare function hasHostedPmCliDependency(manifest:{dependencies?:unknown;optionalDependencies?:unknown;peerDependencies?:unknown;}):boolean;declare function removeHostedPmCliDependency(manifest:Record<string,unknown>):void;declare function linkHostedPmCliDependency(packageRoot:string):Promise<void>;declare function resolveDirectorySymlinkType(platform:NodeJS.Platform):"dir"|"junction";declare function runtimeDependencyInstallSpecs(manifest:{dependencies?:unknown;optionalDependencies?:unknown;peerDependencies?:unknown;}):string[];declare function resolvePackageExtensionDirectory(packageRoot:string,sourceLabel:string):Promise<string>;
|
|
97
97
|
/** Implements resolve install source for the public runtime surface of this module. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{execFile as
|
|
2
|
-
${r}`,
|
|
3
|
-
${f}`,p.GENERIC_FAILURE)}}function E(e){const n=e.trim(),t=n.includes("@file:")?n.slice(0,n.lastIndexOf("@file:")):n;return t.startsWith("@")?t.match(/^(@[^/@\s]+\/[^/@\s]+)/)?.[1]??t:t.match(/^([^/@\s]+)/)?.[1]??t}const re=/^(?:(?:github|gitlab|bitbucket|gist):|git(?:\+[a-z]+)?:|[a-z][a-z0-9+.-]*:\/\/|[\w.-]+@[\w.-]+:)/iu;function ie(e){if(!S(e)){try{const n=v(e.trim());if((n.type==="git"||n.type==="remote")&&!n.name)return}catch{}return E(e)}}function oe(e){const n=e.trim();let t;try{t=v(n)}catch{return}if(!(t.type!=="git"||t.name||re.test(n)))throw new d(`npm:${n} names no local directory here, and npm would read it as a git repository.`,p.USAGE,{code:"npm_source_shorthand_ambiguous",required:"Spell the source explicitly: npm:./<path> for a local directory, or npm:github:<owner>/<repo> for a repository.",why:"A bare owner/repo npm spec means a local directory when one exists and a git host otherwise, so pm refuses to guess which code to install."})}function S(e){const n="@file:",t=e.lastIndexOf(n);return t>0&&e.slice(0,t).trim().length>0&&e.slice(t+n.length).trim().length>0}function se(e){const t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes("npm err! code e404")||t.includes("404 not found")||t.includes("is not in this registry")}function ce(e){const t=(e instanceof Error?e.message:String(e)).toLowerCase();return se(e)||t.includes("not found")}function le(e){const n=e.trim().toLowerCase();return n.startsWith("@unbrained/pm-")||n.startsWith("pm-")}function pe(e){const n=E(e),t=le(n),a=n.replace(/^.*\//,""),i=t?`github.com/unbraind/${a}`:void 0,r=i?`pm package install --project ${i}`:void 0;return{message:t?`npm package "${e}" was not found in the registry. If this is an unpublished first-party pm package, install its GitHub repository instead.`:`npm package "${e}" was not found in the registry.`,context:{code:"npm_package_not_found",required:"Use an install source that exists, or publish the npm package before installing it with npm:<name>.",why:"Classifying npm 404s avoids repeated registry retries and gives agents a deterministic fallback path.",examples:r?[r,"pm package catalog --project --json"]:[`npm view ${n}`,"pm package catalog --project --json"],nextSteps:r?[`Try ${r} if the repository exists.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."]:[`Verify ${n} exists in the npm registry and that you have access to it.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."],recovery:{attempted_command:`pm install --project npm:${e}`,normalized_args:["install","--project",`npm:${e}`],...i&&r?{fallback_candidates:[{source:i,command:r,reason:"canonical first-party GitHub repository fallback for unpublished pm packages"}],next_best_command:r}:{}}}}}function de(e,n){if(!ce(n))return null;const t=pe(e);return new d(t.message,p.NOT_FOUND,t.context)}async function A(e){if(c.isAbsolute(e)||e.startsWith(".")||e.startsWith("..")){const n=c.resolve(process.cwd(),e);return await m(n)?n:null}try{const n=new URL(e);if(n.protocol==="file:"){const t=q(n);return await m(t)?t:null}}catch{}if(!/^[a-z][a-z0-9+.-]*:/i.test(e)){const n=c.resolve(process.cwd(),e);if(await m(n))return n}return null}async function $(e){const n=await A(e);if(n)return n;const t=ue(e);return t!==e?t:(/^[a-z][a-z0-9+.-]*:/i.test(e),e)}function ue(e,n=process.cwd()){const t="@file:",a=e.lastIndexOf(t);if(!S(e))return e;const i=e.slice(0,a),r=e.slice(a+t.length);if(r.startsWith("//")&&!r.startsWith("///"))return e;if(!r.startsWith("/"))return`${i}@${c.resolve(n,r)}`;let o;try{o=decodeURIComponent(new URL(`file:${r}`).pathname)}catch{return e}const s=/^\/[A-Za-z]:/.test(o)?o.slice(1):o;return`${i}@${s}`}function N(e,n){const t=c.resolve(e,n),a=c.relative(e,t);if(a.length===0||a===".."||a.startsWith(`..${c.sep}`)||c.isAbsolute(a))throw new d("npm pack reported a package archive outside its isolated destination.",p.GENERIC_FAILURE,{code:"npm_package_archive_unsafe",required:"Retry with a trusted npm client that writes its archive inside the requested pack destination.",why:"pm will not read a package-manager artifact outside the isolated directory created for this install."});return t}function me(e,n){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(!(typeof t.filename!="string"||t.filename.trim().length===0))return{...n===void 0?{}:{key:n},filename:t.filename,...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{}}}function fe(e){return(Array.isArray(e)?e.map(t=>({value:t})):typeof e=="object"&&e!==null?Object.entries(e).map(([t,a])=>({key:t,value:a})):[]).flatMap(({key:t,value:a})=>{const i=me(a,t);return i?[i]:[]})}function he(e,n){const t=n?.trim().toLowerCase(),a=t?e.filter(o=>{const s=o.name?.trim().toLowerCase();return s!==void 0?s===t:o.key?.trim().toLowerCase()===t}):[];if(a.length===1)return a[0];if(e.length!==1)return;const i=e[0],r=i.name??i.key;return t&&r!==void 0&&r.trim().toLowerCase()!==t?void 0:i}function C(e,n,t){let a;try{a=JSON.parse(e)}catch{const o=e.split(/\r?\n/).map(s=>s.trim()).filter(s=>s.length>0).at(-1);if(!o)throw new d("npm pack did not report a tarball filename.",p.GENERIC_FAILURE);return{tarball:N(n,o)}}const i=fe(a),r=he(i,t);if(!r)throw new d("npm pack --json returned an unsupported or ambiguous package receipt.",p.GENERIC_FAILURE,{code:"npm_pack_json_shape_unsupported",required:"Use an npm client that returns an array of package receipts or an object keyed by package name, with exactly one requested package entry containing filename.",why:`Well-formed JSON contained ${i.length} usable package receipt(s), but pm could not select ${t??"one package"} deterministically.`});return{tarball:N(n,r.filename),package:r.name??r.key,version:r.version}}async function L(e){return U(e,_)}async function U(e,n){const t=await A(e.spec);if(t){if((await l.stat(t)).isFile()&&I(t))return w(t);const o=c.join(t,"package.json"),s=await m(o)?JSON.parse(await l.readFile(o,"utf8")):{};return{directory:await g(t,e.input),package:typeof s.name=="string"?s.name:void 0,version:typeof s.version=="string"?s.version:void 0,cleanup:async()=>{}}}oe(e.spec);const a=await l.mkdtemp(c.join(k.tmpdir(),"pm-npm-package-source-")),i=c.join(a,"pack");await l.mkdir(i,{recursive:!0});try{const r=await $(e.spec),o=await n(["pack",r,"--json","--pack-destination",i]),s=C(o,i,ie(e.spec));if(!await m(s.tarball))throw new d("npm pack did not create its reported package archive.",p.GENERIC_FAILURE,{code:"npm_package_archive_missing",required:"Retry the npm package install with a healthy registry and writable temporary directory.",why:"The package manager reported a tarball filename that was absent before validation, so pm cannot safely extract or install it."});const u=await w(s.tarball);return{directory:u.directory,package:s.package??u.package,version:s.version??u.version,cleanup:async()=>{try{await u.cleanup()}finally{await l.rm(a,{recursive:!0,force:!0})}}}}catch(r){await l.rm(a,{recursive:!0,force:!0});const o=de(e.spec,r);throw o||r}}function I(e){const n=e.toLowerCase();return n.endsWith(".tgz")||n.endsWith(".tar.gz")}function h(e){throw new d(e,p.USAGE,{code:"local_package_archive_unsafe",required:"Use a bounded npm .tgz or .tar.gz archive with one package/ root and no links or escaping paths.",why:"Package archives are untrusted input and must be validated before any entry reaches the filesystem."})}function R(e,n,t){if(e.meta)return;t.entries+=1,t.entries>n.maxEntries&&h(`Local package archive exceeds the ${n.maxEntries} entry limit.`);const a=e.path,i=a.split("/");(a.includes("\\")||a.startsWith("/")||/^[A-Za-z]:/u.test(a)||i.some(r=>r===".."))&&h(`Local package archive contains an escaping path: "${a}".`),i[0]!=="package"&&h(`Local package archive entry "${a}" is outside the required package/ root.`),(e.type==="SymbolicLink"||e.type==="Link")&&h(`Local package archive link "${a}" is not supported.`),e.type!=="File"&&e.type!=="OldFile"&&e.type!=="Directory"&&h(`Local package archive entry "${a}" uses unsupported type "${e.type}".`),e.size>n.maxEntryBytes&&h(`Local package archive entry "${a}" exceeds the ${n.maxEntryBytes} byte entry limit.`),t.expandedBytes+=e.size,t.expandedBytes>n.maxExpandedBytes&&h(`Local package archive exceeds the ${n.maxExpandedBytes} expanded byte limit.`),a==="package/package.json"&&(t.packageJsonEntries+=1)}async function w(e,n=Y){(await l.stat(e)).size>n.maxArchiveBytes&&h(`Local package archive exceeds the ${n.maxArchiveBytes} archive byte limit.`);const a=await l.mkdtemp(c.join(k.tmpdir(),"pm-local-package-archive-")),i=c.join(a,"extract");await l.mkdir(i,{recursive:!0});const r={entries:0,expandedBytes:0,packageJsonEntries:0};let o;try{if(await K({file:e,strict:!0,maxDecompressionRatio:100,onReadEntry:M=>{if(o===void 0)try{R(M,n,r)}catch(B){o=B}}}),o!==void 0)throw o;r.packageJsonEntries!==1&&h(`Local package archive must contain exactly one package/package.json entry; found ${r.packageJsonEntries}.`),await H({file:e,cwd:i,strict:!0,preservePaths:!1,preserveOwner:!1,noMtime:!0,unlink:!0,maxDepth:64,maxDecompressionRatio:100});const s=c.join(i,"package"),u=c.join(s,"package.json"),f=JSON.parse(await l.readFile(u,"utf8"));return await O(s),{directory:await g(s,e),package:typeof f.name=="string"?f.name:void 0,version:typeof f.version=="string"?f.version:void 0,cleanup:async()=>{await l.rm(a,{recursive:!0,force:!0})}}}catch(s){throw await l.rm(a,{recursive:!0,force:!0}),s}}async function O(e,n=_){const t=c.join(e,"package.json");if(!await m(t))return;let a;try{a=JSON.parse(await l.readFile(t,"utf8"))}catch{return}if(typeof a!="object"||a===null)return;const i=a,r=W(i),o=G(i);if(r.length===0&&!o)return;const s={...a};delete s.devDependencies;const u={...s};F(u),await l.writeFile(t,`${JSON.stringify(u,null,2)}
|
|
4
|
-
`,"utf8");try{await Promise.all([l.rm(c.join(e,"package-lock.json"),{force:!0}),l.rm(c.join(e,"npm-shrinkwrap.json"),{force:!0})]),r.length>0&&await n(["install","--ignore-scripts","--no-audit","--fund=false","--package-lock=false","--no-save","--omit=peer","--"],e),o&&await
|
|
5
|
-
`,"utf8")}}function
|
|
1
|
+
import{execFile as X}from"node:child_process";import l from"node:fs/promises";import x from"node:os";import c from"node:path";import{Readable as Z,Writable as Q}from"node:stream";import{pipeline as Y}from"node:stream/promises";import{fileURLToPath as ee}from"node:url";import{promisify as te}from"node:util";import{createGunzip as ne}from"node:zlib";import _ from"npm-package-arg";import{extract as ae,Parser as re}from"tar";import{collectPackageExtensionDirectories as ie}from"../../core/packages/manifest.js";import{resolvePmPackageRootFromModule as oe}from"../../core/packages/root.js";import{pathExists as h}from"../../core/fs/fs-utils.js";import{isPathWithinDirectory as se}from"../../core/fs/path-utils.js";import{EXIT_CODE as u}from"../../core/shared/constants.js";import{PmCliError as p}from"../../core/shared/errors.js";import{listBundledPackageAliases as ce}from"./bundled-catalog.js";const L=te(X),k="@unbrained/pm-cli",le={maxArchiveBytes:64*1024*1024,maxEntries:4096,maxExpandedBytes:256*1024*1024,maxEntryBytes:64*1024*1024},N=100;let E;async function pe(e,n=process.cwd()){const t=e.trim();if(!/^(@[^/\\\s]+\/[^/\\\s]+|[^@/\\\s][^/\\\s]*)$/u.test(t))return null;let a=c.resolve(n);for(;;){const i=c.join(a,"node_modules",...t.split("/")),r=c.join(i,"package.json");if(await h(r))try{const s=JSON.parse(await l.readFile(r,"utf8"));if(s.name===t)return{package:t,...typeof s.version=="string"?{version:s.version}:{},directory:i}}catch{return null}const o=c.dirname(a);if(o===a)return null;a=o}}function P(e,n,t){const a=e.split("/").map(g=>g.trim()).filter(g=>g.length>0);if(a.length<2)return null;const i=a[0],r=a[1].replace(/\.git$/i,"");if(i.length===0||r.length===0)return null;const o=a.slice(2);let s,d;return o[0]==="tree"&&o.length>=2?(s=o[1],d=o.slice(2).join("/")):o.length>0&&(d=o.join("/")),typeof t=="string"&&t.trim().length>0&&(s=t.trim()),{kind:"github",input:n,owner:i,repo:r,repository:`https://github.com/${i}/${r}.git`,ref:s,subpath:d&&d.length>0?d:void 0}}function de(e,n,t){const a=e.slice(4).trim();if(a.length===0)throw new p('npm package source must include a package spec after "npm:".',u.USAGE);if(n)throw new p('Options "--gh/--github" cannot be combined with npm: package sources.',u.USAGE);if(t)throw new p('Option "--ref" cannot be combined with npm: package sources.',u.USAGE);return{kind:"npm",input:e,spec:a}}function Qe(e,n={}){const t=e.trim();if(t.length===0)throw new p("Extension source is required for --install.",u.USAGE);const a=typeof n.ref=="string"&&n.ref.trim().length>0?n.ref.trim():void 0;if(t.startsWith("npm:"))return de(t,n.forceGithub===!0,a);const i=(()=>{try{const o=new URL(t);if(o.hostname!=="github.com")return null;const s=o.pathname.replace(/^\/+/,"");return P(s,t,a)}catch{return null}})();if(i)return i;const r=t.startsWith("github.com/")?t.slice(11):null;if(r){const o=P(r,t,a);if(!o)throw new p(`Invalid GitHub source "${t}".`,u.USAGE);return o}if(n.forceGithub){const o=P(t,t,a);if(!o)throw new p(`Invalid GitHub shorthand "${t}".`,u.USAGE);return o}if(/^https?:\/\//i.test(t))throw new p(`Unsupported extension source URL "${t}". Supported remote source host: github.com.`,u.USAGE);return{kind:"local",input:t,absolute_path:c.resolve(process.cwd(),t)}}async function C(e,n=L,t){try{return((await n("git",e,{encoding:"utf8",timeout:t})).stdout??"").trim()}catch(a){const i=typeof a=="object"&&a!==null&&"stderr"in a?String(a.stderr):"",r=i.trim().length>0?i.trim():a instanceof Error?a.message:String(a);throw new p(`Git command failed: git ${e.join(" ")}
|
|
2
|
+
${r}`,u.GENERIC_FAILURE)}}function ue(e=process.platform){return e==="win32"?"npm.cmd":"npm"}function me(e=process.platform){return e==="win32"}async function A(e,n,t=L,a=process.platform,i=process.env){const r=ue(a),o=Object.fromEntries(Object.entries(i).filter(([s])=>s.toLowerCase()!=="npm_config_allow_scripts"));o.NPM_CONFIG_ALLOW_SCRIPTS="";try{return((await t(r,e,{cwd:n,encoding:"utf8",env:o,shell:me(a)})).stdout??"").trim()}catch(s){const d=typeof s=="object"&&s!==null&&"stderr"in s?String(s.stderr):"",g=d.trim().length>0?d.trim():s instanceof Error?s.message:String(s);throw new p(`npm command failed: ${r} ${e.join(" ")}
|
|
3
|
+
${g}`,u.GENERIC_FAILURE)}}function S(e){const n=e.trim(),t=n.includes("@file:")?n.slice(0,n.lastIndexOf("@file:")):n;return t.startsWith("@")?t.match(/^(@[^/@\s]+\/[^/@\s]+)/)?.[1]??t:t.match(/^([^/@\s]+)/)?.[1]??t}const fe=/^(?:(?:github|gitlab|bitbucket|gist):|git(?:\+[a-z]+)?:|[a-z][a-z0-9+.-]*:\/\/|[\w.-]+@[\w.-]+:)/iu;function he(e){if(!U(e)){try{const n=_(e.trim());if((n.type==="git"||n.type==="remote")&&!n.name)return}catch{}return S(e)}}function ge(e){const n=e.trim();let t;try{t=_(n)}catch{return}if(!(t.type!=="git"||t.name||fe.test(n)))throw new p(`npm:${n} names no local directory here, and npm would read it as a git repository.`,u.USAGE,{code:"npm_source_shorthand_ambiguous",required:"Spell the source explicitly: npm:./<path> for a local directory, or npm:github:<owner>/<repo> for a repository.",why:"A bare owner/repo npm spec means a local directory when one exists and a git host otherwise, so pm refuses to guess which code to install."})}function U(e){const n="@file:",t=e.lastIndexOf(n);return t>0&&e.slice(0,t).trim().length>0&&e.slice(t+n.length).trim().length>0}function ye(e){const t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes("npm err! code e404")||t.includes("404 not found")||t.includes("is not in this registry")}function we(e){const t=(e instanceof Error?e.message:String(e)).toLowerCase();return ye(e)||t.includes("not found")}function ke(e){const n=e.trim().toLowerCase();return n.startsWith("@unbrained/pm-")||n.startsWith("pm-")}function be(e){const n=S(e),t=ke(n),a=n.replace(/^.*\//,""),i=t?`github.com/unbraind/${a}`:void 0,r=i?`pm package install --project ${i}`:void 0;return{message:t?`npm package "${e}" was not found in the registry. If this is an unpublished first-party pm package, install its GitHub repository instead.`:`npm package "${e}" was not found in the registry.`,context:{code:"npm_package_not_found",required:"Use an install source that exists, or publish the npm package before installing it with npm:<name>.",why:"Classifying npm 404s avoids repeated registry retries and gives agents a deterministic fallback path.",examples:r?[r,"pm package catalog --project --json"]:[`npm view ${n}`,"pm package catalog --project --json"],nextSteps:r?[`Try ${r} if the repository exists.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."]:[`Verify ${n} exists in the npm registry and that you have access to it.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."],recovery:{attempted_command:`pm install --project npm:${e}`,normalized_args:["install","--project",`npm:${e}`],...i&&r?{fallback_candidates:[{source:i,command:r,reason:"canonical first-party GitHub repository fallback for unpublished pm packages"}],next_best_command:r}:{}}}}}function ve(e,n){if(!we(n))return null;const t=be(e);return new p(t.message,u.NOT_FOUND,t.context)}async function I(e){if(c.isAbsolute(e)||e.startsWith(".")||e.startsWith("..")){const n=c.resolve(process.cwd(),e);return await h(n)?n:null}try{const n=new URL(e);if(n.protocol==="file:"){const t=ee(n);return await h(t)?t:null}}catch{}if(!/^[a-z][a-z0-9+.-]*:/i.test(e)){const n=c.resolve(process.cwd(),e);if(await h(n))return n}return null}async function O(e){const n=await I(e);if(n)return n;const t=xe(e);return t!==e?t:(/^[a-z][a-z0-9+.-]*:/i.test(e),e)}function xe(e,n=process.cwd()){const t="@file:",a=e.lastIndexOf(t);if(!U(e))return e;const i=e.slice(0,a),r=e.slice(a+t.length);if(r.startsWith("//")&&!r.startsWith("///"))return e;if(!r.startsWith("/"))return`${i}@${c.resolve(n,r)}`;let o;try{o=decodeURIComponent(new URL(`file:${r}`).pathname)}catch{return e}const s=/^\/[A-Za-z]:/.test(o)?o.slice(1):o;return`${i}@${s}`}function R(e,n){const t=c.resolve(e,n),a=c.relative(e,t);if(a.length===0||a===".."||a.startsWith(`..${c.sep}`)||c.isAbsolute(a))throw new p("npm pack reported a package archive outside its isolated destination.",u.GENERIC_FAILURE,{code:"npm_package_archive_unsafe",required:"Retry with a trusted npm client that writes its archive inside the requested pack destination.",why:"pm will not read a package-manager artifact outside the isolated directory created for this install."});return t}function _e(e,n){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(!(typeof t.filename!="string"||t.filename.trim().length===0))return{...n===void 0?{}:{key:n},filename:t.filename,...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{}}}function Ee(e){return(Array.isArray(e)?e.map(t=>({value:t})):typeof e=="object"&&e!==null?Object.entries(e).map(([t,a])=>({key:t,value:a})):[]).flatMap(({key:t,value:a})=>{const i=_e(a,t);return i?[i]:[]})}function Pe(e,n){const t=n?.trim().toLowerCase(),a=t?e.filter(o=>{const s=o.name?.trim().toLowerCase();return s!==void 0?s===t:o.key?.trim().toLowerCase()===t}):[];if(a.length===1)return a[0];if(e.length!==1)return;const i=e[0],r=i.name??i.key;return t&&r!==void 0&&r.trim().toLowerCase()!==t?void 0:i}function G(e,n,t){let a;try{a=JSON.parse(e)}catch{const o=e.split(/\r?\n/).map(s=>s.trim()).filter(s=>s.length>0).at(-1);if(!o)throw new p("npm pack did not report a tarball filename.",u.GENERIC_FAILURE);return{tarball:R(n,o)}}const i=Ee(a),r=Pe(i,t);if(!r)throw new p("npm pack --json returned an unsupported or ambiguous package receipt.",u.GENERIC_FAILURE,{code:"npm_pack_json_shape_unsupported",required:"Use an npm client that returns an array of package receipts or an object keyed by package name, with exactly one requested package entry containing filename.",why:`Well-formed JSON contained ${i.length} usable package receipt(s), but pm could not select ${t??"one package"} deterministically.`});return{tarball:R(n,r.filename),package:r.name??r.key,version:r.version}}async function z(e){return F(e,A)}async function F(e,n){const t=await I(e.spec);if(t){if((await l.stat(t)).isFile()&&D(t))return b(t);const o=c.join(t,"package.json"),s=await h(o)?JSON.parse(await l.readFile(o,"utf8")):{};return{directory:await w(t,e.input),package:typeof s.name=="string"?s.name:void 0,version:typeof s.version=="string"?s.version:void 0,cleanup:async()=>{}}}ge(e.spec);const a=await l.mkdtemp(c.join(x.tmpdir(),"pm-npm-package-source-")),i=c.join(a,"pack");await l.mkdir(i,{recursive:!0});try{const r=await O(e.spec),o=await n(["pack",r,"--json","--pack-destination",i]),s=G(o,i,he(e.spec));if(!await h(s.tarball))throw new p("npm pack did not create its reported package archive.",u.GENERIC_FAILURE,{code:"npm_package_archive_missing",required:"Retry the npm package install with a healthy registry and writable temporary directory.",why:"The package manager reported a tarball filename that was absent before validation, so pm cannot safely extract or install it."});const d=await b(s.tarball);return{directory:d.directory,package:s.package??d.package,version:s.version??d.version,cleanup:async()=>{try{await d.cleanup()}finally{await l.rm(a,{recursive:!0,force:!0})}}}}catch(r){await l.rm(a,{recursive:!0,force:!0});const o=ve(e.spec,r);throw o||r}}function D(e){const n=e.toLowerCase();return n.endsWith(".tgz")||n.endsWith(".tar.gz")}function f(e){throw new p(e,u.USAGE,{code:"local_package_archive_unsafe",required:"Use a bounded npm .tgz or .tar.gz archive with one package/ root and no links or escaping paths.",why:"Package archives are untrusted input and must be validated before any entry reaches the filesystem."})}function Ae(e,n){(e.type==="SymbolicLink"||e.type==="Link")&&f(`Local package archive link "${n}" is not supported.`),e.type!=="File"&&e.type!=="OldFile"&&e.type!=="Directory"&&f(`Local package archive entry "${n}" uses unsupported type "${e.type}".`),(e.header.linkpath||e.extended?.linkpath||e.globalExtended?.linkpath)&&f(`Local package archive entry "${n}" names a link target but is not a link.`)}function W(e,n,t){t.entries+=1,t.entries>n.maxEntries&&f(`Local package archive exceeds the ${n.maxEntries} entry limit.`);const a=e.path,i=a.split("/");(a.includes("\\")||a.startsWith("/")||/^[A-Za-z]:/u.test(a)||i.some(r=>r===".."))&&f(`Local package archive contains an escaping path: "${a}".`),i[0]!=="package"&&f(`Local package archive entry "${a}" is outside the required package/ root.`),Ae(e,a),e.size>n.maxEntryBytes&&f(`Local package archive entry "${a}" exceeds the ${n.maxEntryBytes} byte entry limit.`),t.expandedBytes+=e.size,t.expandedBytes>n.maxExpandedBytes&&f(`Local package archive exceeds the ${n.maxExpandedBytes} expanded byte limit.`),a==="package/package.json"&&(t.packageJsonEntries+=1)}async function Se(e,n){const t=await l.open(e,"r");try{const{size:a}=await t.stat();a>n&&f(`Local package archive exceeds the ${n} archive byte limit.`);const i=new Uint8Array(a+1);let r=0,o;do({bytesRead:o}=await t.read(i,r,i.length-r,r)),r+=o;while(o>0&&r<i.length);return r!==a&&f("Local package archive changed while it was being read."),i.subarray(0,r)}finally{await t.close()}}function je(e){let n=e.length;for(;n>0&&e[n-1]===0;)n-=1;return n}async function $e(e,n){(e[0]!==31||e[1]!==139)&&f("Local package archive is not gzip-compressed; npm package archives are gzip .tgz files.");const t=N,a=`Local package archive exceeds the ${t}x decompression ratio.`,i={entries:0,expandedBytes:0,packageJsonEntries:0},r=new re({strict:!0});let o=0,s=0,d=0;const g=()=>{try{return r.next()}catch(m){return f(`Local package archive is not a valid tar archive (${String(m)}).`)}},j=()=>{for(let m=g();m!==void 0;m=g())m.type==="entry"&&W(m.entry,n,i),m.type==="end"&&(d=r.position)},K=m=>{const $=o;o+=m.length,o>e.length*t&&f(a);const y=je(m);y>0&&(s=$+y),r.push(m),j()},v=ne();try{await Y(Z.from([e]),v,new Q({write(m,$,y){try{K(m),y()}catch(V){y(V)}}}))}catch(m){if(m instanceof p)throw m;f(`Local package archive is not one complete gzip stream (${String(m)}).`)}return r.end(),j(),e.subarray(v.bytesWritten).every(m=>m===0)||f("Local package archive has data after its gzip stream."),o>v.bytesWritten*t&&f(a),s>d&&f("Local package archive has tar data after its end of archive, which would not be installed."),{packageJsonEntries:i.packageJsonEntries}}async function b(e,n=le){const t=await Se(e,n.maxArchiveBytes),a=await $e(t,n),i=await l.mkdtemp(c.join(x.tmpdir(),"pm-local-package-archive-")),r=c.join(i,"extract");await l.mkdir(r,{recursive:!0});try{a.packageJsonEntries!==1&&f(`Local package archive must contain exactly one package/package.json entry; found ${a.packageJsonEntries}.`),await ae({input:t,file:e,cwd:r,strict:!0,preservePaths:!1,preserveOwner:!1,noMtime:!0,unlink:!0,maxDepth:64,maxDecompressionRatio:N});const o=c.join(r,"package"),s=c.join(o,"package.json"),d=JSON.parse(await l.readFile(s,"utf8"));return await M(o),{directory:await w(o,e),package:typeof d.name=="string"?d.name:void 0,version:typeof d.version=="string"?d.version:void 0,cleanup:async()=>{await l.rm(i,{recursive:!0,force:!0})}}}catch(o){throw await l.rm(i,{recursive:!0,force:!0}),o}}async function M(e,n=A){const t=c.join(e,"package.json");if(!await h(t))return;let a;try{a=JSON.parse(await l.readFile(t,"utf8"))}catch{return}if(typeof a!="object"||a===null)return;const i=a,r=H(i),o=J(i);if(r.length===0&&!o)return;const s={...a};delete s.devDependencies;const d={...s};T(d),await l.writeFile(t,`${JSON.stringify(d,null,2)}
|
|
4
|
+
`,"utf8");try{await Promise.all([l.rm(c.join(e,"package-lock.json"),{force:!0}),l.rm(c.join(e,"npm-shrinkwrap.json"),{force:!0})]),r.length>0&&await n(["install","--ignore-scripts","--no-audit","--fund=false","--package-lock=false","--no-save","--omit=peer","--"],e),o&&await q(e)}finally{await l.writeFile(t,`${JSON.stringify(s,null,2)}
|
|
5
|
+
`,"utf8")}}function J(e){for(const n of[e.dependencies,e.optionalDependencies,e.peerDependencies])if(typeof n=="object"&&n!==null&&k in n)return!0;return!1}function T(e){for(const n of["dependencies","optionalDependencies","peerDependencies"]){const t=e[n];if(typeof t!="object"||t===null)continue;const a={...t};delete a[k],Object.keys(a).length===0?delete e[n]:e[n]=a}}async function q(e){const n=oe(import.meta.url,["../../.."]),[t,a]=k.split("/"),i=c.join(e,"node_modules",t),r=c.join(i,a);await l.mkdir(i,{recursive:!0}),await l.rm(r,{recursive:!0,force:!0}),await l.symlink(n,r,B(process.platform))}function B(e){return e==="win32"?"junction":"dir"}function Le(e,n){if(e.startsWith("-"))throw new p(`Extension runtime dependency name "${e}" is unsafe because npm could interpret it as a command-line option.`,u.USAGE,{code:"extension_dependency_name_unsafe",required:"Use a valid npm package name that does not begin with a dash.",why:"Extension manifests are untrusted input and dependency names must never become npm options."});if([...n].some(a=>{const i=a.charCodeAt(0);return i<=31||i===127||"&|;()`\"'".includes(a)}))throw new p(`Extension runtime dependency "${e}" has an unsafe version specifier.`,u.USAGE,{code:"extension_dependency_version_unsafe",required:"Use an npm version, range, dist-tag, URL, or file specifier without shell metacharacters.",why:"npm.cmd requires a command shell on Windows, so untrusted shell metacharacters cannot be forwarded."});try{_.resolve(e,n)}catch{throw new p(`Extension runtime dependency "${e}@${n}" is not a valid npm dependency specifier.`,u.USAGE,{code:"extension_dependency_spec_invalid",required:"Use a valid npm package name and npm-supported version, range, dist-tag, URL, or file specifier.",why:"Only grammar-validated dependency specs may be written to the isolated runtime install manifest."})}return`${e}@${n}`}function H(e){const n=new Map;for(const t of[e.dependencies,e.optionalDependencies,e.peerDependencies])if(!(typeof t!="object"||t===null))for(const[a,i]of Object.entries(t)){if(a===k||typeof i!="string"||i.trim().length===0||n.has(a))continue;const r=i.trim();n.set(a,Le(a,r))}return[...n.values()]}async function w(e,n){const t=await ie(e);if(t.length===1)return t[0];if(t.length>1){const a=t.map(i=>c.relative(e,i).replaceAll(c.sep,"/")).sort((i,r)=>i.localeCompare(r));throw new p(`Package source "${n}" contains multiple extension manifests. Provide an explicit extension path. Candidates: ${a.join(", ")}`,u.USAGE)}throw new p(`Unable to locate a pm extension manifest in package source "${n}". Package installs currently activate only extension resources, so add package.json pm.extensions or an extensions/ directory. Metadata-only resources like pm.docs/pm.examples are catalog metadata and do not activate commands.`,u.USAGE)}async function Ne(e,n){const t=[];n.subpath&&(t.push(n.subpath),t.push(c.posix.join(".agents/pm/extensions",n.subpath)),t.push(c.posix.join(".custom/pm-extensions",n.subpath)),t.push(c.posix.join(".custom/pm-extension",n.subpath)));for(const i of t){const r=c.resolve(e,i);if(se(e,r)&&await h(c.join(r,"manifest.json")))return{directory:r,resolved_subpath:i}}if(await h(c.join(e,"manifest.json")))return{directory:e,resolved_subpath:"."};const a=await w(e,n.input);return{directory:a,resolved_subpath:c.relative(e,a).replaceAll(c.sep,"/")}}function Ce(e){const n=e.trim();return n.length===0||n.startsWith(".")||n.startsWith("~")?!1:n.startsWith("@")?n.split("/").length===2:!n.includes("/")&&!n.includes("\\")}async function Ue(e){const n=`Local extension source does not exist: "${e.absolute_path}".`,t=e.input.trim();if(!Ce(t))return new p(n,u.NOT_FOUND);let a=[];try{const r=process.env.PM_CLI_PACKAGE_ROOT,o=typeof r=="string"&&r.trim().length>0?c.resolve(r.trim()):"";E?.key!==o&&(E={key:o,aliases:await ce()}),a=E.aliases}catch{}const i=[`Retry with pm package install npm:${t} if the package is published to npm.`,`Or inspect bundled packages with pm package catalog --project --json before installing by alias. Known aliases (blank means none found): ${a.join(", ")}`];return new p(`${n} "${t}" did not match a local directory, bundled package alias, or bundled package name; if you meant an npm package, install it as "npm:${t}".`,u.NOT_FOUND,{code:"local_source_not_found_bare_name",required:`Use "npm:${t}" for npm registry packages, a bundled catalog alias, or an existing local directory path.`,why:"Bare names resolve as local paths only after bundled aliases, so unmatched names need an explicit npm: source.",examples:[`pm package install npm:${t}`,"pm package catalog --project --json"],nextSteps:i,recovery:{attempted_command:`pm install ${t}`,normalized_args:["install",t],next_best_command:`pm package install npm:${t}`}})}async function Ye(e){if(e.kind==="local"){let a;try{a=await l.stat(e.absolute_path)}catch{throw await Ue(e)}if(a.isFile()&&D(e.absolute_path)){const r=await b(e.absolute_path);return{source:e,directory:r.directory,source_root:c.dirname(r.directory),resolved_subpath:c.relative(c.dirname(r.directory),r.directory).replaceAll(c.sep,"/"),npm_package:r.package,npm_version:r.version,cleanup:r.cleanup}}if(!a.isDirectory())throw new p(`Local extension source must be a directory or npm .tgz/.tar.gz archive: "${e.absolute_path}".`,u.USAGE);const i=await w(e.absolute_path,e.input);return{source:e,directory:i,source_root:e.absolute_path}}if(e.kind==="npm"){const a=await z(e);return{source:e,directory:a.directory,source_root:c.dirname(a.directory),cleanup:a.cleanup,resolved_subpath:c.relative(c.dirname(a.directory),a.directory).replaceAll(c.sep,"/"),npm_package:a.package,npm_version:a.version}}const n=await l.mkdtemp(c.join(x.tmpdir(),"pm-extension-source-")),t=["clone","--depth","1"];e.ref&&t.push("--branch",e.ref),t.push(e.repository,n);try{await C(t);const a=await C(["-C",n,"rev-parse","HEAD"]),i=await Ne(n,e);return{source:e,directory:i.directory,source_root:n,resolved_subpath:i.resolved_subpath,commit:a,cleanup:async()=>{await l.rm(n,{recursive:!0,force:!0})}}}catch(a){throw await l.rm(n,{recursive:!0,force:!0}),a}}async function et(e,n){if(!await h(e)||!await h(n))return!1;const[t,a]=await Promise.all([l.realpath(e),l.realpath(n)]);return t===a}const tt={extractLocalPackageArchive:b,validateLocalPackageArchiveEntry:W,installNpmPackageRuntimeDependencies:M,npmPackageNameFromSpec:S,parsePackedNpmPackage:G,resolveNpmSourceDirectoryWithRunner:F,resolveNpmSourceDirectory:z,resolveNpmPackSpec:O,findInstalledNpmPackageCandidate:pe,resolvePackageExtensionDirectory:w,runtimeDependencyInstallSpecs:H,hasHostedPmCliDependency:J,removeHostedPmCliDependency:T,linkHostedPmCliDependency:q,resolveDirectorySymlinkType:B,runNpmCommand:A};export{tt as _testOnlyInstallSources,et as areDirectoriesEquivalent,be as buildNpmNotFoundRecovery,pe as findInstalledNpmPackageCandidate,ye as isNpmNotFoundError,we as isNpmPackNotFoundError,xe as normalizeNpmLocalFileAliasSpec,Qe as parseExtensionInstallSource,Ye as resolveInstallSource,ue as resolveNpmCommandName,C as runGitCommand,me as shouldRunNpmCommandInShell,ve as wrapNpmPackResolutionError};
|
|
6
6
|
//# sourceMappingURL=install-sources.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The native action a CLI path names (`package catalog` is `package-catalog`),
|
|
3
|
+
* else the path itself. The `packages` root is Commander's alias of `package`,
|
|
4
|
+
* so it classifies as the action the runtime dispatches.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveExpectHashAction(path:string):string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether a command path admits `--expect-hash`. A native action that never
|
|
9
|
+
* writes items refuses it (`deps` is a conditional mutation in the history
|
|
10
|
+
* inventory, but only reads), and so do a statically dispatched inventory and
|
|
11
|
+
* a read-only subcommand of a writer root.
|
|
12
|
+
* Extension and package actions stay admitted because only their handlers know
|
|
13
|
+
* whether they write.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isExpectHashAdmissibleAction(path:string):boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{PM_EXPECT_HASH_ACTIONS as i,PM_TOOL_ACTIONS as n}from"../cli-contracts/enum-contracts.js";import{STATIC_INVENTORY_COMMAND_PATHS as r}from"../cli-contracts/flag-contracts.js";import{isMutationAction as c}from"../mutation-guard.js";const s=new Set(n),a=new Set(["files lookup","item files lookup"]);function A(e){const t=e.trim().replace(/^packages(?=\s|$)/u,"package").replace(/\s+/gu,"-");return s.has(t)?t:e}function m(e){const t=e.trim().replace(/\s+/gu," ");if(r.has(t)||a.has(t))return!1;const o=A(e);return!(s.has(o)&&(!c(o)||o==="deps")&&!i.has(o))}export{m as isExpectHashAdmissibleAction,A as resolveExpectHashAction};
|
|
2
|
+
//# sourceMappingURL=expect-hash-admission.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import{bindItemRevisionScope,createItemRevisionScope,itemRevisionScopeReceipt,runWithItemRevisionScope,type ItemRevisionRecoveryInvocation,type ItemRevisionScope}from "../../core/store/item-mutation-precondition.js";import{PmCliError,type PmCliErrorDetails}from "../../core/shared/errors.js";
|
|
1
|
+
import{bindItemRevisionScope,createItemRevisionScope,itemRevisionScopeReceipt,runWithItemRevisionScope,type ItemRevisionRecoveryInvocation,type ItemRevisionScope}from "../../core/store/item-mutation-precondition.js";import{PmCliError,type PmCliErrorDetails}from "../../core/shared/errors.js";
|
|
2
|
+
/** Re-exported so presentation layers judge `--expect-hash` admission through this public module (pm-6vk110). */
|
|
3
|
+
export{isExpectHashAdmissibleAction}from "./expect-hash-admission.js";export type{ItemRevisionRecoveryInvocation,ItemRevisionScope}from "../../core/store/item-mutation-precondition.js";
|
|
2
4
|
/** Refusal code for a locked write that found a revision other than the declared one. */
|
|
3
5
|
export declare const ITEM_REVISION_CONFLICT_CODE="item_revision_conflict";
|
|
4
6
|
/** Most recent history entries a conflict refusal describes. */
|
|
@@ -141,6 +143,7 @@ export declare function itemRevisionUncheckedWarning(id:string):string;
|
|
|
141
143
|
* Refuse an expected revision on a native action that never writes items.
|
|
142
144
|
* Extension and package actions stay admitted because only their handlers
|
|
143
145
|
* know whether they write; the receipt reports any expectation they never reach.
|
|
146
|
+
* Per-command discovery reads the same predicate (pm-6vk110).
|
|
144
147
|
*/
|
|
145
148
|
export declare function assertExpectHashAdmissible(path:string,options?:Record<string,unknown>):void;
|
|
146
149
|
/** Refusal for a revision guard on a command or action that writes no items. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getActiveExtensionRegistrations as
|
|
1
|
+
import{getActiveExtensionRegistrations as S}from"../../core/extensions/index.js";import{URL_CREDENTIAL_PLACEHOLDER as b,redactUrlCredentialsInToken as T}from"../../core/shared/url-credentials.js";import{hashDocument as H}from"../../core/history/history.js";import{readHistoryEntries as N}from"../../core/history/read.js";import{resolveItemTypeRegistry as k}from"../../core/item/type-registry.js";import{bindItemRevisionScope as f,createItemRevisionScope as _,ITEM_REVISION_CONFLICT_CHANGED_REASON as O,ITEM_REVISION_CONFLICT_UNREADABLE_REASON as L,isItemRevisionRefusalFrom as U,isItemRevisionRefusalScoped as F,itemRevisionConflictGuidance as M,markItemRevisionRefusalScoped as P,retainItemRevisionRefusalTracker as l,itemRevisionScopeReceipt as g,runWithItemRevisionScope as v,activeItemRevisionExpectations as $}from"../../core/store/item-mutation-precondition.js";import{buildItemNotFoundError as D,locateItem as q,readLocatedItem as G}from"../../core/store/item-store.js";import{getHistoryPath as W,resolvePmRoot as V}from"../../core/store/paths.js";import{readSettings as j}from"../../core/store/settings.js";import{EXIT_CODE as m}from"../../core/shared/constants.js";import{PmCliError as d}from"../../core/shared/errors.js";import{isExpectHashAdmissibleAction as z,resolveExpectHashAction as B}from"./expect-hash-admission.js";import{isExpectHashAdmissibleAction as Le}from"./expect-hash-admission.js";import{resolveHistorySubject as J}from"../history/subject.js";import{resolvePhysicalItemId as K}from"../query/declared-blockers.js";import{EMPTY_CANONICAL_DOCUMENT as X}from"../../core/shared/constants.js";import{isPmCliExpectedError as Y}from"../errors.js";const w="item_revision_conflict",Q=10,R=/^[0-9a-f]{64}$/u;function p(e,i){return new d(`Invalid expected revision ${JSON.stringify(e)}: ${i}.`,m.USAGE,{code:"expect_hash_invalid",value:e,required:"Pass the 64-character item_hash from pm get <id> --json, optionally as <id>=<item_hash>.",examples:["--expect-hash <item_hash>","--expect-hash pm-a1b2=<item_hash>"]})}function I(e){const i=typeof e=="string"?e.trim().toLowerCase():"";if(!R.test(i))throw p(String(e),"the revision is not a 64-character hexadecimal item_hash");return i}function Z(e){return(e===void 0?[]:typeof e=="string"?[e]:e).flatMap(t=>{if(typeof t!="string")throw p(String(t),"expected a string");const n=t.split(",").map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw p(t,"the value is empty");const r=o=>T(t)===t?o:b;return n.map(o=>{const c=o.lastIndexOf("="),s=c===-1?void 0:o.slice(0,c).trim();if(s!==void 0&&s.length===0)throw p(r(o),"the item id before = is empty");const a=c===-1?o:o.slice(c+1);if(!R.test(a.trim().toLowerCase()))throw p(r(a),"the revision is not a 64-character hexadecimal item_hash");const h=I(a);return s===void 0?{itemHash:h}:{id:s,itemHash:h}})})}async function E(e,i){const t=await j(e),n=k(t,S()).type_to_folder,r=await q(e,i,t.id_prefix,t.item_format,n);if(r){const{document:o}=await G(r,{schema:t.schema});if(o.metadata.id!==await K(r.itemPath,r.id))throw new d(`Item file ${r.id} embeds the id ${o.metadata.id}; no revision can be bound to an item whose identity is in conflict.`,m.CONFLICT,{code:"item_identity_conflict",item_id:r.id,required:`Repair ${r.id}'s identity first (pm validate reports it; pm restore ${r.id} <version> recovers a recorded state), then read its item_hash again.`});return{id:o.metadata.id,document:o}}try{return{id:(await J(e,i,t,n)).id,document:X}}catch{throw await D(e,i,t.id_prefix,n)}}function x(e){return V(e.cwd??process.cwd(),e.pmRoot)}async function Ce(e,i={}){const t=await E(x(i),e);return{id:t.id,item_hash:H(t.document)}}async function y(e,i,t){const n=[];for(const r of i){const o=r.id??t;if(o===void 0||o.trim().length===0)throw new d("A bare expected revision needs an item to bind to.",m.USAGE,{code:"expect_hash_target_required",required:"This command has no single item argument; name each target as --expect-hash <id>=<item_hash>.",examples:["--expect-hash pm-a1b2=<item_hash>"]});n.push({id:(await E(e,o)).id,itemHash:r.itemHash})}return n}function ee(e){return[...new Set(e.patch.map(i=>{const t=i.path.split("/");return String(t[1]==="metadata"?t[2]:t[1])}))].sort()}async function te(e,i,t){let n;try{n=await N(W(e,i),i)}catch{return}let r=-1;for(let s=n.length-1;s>=0;s-=1){const a=n[s];if(a.after_hash===t){r=s+1;break}if(a.before_hash===t){r=s;break}}if(r===-1)return{expected_revision_recorded:!1,changes_since:[],changes_since_omitted:0};const o=n.slice(r),c=o.slice(-Q);return{expected_revision_recorded:!0,changes_since:c.map(s=>({ts:s.ts,op:s.op,author:s.author,fields:ee(s)})),changes_since_omitted:o.length-c.length}}async function Ae(e,i){if(!u(e))return{};const t=await C(e,i);return{error_code:w,expected_revision:String(t.context.expected_revision),current_revision:String(t.context.current_revision),details:t.context.details}}function u(e){return Y(e)&&e.context.code===w}function Se(e){const i=e.find(t=>u(t));if(i!==void 0)throw i}function be(){return new d("--expect-hash cannot guard an invocation an extension override rewrote: which item it writes is not provable.",m.USAGE,{code:"expect_hash_invocation_rewritten",required:"Run the command without the rewriting extension (--no-extensions), or drop --expect-hash.",why:"An extension parser or preflight override changed this invocation's tracker or arguments, and final dispatch, the extension SDK client and the guard do not share one rewritten view."})}function ie(e,i){if(i===void 0||!u(e)||typeof e.context.item_id!="string"||F(e))return e;const t=e.context.reason===L;if(!t&&e.context.reason!==O)return e;const n=P(l(e,new d(e.message,e.exitCode,{...e.context,...M(e.context.item_id,t,i)})));return n.stack=e.stack,n}async function C(e,i,t){if(!U(e,i))return e;const n=ie(e,t);if(!u(n)||n.context.details!==void 0)return n;const r=n.context.item_id,o=n.context.expected_revision;if(typeof r!="string"||typeof o!="string")return n;let c;try{c=await te(i,r,o)}catch{return n}if(c===void 0)return n;const s={expected_revision_recorded:c.expected_revision_recorded,changes_since:c.changes_since.map(h=>({ts:h.ts,op:h.op,author:h.author,fields:[...h.fields]})),changes_since_omitted:c.changes_since_omitted},a=l(n,new d(n.message,n.exitCode,{...n.context,details:s}));return a.stack=n.stack,a}async function A(e,i,t){try{return{result:await v(e,i),...g(e)}}catch(n){throw e.pmRoot===void 0?n:await C(n,e.pmRoot,t)}}function ne(e){return e.cwd===void 0&&e.pmRoot===void 0?void 0:{scopeArgs:["--pm-path",x(e)]}}async function Te(e,i,t={}){return A(await oe(e,t),i,ne(t))}async function oe(e,i={}){const t=x(i),n=e.map(({id:o,itemHash:c})=>({id:o,itemHash:I(c)})),r=_();return f(r,t,await y(t,n)),r}function He(e){const i=$(e);return i===void 0||i.length>0}function re(e){return`expect_hash_unchecked:${e}:no_locked_write_reached_this_item`}function se(e,i={}){const t=B(e);if(!z(e))throw ce(t);if((t==="test"||t==="test-all")&&i.background===!0)throw new d(`--expect-hash cannot guard ${t} --background: the worker runs in another process.`,m.USAGE,{code:"expect_hash_background_unsupported",required:`Run ${t} in the foreground to guard its result recording, or drop --expect-hash for a background run.`})}function ce(e){return new d(`--expect-hash guards item writes, and ${e} is not a mutation.`,m.USAGE,{code:"expect_hash_requires_mutation",required:"Use --expect-hash (MCP/SDK expectHash) only on a command or action that writes items."})}function ae(e,i){if(i.length===0||typeof e!="object"||e===null||Array.isArray(e))return e;const t=e,n=Array.isArray(t.warnings)?t.warnings:[];return{...t,warnings:[...n,...i.map(re)]}}async function Ne(e){const i=e.expectHash;if(i!==void 0&&typeof i!="string"&&!(Array.isArray(i)&&i.every(o=>typeof o=="string")))throw p(JSON.stringify(i)??String(i),"expected a string or an array of strings");const t=Z(i);if(t.length===0)return e.run();se(e.action,{background:e.background===!0||e.options?.background===!0});const n=_();f(n,e.pmRoot,await y(e.pmRoot,t,e.defaultId));const r=await A(n,e.run,e.invocation);return ae(r.result,r.unchecked)}export{Q as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,w as ITEM_REVISION_CONFLICT_CODE,se as assertExpectHashAdmissible,oe as bindExpectedItemRevisions,f as bindItemRevisionScope,_ as createItemRevisionScope,te as describeItemRevisionChanges,Ne as dispatchWithExpectedItemRevisions,C as enrichItemRevisionConflict,be as expectHashInvocationRewrittenError,ce as expectHashRequiresMutationError,Le as isExpectHashAdmissibleAction,u as isItemRevisionConflict,He as isTrackerRevisionGuarded,Ae as itemRevisionConflictRowFields,g as itemRevisionScopeReceipt,re as itemRevisionUncheckedWarning,I as normalizeExpectedItemHash,Z as parseExpectHashSpecs,Ce as readItemRevision,y as resolveExpectedItemRevisions,A as runWithBoundItemRevisionScope,v as runWithItemRevisionScope,ie as scopeItemRevisionConflict,Se as throwFirstItemRevisionConflict,Te as withExpectedItemRevisions};
|
|
2
2
|
//# sourceMappingURL=item-revision.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SECRET_RULES as
|
|
1
|
+
import{SECRET_RULES as g,acceptsStructuredValue as D,createSecretDecodedText as P,findSecretRuleMatches as I,isNumericMetadataKey as U,structuredKeyShape as L}from"../core/shared/secret-rules.js";import{EXIT_CODE as b}from"../core/shared/constants.js";import{PmCliError as E}from"../core/shared/errors.js";const K=!0,Y=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],w=new Map(Y.map(e=>[e.action,e])),G=/^(?:0|[1-9]\d*)$/u,q=2**32-2;function F(e){return G.test(e)&&Number(e)<=q}function S(e){const t=[],n=P(e);for(const o of g){const r=W(o,e,n);r&&t.push({rule:o,match:r})}return t}function X(e,t){let n=t.names.get(e);return n===void 0&&(n=S(e),t.names.set(e,n)),n}function A(e,t){let n=t.entries.get(e);return n===void 0&&(n=Array.isArray(e)?Object.getOwnPropertyNames(e).filter(F).map((o,r)=>({name:o,value:e[Number(o)],segment:`[${o}]`,nameMatches:[],position:r})):Object.entries(e).map(([o,r],s)=>{const i=X(o,t);return{name:o,value:r,segment:i.length>0?`[key ${s}]`:`.${o}`,nameMatches:i,position:s}}),t.entries.set(e,n)),n}function R({rule:e,match:t},n,o){const r={rule:e.mutationRule,path:n};return o&&(r.property_name=!0),t.normalizations&&(r.normalizations=t.normalizations),t.normalization_incomplete&&(r.normalization_incomplete=!0),r}function T(e,t){for(let n=t.length-1;n>=0;n-=1)e.push(t[n])}function W(e,t,n){try{return B(e,t,n)}catch(o){return M(o)}}function M(e){if(!(e instanceof RangeError))throw e;return{index:0,normalization_incomplete:!0}}function B(e,t,n){const o=I(e,t,{decodeStrings:!0,decoded:n}),r=o.next().value;if(!r||r.normalization_incomplete)return r;for(const s of o)if(s.normalization_incomplete)return{...r,normalizations:[...new Set([r.normalizations,s.normalizations].flatMap(i=>i??[]))],normalization_incomplete:!0};return r}function H(e,t){const n=[],o=new WeakSet,r=[{value:e,path:"$",identity:C}];for(let s=r.pop();s!==void 0;s=r.pop()){const{value:i,path:c,identity:u}=s;if(typeof i=="string")for(const l of S(i))n.push({finding:R(l,c,!1),identity:u});else if(typeof i=="object"&&i!==null&&!o.has(i)){o.add(i);const l=A(i,t);for(const a of l)for(const d of a.nameMatches)n.push({finding:R(d,`${c}${a.segment}`,!0),identity:m(t,u,a)});T(r,l.map(a=>({value:a.value,path:`${c}${a.segment}`,identity:m(t,u,a)})))}}return n}const C=0;function m(e,t,n){const o=`${t}:${n.position}`;let r=e.locations.get(o);return r===void 0&&(r=e.locations.size+1,e.locations.set(o,r)),r}const h=g.filter(e=>"structured"in e),J=h.map(()=>({named:!1,exact:!1})),j=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/gu,Z=3;function v(e){return e.replace(j,"_")}function V(e){const n=[...e.matchAll(j)].map(o=>o.index).slice(-Z).map(o=>`${v(e.slice(0,o))}_${e.slice(o)}`);return[...new Set([e,v(e),...n])]}function Q(e){const t=V(e);return h.map(n=>{const o=t.map(r=>L(n,r));return o.includes("exact")?"exact":o.includes("prefixed")?"prefixed":void 0})}const ee=h.map(()=>{});function te(e,{path:t,identity:n,contexts:o},r){const s=A(e,r);if(Array.isArray(e)){const i=o.map(({named:c,exact:u})=>u?"lenient":c?"compact":void 0);return s.map(c=>({value:c.value,path:`${t}${c.segment}`,identity:m(r,n,c),contexts:o,judgments:i,bound:!1}))}return s.map(i=>{const{name:c,value:u,segment:l}=i,a=Q(c);return{value:u,path:`${t}${l}`,identity:m(r,n,i),bound:U(c),contexts:o.map(({named:d,exact:f},p)=>({named:d||a[p]!==void 0,exact:f||a[p]==="exact"})),judgments:a.map((d,f)=>d==="exact"?"lenient":d==="prefixed"||o[f].named?"compact":void 0)}})}function ne(e){return typeof e=="string"||typeof e=="number"||typeof e=="bigint"}function oe(e,t){const n=[],o=new WeakMap,r=[{value:e,path:"$",identity:C,contexts:J,judgments:ee,bound:!1}];for(let s=r.pop();s!==void 0;s=r.pop()){const{value:i,path:c,identity:u,contexts:l,judgments:a}=s;if(ne(i)){if(s.bound&&typeof i!="string")continue;a.forEach((p,y)=>{const _=h[y];if(p===void 0)return;let O;try{O=D(_,i,p==="compact")}catch(z){M(z),n.push({finding:{rule:_.mutationRule,path:c,normalization_incomplete:!0},identity:u});return}O&&n.push({finding:{rule:_.mutationRule,path:c},identity:u})});continue}if(typeof i!="object"||i===null)continue;const d=l.map(({named:p,exact:y})=>y?"e":p?"n":"-").join(""),f=o.get(i)??new Set;f.has(d)||(o.set(i,f.add(d)),T(r,te(i,s,t)))}return n}function re(e){const t=new Map,n={entries:new WeakMap,names:new Map,locations:new Map},o=[];for(const{finding:r,identity:s}of[...H(e,n),...oe(e,n)]){const i=`${r.rule}\0${s}\0${r.property_name===!0}`,c=t.get(i);c===void 0?(t.set(i,r),o.push(r)):r.normalization_incomplete&&(c.normalization_incomplete=!0)}return o}function le(e){const t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new E("Mutation author is required by workspace policy.",b.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let n;try{n=re(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(n.length===0)return{author:t,findings:n,warnings:[],override_applied:!1};const o=[...new Set(n.map(r=>r.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new E(`Mutation blocked by secret guard (${o}). No detected value was logged.`,b.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:n,warnings:[`secret_guard_detected:${n.length}:rules=${o}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}const x=Object.freeze(Object.fromEntries(g.map(e=>[e.mutationRule,e.category])));function ie(e){return Object.hasOwn(x,e)?x[e]:void 0}function $(e,t){return e!==void 0&&t!==void 0&&Object.hasOwn(e,t)?e[t]:void 0}const k=new Set(Reflect.ownKeys(Object.prototype));function se(e){const t=Reflect.ownKeys(e);if(t.length!==k.size||!t.every(o=>k.has(o)))return!1;const n=Object.getOwnPropertyDescriptor(e,"constructor")?.value;return typeof n=="function"&&Object.getOwnPropertyDescriptor(n,"prototype")?.value===e}function ce(e){const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype?!0:Object.getPrototypeOf(t)!==null?!1:Reflect.ownKeys(t).length===0||se(t)}function N(e,t){const n=Object.hasOwn(e,t)?e[t]:void 0;if(n!==void 0&&(typeof n!="object"||n===null||!ce(n)))throw new TypeError(`Secret guard policy ${t} must be an object keyed by ${t==="rules"?"rule":"category"}.`);return n}function pe(e,t){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Secret guard policy must be an object with a default decision.");const n=Object.hasOwn(e,"default")?e.default:void 0;if(n===void 0)throw new TypeError("Secret guard policy requires a default decision.");const o=N(e,"categories"),r=N(e,"rules"),s=typeof t=="object"&&t!==null?t.rule:void 0;if(typeof s!="string")throw new TypeError("Secret guard finding must have a string rule.");const i=$(r,s);if(i!==void 0)return i;const c=$(o,ie(s));return c===void 0?n:c}function fe(e){return w.has(e.trim().toLowerCase())}function me(){return[...w.keys()].sort((e,t)=>e.localeCompare(t))}function he(e){return w.get(e.trim().toLowerCase())}export{Y as PM_MUTATION_ACTION_CONTRACTS,x as SECRET_GUARD_RULE_CATEGORIES,pe as decideSecretGuardFinding,le as evaluateMutationGuard,he as getMutationActionContract,fe as isMutationAction,me as listMutationActions,re as scanMutationSecrets,ie as secretGuardRuleCategory};
|
|
2
2
|
//# sourceMappingURL=mutation-guard.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{resolvePmHistoryOperation as
|
|
1
|
+
import{resolvePmHistoryOperation as c}from"./cli-contracts/command-aliases.js";import{PM_CORE_COMMAND_NAMES as d}from"./cli-contracts/enum-contracts.js";const m=["mutation_receipt","entity","collection","diagnostic","stream"],p=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),l=new Set(["close-many","update-many"]),u=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),f=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function o(e){if(e.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!m.includes(e.kind))throw new TypeError(`Unsupported output envelope kind: ${e.kind}`);return e}function i(e){const t=e.trim().replace(/\s+/gu," "),[n=t]=t.split(" ");return l.has(n)?o({command:t,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):p.has(n)?o({command:t,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):u.has(n)?o({command:t,kind:"collection",wrapper_key:n==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):f.has(n)?o({command:t,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):o({command:t,kind:n==="get"?"entity":"diagnostic",wrapper_key:n==="get"?"item":null,cardinality:n==="get"?"one":"none",format_flag:"--json"})}const y=d.map(e=>i(e)),_=new Map(y.map(e=>[e.command,e])),g=new Map([["files lookup",o({command:"files lookup",kind:"collection",wrapper_key:"matches",cardinality:"many",format_flag:"--json"})]]);function E(e){const t=e.trim().replace(/\s+/gu," ");if(t.length===0)throw new TypeError("command must be a non-empty command path");const n=c(t),r=g.get(n);if(r!==void 0)return{...r,command:t};const[s=t]=n.split(" "),a=_.get(s);return a?{...a,command:t}:i(t)}function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){return h(e)&&typeof e.id=="string"&&e.id.length>0&&typeof e.status=="string"&&e.status.length>0&&Number.isSafeInteger(e.changed_field_count)&&Number(e.changed_field_count)>=0&&(e.close_reason===void 0||typeof e.close_reason=="string")&&(e.deleted===void 0||typeof e.deleted=="boolean")&&(e.previous_status===void 0||typeof e.previous_status=="string")&&(e.warnings===void 0||Array.isArray(e.warnings))}function N(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(n){throw new TypeError(`Mutation receipt must be valid JSON: ${String(n)}`,{cause:n})}if(!O(t))throw new TypeError("Mutation receipt must be a flat object with top-level id, status, and changed_field_count fields");return{id:t.id,status:t.status,changedFieldCount:t.changed_field_count,...typeof t.close_reason=="string"?{closeReason:t.close_reason}:{},...typeof t.deleted=="boolean"?{deleted:t.deleted}:{},...typeof t.previous_status=="string"?{previousStatus:t.previous_status}:{},...Array.isArray(t.warnings)?{warnings:t.warnings}:{}}}export{y as PM_COMMAND_OUTPUT_ENVELOPE_CONTRACTS,m as PM_OUTPUT_ENVELOPE_KINDS,o as definePmCommandOutputEnvelope,O as isPmMutationReceipt,N as parseMutationReceipt,E as resolvePmCommandOutputEnvelope};
|
|
2
2
|
//# sourceMappingURL=output-contracts.js.map
|
|
@@ -43,7 +43,7 @@ toon_encoding?:"tabular_when_uniform";}
|
|
|
43
43
|
/** Universal selector for results carrying a {@link ReadRowContract}. */
|
|
44
44
|
export declare const PM_READ_ROW_JQ_SELECTOR=".row_contract.row_keys[] as $key | getpath($key | split(\".\")) | if type == \"array\" then .[] else if type == \"object\" then to_entries[] else empty end end";
|
|
45
45
|
/** Static row declarations shared by CLI, SDK, MCP, and package consumers. */
|
|
46
|
-
export declare const PM_READ_ROW_CONTRACTS:{readonly context:{readonly row_keys:readonly["high_level","low_level"];readonly fields:"supported";};readonly get:{readonly row_keys:readonly["children"];readonly fields:"supported";};readonly list:{readonly row_keys:readonly["items"];readonly fields:"supported";};readonly next:{readonly row_keys:readonly["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"];readonly fields:"unsupported";};readonly search:{readonly row_keys:readonly["items"];readonly fields:"supported";};readonly activity:{readonly row_keys:readonly["activity_digest","compact_activity","provenance_activity","activity"];readonly fields:"unsupported";};readonly history:{readonly row_keys:readonly["compact_history","provenance_history","history","diff"];readonly fields:"unsupported";};readonly deps:{readonly row_keys:readonly["graph.nodes","graph.edges","context.nodes","context.edges"];readonly fields:"unsupported";};readonly health:{readonly row_keys:readonly["checks"];readonly fields:"unsupported";};readonly aggregate:{readonly row_keys:readonly["groups"];readonly fields:"unsupported";};readonly duplicates:{readonly row_keys:readonly["clusters"];readonly fields:"unsupported";};readonly stats:{readonly row_keys:readonly["by_type","by_status"];readonly fields:"unsupported";};readonly comments:{readonly row_keys:readonly["comments"];readonly fields:"unsupported";};readonly notes:{readonly row_keys:readonly["notes"];readonly fields:"unsupported";};readonly learnings:{readonly row_keys:readonly["learnings"];readonly fields:"unsupported";};readonly files:{readonly row_keys:readonly["files"];readonly fields:"unsupported";};readonly docs:{readonly row_keys:readonly["docs"];readonly fields:"unsupported";};readonly validate:{readonly row_keys:readonly["checks","warnings"];readonly fields:"unsupported";};readonly contracts:{readonly row_keys:readonly["command_summaries","commands"];readonly fields:"unsupported";};};
|
|
46
|
+
export declare const PM_READ_ROW_CONTRACTS:{readonly context:{readonly row_keys:readonly["high_level","low_level"];readonly fields:"supported";};readonly get:{readonly row_keys:readonly["children"];readonly fields:"supported";};readonly list:{readonly row_keys:readonly["items"];readonly fields:"supported";};readonly next:{readonly row_keys:readonly["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"];readonly fields:"unsupported";};readonly search:{readonly row_keys:readonly["items"];readonly fields:"supported";};readonly activity:{readonly row_keys:readonly["activity_digest","compact_activity","provenance_activity","activity"];readonly fields:"unsupported";};readonly history:{readonly row_keys:readonly["compact_history","provenance_history","history","diff"];readonly fields:"unsupported";};readonly deps:{readonly row_keys:readonly["graph.nodes","graph.edges","context.nodes","context.edges"];readonly fields:"unsupported";};readonly health:{readonly row_keys:readonly["checks"];readonly fields:"unsupported";};readonly aggregate:{readonly row_keys:readonly["groups"];readonly fields:"unsupported";};readonly duplicates:{readonly row_keys:readonly["clusters"];readonly fields:"unsupported";};readonly stats:{readonly row_keys:readonly["by_type","by_status"];readonly fields:"unsupported";};readonly comments:{readonly row_keys:readonly["comments"];readonly fields:"unsupported";};readonly notes:{readonly row_keys:readonly["notes"];readonly fields:"unsupported";};readonly learnings:{readonly row_keys:readonly["learnings"];readonly fields:"unsupported";};readonly files:{readonly row_keys:readonly["files","matches"];readonly fields:"unsupported";};readonly docs:{readonly row_keys:readonly["docs"];readonly fields:"unsupported";};readonly validate:{readonly row_keys:readonly["checks","warnings"];readonly fields:"unsupported";};readonly contracts:{readonly row_keys:readonly["command_summaries","commands"];readonly fields:"unsupported";};};
|
|
47
47
|
/** Contract for a command whose output modes expose mutually exclusive row shapes. */
|
|
48
48
|
export interface ModePairedOutputProjectionContract{
|
|
49
49
|
/** Stable command name. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EXIT_CODE as
|
|
1
|
+
import{EXIT_CODE as g}from"../core/shared/constants.js";import{PmCliError as k}from"../core/shared/errors.js";import{resolvePmCommandOperation as O}from"./cli-contracts/command-aliases.js";const _=new WeakMap;function K(e,t){_.set(e,new Set(t))}const f='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',u={context:{row_keys:["high_level","low_level"],fields:"supported"},get:{row_keys:["children"],fields:"supported"},list:{row_keys:["items"],fields:"supported"},next:{row_keys:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],fields:"unsupported"},search:{row_keys:["items"],fields:"supported"},activity:{row_keys:["activity_digest","compact_activity","provenance_activity","activity"],fields:"unsupported"},history:{row_keys:["compact_history","provenance_history","history","diff"],fields:"unsupported"},deps:{row_keys:["graph.nodes","graph.edges","context.nodes","context.edges"],fields:"unsupported"},health:{row_keys:["checks"],fields:"unsupported"},aggregate:{row_keys:["groups"],fields:"unsupported"},duplicates:{row_keys:["clusters"],fields:"unsupported"},stats:{row_keys:["by_type","by_status"],fields:"unsupported"},comments:{row_keys:["comments"],fields:"unsupported"},notes:{row_keys:["notes"],fields:"unsupported"},learnings:{row_keys:["learnings"],fields:"unsupported"},files:{row_keys:["files","matches"],fields:"unsupported"},docs:{row_keys:["docs"],fields:"unsupported"},validate:{row_keys:["checks","warnings"],fields:"unsupported"},contracts:{row_keys:["command_summaries","commands"],fields:"unsupported"}},b=[{command:"activity",complete_mode:"full",omissions_by_mode:{digest:[{name:"event_rows",restore_with:"--raw"}],compact:[{name:"provenance",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}},{command:"history",complete_mode:"full",omissions_by_mode:{compact:[{name:"raw_history",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}}];function $(e,t,n){if(e&&t)throw new k(`${n} cannot be combined with --full`,g.USAGE)}function a(e,t=new Set){const n=e.filter(o=>!t.has(o.name)).map(o=>({...o}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function q(e,t){const n=b.find(s=>s.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return a([]);const o=n.omissions_by_mode[t];if(o===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return a(o)}const R=[{name:"hierarchy",restore_with:"--section hierarchy"},{name:"activity",restore_with:"--section activity"},{name:"progress",restore_with:"--section progress"},{name:"blockers",restore_with:"--section blockers"},{name:"recently_created",restore_with:"--section recently_created"},{name:"unparented",restore_with:"--section unparented"},{name:"files",restore_with:"--section files"},{name:"workload",restore_with:"--section workload"},{name:"staleness",restore_with:"--section staleness"},{name:"tests",restore_with:"--section tests"}];function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const j=new Set([void 0,"tabular_when_uniform"]),E=new Set(["collection","none"]),A=new Set(["supported","unsupported"]);function m(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function S(e){return c(e)&&typeof e.command=="string"&&e.command.trim().length>0&&E.has(e.row_kind)&&m(e.row_keys,!0)&&(e.continuation_row_keys===void 0||m(e.continuation_row_keys,!1))&&A.has(e.fields)&&j.has(e.toon_encoding)&&(e.row_kind==="collection"?e.row_keys.length>0&&typeof e.jq_selector=="string"&&e.jq_selector.trim().length>0:e.row_keys.length===0&&e.jq_selector===void 0)}const v={ancestors:["ids"],descendants:["ids"],predecessors:["ids"],successors:["ids"],paths:["paths"],impact:["affected"],audit:["findings"],communities:["communities"],redundancy:["redundant"],dominators:["bottlenecks"],slack:["rows"],centrality:["rows"],articulation:["articulation_points","bridges"],plan:["steps"]},C={context:["sections_included","high_level","low_level"],get:["item"],list:["items","projection"],next:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items","projection"],activity:["activity_digest","compact_activity","provenance_activity","activity"],history:["compact_history","provenance_history","history","diff"],deps:["tree","graph","projection"],health:["checks"],aggregate:["groups"],duplicates:["clusters"],stats:["totals","by_type","by_status"],comments:["comments"],notes:["notes"],learnings:["learnings"],files:["files","matches"],docs:["docs"],validate:["checks","warnings"],contracts:["command_summaries","commands","selected"]};function x(e){const t=e.split(/\s+/u,1)[0];return t==="graph"||t.startsWith("list-")||Object.hasOwn(u,t)?t:O(e).split(/\s+/u,1)[0]}function T(e,t){const n=x(e.trim().toLowerCase()),o=n?.startsWith("list-")?"list":n;if(o==="graph"){const r=typeof t.subcommand=="string"?t.subcommand:"";if(r.length===0)return;const i=v[r];if(i===void 0)return;const l=i.filter(p=>Array.isArray(t[p])||c(t[p]));return{command:"graph",row_kind:l.length>0?"collection":"none",row_keys:l,fields:"unsupported",...l.length>0?{jq_selector:f}:{},toon_encoding:"tabular_when_uniform"}}const s=u[o],d=C[o];return s===void 0||d===void 0||!d.some(r=>Object.hasOwn(t,r))?void 0:(()=>{const r=s.row_keys.filter(i=>{const l=i.split(".").reduce((p,w)=>c(p)?p[w]:void 0,t);return Array.isArray(l)||c(l)});return{command:o,row_kind:r.length>0?"collection":"none",row_keys:r,fields:s.fields,...r.length>0?{jq_selector:f}:{},toon_encoding:"tabular_when_uniform"}})()}function D(e){if(!c(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;const t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;const o=t.filter(r=>c(r)&&typeof r.name=="string"&&r.name.trim().length>0&&typeof r.restore_with=="string"&&r.restore_with.trim().length>0),s=n.filter(r=>typeof r=="string");if(o.length!==t.length||s.length!==n.length)return;const d=new Set(o.map(r=>r.name));if(!(d.size!==o.length||new Set(s).size!==s.length||s.some(r=>!d.has(r))))return a(o,new Set(s))}function G(e){if(!Array.isArray(e.sections_included))return;const t=a(R,new Set(e.sections_included.filter(n=>typeof n=="string")));return c(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function N(e,t,n){if(e==="dependency_provenance")return!1;const o=h(e);if(o!==void 0){const s=n[o.facet];return c(s)&&Object.hasOwn(s,o.member)}return Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&c(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&c(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function h(e){const t=e.indexOf(".");return t===-1?void 0:{facet:e.slice(0,t),member:e.slice(t+1)}}function P(e){if(!c(e.item))return;const t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],o=["body","children","claim_state","linked","schedule"],s=_.get(e),d=i=>n.includes(i)||i==="body"||i==="dependency_provenance"?t:e,r=["body",...n,...o.slice(1),...s?.has("dependency_provenance")?["dependency_provenance"]:[],...s?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[],...[...s??[]].filter(i=>h(i)!==void 0)].filter(i=>s===void 0||s.has(i)||Object.hasOwn(d(i),i)).map(i=>({name:i,restore_with:i==="blockers"?"--full":i==="dependency_provenance"?"--fields dependencies":`--fields ${i}`}));return a(r,new Set(r.flatMap(({name:i})=>N(i,d(i),e)?[i]:[])))}function y(e){if(c(e.projection))return a([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function I(e){if(!c(e.projection))return a([]);if(typeof e.projection.mode=="string")return a([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function M(e){if(!(!c(e.selected)||typeof e.selected.summary!="boolean"))return a([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function L(e,t){const n=D(t);if(n!==void 0)return n;const[o]=e.split(/\s+/u,1);if(o==="context")return G(t);if(o==="get")return P(t);if(o==="list"||o.startsWith("list-"))return y(t);if(o==="search")return y(t)??a([{name:"projection_metadata",restore_with:"--full"}]);if(o==="health")return I(t);if(o==="contracts")return M(t)}function z(e,t){if(e===void 0||!c(t))return t;const n=L(e,t),o=t.row_contract,s=S(o)?o:T(e,t),d=s!==void 0?{...t,row_contract:s}:Object.hasOwn(t,"row_contract")?Object.fromEntries(Object.entries(t).filter(([r])=>r!=="row_contract")):t;return c(d.omission_receipt)||n===void 0?d:{...d,omission_receipt:n}}export{b as PM_MODE_PAIRED_OUTPUT_PROJECTION_CONTRACTS,u as PM_READ_ROW_CONTRACTS,f as PM_READ_ROW_JQ_SELECTOR,$ as assertProjectionModeChoice,z as attachOutputOmissionReceipt,a as createOutputOmissionReceipt,S as isReadRowContract,K as registerOutputMaterialFieldGroups,q as resolveModePairedOutputOmissionReceipt,L as resolveOutputOmissionReceipt,T as resolveReadRowContract};
|
|
2
2
|
//# sourceMappingURL=output-projection.js.map
|