@unbrained/pm-cli 2026.11.30 → 2026.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/commander-usage.js +10 -10
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/extension-command-help.js +6 -6
- package/dist/cli/help-json-payload.js +7 -7
- package/dist/cli/main.js +5 -5
- package/dist/cli/register-list-query.js +10 -10
- package/dist/cli/register-mutation.js +3 -3
- package/dist/cli/runtime/invocation-command-path.js +2 -0
- package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-DCWGM7CY.js → chunk-3HKPVOAN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Z7YL2SUM.js → chunk-3KEMIPKG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TX74QJ4W.js → chunk-4YYFY33T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-47ZS6RPL.js → chunk-7NAO7I75.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-IGEFPHV7.js → chunk-7V65VACG.js} +52 -52
- package/dist/cli-bundle/chunks/chunk-A5ZEMOVR.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-5PNOVDVO.js → chunk-AHV3CSQG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KCVSSONY.js → chunk-C6WM6ZN4.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-CBUC4X7Q.js +127 -0
- package/dist/cli-bundle/chunks/{chunk-CCKM5YQM.js → chunk-G6TARHFK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TY55UX6M.js → chunk-GOEQXVOI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-I4SPJQQI.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-Q4VZSMUL.js → chunk-L2ZSSMYY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NHBG5ET3.js → chunk-MZZ4ZJ5Z.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NRQCBUYD.js +113 -0
- package/dist/cli-bundle/chunks/{chunk-YVTALIN3.js → chunk-OBPO6V7H.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KXTKLDKD.js → chunk-OXC5KBIQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HXQ3OHQR.js → chunk-PCDTWL6V.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AOTI76Q6.js → chunk-Q6K7HWZ7.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-QDV7S2QS.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-NZSXWIX7.js → chunk-ROTEELDL.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-WFYE34TO.js → chunk-SDXCJZKB.js} +23 -23
- package/dist/cli-bundle/chunks/{chunk-2SBTXR6C.js → chunk-SY5C3U32.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FR7ULTM4.js → chunk-TKUG2X24.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FECZV72T.js → chunk-UNBW2LF3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-V2S4XAX3.js +2 -0
- package/dist/cli-bundle/chunks/chunk-WSEIEDEK.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZA5NS3PL.js → chunk-ZL6J6JYT.js} +6 -6
- package/dist/cli-bundle/chunks/{field-option-collisions-2F2Z7R7B.js → field-option-collisions-BBGTV7AD.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-3LENTXYF.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-56J5OCHA.js +2 -0
- package/dist/cli-bundle/chunks/{linked-resource-value-list-WXPPYUVQ.js → linked-resource-value-list-ZBIY4H23.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-actor-UK3QNEEB.js → mutation-actor-NHN33ITJ.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-UTDYPFWP.js → mutation-admission-PGKJTCG6.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-DRA3CWHI.js → register-list-query-7S5QWDTI.js} +11 -11
- package/dist/cli-bundle/chunks/{register-mutation-WO74VLEQ.js → register-mutation-EK6DVIQK.js} +5 -5
- package/dist/cli-bundle/chunks/{register-operations-CRBKH7WN.js → register-operations-6MURXE4V.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-6V6NQB5C.js → register-setup-RW26X3GJ.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-DYEHGASU.js → stage-4ZCF74G4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RQYVX2T6.js → chunk-2DGKVXFT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-2UWKU2BQ.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-A3DORTXS.js → chunk-3COWDIPX.js} +54 -54
- package/dist/cli-bundle/focused-chunks/{chunk-UQJ4PY2Y.js → chunk-4SCFAWAW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7G7JIXLL.js → chunk-6BKT6XQN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-6IY5CVGJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-7A6SEZEY.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IJ3T3W4U.js → chunk-BHNBPCHP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LWBZ7UGG.js → chunk-EQCQTYKO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FM5WQ6ZU.js → chunk-HTDYNY4L.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TQQO42C2.js → chunk-J72TRWR5.js} +26 -26
- package/dist/cli-bundle/focused-chunks/{chunk-L357ZAES.js → chunk-JPZGC3W4.js} +5 -5
- package/dist/cli-bundle/focused-chunks/{chunk-62AMZMR4.js → chunk-KNBGHCIP.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-N64AC5G6.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IIVDBAJM.js → chunk-OG57ESZK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MZNV26XE.js → chunk-P2H3GTJK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QZRYGYTI.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-SQMOF65W.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-T3ILWAEV.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-SXC3NVZI.js → chunk-TR22GU7M.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-M57KDG7I.js → chunk-TXTPAFHJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-VK3IE3TS.js +29 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NJTKGBSK.js → chunk-VQIC3UZB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-U35K7FSE.js → chunk-W4JMV7GF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-7TG7STO7.js → field-option-collisions-2C6DLUC4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-723XCQPS.js +2 -0
- package/dist/cli-bundle/focused-chunks/{item-transaction-2IC2MLML.js → item-transaction-LQLQLZE7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-LJVF2HVD.js → mutation-actor-DJMZUIZI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-SDWQVVHN.js +2 -0
- package/dist/cli-bundle/focused-chunks/{stage-MWR73LTZ.js → stage-QBZIK3T5.js} +2 -2
- package/dist/cli-bundle/main.js +27 -27
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +61 -61
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +2 -2
- package/dist/core/extensions/reserved-host-flags.js +1 -1
- package/dist/core/shared/secret-rules.d.ts +86 -12
- package/dist/core/shared/secret-rules.js +7 -5
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +50 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension/install-sources.d.ts +2 -2
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/lifecycle/expect-hash-admission.d.ts +15 -0
- package/dist/sdk/lifecycle/expect-hash-admission.js +2 -0
- package/dist/sdk/lifecycle/item-revision.d.ts +4 -1
- package/dist/sdk/lifecycle/item-revision.js +1 -1
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/output-contracts.js +1 -1
- package/dist/sdk/output-projection.d.ts +1 -1
- package/dist/sdk/output-projection.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/aggregate.js +1 -1
- package/dist/sdk/query/context.js +1 -1
- package/dist/sdk/query/list.js +1 -1
- package/dist/sdk/query/next.js +1 -1
- package/dist/sdk/query/search-contracts.js +1 -1
- package/dist/sdk/read-output/surfaces.js +1 -1
- package/dist/sdk/read-output-budget.d.ts +1 -1
- package/dist/sdk/read-output-budget.js +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/read-output-rows.js +1 -1
- package/docs/COMMANDS.md +37 -0
- package/docs/MUTATION_INTEGRITY.md +226 -10
- package/docs/SDK.md +16 -6
- package/docs/agent-task-token-baseline.json +1 -1
- package/marketplace.json +1 -1
- package/node_modules/tar/README.md +1792 -1147
- package/node_modules/tar/dist/commonjs/bytes.d.ts +21 -0
- package/node_modules/tar/dist/commonjs/bytes.js +83 -0
- package/node_modules/tar/dist/commonjs/codec.d.ts +53 -0
- package/node_modules/tar/dist/commonjs/codec.js +35 -0
- package/node_modules/tar/dist/commonjs/concat.d.ts +3 -0
- package/node_modules/tar/dist/commonjs/concat.js +20 -0
- package/node_modules/tar/dist/commonjs/create.d.ts +39 -2
- package/node_modules/tar/dist/commonjs/create.js +150 -64
- package/node_modules/tar/dist/commonjs/dealias.d.ts +79 -0
- package/node_modules/tar/dist/commonjs/dealias.js +50 -0
- package/node_modules/tar/dist/commonjs/delete.d.ts +19 -0
- package/node_modules/tar/dist/commonjs/delete.js +121 -0
- package/node_modules/tar/dist/commonjs/entries.d.ts +82 -0
- package/node_modules/tar/dist/commonjs/entries.js +398 -0
- package/node_modules/tar/dist/commonjs/extract.d.ts +14 -2
- package/node_modules/tar/dist/commonjs/extract.js +40 -81
- package/node_modules/tar/dist/commonjs/fs.d.ts +201 -0
- package/node_modules/tar/dist/commonjs/fs.js +5 -0
- package/node_modules/tar/dist/commonjs/header.d.ts +4 -4
- package/node_modules/tar/dist/commonjs/header.js +71 -53
- package/node_modules/tar/dist/commonjs/index.d.ts +25 -18
- package/node_modules/tar/dist/commonjs/index.js +46 -18
- package/node_modules/tar/dist/commonjs/index.min.js +2 -3
- package/node_modules/tar/dist/commonjs/large-numbers.d.ts +2 -2
- package/node_modules/tar/dist/commonjs/large-numbers.js +4 -4
- package/node_modules/tar/dist/commonjs/list.d.ts +23 -6
- package/node_modules/tar/dist/commonjs/list.js +99 -138
- package/node_modules/tar/dist/commonjs/mkdir.d.ts +16 -11
- package/node_modules/tar/dist/commonjs/mkdir.js +121 -159
- package/node_modules/tar/dist/commonjs/normalize-unicode.js +9 -0
- package/node_modules/tar/dist/commonjs/options.d.ts +284 -513
- package/node_modules/tar/dist/commonjs/options.js +20 -61
- package/node_modules/tar/dist/commonjs/pack.d.ts +150 -96
- package/node_modules/tar/dist/commonjs/pack.js +752 -445
- package/node_modules/tar/dist/commonjs/parser.d.ts +98 -0
- package/node_modules/tar/dist/commonjs/parser.js +452 -0
- package/node_modules/tar/dist/commonjs/path-reservations.d.ts +17 -7
- package/node_modules/tar/dist/commonjs/path-reservations.js +110 -140
- package/node_modules/tar/dist/commonjs/path.d.ts +19 -0
- package/node_modules/tar/dist/commonjs/path.js +90 -0
- package/node_modules/tar/dist/commonjs/pax.d.ts +3 -1
- package/node_modules/tar/dist/commonjs/pax.js +67 -36
- package/node_modules/tar/dist/commonjs/read-entry.d.ts +97 -11
- package/node_modules/tar/dist/commonjs/read-entry.js +251 -97
- package/node_modules/tar/dist/commonjs/read-file.d.ts +22 -0
- package/node_modules/tar/dist/commonjs/read-file.js +104 -0
- package/node_modules/tar/dist/commonjs/replace.d.ts +45 -1
- package/node_modules/tar/dist/commonjs/replace.js +164 -211
- package/node_modules/tar/dist/commonjs/server/codecs.d.ts +38 -0
- package/node_modules/tar/dist/commonjs/server/codecs.js +252 -0
- package/node_modules/tar/dist/commonjs/server/index.d.ts +115 -0
- package/node_modules/tar/dist/commonjs/server/index.js +166 -0
- package/node_modules/tar/dist/commonjs/server/index.min.js +3 -0
- package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +8 -0
- package/node_modules/tar/dist/commonjs/strip-absolute-path.js +17 -20
- package/node_modules/tar/dist/commonjs/to-stream.d.ts +7 -0
- package/node_modules/tar/dist/commonjs/to-stream.js +22 -0
- package/node_modules/tar/dist/commonjs/types.d.ts +4 -3
- package/node_modules/tar/dist/commonjs/types.js +4 -3
- package/node_modules/tar/dist/commonjs/unpack.d.ts +143 -89
- package/node_modules/tar/dist/commonjs/unpack.js +780 -725
- package/node_modules/tar/dist/commonjs/update.d.ts +11 -1
- package/node_modules/tar/dist/commonjs/update.js +37 -28
- package/node_modules/tar/dist/commonjs/warn.d.ts +27 -0
- package/node_modules/tar/dist/commonjs/warn.js +36 -0
- package/node_modules/tar/dist/commonjs/win32-path.d.ts +16 -0
- package/node_modules/tar/dist/commonjs/win32-path.js +67 -0
- package/node_modules/tar/dist/commonjs/write-entry.d.ts +64 -111
- package/node_modules/tar/dist/commonjs/write-entry.js +108 -672
- package/node_modules/tar/dist/commonjs/write-flag.d.ts +18 -0
- package/node_modules/tar/dist/commonjs/write-flag.js +29 -0
- package/node_modules/tar/dist/esm/bytes.d.ts +21 -0
- package/node_modules/tar/dist/esm/bytes.js +72 -0
- package/node_modules/tar/dist/esm/codec.d.ts +53 -0
- package/node_modules/tar/dist/esm/codec.js +32 -0
- package/node_modules/tar/dist/esm/concat.d.ts +3 -0
- package/node_modules/tar/dist/esm/concat.js +16 -0
- package/node_modules/tar/dist/esm/create.d.ts +39 -2
- package/node_modules/tar/dist/esm/create.js +144 -61
- package/node_modules/tar/dist/esm/dealias.d.ts +79 -0
- package/node_modules/tar/dist/esm/dealias.js +46 -0
- package/node_modules/tar/dist/esm/delete.d.ts +19 -0
- package/node_modules/tar/dist/esm/delete.js +117 -0
- package/node_modules/tar/dist/esm/entries.d.ts +82 -0
- package/node_modules/tar/dist/esm/entries.js +388 -0
- package/node_modules/tar/dist/esm/extract.d.ts +14 -2
- package/node_modules/tar/dist/esm/extract.js +37 -44
- package/node_modules/tar/dist/esm/fs.d.ts +201 -0
- package/node_modules/tar/dist/esm/fs.js +4 -0
- package/node_modules/tar/dist/esm/header.d.ts +4 -4
- package/node_modules/tar/dist/esm/header.js +71 -53
- package/node_modules/tar/dist/esm/index.d.ts +25 -18
- package/node_modules/tar/dist/esm/index.js +23 -18
- package/node_modules/tar/dist/esm/index.min.js +2 -3
- package/node_modules/tar/dist/esm/large-numbers.d.ts +2 -2
- package/node_modules/tar/dist/esm/large-numbers.js +4 -4
- package/node_modules/tar/dist/esm/list.d.ts +23 -6
- package/node_modules/tar/dist/esm/list.js +96 -101
- package/node_modules/tar/dist/esm/mkdir.d.ts +16 -11
- package/node_modules/tar/dist/esm/mkdir.js +119 -154
- package/node_modules/tar/dist/esm/normalize-unicode.js +9 -0
- package/node_modules/tar/dist/esm/options.d.ts +284 -513
- package/node_modules/tar/dist/esm/options.js +17 -51
- package/node_modules/tar/dist/esm/pack.d.ts +150 -96
- package/node_modules/tar/dist/esm/pack.js +750 -441
- package/node_modules/tar/dist/esm/parser.d.ts +98 -0
- package/node_modules/tar/dist/esm/parser.js +448 -0
- package/node_modules/tar/dist/esm/path-reservations.d.ts +17 -7
- package/node_modules/tar/dist/esm/path-reservations.js +110 -140
- package/node_modules/tar/dist/esm/path.d.ts +19 -0
- package/node_modules/tar/dist/esm/path.js +80 -0
- package/node_modules/tar/dist/esm/pax.d.ts +3 -1
- package/node_modules/tar/dist/esm/pax.js +66 -35
- package/node_modules/tar/dist/esm/read-entry.d.ts +97 -11
- package/node_modules/tar/dist/esm/read-entry.js +248 -96
- package/node_modules/tar/dist/esm/read-file.d.ts +22 -0
- package/node_modules/tar/dist/esm/read-file.js +99 -0
- package/node_modules/tar/dist/esm/replace.d.ts +45 -1
- package/node_modules/tar/dist/esm/replace.js +160 -207
- package/node_modules/tar/dist/esm/server/codecs.d.ts +38 -0
- package/node_modules/tar/dist/esm/server/codecs.js +214 -0
- package/node_modules/tar/dist/esm/server/index.d.ts +115 -0
- package/node_modules/tar/dist/esm/server/index.js +102 -0
- package/node_modules/tar/dist/esm/server/index.min.js +3 -0
- package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +8 -0
- package/node_modules/tar/dist/esm/strip-absolute-path.js +17 -20
- package/node_modules/tar/dist/esm/to-stream.d.ts +7 -0
- package/node_modules/tar/dist/esm/to-stream.js +18 -0
- package/node_modules/tar/dist/esm/types.d.ts +4 -3
- package/node_modules/tar/dist/esm/types.js +4 -3
- package/node_modules/tar/dist/esm/unpack.d.ts +143 -89
- package/node_modules/tar/dist/esm/unpack.js +776 -719
- package/node_modules/tar/dist/esm/update.d.ts +11 -1
- package/node_modules/tar/dist/esm/update.js +35 -28
- package/node_modules/tar/dist/esm/warn.d.ts +27 -0
- package/node_modules/tar/dist/esm/warn.js +31 -0
- package/node_modules/tar/dist/esm/win32-path.d.ts +16 -0
- package/node_modules/tar/dist/esm/win32-path.js +60 -0
- package/node_modules/tar/dist/esm/write-entry.d.ts +64 -111
- package/node_modules/tar/dist/esm/write-entry.js +107 -633
- package/node_modules/tar/dist/esm/write-flag.d.ts +18 -0
- package/node_modules/tar/dist/esm/write-flag.js +25 -0
- package/node_modules/tar/package.json +68 -224
- package/package.json +2 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3TXEWHQX.js +0 -125
- package/dist/cli-bundle/chunks/chunk-JPJNJHQW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NVYDPNQP.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SJWIPGZW.js +0 -113
- package/dist/cli-bundle/chunks/chunk-USBTXMKS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-VCXQ6A35.js +0 -3
- package/dist/cli-bundle/chunks/chunk-YPMNXG2C.js +0 -2
- package/dist/cli-bundle/chunks/item-revision-UAF6L47R.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-RJECL53Y.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2UUBS4BG.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4ER3VMST.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4YBMHMBJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HXM7K6VH.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-NGHT2LNG.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-P55AZPFN.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-WAP3DF4B.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-XR745UGE.js +0 -4
- package/dist/cli-bundle/focused-chunks/item-revision-J7EUGCHR.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-SLFAUONA.js +0 -2
- package/node_modules/@isaacs/fs-minipass/LICENSE +0 -15
- package/node_modules/@isaacs/fs-minipass/README.md +0 -71
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +0 -118
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +0 -430
- package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +0 -3
- package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +0 -118
- package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +0 -420
- package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +0 -3
- package/node_modules/@isaacs/fs-minipass/package.json +0 -72
- package/node_modules/chownr/LICENSE.md +0 -63
- package/node_modules/chownr/README.md +0 -3
- package/node_modules/chownr/dist/commonjs/index.d.ts +0 -3
- package/node_modules/chownr/dist/commonjs/index.js +0 -93
- package/node_modules/chownr/dist/commonjs/package.json +0 -3
- package/node_modules/chownr/dist/esm/index.d.ts +0 -3
- package/node_modules/chownr/dist/esm/index.js +0 -85
- package/node_modules/chownr/dist/esm/package.json +0 -3
- package/node_modules/chownr/package.json +0 -69
- package/node_modules/minipass/LICENSE.md +0 -55
- package/node_modules/minipass/README.md +0 -825
- package/node_modules/minipass/dist/commonjs/index.d.ts +0 -545
- package/node_modules/minipass/dist/commonjs/index.js +0 -1038
- package/node_modules/minipass/dist/commonjs/package.json +0 -3
- package/node_modules/minipass/dist/esm/index.d.ts +0 -545
- package/node_modules/minipass/dist/esm/index.js +0 -1020
- package/node_modules/minipass/dist/esm/package.json +0 -3
- package/node_modules/minipass/package.json +0 -77
- package/node_modules/minizlib/LICENSE +0 -26
- package/node_modules/minizlib/README.md +0 -64
- package/node_modules/minizlib/dist/commonjs/constants.d.ts +0 -2
- package/node_modules/minizlib/dist/commonjs/constants.js +0 -123
- package/node_modules/minizlib/dist/commonjs/index.d.ts +0 -99
- package/node_modules/minizlib/dist/commonjs/index.js +0 -416
- package/node_modules/minizlib/dist/commonjs/package.json +0 -3
- package/node_modules/minizlib/dist/esm/constants.d.ts +0 -2
- package/node_modules/minizlib/dist/esm/constants.js +0 -117
- package/node_modules/minizlib/dist/esm/index.d.ts +0 -99
- package/node_modules/minizlib/dist/esm/index.js +0 -363
- package/node_modules/minizlib/dist/esm/package.json +0 -3
- package/node_modules/minizlib/package.json +0 -80
- package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/get-write-flag.js +0 -32
- package/node_modules/tar/dist/commonjs/make-command.d.ts +0 -49
- package/node_modules/tar/dist/commonjs/make-command.js +0 -52
- package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/normalize-windows-path.js +0 -12
- package/node_modules/tar/dist/commonjs/parse.d.ts +0 -92
- package/node_modules/tar/dist/commonjs/parse.js +0 -655
- package/node_modules/tar/dist/commonjs/process-umask.d.ts +0 -2
- package/node_modules/tar/dist/commonjs/process-umask.js +0 -7
- package/node_modules/tar/dist/commonjs/warn-method.d.ts +0 -24
- package/node_modules/tar/dist/commonjs/warn-method.js +0 -31
- package/node_modules/tar/dist/esm/get-write-flag.d.ts +0 -2
- package/node_modules/tar/dist/esm/get-write-flag.js +0 -26
- package/node_modules/tar/dist/esm/make-command.d.ts +0 -49
- package/node_modules/tar/dist/esm/make-command.js +0 -48
- package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +0 -2
- package/node_modules/tar/dist/esm/normalize-windows-path.js +0 -9
- package/node_modules/tar/dist/esm/parse.d.ts +0 -92
- package/node_modules/tar/dist/esm/parse.js +0 -651
- package/node_modules/tar/dist/esm/process-umask.d.ts +0 -2
- package/node_modules/tar/dist/esm/process-umask.js +0 -3
- package/node_modules/tar/dist/esm/warn-method.d.ts +0 -24
- package/node_modules/tar/dist/esm/warn-method.js +0 -27
- package/node_modules/yallist/LICENSE.md +0 -63
- package/node_modules/yallist/README.md +0 -205
- package/node_modules/yallist/dist/commonjs/index.d.ts +0 -39
- package/node_modules/yallist/dist/commonjs/index.js +0 -384
- package/node_modules/yallist/dist/commonjs/package.json +0 -3
- package/node_modules/yallist/dist/esm/index.d.ts +0 -39
- package/node_modules/yallist/dist/esm/index.js +0 -379
- package/node_modules/yallist/dist/esm/package.json +0 -3
- package/node_modules/yallist/package.json +0 -68
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ac as P,Bb as R,Bc as M,Cb as g,M as O,N as v,Oc as x,Pc as N,Pe as T,ja as E}from"./chunk-SJWIPGZW.js";import{nb as b}from"./chunk-JPJNJHQW.js";import{L as w,M as S,S as I,k as p,m as C,o as k,x as y}from"./chunk-VCXQ6A35.js";import{A as f,C as h}from"./chunk-K672XXGQ.js";import{Command as U}from"commander";function Q(n){return new U().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(n).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:e=>{T(e)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the result encoding for reads and mutations").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume continuation_kind=output_cursor").option("--output-row-contract","Include row selectors, encoding metadata, and read-output receipts").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--all","Reveal every public command and compatibility alias").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").option("--expect-hash <revision>","Refuse writes to the named item unless it is still at this item_hash from pm get (a bare hash names the command's <id>; guard each other item with <id>=<item_hash>, repeatable)",(e,t)=>[...t??[],e]).exitOverride()}function re(n){if(n===void 0)return()=>{};let e=n.trim();if(e.length===0)throw new h("--author requires a non-empty value.",f.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let t=R();g(e);let o=!1;return()=>{o||(o=!0,t===void 0?g(void 0):g(t))}}var c=Object.freeze({clock:"PM_CLOCK",tickMs:"PM_CLOCK_TICK_MS",seed:"PM_SEED"});function _(n,e,t,o){return new h(n,f.USAGE,{code:"invalid_reproducible_process_environment",reason:e,field:t,required:`${c.clock} and ${c.seed}; ${c.tickMs} is optional`,nextSteps:[`Set ${c.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${c.seed} to a non-empty reproducibility seed.`,`Optionally set ${c.tickMs} to a non-negative integer; it defaults to 1.`,"Unset all three variables to retain normal wall-clock and cryptographic-random behavior."],recovery:{recovery_mode:"compact",provided_fields:o,missing_required_fields:e==="incomplete"?[c.clock,c.seed].filter(r=>!o.includes(r)):void 0}})}function z(n){let e=n[c.clock],t=n[c.tickMs],o=n[c.seed],r=[[c.clock,e],[c.tickMs,t],[c.seed,o]].filter(s=>s[1]!==void 0).map(([s])=>s);if(r.length===0)return;if(e===void 0||o===void 0)throw _("Reproducible process execution requires PM_CLOCK and PM_SEED together.","incomplete",e===void 0?c.clock:c.seed,r);if(o.trim().length===0)throw _(`${c.seed} must not be empty.`,"invalid_value",c.seed,r);if(!I(e))throw _(`${c.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`,"invalid_value",c.clock,r);let a=t===void 0?1:Number(t);if(t?.trim().length===0||!Number.isSafeInteger(a)||a<0)throw _(`${c.tickMs} must be a non-negative integer.`,"invalid_value",c.tickMs,r);return w({clock:e,seed:o,tickMs:a})}function W(n){let e=z(n);return e===void 0?t=>t():S(e)}async function ue(n,e){return W(n)(e)}var $=new Set([...Object.values(P),...M,"--full","--brief","--compact","--summary","--fields","--section","--token-budget"]),L=new Set(["--full-changed-fields","--no-changed-fields","--id-only"]);function ke(n,e){if(!["block","unblock"].includes(n)||e.includes(n)||!e.includes("update"))return;let t=new Set(b("update").map(r=>r.flag));if((n==="block"?["--blocked-by","--blocked-reason"]:["--unset","--unblock-note"]).every(r=>t.has(r)))return n==="block"?{examples:[["update","<item-id>","--blocked-by","<blocker-id>","--blocked-reason","<reason>"]],nextSteps:["Choose the actual item and blocker identifiers before running update. --blocked-by records the blocker field and its blocked_by relationship."]}:{examples:[["update","<item-id>","--unset","blocked-by","--unset","blocked-reason","--unblock-note","<note>"]],nextSteps:[`Inspect the item's blockers before running update. --unset blocked-by removes the blocker field and the blocked_by rows naming it; other blocked_by relationships stay, so remove one with --dep-remove "id=<id>,kind=blocked_by" or all with --dep-remove kind=blocked_by. --unset blocked-reason clears the stale reason. --unblock-note alone records a note and does not unblock the item.`,"If your project also uses a blocked lifecycle status, choose its appropriate next status separately with update --status."]}}function q(n,e){let t=n.includes("="),o=t?n.slice(n.indexOf("=")+1):e;if(!(!o||o.startsWith("--")))return{consumed:t?1:2,replacement:["--from",o],conflicts:["--from"]}}var G=["--depth","--output-include","--fields","--section","--for"];function B(n){let e=x(p(n.trim().toLowerCase()));if(e===void 0)return;let t=b(e),o=t.flatMap(s=>[s.flag,...s.aliases??[]]),r=[...N(e).keys()].filter(s=>o.includes(`--${s}`)),a=[...t.find(s=>s.flag==="--depth")?.values??[]];if(!(r.length===0&&a.length===0))return{command:e,modes:r,depth_values:a,declared_flags:o}}function xe(n){return[...n.depth_values.length>0?[`--depth ${n.depth_values.join("|")}`]:[],...n.modes.map(e=>`--${e}`)].join(", ")}function V(n,e,t,o){let r=B(n);if(r===void 0||r.declared_flags.includes(e))return;let a=[...G,...r.modes.map(i=>`--${i}`)].filter(i=>i!==e);if(e==="--depth"){let i=t.includes("="),l=(i?t.slice(t.indexOf("=")+1):o)?.trim().toLowerCase();if(!l)return;let u=i?1:2;return r.modes.includes(l)?{consumed:u,replacement:[`--${l}`],conflicts:a}:l==="standard"?{consumed:u,replacement:[],conflicts:a}:void 0}let s=e.slice(2);return t===e&&r.depth_values.includes(s)?{consumed:1,replacement:["--depth",s],conflicts:a}:void 0}function Y(n,e,t,o){return e==="--since"&&n==="activity"?q(t,o):e==="--toon"&&t===e?{consumed:1,replacement:["--output-format","toon"],conflicts:["--json","--format","--output-format","--stream"]}:V(n,e,t,o)}function J(n){let e=O(n);if(e===void 0)return;let t=n[e].trim().toLowerCase(),o=`${t} ${n[e+1]?.trim().toLowerCase()??""}`,r=p(o);return r!==o.trim()?r:t==="ctx"?"context":p(t)}function Ce(n,e,t){let o=n==="ctx"?"context":p(n);if(x(o)===void 0||e.includes("--")||J(e)!==o)return;let r=t.split("=",1)[0],a=e.flatMap((m,j)=>m===r||m.startsWith(`${r}=`)?[j]:[]);if(a.length!==1)return;let s=a[0],i=Y(o,r,e[s],e[s+1]);if(!i)return;let{replacement:l,consumed:u,conflicts:d}=i;if(!e.some(m=>d.includes(m.split("=",1)[0])))return[...e.slice(0,s),...l,...e.slice(s+u)]}function A(n){let e=n.split("=",1)[0].replaceAll("_","-");return $.has(e)||e.length>=5&&[...$].some(t=>t.startsWith(e))}function Oe(n,e){let t=n.split("=",1)[0].replaceAll("_","-");return A(t)?!L.has(e):L.has(t)?!A(e):!0}function F(n){return n.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function ve(n){if(!(!Array.isArray(n)||n.length===0))return v(n)}function K(n,e){let t=F(e);if(!t)return;let o=b(n).find(r=>r.flag===t||r.aliases?.includes(t));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function ye(n,e,t){let o=[...n],r=o.indexOf("--"),a=r<0?o.length:r;for(let s of t){let i=F(s);if(!i||o.slice(0,a).some(d=>d===i||d.startsWith(`${i}=`)))continue;let l=K(e,i),u=l?[i,l]:[i];o.splice(a,0,...u),a+=u.length}return o.length===n.length?void 0:y(o)}function Ne(n,e){let t=n.trim().split(/\s+/u);if(!(t.length<2||e.includes(t.join(" "))))for(let o=1;o<t.length;o+=1){if(!e.includes(t.slice(0,o).join(" ")))return;let r=t.slice(o).join(" "),a=k(r),s=new Set(e.filter(i=>i===r||i.endsWith(` ${r}`)||i===a?.canonical).map(i=>k(i)?.canonical??i).filter(i=>e.includes(i)));if(s.size>0)return s.size===1?[...s][0]:void 0}}var X={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"],start:["start-task"]};function D(n,e){let t=n.trim().toLowerCase(),o=e.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let r=t.split(" "),a=X[o]?.indexOf(p(t));if(a!==void 0&&a>=0)return a;if(t===o)return 10;if(r.includes(o))return 11;if(r.some(l=>l.startsWith(o)))return 12;let s=o.length>=5?2:1,i=Number.POSITIVE_INFINITY;for(let l of r){let u=E(l,o,s);u!==null&&(i=Math.min(i,u))}return Number.isFinite(i)?20+i:t.includes(o)?30:Number.POSITIVE_INFINITY}function Te(n,e){return n.map(t=>({path:t,score:D(t,e)})).filter(t=>Number.isFinite(t.score)).sort((t,o)=>t.score!==o.score?t.score-o.score:t.path===o.path?0:t.path<o.path?-1:1).map(t=>t.path)}function $e(n,e,t){let o=new Set(e),r=C.filter(i=>i.lifecycle==="deprecated").slice().sort((i,l)=>l.alias.length-i.alias.length),a=[],s=n.flatMap(i=>{let l=r.find(d=>i===d.alias||i.startsWith(`${d.alias} `)),u=i;if(l){let d=i.slice(l.alias.length);if(!o.has(`${l.canonical}${d}`))return[];u=`${l.canonical_argv.join(" ")}${d}`}return t!==void 0&&D(i,t)<10&&a.push(u),[u]});return[...new Set(a.length>0?a:s)]}export{Q as a,re as b,c,z as d,W as e,ue as f,ke as g,B as h,xe as i,Ce as j,A as k,Oe as l,ve as m,K as n,ye as o,Ne as p,D as q,Te as r,$e as s};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{Bb as R,Cb as g,Ke as T,M as O,N as v,ja as E}from"./chunk-NRQCBUYD.js";import{vb as b}from"./chunk-A5ZEMOVR.js";import{L as w,M as S,S as I,ia as P,ja as M,k as p,m as C,o as k,pa as x,qa as N,x as y}from"./chunk-I4SPJQQI.js";import{A as f,C as h}from"./chunk-K672XXGQ.js";import{Command as U}from"commander";function Q(n){return new U().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(n).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:e=>{T(e)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the result encoding for reads and mutations").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume continuation_kind=output_cursor").option("--output-row-contract","Include row selectors, encoding metadata, and read-output receipts").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--all","Reveal every public command and compatibility alias").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").option("--expect-hash <revision>","Refuse writes to the named item unless it is still at this item_hash from pm get (a bare hash names the command's <id>; guard each other item with <id>=<item_hash>, repeatable)",(e,t)=>[...t??[],e]).exitOverride()}function re(n){if(n===void 0)return()=>{};let e=n.trim();if(e.length===0)throw new h("--author requires a non-empty value.",f.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let t=R();g(e);let o=!1;return()=>{o||(o=!0,t===void 0?g(void 0):g(t))}}var c=Object.freeze({clock:"PM_CLOCK",tickMs:"PM_CLOCK_TICK_MS",seed:"PM_SEED"});function _(n,e,t,o){return new h(n,f.USAGE,{code:"invalid_reproducible_process_environment",reason:e,field:t,required:`${c.clock} and ${c.seed}; ${c.tickMs} is optional`,nextSteps:[`Set ${c.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${c.seed} to a non-empty reproducibility seed.`,`Optionally set ${c.tickMs} to a non-negative integer; it defaults to 1.`,"Unset all three variables to retain normal wall-clock and cryptographic-random behavior."],recovery:{recovery_mode:"compact",provided_fields:o,missing_required_fields:e==="incomplete"?[c.clock,c.seed].filter(r=>!o.includes(r)):void 0}})}function z(n){let e=n[c.clock],t=n[c.tickMs],o=n[c.seed],r=[[c.clock,e],[c.tickMs,t],[c.seed,o]].filter(s=>s[1]!==void 0).map(([s])=>s);if(r.length===0)return;if(e===void 0||o===void 0)throw _("Reproducible process execution requires PM_CLOCK and PM_SEED together.","incomplete",e===void 0?c.clock:c.seed,r);if(o.trim().length===0)throw _(`${c.seed} must not be empty.`,"invalid_value",c.seed,r);if(!I(e))throw _(`${c.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`,"invalid_value",c.clock,r);let a=t===void 0?1:Number(t);if(t?.trim().length===0||!Number.isSafeInteger(a)||a<0)throw _(`${c.tickMs} must be a non-negative integer.`,"invalid_value",c.tickMs,r);return w({clock:e,seed:o,tickMs:a})}function W(n){let e=z(n);return e===void 0?t=>t():S(e)}async function ue(n,e){return W(n)(e)}var $=new Set([...Object.values(P),...M,"--full","--brief","--compact","--summary","--fields","--section","--token-budget"]),L=new Set(["--full-changed-fields","--no-changed-fields","--id-only"]);function ke(n,e){if(!["block","unblock"].includes(n)||e.includes(n)||!e.includes("update"))return;let t=new Set(b("update").map(r=>r.flag));if((n==="block"?["--blocked-by","--blocked-reason"]:["--unset","--unblock-note"]).every(r=>t.has(r)))return n==="block"?{examples:[["update","<item-id>","--blocked-by","<blocker-id>","--blocked-reason","<reason>"]],nextSteps:["Choose the actual item and blocker identifiers before running update. --blocked-by records the blocker field and its blocked_by relationship."]}:{examples:[["update","<item-id>","--unset","blocked-by","--unset","blocked-reason","--unblock-note","<note>"]],nextSteps:[`Inspect the item's blockers before running update. --unset blocked-by removes the blocker field and the blocked_by rows naming it; other blocked_by relationships stay, so remove one with --dep-remove "id=<id>,kind=blocked_by" or all with --dep-remove kind=blocked_by. --unset blocked-reason clears the stale reason. --unblock-note alone records a note and does not unblock the item.`,"If your project also uses a blocked lifecycle status, choose its appropriate next status separately with update --status."]}}function q(n,e){let t=n.includes("="),o=t?n.slice(n.indexOf("=")+1):e;if(!(!o||o.startsWith("--")))return{consumed:t?1:2,replacement:["--from",o],conflicts:["--from"]}}var G=["--depth","--output-include","--fields","--section","--for"];function B(n){let e=x(p(n.trim().toLowerCase()));if(e===void 0)return;let t=b(e),o=t.flatMap(s=>[s.flag,...s.aliases??[]]),r=[...N(e).keys()].filter(s=>o.includes(`--${s}`)),a=[...t.find(s=>s.flag==="--depth")?.values??[]];if(!(r.length===0&&a.length===0))return{command:e,modes:r,depth_values:a,declared_flags:o}}function xe(n){return[...n.depth_values.length>0?[`--depth ${n.depth_values.join("|")}`]:[],...n.modes.map(e=>`--${e}`)].join(", ")}function V(n,e,t,o){let r=B(n);if(r===void 0||r.declared_flags.includes(e))return;let a=[...G,...r.modes.map(i=>`--${i}`)].filter(i=>i!==e);if(e==="--depth"){let i=t.includes("="),l=(i?t.slice(t.indexOf("=")+1):o)?.trim().toLowerCase();if(!l)return;let u=i?1:2;return r.modes.includes(l)?{consumed:u,replacement:[`--${l}`],conflicts:a}:l==="standard"?{consumed:u,replacement:[],conflicts:a}:void 0}let s=e.slice(2);return t===e&&r.depth_values.includes(s)?{consumed:1,replacement:["--depth",s],conflicts:a}:void 0}function Y(n,e,t,o){return e==="--since"&&n==="activity"?q(t,o):e==="--toon"&&t===e?{consumed:1,replacement:["--output-format","toon"],conflicts:["--json","--format","--output-format","--stream"]}:V(n,e,t,o)}function J(n){let e=O(n);if(e===void 0)return;let t=n[e].trim().toLowerCase(),o=`${t} ${n[e+1]?.trim().toLowerCase()??""}`,r=p(o);return r!==o.trim()?r:t==="ctx"?"context":p(t)}function Ce(n,e,t){let o=n==="ctx"?"context":p(n);if(x(o)===void 0||e.includes("--")||J(e)!==o)return;let r=t.split("=",1)[0],a=e.flatMap((m,j)=>m===r||m.startsWith(`${r}=`)?[j]:[]);if(a.length!==1)return;let s=a[0],i=Y(o,r,e[s],e[s+1]);if(!i)return;let{replacement:l,consumed:u,conflicts:d}=i;if(!e.some(m=>d.includes(m.split("=",1)[0])))return[...e.slice(0,s),...l,...e.slice(s+u)]}function A(n){let e=n.split("=",1)[0].replaceAll("_","-");return $.has(e)||e.length>=5&&[...$].some(t=>t.startsWith(e))}function Oe(n,e){let t=n.split("=",1)[0].replaceAll("_","-");return A(t)?!L.has(e):L.has(t)?!A(e):!0}function F(n){return n.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function ve(n){if(!(!Array.isArray(n)||n.length===0))return v(n)}function K(n,e){let t=F(e);if(!t)return;let o=b(n).find(r=>r.flag===t||r.aliases?.includes(t));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function ye(n,e,t){let o=[...n],r=o.indexOf("--"),a=r<0?o.length:r;for(let s of t){let i=F(s);if(!i||o.slice(0,a).some(d=>d===i||d.startsWith(`${i}=`)))continue;let l=K(e,i),u=l?[i,l]:[i];o.splice(a,0,...u),a+=u.length}return o.length===n.length?void 0:y(o)}function Ne(n,e){let t=n.trim().split(/\s+/u);if(!(t.length<2||e.includes(t.join(" "))))for(let o=1;o<t.length;o+=1){if(!e.includes(t.slice(0,o).join(" ")))return;let r=t.slice(o).join(" "),a=k(r),s=new Set(e.filter(i=>i===r||i.endsWith(` ${r}`)||i===a?.canonical).map(i=>k(i)?.canonical??i).filter(i=>e.includes(i)));if(s.size>0)return s.size===1?[...s][0]:void 0}}var X={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"],start:["start-task"]};function D(n,e){let t=n.trim().toLowerCase(),o=e.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let r=t.split(" "),a=X[o]?.indexOf(p(t));if(a!==void 0&&a>=0)return a;if(t===o)return 10;if(r.includes(o))return 11;if(r.some(l=>l.startsWith(o)))return 12;let s=o.length>=5?2:1,i=Number.POSITIVE_INFINITY;for(let l of r){let u=E(l,o,s);u!==null&&(i=Math.min(i,u))}return Number.isFinite(i)?20+i:t.includes(o)?30:Number.POSITIVE_INFINITY}function Te(n,e){return n.map(t=>({path:t,score:D(t,e)})).filter(t=>Number.isFinite(t.score)).sort((t,o)=>t.score!==o.score?t.score-o.score:t.path===o.path?0:t.path<o.path?-1:1).map(t=>t.path)}function $e(n,e,t){let o=new Set(e),r=C.filter(i=>i.lifecycle==="deprecated").slice().sort((i,l)=>l.alias.length-i.alias.length),a=[],s=n.flatMap(i=>{let l=r.find(d=>i===d.alias||i.startsWith(`${d.alias} `)),u=i;if(l){let d=i.slice(l.alias.length);if(!o.has(`${l.canonical}${d}`))return[];u=`${l.canonical_argv.join(" ")}${d}`}return t!==void 0&&D(i,t)<10&&a.push(u),[u]});return[...new Set(a.length>0?a:s)]}export{Q as a,re as b,c,z as d,W as e,ue as f,ke as g,B as h,xe as i,Ce as j,A as k,Oe as l,ve as m,K as n,ye as o,Ne as p,D as q,Te as r,$e as s};
|
|
2
|
+
//# sourceMappingURL=chunk-OBPO6V7H.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as et,b as te}from"./chunk-3AZOATC2.js";import{$b as Xe,Ib as Ke,Nb as I,Ub as Ge,Xb as Ye,bc as N,fb as j,
|
|
1
|
+
import{a as et,b as te}from"./chunk-3AZOATC2.js";import{$b as Xe,Ib as Ke,Nb as I,Ub as Ge,Xb as Ye,bc as N,fb as j,gh as Qe,hf as G,if as Y,kh as Ze,xa as Be,za as Je}from"./chunk-NRQCBUYD.js";import{p as $e,r as q}from"./chunk-GSLOAEY2.js";import{Q as H,a as S,b as x,d as u,x as Ue}from"./chunk-I4SPJQQI.js";import{D as We,P as B,V as J,Z as K,aa as He,r as Ve}from"./chunk-TE6FBDHP.js";import{A as p,C as h,E as Fe,F as ee,H as E,J as De,K as ye,L as U,v as Me,y as c,z as $}from"./chunk-K672XXGQ.js";import tt from"node:fs/promises";import M from"node:path";var C="_workspace";function R(e){return M.join(e,"history",`${C}.jsonl`)}function we(e,t){return{metadata:{id:C,title:"Workspace state",description:"Audited singleton workspace document state.",type:"Chore",status:"open",priority:2,tags:["workspace-history"],created_at:t,updated_at:t,documents:e},body:""}}function z(e,t=e.length){let n=Ge();for(let r of e.slice(0,t))n=Xe(n,r.patch).document;return Ye(n)}function F(e){return"documents"in e.metadata&&typeof e.metadata.documents=="object"&&e.metadata.documents!==null&&!Array.isArray(e.metadata.documents)?e.metadata.documents:{}}function D(e){throw new h(`Workspace history verification failed: ${e.join(", ")}`,p.CONFLICT,{code:"workspace_history_chain_invalid",reason:"workspace_history_chain_verification_failed",verification_errors:[...e],required:"Repair the _workspace history chain before reading, reconciling, restoring, or appending audited singleton state.",why:"Continuing against an unverifiable append-only stream could hide or compound workspace state corruption.",examples:["pm history _workspace --verify --json","pm validate --check-history-drift --fix-hints --json"],nextSteps:["Inspect the exact verification_errors and preserve the corrupt stream as evidence.","Use the history-drift remediation returned by validate before retrying the refused operation."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify --json"}})}function ne(e,t){let n=M.resolve(t),r=M.relative(e,n).replaceAll("\\","/");if(r.length===0||r===".."||r.startsWith("../")||M.isAbsolute(r))throw new TypeError("Workspace history document path must stay inside the tracker root");return{documentPath:r,absolutePath:n}}async function hr(e){let t=await I(R(e),C),n=N(t);n.ok||D(n.errors);let r=F(t.length===0?$:z(t)),o=[],i=[],a=[],s=[];for(let l of Object.keys(r).sort()){let d;try{let _=ne(e,M.resolve(e,l));if(d=await E(_.absolutePath),d===null){a.push(l);continue}let f=JSON.parse(d);(S(f)===S(r[l])?o:i).push(l)}catch{s.push(l)}}return{ok:i.length===0&&a.length===0&&s.length===0,document_count:Object.keys(r).length,matching_documents:o,mismatched_documents:i,missing_documents:a,unreadable_documents:s}}async function nt(e){let t=R(e.pmRoot),n=await I(t,C),r=N(n);r.ok||D(r.errors);let o=e.idempotencyKey===void 0?void 0:n.find(f=>f.op===`${e.op}:${e.idempotencyKey}`);if(o)return{entry:o,historyPath:t};let i=H(),a=n.length===0?$:z(n),s=F(a),l=s[e.documentPath];if(l!==void 0&&S(l)!==S(e.before))throw new h(`Workspace history state for "${e.documentPath}" changed outside the audited mutation path.`,p.CONFLICT,{code:"workspace_history_state_conflict",reason:"out_of_band_workspace_state",required:"Reconcile the singleton document with its matching _workspace history state before retrying the mutation.",why:"Accepting the write would make the append-only audit stream describe a state that was not actually observed.",examples:["pm history _workspace --verify","pm validate --check-history-drift --fix-hints"],nextSteps:["Review the version-control change that altered the singleton and preserve the intended document plus its matching workspace history.","Rerun the original mutation only after the on-disk singleton agrees with the latest audited workspace state."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify"}});let d=we({...s,[e.documentPath]:e.after},n.length===0?i:a.metadata.created_at),_=G({nowIso:i,author:e.author,op:e.idempotencyKey===void 0?e.op:`${e.op}:${e.idempotencyKey}`,before:a,after:d,message:e.message});return await Y(t,_),{entry:_,historyPath:t}}async function yr(e){let t=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await nt(e)}finally{await t()}}async function wr(e){let t=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let n=R(e.pmRoot),r=await I(n,C),o=N(r);o.ok||D(o.errors);let i=r.length===0?$:z(r),a=G({nowIso:H(),author:e.author,op:e.op,before:i,after:i,message:e.message,context:e.context});return await Y(n,a),{entry:a,historyPath:n}}finally{await t()}}async function rt(e,t){if(t===e.raw)return!1;let n=t===null?null:JSON.parse(t),r=JSON.parse(e.raw);await U(e.filePath,e.raw);try{(t!==null||e.recordCreation!==!1)&&await nt({pmRoot:e.pmRoot,documentPath:M.relative(e.pmRoot,e.filePath).replaceAll("\\","/"),before:n,after:r,op:e.op,idempotencyKey:e.idempotencyKey,author:e.author,lockTtlSeconds:e.lockTtlSeconds,lockWaitMs:e.lockWaitMs,message:e.message})}catch(o){throw t===null?await tt.rm(e.filePath,{force:!0}):await U(e.filePath,t),o}return!0}async function ot(e){let{documentPath:t}=ne(e.pmRoot,e.filePath),n=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let r=await E(e.filePath);if(e.dryRun===!0||e.idempotencyKey!==void 0){let i=await I(R(e.pmRoot),C),a=N(i);a.ok||D(a.errors);let s=F(i.length===0?$:z(i))[t];if(s!==void 0&&S(s)!==S(r===null?null:JSON.parse(r)))throw new h(`Workspace history state for "${t}" changed outside the audited mutation path.`,p.CONFLICT,{code:"workspace_history_state_conflict"});if(e.idempotencyKey!==void 0&&i.some(l=>l.op===`${e.op}:${e.idempotencyKey}`))return{changed:!1,result:void 0,replayed:!0}}let o=await e.mutate(r);return JSON.parse(o.raw),e.dryRun===!0?{changed:r!==o.raw,result:o.result}:{changed:await rt({...e,raw:o.raw},r),result:o.result}}finally{await n()}}async function kr(e){let t=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await rt(e,await E(e.filePath))}finally{await t()}}async function gr(e){let t=e.authorizationDecision.trim();if(!t)throw new TypeError("Workspace history reconciliation requires an authorization decision");let n=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let{documentPath:r,absolutePath:o}=ne(e.pmRoot,e.filePath),i=R(e.pmRoot),a=await I(i,C),s=N(a);s.ok||D(s.errors);let l=z(a),d=F(l);if(!Object.hasOwn(d,r))throw new TypeError(`Workspace history does not govern document ${r}`);let _=await E(o);if(_===null)throw new TypeError(`Workspace history document is missing: ${r}`);let f=JSON.parse(_);if(S(d[r])===S(f))return{changed:!1,historyPath:i};let w=H(),W=G({nowIso:w,author:e.author,op:e.op,before:l,after:we({...d,[r]:f},l.metadata.created_at),message:e.message,context:{reason:"out_of_band_workspace_state_reconciliation",document_path:r,authorization_decision:t}});return await Y(i,W),{changed:!0,entry:W,historyPath:i}}finally{await n()}}async function br(e){let t=await j(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let{documentPath:n,absolutePath:r}=ne(e.pmRoot,e.filePath),o=await I(R(e.pmRoot),C),i=N(o);if(i.ok||D(i.errors),!Number.isInteger(e.targetVersion)||e.targetVersion<1||e.targetVersion>o.length)throw new TypeError(`Invalid workspace history target version: ${String(e.targetVersion)}`);let a=F(z(o,e.targetVersion))[n];if(a===void 0)throw new TypeError(`Workspace history version ${e.targetVersion} does not contain ${n}`);let s=await E(r),l=`${JSON.stringify(a,null,2)}
|
|
2
2
|
`;if(s===l)return{document_path:n,restored_from_version:e.targetVersion,changed:!1};let d=z(o),_=H(),f=G({nowIso:_,author:e.author,op:e.op,before:d,after:we({...F(d),[n]:a},d.metadata.created_at),message:e.message,context:{reason:"workspace_state_restore",document_path:n,restored_from_version:e.targetVersion,replaced_out_of_band_state:!0}});await U(r,l);try{await Y(R(e.pmRoot),f)}catch(w){throw s===null?await tt.rm(r,{force:!0}):await U(r,s),w}return{document_path:n,restored_from_version:e.targetVersion,changed:!0}}finally{await t()}}import{AsyncLocalStorage as Qt}from"node:async_hooks";import{lstat as Zt,realpath as pt}from"node:fs/promises";import ht from"node:path";function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ke(e,t,n,r=[]){if(x(e,t)&&(r.length>0||re(n)))return n;if(x(e,n)||x(t,n))return t;if((e===void 0||re(e))&&re(t)&&re(n)){let o=e??{},i=new Set([...Object.keys(o),...Object.keys(t),...Object.keys(n)]);return Object.fromEntries([...i].flatMap(a=>{let s=ke(Object.hasOwn(o,a)?o[a]:void 0,Object.hasOwn(t,a)?t[a]:void 0,Object.hasOwn(n,a)?n[a]:void 0,[...r,a]);return s===void 0?[]:[[a,s]]}))}throw new h(`Settings changed concurrently at ${r.join(".")||"<root>"}; read the latest settings and reapply the intended change.`,p.CONFLICT,{reason:"stale_settings_snapshot",required:"Read a fresh settings snapshot and reapply the intended change.",why:"Another writer changed the same setting after this snapshot was read.",examples:["pm config project export --json"],nextSteps:["Read the current settings, then retry the original config operation."]})}var Jt={Epic:2880,Feature:480,Story:480,Milestone:2880,Task:120,Issue:60,Bug:60,Chore:30,Decision:15,Plan:120},it=120;function ge(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function st(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n.toLowerCase(),r);return t}var Kt=st(Jt),at=new WeakMap;function Gt(e){let t=at.get(e);if(t)return t;let n=st(e);return at.set(e,n),n}function Or(e,t){let n=(e??"").trim().toLowerCase();if(n.length===0)return it;if(t){let o=Gt(t).get(n);if(ge(o))return Math.floor(o)}let r=Kt.get(n);return ge(r)?Math.floor(r):it}function be(e){let t={};if(e===null||typeof e!="object"||Array.isArray(e))return t;for(let[n,r]of Object.entries(e)){let o=n.trim();o.length===0||!ge(r)||(t[o]=Math.floor(r))}return t}import{stat as Yt}from"node:fs/promises";var oe=new Map;function ct(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}async function Xt(e){try{let t=await Yt(e);return{path:e,mtime_ms:t.mtimeMs,size:t.size}}catch{return{path:e,mtime_ms:null,size:null}}}async function O(e){let t=ct(e),n=await Promise.all(t.map(r=>Xt(r)));return n.sort((r,o)=>r.path.localeCompare(o.path)),n}function X(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],o=t[n];if(r.path!==o.path||r.mtime_ms!==o.mtime_ms||r.size!==o.size)return!1}return!0}function lt(e){return oe.get(e)}function ie(e,t){let n=ct(t.tracked_paths),r=[...t.signatures].map(o=>({path:o.path,mtime_ms:o.mtime_ms,size:o.size})).sort((o,i)=>o.path.localeCompare(i.path));oe.set(e,{tracked_paths:n,signatures:r,value:t.value})}function L(e){if(e){oe.delete(e);return}oe.clear()}var Ee=new Qt;async function Gr(e,t,n=()=>!0){let r=new Set([ht.resolve(e)]);try{r.add(await pt(e))}catch{}let o=!1,i=[r,()=>!o&&n()];try{return await Ee.run([...Ee.getStore()??[],i],t)}finally{o=!0}}function en(e){let t=ht.resolve(e);return Ee.getStore()?.some(([n,r])=>n.has(t)&&r())??!1}var tn="settings:write",yt=Symbol("pm.settings.persist_source"),wt=Symbol("pm.settings.fallback_origin"),kt=Symbol("pm.settings.fallback_baseline"),nn=128,rn=new Set(["off","advisory","strict"]);function dt(e){return structuredClone(Me[e])}function on(e){return e==="minimal"||e==="default"||e==="strict"||e==="custom"?e:c.governance.preset}var an=new Set(Ve);function gt(e){return an.has(e)}function ut(e,t){let n=typeof t.create_default_type=="string"?t.create_default_type.trim():void 0;return n&&n.length>0&&(e.create_default_type=n),(t.workflow_enforcement==="off"||t.workflow_enforcement==="warn"||t.workflow_enforcement==="strict")&&(e.workflow_enforcement=t.workflow_enforcement),gt(t.start_blocker_enforcement)&&(e.start_blocker_enforcement=t.start_blocker_enforcement),t.require_close_reason===!1&&(e.require_close_reason=!1),e.duplicate_detection_mode=t.duplicate_detection_mode,e.duplicate_detection_threshold=t.duplicate_detection_threshold,e.duplicate_detection_limit=t.duplicate_detection_limit,e}function sn(e){return e.preset==="custom"?ut({preset:"custom",ownership_enforcement:e.ownership_enforcement,create_mode_default:e.create_mode_default,close_validation_default:e.close_validation_default,parent_reference:e.parent_reference,metadata_profile:e.metadata_profile,force_required_for_stale_lock:e.force_required_for_stale_lock},e):ut({preset:e.preset},e)}function cn(e){let t=typeof e.create_default_type=="string"?e.create_default_type.trim():void 0,n={};t&&t.length>0&&(n.create_default_type=t),(e.workflow_enforcement==="off"||e.workflow_enforcement==="warn"||e.workflow_enforcement==="strict")&&(n.workflow_enforcement=e.workflow_enforcement),gt(e.start_blocker_enforcement)&&(n.start_blocker_enforcement=e.start_blocker_enforcement),typeof e.require_close_reason=="boolean"&&(n.require_close_reason=e.require_close_reason),rn.has(String(e.duplicate_detection_mode))&&(n.duplicate_detection_mode=e.duplicate_detection_mode);let r=e.duplicate_detection_threshold;[typeof r=="number",Number.isFinite(r),Number(r)>=0,Number(r)<=1].every(Boolean)&&(n.duplicate_detection_threshold=r);let o=e.duplicate_detection_limit;return[typeof o=="number",Number.isSafeInteger(o),Number(o)>=0,Number(o)<=20].every(Boolean)&&(n.duplicate_detection_limit=o),n}function bt(e){let t=e.governance??{},n=on(t.preset),r=cn(t);if(n==="custom"){let a=dt("default"),s=r.require_close_reason??a.require_close_reason;return{preset:n,ownership_enforcement:t.ownership_enforcement??a.ownership_enforcement,create_mode_default:t.create_mode_default??a.create_mode_default,close_validation_default:t.close_validation_default??a.close_validation_default,parent_reference:t.parent_reference??a.parent_reference,metadata_profile:t.metadata_profile??a.metadata_profile,force_required_for_stale_lock:t.force_required_for_stale_lock??a.force_required_for_stale_lock,...r,require_close_reason:s,duplicate_detection_mode:r.duplicate_detection_mode??a.duplicate_detection_mode,duplicate_detection_threshold:r.duplicate_detection_threshold??a.duplicate_detection_threshold,duplicate_detection_limit:r.duplicate_detection_limit??a.duplicate_detection_limit}}let o=dt(n),i=r.require_close_reason??o.require_close_reason;return{preset:n,...o,...r,require_close_reason:i}}function Te(){return structuredClone(c)}function xt(e){return e==="cache_only"||e==="semantic_configured"||e==="semantic_auto"?e:c.search.mutation_refresh_policy}function vt(e){return e==="auto"||e==="keyword"||e==="semantic"||e==="hybrid"?e:"auto"}function St(e){return typeof e=="boolean"?e:c.search.query_expansion.enabled}function Et(e){return typeof e!="string"?c.search.query_expansion.provider:e.trim()}function Ct(e){return typeof e=="boolean"?e:c.search.rerank.enabled}function Ot(e){return typeof e!="string"?c.search.rerank.model:e.trim()}function Tt(e){return typeof e=="number"&&Number.isFinite(e)&&Number.isInteger(e)&&e>0?e:c.search.rerank.top_k}function At(e){if(typeof e!="string")return c.vector_store.collection_name;let n=e.trim().replaceAll(/[^a-zA-Z0-9_-]/g,"_").slice(0,nn);return n.length>0?n:c.vector_store.collection_name}function xe(e){return{present:Array.isArray(e),values:Array.isArray(e)?structuredClone(e):[]}}function Pt(e,t){let n=e.schema,r=xe(n?.statuses),o=xe(n?.fields),i=xe(n?.type_workflows);return{persisted_settings:structuredClone(e),source_settings:structuredClone(e),has_source_item_type_definitions:Array.isArray(e.item_types?.definitions),source_item_type_definitions:V(e.item_types?.definitions),has_source_schema_statuses:r.present,source_schema_statuses:r.values,has_source_schema_fields:o.present,source_schema_fields:o.values,has_source_schema_type_workflows:i.present,source_schema_type_workflows:i.values,runtime_item_type_definitions:V(t.item_types?.definitions),runtime_schema_statuses:structuredClone(t.schema.statuses),runtime_schema_fields:structuredClone(t.schema.fields),runtime_schema_type_workflows:structuredClone(t.schema.type_workflows??[])}}function ce(e,t){Object.defineProperty(e,yt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function Ae(e){let t=e[yt];if(!(!t||typeof t!="object"))return t}function Yr(e){let t=Ae(e);if(t){let n=structuredClone(t);n.source_settings.item_format=e.item_format,ce(e,n)}}function ae(e){let t=structuredClone(e.settings),n=Ae(e.settings);n&&ce(t,n);let r=Pe(e.settings);return r!==void 0&&jt(t,r),{settings:t,metadata:{has_explicit_item_format:e.metadata.has_explicit_item_format},warnings:[...e.warnings]}}function ln(e,t,n){let r=J(t);return[n,K(e,r.files.types,B.types),K(e,r.files.statuses,B.statuses),K(e,r.files.fields,B.fields),K(e,r.files.workflows,B.workflows)]}async function dn(e,t,n){let r=await O(t);ie(e,{tracked_paths:t,signatures:r,value:ae(n)})}async function un(e,t,n){try{await dn(e,t,n)}catch{L(e)}}function _t(e,t){return e.find(n=>n.path===t)}function _n(e,t,n){for(let r of n){let o=_t(e,r),i=_t(t,r);if(!o||!i||!X([o],[i]))return!1}return!0}async function ve(e,t,n,r,o){try{let i=await O(t);if(!_n(r,i,o)){L(e);return}ie(e,{tracked_paths:t,signatures:i,value:ae(n)})}catch{L(e)}}function fn(e,t){let n=J(e.schema),r=V(e.item_types?.definitions);if(!t)return{item_type_definitions:r,schema_statuses:n.statuses,schema_fields:n.fields,schema_type_workflows:n.type_workflows};let o=n.type_workflows??[],i=x(r,t.runtime_item_type_definitions),a=x(n.statuses,t.runtime_schema_statuses),s=x(n.fields,t.runtime_schema_fields),l=x(o,t.runtime_schema_type_workflows);return{item_type_definitions:i?t.has_source_item_type_definitions?V(t.source_item_type_definitions):[]:r,schema_statuses:a?t.has_source_schema_statuses?structuredClone(t.source_schema_statuses):[]:n.statuses,schema_fields:s?t.has_source_schema_fields?structuredClone(t.source_schema_fields):[]:n.fields,schema_type_workflows:l?t.has_source_schema_type_workflows?structuredClone(t.source_schema_type_workflows):void 0:n.type_workflows}}function jt(e,t){Object.defineProperty(e,wt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function Xr(e){return Pe(e)!==void 0}function Pe(e){let t=e[wt];return typeof t=="string"?t:void 0}function mn(e){return e[kt]}function pn(e,t){Object.defineProperty(e,kt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function v(e){let t=Te();return e!==void 0&&jt(t,e),{settings:t,metadata:{has_explicit_item_format:!1},warnings:e?[e]:[]}}function It(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e.item_format;return t==="toon"||t==="json_markdown"}function Ce(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Nt(e){let t=c.agent_guidance,n=e?.template_version;return{prompt_completed:e?.prompt_completed===!0,declined:e?.declined===!0,declined_at:typeof e?.declined_at=="string"?e.declined_at:t.declined_at,template_version:typeof n=="number"&&Number.isInteger(n)&&n>0?n:t.template_version,last_checked_files:Ce(e?.last_checked_files??t.last_checked_files)}}function b(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function hn(e){return e==="off"||e==="warn"||e==="enforce"?e:c.extensions.policy.mode}function yn(e){return e==="off"||e==="warn"||e==="enforce"?e:c.extensions.policy.trust_mode}function Rt(e){return e==="none"||e==="restricted"||e==="strict"?e:c.extensions.policy.default_sandbox_profile}function wn(e){let t=e.name.trim().toLowerCase();if(t.length===0)return null;let n={name:t};e.disabled===!0&&(n.disabled=!0),e.require_trusted===!0&&(n.require_trusted=!0),e.require_provenance===!0&&(n.require_provenance=!0),e.sandbox_profile!==void 0&&(n.sandbox_profile=Rt(e.sandbox_profile));let r=b(e.allowed_capabilities),o=b(e.blocked_capabilities),i=b(e.allowed_surfaces),a=b(e.blocked_surfaces),s=b(e.allowed_commands),l=b(e.blocked_commands),d=b(e.allowed_actions),_=b(e.blocked_actions),f=b(e.allowed_services),w=b(e.blocked_services);return r.length>0&&(n.allowed_capabilities=r),o.length>0&&(n.blocked_capabilities=o),i.length>0&&(n.allowed_surfaces=i),a.length>0&&(n.blocked_surfaces=a),s.length>0&&(n.allowed_commands=s),l.length>0&&(n.blocked_commands=l),d.length>0&&(n.allowed_actions=d),_.length>0&&(n.blocked_actions=_),f.length>0&&(n.allowed_services=f),w.length>0&&(n.blocked_services=w),n}function kn(e){let t=new Map;for(let n of e??[]){let r=wn(n);r&&t.set(r.name,r)}return[...t.values()].sort((n,r)=>n.name.localeCompare(r.name))}function Se(e){return e==="block"||e==="warn"?e:void 0}function gn(e){if(typeof e=="string")return Se(e);if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=Se(e.global),n=Se(e.project);return t===void 0&&n===void 0?void 0:{...t!==void 0?{global:t}:{},...n!==void 0?{project:n}:{}}}}function k(e,t){return b(e?.[t]??c.extensions.policy[t])}function zt(e){let t=gn(e?.pm_max_version_exceeded_mode);return{mode:hn(e?.mode),trust_mode:yn(e?.trust_mode),...t!==void 0?{pm_max_version_exceeded_mode:t}:{},require_provenance:e?.require_provenance===!0,trusted_extensions:k(e,"trusted_extensions"),default_sandbox_profile:Rt(e?.default_sandbox_profile),allowed_extensions:k(e,"allowed_extensions"),blocked_extensions:k(e,"blocked_extensions"),allowed_capabilities:k(e,"allowed_capabilities"),blocked_capabilities:k(e,"blocked_capabilities"),allowed_surfaces:k(e,"allowed_surfaces"),blocked_surfaces:k(e,"blocked_surfaces"),allowed_commands:k(e,"allowed_commands"),blocked_commands:k(e,"blocked_commands"),allowed_actions:k(e,"allowed_actions"),blocked_actions:k(e,"blocked_actions"),allowed_services:k(e,"allowed_services"),blocked_services:k(e,"blocked_services"),extension_overrides:kn(e?.extension_overrides??c.extensions.policy.extension_overrides)}}function Lt(e){return[...new Set((e??[]).map(n=>n.trim().toLowerCase().replaceAll("-","_")))].filter(n=>n.length>0).sort((n,r)=>n.localeCompare(r)).filter(n=>["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"].includes(n))}function T(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function m(e,t){return e===void 0?t:e}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function Oe(e){return Array.isArray(e)?e:[]}function bn(e,t,n){return{...t.validation,...e.validation,parent_reference:n.parent_reference,metadata_profile:n.metadata_profile,metadata_required_fields:Lt(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:T(e.validation?.lifecycle_stale_blocker_reason_patterns??t.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:T(e.validation?.lifecycle_closure_like_blocked_reason_patterns??t.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:T(e.validation?.lifecycle_closure_like_resolution_patterns??t.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:T(e.validation?.lifecycle_closure_like_actual_result_patterns??t.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:be(e.validation?.estimate_defaults_by_type)}}function xn(e,t){return{enabled:e.telemetry?.enabled??t.telemetry.enabled,first_run_prompt_completed:e.telemetry?.first_run_prompt_completed??t.telemetry.first_run_prompt_completed,capture_level:e.telemetry?.capture_level??t.telemetry.capture_level,endpoint:e.telemetry?.endpoint??t.telemetry.endpoint,installation_id:e.telemetry?.installation_id??t.telemetry.installation_id,retention_days:e.telemetry?.retention_days??t.telemetry.retention_days}}function vn(e,t){return{...t.search,...e.search,default_mode:vt(e.search?.default_mode),mutation_refresh_policy:xt(e.search?.mutation_refresh_policy),query_expansion:{...t.search.query_expansion,...e.search?.query_expansion,enabled:St(e.search?.query_expansion?.enabled),provider:Et(e.search?.query_expansion?.provider)},rerank:{...t.search.rerank,...e.search?.rerank,enabled:Ct(e.search?.rerank?.enabled),model:Ot(e.search?.rerank?.model),top_k:Tt(e.search?.rerank?.top_k)}}}function Sn(e,t){return{adapter:e.vector_store.adapter??t.vector_store.adapter,collection_name:At(e.vector_store.collection_name),qdrant:{...t.vector_store.qdrant,...e.vector_store.qdrant},lancedb:{...t.vector_store.lancedb,...e.vector_store.lancedb}}}function En(e,t){return e.item_format==="json_markdown"?"toon":e.item_format??t.item_format}function Cn(e,t){return{default_depth:e.context?.default_depth??t.context.default_depth,activity_limit:e.context?.activity_limit??t.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??t.context.stale_threshold_days,next_ranking_policy:e.context?.next_ranking_policy??t.context.next_ranking_policy,sections:{...t.context.sections,...e.context?.sections}}}function On(e,t){return{openai:{...t.providers.openai,...e.providers.openai},ollama:{...t.providers.ollama,...e.providers.ollama}}}async function Tn(e,t){let n=await He(e,t.schema);return{settings:{...t,item_types:{definitions:V([...t.item_types.definitions,...Oe(n.type_definitions_from_file)])},schema:n.schema},warnings:n.warnings}}function V(e){let t=(e??[]).map(r=>We(r)).filter(r=>r!==null),n=new Map;for(let r of t)n.set(r.name.toLowerCase(),r);return[...n.values()].sort((r,o)=>r.name.localeCompare(o.name))}function se(e){let t=Te(),n=bt({governance:e.governance??{preset:"default"}});return{...t,...e,item_format:En(e,t),locks:{...t.locks,...e.locks},ids:{...t.ids,...e.ids},agent_identity:structuredClone(e.agent_identity??t.agent_identity),mutation_guard:{...t.mutation_guard,...e.mutation_guard},checkpoints:{...t.checkpoints,...e.checkpoints},output:{...t.output,...e.output},ux:{...t.ux,...e.ux},history:{...t.history,...e.history,compact_policy:{...t.history.compact_policy,...e.history?.compact_policy}},validation:bn(e,t,n),governance:n,workflow:{definition_of_done:[...e.workflow?.definition_of_done??t.workflow.definition_of_done]},testing:{record_results_to_items:e.testing?.record_results_to_items??t.testing.record_results_to_items,allow_untrusted_linked_tests:e.testing?.allow_untrusted_linked_tests??t.testing.allow_untrusted_linked_tests},telemetry:xn(e,t),agent_guidance:Nt(e.agent_guidance??t.agent_guidance),item_types:{definitions:V(e.item_types?.definitions)},schema:J(e.schema??t.schema),context:Cn(e,t),extensions:{enabled:[...e.extensions.enabled],disabled:[...e.extensions.disabled],policy:zt(e.extensions.policy??t.extensions.policy)},search:vn(e,t),providers:On(e,t),vector_store:Sn(e,t)}}function An(e){e.agent_identity=u(e.agent_identity,["probes_enabled","identity_vocabulary","harness_signals"]);let t=e.agent_identity;Object.hasOwn(t,"identity_vocabulary")&&(t.identity_vocabulary=u(g(t.identity_vocabulary),["version","aliases"])),e.agent_identity.harness_signals=Oe(e.agent_identity.harness_signals).map(n=>u(g(n),["harness","environment_keys","model_environment_keys","session_environment_keys","provenance_environment_keys","provenance_resolvers","provenance_unavailable_dimensions","argv_markers","client_names"])),e.locks=u(e.locks,["ttl_seconds","wait_ms"]),e.ids=u(e.ids,["token_length"]),e.mutation_guard=u(e.mutation_guard,["require_attributed_author","secret_guard","stale_in_progress_hours"]),e.checkpoints=u(e.checkpoints,["retention_days"]),e.output=u(e.output,["default_format"]),e.ux=u(e.ux,["deprecation_hints"]),e.history=u(e.history,["missing_stream","compact_policy"]),e.validation=u(e.validation,["sprint_release_format","parent_reference","metadata_profile","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns","estimate_defaults_by_type"]),e.governance=u(e.governance,["preset","ownership_enforcement","create_mode_default","close_validation_default","require_close_reason","parent_reference","metadata_profile","force_required_for_stale_lock","create_default_type","workflow_enforcement","duplicate_detection_mode","duplicate_detection_threshold","duplicate_detection_limit"]),e.workflow=u(e.workflow,["definition_of_done"]),e.testing=u(e.testing,["record_results_to_items","allow_untrusted_linked_tests"]),e.telemetry=u(e.telemetry,["enabled","first_run_prompt_completed","capture_level","endpoint","installation_id","retention_days"]),e.agent_guidance=u(e.agent_guidance,["prompt_completed","declined","declined_at","template_version","last_checked_files"]),e.item_types=u(e.item_types,["definitions"]),e.schema=u(e.schema,["version","files","statuses","fields","workflow","type_workflows","unknown_field_policy"]),e.schema.files=u(g(e.schema.files),["types","statuses","fields","workflows"]),e.schema.workflow=u(g(e.schema.workflow),["draft_status","open_status","in_progress_status","blocked_status","close_status","canceled_status"]),e.context=u(e.context,["default_depth","activity_limit","stale_threshold_days","next_ranking_policy","sections"]),e.context.sections=u(g(e.context.sections),["hierarchy","activity","progress","blockers","files","workload","staleness","tests"]),e.extensions=u(e.extensions,["enabled","disabled","policy"]),e.extensions.policy=u(g(e.extensions.policy),["mode","trust_mode","pm_max_version_exceeded_mode","require_provenance","trusted_extensions","default_sandbox_profile","allowed_extensions","blocked_extensions","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services","extension_overrides"]),e.extensions.policy.extension_overrides=Oe(e.extensions.policy.extension_overrides).map(n=>u(g(n),["name","disabled","require_trusted","require_provenance","sandbox_profile","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services"])),e.search=u(e.search,["score_threshold","hybrid_semantic_weight","max_results","embedding_model","embedding_corpus_max_characters","embedding_batch_size","embedding_timeout_ms","scanner_max_batch_retries","provider","default_mode","mutation_refresh_policy","query_expansion","rerank"]),e.search.query_expansion=u(g(e.search.query_expansion),["enabled","provider"]),e.search.rerank=u(g(e.search.rerank),["enabled","model","top_k"]),e.providers=u(e.providers,["openai","ollama"]),e.providers.openai=u(g(e.providers.openai),["base_url","api_key","model"]),e.providers.ollama=u(g(e.providers.ollama),["base_url","model"]),e.vector_store=u(e.vector_store,["adapter","collection_name","qdrant","lancedb"]),e.vector_store.qdrant=u(g(e.vector_store.qdrant),["url","api_key"]),e.vector_store.lancedb=u(g(e.vector_store.lancedb),["path"])}function Pn(e){return{...e,locks:m(e.locks,c.locks),ids:m(e.ids,c.ids),agent_identity:m(e.agent_identity,c.agent_identity),mutation_guard:m(e.mutation_guard,c.mutation_guard),checkpoints:m(e.checkpoints,c.checkpoints),output:m(e.output,c.output),ux:m(e.ux,c.ux),history:m(e.history,c.history),validation:m(e.validation,c.validation),workflow:m(e.workflow,c.workflow),testing:m(e.testing,c.testing),telemetry:m(e.telemetry,c.telemetry),agent_guidance:m(e.agent_guidance,c.agent_guidance),item_types:m(e.item_types,c.item_types),schema:m(e.schema,c.schema),context:m(e.context,c.context),extensions:m(e.extensions,c.extensions),search:m(e.search,c.search),providers:m(e.providers,c.providers),vector_store:m(e.vector_store,c.vector_store)}}function jn(e,t){return{...e.validation,parent_reference:t.parent_reference,metadata_profile:t.metadata_profile,metadata_required_fields:Lt(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:T(e.validation?.lifecycle_stale_blocker_reason_patterns??c.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:T(e.validation?.lifecycle_closure_like_blocked_reason_patterns??c.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:T(e.validation?.lifecycle_closure_like_resolution_patterns??c.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:T(e.validation?.lifecycle_closure_like_actual_result_patterns??c.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:be(e.validation?.estimate_defaults_by_type)}}function In(e){return{...c.search,...e.search,default_mode:vt(e.search?.default_mode),mutation_refresh_policy:xt(e.search?.mutation_refresh_policy),query_expansion:{...c.search.query_expansion,...e.search?.query_expansion,enabled:St(e.search?.query_expansion?.enabled),provider:Et(e.search?.query_expansion?.provider)},rerank:{...c.search.rerank,...e.search?.rerank,enabled:Ct(e.search?.rerank?.enabled),model:Ot(e.search?.rerank?.model),top_k:Tt(e.search?.rerank?.top_k)}}}function Nn(e){return{default_depth:e.context?.default_depth??c.context.default_depth,activity_limit:e.context?.activity_limit??c.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??c.context.stale_threshold_days,next_ranking_policy:e.context?.next_ranking_policy??c.context.next_ranking_policy,sections:{...c.context.sections,...e.context?.sections}}}function Rn(e){return{...e.vector_store,adapter:e.vector_store?.adapter??c.vector_store.adapter,collection_name:At(e.vector_store?.collection_name),qdrant:{...e.vector_store?.qdrant},lancedb:{...e.vector_store?.lancedb}}}function zn(e,t,n,r){return{...e,item_format:"toon",validation:jn(e,t),governance:t,agent_guidance:Nt(e.agent_guidance),item_types:{definitions:r.item_type_definitions},schema:{...n,statuses:r.schema_statuses,fields:r.schema_fields,type_workflows:r.schema_type_workflows},search:In(e),context:Nn(e),extensions:{enabled:Ce(e.extensions?.enabled),disabled:Ce(e.extensions?.disabled),policy:zt(e.extensions?.policy)},vector_store:Rn(e)}}function qt(e,t){for(let n of Object.keys(t)){let r=Reflect.get(t,n),o=e[n];typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?qt(o,r):e[n]=structuredClone(r)}}function je(e,t,n){let r=new Set([...Object.keys(t),...Object.keys(n)]);for(let o of r){let i=t[o],a=n[o];if(!x(i,a)){if(a===void 0){delete e[o];continue}if(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof a=="object"&&a!==null&&!Array.isArray(a)){let s=e[o],l=typeof s=="object"&&s!==null&&!Array.isArray(s)?s:{};je(l,i,a),Object.keys(l).length>0?e[o]=l:delete e[o];continue}e[o]=structuredClone(a)}}}var le=["version","id_prefix","ids","author_default","agent_identity","mutation_guard","item_format","locks","checkpoints","output","ux","history","validation","governance","workflow","testing","telemetry","agent_guidance","item_types","schema","context","extensions","search","providers","vector_store"];function ft(e,t){let n=Pn(e),r=bt(n),o=J(n.schema),i=fn(n,t),a=zn(n,r,o,i),s=u({...a,governance:sn(r)},le);return An(s),s}function Mt(e,t={}){let n=t.source===void 0?t.persist_source:Pt(t.source.validated,se(t.source.validated)),r=ft(e,n);if(n){let o=se(n.source_settings);o.item_types={definitions:structuredClone(n.runtime_item_type_definitions)},o.schema={...o.schema,statuses:structuredClone(n.runtime_schema_statuses),fields:structuredClone(n.runtime_schema_fields),type_workflows:structuredClone(n.runtime_schema_type_workflows)};let i=ft(o,n);t.source!==void 0&&qt(i,t.source.validated);let a=structuredClone(t.source===void 0?n.source_settings:t.source.raw);return je(a,i,r),`${JSON.stringify(u(a,le),null,2)}
|
|
3
3
|
`}return`${JSON.stringify(r,null,2)}
|
|
4
4
|
`}async function Ln(e){let t;try{t=await pt(e)}catch(s){if(ee(s))return v();throw s}let n=q(t),r;try{r=await Zt(n)}catch(s){if(ee(s))return v();throw s}if(!r.isFile())throw ye("settings.json");let o;try{o=await De(n,ye("settings.json"))}catch(s){if(ee(s))return v();throw s}let i;try{i=JSON.parse(o)}catch{return v("settings_read_invalid_json")}let a=te(i);return a.success?{settings:se(a.data),metadata:{has_explicit_item_format:It(i)},warnings:a.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[]}:v("settings_read_invalid_schema")}async function Ft(e){if(en(e))return Ln(e);let t=q(e),n=[t];await Ze({path:t,scope:"project"});let r=lt(e);if(r){let d=await O(r.tracked_paths);if(X(d,r.signatures))return ae(r.value)}let o=await O([t]),i;try{i=await E(t)}catch{return v("settings_read_fs_error")}if(i===null){let d=v();return await ve(e,[t],d,o,[t]),d}let a=await O([t]);if(!X(o,a))return L(e),Ft(e);let s;try{s=JSON.parse(i)}catch{let d=v("settings_read_invalid_json");return await ve(e,[t],d,a,[t]),d}let l=te(s);if(!l.success){let d=v("settings_read_invalid_schema");return await ve(e,[t],d,a,[t]),d}try{let d=se(l.data),_=ln(e,d.schema,t);n=_;let f=await O(_),w=await Tn(e,d),W=await O(_),he=w.settings;ce(he,Pt(l.data,he));let qe={settings:he,metadata:{has_explicit_item_format:It(s)},warnings:[...l.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[],...w.warnings]};return X(f,W)?ie(e,{tracked_paths:_,signatures:W,value:ae(qe)}):L(e),qe}catch{let d=v("settings_read_merge_failed");return await un(e,n,d),d}}function qn(e,t=[],n=null){let r=Ie(n)??{},o=t.filter(a=>!Object.hasOwn(r,a));if(o.length===0)return e;let i=JSON.parse(e);for(let a of o)Reflect.deleteProperty(i,a);return`${JSON.stringify(i,null,2)}
|
|
@@ -6,4 +6,4 @@ import{a as et,b as te}from"./chunk-3AZOATC2.js";import{$b as Xe,Ib as Ke,Nb as
|
|
|
6
6
|
`}function Un(e){try{return JSON.parse(e)}catch{throw new h("Existing settings.json is malformed; the settings write was refused.",p.USAGE,{code:"settings_write_invalid_existing_json",reason:"existing_settings_json_malformed",why:"Writing defaults over malformed settings could destroy intended project configuration.",nextSteps:["Repair the syntax in .agents/pm/settings.json, then retry the original command.","Run pm health to confirm the settings warning has cleared."]})}}async function Qr(e){return(await Ft(e)).settings}async function Zr(e,t,n=tn,r={}){let o=r.assignedPaths??[];Dn(o);let i=q(e),a=Ae(t),s=a?void 0:Pe(t),l=Mt(t,{persist_source:a}),d=JSON.parse(l),_=!1;try{if(await ot({pmRoot:e,filePath:i,mutate:f=>{let w=f===null?null:Un(f);return f!==null&&r.skipIfStored?.(w)===!0?(_=!0,{raw:f,result:void 0}):s!==void 0&&f!==null?{raw:$n(w,d,s,o,mn(t)),result:void 0}:{raw:a?`${JSON.stringify(u(ke(a.persisted_settings,d,w),le),null,2)}
|
|
7
7
|
`:qn(l,r.omitSections,w),result:void 0}},op:n,author:Ke(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),_)return;a?ce(t,{...a,persisted_settings:structuredClone(d)}):s!==void 0&&pn(t,structuredClone(d)),await Qe({path:i,scope:"project",op:n})}finally{L(e)}}import Vt from"node:fs";import Q from"node:path";import{createRequire as Hn}from"node:module";var Z="@unbrained/pm-cli",Bn=new Set(["append","claim","changelog","close","close-many","close-task","comments","config","copy","create","dedupe-merge","delete","deps","docs","extension","event","events","files","focus","gc","history-author-acknowledge","history-compact","history-redact","history-repair","init","install","item","learnings","meet","merge","normalize","notes","package","packages","pause-task","plan","profile","reindex","release","remind","restore","schema","start-task","test","test-all","test-runs","test-runs-worker","telemetry","templates","twin","update","update-many","upgrade","vcs","workspace"]),Wt=new Set(["--author","--expect-hash","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),Re=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,fe="2026.8.31";function y(e,t){return e.some(n=>t.includes(n.split("=",1)[0]))}function Ne(e,t){return["activate","adopt","adopt-all","deactivate","init","install","migrate","reload","uninstall"].includes(t[0]??"")||y(e,["--activate","--adopt","--adopt-all","--deactivate","--fix-managed-state","--init","--install","--output","--reload","--scaffold","--uninstall"])}var Jn={changelog:(e,t)=>{if(t[0]==="generate")return!y(e,["--check"]);let n=e.indexOf("export");return t[0]==="export"&&(y(e,["--output"])||n>=0&&e[n+1]!==void 0&&!e[n+1].startsWith("-"))},comments:e=>y(e,["--add","--delete","--edit","--file","--stdin"]),config:(e,t)=>(t[0]==="project"||t[0]==="global"?t[1]:t[0])==="set",deps:()=>!1,docs:e=>y(e,["--add","--add-glob","--migrate","--remove"]),duplicates:()=>!1,events:()=>!1,extension:Ne,files:(e,t)=>y(e,["--add","--add-glob","--migrate","--remove"])||t[0]==="discover"&&y(e,["--apply"]),health:e=>!y(e,["--check-only","--no-refresh","--skip-vectors"]),learnings:e=>y(e,["--add","--delete","--edit","--file","--stdin"]),merge:(e,t)=>t[0]!=="report",notes:e=>y(e,["--add","--delete","--edit","--file","--stdin"]),package:Ne,packages:Ne,profile:(e,t)=>t[0]==="apply",schema:(e,t)=>["add-field","add-status","add-type","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type"].includes(t[0]??"")&&!(y(e,["--infer"])&&!y(e,["--apply"])),telemetry:(e,t)=>t.slice(0,2).some(n=>["clear","flush"].includes(n)),templates:(e,t)=>t[0]==="save",test:e=>y(e,["--update","--update-index","--add","--add-json","--background","--measure","--remove","--resume","--run","--stop"]),validate:e=>y(e,["--auto-fix","--prune-missing"]),vcs:(e,t)=>["abandon","create","merge","propose","ref-create"].includes(t[0]??""),workspace:(e,t)=>t[0]==="snapshot"&&["create","delete","restore"].includes(t[1]??"")};function ue(e){let t=e.match(Re);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]??0)]:null}function A(e,t){let n=ue(e),r=ue(t);if(!n||!r)return null;for(let o=0;o<n.length;o+=1){let i=n[o]-r[o];if(i!==0)return Math.sign(i)}return 0}function de(e){return A(e,fe)!==-1?3:2}function Kn(e,t){if(t===3)return e.filter(n=>n.history_epoch_compatible===!1).map(n=>({...n,declaration:n.declaration??n.version})).sort((n,r)=>A(n.version,r.version))[0]}function _e(e){try{let t=JSON.parse(Vt.readFileSync(e,"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Gn(e){let t=[...e.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(r=>({inclusive:r[1]==="<=",version:r[2]})),n=e.match(/\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?\s+-\s+v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/u);return n?[...t,{inclusive:!0,version:n[1]}]:t}function Yn(e){let t=e.split("||").map(n=>Gn(n));return{bounded:t.some(n=>n.length>0),compatible:t.some(n=>n.every(r=>{let o=A(fe,r.version);return o!==null&&(r.inclusive?o!==1:o===-1)}))}}function $t(e){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(t=>{let n=e[t];if(typeof n!="object"||n===null)return[];let r=n[Z];return typeof r=="string"?[r.trim()]:[]})}function Xn(e){return $t(e).flatMap(t=>{let n=/^[<!]/u.test(t)?void 0:t.match(Re)?.[0];if(!n)return[];let r=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(t),o=Yn(t);return[{version:n,constraint:r?"exact":o.bounded?"range":"minimum",...r?{}:{declaration:t},history_epoch_compatible:r?A(n,fe)!==-1:o.compatible}]})}function Qn(e){let n=_e(Q.join(e,"package-lock.json"))?.packages;if(typeof n!="object"||n===null)return;let r=n["node_modules/@unbrained/pm-cli"];if(typeof r!="object"||r===null)return;let o=r.version;return typeof o=="string"?o:void 0}function Zn(e,t){try{let n=Vt.readFileSync(Q.join(e,t),"utf8").split(/\r?\n/u),r=n.findIndex(l=>l.includes(Z));if(r<0)return;let o=n[r].match(/^\s*/u)[0].length,i=[n[r]];for(let l=r+1;l<n.length;l+=1){let d=n[l],_=d.trim(),f=d.match(/^\s*/u)[0].length;if(_.length>0&&f<=o)break;i.push(d)}return i.join(`
|
|
8
8
|
`).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??i[0].match(Re)?.[0]}catch{return}}function Ut(e){let t=[],n=_e(Q.join(e,"package.json"));n&&t.push(...Xn(n).map(a=>({...a,source:"package.json"})));let o=_e(Q.join(e,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof o=="string"&&ue(o)&&t.push({version:o,source:"installed-package",constraint:"exact",history_epoch_compatible:de(o)===3});let i=Qn(e);i&&ue(i)&&t.push({version:i,source:"package-lock.json",constraint:"exact",history_epoch_compatible:de(i)===3});for(let a of["pnpm-lock.yaml","yarn.lock"]){let s=Zn(e,a);s&&t.push({version:s,source:a,constraint:"exact",history_epoch_compatible:de(s)===3})}return t}function er(e,t){if(t<=1)return;let{minVersion:n,lt:r}=Hn(import.meta.url)("semver"),o=$t(_e(Q.join(e,"package.json"))??{}).find(a=>{try{let s=n(a);return s!==null&&r(s,"2026.10.10")}catch{return!1}}),i=o===void 0?Ut(e).find(a=>A(a.version,"2026.10.10")===-1):{version:o,source:"package.json"};if(i)throw new h(`The project selects pm ${i.version}, which cannot safely refuse item format ${t}.`,p.CONFLICT,{code:"project_runtime_item_format_incompatible",reason:i.source,required:"Upgrade project pins, installed SDKs, CI hosts and Git merge drivers before writing guarded item formats.",nextSteps:["Use a pm runtime supporting the required item format throughout the project; preserve original item and history bytes, and never re-anchor history to satisfy an older host."]})}function co(e,t){let n=Je(e);n<=1||(er($e(t),n),e.pm_format_version=n)}function Ht(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(Wt.has(n)){t+=1;continue}if(!n.startsWith("-"))return{command:n.toLowerCase(),index:t}}}function tr(e){let t=Ht(e);if(!t||y(e,["--help","-h","--dry-run"]))return!1;let{command:n,index:r}=t,o=[];for(let a=r+1;a<e.length;a+=1){let s=e[a];if(Wt.has(s)){a+=1;continue}s.startsWith("-")||o.push(s.toLowerCase())}let i=Jn[n];return i?i(e,o):Bn.has(n)}function nr(e){let t=Ht(e.argv)?.command,n=tr(e.argv),r=Ut(e.projectRoot).filter(_=>A(_.version,e.executingVersion)!==null).sort((_,f)=>A(f.version,_.version)),o=r[0],i=o!==void 0&&A(e.executingVersion,o.version)===-1,a=de(e.executingVersion),s=Kn(r,a),l=n&&s!==void 0,d=i&&!n?{code:"project_runtime_stale_read",executing_version:e.executingVersion,project_version:o.version,source:o.source,message:"This read is using an older pm runtime than the project requires.",next_steps:[`Run the command through the project's installed ${Z} ${o.version}.`,"Install the project dependencies with its declared package manager if the local executable is missing."]}:void 0;return{compatible:!n||!i&&!l||e.allowStale===!0,executing_version:e.executingVersion,...o?{project_version:o.version,source:o.source}:{},...t?{command:t}:{},mutating:n,stale:i,history_epoch_incompatible:l,writer_item_hash_version:a,...s?{incompatible_project_version:s.declaration,incompatible_source:s.source}:{},...d?{warning:d}:{},override_applied:n&&(i||l)&&e.allowStale===!0}}function lo(e){let t=nr(e);if(t.compatible)return t;throw t.history_epoch_incompatible?new h(`pm ${t.executing_version} cannot write item-hash epoch ${t.writer_item_hash_version} into a project pinned to pm ${t.incompatible_project_version}.`,p.CONFLICT,{code:"project_runtime_history_epoch_incompatible",reason:t.incompatible_source,why:`The pinned runtime cannot read item_hash_version ${t.writer_item_hash_version}; allowing the write would break its health and validation gates.`,nextSteps:[`Upgrade the project's ${Z} pin to ${fe} or newer before mutating tracker history.`,"For an intentional coordinated migration only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]}):new h(`pm ${t.executing_version} cannot mutate a project pinned to newer pm ${t.project_version}.`,p.CONFLICT,{code:"project_runtime_stale_mutation",reason:t.source,why:"An older runtime can write storage, history, and merge contracts it does not understand.",nextSteps:[`Run this command through the project's installed ${Z} ${t.project_version}.`,"For an intentional recovery only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]})}import Le from"node:fs/promises";import me from"node:path";function P(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function Bt(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:Ue(t),suggested_retry_args:t}}function pe(e){return new h(`Tracker root is not a directory at ${e}.`,p.USAGE,{code:"tracker_root_not_directory",reason:"not_a_directory",resolved_path:e,nextSteps:["Pass a tracker directory, usually <workspace>/.agents/pm, rather than a file path."]})}function ze(e){return new h(`Tracker root is not readable at ${e}.`,p.GENERIC_FAILURE,{code:"tracker_root_unreadable",reason:"unreadable",resolved_path:e,nextSteps:["Grant read and directory-search permission to the tracker root, then retry."]})}async function rr(e){let t=me.resolve(e),n=me.parse(t).root,r=me.dirname(t);for(;r!==n;){let o;try{o=await Le.stat(r)}catch(i){if(P(i,"ENOTDIR"))throw pe(e);if(!P(i,"ENOENT"))throw i;r=me.dirname(r);continue}if(!o.isDirectory())throw pe(e);return}}async function or(e){let t;try{t=await Le.stat(e)}catch(n){throw P(n,"ENOENT")?(await rr(e),new h(`Tracker is not initialized at ${e}. Tracker root does not exist. Run pm init first.`,p.NOT_FOUND,{code:"tracker_root_missing",reason:"missing",resolved_path:e,nextSteps:["Confirm the tracker root path or initialize it with the emitted retry."],recovery:Bt(e)})):P(n,"ENOTDIR")?pe(e):P(n,"EACCES")||P(n,"EPERM")?ze(e):n}if(!t.isDirectory())throw pe(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw ze(e);try{await(await Le.opendir(e)).close()}catch(n){throw P(n,"EACCES")||P(n,"EPERM")?ze(e):n}}async function ko(e){if(await or(e),!await Fe(q(e)))throw new h(`Tracker is not initialized at ${e}. Run pm init first.`,p.NOT_FOUND,{code:"tracker_not_initialized",reason:"settings_missing",resolved_path:e,nextSteps:["Initialize the selected tracker root with the emitted retry."],recovery:Bt(e)})}export{C as a,R as b,hr as c,yr as d,wr as e,ot as f,kr as g,gr as h,br as i,Or as j,L as k,Gr as l,en as m,bt as n,Yr as o,Xr as p,Tn as q,se as r,Mt as s,Ft as t,Qr as u,Zr as v,fe as w,A as x,de as y,Ut as z,er as A,co as B,tr as C,nr as D,lo as E,Bt as F,or as G,ko as H};
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-OXC5KBIQ.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as A,c as b,d as C,e as E,k as S,m as x}from"./chunk-
|
|
1
|
+
import{a as A,c as b,d as C,e as E,k as S,m as x}from"./chunk-SY5C3U32.js";import{lb as w,mb as R,nb as k}from"./chunk-ZL6J6JYT.js";import{Ka as v,pa as p,sa as g,ta as a}from"./chunk-C6WM6ZN4.js";import{_ as O,kd as B}from"./chunk-CBUC4X7Q.js";import{Ke as H,Pe as u,Qe as y,ah as I}from"./chunk-NRQCBUYD.js";import{A as c,C as f}from"./chunk-K672XXGQ.js";function _(r,e){if(typeof r!="string")return;let o=Number.parseInt(r,10);if(!/^\d+$/.test(r.trim())||!Number.isSafeInteger(o))throw new f(`history-compact ${e} must be a non-negative integer.`,c.USAGE);return o}async function D(r,e,o){let t=p(o),s=Date.now(),i=await O(a(e,"ids")),l=i===void 0?void 0:B(i),m=_(e.allOver,"--all-over"),d=_(e.minEntries,"--min-entries");if(e.closed===!0&&e.allStreams===!0)throw new f("history-compact: --closed and --all-streams are mutually exclusive; pick one lifecycle scope.",c.USAGE);let n=e.closed===!0?"closed":e.allStreams===!0?"all-streams":void 0;if((l!==void 0||m!==void 0||n!==void 0)&&typeof e.before=="string")throw new f("history-compact: --before applies only in single-id mode (bulk mode always compacts full streams).",c.USAGE);if(b(r,{ids:l,allOver:m,scope:n}),r!==void 0&&d!==void 0)throw new f("history-compact: --min-entries applies only in bulk mode (single-id mode compacts the named stream).",c.USAGE);if(r===void 0){let h=await C({ids:l,scope:n,allOver:m,minEntries:d,dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},t);u(h,t),h.totals.items_errored>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let h=await A(r,{before:a(e,"before"),dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},t);u(h,t)}t.profile&&y(`profile:command=history-compact took_ms=${Date.now()-s}`)}async function N(r,e,o,t){let s=p(t),i=Date.now(),l=await x(r,e,{author:a(o,"author"),message:a(o,"message"),force:!!o.force},s);await v(s,l),u(l,s),s.profile&&y(`profile:command=restore took_ms=${Date.now()-i}`)}async function F(r,e){let o=p(e),t=await S({verify:a(r,"verify"),output:a(r,"output"),hashAlgorithm:a(r,"hashAlgorithm")},o);"format"in t?(I(t),o.quiet||H(`${JSON.stringify(t,null,2)}
|
|
2
2
|
`)):u(t,o),"ok"in t&&!t.ok&&(process.exitCode=c.GENERIC_FAILURE)}function ee(r,e){r.command(e?"attest":"history-attest",{hidden:!e}).summary("Export or verify history proof.").option("--verify <file>","Compare retained streams with a detached JSON proof").option("--output <file>","Create a proof file and return a compact receipt").option("--hash-algorithm <name>","Bundle digest algorithm: sha256 (default) or sha512").description("Export exact-byte history commitments, or verify an independently retained proof without tracker writes.").action(F),r.command("restore",{hidden:!e}).summary("Restore a version.").argument("<id>","Item id").argument("<target>","Restore target timestamp or version number").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership/lock override").description("Restore an item to an earlier timestamp or version.").action(N),r.command(e?"redact":"history-redact",{hidden:!e}).summary("Redact sensitive values.").argument("<id>","Item id").option("--literal <value>","Literal; repeatable",g).option("--regex <value>","Raw RegExp source (repeatable; e.g. /var/[a-z]+) or /pattern/flags. Leading-slash input is a literal only when the final unescaped slash is followed by supported JavaScript flag letters or nothing.",g).option("--replacement <value>",'Default: "[redacted]"').option("--dry-run","Preview; no item/history edits").option("--author <value>","Author").option("--message <value>","Audit marker message").option("--force","Override owner/lock").description("Redact and reseal item history.").action(async(o,t,s)=>{let i=p(s),l=Date.now(),m=Array.isArray(t.literal)?t.literal:void 0,d=Array.isArray(t.regex)?t.regex:void 0,n=await E(o,{literal:m,regex:d,replacement:a(t,"replacement"),dryRun:t.dryRun===!0,author:a(t,"author"),message:a(t,"message"),force:!!t.force},i);n.changed&&!n.dry_run&&await v(i,n),u(n,i),i.profile&&y(`profile:command=history-redact took_ms=${Date.now()-l}`)}),r.command(e?"repair":"history-repair",{hidden:!e}).summary("Repair drift.").argument("[id]","Item id (omit with --all)").option("--salvage-tail","Recover invalid tail; requires verified prefix").option("--append-only","Bridge breaks; never rewrite entries").option("--all","Scan every stream for drift and repair each drifted stream in one audited pass").option("--dry-run","Preview the re-anchor impact without writing the history file").option("--normalize-provenance","Remove invalid provenance; return aggregate-only evidence").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the repair marker entry").option("--force","Force ownership/lock override").description("Re-anchor a drifted item history chain (recompute hashes, reconcile with the on-disk item) and record an audit marker. Use --all to repair every drifted stream.").action(async(o,t,s)=>{let i=p(s),l=Date.now(),m=t.all===!0;R(o,m);let d={dryRun:t.dryRun===!0,author:a(t,"author"),message:a(t,"message"),force:!!t.force,normalizeProvenance:t.normalizeProvenance===!0,salvageTail:t.salvageTail===!0,appendOnly:t.appendOnly===!0};if(m){let n=await k(d,i);u(n,i),n.totals.failed>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let n=await w(o,d,i);u(n,i)}i.profile&&y(`profile:command=history-repair took_ms=${Date.now()-l}`)}),r.command(e?"compact":"history-compact",{hidden:!e}).summary("Compact streams.").argument("[id]","Item id (omit when using a bulk selector)").option("--before <value>","Compact entries strictly before this version number or ISO timestamp (single-id mode only)").option("--ids <value>","Bulk IDs: comma/newline text, - stdin, or @path file").option("--all-over <n>","Bulk: compact every stream with more than N entries").option("--closed","Bulk: compact only closed (terminal) items' streams").option("--all-streams","Bulk: compact every history stream regardless of lifecycle state").option("--min-entries <n>","Bulk: skip streams with at most N entries (already compact; default 3)").option("--dry-run","Preview compaction impact without writing the history file").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the compaction marker entry").option("--force","Force ownership/lock override").description("Compact item history streams into a synthetic baseline plus retained tail entries. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to compact many.").action(D)}export{ee as a};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-PCDTWL6V.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{d as q}from"./chunk-OGVSGXQX.js";import{a as X,b as R,c as _,d as J}from"./chunk-AA52P34H.js";import{H as K,n as H,u as E,z as V}from"./chunk-
|
|
1
|
+
import{d as q}from"./chunk-OGVSGXQX.js";import{a as X,b as R,c as _,d as J}from"./chunk-AA52P34H.js";import{H as K,n as H,u as E,z as V}from"./chunk-OXC5KBIQ.js";import{Ib as W,Mf as U,fb as $}from"./chunk-NRQCBUYD.js";import{g as B,o as P}from"./chunk-GSLOAEY2.js";import{Q as L}from"./chunk-I4SPJQQI.js";import{A as b,C as k,E as S,G as F,H as G,L as N}from"./chunk-K672XXGQ.js";var ce="PM_SOURCE_CONTEXT_ACCESS",le="PM_ALLOW_SOURCE_CONTEXT_WRITES";function z(e){let n=e[ce],r=n===void 0||n.trim().toLowerCase()==="write"?"write":"read_only",t=r==="read_only"&&e[le]?.trim()==="1";return{access:r,write_override_applied:t,source_writes_allowed:r==="write"||t}}import{access as ue,lstat as ee,readFile as T,realpath as h}from"node:fs/promises";import{constants as me}from"node:fs";import{execFile as pe}from"node:child_process";import a from"node:path";import{promisify as de}from"node:util";var v=de(pe),C="# pm-cli:merge-drivers:start",fe="# pm-cli:merge-drivers:end",x="# pm-cli:merge-drivers:v2:start",te="# pm-cli:merge-drivers:v2:end",ge="merge-fence",he="merge-attributes";function A(e){return`'${e.replaceAll("'",`'"'"'`)}'`}async function we(e,n){let r=await h(e);if(/(?:^|[\\/])bun-node-[^\\/]+[\\/]bun(?:\.exe)?$/iu.test(r))return;let{stdout:t}=await v(e,["--version"],{encoding:"utf8",windowsHide:!0,timeout:1e4});return t.trim()===n?r:void 0}async function ye(){let e=U(import.meta.url,["../../.."]),n=process.execPath,r=!1,t=await h(process.execPath),o=process.versions.bun,i=(process.env.PATH??"").split(a.delimiter).filter(s=>a.isAbsolute(s)).map(s=>a.join(s,o===void 0?a.basename(process.execPath):process.platform==="win32"?"bun.exe":"bun")),c=o===void 0?i:[process.env.npm_execpath??"",...i,t].filter(s=>a.isAbsolute(s)&&/^(?:bun|bun\.exe)$/iu.test(a.basename(s)));for(let s of c)try{if(await ue(s,me.X_OK),o!==void 0){let p=await we(s,o);if(p!==void 0){n=p,r=!0;break}continue}if(s!==t&&await h(s)===t){n=s;break}}catch{}if(o!==void 0&&!r)throw new k("Cannot install Bun merge drivers without a durable executable matching the current Bun version.",b.DEPENDENCY_FAILED,{code:"merge_bun_launcher_unavailable",why:"The current Bun process may be a temporary bunx launcher that Git cannot reuse after this command exits.",nextSteps:["Run with a durable version-matched Bun executable, expose one on an absolute PATH entry, or invoke pm through a Bun runner that publishes an absolute npm_execpath.","Retry pm merge install, then check pm health --strict-exit before merging branches."]});return`${A(n)} ${A(a.join(e,"dist","cli.js"))}`}var re=[{key:"pm-item-toon",name:"pm field-aware TOON item document merge",artifact:"item",itemPath:"%P"},{key:"pm-item-markdown",name:"pm field-aware JSON-markdown item document merge",artifact:"item",itemPath:"%P"},{key:"pm-history",name:"pm append-only history stream merge",artifact:"history",itemPath:void 0},{key:"pm-relationship",name:"pm append-only relationship event store merge",artifact:"relationship",itemPath:void 0},{key:"pm-json",name:"pm key-level JSON config merge",artifact:"json",itemPath:void 0}];function _e(e){let n=e.explicitPath?.trim(),r=e.environment.PM_SOURCE_WORKSPACE_ROOT?.trim(),t=e.environment.PM_SOURCE_PM_PATH?.trim(),o=z(e.environment),i=!!(r&&t),c=n===void 0&&i&&(e.dryRun||o.source_writes_allowed);if(n!==void 0){let s=P(e.cwd,n);return{pm_root:s,workspace_start:s,source_coordinates_available:i,source_context_selected:!1,source_policy:o}}return c?{pm_root:a.resolve(t),workspace_start:a.resolve(r),source_coordinates_available:!0,source_context_selected:!0,source_policy:o}:{pm_root:i?P(e.cwd,".agents/pm"):P(e.cwd),workspace_start:e.cwd,source_coordinates_available:i,source_context_selected:!1,source_policy:o}}async function M(e){try{let{stdout:n}=await v("git",["rev-parse","--show-toplevel"],{cwd:e,env:_(),encoding:"utf8",windowsHide:!0,timeout:1e4});return await h(R(n))}catch{return null}}async function ne(e){let n=await M(e);if(n===null)throw new k("pm merge install requires a git repository (merge drivers are git configuration).",b.USAGE);return n}function O(e,n){return a.relative(e,n).split(a.sep).join("/")}function Y(e){return e.replace(/[\\*?[\]!]/gu,"\\$&")}function g(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}function Q(e,n){if(e[n]!=="'")return null;let r="";for(let t=n+1;t<e.length;t+=1){if(e.startsWith(`'"'"'`,t)){r+="'",t+=4;continue}if(e[t]==="'")return{value:r,nextOffset:t+1};r+=e[t]}return null}async function ve(e,n,r){if(V(n).filter(i=>i.constraint==="exact").some(i=>i.version!==r))return!1;let o=await M(e);if(o!==null&&o!==await h(n)){let i=await Promise.all([o,n].map(async c=>{let s=await v("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:c,env:_(),timeout:1e4});return h(s.stdout.trim())}));if(i[0]===i[1])return!1}return!0}async function be(e,n,r){let t=Q(e,0);if(t===null||e[t.nextOffset]!==" ")return!1;let o=Q(e,t.nextOffset+1);if(o===null||e.slice(o.nextOffset)!==n||!/^(?:node|bun)(?:\.exe)?$/iu.test(a.basename(t.value))||a.basename(o.value)!=="cli.js"||a.basename(a.dirname(o.value))!=="dist"||!await S(t.value)||!await S(o.value))return!1;try{let i=a.dirname(a.dirname(o.value)),c=JSON.parse(await T(a.join(i,"package.json"),"utf8")),s=typeof c.bin=="string"?c.bin:c.bin?.pm;return await ve(i,r,c.version)?c.name==="@unbrained/pm-cli"&&s==="dist/cli.js":!1}catch{return!1}}function j(e,n){let r=e.length>0?`${Y(e)}/`:"",t=[`${g(`${r}**/*.toon`)} merge=pm-item-toon`,`${g(`${r}**/*.md`)} merge=pm-item-markdown`];for(let o of n){let i=Y(o);t.push(`${g(`${r}${i}/*.toon`)} merge=pm-item-toon`),t.push(`${g(`${r}${i}/*.md`)} merge=pm-item-markdown`)}return t.push(`${g(`${r}**/*.jsonl`)} merge=pm-relationship`),t.push(`${g(`${r}history/*.jsonl`)} merge=pm-history`),t.push(`${g(`${r}settings.json`)} merge=pm-json`),t.push(`${g(`${r}**/*.json`)} merge=pm-json`),t.push(`${g(`${r}extensions/**`)} merge=text`),t.push(`${g(`${r}extensions/.managed-extensions.json`)} merge=pm-json`),t}function oe(e){let n=[],r=0;for(;r<e.length;){let t=e.indexOf(C,r),o=e.indexOf(x,r),i=t===-1?o:o===-1?t:Math.min(t,o);if(i===-1)break;let c=i===o,s=c?x:C,p=c?te:fe,d=e.indexOf(p,i+s.length),u=d===-1?e.length:d+p.length;n.push({start:i,end:u,closed:d!==-1,lines:e.slice(i+s.length,d===-1?u:d).split(`
|
|
2
2
|
`).map(l=>l.trim()).filter(Boolean)}),r=u}return n}function ie(e,n,r){let t=new Set(n),o=g(r.length>0?`${r}/`:"").slice(0,-1);return e.some(i=>t.has(i)||i.startsWith(o)&&/^[^/]+\/\*\.(?:toon|md)" merge=pm-item-(?:toon|markdown)$/u.test(i.slice(o.length)))}async function se(e,n,r,t){let o=a.join(e,".gitattributes"),i=t?null:R((await v("git",["rev-parse","--absolute-git-dir"],{cwd:e,env:_(),encoding:"utf8",windowsHide:!0,timeout:1e4})).stdout),c=i===null?null:await $(i,he,120,"merge-fence",!1,!0,5e3);try{let s=await G(o)??"",p=[x,...r,te].join(`
|
|
3
3
|
`),d=oe(s),u=d.filter(m=>ie(m.lines,r,n));u.length===0&&n===".agents/pm"&&d.length===1&&d[0].lines.every(m=>!m.includes("/"))&&u.push(d[0]);let l;if(u.length>0){let m=u[0];l=s;for(let y of u.slice(1).reverse())l=`${l.slice(0,y.start)}${l.slice(y.end)}`;l=`${l.slice(0,m.start)}${p}${l.slice(m.end)}`}else{let m=s.trimEnd();l=`${m.length>0?`${m}
|
|
4
4
|
|
|
5
5
|
`:""}${p}
|
|
6
6
|
`}return l===s&&!(await ee(o)).isSymbolicLink()?{path:o,changed:!1}:(t||await N(o,l),{path:o,changed:!0})}finally{await c?.()}}function ae(e){let n=B(e,null);return[...new Set(Object.values(n.type_to_folder))].sort((r,t)=>r.localeCompare(t))}async function Z(e){try{return await h(e)}catch{return null}}function ke(e,n){let r=a.relative(e,n);return r===""||!a.isAbsolute(r)&&r.split(a.sep)[0]!==".."}async function xe(e){try{return(await ee(e)).isFile()?await T(e,"utf8"):null}catch{return null}}async function Pe(e){try{return await T(e,"utf8")}catch{return null}}async function $e(e,n){let r=n===void 0?await M(e):n;if(r===null)return{trackerRoot:e,topLevel:null};let[t,o]=await Promise.all([Z(e),Z(r)]);return t===null||o===null||!ke(o,t)?null:{trackerRoot:t,topLevel:o}}async function Ee(e){let n=e.topLevel===null?Pe:xe,r=e.trackerRoot;for(let t=0;e.topLevel!==null||t<8;t+=1){let o=await n(a.join(r,".gitattributes"));if(o!==null&&(o.includes(x)||o.includes(C)))return{directory:r,content:o};let i=a.dirname(r);if(i===r||e.topLevel!==null&&a.relative(e.topLevel,r)==="")return null;r=i}return null}async function Ye(e,n,r={}){let t=await $e(a.resolve(e),r.gitWorkspaceRoot),o=t===null?null:await Ee(t);if(t===null||o===null)return{status:"not_installed",missing_patterns:[],stale_patterns:[],schema_scope:"project"};let i=o.directory,c=o.content,s=a.join(i,".gitattributes"),p=O(i,t.trackerRoot),d=oe(c),u=j(p,n),l=d.filter(w=>ie(w.lines,u,p)),m=l.flatMap(w=>w.closed?w.lines:[]),y=new Set(m),f=new Set(u),I=u.filter(w=>!y.has(w)),D=m.filter(w=>!f.has(w));return{status:l.length!==1||!l[0].closed||I.length>0||D.length>0?"drift":"ok",path:s,missing_patterns:I,stale_patterns:D,schema_scope:"project"}}async function Qe(e){let n=[],r=[];for(let t of re){let o=`merge.${t.key}.driver`,i=` merge driver ${t.artifact} "%O" "%A" "%B"${t.itemPath===void 0?"":` --item-path ${t.itemPath}`}`;try{let{stdout:c}=await v("git",["config","--get",o],{cwd:e,env:_(),encoding:"utf8",windowsHide:!0,timeout:1e4}),s=c.trim();await be(s,i,e)||r.push(o)}catch{n.push(o)}}return{status:n.length>0?"missing":r.length>0?"drift":"ok",missing_keys:n,drifted_keys:r}}async function Ze(e){let n;try{n=await ne(a.resolve(e))}catch{return{status:"no_git"}}let r=O(n,a.resolve(e)),t=await E(e),o=W(void 0,t.author_default),i=await $(e,ge,t.locks.ttl_seconds,o,!1,H(t).force_required_for_stale_lock,t.locks.wait_ms);try{let c=a.join(n,".gitattributes"),s;try{s=await T(c,"utf8")}catch(l){if(l instanceof Error&&"code"in l&&F(l))return{status:"not_installed",path:c};throw l}if(!s.includes(x)&&!s.includes(C))return{status:"not_installed",path:c};let p=await E(e),d=ae(p),u=await se(n,r,j(r,d),!1);return{status:u.changed?"refreshed":"unchanged",path:u.path}}finally{await i()}}async function et(e,n){let r=_e({cwd:process.cwd(),explicitPath:n.path,dryRun:e.dryRun===!0,environment:process.env}),t=r.pm_root;await K(t);let o=await ne(r.workspace_start);return Te({pmRoot:t,workspaceRoot:o,dryRun:e.dryRun===!0,preCommitHook:e.preCommitHook===!0})}async function Ce(e,n){let r=(await v("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:e,env:_(),timeout:1e4})).stdout.trim(),t=await $(r,"merge-driver-config",120,"merge-install",!1,!0,5e3);try{let o=await J(e),i;try{i=(await v("git",["config",o,"--null","--get-regexp","."],{cwd:e,env:_(),timeout:1e4})).stdout}catch(s){if(typeof s!="object"||s===null||!("code"in s)||s.code!==1)throw s;i=""}let c=new Map(i.split("\0").filter(Boolean).map(s=>{let p=s.indexOf(`
|
|
7
7
|
`);return[s.slice(0,p),s.slice(p+1)]}));for(let s of n)c.get(s.key)!==s.value&&await X(e,[o,s.key,s.value])}finally{await t()}}async function Te(e){let n=a.resolve(e.pmRoot),r=a.resolve(e.workspaceRoot),t=e.dryRun===!0,o,i;try{[o,i]=await Promise.all([h(n),h(r)])}catch(f){throw new k(`Cannot resolve tracker root ${n} or workspace root ${r}: ${String(f)}`,b.NOT_FOUND,{code:"merge_root_not_found",nextSteps:["Initialize the tracker and ensure both paths are accessible.",'Retry "pm merge install" from the repository workspace.']})}let c=O(i,o);if(q(c))throw new k(`Tracker root ${n} is outside the git repository ${r}; there is nothing to configure for this repository.`,b.USAGE);let s=await E(o),p=ae(s),d=j(c,p),u=[],l=await ye(),m=e.preCommitHook===!0?await import("./settlement-hook-BIVNGBZF.js").then(async f=>({plan:await f.prepareMergeSettlementHook(i,`${l} --pm-path ${A(c||".")}`),write:f.writeMergeSettlementHook})):void 0;for(let f of re)u.push({key:`merge.${f.key}.name`,value:f.name}),u.push({key:`merge.${f.key}.driver`,value:`${l} merge driver ${f.artifact} "%O" "%A" "%B"${f.itemPath===void 0?"":` --item-path ${f.itemPath}`}`});if(!t)try{await Ce(i,u)}catch{throw new k(`Cannot install repository-local merge drivers in ${i}. Ensure the repository Git config is writable and no other Git process holds its lock, then retry.`,b.DEPENDENCY_FAILED,{code:"merge_git_config_unwritable",why:"pm merge install must persist clone-local driver commands before publishing their shared .gitattributes mappings.",nextSteps:["Make the repository Git config writable or wait for the process holding its lock to finish.",'Retry "pm merge install"; the operation is idempotent.','Use "pm merge install --dry-run --json" when the workspace is intentionally read-only.']})}let y=await se(i,c,d,t);return m!==void 0&&!t&&await m.write(m.plan),{ok:!0,dry_run:t,workspace_root:i,pm_root:o,gitattributes:{path:y.path,changed:y.changed,patterns:d,schema_scope:"project"},git_config:u,...m===void 0?{}:{settlement_hook:{path:m.plan.path,changed:m.plan.changed}},guidance:["Commit .gitattributes so every branch and collaborator shares the merge mapping.",'git config is per-clone: each collaborator (and each fresh worktree/clone) runs "pm merge install" once.','After merging branches, run "pm merge reconcile --dry-run" to inspect the complete receipt and history repair, then apply "pm merge reconcile"; use --force only after explicitly accepting any discarded values.',"Custom item types registered later refresh this fence automatically (pm schema add-type/remove-type); rerun pm merge install only after out-of-band type-folder edits."],generated_at:L()}}export{ce as a,le as b,z as c,C as d,fe as e,x as f,te as g,_e as h,M as i,j,ae as k,Ye as l,Qe as m,Ze as n,et as o,Te as p};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-Q6K7HWZ7.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as ke}from"./chunk-AHV3CSQG.js";import{Ad as v,Jc as ve,kc as ge,lc as ye,mb as k,nb as E,tb as Ie,zd as x}from"./chunk-CBUC4X7Q.js";import{u as xe}from"./chunk-OXC5KBIQ.js";import{Fa as y,Ga as w,H as X,Hf as h,Nb as re,Xg as _e,df as se,kf as A,lf as ce,mf as N,nf as ae,of as de,rf as le,sf as ue,tf as fe,uf as pe,vf as me,wf as he,xf as T,y as j}from"./chunk-NRQCBUYD.js";import{a as J,g as Q,i as Z,o as ee,u as te}from"./chunk-GSLOAEY2.js";import{E as we}from"./chunk-A5ZEMOVR.js";import{y as ne,z as oe}from"./chunk-I4SPJQQI.js";import{ba as ie}from"./chunk-TE6FBDHP.js";import{A as p,C as u,z as W}from"./chunk-K672XXGQ.js";var Ee=new Set(j),Pe=new Set(["files lookup","item files lookup"]);function B(e){let n=e.trim().replace(/^packages(?=\s|$)/u,"package").replace(/\s+/gu,"-");return Ee.has(n)?n:e}function O(e){let n=e.trim().replace(/\s+/gu," ");if(we.has(n)||Pe.has(n))return!1;let t=B(e);return!(Ee.has(t)&&(!ve(t)||t==="deps")&&!X.has(t))}import{readdir as ze}from"node:fs/promises";import $ from"node:path";function D(e,n){return(n===void 0?void 0:Z(e,n))?.execution_role??J[e.trim().toLowerCase()]??"agent"}var M="blocked_by",be="blocks",$e=Object.freeze([M,be]),L="no-active-blocker";function d(e){return e.trim().toLowerCase()}function b(e,n){return n?`external:${e}`:`local:${d(e)}`}function _(e){let n=new Map,t=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(t.length>0&&d(t)!==L){let o=x(t);n.set(b(t,o),o?t:d(t))}for(let o of e.dependencies??[]){let i=typeof o.id=="string"?o.id.trim():"";if(h(o.kind)===M&&i.length>0&&d(i)!==L){let r=x(i)||v(o.source_kind);n.set(b(i,r),r?i:d(i))}}return[...n.values()].sort((o,i)=>o.localeCompare(i))}function C(e){let n=new Map;for(let t of e){let o=d(t.id);o.length!==0&&n.set(o,new Set(_(t)))}for(let t of e){let o=d(t.id);if(o.length!==0)for(let i of t.dependencies??[]){let r=h(i.kind)===be&&typeof i.id=="string"?d(i.id):"";if(r.length===0||r===L)continue;let s=n.get(r)??new Set;s.add(o),n.set(r,s)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((i,r)=>i.localeCompare(r))]))}function Ce(e,n){let t=d(e.id);return t.length>0?C(n).get(t)??_(e):_(e)}function H(e,n,t,o){let i=e,r=typeof i.id=="string"?o?.get(d(i.id))??Ce(i,[...n.values()]):_(e),s=new Set((e.dependencies??[]).filter(c=>h(c.kind)===M&&v(c.source_kind)&&typeof c.id=="string"&&c.id.trim().length>0).map(c=>b(c.id.trim(),!0)));return r.map(c=>{if(x(c)||s.has(b(c,!0)))return{id:c,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let a=n.get(d(c));return a?{id:c,title:a.title,status:a.status,resolved:w(a.status,t)}:{id:c,title:null,status:null,resolved:!1}})}function P(e,n,t){return H(e,n,t)}function Fe(e,n){let t=new Map(e.map(s=>[d(s.id),s])),o=C(e),i=new Set([...Re(n),...n.blocked_statuses]),r=new Set;for(let s of e){let c=y(s.status,n);if(!i.has(c))continue;(n.blocked_statuses.has(c)||H(s,t,n,o).some(l=>!l.resolved))&&r.add(d(s.id))}return r}function Ke(e,n,t={},o){let i=[...e.ready,...e.decisions,...e.gates];t.includeContainers===!0&&i.push(...e.containers.filter(s=>s.open_blockers.length===0&&!n.blocked_statuses.has(y(s.item.status,n))));let r={ready:[],decisions:[],gates:[]};for(let s of i){let c=D(s.item.type,o);c==="human"&&t.includeDecisions!==!0?r.decisions.push(s):c==="gate"&&t.includeGates!==!0?r.gates.push(s):r.ready.push(s)}return r}function Re(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function Ue(e,n,t){let o=[d(e)],i=new Set;for(;o.length>0;){let r=o.pop();if(!i.has(r)){i.add(r);for(let s of n.get(r)??[]){if(!w(s.status,t))return!0;o.push(d(s.id))}}}return!1}function Ge(e){let n=new Map,t=new Map,o=new Map,i=C(e);for(let r of e){n.set(d(r.id),r);let s=typeof r.parent=="string"?r.parent.trim():"";if(s.length>0){let c=d(s),a=t.get(c)??[];a.push(r),t.set(c,a)}for(let c of i.get(d(r.id))){let a=d(c),l=o.get(a)??[];l.push(r.id),o.set(a,l)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:i}}function qe(e,n,t,o){let{itemsById:i,childrenByParent:r,blockedByReverse:s,blockerIdsByItem:c}=Ge(n),a=new Set([...Re(t),...t.blocked_statuses]),l=new Set(n.filter(f=>!w(f.status,t)).map(f=>d(f.id))),U=[],G=[],S=[],q=[],z=[],V=0;for(let f of e){if(!a.has(y(f.status,t)))continue;V+=1;let Y=H(f,i,t,c).filter(m=>!m.resolved),De=(s.get(d(f.id))??[]).filter(m=>l.has(d(m))).sort((m,He)=>m.localeCompare(He)),g={item:f,open_blockers:Y,unblocks:De};if(Ue(f.id,r,t)){S.push(g);continue}let Me=t.blocked_statuses.has(y(f.status,t));if(Y.length===0&&!Me){let m=D(f.type,o);m==="human"?q.push(g):m==="gate"?z.push(g):U.push(g)}else G.push(g)}return{ready:U,blocked:G,containers:S,decisions:q,gates:z,active_count:V,container_count:S.length}}function Ve(e,n){let t=new Map;for(let o of e){let i=o.external?o.id:n.get(o.id.toLowerCase())?.id??o.id;t.set(o.external?`external:${i}`:`local:${i.toLowerCase()}`,{...o,id:i})}return[...t.values()]}async function F(e,n){let t=$.basename(e),i=(await ze($.dirname(e)).catch(r=>{throw ge("Cannot verify the blocker's physical file identity",{exitCode:p.GENERIC_FAILURE,context:{code:"blocker_identity_read_failed",required:"Restore access to the blocker item directory, then retry the item read."},cause:r})})).filter(r=>r.toLowerCase()===t.toLowerCase()).sort((r,s)=>+(s===t)-+(r===t)||r.localeCompare(s)).map(r=>$.parse(r).name)[0];if(i===void 0)throw new u(`Blocker canonical file disappeared during identity verification: ${n}`,p.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker file and validate storage integrity before retrying the item read."});return i}async function wt(e){let n=_(e.metadata);if(n.length===0)return[];let t=new Map([e.metadata.blocked_by,...(e.metadata.dependencies??[]).filter(i=>h(i.kind)==="blocked_by").map(i=>i.id)].filter(i=>typeof i=="string").map(i=>[i.trim().toLowerCase(),i.trim()])),o=new Map;for(let i of n){if(x(i)||!/^(?!\.{1,2}$)[^/\\:\0]+$/u.test(i)||e.metadata.dependencies?.some(c=>c.id.trim()===i&&h(c.kind)==="blocked_by"&&v(c.source_kind)))continue;let r=await k(e.pmRoot,t.get(i),e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(r===null)continue;let s=await E(r,{schema:e.settings.schema});if(r.id=await F(r.itemPath,r.id),s.document.metadata.id!==r.id)throw new u(`Blocker identity differs from its canonical file: ${r.id}`,p.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker identity and validate storage integrity before retrying the item read."});o.set(i.toLowerCase(),s.document.metadata)}return Ve(P({blocked_by:e.metadata.blocked_by,dependencies:e.metadata.dependencies,updated_at:e.metadata.updated_at},o,ie(e.settings.schema)),o)}var Se="item_revision_conflict",Ye=10,Ae=/^[0-9a-f]{64}$/u;function I(e,n){return new u(`Invalid expected revision ${JSON.stringify(e)}: ${n}.`,p.USAGE,{code:"expect_hash_invalid",value:e,required:"Pass the 64-character item_hash from pm get <id> --json, optionally as <id>=<item_hash>.",examples:["--expect-hash <item_hash>","--expect-hash pm-a1b2=<item_hash>"]})}function Ne(e){let n=typeof e=="string"?e.trim().toLowerCase():"";if(!Ae.test(n))throw I(String(e),"the revision is not a 64-character hexadecimal item_hash");return n}function We(e){return(e===void 0?[]:typeof e=="string"?[e]:e).flatMap(t=>{if(typeof t!="string")throw I(String(t),"expected a string");let o=t.split(",").map(r=>r.trim()).filter(r=>r.length>0);if(o.length===0)throw I(t,"the value is empty");let i=r=>oe(t)===t?r:ne;return o.map(r=>{let s=r.lastIndexOf("="),c=s===-1?void 0:r.slice(0,s).trim();if(c!==void 0&&c.length===0)throw I(i(r),"the item id before = is empty");let a=s===-1?r:r.slice(s+1);if(!Ae.test(a.trim().toLowerCase()))throw I(i(a),"the revision is not a 64-character hexadecimal item_hash");let l=Ne(a);return c===void 0?{itemHash:l}:{id:c,itemHash:l}})})}async function Te(e,n){let t=await xe(e),o=Q(t,_e()).type_to_folder,i=await k(e,n,t.id_prefix,t.item_format,o);if(i){let{document:r}=await E(i,{schema:t.schema});if(r.metadata.id!==await F(i.itemPath,i.id))throw new u(`Item file ${i.id} embeds the id ${r.metadata.id}; no revision can be bound to an item whose identity is in conflict.`,p.CONFLICT,{code:"item_identity_conflict",item_id:i.id,required:`Repair ${i.id}'s identity first (pm validate reports it; pm restore ${i.id} <version> recovers a recorded state), then read its item_hash again.`});return{id:r.metadata.id,document:r}}try{return{id:(await ke(e,n,t,o)).id,document:W}}catch{throw await Ie(e,n,t.id_prefix,o)}}function K(e){return ee(e.cwd??process.cwd(),e.pmRoot)}async function Ft(e,n={}){let t=await Te(K(n),e);return{id:t.id,item_hash:se(t.document)}}async function Be(e,n,t){let o=[];for(let i of n){let r=i.id??t;if(r===void 0||r.trim().length===0)throw new u("A bare expected revision needs an item to bind to.",p.USAGE,{code:"expect_hash_target_required",required:"This command has no single item argument; name each target as --expect-hash <id>=<item_hash>.",examples:["--expect-hash pm-a1b2=<item_hash>"]});o.push({id:(await Te(e,r)).id,itemHash:i.itemHash})}return o}function je(e){return[...new Set(e.patch.map(n=>{let t=n.path.split("/");return String(t[1]==="metadata"?t[2]:t[1])}))].sort()}async function Xe(e,n,t){let o;try{o=await re(te(e,n),n)}catch{return}let i=-1;for(let c=o.length-1;c>=0;c-=1){let a=o[c];if(a.after_hash===t){i=c+1;break}if(a.before_hash===t){i=c;break}}if(i===-1)return{expected_revision_recorded:!1,changes_since:[],changes_since_omitted:0};let r=o.slice(i),s=r.slice(-Ye);return{expected_revision_recorded:!0,changes_since:s.map(c=>({ts:c.ts,op:c.op,author:c.author,fields:je(c)})),changes_since_omitted:r.length-s.length}}async function Kt(e,n){if(!R(e))return{};let t=await Oe(e,n);return{error_code:Se,expected_revision:String(t.context.expected_revision),current_revision:String(t.context.current_revision),details:t.context.details}}function R(e){return ye(e)&&e.context.code===Se}function Ut(e){let n=e.find(t=>R(t));if(n!==void 0)throw n}function Gt(){return new u("--expect-hash cannot guard an invocation an extension override rewrote: which item it writes is not provable.",p.USAGE,{code:"expect_hash_invocation_rewritten",required:"Run the command without the rewriting extension (--no-extensions), or drop --expect-hash.",why:"An extension parser or preflight override changed this invocation's tracker or arguments, and final dispatch, the extension SDK client and the guard do not share one rewritten view."})}function Je(e,n){if(n===void 0||!R(e)||typeof e.context.item_id!="string"||me(e))return e;let t=e.context.reason===ue;if(!t&&e.context.reason!==le)return e;let o=he(T(e,new u(e.message,e.exitCode,{...e.context,...fe(e.context.item_id,t,n)})));return o.stack=e.stack,o}async function Oe(e,n,t){if(!pe(e,n))return e;let o=Je(e,t);if(!R(o)||o.context.details!==void 0)return o;let i=o.context.item_id,r=o.context.expected_revision;if(typeof i!="string"||typeof r!="string")return o;let s;try{s=await Xe(n,i,r)}catch{return o}if(s===void 0)return o;let c={expected_revision_recorded:s.expected_revision_recorded,changes_since:s.changes_since.map(l=>({ts:l.ts,op:l.op,author:l.author,fields:[...l.fields]})),changes_since_omitted:s.changes_since_omitted},a=T(o,new u(o.message,o.exitCode,{...o.context,details:c}));return a.stack=o.stack,a}async function Le(e,n,t){try{return{result:await ce(e,n),...ae(e)}}catch(o){throw e.pmRoot===void 0?o:await Oe(o,e.pmRoot,t)}}function Qe(e){return e.cwd===void 0&&e.pmRoot===void 0?void 0:{scopeArgs:["--pm-path",K(e)]}}async function qt(e,n,t={}){return Le(await Ze(e,t),n,Qe(t))}async function Ze(e,n={}){let t=K(n),o=e.map(({id:r,itemHash:s})=>({id:r,itemHash:Ne(s)})),i=A();return N(i,t,await Be(t,o)),i}function zt(e){let n=de(e);return n===void 0||n.length>0}function et(e){return`expect_hash_unchecked:${e}:no_locked_write_reached_this_item`}function tt(e,n={}){let t=B(e);if(!O(e))throw nt(t);if((t==="test"||t==="test-all")&&n.background===!0)throw new u(`--expect-hash cannot guard ${t} --background: the worker runs in another process.`,p.USAGE,{code:"expect_hash_background_unsupported",required:`Run ${t} in the foreground to guard its result recording, or drop --expect-hash for a background run.`})}function nt(e){return new u(`--expect-hash guards item writes, and ${e} is not a mutation.`,p.USAGE,{code:"expect_hash_requires_mutation",required:"Use --expect-hash (MCP/SDK expectHash) only on a command or action that writes items."})}function ot(e,n){if(n.length===0||typeof e!="object"||e===null||Array.isArray(e))return e;let t=e,o=Array.isArray(t.warnings)?t.warnings:[];return{...t,warnings:[...o,...n.map(et)]}}async function Vt(e){let n=e.expectHash;if(n!==void 0&&typeof n!="string"&&!(Array.isArray(n)&&n.every(r=>typeof r=="string")))throw I(JSON.stringify(n)??String(n),"expected a string or an array of strings");let t=We(n);if(t.length===0)return e.run();tt(e.action,{background:e.background===!0||e.options?.background===!0});let o=A();N(o,e.pmRoot,await Be(e.pmRoot,t,e.defaultId));let i=await Le(o,e.run,e.invocation);return ot(i.result,i.unchecked)}export{O as a,D as b,$e as c,_ as d,C as e,Ce as f,P as g,Fe as h,Ke as i,qe as j,wt as k,Se as l,Ye as m,Ne as n,We as o,Ft as p,Be as q,Xe as r,Kt as s,R as t,Ut as u,Gt as v,Je as w,Oe as x,Le as y,qt as z,Ze as A,zt as B,et as C,tt as D,nt as E,Vt as F};
|
|
2
|
+
//# sourceMappingURL=chunk-QDV7S2QS.js.map
|