@unbrained/pm-cli 2026.12.1 → 2026.12.3
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 +4 -4
- package/dist/cli/expected-revisions.js +1 -1
- package/dist/cli/extension-command-help.js +4 -4
- package/dist/cli/main.js +5 -5
- package/dist/cli/runtime/invocation-rewrites.js +1 -1
- package/dist/cli/runtime-field-commands.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3ESBFEQC.js +2 -0
- package/dist/cli-bundle/chunks/chunk-46AZP5QW.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-OBPO6V7H.js → chunk-5WTBF4M4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3KEMIPKG.js → chunk-6TOZQ5BQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YYFY33T.js → chunk-AHVOEE7F.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-CQHB3ZZH.js +2 -0
- package/dist/cli-bundle/chunks/chunk-DZPOS3YT.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-OKEJ4U2I.js → chunk-E5ADC3HT.js} +65 -65
- package/dist/cli-bundle/chunks/{chunk-SY5C3U32.js → chunk-E5HO7HWP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3HKPVOAN.js → chunk-EDJ3KR2H.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XME6GIFQ.js → chunk-FWQNWPIV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CWPR234D.js → chunk-H4U3LEOD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MZZ4ZJ5Z.js → chunk-HNMED75Y.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-U7RBJGLF.js → chunk-HPCMM74Q.js} +22 -22
- package/dist/cli-bundle/chunks/{chunk-WSEIEDEK.js → chunk-ITM4AMVM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q6K7HWZ7.js → chunk-IW4A3I4N.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4YQMQOUO.js → chunk-JJ73G5UT.js} +52 -52
- package/dist/cli-bundle/chunks/chunk-L4HMFRHB.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-YSVOXCYH.js → chunk-LTQWPQ7H.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q6GLSAJY.js → chunk-MRT3ADO4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZL6J6JYT.js → chunk-PBMLIV74.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NA6D75V5.js → chunk-PJMGWJKU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-Q2HMDV56.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-OXC5KBIQ.js → chunk-RRBNCL63.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CBUC4X7Q.js → chunk-TDOF7BKO.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-UXEZXGAD.js +113 -0
- package/dist/cli-bundle/chunks/{chunk-PCDTWL6V.js → chunk-W7HA65EO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-I4SPJQQI.js → chunk-XGNUDSCG.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-AHV3CSQG.js → chunk-XKJ5NWQ7.js} +2 -2
- package/dist/cli-bundle/chunks/{field-option-collisions-BBGTV7AD.js → field-option-collisions-DXKTKW6J.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-DXEF4XBU.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-EANA7V4W.js +2 -0
- package/dist/cli-bundle/chunks/{linked-resource-value-list-E2DX52LY.js → linked-resource-value-list-5JRGUDUB.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-actor-NHN33ITJ.js → mutation-actor-S5G7FMNG.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-PGKJTCG6.js → mutation-admission-HQVNPOXV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-7S5QWDTI.js → register-list-query-SQF5PSJ4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-2F6JUBST.js → register-mutation-4AQ4CEBL.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-ET3UKPYK.js → register-operations-76P7OM4P.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-I63QTFCU.js → register-setup-T6OEOZK3.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-4ZCF74G4.js → stage-KUICZHSF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-4SCFAWAW.js → chunk-3LHBKFPD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-4DDXERKN.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-JPZGC3W4.js → chunk-4YU75CWI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TXTPAFHJ.js → chunk-5JQVPQMN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KNBGHCIP.js → chunk-5Z4DXYBZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7DOP5HEZ.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TR22GU7M.js → chunk-AX4RBJ7B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7A6SEZEY.js → chunk-BEHQCHQV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-BUIF6CMZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-E2IWEJL5.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-GBU7GKNJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-EQCQTYKO.js → chunk-K35KTBDZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VQIC3UZB.js → chunk-KNST4PGF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-P2H3GTJK.js → chunk-L2XJB5PK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-L6NOGC4N.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-VK3IE3TS.js → chunk-LWIIDPAV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6IY5CVGJ.js → chunk-M54BMYG4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6BKT6XQN.js → chunk-NEK7RX3N.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BHNBPCHP.js → chunk-OKGWIW6C.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2DGKVXFT.js → chunk-RFDSSOTZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SSX5YBDC.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OG57ESZK.js → chunk-TIEQVIFN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SQ72CVUH.js → chunk-VEUBDQDP.js} +54 -54
- package/dist/cli-bundle/focused-chunks/{chunk-2UWKU2BQ.js → chunk-WDHNPNHX.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-2C6DLUC4.js → field-option-collisions-32X7FP3H.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-GUYSVVQD.js +2 -0
- package/dist/cli-bundle/focused-chunks/{item-transaction-2K4SFLJ7.js → item-transaction-MLKHZPL7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-DJMZUIZI.js → mutation-actor-RDZJTRW2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-SDWQVVHN.js → mutation-admission-IQB6XL75.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-QBZIK3T5.js → stage-AA7LORZ2.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 +63 -63
- 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 +9 -9
- package/dist/core/extensions/loader.d.ts +8 -0
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/item/actionability.js +1 -1
- package/dist/core/output/output.js +16 -16
- package/dist/mcp/server.js +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +25 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/context-intent-contracts.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 +27 -8
- package/dist/sdk/lifecycle/expect-hash-admission.js +1 -1
- package/dist/sdk/lifecycle/item-revision.d.ts +12 -4
- package/dist/sdk/lifecycle/item-revision.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/read-output/surfaces.js +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/runtime-input.d.ts +6 -0
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.js +1 -1
- package/docs/COMMANDS.md +23 -5
- package/docs/EXTENSIONS.md +1 -1
- package/docs/SDK.md +15 -2
- 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-A5ZEMOVR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-AJLU6KLW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-C6WM6ZN4.js +0 -9
- package/dist/cli-bundle/chunks/chunk-HZZLSBIJ.js +0 -2
- package/dist/cli-bundle/chunks/chunk-L2ZSSMYY.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NRQCBUYD.js +0 -113
- package/dist/cli-bundle/chunks/chunk-QDV7S2QS.js +0 -2
- package/dist/cli-bundle/chunks/item-revision-3LENTXYF.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-66RDV7PH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HTDYNY4L.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-N64AC5G6.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-PT7RT3T6.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-QZRYGYTI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-SQMOF65W.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-T3ILWAEV.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-W4JMV7GF.js +0 -3
- package/dist/cli-bundle/focused-chunks/item-revision-723XCQPS.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{normalizeUniqueStringList as U}from"./string-lists.js";import{PM_EXPECT_HASH_ACTIONS as W,PM_TOOL_ACTIONS as h}from"./enum-contracts.js";import{TOOL_CREATE_OPTION_CONTRACTS as K,TOOL_SHARED_CREATE_UPDATE_OPTION_CONTRACTS as E,TOOL_UPDATE_OPTION_CONTRACTS as Y,TOOL_UPDATE_MANY_FILTER_OPTION_CONTRACTS as j,TOOL_CONTEXT_OPTION_CONTRACTS as G,TOOL_ACTIVITY_OPTION_CONTRACTS as H,TOOL_LIST_FILTER_OPTION_CONTRACTS as $,TOOL_AGGREGATE_OPTION_CONTRACTS as B,TOOL_SEARCH_FILTER_OPTION_CONTRACTS as z,TOOL_CLOSE_MANY_FILTER_OPTION_CONTRACTS as J}from"./tool-option-contracts.js";import{PM_TOOL_PARAMETER_PROPERTIES as R,PM_TOOL_PARAMETER_METADATA as V,PM_TOOL_ACTION_SCOPED_PARAMETER_PROPERTIES as X,PM_TOOL_ACTION_SCOPED_PARAMETER_METADATA as Z,PLAN_ACTION_PARAMETER_PROPERTIES as _,PLAN_ACTION_PARAMETER_METADATA as g}from"./tool-parameter-tables.js";import{toUniqueFlagContracts as Q,withFlagAliasMetadata as ee}from"./flag-contracts.js";import{resolveReadOutputSurface as te}from"../read-output-contracts.js";import{CREATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS as re,UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS as oe}from"./commander-mutation-options.js";const ae={...X,"history-attest":{verify:{type:"object",additionalProperties:!0},output:{not:{}}}},y={...R,pause:{type:"boolean"},handoff:{type:"string"},releaseAssignment:{type:"boolean"},hashAlgorithm:{type:"string",enum:["sha256","sha512"]}},u={...V,pause:{description:"Return work to its configured open status before releasing ownership."},handoff:{description:"Release into a configured non-terminal queue with a required evidence message."},releaseAssignment:{description:"Release assignment after recording closure evidence."},hashAlgorithm:{description:"Digest for detached history bundles; defaults to sha256."}},ne=["json","quiet","profile","noExtensions","noPager","tokenAccounting","path","pmExecutable","timeoutMs"],ie=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor","outputRowContract"],se=new Set(["action","cwd","options",...Object.keys(y).filter(e=>e!=="severity")]);function ke(e){const t=e.trim().toLowerCase();let r="";for(let o=0;o<t.length;o+=1){const a=t[o];if(a!=="-"&&a!=="_"){r+=a;continue}let n=o+1;for(;t[n]==="-"||t[n]==="_";)n+=1;const i=t[n];if(i!==void 0&&(i>="a"&&i<="z"||i>="0"&&i<="9")){r+=i.toUpperCase(),o=n;continue}r+=t.slice(o,n),o=n-1}return se.has(r)?{field:e,property:r,owner:"mcp_tool_input",nested_path:r==="expectHash"?`options.field (${e}=<value>)`:`options.${r}`}:void 0}const le={create:["fullChangedFields","idOnly"],copy:["fullChangedFields","idOnly"],update:["fullChangedFields","idOnly"],"item-reopen":["fullChangedFields","idOnly"],close:["fullChangedFields","idOnly"],claim:["fullChangedFields","idOnly"],release:["fullChangedFields","idOnly"],"start-task":["fullChangedFields","idOnly"],"pause-task":["fullChangedFields","idOnly"],"close-task":["fullChangedFields","idOnly"],restore:["fullChangedFields","idOnly"],append:["fullChangedFields"],"update-many":["fullChangedFields"],"close-many":["fullChangedFields"],assurance:["fullChangedFields","idOnly"]},de=["createMode","status","deadline","estimate","acceptanceCriteria","definitionOfReady","order","rank","goal","objective","value","impact","outcome","whyNow","assignee","reviewer","risk","confidence","sprint","release","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact","comment","note","learning","reminder","event","typeOption"],ce=Object.freeze({"close-many":["list","expected_result","expected","actual_result","actual","validate_close","dry_run","checkpoint","no_checkpoint","filterAssignee_filter"],"update-many":["list","update","dry_run","checkpoint","no_checkpoint","filterAssignee_filter"],...Object.fromEntries(h.filter(e=>e==="upgrade"||e==="install"||e==="extension"||e==="package"||e.startsWith("extension-")||e.startsWith("package-")).map(e=>[e,["project","local","global"]]))});function s(e){return U(e)}const pe=s([...K.map(e=>e.param),...E.map(e=>e.param)]),v=s([...Y.map(e=>e.param),...E.map(e=>e.param),"force"]),ue=s([...j.map(e=>e.param),...v.filter(e=>e!=="allowMissingParent"&&e!=="completedAt"),"dryRun","rollback","noCheckpoint"]),me=s([...J.map(e=>e.param),"reason","completedAt","resolution","expectedResult","actualResult","validateClose","dryRun","rollback","noCheckpoint","author","message","force"]),C=s([...G.map(e=>e.param),"past","section"]),fe=s([...H.map(e=>e.param),"stream"]),A=s([...$.map(e=>e.param),"all","includeBody","noTruncate","strictRead","compact","brief","full"]),c=A.filter(e=>e!=="all"&&e!=="status"),d=[[{property:"today",schema:{const:!0}},{property:"recent",schema:{const:!0}}],[{property:"today",schema:{const:!0}},{property:"updatedAfter",schema:{type:"string",pattern:"\\S"}}],[{property:"recent",schema:{const:!0}},{property:"updatedAfter",schema:{type:"string",pattern:"\\S"}}]],ye=[[{property:"summary",schema:{const:!0}},{property:"schemaOnly",schema:{const:!0}}],[{property:"summary",schema:{const:!0}},{property:"flagsOnly",schema:{const:!0}}],[{property:"summary",schema:{const:!0}},{property:"availabilityOnly",schema:{const:!0}}],[{property:"schemaOnly",schema:{const:!0}},{property:"flagsOnly",schema:{const:!0}}],[{property:"schemaOnly",schema:{const:!0}},{property:"availabilityOnly",schema:{const:!0}}],[{property:"flagsOnly",schema:{const:!0}},{property:"availabilityOnly",schema:{const:!0}}]],Oe=s([...B.map(e=>e.param),"count","completion","includeUnparented"]),he=s(["query","keywords","mode","semantic","hybrid","includeLinked","titleExact","phraseExact","highlight","compact","full",...z.map(e=>e.param)]),P=s(["type","tag","priority","assignee","assigneeFilter","sprint","release","parent","limit","blockedLimit","readyOnly","format","includeDecisions","includeGates","includeContainers","tokenBudget","explainRanking"]),l=["author","message","force"],Ae=["releaseAssignment","text","reason","closeReason","completedAt","duplicateOf","validateClose","resolution","expectedResult","actualResult"],m=["author","assignee","message","force"],Te=["dryRun","target","scope","capability","declarative","github","ref","init","install","uninstall","explore","manage","offline","describe","markdown","output","reload","doctor","catalog","list","adopt","adoptAll","activate","deactivate","runtimeProbe","fixManagedState","isolated","ignoreGlobal","detail","trace","watch","strictExit","failOnWarn","fields"];function b(e){return{[`${e}-init`]:{required:["target"],optional:["scope","capability",...e==="package"?["declarative"]:[]]},[`${e}-install`]:{optional:["target","github","scope","ref","dryRun"],anyOfRequired:[["target"],["github"]]},[`${e}-uninstall`]:{required:["target"],optional:["scope"]},[`${e}-explore`]:{optional:["scope","fields"]},[`${e}-manage`]:{optional:["scope","runtimeProbe","fixManagedState","offline","fields"]},[`${e}-describe`]:{optional:["target","scope","markdown","output"]},[`${e}-reload`]:{optional:["scope","watch"]},[`${e}-doctor`]:{optional:["scope","detail","trace","fixManagedState","isolated","ignoreGlobal","strictExit","failOnWarn"]},[`${e}-catalog`]:{optional:["scope","fields"]},[`${e}-adopt`]:{required:["target"],optional:["scope","github","ref"]},[`${e}-adopt-all`]:{optional:["scope"]},[`${e}-activate`]:{required:["target"],optional:["scope"]},[`${e}-deactivate`]:{required:["target"],optional:["scope"]},[e]:{optional:Te,dependentAnyOfRequired:[{property:"dryRun",value:!0,anyOfRequired:[["install","target"],["install","github"]]}],mutuallyExclusiveWhen:[[{property:"dryRun",schema:{const:!0}},{property:"install",schema:{const:!1}}]]}}}const S={required:["title"],optional:["start","duration","end","location","timezone","allDay","parent","inheritFocus","allowMissingParent","tags","priority","body","description","author","message"]},q={optional:["target","scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"]},f={init:{optional:["prefix","idPrefix","workspace","preset","typePreset","defaults","author","agentGuidance","withPackages","mergeFence","force","verbose"]},config:{required:["scope","configAction"],optional:["key","value","criterion","clearCriteria","format","policy"]},...b("extension"),...b("package"),"package-upgrade":q,install:{optional:["target","github","scope","ref","dryRun"],anyOfRequired:[["target"],["github"]]},upgrade:q,create:{required:["title","description","type","status","priority","message"],optional:pe},copy:{required:["id"],optional:["title","author","message","allowDuplicate"]},focus:{optional:["id","clear"],mutuallyExclusive:[["id","clear"]]},list:{optional:A,mutuallyExclusiveWhen:d},"list-all":{optional:A,mutuallyExclusiveWhen:d},"list-draft":{optional:c,mutuallyExclusiveWhen:d},"list-open":{optional:c,mutuallyExclusiveWhen:d},"list-in-progress":{optional:c,mutuallyExclusiveWhen:d},"list-blocked":{optional:c,mutuallyExclusiveWhen:d},"list-closed":{optional:c,mutuallyExclusiveWhen:d},"list-canceled":{optional:c,mutuallyExclusiveWhen:d},aggregate:{optional:Oe},guide:{optional:["list","format","depth"]},context:{optional:C},ctx:{optional:C},get:{required:["id"],optional:["for","tokenBudget","at","depth","full","fields","tree","treeDepth","format"]},search:{optional:he,anyOfRequired:[["query"],["keywords"]]},eval:{optional:["mode","k","failUnder","queries","format"]},events:{optional:["verify","since","type","author","item","limit","full","provenance","provenanceSummary","harness","agentInstance","provenanceFilter","cursorMode"]},merge:{required:["subcommand"],optional:["dryRun","preCommitHook","stage","author","message","force","includeReconciled","artifact","basePath","oursPath","theirsPath","output","outputPath","itemPath","prefer"]},workspace:{required:["subcommand"],optional:["snapshotAction","name","target","dryRun","force","author","message","lockTtlSeconds","lockWaitMs"],conditionalRequired:[{property:"subcommand",value:"snapshot",required:["snapshotAction"]}]},meet:S,event:S,remind:{required:["title"],optional:["at","text","parent","inheritFocus","allowMissingParent","tags","priority","body","description","author","message"]},next:{optional:[...P,"for"]},reindex:{optional:["mode","progress"]},history:{required:["id"],optional:["limit","order","compact","full","provenance","provenanceSummary","harness","agentInstance","provenanceFilter","diff","verify","field","strictExit","failOnWarn","format"]},"history-attest":{optional:["verify","output","hashAlgorithm"],mutuallyExclusive:[["verify","hashAlgorithm"]]},"history-redact":{required:["id"],optional:["literal","regex","replacement","dryRun",...l],anyOfRequired:[["literal"],["regex"]]},"history-repair":{optional:["id","all","dryRun","normalizeProvenance","salvageTail","appendOnly",...l],oneOfRequired:[["id"],["all"]],mutuallyExclusiveWhen:[[{property:"appendOnly",schema:{const:!0}},{property:"salvageTail",schema:{const:!0}}],[{property:"appendOnly",schema:{const:!0}},{property:"normalizeProvenance",schema:{const:!0}}],[{property:"salvageTail",schema:{const:!0}},{property:"all",schema:{const:!0}}],[{property:"salvageTail",schema:{const:!0}},{property:"normalizeProvenance",schema:{const:!0}}]]},"history-author-acknowledge":{optional:["historyEvent","allActionable","dryRun","planFingerprint","limit","attributedAuthor","reviewer","reason"],oneOfRequired:[["historyEvent"],["allActionable"]]},"history-compact":{optional:["id","before","ids","allOver","closed","allStreams","minEntries","dryRun",...l]},schema:{mutuallyExclusiveWhen:[[{property:"subcommand",schema:{const:"policy-mode"}},{property:"name",schema:{not:{enum:["advise","refuse"]}}}]],required:["subcommand"],optional:["definition","policy","message","name","description","defaultStatus","folder","alias","role","order","fieldType","commands","cliFlag","required","requiredOnCreate","allowUnset","requiredTypes","typePreset","infer","minCount","apply","to","migrationId","fieldTypeScope","dryRun","author","force"],conditionalRequired:[{property:"subcommand",value:"policy-put",required:["definition"]},{property:"subcommand",value:"policy-remove",required:["name"]},{property:"subcommand",value:"policy-mode",required:["name"]},{property:"subcommand",value:"policy-check",required:["name"]},{property:"subcommand",value:"policy-approve",required:["name","policy"]},{property:"subcommand",value:"show",required:["name"]},{property:"subcommand",value:"show-status",required:["name"]},{property:"subcommand",value:"add-type",required:["name"]},{property:"subcommand",value:"remove-type",required:["name"]},{property:"subcommand",value:"add-status",required:["name"]},{property:"subcommand",value:"remove-status",required:["name"]},{property:"subcommand",value:"add-field",required:["name"]},{property:"subcommand",value:"remove-field",required:["name"]},{property:"subcommand",value:"show-field",required:["name"]},{property:"subcommand",value:"rename-type",required:["name","to"]},{property:"subcommand",value:"rename-field",required:["name","to"]},{property:"subcommand",value:"remap-status",required:["name","to"]},{property:"subcommand",value:"apply-preset",required:["typePreset"]}]},profile:{required:["subcommand"],optional:["name","dryRun","author","force"],conditionalRequired:[{property:"subcommand",value:"show",required:["name"]},{property:"subcommand",value:"apply",required:["name"]},{property:"subcommand",value:"lint",required:["name"]}]},plan:{required:["subcommand"],optional:["id","stepRef","reorderTo","title","description","template","scope","parent","inheritFocus","related","blocks","blockedBy","harness","mode","resumeContext","tags","priority",...de,"body","claim","fromSearch","stepTitle","step","stepBody","stepOwner","stepStatus","stepEvidence","stepBlockedReason","stepReplacement","dependsOn","link","linkKind","linkNote","promoteToItemDep","allowMultipleActive","file","test","doc","decisionText","decision","decisionRationale","decisionEvidence","discoveryText","discovery","validationText","validation","validationCommand","validationExpected","depth","fields","steps","materializeType","materializeParent","materializeTags","field",...l]},activity:{optional:fe},restore:{required:["id","target"],optional:l},update:{required:["id"],optional:v,mutuallyExclusive:[["acceptanceCriteria","addAc"],["acceptanceCriteria","removeAc"]]},"update-many":{optional:ue,mutuallyExclusive:[["acceptanceCriteria","addAc"],["acceptanceCriteria","removeAc"]]},close:{required:["id"],optional:[...Ae,...l]},"close-many":{optional:me},delete:{required:["id"],optional:["dryRun",...l]},append:{required:["id","body"],optional:l},comments:{required:["id"],optional:["text","add","stdin","edit","delete","limit","full","ifAbsent","expectAt",...l],mutuallyExclusive:[["edit","ifAbsent"],["delete","ifAbsent"],["expectAt","ifAbsent"]]},notes:{required:["id"],optional:["text","add","addJson","stdin","edit","delete","limit","since","eventType","includeMeta","full","ifAbsent","expectAt",...l],mutuallyExclusive:[["addJson","add"],["addJson","stdin"],["addJson","file"],["addJson","edit"],["addJson","delete"],["edit","ifAbsent"],["delete","ifAbsent"],["expectAt","ifAbsent"]]},learnings:{required:["id"],optional:["text","add","stdin","edit","delete","limit","full","ifAbsent","expectAt",...l],mutuallyExclusive:[["edit","ifAbsent"],["delete","ifAbsent"],["expectAt","ifAbsent"]]},files:{required:[],optional:["id","add","addGlob","remove","migrate","list","addNote","noteConflict","discover","apply","discoveryNote","appendStable","validatePaths","full","lookupPath","scope","limit","offset","noTruncate","strictRead","explain","lines","decisionDepth",...l],anyOfRequired:[["id"],["lookupPath"]],dependentAnyOfRequired:[{property:"addNote",anyOfRequired:[["add"],["addGlob"]]},{property:"noteConflict",anyOfRequired:[["add"],["addGlob"]]}]},docs:{required:["id"],optional:["add","addGlob","remove","migrate","addNote","noteConflict","list","validatePaths","full",...l],dependentAnyOfRequired:[{property:"addNote",anyOfRequired:[["add"],["addGlob"]]},{property:"noteConflict",anyOfRequired:[["add"],["addGlob"]]}]},deps:{required:["id"],optional:["format","maxDepth","collapse","summary","full","nodeLimit","edgeLimit","tokenBudget","cursor","direction","kind"]},graph:{required:["subcommand"],optional:["id","target","kind","maxDepth","limit","after","direction","maxPaths","sample","exemptIsolate","exemptIsolateType","saveBaseline","rebuild","clear","summary","full"]},test:{required:["id"],optional:["list","add","addJson","remove","removeIndex","update","updateIndex","setJson","run","match","onlyIndex","onlyLast","full","background","timeout","progress","envSet","envClear","sharedHostSafe","pmContext","overrideLinkedPmContext","workspaceContext","overrideLinkedWorkspaceContext","allowUntrustedLinkedTests","acknowledgeLinkedTests","failOnContextMismatch","failOnSkipped","failOnEmptyTestRun","requireAssertionsForPm","checkContext","fullOutput","autoPmContext","measure","metricBelow","metricDiff",...l],dependentAnyOfRequired:[{property:"update",anyOfRequired:[["setJson"]]},{property:"updateIndex",anyOfRequired:[["setJson"]]},{property:"setJson",anyOfRequired:[["update"],["updateIndex"]]}],mutuallyExclusive:[["update","updateIndex"],["acknowledgeLinkedTests","run"],["acknowledgeLinkedTests","background"]]},"test-all":{optional:["status","limit","offset","background","timeout","progress","envSet","envClear","sharedHostSafe","pmContext","overrideLinkedPmContext","workspaceContext","overrideLinkedWorkspaceContext","allowUntrustedLinkedTests","failOnContextMismatch","failOnSkipped","failOnEmptyTestRun","requireAssertionsForPm","checkContext","fullOutput","autoPmContext"]},telemetry:{optional:["subcommand","limit"]},"test-runs-list":{optional:["status","limit"]},"test-runs-status":{required:["runId"]},"test-runs-logs":{required:["runId"],optional:["stream","tail"]},"test-runs-stop":{required:["runId"],optional:["force"]},"test-runs-resume":{required:["runId"],optional:["author"]},stats:{optional:["includeEmpty","storage","metadataCoverage","fieldUtilization","byAssignee","byTag","byPriority","tagPrefix","measurements","metric","measurementLimit","observe","improvementDirection","measurementSource","measurementItem","measurementRevision","author","message","provenanceCoverage","fleetAttribution","since","eventLimit","minimumSample"]},duplicates:{optional:["status","since","threshold","limit","exhaustive"]},health:{optional:["strictDirectories","requireMergeDrivers","strictExit","failOnWarn","checkOnly","checkTelemetry","noRefresh","refreshVectors","verboseStaleItems","verboseAuthorEvents","brief","summary","skipVectors","skipIntegrity","skipDrift","full"]},validate:{optional:["checkCompleteness","checkStorageIntegrity","checkMetadata","metadataProfile","checkResolution","checkLifecycle","checkStaleBlockers","dependencyCycleSeverity","parentCycleSeverity","checkFiles","scanMode","includePmInternals","verboseFileLists","verboseDiagnostics","allAffectedIds","strictExit","failOnWarn","fixHints","autoFix","dryRun","fixScope","pruneMissing","checkHistoryDrift","checkCommandReferences","counts","full"]},assurance:{required:["subcommand"],optional:["kind","id","definition","trigger","treeId","gate","limit","dryRun","author","message","preset","owner","apply","enforcement"],conditionalRequired:[{property:"subcommand",value:"list",required:["kind"]},{property:"subcommand",value:"show",required:["kind","id"]},{property:"subcommand",value:"put",required:["kind","id","definition"]},{property:"subcommand",value:"remove",required:["kind","id"]},{property:"subcommand",value:"run",required:["id","trigger"]},{property:"subcommand",value:"apply",required:["preset","owner"]},{property:"subcommand",value:"derive",required:["owner"]},{property:"subcommand",value:"risk",required:["definition"]},{property:"subcommand",value:"lineages",required:["definition"]},{property:"subcommand",value:"promote",required:["id","enforcement"]}],mutuallyExclusiveWhen:[[{property:"subcommand",schema:{const:"risk"}},{property:"definition",schema:{not:{required:["policy","change"]}}}],[{property:"subcommand",schema:{const:"lineages"}},{property:"definition",schema:{anyOf:[{required:["change"]},{not:{required:["policy"]}}]}}]]},gc:{optional:["dryRun","gcScope"]},contracts:{optional:["contractAction","command","summary","schemaOnly","flagsOnly","availabilityOnly","runtimeOnly","activeOnly","full"],mutuallyExclusiveWhen:ye},completion:{required:["shell"],optional:["eagerTags"]},claim:{optional:["start","id","next","ifAvailable","takeoverStale","maxAttempts","includeDecisions",...P,...m],oneOfRequired:[["id"],["next"]],mutuallyExclusiveWhen:[[{property:"start",schema:{const:!0}},{property:"ifAvailable",schema:{const:!0}},{property:"id",schema:{type:"string"}}],[{property:"takeoverStale",schema:{const:!0}},{property:"force",schema:{const:!0}}],[{property:"takeoverStale",schema:{const:!0}},{property:"next",schema:{const:!0}}]]},release:{required:["id"],optional:["pause","handoff",...m],dependentAnyOfRequired:[{property:"handoff",anyOfRequired:[["message"]]}],mutuallyExclusiveWhen:[[{property:"pause",schema:{const:!0}},{property:"handoff",schema:{type:"string"}}]]},"start-task":{required:["id"],optional:[...m,"takeoverStale"],mutuallyExclusiveWhen:[[{property:"takeoverStale",schema:{const:!0}},{property:"force",schema:{const:!0}}]]},"pause-task":{required:["id"],optional:m},"close-task":{required:["id"],optional:["text","validateClose",...m]},"item-reopen":{required:["id","reason"],optional:["status","expectedResult","author","message","force"]}},Le=Object.freeze(Object.fromEntries(h.map(e=>[e,f[e]])));function x(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").trim().replace(/^./,t=>t.toUpperCase()).concat(".")}function M(e,t){const r=typeof t=="object"&&t!==null?{...t}:{},o=u[e];return{...r,description:o?.description??x(e),...o?.examples?{examples:o.examples}:{}}}function Ee(e,t){if(e==="history-attest"&&t==="verify")return{description:"Compare all retained history streams with a detached JSON proof object. Server-local proof paths are not accepted over MCP."};if(e==="history-attest"&&t==="output")return{description:"Local CLI/SDK only. MCP rejects this field; save the returned JSON bundle on the client."};if(e==="claim"&&t==="start")return{description:"Move the claimed item to its configured in-progress status; with next, the selected item is claimed and started in one locked write."};if((e==="list"||e.startsWith("list-"))&&t==="all")return{description:"Return items from every lifecycle status instead of the default active-status set."};if(e==="plan"&&Object.prototype.hasOwnProperty.call(g,t))return g[t];const r=Z[e];return r&&Object.prototype.hasOwnProperty.call(r,t)?r[t]:u[t]}function I(e,t,r){const o=typeof r=="object"&&r!==null?{...r}:{},a=Ee(e,t);return{...o,description:a?.description??x(t),...a?.examples?{examples:a.examples}:{}}}function Re(e,t){if(e==="claim"&&t==="start")return{type:"boolean"};const r=ae[e];return r&&Object.prototype.hasOwnProperty.call(r,t)?r[t]:e==="plan"&&Object.prototype.hasOwnProperty.call(_,t)?_[t]:(e==="get"||e==="history"||e==="search")&&t==="format"?{type:"string",enum:["json","toon"]}:t==="pause"||t==="handoff"||t==="releaseAssignment"||t==="hashAlgorithm"?y[t]:R[t]}function _e(e,t){const r={action:{const:e,description:u.action?.description??"Tool action to execute."}};for(const o of t){if(o==="action")continue;const a=Re(e,o);a&&(r[o]=I(e,o,a))}return r}function ge(e,t){const r=t.flat();return t.map(o=>{const a=r.filter(n=>!o.includes(n));return{required:[...o],...a.length>0?{not:{anyOf:a.map(n=>({required:[n]}))}}:{},...e==="history-repair"&&o.includes("all")?{properties:{all:{const:!0}}}:e==="claim"&&o.includes("next")?{properties:{next:{const:!0}}}:{}}})}function N(e,t){return{...t===void 0?{}:{properties:{[e]:{const:t}}},required:[e]}}function ve(e){const t=[];if(e.conditionalRequired&&e.conditionalRequired.length>0)for(const r of e.conditionalRequired)t.push({if:N(r.property,r.value),then:{required:r.required}});if(e.dependentAnyOfRequired&&e.dependentAnyOfRequired.length>0)for(const r of e.dependentAnyOfRequired)t.push({if:N(r.property,r.value),then:{anyOf:r.anyOfRequired.map(o=>({required:[...o]}))}});if(e.mutuallyExclusive&&e.mutuallyExclusive.length>0)for(const r of e.mutuallyExclusive)t.push({not:{required:s(r)}});if(e.mutuallyExclusiveWhen&&e.mutuallyExclusiveWhen.length>0)for(const r of e.mutuallyExclusiveWhen)t.push({not:{allOf:r.map(o=>({properties:{[o.property]:o.schema},required:[o.property]}))}});return t}function k(e){if(!Object.prototype.hasOwnProperty.call(f,e))return;const t=f[e],r=le[e]??[];return s(["action",...ne,...te(e)!==void 0?ie:[],...r,...W.has(e)?["expectHash"]:[],...t.required??[],...t.optional??[]])}function we(e){const t=k(e);if(t===void 0)return;const r=e==="create"?re:e==="update"?oe:[];return s([...t,...r.flatMap(({keys:o,target:a})=>[a,...o]),...ce[e]??[]])}function T(e){const t=f[e],r=s(t.required??[]),o=k(e),a={type:"object",additionalProperties:!1,required:["action",...r],title:`pm action "${e}" parameters`,properties:_e(e,o)};t.anyOfRequired&&t.anyOfRequired.length>0&&(a.anyOf=t.anyOfRequired.map(i=>({required:[...i]}))),t.oneOfRequired&&t.oneOfRequired.length>0&&(a.oneOf=ge(e,t.oneOfRequired));const n=ve(t);return n.length>0&&(a.allOf=n),a}function De(e,t={}){const r=T(e),o={...r.properties};delete o.action;const a=[...r.anyOf??[],...r.oneOf??[]],n=(t.required??r.required.map(String)).filter(p=>p==="action"?!1:t.required===void 0?!0:!a.some(O=>O.required?.map(String).includes(p))),i={type:"object",additionalProperties:t.additionalProperties??!0,properties:{...o,options:{type:"object",additionalProperties:!0,description:"Advanced command options forwarded to the selected pm action."},...t.properties},required:n};return r.anyOf!==void 0&&(i.anyOf=r.anyOf),r.oneOf!==void 0&&(i.oneOf=r.oneOf),r.allOf!==void 0&&(i.allOf=r.allOf),i}function L(e){let t;const r=()=>t??=e();return new Proxy({},{get:(o,a)=>r()[a],has:(o,a)=>a in r(),ownKeys:()=>Reflect.ownKeys(r()),getOwnPropertyDescriptor:(o,a)=>{const n=Reflect.getOwnPropertyDescriptor(r(),a);return n&&(n.configurable=!0),n}})}const w="4.28.1",Ce=w.split(".")[0],Pe="1.12.0",Fe=L(()=>({$schema:"https://json-schema.org/draft/2020-12/schema",$id:`https://schema.unbrained.dev/pm-cli/tool-parameters-v${Ce}.schema.json`,title:"pm-cli tool parameters (action-scoped strict schema)","x-schema-version":w,type:"object",oneOf:h.map(e=>T(e))}));function D(e,t){const r=M(e,t);if(typeof r.type=="string")return r;const a=(Array.isArray(r.anyOf)?r.anyOf:[]).find(p=>typeof p.type=="string");if(a){const{anyOf:p,...O}=r;return{...a,...O}}const{anyOf:n,...i}=r;return{...i,type:"string"}}function F(){const e={action:{type:"string",description:u.action?.description??"Tool action to execute."},options:{type:"object",additionalProperties:!0,description:"Advanced command options object forwarded to the selected pm action."}};for(const t of Object.keys(y).sort())e[t]=D(t,y[t]);return{title:"pm-cli tool parameters (provider-compatible flat schema)","x-schema-version":Pe,type:"object",additionalProperties:!1,required:["action"],properties:e}}const Ue=L(F),We={buildActionScopedToolSchema:T,buildProviderCompatibleToolSchema:F,decorateActionScopedToolParameterDefinition:I,decorateToolParameterDefinition:M,toolActionSchemaContracts:f,toolParameterMetadata:u,toProviderCompatibleParameterDefinition:D,toUniqueFlagContracts:Q,withFlagAliasMetadata:ee};export{Ae as CLOSE_ACTION_OPTION_KEYS,de as PLAN_CREATE_METADATA_PARAMETER_KEYS,Ue as PM_PROVIDER_TOOL_PARAMETERS_SCHEMA,Pe as PM_PROVIDER_TOOL_PARAMETERS_SCHEMA_VERSION,Le as PM_TOOL_ACTION_PARAMETER_CONTRACTS,Fe as PM_TOOL_PARAMETERS_SCHEMA,Ce as PM_TOOL_PARAMETERS_SCHEMA_MAJOR,w as PM_TOOL_PARAMETERS_SCHEMA_VERSION,se as PM_TOOL_RESERVED_CUSTOM_FIELD_PROPERTIES,We as _testOnlyCliContracts,De as buildPmActionToolInputSchema,we as pmToolActionNestedOptionKeys,k as pmToolActionParameterKeys,ke as resolvePmToolCustomFieldCollision};
|
|
1
|
+
import{normalizeUniqueStringList as W}from"./string-lists.js";import{PM_EXPECT_HASH_ACTIONS as Y,PM_EXPECT_HASH_CONDITIONAL_ACTIONS as G,PM_EXPECT_HASH_HANDLER_DECIDED_ACTIONS as $,PM_EXPECT_HASH_SCHEMA_SUBCOMMANDS as B,PM_TOOL_ACTIONS as h}from"./enum-contracts.js";import{TOOL_CREATE_OPTION_CONTRACTS as V,TOOL_SHARED_CREATE_UPDATE_OPTION_CONTRACTS as _,TOOL_UPDATE_OPTION_CONTRACTS as z,TOOL_UPDATE_MANY_FILTER_OPTION_CONTRACTS as J,TOOL_CONTEXT_OPTION_CONTRACTS as X,TOOL_ACTIVITY_OPTION_CONTRACTS as Z,TOOL_LIST_FILTER_OPTION_CONTRACTS as Q,TOOL_AGGREGATE_OPTION_CONTRACTS as ee,TOOL_SEARCH_FILTER_OPTION_CONTRACTS as te,TOOL_CLOSE_MANY_FILTER_OPTION_CONTRACTS as re}from"./tool-option-contracts.js";import{PM_TOOL_PARAMETER_PROPERTIES as R,PM_TOOL_PARAMETER_METADATA as oe,PM_TOOL_ACTION_SCOPED_PARAMETER_PROPERTIES as ae,PM_TOOL_ACTION_SCOPED_PARAMETER_METADATA as ne,PLAN_ACTION_PARAMETER_PROPERTIES as g,PLAN_ACTION_PARAMETER_METADATA as C}from"./tool-parameter-tables.js";import{toUniqueFlagContracts as ie,withFlagAliasMetadata as se}from"./flag-contracts.js";import{resolveReadOutputSurface as le}from"../read-output-contracts.js";import{CREATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS as pe,UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS as de}from"./commander-mutation-options.js";const ce={...ae,"history-attest":{verify:{type:"object",additionalProperties:!0},output:{not:{}}}},f={...R,pause:{type:"boolean"},handoff:{type:"string"},releaseAssignment:{type:"boolean"},hashAlgorithm:{type:"string",enum:["sha256","sha512"]}},u={...oe,pause:{description:"Return work to its configured open status before releasing ownership."},handoff:{description:"Release into a configured non-terminal queue with a required evidence message."},releaseAssignment:{description:"Release assignment after recording closure evidence."},hashAlgorithm:{description:"Digest for detached history bundles; defaults to sha256."}},ue=["json","quiet","profile","noExtensions","noPager","tokenAccounting","path","pmExecutable","timeoutMs"],me=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor","outputRowContract"],ye=new Set(["action","cwd","options",...Object.keys(f).filter(e=>e!=="severity")]);function Ge(e){const t=e.trim().toLowerCase();let r="";for(let o=0;o<t.length;o+=1){const a=t[o];if(a!=="-"&&a!=="_"){r+=a;continue}let n=o+1;for(;t[n]==="-"||t[n]==="_";)n+=1;const i=t[n];if(i!==void 0&&(i>="a"&&i<="z"||i>="0"&&i<="9")){r+=i.toUpperCase(),o=n;continue}r+=t.slice(o,n),o=n-1}return ye.has(r)?{field:e,property:r,owner:"mcp_tool_input",nested_path:r==="expectHash"?`options.field (${e}=<value>)`:`options.${r}`}:void 0}const fe={create:["fullChangedFields","idOnly"],copy:["fullChangedFields","idOnly"],update:["fullChangedFields","idOnly"],"item-reopen":["fullChangedFields","idOnly"],close:["fullChangedFields","idOnly"],claim:["fullChangedFields","idOnly"],release:["fullChangedFields","idOnly"],"start-task":["fullChangedFields","idOnly"],"pause-task":["fullChangedFields","idOnly"],"close-task":["fullChangedFields","idOnly"],restore:["fullChangedFields","idOnly"],append:["fullChangedFields"],"update-many":["fullChangedFields"],"close-many":["fullChangedFields"],assurance:["fullChangedFields","idOnly"]},Oe=["createMode","status","deadline","estimate","acceptanceCriteria","definitionOfReady","order","rank","goal","objective","value","impact","outcome","whyNow","assignee","reviewer","risk","confidence","sprint","release","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact","comment","note","learning","reminder","event","typeOption"],he=Object.freeze({"close-many":["list","expected_result","expected","actual_result","actual","validate_close","dry_run","checkpoint","no_checkpoint","filterAssignee_filter"],"update-many":["list","update","dry_run","checkpoint","no_checkpoint","filterAssignee_filter"],...Object.fromEntries(h.filter(e=>e==="upgrade"||e==="install"||e==="extension"||e==="package"||e.startsWith("extension-")||e.startsWith("package-")).map(e=>[e,["project","local","global"]]))});function s(e){return W(e)}const Ae=s([...V.map(e=>e.param),..._.map(e=>e.param)]),v=s([...z.map(e=>e.param),..._.map(e=>e.param),"force"]),Te=s([...J.map(e=>e.param),...v.filter(e=>e!=="allowMissingParent"&&e!=="completedAt"),"dryRun","rollback","noCheckpoint"]),Ee=s([...re.map(e=>e.param),"reason","completedAt","resolution","expectedResult","actualResult","validateClose","dryRun","rollback","noCheckpoint","author","message","force"]),P=s([...X.map(e=>e.param),"past","section"]),_e=s([...Z.map(e=>e.param),"stream"]),A=s([...Q.map(e=>e.param),"all","includeBody","noTruncate","strictRead","compact","brief","full"]),c=A.filter(e=>e!=="all"&&e!=="status"),p=[[{property:"today",schema:{const:!0}},{property:"recent",schema:{const:!0}}],[{property:"today",schema:{const:!0}},{property:"updatedAfter",schema:{type:"string",pattern:"\\S"}}],[{property:"recent",schema:{const:!0}},{property:"updatedAfter",schema:{type:"string",pattern:"\\S"}}]],Re=[[{property:"summary",schema:{const:!0}},{property:"schemaOnly",schema:{const:!0}}],[{property:"summary",schema:{const:!0}},{property:"flagsOnly",schema:{const:!0}}],[{property:"summary",schema:{const:!0}},{property:"availabilityOnly",schema:{const:!0}}],[{property:"schemaOnly",schema:{const:!0}},{property:"flagsOnly",schema:{const:!0}}],[{property:"schemaOnly",schema:{const:!0}},{property:"availabilityOnly",schema:{const:!0}}],[{property:"flagsOnly",schema:{const:!0}},{property:"availabilityOnly",schema:{const:!0}}]],ge=s([...ee.map(e=>e.param),"count","completion","includeUnparented"]),Ce=s(["query","keywords","mode","semantic","hybrid","includeLinked","titleExact","phraseExact","highlight","compact","full",...te.map(e=>e.param)]),S=s(["type","tag","priority","assignee","assigneeFilter","sprint","release","parent","limit","blockedLimit","readyOnly","format","includeDecisions","includeGates","includeContainers","tokenBudget","explainRanking"]),l=["author","message","force"],ve=["releaseAssignment","text","reason","closeReason","completedAt","duplicateOf","validateClose","resolution","expectedResult","actualResult"],m=["author","assignee","message","force"],Pe=["dryRun","target","scope","capability","declarative","github","ref","init","install","uninstall","explore","manage","offline","describe","markdown","output","reload","doctor","catalog","list","adopt","adoptAll","activate","deactivate","runtimeProbe","fixManagedState","isolated","ignoreGlobal","detail","trace","watch","strictExit","failOnWarn","fields"];function b(e){return{[`${e}-init`]:{required:["target"],optional:["scope","capability",...e==="package"?["declarative"]:[]]},[`${e}-install`]:{optional:["target","github","scope","ref","dryRun"],anyOfRequired:[["target"],["github"]]},[`${e}-uninstall`]:{required:["target"],optional:["scope"]},[`${e}-explore`]:{optional:["scope","fields"]},[`${e}-manage`]:{optional:["scope","runtimeProbe","fixManagedState","offline","fields"]},[`${e}-describe`]:{optional:["target","scope","markdown","output"]},[`${e}-reload`]:{optional:["scope","watch"]},[`${e}-doctor`]:{optional:["scope","detail","trace","fixManagedState","isolated","ignoreGlobal","strictExit","failOnWarn"]},[`${e}-catalog`]:{optional:["scope","fields"]},[`${e}-adopt`]:{required:["target"],optional:["scope","github","ref"]},[`${e}-adopt-all`]:{optional:["scope"]},[`${e}-activate`]:{required:["target"],optional:["scope"]},[`${e}-deactivate`]:{required:["target"],optional:["scope"]},[e]:{optional:Pe,dependentAnyOfRequired:[{property:"dryRun",value:!0,anyOfRequired:[["install","target"],["install","github"]]}],mutuallyExclusiveWhen:[[{property:"dryRun",schema:{const:!0}},{property:"install",schema:{const:!1}}]]}}}const q={required:["title"],optional:["start","duration","end","location","timezone","allDay","parent","inheritFocus","allowMissingParent","tags","priority","body","description","author","message"]},x={optional:["target","scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"]};function Se(e){return`^\\s*(?:${e.map(r=>[...r].map(o=>/[a-z]/u.test(o)?`[${o}${o.toUpperCase()}]`:o.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("")).join("|")})\\s*$`}const be=Se(B),M={type:"string",pattern:be},I=["expectHash","expect_hash"],N={not:{type:"array",maxItems:0}},qe=T({anyOf:[...I.map(e=>({properties:{[e]:N},required:[e]})),{properties:{options:{type:"object",anyOf:I.map(e=>({properties:{[e]:N},required:[e]}))}},required:["options"]}]},{anyOf:[{properties:{subcommand:M},required:["subcommand"]},{properties:{subcommand:{not:{type:"string",pattern:"\\S"}},options:{type:"object",properties:{subcommand:M},required:["subcommand"]}},required:["options"]}]}),xe={schema:qe},y={init:{optional:["prefix","idPrefix","workspace","preset","typePreset","defaults","author","agentGuidance","withPackages","mergeFence","force","verbose"]},config:{required:["scope","configAction"],optional:["key","value","criterion","clearCriteria","format","policy"]},...b("extension"),...b("package"),"package-upgrade":x,install:{optional:["target","github","scope","ref","dryRun"],anyOfRequired:[["target"],["github"]]},upgrade:x,create:{required:["title","description","type","status","priority","message"],optional:Ae},copy:{required:["id"],optional:["title","author","message","allowDuplicate"]},focus:{optional:["id","clear"],mutuallyExclusive:[["id","clear"]]},list:{optional:A,mutuallyExclusiveWhen:p},"list-all":{optional:A,mutuallyExclusiveWhen:p},"list-draft":{optional:c,mutuallyExclusiveWhen:p},"list-open":{optional:c,mutuallyExclusiveWhen:p},"list-in-progress":{optional:c,mutuallyExclusiveWhen:p},"list-blocked":{optional:c,mutuallyExclusiveWhen:p},"list-closed":{optional:c,mutuallyExclusiveWhen:p},"list-canceled":{optional:c,mutuallyExclusiveWhen:p},aggregate:{optional:ge},guide:{optional:["list","format","depth"]},context:{optional:P},ctx:{optional:P},get:{required:["id"],optional:["for","tokenBudget","at","depth","full","fields","tree","treeDepth","format"]},search:{optional:Ce,anyOfRequired:[["query"],["keywords"]]},eval:{optional:["mode","k","failUnder","queries","format"]},events:{optional:["verify","since","type","author","item","limit","full","provenance","provenanceSummary","harness","agentInstance","provenanceFilter","cursorMode"]},merge:{required:["subcommand"],optional:["dryRun","preCommitHook","stage","author","message","force","includeReconciled","artifact","basePath","oursPath","theirsPath","output","outputPath","itemPath","prefer"]},workspace:{required:["subcommand"],optional:["snapshotAction","name","target","dryRun","force","author","message","lockTtlSeconds","lockWaitMs"],conditionalRequired:[{property:"subcommand",value:"snapshot",required:["snapshotAction"]}]},meet:q,event:q,remind:{required:["title"],optional:["at","text","parent","inheritFocus","allowMissingParent","tags","priority","body","description","author","message"]},next:{optional:[...S,"for"]},reindex:{optional:["mode","progress"]},history:{required:["id"],optional:["limit","order","compact","full","provenance","provenanceSummary","harness","agentInstance","provenanceFilter","diff","verify","field","strictExit","failOnWarn","format"]},"history-attest":{optional:["verify","output","hashAlgorithm"],mutuallyExclusive:[["verify","hashAlgorithm"]]},"history-redact":{required:["id"],optional:["literal","regex","replacement","dryRun",...l],anyOfRequired:[["literal"],["regex"]]},"history-repair":{optional:["id","all","dryRun","normalizeProvenance","salvageTail","appendOnly",...l],oneOfRequired:[["id"],["all"]],mutuallyExclusiveWhen:[[{property:"appendOnly",schema:{const:!0}},{property:"salvageTail",schema:{const:!0}}],[{property:"appendOnly",schema:{const:!0}},{property:"normalizeProvenance",schema:{const:!0}}],[{property:"salvageTail",schema:{const:!0}},{property:"all",schema:{const:!0}}],[{property:"salvageTail",schema:{const:!0}},{property:"normalizeProvenance",schema:{const:!0}}]]},"history-author-acknowledge":{optional:["historyEvent","allActionable","dryRun","planFingerprint","limit","attributedAuthor","reviewer","reason"],oneOfRequired:[["historyEvent"],["allActionable"]]},"history-compact":{optional:["id","before","ids","allOver","closed","allStreams","minEntries","dryRun",...l]},schema:{mutuallyExclusiveWhen:[[{property:"subcommand",schema:{const:"policy-mode"}},{property:"name",schema:{not:{enum:["advise","refuse"]}}}]],required:["subcommand"],optional:["definition","policy","message","name","description","defaultStatus","folder","alias","role","order","fieldType","commands","cliFlag","required","requiredOnCreate","allowUnset","requiredTypes","typePreset","infer","minCount","apply","to","migrationId","fieldTypeScope","dryRun","author","force"],conditionalRequired:[{property:"subcommand",value:"policy-put",required:["definition"]},{property:"subcommand",value:"policy-remove",required:["name"]},{property:"subcommand",value:"policy-mode",required:["name"]},{property:"subcommand",value:"policy-check",required:["name"]},{property:"subcommand",value:"policy-approve",required:["name","policy"]},{property:"subcommand",value:"show",required:["name"]},{property:"subcommand",value:"show-status",required:["name"]},{property:"subcommand",value:"add-type",required:["name"]},{property:"subcommand",value:"remove-type",required:["name"]},{property:"subcommand",value:"add-status",required:["name"]},{property:"subcommand",value:"remove-status",required:["name"]},{property:"subcommand",value:"add-field",required:["name"]},{property:"subcommand",value:"remove-field",required:["name"]},{property:"subcommand",value:"show-field",required:["name"]},{property:"subcommand",value:"rename-type",required:["name","to"]},{property:"subcommand",value:"rename-field",required:["name","to"]},{property:"subcommand",value:"remap-status",required:["name","to"]},{property:"subcommand",value:"apply-preset",required:["typePreset"]}]},profile:{required:["subcommand"],optional:["name","dryRun","author","force"],conditionalRequired:[{property:"subcommand",value:"show",required:["name"]},{property:"subcommand",value:"apply",required:["name"]},{property:"subcommand",value:"lint",required:["name"]}]},plan:{required:["subcommand"],optional:["id","stepRef","reorderTo","title","description","template","scope","parent","inheritFocus","related","blocks","blockedBy","harness","mode","resumeContext","tags","priority",...Oe,"body","claim","fromSearch","stepTitle","step","stepBody","stepOwner","stepStatus","stepEvidence","stepBlockedReason","stepReplacement","dependsOn","link","linkKind","linkNote","promoteToItemDep","allowMultipleActive","file","test","doc","decisionText","decision","decisionRationale","decisionEvidence","discoveryText","discovery","validationText","validation","validationCommand","validationExpected","depth","fields","steps","materializeType","materializeParent","materializeTags","field",...l]},activity:{optional:_e},restore:{required:["id","target"],optional:l},update:{required:["id"],optional:v,mutuallyExclusive:[["acceptanceCriteria","addAc"],["acceptanceCriteria","removeAc"]]},"update-many":{optional:Te,mutuallyExclusive:[["acceptanceCriteria","addAc"],["acceptanceCriteria","removeAc"]]},close:{required:["id"],optional:[...ve,...l]},"close-many":{optional:Ee},delete:{required:["id"],optional:["dryRun",...l]},append:{required:["id","body"],optional:l},comments:{required:["id"],optional:["text","add","stdin","edit","delete","limit","full","ifAbsent","expectAt",...l],mutuallyExclusive:[["edit","ifAbsent"],["delete","ifAbsent"],["expectAt","ifAbsent"]]},notes:{required:["id"],optional:["text","add","addJson","stdin","edit","delete","limit","since","eventType","includeMeta","full","ifAbsent","expectAt",...l],mutuallyExclusive:[["addJson","add"],["addJson","stdin"],["addJson","file"],["addJson","edit"],["addJson","delete"],["edit","ifAbsent"],["delete","ifAbsent"],["expectAt","ifAbsent"]]},learnings:{required:["id"],optional:["text","add","stdin","edit","delete","limit","full","ifAbsent","expectAt",...l],mutuallyExclusive:[["edit","ifAbsent"],["delete","ifAbsent"],["expectAt","ifAbsent"]]},files:{required:[],optional:["id","add","addGlob","remove","migrate","list","addNote","noteConflict","discover","apply","discoveryNote","appendStable","validatePaths","full","lookupPath","scope","limit","offset","noTruncate","strictRead","explain","lines","decisionDepth",...l],anyOfRequired:[["id"],["lookupPath"]],dependentAnyOfRequired:[{property:"addNote",anyOfRequired:[["add"],["addGlob"]]},{property:"noteConflict",anyOfRequired:[["add"],["addGlob"]]}]},docs:{required:["id"],optional:["add","addGlob","remove","migrate","addNote","noteConflict","list","validatePaths","full",...l],dependentAnyOfRequired:[{property:"addNote",anyOfRequired:[["add"],["addGlob"]]},{property:"noteConflict",anyOfRequired:[["add"],["addGlob"]]}]},deps:{required:["id"],optional:["format","maxDepth","collapse","summary","full","nodeLimit","edgeLimit","tokenBudget","cursor","direction","kind"]},graph:{required:["subcommand"],optional:["id","target","kind","maxDepth","limit","after","direction","maxPaths","sample","exemptIsolate","exemptIsolateType","saveBaseline","rebuild","clear","summary","full"]},test:{required:["id"],optional:["list","add","addJson","remove","removeIndex","update","updateIndex","setJson","run","match","onlyIndex","onlyLast","full","background","timeout","progress","envSet","envClear","sharedHostSafe","pmContext","overrideLinkedPmContext","workspaceContext","overrideLinkedWorkspaceContext","allowUntrustedLinkedTests","acknowledgeLinkedTests","failOnContextMismatch","failOnSkipped","failOnEmptyTestRun","requireAssertionsForPm","checkContext","fullOutput","autoPmContext","measure","metricBelow","metricDiff",...l],dependentAnyOfRequired:[{property:"update",anyOfRequired:[["setJson"]]},{property:"updateIndex",anyOfRequired:[["setJson"]]},{property:"setJson",anyOfRequired:[["update"],["updateIndex"]]}],mutuallyExclusive:[["update","updateIndex"],["acknowledgeLinkedTests","run"],["acknowledgeLinkedTests","background"]]},"test-all":{optional:["status","limit","offset","background","timeout","progress","envSet","envClear","sharedHostSafe","pmContext","overrideLinkedPmContext","workspaceContext","overrideLinkedWorkspaceContext","allowUntrustedLinkedTests","failOnContextMismatch","failOnSkipped","failOnEmptyTestRun","requireAssertionsForPm","checkContext","fullOutput","autoPmContext"]},telemetry:{optional:["subcommand","limit"]},"test-runs-list":{optional:["status","limit"]},"test-runs-status":{required:["runId"]},"test-runs-logs":{required:["runId"],optional:["stream","tail"]},"test-runs-stop":{required:["runId"],optional:["force"]},"test-runs-resume":{required:["runId"],optional:["author"]},stats:{optional:["includeEmpty","storage","metadataCoverage","fieldUtilization","byAssignee","byTag","byPriority","tagPrefix","measurements","metric","measurementLimit","observe","improvementDirection","measurementSource","measurementItem","measurementRevision","author","message","provenanceCoverage","fleetAttribution","since","eventLimit","minimumSample"]},duplicates:{optional:["status","since","threshold","limit","exhaustive"]},health:{optional:["strictDirectories","requireMergeDrivers","strictExit","failOnWarn","checkOnly","checkTelemetry","noRefresh","refreshVectors","verboseStaleItems","verboseAuthorEvents","brief","summary","skipVectors","skipIntegrity","skipDrift","full"]},validate:{optional:["checkCompleteness","checkStorageIntegrity","checkMetadata","metadataProfile","checkResolution","checkLifecycle","checkStaleBlockers","dependencyCycleSeverity","parentCycleSeverity","checkFiles","scanMode","includePmInternals","verboseFileLists","verboseDiagnostics","allAffectedIds","strictExit","failOnWarn","fixHints","autoFix","dryRun","fixScope","pruneMissing","checkHistoryDrift","checkCommandReferences","counts","full"]},assurance:{required:["subcommand"],optional:["kind","id","definition","trigger","treeId","gate","limit","dryRun","author","message","preset","owner","apply","enforcement"],conditionalRequired:[{property:"subcommand",value:"list",required:["kind"]},{property:"subcommand",value:"show",required:["kind","id"]},{property:"subcommand",value:"put",required:["kind","id","definition"]},{property:"subcommand",value:"remove",required:["kind","id"]},{property:"subcommand",value:"run",required:["id","trigger"]},{property:"subcommand",value:"apply",required:["preset","owner"]},{property:"subcommand",value:"derive",required:["owner"]},{property:"subcommand",value:"risk",required:["definition"]},{property:"subcommand",value:"lineages",required:["definition"]},{property:"subcommand",value:"promote",required:["id","enforcement"]}],mutuallyExclusiveWhen:[[{property:"subcommand",schema:{const:"risk"}},{property:"definition",schema:{not:{required:["policy","change"]}}}],[{property:"subcommand",schema:{const:"lineages"}},{property:"definition",schema:{anyOf:[{required:["change"]},{not:{required:["policy"]}}]}}]]},gc:{optional:["dryRun","gcScope"]},contracts:{optional:["contractAction","command","summary","schemaOnly","flagsOnly","availabilityOnly","runtimeOnly","activeOnly","full"],mutuallyExclusiveWhen:Re},completion:{required:["shell"],optional:["eagerTags"]},claim:{optional:["start","id","next","ifAvailable","takeoverStale","maxAttempts","includeDecisions",...S,...m],oneOfRequired:[["id"],["next"]],mutuallyExclusiveWhen:[[{property:"start",schema:{const:!0}},{property:"ifAvailable",schema:{const:!0}},{property:"id",schema:{type:"string"}}],[{property:"takeoverStale",schema:{const:!0}},{property:"force",schema:{const:!0}}],[{property:"takeoverStale",schema:{const:!0}},{property:"next",schema:{const:!0}}]]},release:{required:["id"],optional:["pause","handoff",...m],dependentAnyOfRequired:[{property:"handoff",anyOfRequired:[["message"]]}],mutuallyExclusiveWhen:[[{property:"pause",schema:{const:!0}},{property:"handoff",schema:{type:"string"}}]]},"start-task":{required:["id"],optional:[...m,"takeoverStale"],mutuallyExclusiveWhen:[[{property:"takeoverStale",schema:{const:!0}},{property:"force",schema:{const:!0}}]]},"pause-task":{required:["id"],optional:m},"close-task":{required:["id"],optional:["text","validateClose",...m]},"item-reopen":{required:["id","reason"],optional:["status","expectedResult","author","message","force"]}},$e=Object.freeze(Object.fromEntries(h.map(e=>[e,y[e]])));function L(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").trim().replace(/^./,t=>t.toUpperCase()).concat(".")}function k(e,t){const r=typeof t=="object"&&t!==null?{...t}:{},o=u[e];return{...r,description:o?.description??L(e),...o?.examples?{examples:o.examples}:{}}}function Me(e,t){if(e==="history-attest"&&t==="verify")return{description:"Compare all retained history streams with a detached JSON proof object. Server-local proof paths are not accepted over MCP."};if(e==="history-attest"&&t==="output")return{description:"Local CLI/SDK only. MCP rejects this field; save the returned JSON bundle on the client."};if(e==="claim"&&t==="start")return{description:"Move the claimed item to its configured in-progress status; with next, the selected item is claimed and started in one locked write."};if((e==="list"||e.startsWith("list-"))&&t==="all")return{description:"Return items from every lifecycle status instead of the default active-status set."};if(e==="plan"&&Object.prototype.hasOwnProperty.call(C,t))return C[t];const r=ne[e];return r&&Object.prototype.hasOwnProperty.call(r,t)?r[t]:u[t]}function D(e,t,r){const o=typeof r=="object"&&r!==null?{...r}:{},a=Me(e,t);return{...o,description:a?.description??L(t),...a?.examples?{examples:a.examples}:{}}}function Ie(e,t){if(e==="claim"&&t==="start")return{type:"boolean"};const r=ce[e];return r&&Object.prototype.hasOwnProperty.call(r,t)?r[t]:e==="plan"&&Object.prototype.hasOwnProperty.call(g,t)?g[t]:(e==="get"||e==="history"||e==="search")&&t==="format"?{type:"string",enum:["json","toon"]}:t==="pause"||t==="handoff"||t==="releaseAssignment"||t==="hashAlgorithm"?f[t]:R[t]}function Ne(e,t){const r={action:{const:e,description:u.action?.description??"Tool action to execute."}};for(const o of t){if(o==="action")continue;const a=Ie(e,o);a&&(r[o]=D(e,o,a))}return r}function Le(e,t){const r=t.flat();return t.map(o=>{const a=r.filter(n=>!o.includes(n));return{required:[...o],...a.length>0?{not:{anyOf:a.map(n=>({required:[n]}))}}:{},...e==="history-repair"&&o.includes("all")?{properties:{all:{const:!0}}}:e==="claim"&&o.includes("next")?{properties:{next:{const:!0}}}:{}}})}function T(e,t){return{if:e,then:t}}function w(e,t){return{...t===void 0?{}:{properties:{[e]:{const:t}}},required:[e]}}function ke(e){const t=[];if(e.conditionalRequired&&e.conditionalRequired.length>0)for(const r of e.conditionalRequired)t.push(T(w(r.property,r.value),{required:r.required}));if(e.dependentAnyOfRequired&&e.dependentAnyOfRequired.length>0)for(const r of e.dependentAnyOfRequired)t.push(T(w(r.property,r.value),{anyOf:r.anyOfRequired.map(o=>({required:[...o]}))}));if(e.mutuallyExclusive&&e.mutuallyExclusive.length>0)for(const r of e.mutuallyExclusive)t.push({not:{required:s(r)}});if(e.mutuallyExclusiveWhen&&e.mutuallyExclusiveWhen.length>0)for(const r of e.mutuallyExclusiveWhen)t.push({not:{allOf:r.map(o=>({properties:{[o.property]:o.schema},required:[o.property]}))}});return t}function H(e){if(!Object.prototype.hasOwnProperty.call(y,e))return;const t=y[e],r=fe[e]??[];return s(["action",...ue,...le(e)!==void 0?me:[],...r,...Y.has(e)||G.has(e)||$.has(e)?["expectHash"]:[],...t.required??[],...t.optional??[]])}function Be(e){const t=H(e);if(t===void 0)return;const r=e==="create"?pe:e==="update"?de:[];return s([...t,...r.flatMap(({keys:o,target:a})=>[a,...o]),...he[e]??[],...t.includes("expectHash")?["expect_hash"]:[]])}function E(e){const t=y[e],r=s(t.required??[]),o=H(e),a={type:"object",additionalProperties:!1,required:["action",...r],title:`pm action "${e}" parameters`,properties:Ne(e,o)};t.anyOfRequired&&t.anyOfRequired.length>0&&(a.anyOf=t.anyOfRequired.map(d=>({required:[...d]}))),t.oneOfRequired&&t.oneOfRequired.length>0&&(a.oneOf=Le(e,t.oneOfRequired));const n=xe[e],i=[...ke(t),...n===void 0?[]:[n]];return i.length>0&&(a.allOf=i),a}function Ve(e,t={}){const r=E(e),o={...r.properties};delete o.action;const a=[...r.anyOf??[],...r.oneOf??[]],n=(t.required??r.required.map(String)).filter(d=>d==="action"?!1:t.required===void 0?!0:!a.some(O=>O.required?.map(String).includes(d))),i={type:"object",additionalProperties:t.additionalProperties??!0,properties:{...o,options:{type:"object",additionalProperties:!0,description:"Advanced command options forwarded to the selected pm action."},...t.properties},required:n};return r.anyOf!==void 0&&(i.anyOf=r.anyOf),r.oneOf!==void 0&&(i.oneOf=r.oneOf),r.allOf!==void 0&&(i.allOf=r.allOf),i}function F(e){let t;const r=()=>t??=e();return new Proxy({},{get:(o,a)=>r()[a],has:(o,a)=>a in r(),ownKeys:()=>Reflect.ownKeys(r()),getOwnPropertyDescriptor:(o,a)=>{const n=Reflect.getOwnPropertyDescriptor(r(),a);return n&&(n.configurable=!0),n}})}const U="4.28.1",De=U.split(".")[0],we="1.12.0",ze=F(()=>({$schema:"https://json-schema.org/draft/2020-12/schema",$id:`https://schema.unbrained.dev/pm-cli/tool-parameters-v${De}.schema.json`,title:"pm-cli tool parameters (action-scoped strict schema)","x-schema-version":U,type:"object",oneOf:h.map(e=>E(e))}));function j(e,t){const r=k(e,t);if(typeof r.type=="string")return r;const a=(Array.isArray(r.anyOf)?r.anyOf:[]).find(d=>typeof d.type=="string");if(a){const{anyOf:d,...O}=r;return{...a,...O}}const{anyOf:n,...i}=r;return{...i,type:"string"}}function K(){const e={action:{type:"string",description:u.action?.description??"Tool action to execute."},options:{type:"object",additionalProperties:!0,description:"Advanced command options object forwarded to the selected pm action."}};for(const t of Object.keys(f).sort())e[t]=j(t,f[t]);return{title:"pm-cli tool parameters (provider-compatible flat schema)","x-schema-version":we,type:"object",additionalProperties:!1,required:["action"],properties:e}}const Je=F(K),Xe={buildActionScopedToolSchema:E,buildProviderCompatibleToolSchema:K,decorateActionScopedToolParameterDefinition:D,decorateToolParameterDefinition:k,toolActionSchemaContracts:y,toolParameterMetadata:u,toProviderCompatibleParameterDefinition:j,toUniqueFlagContracts:ie,withFlagAliasMetadata:se};export{ve as CLOSE_ACTION_OPTION_KEYS,Oe as PLAN_CREATE_METADATA_PARAMETER_KEYS,Je as PM_PROVIDER_TOOL_PARAMETERS_SCHEMA,we as PM_PROVIDER_TOOL_PARAMETERS_SCHEMA_VERSION,$e as PM_TOOL_ACTION_PARAMETER_CONTRACTS,ze as PM_TOOL_PARAMETERS_SCHEMA,De as PM_TOOL_PARAMETERS_SCHEMA_MAJOR,U as PM_TOOL_PARAMETERS_SCHEMA_VERSION,ye as PM_TOOL_RESERVED_CUSTOM_FIELD_PROPERTIES,Xe as _testOnlyCliContracts,Ve as buildPmActionToolInputSchema,Be as pmToolActionNestedOptionKeys,H as pmToolActionParameterKeys,Ge as resolvePmToolCustomFieldCollision};
|
|
2
2
|
//# sourceMappingURL=tool-schema.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{AsyncLocalStorage as tt}from"node:async_hooks";import{attachExtensionReadOutputRows as et,resolveExtensionOutputCommand as nt}from"./read-output/extension.js";import{quoteCommandArg as I,renderPmCommand as q}from"./command-line.js";import{attachOutputOmissionReceipt as rt}from"./output-projection.js";import{decodeQueryCursorEnvelope as ot,encodeQueryCursor as it}from"./pagination.js";import{applyReadOutputDimensions as dt,decodeReadOutputContinuationCursor as ut,isReadResultOmittedForBudget as z,resolveReadOutputSurface as st,stabilizeReadOutputReceiptEstimates as ct}from"./read-output-contracts.js";import{estimateReadOutputTokens as E,MAX_ESTIMATE_ITERATIONS as at,readOutputMeasurementFormat as T,registerReadOutputPassHooks as ft,resolveReadOutputRecoveryBudget as lt}from"./read-output-budget.js";import{propagateContextUsageServingReceipt as R}from"./context-usage.js";import{readOutputContinuationRowCollections as _t}from"./read-output-rows.js";import{EXIT_CODE as B}from"../core/shared/constants.js";import{PmCliError as A}from"../core/shared/errors.js";import{compactExplanatoryString as gt,isContinuationTokenKey as mt,isTrackerItemDocumentKey as bt}from"../core/shared/text-normalization.js";const ht="limit_overridden_by_intent",U=Object.freeze([{command:"context",intent:"orient",description:"Bounded active hierarchy, ownership, blockers, and recent progress.",included_field_groups:["summary","focus","hierarchy","blockers","activity"],token_budget:3e3,source:"core"},{command:"context",intent:"handoff",description:"Active ownership, evidence, decisions, and immediate continuation context.",included_field_groups:["summary","focus","in_progress","decisions","activity"],token_budget:2200,source:"core"},{command:"get",intent:"inspect",description:"Standard-depth item metadata, relationships, evidence, and lifecycle state.",included_field_groups:["item","children","claim_state","linked"],token_budget:3200,source:"core"},{command:"list",intent:"triage",description:"A budget-derived page of compact governance, ownership, priority, and blocker rows for triage.",included_field_groups:["identity","governance","ownership","dependencies"],token_budget:3200,source:"core"},{command:"next",intent:"execute",description:"The highest-ranked actionable work with concise ranking evidence.",included_field_groups:["recommended"],token_budget:1200,source:"core"},{command:"search",intent:"discover",description:"A budget-derived page of ranked canonical lineage candidates with compact match evidence.",included_field_groups:["identity","status","lineage","match"],token_budget:1800,source:"core"}]),G=new tt;function kt(){return G.getStore()??U}function jt(t,e){return G.run(yt(t.workspaceContracts,t.packageContracts),e)}function pt(t,e){const n=t.command.trim().toLowerCase(),o=t.intent.trim().toLowerCase(),i=`${n}:${o}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(o))throw new TypeError(`Invalid context intent command or name: ${i}`);if(t.description.trim().length===0)throw new TypeError(`Context intent ${i} requires a non-empty description`);if(!Number.isSafeInteger(t.token_budget)||t.token_budget<=0)throw new TypeError(`Context intent ${i} requires a positive integer token_budget`);const r=[...new Set(t.included_field_groups.map(d=>d.trim()).filter(Boolean))];if(r.length===0)throw new TypeError(`Context intent ${i} requires included_field_groups`);return{command:n,intent:o,description:t.description.trim(),included_field_groups:r,token_budget:t.token_budget,source:e}}function yt(t=[],e=[]){const n=[{source:"core",contracts:U,allowOverride:!1},{source:"package",contracts:e,allowOverride:!1},{source:"workspace",contracts:t,allowOverride:!0}],o=new Map,i=new Set;for(const r of n){i.clear();for(const d of r.contracts){const s=pt(d,r.source),u=`${s.command}:${s.intent}`;if(i.has(u))throw new TypeError(`Duplicate context intent declaration: ${u}`);if(i.add(u),!r.allowOverride&&o.has(u))throw new TypeError(`Duplicate context intent declaration: ${u}`);o.set(u,s)}}return[...o.values()].sort((r,d)=>r.command.localeCompare(d.command)||r.intent.localeCompare(d.intent))}function X(t,e,n=kt(),o=[]){const i=t.trim().toLowerCase(),r=e.trim().toLowerCase(),d=n.find(c=>c.command===i&&c.intent===r);if(d)return{...d,source:d.source??"core"};const s=n.filter(c=>c.command===i).map(c=>c.intent);if(s.length===0)return;const u=s.map(c=>{const f=Array.from({length:r.length+1},(b,g)=>g);for(let b=1;b<=c.length;b+=1){let g=f[0];f[0]=b;for(let h=1;h<=r.length;h+=1){const j=f[h];f[h]=Math.min(f[h]+1,f[h-1]+1,g+(c[b-1]===r[h-1]?0:1)),g=j}}return{candidate:c,distance:f[r.length]}}).sort((c,f)=>c.distance-f.distance||c.candidate.localeCompare(f.candidate))[0].candidate,a=[i,...o,"--for",r],l=[i,...o,"--for",u],_=q(l);throw new A(`Unknown context intent "${r}" for ${i}. Did you mean "${u}"?`,B.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:r,required:`Use a declared ${i} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[_],recovery:{recovery_mode:"compact",attempted_command:q(a),allowed_values:[...s].sort(),suggested_retry:_,suggested_retry_args:l}})}function N(t,e){const n=k(t.limit),o=String(n===void 0?e:Math.min(n,e));return(t.limit===void 0||n!==void 0)&&(t.limit=o),o}const W={context:(t,e,n,o)=>{t.section===void 0&&t.depth===void 0&&(t.section=e.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]),t.depth===void 0&&(t.depth=e.intent==="handoff"?"deep":"standard");const i=C(o,t.tokenBudget,e.token_budget),r=v("context",e.intent,i,n),d=N(t,r);t.activityLimit===void 0&&(t.activityLimit=d)},get:t=>{t.depth===void 0&&t.fields===void 0&&(t.depth="standard")},list:(t,e,n,o)=>{t.brief===void 0&&t.compact===void 0&&t.full===void 0&&t.fields===void 0&&(t.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");const i=C(o,t.tokenBudget,e.token_budget),r=v("list",e.intent,i,n);N(t,r)},next:t=>{t.readyOnly===void 0&&(t.readyOnly=!0)},search:(t,e,n,o)=>{t.compact===void 0&&t.full===void 0&&t.fields===void 0&&(t.compact=!0);const i=C(o,t.tokenBudget,e.token_budget),r=v("search",e.intent,i,n);N(t,r)}};function te(t,e,n=[]){const o=e.tokenBudget??e.token_budget;if(typeof e.for!="string"){if(o!==void 0&&(t==="get"||t==="list"||t==="search"))throw new A("--token-budget requires a declared context intent selected with --for",B.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(e.tokenBudget!==void 0||e.token_budget===void 0)return e;const u={...e,tokenBudget:o};return delete u.token_budget,u}const i=X(t,e.for,void 0,n),r=w(e),d=k(o)!==void 0||typeof r=="number",s={...e};return s.tokenBudget===void 0&&o!==void 0&&(s.tokenBudget=o),delete s.token_budget,typeof r=="number"?s.tokenBudget=String(r):s.tokenBudget===void 0&&(s.tokenBudget=String(i.token_budget)),W[t](s,i,d,r),s}const wt={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},x=256;function S(t,e,n=!0,o=!0){return Array.isArray(t)?t.map(i=>S(i,e,n,!1)):t!==null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([i,r])=>[i,n&&typeof r=="string"&&mt(i)?r:S(r,e,n&&!(o&&bt(e,i)),!1)])):typeof t=="string"?gt(t):t}function k(t){const e=typeof t=="number"?t:typeof t=="string"&&/^\d+$/u.test(t.trim())?Number(t):Number.NaN;return Number.isSafeInteger(e)&&e>0?e:void 0}function w(t){const e=t.outputBudget??t.output_budget;return e==="unbounded"?e:k(e)}function xt(t){return w(t)===void 0?"--token-budget":"--output-budget"}function C(t,e,n){return typeof t=="number"?t:Ct(e,n)}function Ct(t,e){const n=k(t);if(n===void 0)return e;if(n<x)throw new A(`Context intent token budget must be at least ${x}`,B.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(t),required:`Use an integer token budget of at least ${x}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${x} or omit the override.`]});return n}function F(t,e){const n=t==="context"&&e==="orient";return t==="context"?n?{overhead:1200,rowCost:600}:{overhead:800,rowCost:500}:{overhead:t==="list"?520:480,rowCost:16}}function v(t,e,n,o){if(t==="get"||t==="next")return;const{overhead:i,rowCost:r}=F(t,e),d=Math.max(t==="context"?1:2,Math.floor((n-i)/r));return o?d:Math.min(t==="context"?20:100,d)}function p(t,e,n){const o=T(n),i=n.outputRowContract===!0||n.output_row_contract===!0;let r=e.estimated_tokens,d=r;for(let s=0;s<at;s+=1){e.estimated_tokens=r;const u=E(i||!Object.hasOwn(t,"row_contract")?t:Object.fromEntries(Object.entries(t).filter(([a])=>a!=="row_contract")),o);if(u===r)return;r=u,d=Math.max(d,r)}e.estimated_tokens=d}const K={context:["high_level","low_level","blocked_fallback","recently_created","unparented","hierarchy","activity","blockers"],get:["children"],list:["items"],next:["ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items"]};function J(t){try{const e=JSON.parse(Buffer.from(t,"base64url").toString("utf8"));return typeof e.fingerprint!="string"||!Number.isSafeInteger(e.after_index)?void 0:{fingerprint:e.fingerprint,after_index:e.after_index,...typeof e.snapshot=="string"?{snapshot:e.snapshot}:{}}}catch{return}}function vt(t){if(t===null||typeof t!="object")return;if(typeof t.id=="string")return t.id;const e=t.item?.id;return typeof e=="string"?e:void 0}function Ot(t,e,n,o){let i=!1;for(;;){if(p(t,e,o),e.estimated_tokens<=e.token_budget||n.length<=1)return i;const r=Buffer.byteLength(JSON.stringify(n),"utf8"),d=(e.estimated_tokens-e.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(d/Math.max(1,Math.ceil(r/n.length)))))),i=!0}}function It(t,e,n){const o=t.items,i=typeof t.next_cursor=="string",r=i?t.next_cursor:n.after;if(!Array.isArray(o)||typeof r!="string")return!1;const d=J(r);if(d===void 0)return!1;const s=o.length,u=[...o];let a=!1;for(;;){if(a=Ot(t,e,o,n)||a,!a)return!1;const l=vt(o.at(-1));if(l===void 0)return o.splice(0,o.length,...u),p(t,e,n),!1;if(t.next_cursor=it(d.fingerprint,l,i?d.after_index-(s-o.length):d.after_index+o.length,d.snapshot),p(t,e,n),e.estimated_tokens<=e.token_budget||o.length<=1)break}return typeof t.count=="number"&&(t.count=o.length),typeof t.applied_limit=="number"&&(t.applied_limit=o.length),!0}function Et(t,e,n,o){if(t==="list"||t==="search")return It(e,n,o);if(t!=="next"||typeof e.next_cursor=="string")return!1;let i=!1;for(;;){if(p(e,n,o),n.estimated_tokens<=n.token_budget)return i;const r=K[t].map(c=>({key:c,rows:Array.isArray(e[c])?e[c]:[]})).filter(({rows:c})=>c.length>0).sort((c,f)=>f.rows.length-c.rows.length||c.key.localeCompare(f.key))[0];if(r===void 0)return i;const d=K[t].reduce((c,f)=>c+(Array.isArray(e[f])?e[f].length:0),0);if(d<=1)return i;const s=Math.min(r.rows.length,d-1),u=Buffer.byteLength(JSON.stringify(r.rows),"utf8"),a=Math.max(1,Math.ceil(u/r.rows.length)),l=(n.estimated_tokens-n.token_budget)*4,_=Math.min(s,Math.max(1,Math.ceil(l/a)));r.rows.splice(-_,_),i=!0}}function $(t,e,n){if(typeof e.for!="string")return n;const o=t.startsWith("list-")?"list":t;if(!(o in W))return n;const i=o,r=X(i,e.for),d=w(e),s=C(d,e.tokenBudget??e.token_budget,r.token_budget),u={command:i,intent:r.intent,source:r.source,included_field_groups:[...r.included_field_groups],token_budget:s,declared_token_budget:r.token_budget,token_budget_override:s-r.token_budget,estimated_tokens:0,within_budget:!0,degradation:wt[i],declaration_feasible:!0,result_omitted:!1},a={...n},l=v(i,r.intent,u.token_budget,k(e.tokenBudget??e.token_budget)!==void 0||typeof d=="number");if(l!==void 0){const g=k(e.limit),h=g!==void 0&&g<l;u.budget_derived_limit=l,u.binding_constraint=h?"explicit_limit":"token_budget",u.limit_reason=h?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",a.budget_derived_limit=l,St({builtInCommand:i,intent:r.intent},u,a,e)}const _=L.get(e)??0,c=u.token_budget;u.token_budget=c-_;const f=d==="unbounded"?M(a,u,e):Tt(i,a,u,e,st(t,e));u.declaration_feasible=u.estimated_tokens<=u.declared_token_budget;const b=V(d,u,f,()=>Y(t,i,r.intent,{...u,token_budget:c,estimated_tokens:u.estimated_tokens+_},a,e));return u.result_omitted&&(u.estimated_tokens+=_,u.declaration_feasible=u.estimated_tokens<=u.declared_token_budget),u.token_budget=c,b}function M(t,e,n){const o={...t,context_intent:e};return p(o,e,n),o}function Tt(t,e,n,o,i){let r=M(e,n,o);return n.estimated_tokens>n.token_budget&&(n.degradation="recursive_budget_compaction",r=M(S(e,i),n,o)),n.estimated_tokens>n.token_budget&&Et(t,r,n,o)&&(n.degradation="budget_row_compaction",p(r,n,o)),r}const L=new WeakMap;function V(t,e,n,o){return e.estimated_tokens<=e.token_budget||(e.within_budget=!1,t==="unbounded")?n:(e.degradation="budget_receipt_only",e.result_omitted=!0,typeof t=="number"?{output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},context_intent:e}:{budget_exceeded:{omitted_result:!0,reason:e.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:o()},context_intent:e})}const Rt=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function Bt(t,e){if(typeof e!="string"||e.length===0)return!1;if(nt(t)===void 0)return!0;try{return ot(e),!0}catch{return!1}}function Q(t,e,n){if(!Bt(t,e.after)||z(n))return n;const o=J(e.after)?.fingerprint??"opaque_cursor",i={...n};for(const r of Rt)delete i[r];return i.continuation_contract={fingerprint:o,metadata:"reference",restore_with:"omit --after"},i}function m(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function At(t,e){const n=t==="get"&&m(e.item)&&typeof e.item.id=="string"?e.item.id:t==="search"&&typeof e.query=="string"?e.query:void 0;return n===void 0?"":` ${I(n)}`}function Nt(t){return typeof t.fields=="string"&&t.fields.trim()!==""?` --fields ${I(t.fields)}`:""}function St(t,e,n,o){const i=k(o.limit),r=e.budget_derived_limit;if(i===void 0||i<=r)return;const{overhead:d,rowCost:s}=F(t.builtInCommand,t.intent),u=Math.max(e.token_budget,d+s*i);e.limit_reason=`The ${e.token_budget}-token ${t.intent} budget carries ${r} rows, so it reduced the caller's --limit ${i}.`,e.limit_override={flag:"--limit",requested:i,effective:r,...Number.isSafeInteger(u)?{token_budget_for_requested:u,restore_with:`${xt(o)} ${u}`}:{}};const a=`${ht}:--limit ${i}->${r}`;n.warnings=Array.isArray(n.warnings)?[...n.warnings,a]:[a],m(n.filters)&&(n.filters={...n.filters,requested_limit:String(i)})}function Y(t,e,n,o,i,r){const d=At(e,i),s=e==="get"?"":` --limit ${o.budget_derived_limit??1}`,{output_budget:u}=lt({effective_budget_tokens:o.token_budget,measured_result_tokens:o.estimated_tokens});return`pm ${t}${d}${Nt(r)} --for ${I(n)} --token-budget ${u}${s}`}function y(t,e){if(m(t))return typeof t[e]=="number"?t[e]:void 0}function H(t,e){let n=t;for(let o=0;o<8;o+=1){$t(n);const i=y(n.context_intent,"estimated_tokens"),r=y(n.read_output,"estimated_tokens"),d=y(n.read_session,"spent_this_call_tokens");if(m(n.context_intent)&&n.context_intent.result_omitted!==!0&&p(n,n.context_intent,e),n=ct(n,e),y(n.context_intent,"estimated_tokens")===i&&y(n.read_output,"estimated_tokens")===r&&y(n.read_session,"spent_this_call_tokens")===d)break}return n}function $t(t){const e=t.context_intent;m(e)&&Number(e.estimated_tokens)>Number(e.token_budget)&&(e.within_budget=!1)}function Mt(t,e){const n=e.context_intent;if(!m(n)||n.result_omitted===!0)return;const o=n.degradation==="recursive_budget_compaction"||n.degradation==="budget_row_compaction",i={...e};for(const r of _t(t)){const d=e[r.path];if(Array.isArray(d)&&Array.isArray(r.value)&&d.length<=r.value.length){const s=r.value.slice(0,d.length);i[r.path]=o?s.map(D):s}}return i}function D(t){return Array.isArray(t)?t.map(D):t!==null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([e,n])=>[e,D(n)])):t}function ee(t,e,n){const o=rt(t,et(t??"",n));if(typeof o!="object"||o===null||Array.isArray(o))return R(n,o),o;const i=t??"",r=o,d=$(i,e,r),s=y(d.context_intent,"estimated_tokens"),u=Mt(r,d),a=O(i,e,n,d,u),l=P(e,a,d.context_intent);if(l===void 0)return Lt(e,a,d)?Pt(i,e,n,r,d,Number(s),u,a):a;const _={...e};L.set(_,l.estimated-Number(s));const c=$(i,_,r),f=Z(i,e,_,n,c,u),b=f===void 0?l:P(e,f,c.context_intent);if(b===void 0)return f;const g={...b.receipt,estimated_tokens:b.estimated};return O(i,{...e,outputCursor:void 0,output_cursor:void 0},n,V(w(e),g,f??a,()=>Y(i,g.command,g.intent,g,r,e)))}function Lt(t,e,n){const o=n.context_intent;return Object.hasOwn(e,"output_budget_exceeded")&&m(o)&&o.result_omitted!==!0&&Dt.has(String(o.command))&&(t.outputInclude??t.output_include)===void 0&&(t.outputSession??t.output_session)===void 0}const Dt=new Set(["list","search"]);function Pt(t,e,n,o,i,r,d,s){const u=O(t,{...e,outputBudget:"unbounded"},n,{...i,context_intent:{...i.context_intent}},d),a={...e};L.set(a,E(u,T(e))-r);const l=$(t,a,o),_=Z(t,e,a,n,l,d);return _===void 0||Object.hasOwn(_,"output_budget_exceeded")||P(e,_,l.context_intent)!==void 0?s:_}function Z(t,e,n,o,i,r){return z(i)||qt(e,i)?void 0:O(t,n,o,i,r)}function qt(t,e){const n=t.outputCursor??t.output_cursor;if(typeof n!="string")return!1;const o=ut(n),i=e[o.path];return Array.isArray(i)&&i.length<=o.offset}function P(t,e,n){const o=m(e.context_intent),i=o?e.context_intent:n;if(!m(i)||i.result_omitted===!0||Object.hasOwn(e,"output_budget_exceeded"))return;const r=i,d=o?r.estimated_tokens:E(e,T(t));return w(t)==="unbounded"||d<=r.token_budget?void 0:{receipt:r,estimated:d}}function zt(t){return!m(t)||t.result_omitted===!0?{}:{mirrorEstimate:(e,n)=>{m(e.context_intent)&&(e.context_intent.estimated_tokens=n)}}}function O(t,e,n,o,i){const r={...e,outputRowContract:e.outputRowContract===!0||e.output_row_contract===!0};ft(r,{...i===void 0?{}:{continuationBinding:Q(t,e,i)},...zt(o.context_intent)});const d=dt(t,r,Q(t,e,o));if(R(n,d),e.outputRowContract===!0||e.output_row_contract===!0||!Object.hasOwn(d,"row_contract"))return m(d.context_intent)?H(d,e):d;const s=Object.fromEntries(Object.entries(d).filter(([a])=>a!=="row_contract"));Object.defineProperty(s,"row_contract",{value:d.row_contract,enumerable:!1,configurable:!0});const u=H(s,e);return delete u.row_contract,R(d,u),u}export{ht as CONTEXT_INTENT_LIMIT_OVERRIDE_WARNING,U as PM_CONTEXT_INTENT_CONTRACTS,te as applyContextIntentProjection,$ as attachContextIntentReceipt,ee as attachReadOutputContracts,yt as composeContextIntentContracts,vt as contextIntentRowId,J as decodeContextIntentCursor,kt as getActiveContextIntentContracts,X as resolveContextIntentContract,jt as runWithContextIntentContracts};
|
|
1
|
+
import{AsyncLocalStorage as tt}from"node:async_hooks";import{attachExtensionReadOutputRows as et,resolveExtensionOutputCommand as nt}from"./read-output/extension.js";import{quoteCommandArg as I,renderPmCommand as q}from"./command-line.js";import{attachOutputOmissionReceipt as rt}from"./output-projection.js";import{resolveNativeReadOutputSurface as ot}from"./read-output/surfaces.js";import{decodeQueryCursorEnvelope as it,encodeQueryCursor as dt}from"./pagination.js";import{applyReadOutputDimensions as ut,decodeReadOutputContinuationCursor as st,isReadResultOmittedForBudget as z,resolveReadOutputSurface as at,stabilizeReadOutputReceiptEstimates as ct}from"./read-output-contracts.js";import{estimateReadOutputTokens as E,MAX_ESTIMATE_ITERATIONS as ft,readOutputMeasurementFormat as T,registerReadOutputPassHooks as lt,resolveReadOutputRecoveryBudget as _t}from"./read-output-budget.js";import{propagateContextUsageServingReceipt as R}from"./context-usage.js";import{readOutputContinuationRowCollections as gt}from"./read-output-rows.js";import{EXIT_CODE as B}from"../core/shared/constants.js";import{PmCliError as A}from"../core/shared/errors.js";import{compactExplanatoryString as mt,isContinuationTokenKey as bt,isTrackerItemDocumentKey as ht}from"../core/shared/text-normalization.js";const kt="limit_overridden_by_intent",U=Object.freeze([{command:"context",intent:"orient",description:"Bounded active hierarchy, ownership, blockers, and recent progress.",included_field_groups:["summary","focus","hierarchy","blockers","activity"],token_budget:3e3,source:"core"},{command:"context",intent:"handoff",description:"Active ownership, evidence, decisions, and immediate continuation context.",included_field_groups:["summary","focus","in_progress","decisions","activity"],token_budget:2200,source:"core"},{command:"get",intent:"inspect",description:"Standard-depth item metadata, relationships, evidence, and lifecycle state.",included_field_groups:["item","children","claim_state","linked"],token_budget:3200,source:"core"},{command:"list",intent:"triage",description:"A budget-derived page of compact governance, ownership, priority, and blocker rows for triage.",included_field_groups:["identity","governance","ownership","dependencies"],token_budget:3200,source:"core"},{command:"next",intent:"execute",description:"The highest-ranked actionable work with concise ranking evidence.",included_field_groups:["recommended"],token_budget:1200,source:"core"},{command:"search",intent:"discover",description:"A budget-derived page of ranked canonical lineage candidates with compact match evidence.",included_field_groups:["identity","status","lineage","match"],token_budget:1800,source:"core"}]),G=new tt;function pt(){return G.getStore()??U}function ee(t,e){return G.run(wt(t.workspaceContracts,t.packageContracts),e)}function yt(t,e){const n=t.command.trim().toLowerCase(),i=t.intent.trim().toLowerCase(),o=`${n}:${i}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(i))throw new TypeError(`Invalid context intent command or name: ${o}`);if(t.description.trim().length===0)throw new TypeError(`Context intent ${o} requires a non-empty description`);if(!Number.isSafeInteger(t.token_budget)||t.token_budget<=0)throw new TypeError(`Context intent ${o} requires a positive integer token_budget`);const r=[...new Set(t.included_field_groups.map(d=>d.trim()).filter(Boolean))];if(r.length===0)throw new TypeError(`Context intent ${o} requires included_field_groups`);return{command:n,intent:i,description:t.description.trim(),included_field_groups:r,token_budget:t.token_budget,source:e}}function wt(t=[],e=[]){const n=[{source:"core",contracts:U,allowOverride:!1},{source:"package",contracts:e,allowOverride:!1},{source:"workspace",contracts:t,allowOverride:!0}],i=new Map,o=new Set;for(const r of n){o.clear();for(const d of r.contracts){const s=yt(d,r.source),u=`${s.command}:${s.intent}`;if(o.has(u))throw new TypeError(`Duplicate context intent declaration: ${u}`);if(o.add(u),!r.allowOverride&&i.has(u))throw new TypeError(`Duplicate context intent declaration: ${u}`);i.set(u,s)}}return[...i.values()].sort((r,d)=>r.command.localeCompare(d.command)||r.intent.localeCompare(d.intent))}function X(t,e,n=pt(),i=[]){const o=t.trim().toLowerCase(),r=e.trim().toLowerCase(),d=n.find(a=>a.command===o&&a.intent===r);if(d)return{...d,source:d.source??"core"};const s=n.filter(a=>a.command===o).map(a=>a.intent);if(s.length===0)return;const u=s.map(a=>{const l=Array.from({length:r.length+1},(m,h)=>h);for(let m=1;m<=a.length;m+=1){let h=l[0];l[0]=m;for(let g=1;g<=r.length;g+=1){const j=l[g];l[g]=Math.min(l[g]+1,l[g-1]+1,h+(a[m-1]===r[g-1]?0:1)),h=j}}return{candidate:a,distance:l[r.length]}}).sort((a,l)=>a.distance-l.distance||a.candidate.localeCompare(l.candidate))[0].candidate,c=[o,...i,"--for",r],f=[o,...i,"--for",u],_=q(f);throw new A(`Unknown context intent "${r}" for ${o}. Did you mean "${u}"?`,B.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:r,required:`Use a declared ${o} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[_],recovery:{recovery_mode:"compact",attempted_command:q(c),allowed_values:[...s].sort(),suggested_retry:_,suggested_retry_args:f}})}function N(t,e){const n=k(t.limit),i=String(n===void 0?e:Math.min(n,e));return(t.limit===void 0||n!==void 0)&&(t.limit=i),i}const W={context:(t,e,n,i)=>{t.section===void 0&&t.depth===void 0&&(t.section=e.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]),t.depth===void 0&&(t.depth=e.intent==="handoff"?"deep":"standard");const o=C(i,t.tokenBudget,e.token_budget),r=v("context",e.intent,o,n),d=N(t,r);t.activityLimit===void 0&&(t.activityLimit=d)},get:t=>{t.depth===void 0&&t.fields===void 0&&(t.depth="standard")},list:(t,e,n,i)=>{t.brief===void 0&&t.compact===void 0&&t.full===void 0&&t.fields===void 0&&(t.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");const o=C(i,t.tokenBudget,e.token_budget),r=v("list",e.intent,o,n);N(t,r)},next:t=>{t.readyOnly===void 0&&(t.readyOnly=!0)},search:(t,e,n,i)=>{t.compact===void 0&&t.full===void 0&&t.fields===void 0&&(t.compact=!0);const o=C(i,t.tokenBudget,e.token_budget),r=v("search",e.intent,o,n);N(t,r)}};function ne(t,e,n=[]){const i=e.tokenBudget??e.token_budget;if(typeof e.for!="string"){if(i!==void 0&&(t==="get"||t==="list"||t==="search"))throw new A("--token-budget requires a declared context intent selected with --for",B.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(e.tokenBudget!==void 0||e.token_budget===void 0)return e;const u={...e,tokenBudget:i};return delete u.token_budget,u}const o=X(t,e.for,void 0,n),r=w(e),d=k(i)!==void 0||typeof r=="number",s={...e};return s.tokenBudget===void 0&&i!==void 0&&(s.tokenBudget=i),delete s.token_budget,typeof r=="number"?s.tokenBudget=String(r):s.tokenBudget===void 0&&(s.tokenBudget=String(o.token_budget)),W[t](s,o,d,r),s}const xt={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},x=256;function S(t,e,n=!0,i=!0){return Array.isArray(t)?t.map(o=>S(o,e,n,!1)):t!==null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([o,r])=>[o,n&&typeof r=="string"&&bt(o)?r:S(r,e,n&&!(i&&ht(e,o)),!1)])):typeof t=="string"?mt(t):t}function k(t){const e=typeof t=="number"?t:typeof t=="string"&&/^\d+$/u.test(t.trim())?Number(t):Number.NaN;return Number.isSafeInteger(e)&&e>0?e:void 0}function w(t){const e=t.outputBudget??t.output_budget;return e==="unbounded"?e:k(e)}function Ct(t){return w(t)===void 0?"--token-budget":"--output-budget"}function C(t,e,n){return typeof t=="number"?t:vt(e,n)}function vt(t,e){const n=k(t);if(n===void 0)return e;if(n<x)throw new A(`Context intent token budget must be at least ${x}`,B.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(t),required:`Use an integer token budget of at least ${x}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${x} or omit the override.`]});return n}function F(t,e){const n=t==="context"&&e==="orient";return t==="context"?n?{overhead:1200,rowCost:600}:{overhead:800,rowCost:500}:{overhead:t==="list"?520:480,rowCost:16}}function v(t,e,n,i){if(t==="get"||t==="next")return;const{overhead:o,rowCost:r}=F(t,e),d=Math.max(t==="context"?1:2,Math.floor((n-o)/r));return i?d:Math.min(t==="context"?20:100,d)}function p(t,e,n){const i=T(n),o=n.outputRowContract===!0||n.output_row_contract===!0;let r=e.estimated_tokens,d=r;for(let s=0;s<ft;s+=1){e.estimated_tokens=r;const u=E(o||!Object.hasOwn(t,"row_contract")?t:Object.fromEntries(Object.entries(t).filter(([c])=>c!=="row_contract")),i);if(u===r)return;r=u,d=Math.max(d,r)}e.estimated_tokens=d}const K={context:["high_level","low_level","blocked_fallback","recently_created","unparented","hierarchy","activity","blockers"],get:["children"],list:["items"],next:["ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items"]};function J(t){try{const e=JSON.parse(Buffer.from(t,"base64url").toString("utf8"));return typeof e.fingerprint!="string"||!Number.isSafeInteger(e.after_index)?void 0:{fingerprint:e.fingerprint,after_index:e.after_index,...typeof e.snapshot=="string"?{snapshot:e.snapshot}:{}}}catch{return}}function Ot(t){if(t===null||typeof t!="object")return;if(typeof t.id=="string")return t.id;const e=t.item?.id;return typeof e=="string"?e:void 0}function It(t,e,n,i){let o=!1;for(;;){if(p(t,e,i),e.estimated_tokens<=e.token_budget||n.length<=1)return o;const r=Buffer.byteLength(JSON.stringify(n),"utf8"),d=(e.estimated_tokens-e.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(d/Math.max(1,Math.ceil(r/n.length)))))),o=!0}}function Et(t,e,n){const i=t.items,o=typeof t.next_cursor=="string",r=o?t.next_cursor:n.after;if(!Array.isArray(i)||typeof r!="string")return!1;const d=J(r);if(d===void 0)return!1;const s=i.length,u=[...i];let c=!1;for(;;){if(c=It(t,e,i,n)||c,!c)return!1;const f=Ot(i.at(-1));if(f===void 0)return i.splice(0,i.length,...u),p(t,e,n),!1;if(t.next_cursor=dt(d.fingerprint,f,o?d.after_index-(s-i.length):d.after_index+i.length,d.snapshot),p(t,e,n),e.estimated_tokens<=e.token_budget||i.length<=1)break}return typeof t.count=="number"&&(t.count=i.length),typeof t.applied_limit=="number"&&(t.applied_limit=i.length),!0}function Tt(t,e,n,i){if(t==="list"||t==="search")return Et(e,n,i);if(t!=="next"||typeof e.next_cursor=="string")return!1;let o=!1;for(;;){if(p(e,n,i),n.estimated_tokens<=n.token_budget)return o;const r=K[t].map(a=>({key:a,rows:Array.isArray(e[a])?e[a]:[]})).filter(({rows:a})=>a.length>0).sort((a,l)=>l.rows.length-a.rows.length||a.key.localeCompare(l.key))[0];if(r===void 0)return o;const d=K[t].reduce((a,l)=>a+(Array.isArray(e[l])?e[l].length:0),0);if(d<=1)return o;const s=Math.min(r.rows.length,d-1),u=Buffer.byteLength(JSON.stringify(r.rows),"utf8"),c=Math.max(1,Math.ceil(u/r.rows.length)),f=(n.estimated_tokens-n.token_budget)*4,_=Math.min(s,Math.max(1,Math.ceil(f/c)));r.rows.splice(-_,_),o=!0}}function $(t,e,n){if(typeof e.for!="string")return n;const i=t.startsWith("list-")?"list":t;if(!(i in W))return n;const o=i,r=X(o,e.for),d=w(e),s=C(d,e.tokenBudget??e.token_budget,r.token_budget),u={command:o,intent:r.intent,source:r.source,included_field_groups:[...r.included_field_groups],token_budget:s,declared_token_budget:r.token_budget,token_budget_override:s-r.token_budget,estimated_tokens:0,within_budget:!0,degradation:xt[o],declaration_feasible:!0,result_omitted:!1},c={...n},f=v(o,r.intent,u.token_budget,k(e.tokenBudget??e.token_budget)!==void 0||typeof d=="number");if(f!==void 0){const h=k(e.limit),g=h!==void 0&&h<f;u.budget_derived_limit=f,u.binding_constraint=g?"explicit_limit":"token_budget",u.limit_reason=g?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",c.budget_derived_limit=f,$t({builtInCommand:o,intent:r.intent},u,c,e)}const _=L.get(e)??0,a=u.token_budget;u.token_budget=a-_;const l=d==="unbounded"?M(c,u,e):Rt(o,c,u,e,at(t,e));u.declaration_feasible=u.estimated_tokens<=u.declared_token_budget;const m=V(d,u,l,()=>Y(t,o,r.intent,{...u,token_budget:a,estimated_tokens:u.estimated_tokens+_},c,e));return u.result_omitted&&(u.estimated_tokens+=_,u.declaration_feasible=u.estimated_tokens<=u.declared_token_budget),u.token_budget=a,m}function M(t,e,n){const i={...t,context_intent:e};return p(i,e,n),i}function Rt(t,e,n,i,o){let r=M(e,n,i);return n.estimated_tokens>n.token_budget&&(n.degradation="recursive_budget_compaction",r=M(S(e,o),n,i)),n.estimated_tokens>n.token_budget&&Tt(t,r,n,i)&&(n.degradation="budget_row_compaction",p(r,n,i)),r}const L=new WeakMap;function V(t,e,n,i){return e.estimated_tokens<=e.token_budget||(e.within_budget=!1,t==="unbounded")?n:(e.degradation="budget_receipt_only",e.result_omitted=!0,typeof t=="number"?{output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},context_intent:e}:{budget_exceeded:{omitted_result:!0,reason:e.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:i()},context_intent:e})}const Bt=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function At(t,e){if(typeof e!="string"||e.length===0)return!1;if(nt(t)===void 0)return!0;try{return it(e),!0}catch{return!1}}function Q(t,e,n){if(!At(t,e.after)||z(n))return n;const i=J(e.after)?.fingerprint??"opaque_cursor",o={...n};for(const r of Bt)delete o[r];return o.continuation_contract={fingerprint:i,metadata:"reference",restore_with:"omit --after"},o}function b(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Nt(t,e){const n=t==="get"&&b(e.item)&&typeof e.item.id=="string"?e.item.id:t==="search"&&typeof e.query=="string"?e.query:void 0;return n===void 0?"":` ${I(n)}`}function St(t){return typeof t.fields=="string"&&t.fields.trim()!==""?` --fields ${I(t.fields)}`:""}function $t(t,e,n,i){const o=k(i.limit),r=e.budget_derived_limit;if(o===void 0||o<=r)return;const{overhead:d,rowCost:s}=F(t.builtInCommand,t.intent),u=Math.max(e.token_budget,d+s*o);e.limit_reason=`The ${e.token_budget}-token ${t.intent} budget carries ${r} rows, so it reduced the caller's --limit ${o}.`,e.limit_override={flag:"--limit",requested:o,effective:r,...Number.isSafeInteger(u)?{token_budget_for_requested:u,restore_with:`${Ct(i)} ${u}`}:{}};const c=`${kt}:--limit ${o}->${r}`;n.warnings=Array.isArray(n.warnings)?[...n.warnings,c]:[c],b(n.filters)&&(n.filters={...n.filters,requested_limit:String(o)})}function Y(t,e,n,i,o,r){const d=Nt(e,o),s=e==="get"?"":` --limit ${i.budget_derived_limit??1}`,{output_budget:u}=_t({effective_budget_tokens:i.token_budget,measured_result_tokens:i.estimated_tokens});return`pm ${t}${d}${St(r)} --for ${I(n)} --token-budget ${u}${s}`}function y(t,e){if(b(t))return typeof t[e]=="number"?t[e]:void 0}function H(t,e){let n=t;for(let i=0;i<8;i+=1){Mt(n);const o=y(n.context_intent,"estimated_tokens"),r=y(n.read_output,"estimated_tokens"),d=y(n.read_session,"spent_this_call_tokens");if(b(n.context_intent)&&n.context_intent.result_omitted!==!0&&p(n,n.context_intent,e),n=ct(n,e),y(n.context_intent,"estimated_tokens")===o&&y(n.read_output,"estimated_tokens")===r&&y(n.read_session,"spent_this_call_tokens")===d)break}return n}function Mt(t){const e=t.context_intent;b(e)&&Number(e.estimated_tokens)>Number(e.token_budget)&&(e.within_budget=!1)}function Lt(t,e){const n=e.context_intent;if(!b(n)||n.result_omitted===!0)return;const i=n.degradation==="recursive_budget_compaction"||n.degradation==="budget_row_compaction",o={...e};for(const r of gt(t)){const d=e[r.path];if(Array.isArray(d)&&Array.isArray(r.value)&&d.length<=r.value.length){const s=r.value.slice(0,d.length);o[r.path]=i?s.map(D):s}}return o}function D(t){return Array.isArray(t)?t.map(D):t!==null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([e,n])=>[e,D(n)])):t}function re(t,e,n){const i=ot((t??"").trim().toLowerCase(),e)==="package-catalog"?"package-catalog":t,o=rt(i,et(t??"",n));if(typeof o!="object"||o===null||Array.isArray(o))return R(n,o),o;const r=t??"",d=o,s=$(r,e,d),u=y(s.context_intent,"estimated_tokens"),c=Lt(d,s),f=O(r,e,n,s,c),_=P(e,f,s.context_intent);if(_===void 0)return Dt(e,f,s)?qt(r,e,n,d,s,Number(u),c,f):f;const a={...e};L.set(a,_.estimated-Number(u));const l=$(r,a,d),m=Z(r,e,a,n,l,c),h=m===void 0?_:P(e,m,l.context_intent);if(h===void 0)return m;const g={...h.receipt,estimated_tokens:h.estimated};return O(r,{...e,outputCursor:void 0,output_cursor:void 0},n,V(w(e),g,m??f,()=>Y(r,g.command,g.intent,g,d,e)))}function Dt(t,e,n){const i=n.context_intent;return Object.hasOwn(e,"output_budget_exceeded")&&b(i)&&i.result_omitted!==!0&&Pt.has(String(i.command))&&(t.outputInclude??t.output_include)===void 0&&(t.outputSession??t.output_session)===void 0}const Pt=new Set(["list","search"]);function qt(t,e,n,i,o,r,d,s){const u=O(t,{...e,outputBudget:"unbounded"},n,{...o,context_intent:{...o.context_intent}},d),c={...e};L.set(c,E(u,T(e))-r);const f=$(t,c,i),_=Z(t,e,c,n,f,d);return _===void 0||Object.hasOwn(_,"output_budget_exceeded")||P(e,_,f.context_intent)!==void 0?s:_}function Z(t,e,n,i,o,r){return z(o)||zt(e,o)?void 0:O(t,n,i,o,r)}function zt(t,e){const n=t.outputCursor??t.output_cursor;if(typeof n!="string")return!1;const i=st(n),o=e[i.path];return Array.isArray(o)&&o.length<=i.offset}function P(t,e,n){const i=b(e.context_intent),o=i?e.context_intent:n;if(!b(o)||o.result_omitted===!0||Object.hasOwn(e,"output_budget_exceeded"))return;const r=o,d=i?r.estimated_tokens:E(e,T(t));return w(t)==="unbounded"||d<=r.token_budget?void 0:{receipt:r,estimated:d}}function Ut(t){return!b(t)||t.result_omitted===!0?{}:{mirrorEstimate:(e,n)=>{b(e.context_intent)&&(e.context_intent.estimated_tokens=n)}}}function O(t,e,n,i,o){const r={...e,outputRowContract:e.outputRowContract===!0||e.output_row_contract===!0};lt(r,{...o===void 0?{}:{continuationBinding:Q(t,e,o)},...Ut(i.context_intent)});const d=ut(t,r,Q(t,e,i));if(R(n,d),e.outputRowContract===!0||e.output_row_contract===!0||!Object.hasOwn(d,"row_contract"))return b(d.context_intent)?H(d,e):d;const s=Object.fromEntries(Object.entries(d).filter(([c])=>c!=="row_contract"));Object.defineProperty(s,"row_contract",{value:d.row_contract,enumerable:!1,configurable:!0});const u=H(s,e);return delete u.row_contract,R(d,u),u}export{kt as CONTEXT_INTENT_LIMIT_OVERRIDE_WARNING,U as PM_CONTEXT_INTENT_CONTRACTS,ne as applyContextIntentProjection,$ as attachContextIntentReceipt,re as attachReadOutputContracts,wt as composeContextIntentContracts,Ot as contextIntentRowId,J as decodeContextIntentCursor,pt as getActiveContextIntentContracts,X as resolveContextIntentContract,ee as runWithContextIntentContracts};
|
|
2
2
|
//# sourceMappingURL=context-intent-contracts.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
|
|
@@ -5,11 +5,30 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function resolveExpectHashAction(path:string):string;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* a
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
* The action an SDK or MCP call's guard is judged on: the caller's own action
|
|
9
|
+
* name when it is native, since an alias such as `package-catalog` names its
|
|
10
|
+
* operation exactly as `pm package catalog` does, else the action it resolves
|
|
11
|
+
* to (an extension action, or a non-native shorthand such as `ctx`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveExpectHashCallAction(requested:string|undefined,resolved:string):string;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a command path admits `--expect-hash` in at least one mode, the
|
|
16
|
+
* answer discovery publishes. A native action admits it when it can write an
|
|
17
|
+
* existing item (`PM_EXPECT_HASH_ACTIONS`), and `schema` does in its item
|
|
18
|
+
* rewriting migrations and policy approvals; reads refuse it, and so do native writers that create
|
|
19
|
+
* new items or write only settings and caches (`create`, `copy`, `config`,
|
|
20
|
+
* `gc`, `profile`; pm-oehf5s). A statically dispatched inventory and a
|
|
21
|
+
* read-only subcommand of a writer root refuse it too. Extension and package
|
|
22
|
+
* actions stay admitted because only their handlers know whether they write.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isExpectHashAdmissibleAction(path:string):boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether one invocation admits `--expect-hash`, the answer the runtime
|
|
27
|
+
* enforces: as {@link isExpectHashAdmissibleAction}, except that `schema`
|
|
28
|
+
* admits it only for the subcommands that rewrite existing items.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isExpectHashAdmissibleInvocation(path:string,subcommand:unknown):boolean;
|
|
31
|
+
/** The schema subcommands that admit the guard, for refusal guidance that names the same list. */
|
|
32
|
+
export declare function expectHashAdmittedSchemaSubcommands():readonly string[];
|
|
33
|
+
/** The mode condition discovery states beside an admitted guard, when the action admits it only in some modes. */
|
|
34
|
+
export declare function expectHashAdmissionCondition(path:string):string|undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{PM_EXPECT_HASH_ACTIONS as
|
|
1
|
+
import{PM_EXPECT_HASH_ACTIONS as r,PM_EXPECT_HASH_CONDITIONAL_ACTIONS as c,PM_EXPECT_HASH_HANDLER_DECIDED_ACTIONS as A,PM_EXPECT_HASH_SCHEMA_SUBCOMMANDS as a,PM_TOOL_ACTIONS as _}from"../cli-contracts/enum-contracts.js";import{STATIC_INVENTORY_COMMAND_PATHS as E}from"../cli-contracts/flag-contracts.js";const i=new Set(_),S=new Set(["files lookup","item files lookup"]);function o(e){const t=e.trim().replace(/^packages(?=\s|$)/u,"package").replace(/\s+/gu,"-");return i.has(t)?t:e}function l(e,t){return e!==void 0&&i.has(e)?e:t}const s=a;function p(e){const t=e.trim().replace(/\s+/gu," ");if(E.has(t)||S.has(t))return!1;const n=o(e);return!i.has(n)||r.has(n)||c.has(n)||A.has(n)}function T(e,t){return p(e)?o(e)!=="schema"||typeof t=="string"&&s.includes(t.trim().toLowerCase()):!1}function h(){return s}function H(e){return o(e)==="schema"?`Applies only to ${s.join(", ")}, which write existing items.`:void 0}export{H as expectHashAdmissionCondition,h as expectHashAdmittedSchemaSubcommands,p as isExpectHashAdmissibleAction,T as isExpectHashAdmissibleInvocation,o as resolveExpectHashAction,l as resolveExpectHashCallAction};
|
|
2
2
|
//# sourceMappingURL=expect-hash-admission.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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
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";
|
|
3
|
+
export{expectHashAdmissionCondition,isExpectHashAdmissibleAction}from "./expect-hash-admission.js";export type{ItemRevisionRecoveryInvocation,ItemRevisionScope}from "../../core/store/item-mutation-precondition.js";
|
|
4
4
|
/** Refusal code for a locked write that found a revision other than the declared one. */
|
|
5
5
|
export declare const ITEM_REVISION_CONFLICT_CODE="item_revision_conflict";
|
|
6
6
|
/** Most recent history entries a conflict refusal describes. */
|
|
@@ -146,17 +146,25 @@ export declare function itemRevisionUncheckedWarning(id:string):string;
|
|
|
146
146
|
* Per-command discovery reads the same predicate (pm-6vk110).
|
|
147
147
|
*/
|
|
148
148
|
export declare function assertExpectHashAdmissible(path:string,options?:Record<string,unknown>):void;
|
|
149
|
-
/**
|
|
150
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Refusal for a revision guard on a command or action that writes no existing
|
|
151
|
+
* item. `create` and `copy` do write items, but only new ones, so the message
|
|
152
|
+
* says to remove the guard there rather than calling them reads.
|
|
153
|
+
*/
|
|
154
|
+
export declare function expectHashRequiresMutationError(action:string,subcommand?:unknown):PmCliError;
|
|
151
155
|
/**
|
|
152
156
|
* Generic-dispatch entry for the `expectHash` action parameter used by MCP and
|
|
153
157
|
* `PmClient.run`. Tokens follow the CLI grammar: a bare hash binds to the
|
|
154
158
|
* action's `id`, and `<id>=<hash>` names the target explicitly.
|
|
155
159
|
*/
|
|
156
|
-
export declare function dispatchWithExpectedItemRevisions<T>(params:{action:string;
|
|
160
|
+
export declare function dispatchWithExpectedItemRevisions<T>(params:{action:string;
|
|
161
|
+
/** The caller's own action name before alias resolution, which names the operation a guard is judged on. */
|
|
162
|
+
requestedAction?:string;expectHash:unknown;defaultId?:string;pmRoot:string;run:()=> Promise<T>;
|
|
157
163
|
/** Nested action options, consulted for modes the guard cannot cover (background test workers). */
|
|
158
164
|
options?:Record<string,unknown>;
|
|
159
165
|
/** Top-level background flag, consulted like `options.background`. */
|
|
160
166
|
background?:unknown;
|
|
167
|
+
/** The verb a subcommand-dispatched action runs, resolved as its handler resolves it. */
|
|
168
|
+
subcommand?:unknown;
|
|
161
169
|
/** Invocation whose tracker scope a revision refusal's recovery commands replay. */
|
|
162
170
|
invocation?:ItemRevisionRecoveryInvocation;}):Promise<T>;
|