@unbrained/pm-cli 2026.11.13 → 2026.11.15
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/README.md +1 -1
- package/dist/cli/extension-command-help.js +2 -2
- package/dist/cli/register-mutation.js +2 -2
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-6UTBX62V.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-GWVP23RZ.js → chunk-7AODVNHX.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ASGAELBQ.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-PUU5DXSV.js → chunk-DBUBX4DL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5LG5YZYF.js → chunk-E4B2HWH7.js} +13 -13
- package/dist/cli-bundle/chunks/chunk-E74OMFBZ.js +6 -0
- package/dist/cli-bundle/chunks/chunk-FSE624WQ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-FYOIH56R.js +20 -0
- package/dist/cli-bundle/chunks/chunk-GAFALSR2.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-LKVFPQNY.js → chunk-GCSKHCYK.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HMVZSXB4.js +8 -0
- package/dist/cli-bundle/chunks/chunk-IXV5UM4U.js +31 -0
- package/dist/cli-bundle/chunks/chunk-J6L3Q5J4.js +3 -0
- package/dist/cli-bundle/chunks/chunk-KLWGIEDC.js +114 -0
- package/dist/cli-bundle/chunks/chunk-KSLPRST2.js +10 -0
- package/dist/cli-bundle/chunks/chunk-LC6DL446.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-UFZQPKQS.js → chunk-NAX554KY.js} +35 -35
- package/dist/cli-bundle/chunks/chunk-PMIGRSNZ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-Q6GBRK27.js +3 -0
- package/dist/cli-bundle/chunks/chunk-QZNDEZYI.js +2 -0
- package/dist/cli-bundle/chunks/chunk-S5UXBECQ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-UJMQP2HP.js → chunk-TESRFVGF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GXGMMIZN.js → chunk-VWKLTHYQ.js} +80 -70
- package/dist/cli-bundle/chunks/chunk-YJNY5MKP.js +2 -0
- package/dist/cli-bundle/chunks/chunk-YLPZE2TK.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-RSAN2YUU.js → chunk-ZVDXGAYV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ZWUS65LN.js +2 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-I6RQGD6Y.js → indexed-receipt-blobs-42Y2CSEQ.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-JCEDTAVX.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-BSMGKZ4S.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-IQHBRFAJ.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-DF6BFGG6.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-JNJY2D3N.js → register-list-query-DNKPQB76.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-WVTDFLEF.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-NR5MTT5T.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-2RTG3LII.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-JHXLUBEN.js → settlement-hook-W5ULPKIE.js} +2 -2
- package/dist/cli-bundle/chunks/stage-YFNK7U26.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-Q3OA5OAK.js → chunk-2UQFFVQK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-52H6AELE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-J3LQQP3N.js → chunk-63FM3TIG.js} +7 -7
- package/dist/cli-bundle/focused-chunks/{chunk-VGFKTSGY.js → chunk-7GCAZJT4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-BSY6FZ3Y.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-CZZKAGHE.js +91 -0
- package/dist/cli-bundle/focused-chunks/chunk-DRBXOAGY.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-DXMQ32EH.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-EALGFJRP.js +78 -0
- package/dist/cli-bundle/focused-chunks/chunk-FK2X6MJY.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IDAYTYNN.js → chunk-JE3MFEQZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JR75B6HU.js → chunk-JRRHN2PZ.js} +12 -12
- package/dist/cli-bundle/focused-chunks/chunk-JXA77YIV.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-LQZ5F6LE.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-LSWUTTE6.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-QXOFSZR6.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-RMCODWHZ.js +65 -0
- package/dist/cli-bundle/focused-chunks/chunk-S6GTALM4.js +24 -0
- package/dist/cli-bundle/focused-chunks/chunk-UPUIDGNJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TVJ2PHAK.js → chunk-W2KIQ7RF.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-WGYR3X6O.js +26 -0
- package/dist/cli-bundle/focused-chunks/chunk-WVYXR3YX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ZJF6ZA7B.js → chunk-XQZKGTZV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-4LFE3FQL.js → chunk-YTNUUEY6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-YZUBG4W2.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-Z6HCQYSW.js +8 -0
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-7XGVHYAO.js → indexed-receipt-blobs-LSBWMXKS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-YO7YGQYE.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-7A3Q4CAJ.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-actor-UQHBNHOF.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-admission-G565NLPE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{settlement-hook-H56537UV.js → settlement-hook-UXN76GMA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/stage-F3YJGNRK.js +2 -0
- package/dist/cli-bundle/main.js +7 -7
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +3 -3
- 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 +57 -57
- 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 +11 -11
- package/dist/core/extensions/extension-hook-runtime.js +1 -1
- package/dist/core/extensions/extension-types.d.ts +30 -0
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/extensions/index.d.ts +21 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/mutation-actor-snapshot.js +2 -0
- package/dist/core/extensions/mutation-actor.js +2 -0
- package/dist/core/item/deferred-fields.js +2 -0
- package/dist/core/item/item-format-version.d.ts +8 -6
- package/dist/core/item/item-format-version.js +1 -1
- package/dist/core/item/item-format.js +2 -2
- package/dist/core/lock/lock.js +3 -3
- package/dist/core/output/linked-test-projection.js +6 -0
- package/dist/core/output/output.d.ts +7 -0
- package/dist/core/output/output.js +9 -7
- package/dist/core/schema/runtime-field-values.d.ts +4 -0
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/session/session-state.js +1 -1
- package/dist/core/shared/item-metadata-contract.js +1 -1
- package/dist/core/shared/text-normalization.d.ts +24 -0
- package/dist/core/shared/text-normalization.js +1 -1
- package/dist/core/shared/url-credentials.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/test/run-selectors.d.ts +3 -1
- package/dist/core/test/run-selectors.js +1 -1
- package/dist/sdk/agent/closed-domain-contracts.js +1 -1
- package/dist/sdk/annotations.js +1 -1
- package/dist/sdk/authoring.d.ts +1 -1
- package/dist/sdk/authoring.js +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
- package/dist/sdk/cli-contracts/completeness.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/registration-helpers.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/completion/bash.js +1 -1
- package/dist/sdk/completion/fish.js +6 -1
- package/dist/sdk/completion/zsh.js +6 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/docs.d.ts +3 -1
- package/dist/sdk/docs.js +1 -1
- package/dist/sdk/environment/project-runtime-compatibility.d.ts +8 -1
- package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
- package/dist/sdk/extension/command-options.d.ts +23 -4
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension/native-command-options.js +2 -0
- package/dist/sdk/files.d.ts +3 -1
- package/dist/sdk/files.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/health.js +1 -1
- package/dist/sdk/governance/lifecycle-dependency-cycles.d.ts +12 -0
- package/dist/sdk/governance/lifecycle-dependency-cycles.js +2 -0
- package/dist/sdk/governance/validate-deferred-fields.js +2 -0
- package/dist/sdk/governance/validate.d.ts +2 -2
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/guide-topics.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/item-transaction.d.ts +2 -2
- package/dist/sdk/item-transaction.js +1 -1
- package/dist/sdk/lifecycle/claim.d.ts +5 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/close.js +1 -1
- package/dist/sdk/lifecycle/copy.js +1 -1
- package/dist/sdk/lifecycle/create-deferrals.js +2 -0
- package/dist/sdk/lifecycle/create.d.ts +6 -2
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
- package/dist/sdk/lifecycle/plan.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/lifecycle/shared-unset-fields.d.ts +7 -1
- package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
- package/dist/sdk/linked-artifacts.d.ts +45 -3
- package/dist/sdk/linked-artifacts.js +2 -2
- package/dist/sdk/merge/three-way.d.ts +1 -1
- package/dist/sdk/merge/three-way.js +2 -2
- package/dist/sdk/output/table-rows.d.ts +28 -4
- package/dist/sdk/output/table-rows.js +1 -1
- package/dist/sdk/output.d.ts +1 -1
- package/dist/sdk/output.js +1 -1
- package/dist/sdk/package-import-adapters.d.ts +9 -1
- package/dist/sdk/package-import-adapters.js +1 -1
- package/dist/sdk/pagination.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/complete-list.d.ts +14 -5
- package/dist/sdk/query/complete-list.js +1 -1
- package/dist/sdk/query/list.js +1 -1
- package/dist/sdk/query/projection-contracts.d.ts +6 -0
- package/dist/sdk/query/projection-contracts.js +1 -1
- package/dist/sdk/read-output/continuation.js +1 -1
- package/dist/sdk/read-output/extension.js +1 -1
- package/dist/sdk/read-output-budget.js +1 -1
- package/dist/sdk/runtime-input.d.ts +6 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.d.ts +2 -2
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/test/batch.d.ts +5 -2
- package/dist/sdk/test/batch.js +2 -2
- package/dist/sdk/test/command-args.js +1 -1
- package/dist/sdk/test/entry.js +2 -2
- package/dist/sdk/test/execution.d.ts +10 -7
- package/dist/sdk/test/execution.js +2 -2
- package/dist/sdk/test/parsers.js +1 -1
- package/dist/sdk/test/prerequisites.d.ts +1 -1
- package/dist/sdk/test/prerequisites.js +1 -1
- package/dist/sdk/test/run-phases.d.ts +44 -0
- package/dist/sdk/test/run-phases.js +2 -0
- package/dist/sdk/testing.d.ts +15 -2
- package/dist/sdk/testing.js +1 -1
- package/dist/types.d.ts +11 -1
- package/dist/types.js +1 -1
- package/docs/AGENT_OUTPUT_ENCODINGS.md +16 -4
- package/docs/COMMANDS.md +31 -4
- package/docs/EXTENSIONS.md +1 -1
- package/docs/LINKED_TEST_EDITS.md +2 -1
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +6 -3
- package/docs/README.md +2 -2
- package/docs/READ_OUTPUT_CONTRACTS.md +23 -2
- package/docs/SDK.md +129 -6
- package/docs/TESTING.md +64 -1
- package/docs/WORKSPACE_CONCURRENCY.md +5 -1
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +9 -9
- package/marketplace.json +1 -1
- package/package.json +6 -4
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/extensions/calendar/command-definitions.ts +2 -0
- 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/extensions/todos/runtime.ts +3 -0
- 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/CHANGELOG.md +0 -4793
- package/dist/cli-bundle/chunks/chunk-36E4L2R4.js +0 -2
- package/dist/cli-bundle/chunks/chunk-4WD4CHVH.js +0 -8
- package/dist/cli-bundle/chunks/chunk-6UXBWMEM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CO7RWLCM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-COTC2QOR.js +0 -6
- package/dist/cli-bundle/chunks/chunk-FAYX6C7H.js +0 -2
- package/dist/cli-bundle/chunks/chunk-GIAJX2QJ.js +0 -9
- package/dist/cli-bundle/chunks/chunk-HQINCDF6.js +0 -116
- package/dist/cli-bundle/chunks/chunk-IYDIPXBO.js +0 -2
- package/dist/cli-bundle/chunks/chunk-L4F4ZHGR.js +0 -2
- package/dist/cli-bundle/chunks/chunk-O4ZLEN4T.js +0 -3
- package/dist/cli-bundle/chunks/chunk-O6PBQMD7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-O6T24Z3M.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OQCVU2SG.js +0 -8
- package/dist/cli-bundle/chunks/chunk-QSSENTXG.js +0 -20
- package/dist/cli-bundle/chunks/chunk-TCYIGAQG.js +0 -31
- package/dist/cli-bundle/chunks/chunk-URWNUZQZ.js +0 -3
- package/dist/cli-bundle/chunks/chunk-UYARS5XF.js +0 -3
- package/dist/cli-bundle/chunks/item-revision-G5OVYGZ5.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-I2X2P4TW.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-SET4KY73.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-WTHZHPOP.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-EZP3EG6A.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-THFZP23A.js +0 -2
- package/dist/cli-bundle/chunks/stage-JXJILTYE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2ZPGEGTB.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3MB47JLT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-5KTOMFLR.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-5NTLNE54.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-ADBFVDTG.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-CSKDIMQP.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-FNIX62V6.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-G6ERMFJ5.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-IYV3IPRF.js +0 -65
- package/dist/cli-bundle/focused-chunks/chunk-QGQJBQCH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-RIMNSVFA.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-VGJDKDKA.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VGUQ4V47.js +0 -82
- package/dist/cli-bundle/focused-chunks/chunk-VTOTZ5UC.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-WFVZ7GGR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZOGEQFGH.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-revision-IF7E7BVY.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-5TFWIOXI.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-KELM46JF.js +0 -2
- package/dist/cli-bundle/focused-chunks/stage-UAKMQTCI.js +0 -2
package/dist/sdk/docs.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Implements the pm docs command surface and its agent-facing runtime behavior.
|
|
5
5
|
*/
|
|
6
|
-
import type{GlobalOptions}from "../core/shared/command-types.js";import type{LinkedDoc}from "../types/index.js";import{type LinkedCollectionMutationReceipt,type LinkedPathValidation}from "./linked-artifacts.js";import type{AnnotationOmissionReceipt}from "./annotations.js";
|
|
6
|
+
import type{GlobalOptions}from "../core/shared/command-types.js";import type{LinkedDoc}from "../types/index.js";import{type LinkedCollectionMutationReceipt,type LinkedPathValidation}from "./linked-artifacts.js";import type{AnnotationOmissionReceipt}from "./annotations.js";import type{LinkedArtifactNoteConflictMode}from "./linked-artifacts.js";
|
|
7
7
|
/** Documents the docs command options payload exchanged by command, SDK, and package integrations. */
|
|
8
8
|
export interface DocsCommandOptions{
|
|
9
9
|
/** Value that configures or reports add for this contract. */
|
|
@@ -16,6 +16,8 @@ remove?:string[];
|
|
|
16
16
|
migrate?:string[];
|
|
17
17
|
/** GH-170 (pm-pfnx): standalone note applied to every --add/--add-glob link in this invocation. */
|
|
18
18
|
note?:string;
|
|
19
|
+
/** How an add treats a stored link with a different note: refuse (default), replace or append (GH-1716). */
|
|
20
|
+
noteConflict?:LinkedArtifactNoteConflictMode|(string&{});
|
|
19
21
|
/** Value that configures or reports list for this contract. */
|
|
20
22
|
list?:boolean;
|
|
21
23
|
/** Value that configures or reports validate paths for this contract. */
|
package/dist/sdk/docs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b1de9573-b582-502d-8fb1-9e6ba3a521b0")}catch{}})();import{renameArtifactsResultKey,runLinkedArtifacts}from"./linked-artifacts.js";async function runDocs(id,options,global2){const result=await runLinkedArtifacts(id,options,global2,{metadataKey:"docs",op:"docs_add",bareNoun:"doc",supportsAppendStable:!1});return renameArtifactsResultKey(result,"docs")}export{runDocs};
|
|
2
2
|
//# sourceMappingURL=docs.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{PmCliError}from "../../core/shared/errors.js";export{PmCliError};
|
|
1
|
+
import{PmCliError}from "../../core/shared/errors.js";import type{ItemMetadata}from "../../types/index.js";export{PmCliError};
|
|
2
2
|
/** First pm release whose history writer and reader support item-hash epoch 3. */
|
|
3
3
|
export declare const HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN="2026.8.31";
|
|
4
4
|
/** One discovered project pin that can prove the active executable is stale. */
|
|
@@ -63,6 +63,13 @@ export declare function historyItemHashVersionForRuntime(version:string):2|3;
|
|
|
63
63
|
export declare function discoverProjectRuntimeVersionPins(projectRoot:string):ProjectRuntimeVersionPin[];
|
|
64
64
|
/** Refuse guarded-format writes while the owning project still selects a host predating format admission. */
|
|
65
65
|
export declare function assertProjectRuntimeFormatGuard(projectRoot:string,formatVersion:number):void;
|
|
66
|
+
/**
|
|
67
|
+
* Stamp the item format a newly written record needs, exactly as a later edit
|
|
68
|
+
* would: a linked-test setup entry needs format 3 (GH-1671). Create and the SDK
|
|
69
|
+
* import writer call it before serializing, and a project whose pinned pm
|
|
70
|
+
* cannot refuse that format is refused before anything is written.
|
|
71
|
+
*/
|
|
72
|
+
export declare function stampRequiredItemFormat(metadata:ItemMetadata,pmRoot:string):void;
|
|
66
73
|
/** Classify mutation-capable invocations while preserving explicit read modes. */
|
|
67
74
|
export declare function isProjectMutatingInvocation(argv:readonly string[]):boolean;
|
|
68
75
|
/** Inspect whether one invocation is compatible with the project's newest pin. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
-
`).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??entry[0].match(VERSION_PATTERN)?.[0]}catch{return}}function discoverProjectRuntimeVersionPins(projectRoot){const pins=[],projectPackage=readJsonRecord(path.join(projectRoot,"package.json"));projectPackage&&pins.push(...dependencyPins(projectPackage).map(pin=>({...pin,source:"package.json"})));const installedVersion=readJsonRecord(path.join(projectRoot,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof installedVersion=="string"&&parseDateVersion(installedVersion)&&pins.push({version:installedVersion,source:"installed-package",constraint:"exact",history_epoch_compatible:historyItemHashVersionForRuntime(installedVersion)===3});const packageLockVersion=packageLockPin(projectRoot);packageLockVersion&&parseDateVersion(packageLockVersion)&&pins.push({version:packageLockVersion,source:"package-lock.json",constraint:"exact",history_epoch_compatible:historyItemHashVersionForRuntime(packageLockVersion)===3});for(const file of["pnpm-lock.yaml","yarn.lock"]){const version=textLockPin(projectRoot,file);version&&pins.push({version,source:file,constraint:"exact",history_epoch_compatible:historyItemHashVersionForRuntime(version)===3})}return pins}function assertProjectRuntimeFormatGuard(projectRoot,formatVersion){if(formatVersion<=1)return;const{minVersion,lt}=createRequire(import.meta.url)("semver"),declaration=dependencyDeclarations(readJsonRecord(path.join(projectRoot,"package.json"))??{}).find(specification=>{try{const minimum=minVersion(specification);return minimum!==null&<(minimum,"2026.10.10")}catch{return!1}}),incompatible=declaration===void 0?discoverProjectRuntimeVersionPins(projectRoot).find(pin=>comparePmDateVersions(pin.version,"2026.10.10")===-1):{version:declaration,source:"package.json"};if(incompatible)throw new PmCliError(`The project selects pm ${incompatible.version}, which cannot safely refuse item format ${formatVersion}.`,EXIT_CODE.CONFLICT,{code:"project_runtime_item_format_incompatible",reason:incompatible.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 commandTokenFromArgv(argv){for(let index=0;index<argv.length;index+=1){const token=argv[index];if(GLOBAL_VALUE_FLAGS.has(token)){index+=1;continue}if(!token.startsWith("-"))return{command:token.toLowerCase(),index}}}function isProjectMutatingInvocation(argv){const commandToken=commandTokenFromArgv(argv);if(!commandToken||hasAnyToken(argv,["--help","-h","--dry-run"]))return!1;const{command,index:commandIndex}=commandToken,positionals=[];for(let index=commandIndex+1;index<argv.length;index+=1){const token=argv[index];if(GLOBAL_VALUE_FLAGS.has(token)){index+=1;continue}token.startsWith("-")||positionals.push(token.toLowerCase())}const mixedClassifier=MIXED_COMMAND_CLASSIFIERS[command];return mixedClassifier?mixedClassifier(argv,positionals):MUTATING_COMMANDS.has(command)}function inspectProjectRuntimeCompatibility(options){const command=commandTokenFromArgv(options.argv)?.command,mutating=isProjectMutatingInvocation(options.argv),pins=discoverProjectRuntimeVersionPins(options.projectRoot).filter(pin=>comparePmDateVersions(pin.version,options.executingVersion)!==null).sort((left,right)=>comparePmDateVersions(right.version,left.version)),newest=pins[0],stale=newest!==void 0&&comparePmDateVersions(options.executingVersion,newest.version)===-1,writerItemHashVersion=historyItemHashVersionForRuntime(options.executingVersion),incompatibleEpochPin=findIncompatibleHistoryEpochPin(pins,writerItemHashVersion),historyEpochIncompatible=mutating&&incompatibleEpochPin!==void 0,warning=stale&&!mutating?{code:"project_runtime_stale_read",executing_version:options.executingVersion,project_version:newest.version,source:newest.source,message:"This read is using an older pm runtime than the project requires.",next_steps:[`Run the command through the project's installed ${PACKAGE_NAME} ${newest.version}.`,"Install the project dependencies with its declared package manager if the local executable is missing."]}:void 0;return{compatible:!mutating||!stale&&!historyEpochIncompatible||options.allowStale===!0,executing_version:options.executingVersion,...newest?{project_version:newest.version,source:newest.source}:{},...command?{command}:{},mutating,stale,history_epoch_incompatible:historyEpochIncompatible,writer_item_hash_version:writerItemHashVersion,...incompatibleEpochPin?{incompatible_project_version:incompatibleEpochPin.declaration,incompatible_source:incompatibleEpochPin.source}:{},...warning?{warning}:{},override_applied:mutating&&(stale||historyEpochIncompatible)&&options.allowStale===!0}}function assertProjectRuntimeCompatibility(options){const result=inspectProjectRuntimeCompatibility(options);if(result.compatible)return result;throw result.history_epoch_incompatible?new PmCliError(`pm ${result.executing_version} cannot write item-hash epoch ${result.writer_item_hash_version} into a project pinned to pm ${result.incompatible_project_version}.`,EXIT_CODE.CONFLICT,{code:"project_runtime_history_epoch_incompatible",reason:result.incompatible_source,why:`The pinned runtime cannot read item_hash_version ${result.writer_item_hash_version}; allowing the write would break its health and validation gates.`,nextSteps:[`Upgrade the project's ${PACKAGE_NAME} pin to ${HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN} 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 PmCliError(`pm ${result.executing_version} cannot mutate a project pinned to newer pm ${result.project_version}.`,EXIT_CODE.CONFLICT,{code:"project_runtime_stale_mutation",reason:result.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 ${PACKAGE_NAME} ${result.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."]})}export{HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN,PmCliError,assertProjectRuntimeCompatibility,assertProjectRuntimeFormatGuard,comparePmDateVersions,discoverProjectRuntimeVersionPins,historyItemHashVersionForRuntime,inspectProjectRuntimeCompatibility,isProjectMutatingInvocation};
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="27729f1f-7de5-5907-943e-88b4b6093842")}catch{}})();import fs from"node:fs";import path from"node:path";import{createRequire}from"node:module";import{EXIT_CODE}from"../../core/shared/constants.js";import{PmCliError}from"../../core/shared/errors.js";import{BASELINE_ITEM_FORMAT_VERSION,requiredItemFormatVersion}from"../../core/item/item-format-version.js";import{resolveWorkspaceRoot}from"../../core/store/paths.js";const PACKAGE_NAME="@unbrained/pm-cli",MUTATING_COMMANDS=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"]),GLOBAL_VALUE_FLAGS=new Set(["--author","--expect-hash","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),VERSION_PATTERN=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN="2026.8.31";function hasAnyToken(argv,tokens){return argv.some(token=>tokens.includes(token.split("=",1)[0]))}function isPackageMutation(argv,positionals){return["activate","adopt","adopt-all","deactivate","init","install","migrate","reload","uninstall"].includes(positionals[0]??"")||hasAnyToken(argv,["--activate","--adopt","--adopt-all","--deactivate","--fix-managed-state","--init","--install","--output","--reload","--scaffold","--uninstall"])}const MIXED_COMMAND_CLASSIFIERS={changelog:(argv,positionals)=>{if(positionals[0]==="generate")return!hasAnyToken(argv,["--check"]);const exportIndex=argv.indexOf("export");return positionals[0]==="export"&&(hasAnyToken(argv,["--output"])||exportIndex>=0&&argv[exportIndex+1]!==void 0&&!argv[exportIndex+1].startsWith("-"))},comments:argv=>hasAnyToken(argv,["--add","--delete","--edit","--file","--stdin"]),config:(_argv,positionals)=>(positionals[0]==="project"||positionals[0]==="global"?positionals[1]:positionals[0])==="set",deps:()=>!1,docs:argv=>hasAnyToken(argv,["--add","--add-glob","--migrate","--remove"]),duplicates:()=>!1,events:()=>!1,extension:isPackageMutation,files:(argv,positionals)=>hasAnyToken(argv,["--add","--add-glob","--migrate","--remove"])||positionals[0]==="discover"&&hasAnyToken(argv,["--apply"]),health:argv=>!hasAnyToken(argv,["--check-only","--no-refresh","--skip-vectors"]),learnings:argv=>hasAnyToken(argv,["--add","--delete","--edit","--file","--stdin"]),merge:(_argv,positionals)=>positionals[0]!=="report",notes:argv=>hasAnyToken(argv,["--add","--delete","--edit","--file","--stdin"]),package:isPackageMutation,packages:isPackageMutation,profile:(_argv,positionals)=>positionals[0]==="apply",schema:(argv,positionals)=>["add-field","add-status","add-type","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type"].includes(positionals[0]??"")&&!(hasAnyToken(argv,["--infer"])&&!hasAnyToken(argv,["--apply"])),telemetry:(_argv,positionals)=>positionals.slice(0,2).some(token=>["clear","flush"].includes(token)),templates:(_argv,positionals)=>positionals[0]==="save",test:argv=>hasAnyToken(argv,["--update","--update-index","--add","--add-json","--background","--measure","--remove","--resume","--run","--stop"]),validate:argv=>hasAnyToken(argv,["--auto-fix","--prune-missing"]),vcs:(_argv,positionals)=>["abandon","create","merge","propose","ref-create"].includes(positionals[0]??""),workspace:(_argv,positionals)=>positionals[0]==="snapshot"&&["create","delete","restore"].includes(positionals[1]??"")};function parseDateVersion(value){const match=value.match(VERSION_PATTERN);return match?[Number(match[1]),Number(match[2]),Number(match[3]),Number(match[4]??0)]:null}function comparePmDateVersions(left,right){const leftParts=parseDateVersion(left),rightParts=parseDateVersion(right);if(!leftParts||!rightParts)return null;for(let index=0;index<leftParts.length;index+=1){const delta=leftParts[index]-rightParts[index];if(delta!==0)return Math.sign(delta)}return 0}function historyItemHashVersionForRuntime(version){return comparePmDateVersions(version,HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN)!==-1?3:2}function findIncompatibleHistoryEpochPin(pins,writerItemHashVersion){if(writerItemHashVersion===3)return pins.filter(pin=>pin.history_epoch_compatible===!1).map(pin=>({...pin,declaration:pin.declaration??pin.version})).sort((left,right)=>comparePmDateVersions(left.version,right.version))[0]}function readJsonRecord(filePath){try{const parsed=JSON.parse(fs.readFileSync(filePath,"utf8"));return typeof parsed=="object"&&parsed!==null&&!Array.isArray(parsed)?parsed:null}catch{return null}}function rangeUpperBounds(alternative){const comparators=[...alternative.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(match=>({inclusive:match[1]==="<=",version:match[2]})),hyphen=alternative.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 hyphen?[...comparators,{inclusive:!0,version:hyphen[1]}]:comparators}function analyzeHistoryEpochRange(specification){const alternativeBounds=specification.split("||").map(alternative=>rangeUpperBounds(alternative));return{bounded:alternativeBounds.some(bounds=>bounds.length>0),compatible:alternativeBounds.some(bounds=>bounds.every(bound=>{const comparison=comparePmDateVersions(HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN,bound.version);return comparison!==null&&(bound.inclusive?comparison!==1:comparison===-1)}))}}function dependencyDeclarations(packageJson){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(field=>{const dependencies=packageJson[field];if(typeof dependencies!="object"||dependencies===null)return[];const value=dependencies[PACKAGE_NAME];return typeof value=="string"?[value.trim()]:[]})}function dependencyPins(packageJson){return dependencyDeclarations(packageJson).flatMap(specification=>{const version=/^[<!]/u.test(specification)?void 0:specification.match(VERSION_PATTERN)?.[0];if(!version)return[];const exact=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(specification),range=analyzeHistoryEpochRange(specification);return[{version,constraint:exact?"exact":range.bounded?"range":"minimum",...exact?{}:{declaration:specification},history_epoch_compatible:exact?comparePmDateVersions(version,HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN)!==-1:range.compatible}]})}function packageLockPin(projectRoot){const packages=readJsonRecord(path.join(projectRoot,"package-lock.json"))?.packages;if(typeof packages!="object"||packages===null)return;const installed=packages["node_modules/@unbrained/pm-cli"];if(typeof installed!="object"||installed===null)return;const version=installed.version;return typeof version=="string"?version:void 0}function textLockPin(projectRoot,file){try{const lines=fs.readFileSync(path.join(projectRoot,file),"utf8").split(/\r?\n/u),packageLineIndex=lines.findIndex(line=>line.includes(PACKAGE_NAME));if(packageLineIndex<0)return;const packageIndent=lines[packageLineIndex].match(/^\s*/u)[0].length,entry=[lines[packageLineIndex]];for(let index=packageLineIndex+1;index<lines.length;index+=1){const line=lines[index],trimmed=line.trim(),indent=line.match(/^\s*/u)[0].length;if(trimmed.length>0&&indent<=packageIndent)break;entry.push(line)}return entry.join(`
|
|
2
|
+
`).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??entry[0].match(VERSION_PATTERN)?.[0]}catch{return}}function discoverProjectRuntimeVersionPins(projectRoot){const pins=[],projectPackage=readJsonRecord(path.join(projectRoot,"package.json"));projectPackage&&pins.push(...dependencyPins(projectPackage).map(pin=>({...pin,source:"package.json"})));const installedVersion=readJsonRecord(path.join(projectRoot,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof installedVersion=="string"&&parseDateVersion(installedVersion)&&pins.push({version:installedVersion,source:"installed-package",constraint:"exact",history_epoch_compatible:historyItemHashVersionForRuntime(installedVersion)===3});const packageLockVersion=packageLockPin(projectRoot);packageLockVersion&&parseDateVersion(packageLockVersion)&&pins.push({version:packageLockVersion,source:"package-lock.json",constraint:"exact",history_epoch_compatible:historyItemHashVersionForRuntime(packageLockVersion)===3});for(const file of["pnpm-lock.yaml","yarn.lock"]){const version=textLockPin(projectRoot,file);version&&pins.push({version,source:file,constraint:"exact",history_epoch_compatible:historyItemHashVersionForRuntime(version)===3})}return pins}function assertProjectRuntimeFormatGuard(projectRoot,formatVersion){if(formatVersion<=1)return;const{minVersion,lt}=createRequire(import.meta.url)("semver"),declaration=dependencyDeclarations(readJsonRecord(path.join(projectRoot,"package.json"))??{}).find(specification=>{try{const minimum=minVersion(specification);return minimum!==null&<(minimum,"2026.10.10")}catch{return!1}}),incompatible=declaration===void 0?discoverProjectRuntimeVersionPins(projectRoot).find(pin=>comparePmDateVersions(pin.version,"2026.10.10")===-1):{version:declaration,source:"package.json"};if(incompatible)throw new PmCliError(`The project selects pm ${incompatible.version}, which cannot safely refuse item format ${formatVersion}.`,EXIT_CODE.CONFLICT,{code:"project_runtime_item_format_incompatible",reason:incompatible.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 stampRequiredItemFormat(metadata,pmRoot){const requiredFormat=requiredItemFormatVersion(metadata);requiredFormat<=BASELINE_ITEM_FORMAT_VERSION||(assertProjectRuntimeFormatGuard(resolveWorkspaceRoot(pmRoot),requiredFormat),metadata.pm_format_version=requiredFormat)}function commandTokenFromArgv(argv){for(let index=0;index<argv.length;index+=1){const token=argv[index];if(GLOBAL_VALUE_FLAGS.has(token)){index+=1;continue}if(!token.startsWith("-"))return{command:token.toLowerCase(),index}}}function isProjectMutatingInvocation(argv){const commandToken=commandTokenFromArgv(argv);if(!commandToken||hasAnyToken(argv,["--help","-h","--dry-run"]))return!1;const{command,index:commandIndex}=commandToken,positionals=[];for(let index=commandIndex+1;index<argv.length;index+=1){const token=argv[index];if(GLOBAL_VALUE_FLAGS.has(token)){index+=1;continue}token.startsWith("-")||positionals.push(token.toLowerCase())}const mixedClassifier=MIXED_COMMAND_CLASSIFIERS[command];return mixedClassifier?mixedClassifier(argv,positionals):MUTATING_COMMANDS.has(command)}function inspectProjectRuntimeCompatibility(options){const command=commandTokenFromArgv(options.argv)?.command,mutating=isProjectMutatingInvocation(options.argv),pins=discoverProjectRuntimeVersionPins(options.projectRoot).filter(pin=>comparePmDateVersions(pin.version,options.executingVersion)!==null).sort((left,right)=>comparePmDateVersions(right.version,left.version)),newest=pins[0],stale=newest!==void 0&&comparePmDateVersions(options.executingVersion,newest.version)===-1,writerItemHashVersion=historyItemHashVersionForRuntime(options.executingVersion),incompatibleEpochPin=findIncompatibleHistoryEpochPin(pins,writerItemHashVersion),historyEpochIncompatible=mutating&&incompatibleEpochPin!==void 0,warning=stale&&!mutating?{code:"project_runtime_stale_read",executing_version:options.executingVersion,project_version:newest.version,source:newest.source,message:"This read is using an older pm runtime than the project requires.",next_steps:[`Run the command through the project's installed ${PACKAGE_NAME} ${newest.version}.`,"Install the project dependencies with its declared package manager if the local executable is missing."]}:void 0;return{compatible:!mutating||!stale&&!historyEpochIncompatible||options.allowStale===!0,executing_version:options.executingVersion,...newest?{project_version:newest.version,source:newest.source}:{},...command?{command}:{},mutating,stale,history_epoch_incompatible:historyEpochIncompatible,writer_item_hash_version:writerItemHashVersion,...incompatibleEpochPin?{incompatible_project_version:incompatibleEpochPin.declaration,incompatible_source:incompatibleEpochPin.source}:{},...warning?{warning}:{},override_applied:mutating&&(stale||historyEpochIncompatible)&&options.allowStale===!0}}function assertProjectRuntimeCompatibility(options){const result=inspectProjectRuntimeCompatibility(options);if(result.compatible)return result;throw result.history_epoch_incompatible?new PmCliError(`pm ${result.executing_version} cannot write item-hash epoch ${result.writer_item_hash_version} into a project pinned to pm ${result.incompatible_project_version}.`,EXIT_CODE.CONFLICT,{code:"project_runtime_history_epoch_incompatible",reason:result.incompatible_source,why:`The pinned runtime cannot read item_hash_version ${result.writer_item_hash_version}; allowing the write would break its health and validation gates.`,nextSteps:[`Upgrade the project's ${PACKAGE_NAME} pin to ${HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN} 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 PmCliError(`pm ${result.executing_version} cannot mutate a project pinned to newer pm ${result.project_version}.`,EXIT_CODE.CONFLICT,{code:"project_runtime_stale_mutation",reason:result.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 ${PACKAGE_NAME} ${result.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."]})}export{HISTORY_ITEM_HASH_VERSION_3_INTRODUCED_IN,PmCliError,assertProjectRuntimeCompatibility,assertProjectRuntimeFormatGuard,comparePmDateVersions,discoverProjectRuntimeVersionPins,historyItemHashVersionForRuntime,inspectProjectRuntimeCompatibility,isProjectMutatingInvocation,stampRequiredItemFormat};
|
|
3
3
|
//# sourceMappingURL=project-runtime-compatibility.js.map
|
|
@@ -61,11 +61,30 @@ export declare function collectExtensionFlagDefinitionsForCommand(registrations:
|
|
|
61
61
|
* `status-filter`, `--status-filter`, or its short letter) folds into the
|
|
62
62
|
* handler key, then declared defaults, value coercion, and strict validation
|
|
63
63
|
* apply through {@link coerceLooseCommandOptionsWithFlagDefinitions}. An
|
|
64
|
-
* `undefined` value counts as omitted.
|
|
65
|
-
*
|
|
66
|
-
*
|
|
64
|
+
* `undefined` value counts as omitted. Two spellings of one flag with
|
|
65
|
+
* different values are refused with `extension_option_spelling_conflict`.
|
|
66
|
+
*
|
|
67
|
+
* The refusals match CLI dispatch (pm-gh1726, pm-gh1727): a key that is
|
|
68
|
+
* neither a declared spelling nor a host-owned option ({@link isDirectHostOptionKey})
|
|
69
|
+
* is refused with `unknown_option` before the handler runs; a missing required
|
|
70
|
+
* flag (an empty array counts as missing for a list flag) with
|
|
71
|
+
* `missing_required_option`; a disabled flag with `extension_option_disabled`;
|
|
72
|
+
* and an array for a flag that is not `list`/`repeatable` with
|
|
73
|
+
* `extension_flag_value_invalid`, because argv never delivers one. Host-owned
|
|
74
|
+
* keys pass through unchanged. A command that declares no flags is returned
|
|
75
|
+
* as it is (pm-4of199 owns that refusal).
|
|
76
|
+
*
|
|
77
|
+
* Pass `{ undeclaredKeys: "pass" }` for a native command path an extension
|
|
78
|
+
* extends or overrides (`list`): the native contract, including its aliases,
|
|
79
|
+
* negated flags and settings-dependent runtime fields, owns every other key
|
|
80
|
+
* there, so undeclared keys keep passing through as before. A `repeatable`
|
|
81
|
+
* declaration counts as `list` here, as the loader expands it.
|
|
67
82
|
*/
|
|
68
|
-
export declare function normalizeDirectExtensionCommandOptions(options:Record<string,unknown>,
|
|
83
|
+
export declare function normalizeDirectExtensionCommandOptions(options:Record<string,unknown>,declaredDefinitions:ReadonlyArray<LooseCommandFlagDefinition>,commandPath:string,policy?:DirectExtensionOptionPolicy):Record<string,unknown>;
|
|
84
|
+
/** How {@link normalizeDirectExtensionCommandOptions} treats a key no declaration or host flag owns. */
|
|
85
|
+
export interface DirectExtensionOptionPolicy{
|
|
86
|
+
/** `refuse` (default) for an extension-created command; `pass` for a native command path an extension extends. */
|
|
87
|
+
undeclaredKeys?:"refuse"|"pass";}
|
|
69
88
|
/** How an argv option token takes its value, as Commander parses it: `<value>`, `[value]`, or a switch. */
|
|
70
89
|
export type ArgvOptionArity="required"|"optional"|"none";
|
|
71
90
|
/** An option a command registered with Commander: how it takes its value and the attribute it sets. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="90fdc6f3-29d4-5266-a142-d9d14fbb12e7")}catch{}})();import{isDeepStrictEqual}from"node:util";import{resolvePmCommandOperation}from"../cli-contracts/command-aliases.js";import{describeFlagScalarValueFailure,resolveExtensionFlagValueContract,resolveExtensionLongFlagName,EXIT_CODE,PmCliError,flattenFlagListValue,resolveFlagValueKind}from"../runtime-primitives.js";const UNSAFE_LOOSE_OPTION_KEYS=new Set(["__proto__","prototype","constructor"]),LOOSE_OPTION_OCCURRENCES=Symbol("looseOptionOccurrences");function toLooseOptionKey(rawKey){return rawKey.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(_match,group)=>group.toUpperCase())}function setLooseOptionValue(options,key,value){const existing=options[key];if(existing===void 0){options[key]=value;return}if(Array.isArray(existing)){existing.push(value),options[key]=existing;return}options[key]=[existing,value]}function parseLooseOptionToken(args,index){const token=args[index];if(!token.startsWith("-")||token==="-"||token==="--")return null;if(!token.startsWith("--")){const equalsIndex2=token.indexOf("=");if(equalsIndex2>=0)return{consumed:1,key:token.slice(1,equalsIndex2).trim(),value:token.slice(equalsIndex2+1),attached:!0};const key2=token.slice(1).trim(),next2=args[index+1];return typeof next2=="string"&&!next2.startsWith("-")?{consumed:2,key:key2,value:next2}:{consumed:1,key:key2,value:!0}}const equalsIndex=token.indexOf("=");if(equalsIndex>=0)return{consumed:1,key:token.slice(2,equalsIndex).trim(),value:token.slice(equalsIndex+1),attached:!0};if(token.startsWith("--no-"))return{consumed:1,key:token.slice(5).trim(),value:!1};const key=token.slice(2).trim(),next=args[index+1];return typeof next=="string"&&!next.startsWith("-")?{consumed:2,key,value:next}:{consumed:1,key,value:!0}}function isUnsafeLooseOptionKey(key){return UNSAFE_LOOSE_OPTION_KEYS.has(key)}function resolveLooseOptionCoercionKind(definition){const raw=(typeof definition.value_type=="string"?definition.value_type:void 0)??(typeof definition.type=="string"?definition.type:void 0);return resolveFlagValueKind(raw)}function collectLooseOptionKeys(definition){const keys=[],long=resolveExtensionLongFlagName(definition.long)??"",short=typeof definition.short=="string"?definition.short.trim():"";if(long.startsWith("--")){const normalized=toLooseOptionKey(long.slice(2));normalized.length>0&&!isUnsafeLooseOptionKey(normalized)&&keys.push(normalized)}if(short.startsWith("-")&&!short.startsWith("--")){const normalized=toLooseOptionKey(short.slice(1));normalized.length>0&&!isUnsafeLooseOptionKey(normalized)&&keys.push(normalized)}return[...new Set(keys)]}function collectLooseCommandOptionKeysForDefinitions(definitions){const keys=new Set;for(const definition of definitions)for(const key of collectLooseOptionKeys(definition))keys.add(key);return keys}function resolveCanonicalLooseOptionKey(definition){const long=resolveExtensionLongFlagName(definition.long)??"";if(long.startsWith("--")){const normalized=toLooseOptionKey(long.slice(2));if(normalized.length>0&&!isUnsafeLooseOptionKey(normalized))return normalized}return collectLooseOptionKeys(definition)[0]??null}function formatLooseOptionLabel(definition){const long=typeof definition.long=="string"?definition.long.trim():"";if(long.startsWith("--")&&long.length>2)return long;const short=typeof definition.short=="string"?definition.short.trim():"";return short.startsWith("-")&&!short.startsWith("--")&&short.length>1?short:null}function collectRefusalListingLabels(definitions,listing){return[...(listing.definitions??definitions).map(definition=>formatLooseOptionLabel(definition)).filter(label=>label!==null),...listing.inheritedFlags??[]]}function validateLooseCommandOptionsWithFlagDefinitions(options,definitions,commandPath,listing={}){if(definitions.length===0)return;const allowed=new Set,disabled=new Map,required=[],labels=collectRefusalListingLabels(definitions,listing);for(const definition of definitions){const keys=collectLooseOptionKeys(definition),normalizedLabel=formatLooseOptionLabel(definition);for(const key of keys)allowed.add(key),definition.enabled===!1&&disabled.set(key,normalizedLabel);definition.required===!0&&definition.enabled!==!1&&keys.length>0&&required.push({keys,label:normalizedLabel})}for(const key of Object.keys(options)){if(!allowed.has(key)){const expected=labels.length>0?` Expected one of: ${[...new Set(labels)].join(", ")}.`:"";throw new PmCliError(`Unknown option '--${key}' for extension command '${commandPath}'.${expected}`,EXIT_CODE.USAGE,{code:"unknown_option",flag:`--${key}`,required:`Use a flag the command accepts; run pm contracts --command ${commandPath} --flags-only --json to list them.`})}const disabledLabel=disabled.get(key);if(disabledLabel)throw new PmCliError(`Option '${disabledLabel}' is disabled for extension command '${commandPath}'.`,EXIT_CODE.USAGE)}for(const entry of required)if(!entry.keys.some(key=>Object.hasOwn(options,key)))throw new PmCliError(`Missing required option '${entry.label}' for extension command '${commandPath}'.`,EXIT_CODE.USAGE)}function coerceLooseStringOptionValue(value){return typeof value=="string"||value==null?value:String(value)}function coerceLooseNumberOptionValue(value){if(typeof value=="number")return value;if(typeof value=="string"&&value.trim().length>0){const parsed=Number(value);return Number.isFinite(parsed)?parsed:value}return value}function coerceLooseBooleanOptionValue(value){if(typeof value=="boolean")return value;if(typeof value=="string"){const normalized=value.trim().toLowerCase();if(normalized==="true"||normalized==="1")return!0;if(normalized==="false"||normalized==="0")return!1}return value}const LOOSE_OPTION_VALUE_COERCERS={string:coerceLooseStringOptionValue,number:coerceLooseNumberOptionValue,boolean:coerceLooseBooleanOptionValue};function coerceLooseOptionValue(value,kind){return Array.isArray(value)?value.map(entry=>coerceLooseOptionValue(entry,kind)):LOOSE_OPTION_VALUE_COERCERS[kind](value)}function normalizeAccumulatedFlagValue(value,kind,preserveOccurrenceCommas){const entries=preserveOccurrenceCommas?(Array.isArray(value)?value.flat(1/0):[value]).filter(entry=>entry!=null&&entry!==""):flattenFlagListValue(value);return kind?entries.map(entry=>coerceLooseOptionValue(entry,kind)):entries}function applyFlagDefault(defaultValue,kind,isListFlag,preserveOccurrenceCommas){return isListFlag?normalizeAccumulatedFlagValue(defaultValue,kind,preserveOccurrenceCommas):kind?coerceLooseOptionValue(defaultValue,kind):defaultValue}function readOrderedLooseListValues(occurrenceSource,optionKeys,fallback){const occurrences=occurrenceSource[LOOSE_OPTION_OCCURRENCES];if(!occurrences||occurrences.length===0)return fallback;const acceptedKeys=new Set(optionKeys);return occurrences.filter(occurrence=>acceptedKeys.has(occurrence.key)).map(occurrence=>occurrence.value)}function isBooleanSwitchDefinition(definition){return resolveExtensionFlagValueContract(definition).value_arity==="none"}function refuseStrictScalarValue(definition,kind,entry,expected,commandPath){const label=formatLooseOptionLabel(definition),scope=commandPath?` for extension command '${commandPath}'`:"",received=entry===!0?"no value":JSON.stringify(entry);throw new PmCliError(`Option '${label}'${scope} expects ${expected}; received ${received}.`,EXIT_CODE.USAGE,{code:"extension_flag_value_invalid",required:`Pass ${label} ${kind==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${kind} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${kind} value for ${label}.`,`Run pm ${commandPath??"<command>"} --help to review the declared flag contract.`]})}function isStrictTypedDefinition(definition,kind){return definition.value_validation==="strict"&&kind!=="string"}function readLooseOccurrences(occurrenceSource,optionKeys){const occurrences=occurrenceSource[LOOSE_OPTION_OCCURRENCES];if(!occurrences)return[];const acceptedKeys=new Set(optionKeys);return occurrences.filter(occurrence=>acceptedKeys.has(occurrence.key))}function refuseMalformedAttachedSwitchValues(definition,optionKeys,occurrenceSource,commandPath){if(isBooleanSwitchDefinition(definition))for(const occurrence of readLooseOccurrences(occurrenceSource,optionKeys)){if(occurrence.attached!==!0)continue;const values=definition.list===!0&&definition.repeatable!==!0?flattenFlagListValue(occurrence.value):[occurrence.value];for(const value of values){const failure=describeFlagScalarValueFailure(coerceLooseOptionValue(value,"boolean"),"boolean");failure!==null&&refuseStrictScalarValue(definition,"boolean",value,failure.expected,commandPath)}}}function refuseEmptyStrictListEntries(definition,kind,rawValue,preserveOccurrenceCommas,commandPath){const occurrences=Array.isArray(rawValue)?rawValue.flat(1/0):[rawValue],entries=preserveOccurrenceCommas?occurrences:occurrences.flatMap(entry=>typeof entry=="string"?entry.split(","):[entry]);for(const entry of entries)if(typeof entry=="string"&&entry.trim().length===0){const failure=describeFlagScalarValueFailure(entry,kind);refuseStrictScalarValue(definition,kind,entry,failure.expected,commandPath)}}function validateStrictScalarOptionValue(definition,value,kind,commandPath){if(!isStrictTypedDefinition(definition,kind))return value;const isSwitch=kind==="boolean"&&isBooleanSwitchDefinition(definition),normalizeEntry=entry=>{const failure=describeFlagScalarValueFailure(entry,kind);return failure===null?entry:isSwitch&&typeof entry=="string"?!0:refuseStrictScalarValue(definition,kind,entry,failure.expected,commandPath)};return Array.isArray(value)?value.map(normalizeEntry):normalizeEntry(value)}function mergeAliasOptionKeys(coerced,canonical,optionKeys,isListFlag){for(const key of optionKeys)if(!(key===canonical||!Object.hasOwn(coerced,key))){if(Object.hasOwn(coerced,canonical)){if(isListFlag){const canonicalValue=coerced[canonical],aliasValue=coerced[key];coerced[canonical]=[...Array.isArray(canonicalValue)?canonicalValue:[canonicalValue],...Array.isArray(aliasValue)?aliasValue:[aliasValue]].filter(value=>value!=null)}delete coerced[key];continue}coerced[canonical]=coerced[key],delete coerced[key]}}function coerceLooseCommandOptionsWithFlagDefinitions(options,definitions,occurrenceSource=options,commandPath){if(definitions.length===0)return options;const coerced=Object.create(null);for(const[key,value]of Object.entries(options))coerced[key]=value;const canonicalKeys=new Set(definitions.map(definition=>resolveCanonicalLooseOptionKey(definition)).filter(key=>key!==null));for(const definition of definitions){const canonical=resolveCanonicalLooseOptionKey(definition);if(canonical){const optionKeys=collectLooseOptionKeys(definition).filter(key=>key===canonical||!canonicalKeys.has(key));coerceDefinedLooseOption(coerced,definition,canonical,optionKeys,occurrenceSource,commandPath)}}return coerced}function coerceDefinedLooseOption(coerced,definition,canonical,optionKeys,occurrenceSource,commandPath){const isListFlag=definition.list===!0,kind=resolveLooseOptionCoercionKind(definition);kind&&!isListFlag&&refuseMalformedScalarAliasValues(coerced,definition,canonical,optionKeys,kind,commandPath),mergeAliasOptionKeys(coerced,canonical,optionKeys,isListFlag);const preserveOccurrenceCommas=definition.repeatable===!0;if(!Object.hasOwn(coerced,canonical)){definition.default!==void 0&&(coerced[canonical]=applyFlagDefault(definition.default,kind,isListFlag,preserveOccurrenceCommas));return}if(kind==="boolean"&&isStrictTypedDefinition(definition,kind)&&refuseMalformedAttachedSwitchValues(definition,optionKeys,occurrenceSource,commandPath),isListFlag){coerced[canonical]=coerceAccumulatedLooseOption(definition,optionKeys,occurrenceSource,coerced[canonical],kind,preserveOccurrenceCommas,commandPath);return}kind&&(coerced[canonical]=validateStrictScalarOptionValue(definition,coerceLooseOptionValue(coerced[canonical],kind),kind,commandPath))}function refuseMalformedScalarAliasValues(coerced,definition,canonical,optionKeys,kind,commandPath){for(const key of optionKeys)key!==canonical&&Object.hasOwn(coerced,key)&&validateStrictScalarOptionValue(definition,coerceLooseOptionValue(coerced[key],kind),kind,commandPath)}function coerceAccumulatedLooseOption(definition,optionKeys,occurrenceSource,current,kind,preserveOccurrenceCommas,commandPath){const ordered=readOrderedLooseListValues(occurrenceSource,optionKeys,current);kind&&isStrictTypedDefinition(definition,kind)&&refuseEmptyStrictListEntries(definition,kind,ordered,preserveOccurrenceCommas,commandPath);const normalized=normalizeAccumulatedFlagValue(ordered,kind,preserveOccurrenceCommas);return kind?validateStrictScalarOptionValue(definition,normalized,kind,commandPath):normalized}function parseLooseCommandOptions(args){const options=Object.create(null),occurrences=[];Object.defineProperty(options,LOOSE_OPTION_OCCURRENCES,{value:occurrences});let index=0;for(;index<args.length;){const parsed=parseLooseOptionToken(args,index);if(!parsed){index+=1;continue}const normalizedKey=toLooseOptionKey(parsed.key);if(normalizedKey.length===0||isUnsafeLooseOptionKey(normalizedKey)){index+=parsed.consumed;continue}setLooseOptionValue(options,normalizedKey,parsed.value),occurrences.push({...parsed,key:normalizedKey}),index+=parsed.consumed}return options}function collectLoosePositionalArgs(args){const positionals=[];let index=0;for(;index<args.length;){if(args[index]==="--"){positionals.push(...args.slice(index+1));break}const parsed=parseLooseOptionToken(args,index);if(parsed){index+=Math.max(1,parsed.consumed);continue}positionals.push(args[index]),index+=1}return positionals}function stripLooseCommandOptionTokens(args,definitions){if(definitions.length===0)return[...args];const knownKeys=new Set,booleanKeys=new Set;for(const definition of definitions){const valueKind=resolveLooseOptionCoercionKind(definition);for(const key of collectLooseOptionKeys(definition))knownKeys.add(key),valueKind==="boolean"&&booleanKeys.add(key)}if(knownKeys.size===0)return[...args];const stripped=[];let index=0;for(;index<args.length;){if(args[index]==="--"){stripped.push(...args.slice(index+1));break}const parsed=parseLooseOptionToken(args,index);if(parsed){const normalizedKey=toLooseOptionKey(parsed.key);if(knownKeys.has(normalizedKey)){const token=args[index],consumed=booleanKeys.has(normalizedKey)&&!token.includes("=")?1:parsed.consumed;index+=consumed;continue}}stripped.push(args[index]),index+=1}return stripped}function resolveExtensionFlagOptionKey(definition){return resolveCanonicalLooseOptionKey(definition)}function normalizeFlagTargetCommandPath(commandPath){return commandPath.trim().toLowerCase().split(/\s+/u).filter(part=>part.length>0).join(" ")}function collectExtensionFlagDefinitionsForCommand(registrations,commandPath){const normalizedCommandPath=normalizeFlagTargetCommandPath(commandPath);if(normalizedCommandPath.length===0)return[];const operation=resolvePmCommandOperation(normalizedCommandPath);return registrations.flags.filter(entry=>resolvePmCommandOperation(normalizeFlagTargetCommandPath(entry.target_command))===operation).flatMap(entry=>[...entry.flags])}function refuseConflictingOptionSpellings(definition,handlerKey,spellings,commandPath){const label=formatLooseOptionLabel(definition),[first,second]=spellings;throw new PmCliError(`Options '${first}' and '${second}' both set ${label} for extension command '${commandPath}' with different values.`,EXIT_CODE.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${label} once, under the handler key '${handlerKey}'.`,why:`'${first}' and '${second}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${first}' or '${second}' and pass one value as '${handlerKey}'.`,`Run pm contracts --command ${commandPath} --flags-only --json to read each flag's sdk_option key.`]})}function normalizeDirectExtensionCommandOptions(options,definitions,commandPath){if(definitions.length===0)return options;const index=indexDeclaredOptionSpellings(definitions),folded=foldDirectOptionSpellings(options,index,commandPath),handlerKeys=new Set([...index.long.values()].map(({handlerKey})=>handlerKey)),declared=Object.create(null),passthrough=Object.create(null);for(const[key,value]of Object.entries(folded))(handlerKeys.has(key)?declared:passthrough)[key]=value;return refuseDirectDeclarationViolations(declared,definitions,commandPath),Object.assign(passthrough,coerceLooseCommandOptionsWithFlagDefinitions(declared,definitions,recordDirectOptionOccurrences(declared,index),commandPath))}function recordDirectOptionOccurrences(folded,index){const handlerKeys=new Set([...index.long.values()].map(({handlerKey})=>handlerKey)),occurrences=Object.entries(folded).filter(([key])=>handlerKeys.has(key)).flatMap(([key,value])=>(Array.isArray(value)?value.flat(1/0):[value]).map(entry=>({consumed:1,key,value:entry,attached:!0}))),occurrenceSource=Object.create(null);return Object.defineProperty(occurrenceSource,LOOSE_OPTION_OCCURRENCES,{value:occurrences}),occurrenceSource}function refuseDirectDeclarationViolations(declared,definitions,commandPath){for(const definition of definitions){const handlerKey=resolveCanonicalLooseOptionKey(definition);if(handlerKey===null)continue;const label=formatLooseOptionLabel(definition),supplied=Object.hasOwn(declared,handlerKey);if(definition.enabled===!1&&supplied)throw new PmCliError(`Option '${label}' is disabled for extension command '${commandPath}'.`,EXIT_CODE.USAGE);if(definition.required===!0&&definition.enabled!==!1&&!supplied)throw new PmCliError(`Missing required option '${label}' for extension command '${commandPath}'.`,EXIT_CODE.USAGE)}}function indexDeclaredOptionSpellings(definitions){const index={long:new Map,short:new Map},claim=(map,spelling,entry)=>{spelling.length>0&&!map.has(spelling)&&map.set(spelling,entry)};for(const definition of definitions){const handlerKey=resolveCanonicalLooseOptionKey(definition);if(handlerKey===null)continue;const entry={handlerKey,definition};claim(index.long,handlerKey,entry);const short=typeof definition.short=="string"?definition.short.trim():"";short.startsWith("-")&&!short.startsWith("--")&&claim(index.short,short.slice(1),entry)}return index}function resolveDeclaredOptionSpelling(index,spelling){return index.long.get(spelling)??index.short.get(spelling.replace(/^-(?!-)/u,""))??index.long.get(toLooseOptionKey(spelling.replace(/^-{1,2}/u,"")))}function resolveNegatedBooleanSpelling(index,spelling,value){const negated=/^(?:--)?no-(.+)$/u.exec(spelling)?.[1];if(negated===void 0||resolveDeclaredOptionSpelling(index,spelling)!==void 0)return{spelling,value};const declared=resolveDeclaredOptionSpelling(index,negated),flag=coerceLooseBooleanOptionValue(value);return declared!==void 0&&resolveLooseOptionCoercionKind(declared.definition)==="boolean"&&typeof flag=="boolean"?{spelling:negated,value:!flag}:{spelling,value}}function foldDirectOptionSpellings(options,index,commandPath){const folded=Object.create(null),suppliedBy=new Map;for(const[rawSpelling,rawValue]of Object.entries(options)){const{spelling,value}=resolveNegatedBooleanSpelling(index,rawSpelling,rawValue),declared=resolveDeclaredOptionSpelling(index,spelling);if(declared===void 0)folded[spelling]=value;else if(value!==void 0){const prior=suppliedBy.get(declared.handlerKey);prior===void 0?(suppliedBy.set(declared.handlerKey,spelling),folded[declared.handlerKey]=value):isDeepStrictEqual(folded[declared.handlerKey],value)||refuseConflictingOptionSpellings(declared.definition,declared.handlerKey,[prior,spelling],commandPath)}}return folded}function indexDeclaredArgvSpellings(definitions){const index=new Map;for(const definition of definitions){const handlerKey=resolveCanonicalLooseOptionKey(definition);if(handlerKey===null)continue;const entry={definition,handlerKey,kind:resolveLooseOptionCoercionKind(definition),arity:resolveExtensionFlagValueContract(definition).value_arity,scalar:definition.list!==!0},spellings=[resolveExtensionLongFlagName(definition.long),typeof definition.short=="string"?definition.short.trim():""];for(const spelling of spellings.filter(candidate=>candidate?.startsWith("-")===!0))index.has(spelling)||index.set(spelling,entry)}return index}function resolveArgvSpelling(scope,index,spelling){const registered=scope.optionOf(spelling),declared=index.get(spelling),settable=declared?.scalar===!0?declared:void 0;if(registered!==void 0){const base={arity:registered.arity,...registered.variadic===!0?{variadic:!0}:{}};if(settable?.handlerKey===registered.key)return{...base,declared:settable};const positive=declared===void 0&&spelling.startsWith("--no-")?index.get(`--${spelling.slice(5)}`):void 0;return positive?.scalar===!0&&positive.kind==="boolean"&&positive.handlerKey===registered.key?{...base,declared:positive,negates:!0}:base}if(!(!scope.includesLooseFlags||declared===void 0))return settable===void 0?{arity:declared.arity,loose:!0}:{arity:declared.arity,declared:settable,loose:!0}}function isArgvOptionToken(token){return token.length>1&&token.startsWith("-")}const NEGATIVE_NUMBER_ARGV_TOKEN=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function scanArgvScope(scope,resolve,record){const{tokens}=scope;let position=0,group,unrecognizedSeen=!1,variadic=!1;for(;position<tokens.length||group!==void 0;){const token=group??tokens[position++];if(token==="--")return;if(variadic&&group===void 0&&isArgvVariadicValue(scope,token))continue;const step=isArgvOptionToken(token)?scanArgvOptionToken(scope,token,tokens[position],resolve,record):{consumedByCommander:!1,consumed:0};if(position+=step.consumed,group=step.group,variadic=step.variadic===!0,!step.consumedByCommander){if(stopsArgvScope(scope.stop,token,unrecognizedSeen))return;unrecognizedSeen=!0}}}function isArgvVariadicValue(scope,token){return!isArgvOptionToken(token)||scope.negativeNumbersAreValues&&NEGATIVE_NUMBER_ARGV_TOKEN.test(token)}function stopsArgvScope(stop,token,unrecognizedSeen){return stop!==void 0&&(stop.atFirstUnrecognized||!unrecognizedSeen&&stop.atSubcommand(token))}function scanArgvOptionToken(scope,token,next,resolve,record){const loose=readLooseArgvOccurrence(token,next,resolve);if(loose!==void 0)return record(loose.spelling,loose.entry,loose.value),{consumedByCommander:!1,consumed:loose.consumed};const exact=resolve(token);if(exact!==void 0){const takesNext=exact.arity==="required"||exact.arity==="optional"&&next!==void 0&&(!isArgvOptionToken(next)||scope.negativeNumbersAreValues&&NEGATIVE_NUMBER_ARGV_TOKEN.test(next));return record(token,exact,exact.negates===!0?!1:takesNext?next:!0),{consumedByCommander:!0,consumed:takesNext?1:0,variadic:exact.variadic===!0}}return token[1]!=="-"?{consumed:0,...scanShortGroup(token,resolve,record)}:{consumedByCommander:scanLongToken(token,resolve,record,scope.includesLooseFlags?record:()=>{}),consumed:0}}function readLooseArgvOccurrence(token,next,resolve){const equals=token.indexOf("="),spelling=equals>1?token.slice(0,equals):token,entry=resolve(spelling);if(entry?.loose===!0)return equals>1?{spelling,entry,value:token.slice(equals+1),consumed:0}:next!==void 0&&!next.startsWith("-")?{spelling,entry,value:next,consumed:1}:{spelling,entry,value:!0,consumed:0};const negated=equals<0&&token.startsWith("--no-")?resolve(`--${token.slice(5)}`):void 0;return negated?.loose===!0&&negated.declared?.kind==="boolean"?{spelling:token,entry:negated,value:!1,consumed:0}:void 0}function scanShortGroup(token,resolve,record){const spelling=token.slice(0,2),entry=token.length>2?resolve(spelling):void 0;return entry===void 0||entry.loose===!0?{consumedByCommander:!1}:entry.arity!=="none"?(record(spelling,entry,token.slice(2)),{consumedByCommander:!0}):(record(spelling,entry,!0),{consumedByCommander:!0,group:`-${token.slice(2)}`})}function scanLongToken(token,resolve,record,recordUnparsed){const equals=token.indexOf("=");if(equals>2){const spelling=token.slice(0,equals),entry=resolve(spelling);return entry!==void 0&&entry.arity!=="none"?(record(spelling,entry,token.slice(equals+1)),!0):(entry?.declared?.kind==="boolean"&&recordUnparsed(spelling,entry,token.slice(equals+1)),!1)}const negated=token.startsWith("--no-")?resolve(`--${token.slice(5)}`):void 0;return negated?.declared?.kind==="boolean"&&recordUnparsed(token,negated,!1),!1}function refuseConflictingArgvOptionSpellings(scopes,definitions,commandPath){const index=indexDeclaredArgvSpellings(definitions),latest=new Map;for(const scope of scopes)scanArgvScope(scope,spelling=>resolveArgvSpelling(scope,index,spelling),(spelling,entry,value)=>{entry.declared!==void 0&&recordArgvSpellingValue(latest,entry.declared,spelling,value,commandPath)})}function recordArgvSpellingValue(latest,declared,spelling,value,commandPath){const{definition,handlerKey,kind}=declared,coerced=kind?coerceLooseOptionValue(value,kind):value,spellings=latest.get(handlerKey)??new Map,conflicting=[...spellings].find(([other,otherValue])=>other!==spelling&&!isDeepStrictEqual(otherValue,coerced));conflicting!==void 0&&refuseConflictingOptionSpellings(definition,handlerKey,[conflicting[0],spelling],commandPath),spellings.set(spelling,coerced),latest.set(handlerKey,spellings)}export{coerceLooseCommandOptionsWithFlagDefinitions,collectExtensionFlagDefinitionsForCommand,collectLooseCommandOptionKeysForDefinitions,collectLoosePositionalArgs,normalizeDirectExtensionCommandOptions,parseLooseCommandOptions,refuseConflictingArgvOptionSpellings,resolveExtensionFlagOptionKey,stripLooseCommandOptionTokens,validateLooseCommandOptionsWithFlagDefinitions};
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ab4e2ed3-e7e8-5a7a-a13e-7b8dce750dc4")}catch{}})();import{isDeepStrictEqual}from"node:util";import{resolvePmCommandOperation}from"../cli-contracts/command-aliases.js";import{describeFlagScalarValueFailure,resolveExtensionFlagValueContract,resolveExtensionLongFlagName,EXIT_CODE,PmCliError,flattenFlagListValue,resolveFlagValueKind}from"../runtime-primitives.js";import{RESERVED_EXTENSION_HOST_FLAG_NAMES}from"../../core/extensions/reserved-host-flags.js";const UNSAFE_LOOSE_OPTION_KEYS=new Set(["__proto__","prototype","constructor"]),LOOSE_OPTION_OCCURRENCES=Symbol("looseOptionOccurrences");function toLooseOptionKey(rawKey){return rawKey.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(_match,group)=>group.toUpperCase())}function setLooseOptionValue(options,key,value){const existing=options[key];if(existing===void 0){options[key]=value;return}if(Array.isArray(existing)){existing.push(value),options[key]=existing;return}options[key]=[existing,value]}function parseLooseOptionToken(args,index){const token=args[index];if(!token.startsWith("-")||token==="-"||token==="--")return null;if(!token.startsWith("--")){const equalsIndex2=token.indexOf("=");if(equalsIndex2>=0)return{consumed:1,key:token.slice(1,equalsIndex2).trim(),value:token.slice(equalsIndex2+1),attached:!0};const key2=token.slice(1).trim(),next2=args[index+1];return typeof next2=="string"&&!next2.startsWith("-")?{consumed:2,key:key2,value:next2}:{consumed:1,key:key2,value:!0}}const equalsIndex=token.indexOf("=");if(equalsIndex>=0)return{consumed:1,key:token.slice(2,equalsIndex).trim(),value:token.slice(equalsIndex+1),attached:!0};if(token.startsWith("--no-"))return{consumed:1,key:token.slice(5).trim(),value:!1};const key=token.slice(2).trim(),next=args[index+1];return typeof next=="string"&&!next.startsWith("-")?{consumed:2,key,value:next}:{consumed:1,key,value:!0}}function isUnsafeLooseOptionKey(key){return UNSAFE_LOOSE_OPTION_KEYS.has(key)}function resolveLooseOptionCoercionKind(definition){const raw=(typeof definition.value_type=="string"?definition.value_type:void 0)??(typeof definition.type=="string"?definition.type:void 0);return resolveFlagValueKind(raw)}function collectLooseOptionKeys(definition){const keys=[],long=resolveExtensionLongFlagName(definition.long)??"",short=typeof definition.short=="string"?definition.short.trim():"";if(long.startsWith("--")){const normalized=toLooseOptionKey(long.slice(2));normalized.length>0&&!isUnsafeLooseOptionKey(normalized)&&keys.push(normalized)}if(short.startsWith("-")&&!short.startsWith("--")){const normalized=toLooseOptionKey(short.slice(1));normalized.length>0&&!isUnsafeLooseOptionKey(normalized)&&keys.push(normalized)}return[...new Set(keys)]}function collectLooseCommandOptionKeysForDefinitions(definitions){const keys=new Set;for(const definition of definitions)for(const key of collectLooseOptionKeys(definition))keys.add(key);return keys}function resolveCanonicalLooseOptionKey(definition){const long=resolveExtensionLongFlagName(definition.long)??"";if(long.startsWith("--")){const normalized=toLooseOptionKey(long.slice(2));if(normalized.length>0&&!isUnsafeLooseOptionKey(normalized))return normalized}return collectLooseOptionKeys(definition)[0]??null}function formatLooseOptionLabel(definition){const long=resolveExtensionLongFlagName(definition.long)??"";if(long.startsWith("--")&&long.length>2)return long;const short=typeof definition.short=="string"?definition.short.trim():"";return short.startsWith("-")&&!short.startsWith("--")&&short.length>1?short:null}function collectRefusalListingLabels(definitions,listing){return[...(listing.definitions??definitions).map(definition=>formatLooseOptionLabel(definition)).filter(label=>label!==null),...listing.inheritedFlags??[]]}function validateLooseCommandOptionsWithFlagDefinitions(options,definitions,commandPath,listing={}){if(definitions.length===0)return;const allowed=new Set,disabled=new Map,required=[],labels=collectRefusalListingLabels(definitions,listing);for(const definition of definitions){const keys=collectLooseOptionKeys(definition),normalizedLabel=formatLooseOptionLabel(definition);for(const key of keys)allowed.add(key),definition.enabled===!1&&disabled.set(key,normalizedLabel);definition.required===!0&&definition.enabled!==!1&&keys.length>0&&required.push({keys,label:normalizedLabel,definition})}for(const key of Object.keys(options)){allowed.has(key)||refuseUnknownExtensionOption(`--${key}`,`--${key}`,commandPath,labels);const disabledLabel=disabled.get(key);disabledLabel&&refuseDisabledExtensionOption(disabledLabel,commandPath)}for(const entry of required){const present=key=>Object.hasOwn(options,key)&&(entry.definition.list!==!0||hasLooseListEntries(entry.definition,options[key]));entry.keys.some(present)||refuseMissingRequiredExtensionOption(entry.definition,entry.keys[0],entry.label,commandPath)}}function refuseUnknownExtensionOption(supplied,flag,commandPath,labels){const expected=labels.length>0?` Expected one of: ${[...new Set(labels)].join(", ")}.`:"";throw new PmCliError(`Unknown option '${supplied}' for extension command '${commandPath}'.${expected}`,EXIT_CODE.USAGE,{code:"unknown_option",flag,required:`Use a flag the command accepts; run pm contracts --command ${commandPath} --flags-only --json to list them.`})}function refuseDisabledExtensionOption(label,commandPath){throw new PmCliError(`Option '${label}' is disabled for extension command '${commandPath}'.`,EXIT_CODE.USAGE,{code:"extension_option_disabled",flag:label,required:`Remove ${label}; the command declares it with enabled: false.`,why:"A disabled declaration keeps the flag in the contract while refusing every value for it.",examples:[`pm ${commandPath} --help`],nextSteps:[`Run pm contracts --command ${commandPath} --flags-only --json to list the flags this command accepts.`]})}function refuseMissingRequiredExtensionOption(definition,handlerKey,label,commandPath){const value=resolveExtensionFlagValueContract(definition),usage=value.value_arity==="none"?label:value.value_arity==="optional"?`${label} [${value.value_name}]`:`${label} <${value.value_name}>`;throw new PmCliError(`Missing required option '${label}' for extension command '${commandPath}'.`,EXIT_CODE.USAGE,{code:"missing_required_option",flag:label,field:handlerKey,required:`Pass ${usage}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${commandPath} ${usage}`],nextSteps:[`Run pm contracts --command ${commandPath} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[label]}})}function coerceLooseStringOptionValue(value){return typeof value=="string"||value==null?value:String(value)}function coerceLooseNumberOptionValue(value){if(typeof value=="number")return value;if(typeof value=="string"&&value.trim().length>0){const parsed=Number(value);return Number.isFinite(parsed)?parsed:value}return value}function coerceLooseBooleanOptionValue(value){if(typeof value=="boolean")return value;if(typeof value=="string"){const normalized=value.trim().toLowerCase();if(normalized==="true"||normalized==="1")return!0;if(normalized==="false"||normalized==="0")return!1}return value}const LOOSE_OPTION_VALUE_COERCERS={string:coerceLooseStringOptionValue,number:coerceLooseNumberOptionValue,boolean:coerceLooseBooleanOptionValue};function coerceLooseOptionValue(value,kind){return Array.isArray(value)?value.map(entry=>coerceLooseOptionValue(entry,kind)):LOOSE_OPTION_VALUE_COERCERS[kind](value)}function normalizeAccumulatedFlagValue(value,kind,preserveOccurrenceCommas){const entries=preserveOccurrenceCommas?(Array.isArray(value)?value.flat(1/0):[value]).filter(entry=>entry!=null&&entry!==""):flattenFlagListValue(value);return kind?entries.map(entry=>coerceLooseOptionValue(entry,kind)):entries}function hasLooseListEntries(definition,value){return normalizeAccumulatedFlagValue(value,null,definition.repeatable===!0).length>0}function applyFlagDefault(defaultValue,kind,isListFlag,preserveOccurrenceCommas){return isListFlag?normalizeAccumulatedFlagValue(defaultValue,kind,preserveOccurrenceCommas):kind?coerceLooseOptionValue(defaultValue,kind):defaultValue}function readOrderedLooseListValues(occurrenceSource,optionKeys,fallback){const matching=readLooseOccurrences(occurrenceSource,optionKeys);return matching.length===0?fallback:matching.map(occurrence=>occurrence.value)}function isBooleanSwitchDefinition(definition){return resolveExtensionFlagValueContract(definition).value_arity==="none"}function refuseStrictScalarValue(definition,kind,entry,expected,commandPath){const label=formatLooseOptionLabel(definition),scope=commandPath?` for extension command '${commandPath}'`:"",received=entry===!0?"no value":JSON.stringify(entry);throw new PmCliError(`Option '${label}'${scope} expects ${expected}; received ${received}.`,EXIT_CODE.USAGE,{code:"extension_flag_value_invalid",flag:label,required:`Pass ${label} ${kind==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${kind} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${kind} value for ${label}.`,`Run pm ${commandPath??"<command>"} --help to review the declared flag contract.`]})}function isStrictTypedDefinition(definition,kind){return definition.value_validation==="strict"&&kind!=="string"}function readLooseOccurrences(occurrenceSource,optionKeys){const occurrences=occurrenceSource[LOOSE_OPTION_OCCURRENCES];if(!occurrences)return[];const acceptedKeys=new Set(optionKeys);return occurrences.filter(occurrence=>acceptedKeys.has(occurrence.key))}function refuseMalformedAttachedSwitchValues(definition,optionKeys,occurrenceSource,commandPath){if(isBooleanSwitchDefinition(definition))for(const occurrence of readLooseOccurrences(occurrenceSource,optionKeys)){if(occurrence.attached!==!0)continue;const values=definition.list===!0&&definition.repeatable!==!0?flattenFlagListValue(occurrence.value):[occurrence.value];for(const value of values){const failure=describeFlagScalarValueFailure(coerceLooseOptionValue(value,"boolean"),"boolean");failure!==null&&refuseStrictScalarValue(definition,"boolean",value,failure.expected,commandPath)}}}function refuseEmptyStrictListEntries(definition,kind,rawValue,preserveOccurrenceCommas,commandPath){const occurrences=Array.isArray(rawValue)?rawValue.flat(1/0):[rawValue],entries=preserveOccurrenceCommas?occurrences:occurrences.flatMap(entry=>typeof entry=="string"?entry.split(","):[entry]);for(const entry of entries)if(typeof entry=="string"&&entry.trim().length===0){const failure=describeFlagScalarValueFailure(entry,kind);refuseStrictScalarValue(definition,kind,entry,failure.expected,commandPath)}}function validateStrictScalarOptionValue(definition,value,kind,commandPath){if(!isStrictTypedDefinition(definition,kind))return value;const isSwitch=kind==="boolean"&&isBooleanSwitchDefinition(definition),normalizeEntry=entry=>{const failure=describeFlagScalarValueFailure(entry,kind);return failure===null?entry:isSwitch&&typeof entry=="string"?!0:refuseStrictScalarValue(definition,kind,entry,failure.expected,commandPath)};return Array.isArray(value)?value.map(normalizeEntry):normalizeEntry(value)}function mergeAliasOptionKeys(coerced,canonical,optionKeys,isListFlag){for(const key of optionKeys)if(!(key===canonical||!Object.hasOwn(coerced,key))){if(Object.hasOwn(coerced,canonical)){if(isListFlag){const canonicalValue=coerced[canonical],aliasValue=coerced[key];coerced[canonical]=[...Array.isArray(canonicalValue)?canonicalValue:[canonicalValue],...Array.isArray(aliasValue)?aliasValue:[aliasValue]].filter(value=>value!=null)}delete coerced[key];continue}coerced[canonical]=coerced[key],delete coerced[key]}}function coerceLooseCommandOptionsWithFlagDefinitions(options,definitions,occurrenceSource=options,commandPath){if(definitions.length===0)return options;const coerced=Object.create(null);for(const[key,value]of Object.entries(options))coerced[key]=value;const canonicalKeys=new Set(definitions.map(definition=>resolveCanonicalLooseOptionKey(definition)).filter(key=>key!==null));for(const definition of definitions){const canonical=resolveCanonicalLooseOptionKey(definition);if(canonical){const optionKeys=collectLooseOptionKeys(definition).filter(key=>key===canonical||!canonicalKeys.has(key));coerceDefinedLooseOption(coerced,definition,canonical,optionKeys,occurrenceSource,commandPath)}}return coerced}function coerceDefinedLooseOption(coerced,definition,canonical,optionKeys,occurrenceSource,commandPath){const isListFlag=definition.list===!0,kind=resolveLooseOptionCoercionKind(definition);kind&&!isListFlag&&refuseMalformedScalarAliasValues(coerced,definition,canonical,optionKeys,kind,commandPath),mergeAliasOptionKeys(coerced,canonical,optionKeys,isListFlag);const preserveOccurrenceCommas=definition.repeatable===!0;if(!Object.hasOwn(coerced,canonical)){definition.default!==void 0&&(coerced[canonical]=applyFlagDefault(definition.default,kind,isListFlag,preserveOccurrenceCommas));return}if(kind==="boolean"&&isStrictTypedDefinition(definition,kind)&&refuseMalformedAttachedSwitchValues(definition,optionKeys,occurrenceSource,commandPath),isListFlag){coerced[canonical]=coerceAccumulatedLooseOption(definition,optionKeys,occurrenceSource,coerced[canonical],kind,preserveOccurrenceCommas,commandPath);return}kind&&(coerced[canonical]=validateStrictScalarOptionValue(definition,coerceLooseOptionValue(coerced[canonical],kind),kind,commandPath))}function refuseMalformedScalarAliasValues(coerced,definition,canonical,optionKeys,kind,commandPath){for(const key of optionKeys)key!==canonical&&Object.hasOwn(coerced,key)&&validateStrictScalarOptionValue(definition,coerceLooseOptionValue(coerced[key],kind),kind,commandPath)}function coerceAccumulatedLooseOption(definition,optionKeys,occurrenceSource,current,kind,preserveOccurrenceCommas,commandPath){const ordered=readOrderedLooseListValues(occurrenceSource,optionKeys,current);kind&&isStrictTypedDefinition(definition,kind)&&refuseEmptyStrictListEntries(definition,kind,ordered,preserveOccurrenceCommas,commandPath);const normalized=normalizeAccumulatedFlagValue(ordered,kind,preserveOccurrenceCommas);return kind?validateStrictScalarOptionValue(definition,normalized,kind,commandPath):normalized}function parseLooseCommandOptions(args){const options=Object.create(null),occurrences=[];Object.defineProperty(options,LOOSE_OPTION_OCCURRENCES,{value:occurrences});let index=0;for(;index<args.length;){const parsed=parseLooseOptionToken(args,index);if(!parsed){index+=1;continue}const normalizedKey=toLooseOptionKey(parsed.key);if(normalizedKey.length===0||isUnsafeLooseOptionKey(normalizedKey)){index+=parsed.consumed;continue}setLooseOptionValue(options,normalizedKey,parsed.value),occurrences.push({...parsed,key:normalizedKey}),index+=parsed.consumed}return options}function collectLoosePositionalArgs(args){const positionals=[];let index=0;for(;index<args.length;){if(args[index]==="--"){positionals.push(...args.slice(index+1));break}const parsed=parseLooseOptionToken(args,index);if(parsed){index+=Math.max(1,parsed.consumed);continue}positionals.push(args[index]),index+=1}return positionals}function stripLooseCommandOptionTokens(args,definitions){if(definitions.length===0)return[...args];const knownKeys=new Set,booleanKeys=new Set;for(const definition of definitions){const valueKind=resolveLooseOptionCoercionKind(definition);for(const key of collectLooseOptionKeys(definition))knownKeys.add(key),valueKind==="boolean"&&booleanKeys.add(key)}if(knownKeys.size===0)return[...args];const stripped=[];let index=0;for(;index<args.length;){if(args[index]==="--"){stripped.push(...args.slice(index+1));break}const parsed=parseLooseOptionToken(args,index);if(parsed){const normalizedKey=toLooseOptionKey(parsed.key);if(knownKeys.has(normalizedKey)){const token=args[index],consumed=booleanKeys.has(normalizedKey)&&!token.includes("=")?1:parsed.consumed;index+=consumed;continue}}stripped.push(args[index]),index+=1}return stripped}function resolveExtensionFlagOptionKey(definition){return resolveCanonicalLooseOptionKey(definition)}function normalizeFlagTargetCommandPath(commandPath){return commandPath.trim().toLowerCase().split(/\s+/u).filter(part=>part.length>0).join(" ")}function collectExtensionFlagDefinitionsForCommand(registrations,commandPath){const normalizedCommandPath=normalizeFlagTargetCommandPath(commandPath);if(normalizedCommandPath.length===0)return[];const operation=resolvePmCommandOperation(normalizedCommandPath);return registrations.flags.filter(entry=>resolvePmCommandOperation(normalizeFlagTargetCommandPath(entry.target_command))===operation).flatMap(entry=>[...entry.flags])}function refuseConflictingOptionSpellings(definition,handlerKey,spellings,commandPath){const label=formatLooseOptionLabel(definition),[first,second]=spellings;throw new PmCliError(`Options '${first}' and '${second}' both set ${label} for extension command '${commandPath}' with different values.`,EXIT_CODE.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${label} once, under the handler key '${handlerKey}'.`,why:`'${first}' and '${second}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${first}' or '${second}' and pass one value as '${handlerKey}'.`,`Run pm contracts --command ${commandPath} --flags-only --json to read each flag's sdk_option key.`]})}function normalizeDirectExtensionCommandOptions(options,declaredDefinitions,commandPath,policy={}){if(declaredDefinitions.length===0)return options;const definitions=declaredDefinitions.map(definition=>definition.repeatable===!0&&definition.list!==!0?{...definition,list:!0}:definition),index=indexDeclaredOptionSpellings(definitions),folded=foldDirectOptionSpellings(options,index,commandPath),handlerKeys=new Set([...index.long.values()].map(({handlerKey})=>handlerKey)),declared=Object.create(null),passthrough=Object.create(null);for(const[key,value]of Object.entries(folded))handlerKeys.has(key)?declared[key]=value:value===void 0||policy.undeclaredKeys==="pass"||isDirectHostOptionKey(key)?passthrough[key]=value:refuseUnknownExtensionOption(key,toDashedOptionFlag(key),commandPath,collectRefusalListingLabels(definitions,{}));return refuseDirectDeclarationViolations(declared,definitions,commandPath),Object.assign(passthrough,coerceLooseCommandOptionsWithFlagDefinitions(declared,definitions,recordDirectOptionOccurrences(declared,index),commandPath))}function recordDirectOptionOccurrences(folded,index){const handlerKeys=new Set([...index.long.values()].map(({handlerKey})=>handlerKey)),occurrences=Object.entries(folded).filter(([key])=>handlerKeys.has(key)).flatMap(([key,value])=>(Array.isArray(value)?value.flat(1/0):[value]).map(entry=>({consumed:1,key,value:entry,attached:!0}))),occurrenceSource=Object.create(null);return Object.defineProperty(occurrenceSource,LOOSE_OPTION_OCCURRENCES,{value:occurrences}),occurrenceSource}function refuseDirectDeclarationViolations(declared,definitions,commandPath){for(const definition of definitions){const handlerKey=resolveCanonicalLooseOptionKey(definition);if(handlerKey===null)continue;const label=formatLooseOptionLabel(definition),value=declared[handlerKey],supplied=Object.hasOwn(declared,handlerKey);definition.enabled===!1&&supplied&&refuseDisabledExtensionOption(label,commandPath);const present=supplied&&(definition.list!==!0||hasLooseListEntries(definition,value));definition.required===!0&&definition.enabled!==!1&&!present&&refuseMissingRequiredExtensionOption(definition,handlerKey,label,commandPath),definition.list!==!0&&Array.isArray(value)&&refuseDirectArrayForSingleValueFlag(label,commandPath)}}function refuseDirectArrayForSingleValueFlag(label,commandPath){throw new PmCliError(`Option '${label}' for extension command '${commandPath}' takes one value; received an array.`,EXIT_CODE.USAGE,{code:"extension_flag_value_invalid",flag:label,required:`Pass one value for ${label}, or ask the package to declare it with list: true or repeatable: true.`,why:"The flag is not declared list or repeatable, so pm refuses an array before the extension handler runs instead of handing it a value of the wrong shape.",nextSteps:[`Run pm contracts --command ${commandPath} --flags-only --json to read each flag's value contract.`]})}const DIRECT_HOST_OPTION_KEYS=new Set([...[...RESERVED_EXTENSION_HOST_FLAG_NAMES].flatMap(flag=>{const body=flag.replace(/^--/u,"");return[body,...body.startsWith("no-")?[body.slice(3)]:[]].flatMap(spelling=>[toLooseOptionKey(spelling),spelling.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function isDirectHostOptionKey(key){return DIRECT_HOST_OPTION_KEYS.has(key)||DIRECT_HOST_OPTION_KEYS.has(toLooseOptionKey(key.replace(/^-{1,2}/u,"")))}function toDashedOptionFlag(key){return`--${key.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function indexDeclaredOptionSpellings(definitions){const index={long:new Map,short:new Map},claim=(map,spelling,entry)=>{spelling.length>0&&!map.has(spelling)&&map.set(spelling,entry)};for(const definition of definitions){const handlerKey=resolveCanonicalLooseOptionKey(definition);if(handlerKey===null)continue;const entry={handlerKey,definition};claim(index.long,handlerKey,entry);const short=typeof definition.short=="string"?definition.short.trim():"";short.startsWith("-")&&!short.startsWith("--")&&claim(index.short,short.slice(1),entry)}return index}function resolveDeclaredOptionSpelling(index,spelling){return index.long.get(spelling)??index.short.get(spelling.replace(/^-(?!-)/u,""))??index.long.get(toLooseOptionKey(spelling.replace(/^-{1,2}/u,"")))}function resolveNegatedBooleanSpelling(index,spelling,value,commandPath){const negated=/^(?:--)?no-(.+)$/u.exec(spelling)?.[1];if(negated===void 0||resolveDeclaredOptionSpelling(index,spelling)!==void 0)return{spelling,value};const declared=resolveDeclaredOptionSpelling(index,negated);return declared===void 0||resolveLooseOptionCoercionKind(declared.definition)!=="boolean"?{spelling,value}:(declared.definition.list===!0||declared.definition.repeatable===!0)&&Array.isArray(value)?{spelling:negated,value:value.flat(1/0).map(entry=>invertNegatedListEntry(spelling,declared.definition,entry,commandPath))}:declared.definition.list===!0&&value!==void 0?{spelling:negated,value:invertNegatedListEntry(spelling,declared.definition,value,commandPath)}:{spelling:negated,value:value===void 0?value:invertNegatedBooleanEntry(spelling,declared.definition,value,commandPath)}}function invertNegatedListEntry(spelling,definition,entry,commandPath){const invertToken=token=>token.trim().length===0?token:String(invertNegatedBooleanEntry(spelling,definition,token.trim(),commandPath));return entry==null?entry:typeof entry!="string"?invertNegatedBooleanEntry(spelling,definition,entry,commandPath):entry.trim().length===0?entry:definition.repeatable===!0||!entry.includes(",")?invertNegatedBooleanEntry(spelling,definition,entry,commandPath):entry.split(",").map(invertToken).join(",")}function invertNegatedBooleanEntry(spelling,definition,value,commandPath){const flag=coerceLooseBooleanOptionValue(value);return typeof flag=="boolean"?!flag:refuseNegatedBooleanValue(spelling,definition,value,commandPath)}function refuseNegatedBooleanValue(spelling,definition,value,commandPath){const label=formatLooseOptionLabel(definition);throw new PmCliError(`Option '${spelling}' for extension command '${commandPath}' negates ${label} and expects true, false, 1, or 0; received ${JSON.stringify(value)}.`,EXIT_CODE.USAGE,{code:"extension_flag_value_invalid",flag:label,required:`Pass ${label} as true or false, or '${spelling}' as true.`,why:`'${spelling}' is the negated spelling of the boolean ${label}, so only a boolean value can be inverted before the extension handler runs.`,nextSteps:[`Run pm contracts --command ${commandPath} --flags-only --json to read each flag's value contract.`]})}function foldDirectOptionSpellings(options,index,commandPath){const folded=Object.create(null),suppliedBy=new Map;for(const[rawSpelling,rawValue]of Object.entries(options)){const{spelling,value}=resolveNegatedBooleanSpelling(index,rawSpelling,rawValue,commandPath),declared=resolveDeclaredOptionSpelling(index,spelling);if(declared===void 0)folded[spelling]=value;else if(value!==void 0){const prior=suppliedBy.get(declared.handlerKey);prior===void 0?(suppliedBy.set(declared.handlerKey,spelling),folded[declared.handlerKey]=value):isDeepStrictEqual(deliverDirectOptionValue(declared.definition,declared.handlerKey,folded[declared.handlerKey],index,commandPath),deliverDirectOptionValue(declared.definition,declared.handlerKey,value,index,commandPath))||refuseConflictingOptionSpellings(declared.definition,declared.handlerKey,[prior,spelling],commandPath)}}return folded}function deliverDirectOptionValue(definition,handlerKey,value,index,commandPath){const single={[handlerKey]:value};return refuseDirectDeclarationViolations(single,[definition],commandPath),coerceLooseCommandOptionsWithFlagDefinitions(single,[definition],recordDirectOptionOccurrences(single,index),commandPath)[handlerKey]}function indexDeclaredArgvSpellings(definitions){const index=new Map;for(const definition of definitions){const handlerKey=resolveCanonicalLooseOptionKey(definition);if(handlerKey===null)continue;const entry={definition,handlerKey,kind:resolveLooseOptionCoercionKind(definition),arity:resolveExtensionFlagValueContract(definition).value_arity,scalar:definition.list!==!0},spellings=[resolveExtensionLongFlagName(definition.long),typeof definition.short=="string"?definition.short.trim():""];for(const spelling of spellings.filter(candidate=>candidate?.startsWith("-")===!0))index.has(spelling)||index.set(spelling,entry)}return index}function resolveArgvSpelling(scope,index,spelling){const registered=scope.optionOf(spelling),declared=index.get(spelling),settable=declared?.scalar===!0?declared:void 0;if(registered!==void 0){const base={arity:registered.arity,...registered.variadic===!0?{variadic:!0}:{}};if(settable?.handlerKey===registered.key)return{...base,declared:settable};const positive=declared===void 0&&spelling.startsWith("--no-")?index.get(`--${spelling.slice(5)}`):void 0;return positive?.scalar===!0&&positive.kind==="boolean"&&positive.handlerKey===registered.key?{...base,declared:positive,negates:!0}:base}if(!(!scope.includesLooseFlags||declared===void 0))return settable===void 0?{arity:declared.arity,loose:!0}:{arity:declared.arity,declared:settable,loose:!0}}function isArgvOptionToken(token){return token.length>1&&token.startsWith("-")}const NEGATIVE_NUMBER_ARGV_TOKEN=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function scanArgvScope(scope,resolve,record){const{tokens}=scope;let position=0,group,unrecognizedSeen=!1,variadic=!1;for(;position<tokens.length||group!==void 0;){const token=group??tokens[position++];if(token==="--")return;if(variadic&&group===void 0&&isArgvVariadicValue(scope,token))continue;const step=isArgvOptionToken(token)?scanArgvOptionToken(scope,token,tokens[position],resolve,record):{consumedByCommander:!1,consumed:0};if(position+=step.consumed,group=step.group,variadic=step.variadic===!0,!step.consumedByCommander){if(stopsArgvScope(scope.stop,token,unrecognizedSeen))return;unrecognizedSeen=!0}}}function isArgvVariadicValue(scope,token){return!isArgvOptionToken(token)||scope.negativeNumbersAreValues&&NEGATIVE_NUMBER_ARGV_TOKEN.test(token)}function stopsArgvScope(stop,token,unrecognizedSeen){return stop!==void 0&&(stop.atFirstUnrecognized||!unrecognizedSeen&&stop.atSubcommand(token))}function scanArgvOptionToken(scope,token,next,resolve,record){const loose=readLooseArgvOccurrence(token,next,resolve);if(loose!==void 0)return record(loose.spelling,loose.entry,loose.value),{consumedByCommander:!1,consumed:loose.consumed};const exact=resolve(token);if(exact!==void 0){const takesNext=exact.arity==="required"||exact.arity==="optional"&&next!==void 0&&(!isArgvOptionToken(next)||scope.negativeNumbersAreValues&&NEGATIVE_NUMBER_ARGV_TOKEN.test(next));return record(token,exact,exact.negates===!0?!1:takesNext?next:!0),{consumedByCommander:!0,consumed:takesNext?1:0,variadic:exact.variadic===!0}}return token[1]!=="-"?{consumed:0,...scanShortGroup(token,resolve,record)}:{consumedByCommander:scanLongToken(token,resolve,record,scope.includesLooseFlags?record:()=>{}),consumed:0}}function readLooseArgvOccurrence(token,next,resolve){const equals=token.indexOf("="),spelling=equals>1?token.slice(0,equals):token,entry=resolve(spelling);if(entry?.loose===!0)return equals>1?{spelling,entry,value:token.slice(equals+1),consumed:0}:next!==void 0&&!next.startsWith("-")?{spelling,entry,value:next,consumed:1}:{spelling,entry,value:!0,consumed:0};const negated=equals<0&&token.startsWith("--no-")?resolve(`--${token.slice(5)}`):void 0;return negated?.loose===!0&&negated.declared?.kind==="boolean"?{spelling:token,entry:negated,value:!1,consumed:0}:void 0}function scanShortGroup(token,resolve,record){const spelling=token.slice(0,2),entry=token.length>2?resolve(spelling):void 0;return entry===void 0||entry.loose===!0?{consumedByCommander:!1}:entry.arity!=="none"?(record(spelling,entry,token.slice(2)),{consumedByCommander:!0}):(record(spelling,entry,!0),{consumedByCommander:!0,group:`-${token.slice(2)}`})}function scanLongToken(token,resolve,record,recordUnparsed){const equals=token.indexOf("=");if(equals>2){const spelling=token.slice(0,equals),entry=resolve(spelling);return entry!==void 0&&entry.arity!=="none"?(record(spelling,entry,token.slice(equals+1)),!0):(entry?.declared?.kind==="boolean"&&recordUnparsed(spelling,entry,token.slice(equals+1)),!1)}const negated=token.startsWith("--no-")?resolve(`--${token.slice(5)}`):void 0;return negated?.declared?.kind==="boolean"&&recordUnparsed(token,negated,!1),!1}function refuseConflictingArgvOptionSpellings(scopes,definitions,commandPath){const index=indexDeclaredArgvSpellings(definitions),latest=new Map;for(const scope of scopes)scanArgvScope(scope,spelling=>resolveArgvSpelling(scope,index,spelling),(spelling,entry,value)=>{entry.declared!==void 0&&recordArgvSpellingValue(latest,entry.declared,spelling,value,commandPath)})}function recordArgvSpellingValue(latest,declared,spelling,value,commandPath){const{definition,handlerKey,kind}=declared,coerced=kind?coerceLooseOptionValue(value,kind):value,spellings=latest.get(handlerKey)??new Map,conflicting=[...spellings].find(([other,otherValue])=>other!==spelling&&!isDeepStrictEqual(otherValue,coerced));conflicting!==void 0&&refuseConflictingOptionSpellings(definition,handlerKey,[conflicting[0],spelling],commandPath),spellings.set(spelling,coerced),latest.set(handlerKey,spellings)}export{coerceLooseCommandOptionsWithFlagDefinitions,collectExtensionFlagDefinitionsForCommand,collectLooseCommandOptionKeysForDefinitions,collectLoosePositionalArgs,normalizeDirectExtensionCommandOptions,parseLooseCommandOptions,refuseConflictingArgvOptionSpellings,resolveExtensionFlagOptionKey,stripLooseCommandOptionTokens,validateLooseCommandOptionsWithFlagDefinitions};
|
|
2
2
|
//# sourceMappingURL=command-options.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1956081d-53b1-5f2c-887a-6aac3325b764")}catch{}})();import{isCoreCommandPath}from"../cli-contracts/runtime-contracts.js";function resolveDirectExtensionOptionPolicy(commandPath){return{undeclaredKeys:isCoreCommandPath(commandPath)?"pass":"refuse"}}export{resolveDirectExtensionOptionPolicy};
|
|
2
|
+
//# sourceMappingURL=native-command-options.js.map
|
package/dist/sdk/files.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type{GlobalOptions}from "../core/shared/command-types.js";import type{ItemDocument,LinkedFile,LinkScope}from "../types/index.js";import{type LinkedCollectionMutationReceipt,type LinkedPathValidation}from "./linked-artifacts.js";import type{AnnotationOmissionReceipt}from "./annotations.js";import{type SourceLineRange,type SourceTraceabilityExplanation,type SourceTraceabilityReceipt}from "./traceability/source-traceability.js";
|
|
1
|
+
import type{GlobalOptions}from "../core/shared/command-types.js";import type{ItemDocument,LinkedFile,LinkScope}from "../types/index.js";import{type LinkedCollectionMutationReceipt,type LinkedPathValidation}from "./linked-artifacts.js";import type{AnnotationOmissionReceipt}from "./annotations.js";import type{LinkedArtifactNoteConflictMode}from "./linked-artifacts.js";import{type SourceLineRange,type SourceTraceabilityExplanation,type SourceTraceabilityReceipt}from "./traceability/source-traceability.js";
|
|
2
2
|
/** Documents the files command options payload exchanged by command, SDK, and package integrations. */
|
|
3
3
|
export interface FilesCommandOptions{
|
|
4
4
|
/** Value that configures or reports add for this contract. */
|
|
@@ -11,6 +11,8 @@ remove?:string[];
|
|
|
11
11
|
migrate?:string[];
|
|
12
12
|
/** GH-170 (pm-pfnx): standalone note applied to every --add/--add-glob link in this invocation. */
|
|
13
13
|
note?:string;
|
|
14
|
+
/** How an add treats a stored link with a different note: refuse (default), replace or append (GH-1716). */
|
|
15
|
+
noteConflict?:LinkedArtifactNoteConflictMode|(string&{});
|
|
14
16
|
/** Value that configures or reports list for this contract. */
|
|
15
17
|
list?:boolean;
|
|
16
18
|
/** Value that configures or reports append stable for this contract. */
|
package/dist/sdk/files.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b78d1abc-716f-51a6-a6c2-ab8382eb12e4")}catch{}})();import{assertInitializedTracker}from"./environment/tracker-preflight.js";import fs from"node:fs/promises";import path from"node:path";import{getActiveExtensionRegistrations,hasActiveOnReadHooks}from"../core/extensions/index.js";import{resolveItemTypeRegistry}from"../core/item/type-registry.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{locateItem,listAllItemMetadata,mutateItem,readLocatedItem}from"../core/store/item-store.js";import{readItemMetadataDerivedIndexState}from"../core/store/item-metadata-cache.js";import{queryLinkedFileMetadataIndex}from"../core/store/item-metadata-query-index.js";import{resolvePmRoot,resolveWorkspaceRoot}from"../core/store/paths.js";import{readSettings}from"../core/store/settings.js";import{resolveAuthor}from"../core/shared/author.js";import{isPathWithinDirectory}from"../core/fs/path-utils.js";import{dedupeLinkedArtifacts,normalizeLinkedPath,renameArtifactsResultKey,runLinkedArtifacts,sortLinkedArtifacts}from"./linked-artifacts.js";import{explainSourceTraceability}from"./traceability/source-traceability.js";const RELATIVE_REFERENCE_SCAN_MAX_CHARS=32768;function normalizeCandidatePathForOutput(value){return normalizeLinkedPath(path.normalize(value))}async function realpathForContainment(inputPath){try{return await fs.realpath(inputPath)}catch{return path.resolve(inputPath)}}function linkedFileResolvedKey(linkedFile,projectRoot){const resolvedPath=path.isAbsolute(linkedFile.path)?path.resolve(linkedFile.path):path.resolve(projectRoot,linkedFile.path);return`${normalizeCandidatePathForOutput(resolvedPath)}::${linkedFile.scope}`}function collectTextReferences(value,fieldPath,references){if(typeof value=="string"){const trimmed=value.trim();trimmed.length>0&&references.push({field:fieldPath,value:trimmed});return}if(Array.isArray(value)){value.forEach((entry,index)=>collectTextReferences(entry,`${fieldPath}[${index}]`,references));return}if(typeof value=="object"&&value!==null)for(const[key,nested]of Object.entries(value))collectTextReferences(nested,fieldPath?`${fieldPath}.${key}`:key,references)}function collectItemTextReferences(document){const references=[];return collectTextReferences(document.metadata,"metadata",references),collectTextReferences(document.body,"body",references),references}function cleanupPathToken(value){let next=value.trim();return next=next.replace(/^[`"'<([{]+/u,""),next=next.replace(/[`"'>)\]},;!?]+$/u,""),next=next.replace(/[.]+$/u,""),next=next.replace(/:(?:\d+)(?::\d+)?$/u,""),next=next.replace(/[.]+$/u,""),next}function extractRawPathReferences(references){const rawReferences=[],absolutePattern=/(?:[A-Za-z]:[\\/]|\/)[^\s"'`<>()[\]{},;]+/gu,relativePattern=/(?:\.{1,2}[\\/])?(?:(?:[A-Za-z0-9_.@-]+[\\/])+[A-Za-z0-9_.@-]+|[A-Za-z0-9_.@-]+\.[A-Za-z0-9][A-Za-z0-9._-]*)/gu;for(const reference of references){const seenInField=new Set,boundedRelativeValue=reference.value.slice(0,RELATIVE_REFERENCE_SCAN_MAX_CHARS);for(const[pattern,input]of[[absolutePattern,reference.value],[relativePattern,boundedRelativeValue]]){pattern.lastIndex=0;for(const match of input.matchAll(pattern)){const token=cleanupPathToken(match[0]);!token||seenInField.has(token)||(seenInField.add(token),rawReferences.push({field:reference.field,value:token}))}}}return rawReferences}async function resolveDiscoveredFile(rawPath,workspaceRoot,invocationRoot=workspaceRoot){const absolutePath=path.isAbsolute(rawPath)?path.resolve(rawPath):path.resolve(invocationRoot,rawPath);let stats;try{stats=await fs.stat(absolutePath)}catch{return}if(!stats.isFile())return;const[canonicalProjectRoot,canonicalAbsolutePath]=await Promise.all([realpathForContainment(workspaceRoot),realpathForContainment(absolutePath)]);if(isPathWithinDirectory(canonicalProjectRoot,canonicalAbsolutePath)){const relativePath=path.relative(canonicalProjectRoot,canonicalAbsolutePath);return!relativePath||relativePath.startsWith("..")||path.isAbsolute(relativePath)?void 0:{path:normalizeCandidatePathForOutput(relativePath),scope:"project"}}return{path:normalizeCandidatePathForOutput(absolutePath),scope:"global"}}async function discoverReferencedFiles(document,workspaceRoot,invocationRoot=workspaceRoot){const existingResolvedKeys=new Set((document.metadata.files??[]).map(entry=>linkedFileResolvedKey(entry,workspaceRoot))),grouped=new Map,rawReferences=extractRawPathReferences(collectItemTextReferences(document)),resolvedByValue=new Map;await Promise.all([...new Set(rawReferences.map(reference=>reference.value))].map(async value=>{resolvedByValue.set(value,await resolveDiscoveredFile(value,workspaceRoot,invocationRoot))}));const resolvedReferences=rawReferences.map(reference=>({reference,resolved:resolvedByValue.get(reference.value)}));for(const{reference,resolved}of resolvedReferences){if(!resolved)continue;const key=linkedFileResolvedKey(resolved,workspaceRoot),existing=grouped.get(key)??{path:resolved.path,scope:resolved.scope,sourceFields:new Set,originalPaths:new Set,sourceCount:0};existing.sourceFields.add(reference.field),existing.originalPaths.add(reference.value),existing.sourceCount+=1,grouped.set(key,existing)}return[...grouped.entries()].map(([key,entry])=>({path:entry.path,scope:entry.scope,status:existingResolvedKeys.has(key)?"already_linked":"addable",source_count:entry.sourceCount,source_fields:[...entry.sourceFields].sort((left,right)=>left.localeCompare(right)),original_paths:[...entry.originalPaths].sort((left,right)=>left.localeCompare(right))})).sort((left,right)=>{const byStatus=left.status.localeCompare(right.status);if(byStatus!==0)return byStatus;const byPath=left.path.localeCompare(right.path);return byPath!==0?byPath:left.scope.localeCompare(right.scope)})}const _testOnly={relativeReferenceScanMaxChars:RELATIVE_REFERENCE_SCAN_MAX_CHARS,normalizeCandidatePathForOutput,realpathForContainment,linkedFileResolvedKey,collectTextReferences,collectItemTextReferences,cleanupPathToken,extractRawPathReferences,resolveDiscoveredFile,discoverReferencedFiles};async function runFiles(id,options,global2){const result=await runLinkedArtifacts(id,options,global2,{metadataKey:"files",op:"files_add",bareNoun:"file",supportsAppendStable:!0});return renameArtifactsResultKey(result,"files")}async function normalizeFilesLookupPaths(values,workspaceRoot){const canonicalWorkspaceRoot=await realpathForContainment(workspaceRoot),paths=await Promise.all(values.map(async value=>{const trimmed=value.trim();if(!trimmed)throw new PmCliError("Files lookup paths must not be empty.",EXIT_CODE.USAGE);if(!path.isAbsolute(trimmed))return normalizeLinkedPath(trimmed);const canonicalAbsolutePath=await realpathForContainment(trimmed);return isPathWithinDirectory(canonicalWorkspaceRoot,canonicalAbsolutePath)?normalizeLinkedPath(path.relative(canonicalWorkspaceRoot,canonicalAbsolutePath)):normalizeLinkedPath(canonicalAbsolutePath)})),uniquePaths=[...new Set(paths)].sort((left,right)=>left.localeCompare(right));if(uniquePaths.length===0)throw new PmCliError("Files lookup requires at least one path.",EXIT_CODE.USAGE);return uniquePaths}function resolveFilesLookupWindow(options){for(const[label,value]of[["limit",options.limit],["offset",options.offset]])if(value!==void 0&&(!Number.isInteger(value)||value<0))throw new PmCliError(`Files lookup ${label} must be a non-negative integer.`,EXIT_CODE.USAGE);const{offset=0,limit=50}=options;return{offset:Math.max(0,Math.floor(offset)),limit:options.noTruncate?void 0:Math.max(0,Math.floor(limit))}}function projectFilesLookupItem(item){return{id:item.id,title:item.title,type:item.type,status:item.status,priority:item.priority,updated_at:item.updated_at}}function compareFilesLookupCandidates(left,right){const byPriority=left.item.priority-right.item.priority;if(byPriority!==0)return byPriority;const byUpdated=right.item.updated_at.localeCompare(left.item.updated_at);return byUpdated===0?left.item.id.localeCompare(right.item.id):byUpdated}function matchingFilesLookupCandidates(params){return params.metadata.map(item=>({item,files:(item.files??[]).filter(file=>params.paths.includes(normalizeLinkedPath(file.path))&&(params.scope===void 0||file.scope===params.scope)).sort((left,right)=>{const byPath=left.path.localeCompare(right.path);return byPath===0?left.scope.localeCompare(right.scope):byPath})})).filter(match=>match.files.length>0).sort(compareFilesLookupCandidates)}async function resolveFilesLookupTraceability(params){if(params.explain)return explainSourceTraceability({workspaceRoot:params.workspaceRoot,paths:params.paths,candidates:params.matching,corpus:params.metadata,...params.lineRange?{lineRange:params.lineRange}:{},...params.decisionDepth===void 0?{}:{decisionDepth:params.decisionDepth}})}async function queryFilesLookupIndex(params){if([params.strictRead,params.noTruncate,params.explain,hasActiveOnReadHooks()].includes(!0))return null;const indexState=await readItemMetadataDerivedIndexState(params.pmRoot,[...new Set(Object.values(params.typeToFolder))]);return indexState?queryLinkedFileMetadataIndex({pmRoot:params.pmRoot,expectedSourceCursor:indexState.source_cursor,paths:params.paths,scope:params.scope,limit:params.limit,offset:params.offset}):null}async function queryFilesLookupSource(params){const warnings=[],metadata=await listAllItemMetadata(params.pmRoot,params.settings.item_format,params.typeToFolder,warnings,params.settings.schema),matching=matchingFilesLookupCandidates({metadata,paths:params.paths,scope:params.scope}),readWarnings=warnings.filter(warning=>/^item_list_(?:item|directory)_read_failed:/u.test(warning));if(params.strictRead&&readWarnings.length>0)throw new PmCliError(`Files lookup could not read every item: ${readWarnings.join("; ")}`,EXIT_CODE.GENERIC_FAILURE);const traceability=await resolveFilesLookupTraceability({explain:params.explain,workspaceRoot:params.workspaceRoot,paths:params.paths,matching,metadata,lineRange:params.lineRange,decisionDepth:params.decisionDepth}),page=(traceability?[...matching].sort((left,right)=>{const byScore=traceability.explanations.get(right.item.id).score-traceability.explanations.get(left.item.id).score;return byScore!==0?byScore:compareFilesLookupCandidates(left,right)}):matching).slice(params.offset,params.limit===void 0?void 0:params.offset+params.limit);return{paths:params.paths,total:matching.length,count:page.length,offset:params.offset,limit:params.limit??null,has_more:params.offset+page.length<matching.length,truncated:params.offset+page.length<matching.length,completeness:{status:readWarnings.length===0?"complete":"partial",source:"source_scan"},warnings,matches:page.map(match=>({item:projectFilesLookupItem(match.item),files:match.files,...traceability?{traceability:traceability.explanations.get(match.item.id)}:{}})),...traceability?{traceability_receipt:traceability.receipt}:{}}}async function runFilesLookup(options,global2){const pmRoot=resolvePmRoot(process.cwd(),global2.path),workspaceRoot=resolveWorkspaceRoot(pmRoot);await assertInitializedTracker(pmRoot);const paths=await normalizeFilesLookupPaths(options.paths,workspaceRoot);if(options.lineRange&&paths.length!==1)throw new PmCliError("Files lookup line attribution requires exactly one source path.",EXIT_CODE.USAGE);const settings=await readSettings(pmRoot),typeRegistry=resolveItemTypeRegistry(settings,getActiveExtensionRegistrations()),{offset,limit}=resolveFilesLookupWindow(options),indexed=await queryFilesLookupIndex({pmRoot,typeToFolder:typeRegistry.type_to_folder,paths,scope:options.scope,limit,offset,strictRead:options.strictRead===!0,noTruncate:options.noTruncate===!0,explain:options.explain===!0||options.lineRange!==void 0});return indexed?{paths,total:indexed.total,count:indexed.matches.length,offset,limit,has_more:offset+indexed.matches.length<indexed.total,truncated:offset+indexed.matches.length<indexed.total,completeness:{status:"unchecked",source:"index"},warnings:[],matches:indexed.matches.map(match=>({item:projectFilesLookupItem(match.item),files:match.files}))}:queryFilesLookupSource({pmRoot,settings,typeToFolder:typeRegistry.type_to_folder,paths,scope:options.scope,limit,offset,strictRead:options.strictRead===!0,workspaceRoot,explain:options.explain===!0||options.lineRange!==void 0,lineRange:options.lineRange,decisionDepth:options.decisionDepth})}async function runFilesDiscover(id,options,global2){const pmRoot=resolvePmRoot(process.cwd(),global2.path),workspaceRoot=resolveWorkspaceRoot(pmRoot);await assertInitializedTracker(pmRoot);const settings=await readSettings(pmRoot),typeRegistry=resolveItemTypeRegistry(settings,getActiveExtensionRegistrations()),located=await locateItem(pmRoot,id,settings.id_prefix,settings.item_format,typeRegistry.type_to_folder);if(!located)throw new PmCliError(`Item ${id} not found`,EXIT_CODE.NOT_FOUND);const loaded=await readLocatedItem(located,{schema:settings.schema}),candidates=await discoverReferencedFiles(loaded.document,workspaceRoot,process.cwd()),addableCandidates=candidates.filter(candidate=>candidate.status==="addable"),skippedExisting=candidates.filter(candidate=>candidate.status==="already_linked"),requestedApply=options.apply===!0,note=options.note?.trim()||"discovered from item text";if(!requestedApply||addableCandidates.length===0){const files2=loaded.document.metadata.files??[];return{id:located.id,files:files2,changed:!1,apply:requestedApply,count:files2.length,candidate_count:candidates.length,addable_count:addableCandidates.length,added_count:0,skipped_existing_count:skippedExisting.length,candidates,added:[],skipped_existing:skippedExisting}}const author=resolveAuthor(options.author,settings.author_default),discoveredAdds=addableCandidates.map(candidate=>({path:candidate.path,scope:candidate.scope,note}));let appliedAdds=[];const appliedCandidateIndices=new Set,result=await mutateItem({pmRoot,settings,id,op:"files_discover",author,message:options.message??"Discover referenced file links",force:options.force,mutate(document){const next=[...document.metadata.files??[]],existingResolvedKeys=new Set(next.map(entry=>linkedFileResolvedKey(entry,workspaceRoot)));appliedAdds=[],appliedCandidateIndices.clear();for(const[index,add]of discoveredAdds.entries()){const resolvedKey=linkedFileResolvedKey(add,workspaceRoot);existingResolvedKeys.has(resolvedKey)||(next.push(add),existingResolvedKeys.add(resolvedKey),appliedAdds.push(add),appliedCandidateIndices.add(index))}const deduped=dedupeLinkedArtifacts(next),normalized=options.appendStable?deduped:sortLinkedArtifacts(deduped);return normalized.length>0?document.metadata.files=normalized:delete document.metadata.files,{changedFields:appliedAdds.length>0?["files"]:[],warnings:appliedAdds.length!==discoveredAdds.length?[`files_discover_skipped_existing:${discoveredAdds.length-appliedAdds.length}`]:[]}}}),files=result.item.files??[],addedResolvedKeys=new Set(appliedAdds.map(entry=>linkedFileResolvedKey(entry,workspaceRoot))),added=files.filter(entry=>addedResolvedKeys.has(linkedFileResolvedKey(entry,workspaceRoot))),skippedDuringApply=addableCandidates.filter((_candidate,index)=>!appliedCandidateIndices.has(index)),allSkippedExisting=[...skippedExisting,...skippedDuringApply];return{id:result.item.id,files,changed:added.length>0,apply:!0,count:files.length,candidate_count:candidates.length,addable_count:addableCandidates.length,added_count:added.length,skipped_existing_count:allSkippedExisting.length,candidates,added,skipped_existing:allSkippedExisting}}export{_testOnly,runFiles,runFilesDiscover,runFilesLookup};
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ad4d4093-7e23-5361-bec4-efb37bd610b6")}catch{}})();import{assertInitializedTracker}from"./environment/tracker-preflight.js";import fs from"node:fs/promises";import path from"node:path";import{getActiveExtensionRegistrations,hasActiveOnReadHooks}from"../core/extensions/index.js";import{resolveItemTypeRegistry}from"../core/item/type-registry.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{locateItem,listAllItemMetadata,mutateItem,readLocatedItem}from"../core/store/item-store.js";import{readItemMetadataDerivedIndexState}from"../core/store/item-metadata-cache.js";import{queryLinkedFileMetadataIndex}from"../core/store/item-metadata-query-index.js";import{resolvePmRoot,resolveWorkspaceRoot}from"../core/store/paths.js";import{readSettings}from"../core/store/settings.js";import{resolveAuthor}from"../core/shared/author.js";import{isPathWithinDirectory}from"../core/fs/path-utils.js";import{dedupeLinkedArtifacts,normalizeLinkedPath,renameArtifactsResultKey,runLinkedArtifacts,sortLinkedArtifacts}from"./linked-artifacts.js";import{explainSourceTraceability}from"./traceability/source-traceability.js";const RELATIVE_REFERENCE_SCAN_MAX_CHARS=32768;function normalizeCandidatePathForOutput(value){return normalizeLinkedPath(path.normalize(value))}async function realpathForContainment(inputPath){try{return await fs.realpath(inputPath)}catch{return path.resolve(inputPath)}}function linkedFileResolvedKey(linkedFile,projectRoot){const resolvedPath=path.isAbsolute(linkedFile.path)?path.resolve(linkedFile.path):path.resolve(projectRoot,linkedFile.path);return`${normalizeCandidatePathForOutput(resolvedPath)}::${linkedFile.scope}`}function collectTextReferences(value,fieldPath,references){if(typeof value=="string"){const trimmed=value.trim();trimmed.length>0&&references.push({field:fieldPath,value:trimmed});return}if(Array.isArray(value)){value.forEach((entry,index)=>collectTextReferences(entry,`${fieldPath}[${index}]`,references));return}if(typeof value=="object"&&value!==null)for(const[key,nested]of Object.entries(value))collectTextReferences(nested,fieldPath?`${fieldPath}.${key}`:key,references)}function collectItemTextReferences(document){const references=[];return collectTextReferences(document.metadata,"metadata",references),collectTextReferences(document.body,"body",references),references}function cleanupPathToken(value){let next=value.trim();return next=next.replace(/^[`"'<([{]+/u,""),next=next.replace(/[`"'>)\]},;!?]+$/u,""),next=next.replace(/[.]+$/u,""),next=next.replace(/:(?:\d+)(?::\d+)?$/u,""),next=next.replace(/[.]+$/u,""),next}function extractRawPathReferences(references){const rawReferences=[],absolutePattern=/(?:[A-Za-z]:[\\/]|\/)[^\s"'`<>()[\]{},;]+/gu,relativePattern=/(?:\.{1,2}[\\/])?(?:(?:[A-Za-z0-9_.@-]+[\\/])+[A-Za-z0-9_.@-]+|[A-Za-z0-9_.@-]+\.[A-Za-z0-9][A-Za-z0-9._-]*)/gu;for(const reference of references){const seenInField=new Set,boundedRelativeValue=reference.value.slice(0,RELATIVE_REFERENCE_SCAN_MAX_CHARS);for(const[pattern,input]of[[absolutePattern,reference.value],[relativePattern,boundedRelativeValue]]){pattern.lastIndex=0;for(const match of input.matchAll(pattern)){const token=cleanupPathToken(match[0]);!token||seenInField.has(token)||(seenInField.add(token),rawReferences.push({field:reference.field,value:token}))}}}return rawReferences}async function resolveDiscoveredFile(rawPath,workspaceRoot,invocationRoot=workspaceRoot){const absolutePath=path.isAbsolute(rawPath)?path.resolve(rawPath):path.resolve(invocationRoot,rawPath);let stats;try{stats=await fs.stat(absolutePath)}catch{return}if(!stats.isFile())return;const[canonicalProjectRoot,canonicalAbsolutePath]=await Promise.all([realpathForContainment(workspaceRoot),realpathForContainment(absolutePath)]);if(isPathWithinDirectory(canonicalProjectRoot,canonicalAbsolutePath)){const relativePath=path.relative(canonicalProjectRoot,canonicalAbsolutePath);return!relativePath||relativePath.startsWith("..")||path.isAbsolute(relativePath)?void 0:{path:normalizeCandidatePathForOutput(relativePath),scope:"project"}}return{path:normalizeCandidatePathForOutput(absolutePath),scope:"global"}}async function discoverReferencedFiles(document,workspaceRoot,invocationRoot=workspaceRoot){const existingResolvedKeys=new Set((document.metadata.files??[]).map(entry=>linkedFileResolvedKey(entry,workspaceRoot))),grouped=new Map,rawReferences=extractRawPathReferences(collectItemTextReferences(document)),resolvedByValue=new Map;await Promise.all([...new Set(rawReferences.map(reference=>reference.value))].map(async value=>{resolvedByValue.set(value,await resolveDiscoveredFile(value,workspaceRoot,invocationRoot))}));const resolvedReferences=rawReferences.map(reference=>({reference,resolved:resolvedByValue.get(reference.value)}));for(const{reference,resolved}of resolvedReferences){if(!resolved)continue;const key=linkedFileResolvedKey(resolved,workspaceRoot),existing=grouped.get(key)??{path:resolved.path,scope:resolved.scope,sourceFields:new Set,originalPaths:new Set,sourceCount:0};existing.sourceFields.add(reference.field),existing.originalPaths.add(reference.value),existing.sourceCount+=1,grouped.set(key,existing)}return[...grouped.entries()].map(([key,entry])=>({path:entry.path,scope:entry.scope,status:existingResolvedKeys.has(key)?"already_linked":"addable",source_count:entry.sourceCount,source_fields:[...entry.sourceFields].sort((left,right)=>left.localeCompare(right)),original_paths:[...entry.originalPaths].sort((left,right)=>left.localeCompare(right))})).sort((left,right)=>{const byStatus=left.status.localeCompare(right.status);if(byStatus!==0)return byStatus;const byPath=left.path.localeCompare(right.path);return byPath!==0?byPath:left.scope.localeCompare(right.scope)})}const _testOnly={relativeReferenceScanMaxChars:RELATIVE_REFERENCE_SCAN_MAX_CHARS,normalizeCandidatePathForOutput,realpathForContainment,linkedFileResolvedKey,collectTextReferences,collectItemTextReferences,cleanupPathToken,extractRawPathReferences,resolveDiscoveredFile,discoverReferencedFiles};async function runFiles(id,options,global2){const result=await runLinkedArtifacts(id,options,global2,{metadataKey:"files",op:"files_add",bareNoun:"file",supportsAppendStable:!0});return renameArtifactsResultKey(result,"files")}async function normalizeFilesLookupPaths(values,workspaceRoot){const canonicalWorkspaceRoot=await realpathForContainment(workspaceRoot),paths=await Promise.all(values.map(async value=>{const trimmed=value.trim();if(!trimmed)throw new PmCliError("Files lookup paths must not be empty.",EXIT_CODE.USAGE);if(!path.isAbsolute(trimmed))return normalizeLinkedPath(trimmed);const canonicalAbsolutePath=await realpathForContainment(trimmed);return isPathWithinDirectory(canonicalWorkspaceRoot,canonicalAbsolutePath)?normalizeLinkedPath(path.relative(canonicalWorkspaceRoot,canonicalAbsolutePath)):normalizeLinkedPath(canonicalAbsolutePath)})),uniquePaths=[...new Set(paths)].sort((left,right)=>left.localeCompare(right));if(uniquePaths.length===0)throw new PmCliError("Files lookup requires at least one path.",EXIT_CODE.USAGE);return uniquePaths}function resolveFilesLookupWindow(options){for(const[label,value]of[["limit",options.limit],["offset",options.offset]])if(value!==void 0&&(!Number.isInteger(value)||value<0))throw new PmCliError(`Files lookup ${label} must be a non-negative integer.`,EXIT_CODE.USAGE);const{offset=0,limit=50}=options;return{offset:Math.max(0,Math.floor(offset)),limit:options.noTruncate?void 0:Math.max(0,Math.floor(limit))}}function projectFilesLookupItem(item){return{id:item.id,title:item.title,type:item.type,status:item.status,priority:item.priority,updated_at:item.updated_at}}function compareFilesLookupCandidates(left,right){const byPriority=left.item.priority-right.item.priority;if(byPriority!==0)return byPriority;const byUpdated=right.item.updated_at.localeCompare(left.item.updated_at);return byUpdated===0?left.item.id.localeCompare(right.item.id):byUpdated}function matchingFilesLookupCandidates(params){return params.metadata.map(item=>({item,files:(item.files??[]).filter(file=>params.paths.includes(normalizeLinkedPath(file.path))&&(params.scope===void 0||file.scope===params.scope)).sort((left,right)=>{const byPath=left.path.localeCompare(right.path);return byPath===0?left.scope.localeCompare(right.scope):byPath})})).filter(match=>match.files.length>0).sort(compareFilesLookupCandidates)}async function resolveFilesLookupTraceability(params){if(params.explain)return explainSourceTraceability({workspaceRoot:params.workspaceRoot,paths:params.paths,candidates:params.matching,corpus:params.metadata,...params.lineRange?{lineRange:params.lineRange}:{},...params.decisionDepth===void 0?{}:{decisionDepth:params.decisionDepth}})}async function queryFilesLookupIndex(params){if([params.strictRead,params.noTruncate,params.explain,hasActiveOnReadHooks()].includes(!0))return null;const indexState=await readItemMetadataDerivedIndexState(params.pmRoot,[...new Set(Object.values(params.typeToFolder))]);return indexState?queryLinkedFileMetadataIndex({pmRoot:params.pmRoot,expectedSourceCursor:indexState.source_cursor,paths:params.paths,scope:params.scope,limit:params.limit,offset:params.offset}):null}async function queryFilesLookupSource(params){const warnings=[],metadata=await listAllItemMetadata(params.pmRoot,params.settings.item_format,params.typeToFolder,warnings,params.settings.schema),matching=matchingFilesLookupCandidates({metadata,paths:params.paths,scope:params.scope}),readWarnings=warnings.filter(warning=>/^item_list_(?:item|directory)_read_failed:/u.test(warning));if(params.strictRead&&readWarnings.length>0)throw new PmCliError(`Files lookup could not read every item: ${readWarnings.join("; ")}`,EXIT_CODE.GENERIC_FAILURE);const traceability=await resolveFilesLookupTraceability({explain:params.explain,workspaceRoot:params.workspaceRoot,paths:params.paths,matching,metadata,lineRange:params.lineRange,decisionDepth:params.decisionDepth}),page=(traceability?[...matching].sort((left,right)=>{const byScore=traceability.explanations.get(right.item.id).score-traceability.explanations.get(left.item.id).score;return byScore!==0?byScore:compareFilesLookupCandidates(left,right)}):matching).slice(params.offset,params.limit===void 0?void 0:params.offset+params.limit);return{paths:params.paths,total:matching.length,count:page.length,offset:params.offset,limit:params.limit??null,has_more:params.offset+page.length<matching.length,truncated:params.offset+page.length<matching.length,completeness:{status:readWarnings.length===0?"complete":"partial",source:"source_scan"},warnings,matches:page.map(match=>({item:projectFilesLookupItem(match.item),files:match.files,...traceability?{traceability:traceability.explanations.get(match.item.id)}:{}})),...traceability?{traceability_receipt:traceability.receipt}:{}}}async function runFilesLookup(options,global2){const pmRoot=resolvePmRoot(process.cwd(),global2.path),workspaceRoot=resolveWorkspaceRoot(pmRoot);await assertInitializedTracker(pmRoot);const paths=await normalizeFilesLookupPaths(options.paths,workspaceRoot);if(options.lineRange&&paths.length!==1)throw new PmCliError("Files lookup line attribution requires exactly one source path.",EXIT_CODE.USAGE);const settings=await readSettings(pmRoot),typeRegistry=resolveItemTypeRegistry(settings,getActiveExtensionRegistrations()),{offset,limit}=resolveFilesLookupWindow(options),indexed=await queryFilesLookupIndex({pmRoot,typeToFolder:typeRegistry.type_to_folder,paths,scope:options.scope,limit,offset,strictRead:options.strictRead===!0,noTruncate:options.noTruncate===!0,explain:options.explain===!0||options.lineRange!==void 0});return indexed?{paths,total:indexed.total,count:indexed.matches.length,offset,limit,has_more:offset+indexed.matches.length<indexed.total,truncated:offset+indexed.matches.length<indexed.total,completeness:{status:"unchecked",source:"index"},warnings:[],matches:indexed.matches.map(match=>({item:projectFilesLookupItem(match.item),files:match.files}))}:queryFilesLookupSource({pmRoot,settings,typeToFolder:typeRegistry.type_to_folder,paths,scope:options.scope,limit,offset,strictRead:options.strictRead===!0,workspaceRoot,explain:options.explain===!0||options.lineRange!==void 0,lineRange:options.lineRange,decisionDepth:options.decisionDepth})}async function runFilesDiscover(id,options,global2){const pmRoot=resolvePmRoot(process.cwd(),global2.path),workspaceRoot=resolveWorkspaceRoot(pmRoot);await assertInitializedTracker(pmRoot);const settings=await readSettings(pmRoot),typeRegistry=resolveItemTypeRegistry(settings,getActiveExtensionRegistrations()),located=await locateItem(pmRoot,id,settings.id_prefix,settings.item_format,typeRegistry.type_to_folder);if(!located)throw new PmCliError(`Item ${id} not found`,EXIT_CODE.NOT_FOUND);const loaded=await readLocatedItem(located,{schema:settings.schema}),candidates=await discoverReferencedFiles(loaded.document,workspaceRoot,process.cwd()),addableCandidates=candidates.filter(candidate=>candidate.status==="addable"),skippedExisting=candidates.filter(candidate=>candidate.status==="already_linked"),requestedApply=options.apply===!0,note=options.note?.trim()||"discovered from item text";if(!requestedApply||addableCandidates.length===0){const files2=loaded.document.metadata.files??[];return{id:located.id,files:files2,changed:!1,apply:requestedApply,count:files2.length,candidate_count:candidates.length,addable_count:addableCandidates.length,added_count:0,skipped_existing_count:skippedExisting.length,candidates,added:[],skipped_existing:skippedExisting}}const author=resolveAuthor(options.author,settings.author_default),discoveredAdds=addableCandidates.map(candidate=>({path:candidate.path,scope:candidate.scope,note}));let appliedAdds=[];const appliedCandidateIndices=new Set,result=await mutateItem({pmRoot,settings,id,op:"files_discover",author,message:options.message??"Discover referenced file links",force:options.force,mutate(document){const next=[...document.metadata.files??[]],existingResolvedKeys=new Set(next.map(entry=>linkedFileResolvedKey(entry,workspaceRoot)));appliedAdds=[],appliedCandidateIndices.clear();for(const[index,add]of discoveredAdds.entries()){const resolvedKey=linkedFileResolvedKey(add,workspaceRoot);existingResolvedKeys.has(resolvedKey)||(next.push(add),existingResolvedKeys.add(resolvedKey),appliedAdds.push(add),appliedCandidateIndices.add(index))}const deduped=dedupeLinkedArtifacts(next),normalized=options.appendStable?deduped:sortLinkedArtifacts(deduped);return normalized.length>0?document.metadata.files=normalized:delete document.metadata.files,{changedFields:appliedAdds.length>0?["files"]:[],warnings:appliedAdds.length!==discoveredAdds.length?[`files_discover_skipped_existing:${discoveredAdds.length-appliedAdds.length}`]:[]}}}),files=result.item.files??[],addedResolvedKeys=new Set(appliedAdds.map(entry=>linkedFileResolvedKey(entry,workspaceRoot))),added=files.filter(entry=>addedResolvedKeys.has(linkedFileResolvedKey(entry,workspaceRoot))),skippedDuringApply=addableCandidates.filter((_candidate,index)=>!appliedCandidateIndices.has(index)),allSkippedExisting=[...skippedExisting,...skippedDuringApply];return{id:result.item.id,files,changed:added.length>0,apply:!0,count:files.length,candidate_count:candidates.length,addable_count:addableCandidates.length,added_count:added.length,skipped_existing_count:allSkippedExisting.length,candidates,added,skipped_existing:allSkippedExisting}}export{_testOnly,runFiles,runFilesDiscover,runFilesLookup};
|
|
2
2
|
//# sourceMappingURL=files.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a37d89ab-e19f-55e3-9fa8-3158e6a1ef0b")}catch{}})();const PM_ERROR_CODE_CATALOG_PART_1=[{code:"acceptance_criteria_mutation_conflict",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_remove_unmatched",exit_code:3,sources:["sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_semicolon_forbidden",exit_code:2,stable:!0,sources:["core/item/parse.ts"]},{code:"accepted_rejected_value",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"alias_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"alias_target_missing",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"already_claimed_by",exit_code:4,stable:!0,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"ambiguous_option_combination",exit_code:2,stable:!0,sources:["sdk/lifecycle/claim.ts","sdk/lifecycle/plan.ts"],emitting_commands:["claim","plan"]},{code:"annotation_alias_conflict",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"annotation_entry_mismatch",exit_code:4,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_invalid",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_without_target",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_flag_like_value",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_if_absent_without_append",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_message_without_text",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_text_source_conflict",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"annotation_transposed_subcommand",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"append_empty_body",exit_code:2,stable:!0,sources:["sdk/lifecycle/append.ts"],emitting_commands:["append"]},{code:"assurance_registry_invalid",exit_code:1,sources:["sdk/governance/assurance.ts"]},{code:"bare_comma_entry_ambiguous",exit_code:2,sources:["core/item/parse.ts"]},{code:"blocker_identity_read_failed",exit_code:1,sources:["sdk/query/declared-blockers.ts"]},{code:"body_file_conflicts_with_body",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_missing_path",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_unreadable",exit_code:3,stable:!0,sources:["core/io/body-file.ts"]},{code:"budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"bulk_create_route",exit_code:2,sources:["cli/register-mutation.ts"]},{code:"bulk_ids_input_empty",exit_code:2,sources:["core/io/bulk-ids-input.ts","sdk/history-compact.ts","sdk/history-mcp.ts"],owned_states:[{state:"bulk_ids_stdin_contains_no_nonempty_ids",probe_id:"bulk-ids-stdin-empty",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_missing_path",exit_code:2,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_token_omits_its_path",probe_id:"bulk-ids-file-path-missing",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_unreadable",exit_code:3,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_path_cannot_be_read",probe_id:"bulk-ids-file-unreadable",entrypoints:["update-many"],expected_exit_class:"not_found"}]},{code:"bundle_integrity_torn_install",exit_code:1,stable:!0,sources:["cli/bundle-integrity.ts"]},{code:"capability_undeclared",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"capability_unused",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"child_projection_item_bound_exceeded",exit_code:1,stable:!0,sources:["sdk/item-children.ts"]},{code:"close_reason_required",exit_code:2,stable:!0,sources:["sdk/lifecycle-policy.ts","sdk/lifecycle/close-many.ts"],emitting_commands:["*","close-many"]},{code:"close_through_update",exit_code:1,stable:!0,sources:["core/telemetry/observability.ts"]},{code:"close_validation_missing_fields",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"collected_zero_items",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"collection_transposed_subcommand",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"command_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"command_namespace",exit_code:2,stable:!0,sources:["sdk/cli-contracts/runtime-contracts.ts"]},{code:"command_override_conflict",exit_code:4,stable:!0,sources:["sdk/compose.ts"]},{code:"config_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_key_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts","sdk/config.ts"]},{code:"config_value_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"conflicting_lifecycle_owner",exit_code:2,stable:!0,sources:["cli/register-operations.ts"]},{code:"context_evaluation_read_incomplete",exit_code:2,sources:["sdk/context-relevance.ts"]},{code:"context_signal_store_invalid",exit_code:2,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_stale",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_write_failed",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_takes_no_item_argument",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"core_item_field_requires_dedicated_flag",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"create_positional_type_without_title",exit_code:2,stable:!0,sources:["cli/register-mutation.ts"]},{code:"dependency_cardinality_created",exit_code:2,sources:["sdk/graph/cardinality-integrity.ts"]},{code:"dependency_edge_not_allowed",exit_code:2,stable:!0,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_flag_value_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_remove_no_match",exit_code:3,sources:["sdk/lifecycle/dependency-removal.ts"],emitting_commands:["update"]},{code:"dependency_target_not_found",exit_code:3,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_temporal_order_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"duplicate_canonical_flag",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"duplicate_command",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"duplicate_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"duplicate_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"duplicate_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"duplicate_probe",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"duplicate_sweep_cost_limit",exit_code:4,stable:!0,sources:["sdk/query/duplicate-candidates.ts"],emitting_commands:["duplicate-candidates"]},{code:"duplicate_target_circular",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_is_duplicate",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_missing",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_self",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"empty_corpus",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"empty_surface",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"event_cursor_query_mismatch",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"event_history_integrity_failed",exit_code:1,sources:["core/history/event-index.ts"]},{code:"event_index_unavailable",exit_code:1,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"exit_code_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"expect_hash_background_unsupported",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invalid",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invocation_rewritten",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_requires_mutation",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_target_required",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expected_revision_duplicate",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"expected_revision_scope_conflict",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"extension_command_activation_failed",exit_code:1,stable:!0,sources:["cli/commander-usage.ts"]},{code:"extension_dependency_name_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_spec_invalid",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_version_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_flag_value_invalid",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_install_incomplete_source_scan",exit_code:2,sources:["sdk/extension/install-plan.ts"]},{code:"extension_install_rollback_failed",exit_code:1,sources:["sdk/extension/install-snapshot.ts"]},{code:"extension_install_soft_failed",exit_code:1,stable:!0,sources:["cli/register-setup.ts"]},{code:"extension_install_source_contains_destination",exit_code:2,stable:!0,sources:["sdk/extension/install-runtime.ts"]},{code:"extension_item_field_reserved",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_type_conflict",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_unknown",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_mutation_guard_failed",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_decision",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_denial",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_timed_out",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_option_spelling_conflict",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_read_output_invalid",exit_code:2,sources:["sdk/read-output/extension.ts"]},{code:"extension_update_health_partial_coverage",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"extensions_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"field_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_mcp_input_collision",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"github_source_entry_unbuilt",exit_code:2,stable:!0,sources:["sdk/extension/shared.ts"]},{code:"hierarchy_cardinality_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_cycle_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_parent_divergence_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"history_author_acknowledge_plan_conflict",exit_code:4,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_plan_fingerprint_required",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_preview_limit_invalid",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_required_values_missing",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_conflict",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_required",exit_code:2,stable:!0,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_not_actionable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_unreadable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_baseline_unavailable",exit_code:1,sources:["core/history/projection.ts"]},{code:"history_drift_chain_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_chain_mismatches"]},{code:"history_drift_hash_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_hash_mismatches"]},{code:"history_drift_merge_receipt",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_missing_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_missing_streams"]},{code:"history_drift_unreadable_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_unreadable_streams"]},{code:"history_drift_version_skew",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_version_skews"]},{code:"history_json_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/history/read.ts"],canonical_code:"merge_conflict_markers_detected"},{code:"history_replay_invalid",exit_code:1,sources:["core/history/projection.ts","core/history/tombstone.ts"]},{code:"history_salvage_refused",exit_code:4,sources:["sdk/history/salvage.ts"]},{code:"history_stream_over_compact_threshold",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"history_target_out_of_range",exit_code:1,stable:!0,sources:["core/history/projection.ts"]},{code:"history_timestamp_invalid",exit_code:1,sources:["core/history/event-index.ts","core/history/history.ts"]},{code:"history_union_rebase_conflict",exit_code:4,sources:["sdk/merge/history-scalar-rebase.ts"]},{code:"history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_unknown_author_events"]},{code:"history_version_mapping_unavailable",exit_code:2,sources:["core/history/version-address.ts"]},{code:"history_version_pruned",exit_code:2,sources:["core/history/projection.ts"]},{code:"host_environment_capacity_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_operation_invalid",exit_code:2,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_permission_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_resource_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"improvement_metric_contract_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"improvement_observation_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"incomplete_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"inconsistent_concept_kind",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"init_existing_settings_requires_force",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_gitignore_unwritable",exit_code:1,stable:!0,sources:["sdk/workspace.ts"]},{code:"init_id_prefix_conflict",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_id_prefix_path_like",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"integrity_history_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_history_conflict_markers"]},{code:"integrity_history_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_history_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_ahead_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_ahead_items"]},{code:"integrity_item_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_outdated_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_outdated_items"]},{code:"integrity_item_parse_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"invalid_argument_value",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/item/priority.ts","core/shared/url-credentials.ts","core/telemetry/observability.ts","sdk/config.ts","sdk/context-intent-contracts.ts","sdk/dependencies.ts","sdk/governance/assurance-mutation-error.ts","sdk/history-redact.ts","sdk/lifecycle/create.ts","sdk/lifecycle/task-composition.ts","sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts","sdk/query/next.ts","sdk/runtime-input.ts","sdk/runtime/mutation-admission.ts","sdk/runtime/mutation-value-validation.ts","sdk/runtime/schema-preview.ts","sdk/workspace.ts"],emitting_commands:["*","create","next","task-composition","update","update-many"]},{code:"invalid_command_usage",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"invalid_event_cursor",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_cursor_mode",exit_code:2,sources:["cli/register-list-query.ts","sdk/mutation-events.ts","sdk/runtime-extended-actions.ts"]},{code:"invalid_event_follow_interval",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_limit",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_since",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_history_analytics_limit",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_minimum_sample",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_since",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_improvement_ledger",exit_code:1,sources:["sdk/improvement-ledger-validation.ts"]},{code:"invalid_improvement_metric",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_limit",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_timestamp",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_provenance_predicate",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"invalid_query_cursor",exit_code:2,stable:!0,sources:["sdk/pagination.ts","sdk/query/window-pagination.ts"]},{code:"invalid_read_output_session",exit_code:2,sources:["sdk/read-output-session.ts"]},{code:"invalid_reproducible_process_environment",exit_code:2,sources:["sdk/reproducibility/process.ts"]},{code:"invalid_workspace_snapshot_target",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"item_already_active",exit_code:4,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"item_already_exists",exit_code:4,stable:!0,sources:["sdk/lifecycle/create.ts"],emitting_commands:["create"]},{code:"item_deleted",exit_code:3,sources:["core/history/tombstone.ts"]},{code:"item_document_encoding_invalid",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_document_invalid",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_document_roundtrip_failed",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_format_version_unsupported",exit_code:4,sources:["core/item/item-format.ts"]},{code:"item_id_collision",exit_code:4,stable:!0,sources:["sdk/lifecycle/copy.ts"],emitting_commands:["copy"]},{code:"item_identity_ambiguous",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_identity_conflict",exit_code:4,sources:["sdk/governance/validate-history-drift.ts","sdk/lifecycle/item-revision.ts","sdk/merge/three-way.ts","sdk/query/declared-blockers.ts"]},{code:"item_identity_reserved",exit_code:4,sources:["core/history/history.ts"]},{code:"item_not_found",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/item-store.ts","core/telemetry/observability.ts","sdk/governance/validate-history-drift.ts"]},{code:"item_revision_conflict",exit_code:4,sources:["core/store/item-mutation-precondition.ts"]},{code:"likely_duplicate",exit_code:4,stable:!0,sources:["sdk/similarity.ts"]},{code:"linked_artifact_mutation_conflict",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_key_misread",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_resource_positional_value",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"linked_test_command_immutable",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_command_not_executable",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_context_invalid",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_patch_fields_unsupported",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_remove_no_match",exit_code:3,sources:["sdk/test/execution.ts"]},{code:"linked_test_update_ambiguous",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_update_no_match",exit_code:3,sources:["sdk/test/update.ts"]},{code:"linked_test_value_not_quoted",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"list_source_incomplete",exit_code:1,stable:!0,sources:["sdk/query/list.ts"],emitting_commands:["list"]},{code:"local_package_archive_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"local_source_not_found_bare_name",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"lock_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/lock/lock.ts","core/telemetry/observability.ts"]},{code:"lock_lost",exit_code:4,sources:["core/lock/lock.ts"]},{code:"lock_path_unsafe",exit_code:4,sources:["core/lock/lock-confinement.ts"]},{code:"locks_stale_count",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"locks_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"malformed_plan_step_evidence",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"managed_state_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"managed_state_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_capabilities_absent",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"manifest_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_unknown_key",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_declares_an_unknown_top_level_key",probe_id:"author-manifest-unknown-key",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"manifest_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"mcp_annotation_file_unavailable",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"mcp_stdin_unavailable",exit_code:2,sources:["sdk/annotations.ts"]},{code:"mcp_task_not_found_or_not_authorized",exit_code:3,sources:["sdk/mcp/tasks.ts"]},{code:"merge_artifacts_ignored",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_bun_launcher_unavailable",exit_code:5,sources:["sdk/merge/install.ts"]},{code:"merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/item/item-format.ts"],aliases:["history_merge_conflict_markers_detected"]},{code:"merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_git_config_unwritable",exit_code:5,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_receipt_evidence_invalid",exit_code:4,sources:["core/diagnostics/remediation.ts","sdk/merge/reconcile.ts"]},{code:"merge_receipt_history_reference_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_receipt_not_portable",exit_code:4,sources:["sdk/merge/receipts.ts"]},{code:"merge_receipts_pending",exit_code:1,sources:["core/diagnostics/remediation.ts"]}];export{PM_ERROR_CODE_CATALOG_PART_1};
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6d195507-9135-5031-a368-7e65c8f84179")}catch{}})();const PM_ERROR_CODE_CATALOG_PART_1=[{code:"acceptance_criteria_mutation_conflict",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_remove_unmatched",exit_code:3,sources:["sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_semicolon_forbidden",exit_code:2,stable:!0,sources:["core/item/parse.ts"]},{code:"accepted_rejected_value",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"alias_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"alias_target_missing",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"already_claimed_by",exit_code:4,stable:!0,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"ambiguous_option_combination",exit_code:2,stable:!0,sources:["sdk/lifecycle/claim.ts","sdk/lifecycle/plan.ts"],emitting_commands:["claim","plan"]},{code:"annotation_alias_conflict",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"annotation_entry_mismatch",exit_code:4,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_invalid",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_without_target",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_flag_like_value",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_if_absent_without_append",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_message_without_text",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_text_compacted",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_text_source_conflict",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"annotation_transposed_subcommand",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"append_empty_body",exit_code:2,stable:!0,sources:["sdk/lifecycle/append.ts"],emitting_commands:["append"]},{code:"assurance_registry_invalid",exit_code:1,sources:["sdk/governance/assurance.ts"]},{code:"bare_comma_entry_ambiguous",exit_code:2,sources:["core/item/parse.ts"]},{code:"blocker_identity_read_failed",exit_code:1,sources:["sdk/query/declared-blockers.ts"]},{code:"body_file_conflicts_with_body",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_missing_path",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_unreadable",exit_code:3,stable:!0,sources:["core/io/body-file.ts"]},{code:"budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"bulk_create_route",exit_code:2,sources:["cli/register-mutation.ts"]},{code:"bulk_ids_input_empty",exit_code:2,sources:["core/io/bulk-ids-input.ts","sdk/history-compact.ts","sdk/history-mcp.ts"],owned_states:[{state:"bulk_ids_stdin_contains_no_nonempty_ids",probe_id:"bulk-ids-stdin-empty",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_missing_path",exit_code:2,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_token_omits_its_path",probe_id:"bulk-ids-file-path-missing",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_unreadable",exit_code:3,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_path_cannot_be_read",probe_id:"bulk-ids-file-unreadable",entrypoints:["update-many"],expected_exit_class:"not_found"}]},{code:"bundle_integrity_torn_install",exit_code:1,stable:!0,sources:["cli/bundle-integrity.ts"]},{code:"capability_undeclared",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"capability_unused",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"child_projection_item_bound_exceeded",exit_code:1,stable:!0,sources:["sdk/item-children.ts"]},{code:"close_reason_required",exit_code:2,stable:!0,sources:["sdk/lifecycle-policy.ts","sdk/lifecycle/close-many.ts"],emitting_commands:["*","close-many"]},{code:"close_through_update",exit_code:1,stable:!0,sources:["core/telemetry/observability.ts"]},{code:"close_validation_deferred_fields",exit_code:2,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"close_validation_missing_fields",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"collected_zero_items",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"collection_transposed_subcommand",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"command_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"command_namespace",exit_code:2,stable:!0,sources:["sdk/cli-contracts/runtime-contracts.ts"]},{code:"command_override_conflict",exit_code:4,stable:!0,sources:["sdk/compose.ts"]},{code:"config_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_key_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts","sdk/config.ts"]},{code:"config_value_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"conflicting_lifecycle_owner",exit_code:2,stable:!0,sources:["cli/register-operations.ts"]},{code:"context_evaluation_read_incomplete",exit_code:2,sources:["sdk/context-relevance.ts"]},{code:"context_signal_store_invalid",exit_code:2,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_stale",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_write_failed",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_takes_no_item_argument",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"core_item_field_requires_dedicated_flag",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"create_deferral_conflict",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_field_unsupported",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_fields_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_reason_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_positional_type_without_title",exit_code:2,stable:!0,sources:["cli/register-mutation.ts"]},{code:"dependency_cardinality_created",exit_code:2,sources:["sdk/graph/cardinality-integrity.ts"]},{code:"dependency_edge_not_allowed",exit_code:2,stable:!0,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_flag_value_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_remove_no_match",exit_code:3,sources:["sdk/lifecycle/dependency-removal.ts"],emitting_commands:["update"]},{code:"dependency_target_not_found",exit_code:3,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_temporal_order_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"duplicate_canonical_flag",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"duplicate_command",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"duplicate_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"duplicate_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"duplicate_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"duplicate_probe",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"duplicate_sweep_cost_limit",exit_code:4,stable:!0,sources:["sdk/query/duplicate-candidates.ts"],emitting_commands:["duplicate-candidates"]},{code:"duplicate_target_circular",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_is_duplicate",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_missing",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_self",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"empty_corpus",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"empty_surface",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"event_cursor_query_mismatch",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"event_history_integrity_failed",exit_code:1,sources:["core/history/event-index.ts"]},{code:"event_index_unavailable",exit_code:1,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"exit_code_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"expect_hash_background_unsupported",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invalid",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invocation_rewritten",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_requires_mutation",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_target_required",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expected_revision_duplicate",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"expected_revision_scope_conflict",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"extension_command_activation_failed",exit_code:1,stable:!0,sources:["cli/commander-usage.ts"]},{code:"extension_dependency_name_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_spec_invalid",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_version_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_flag_value_invalid",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_install_incomplete_source_scan",exit_code:2,sources:["sdk/extension/install-plan.ts"]},{code:"extension_install_rollback_failed",exit_code:1,sources:["sdk/extension/install-snapshot.ts"]},{code:"extension_install_soft_failed",exit_code:1,stable:!0,sources:["cli/register-setup.ts"]},{code:"extension_install_source_contains_destination",exit_code:2,stable:!0,sources:["sdk/extension/install-runtime.ts"]},{code:"extension_item_field_reserved",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_type_conflict",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_unknown",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_mutation_guard_failed",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_decision",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_denial",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_timed_out",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_option_disabled",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_option_spelling_conflict",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_read_output_invalid",exit_code:2,sources:["sdk/read-output/extension.ts"]},{code:"extension_update_health_partial_coverage",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"extensions_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"field_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_mcp_input_collision",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"github_source_entry_unbuilt",exit_code:2,stable:!0,sources:["sdk/extension/shared.ts"]},{code:"hierarchy_cardinality_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_cycle_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_parent_divergence_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"history_author_acknowledge_plan_conflict",exit_code:4,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_plan_fingerprint_required",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_preview_limit_invalid",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_required_values_missing",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_conflict",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_required",exit_code:2,stable:!0,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_not_actionable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_unreadable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_baseline_unavailable",exit_code:1,sources:["core/history/projection.ts"]},{code:"history_drift_chain_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_chain_mismatches"]},{code:"history_drift_hash_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_hash_mismatches"]},{code:"history_drift_merge_receipt",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_missing_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_missing_streams"]},{code:"history_drift_unreadable_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_unreadable_streams"]},{code:"history_drift_version_skew",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_version_skews"]},{code:"history_json_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/history/read.ts"],canonical_code:"merge_conflict_markers_detected"},{code:"history_replay_invalid",exit_code:1,sources:["core/history/projection.ts","core/history/tombstone.ts"]},{code:"history_salvage_refused",exit_code:4,sources:["sdk/history/salvage.ts"]},{code:"history_stream_over_compact_threshold",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"history_target_out_of_range",exit_code:1,stable:!0,sources:["core/history/projection.ts"]},{code:"history_timestamp_invalid",exit_code:1,sources:["core/history/event-index.ts","core/history/history.ts"]},{code:"history_union_rebase_conflict",exit_code:4,sources:["sdk/merge/history-scalar-rebase.ts"]},{code:"history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_unknown_author_events"]},{code:"history_version_mapping_unavailable",exit_code:2,sources:["core/history/version-address.ts"]},{code:"history_version_pruned",exit_code:2,sources:["core/history/projection.ts"]},{code:"host_environment_capacity_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_operation_invalid",exit_code:2,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_permission_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_resource_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"improvement_metric_contract_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"improvement_observation_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"incomplete_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"inconsistent_concept_kind",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"init_existing_settings_requires_force",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_gitignore_unwritable",exit_code:1,stable:!0,sources:["sdk/workspace.ts"]},{code:"init_id_prefix_conflict",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_id_prefix_path_like",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"integrity_history_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_history_conflict_markers"]},{code:"integrity_history_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_history_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_ahead_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_ahead_items"]},{code:"integrity_item_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_outdated_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_outdated_items"]},{code:"integrity_item_parse_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"invalid_argument_value",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/item/priority.ts","core/shared/url-credentials.ts","core/telemetry/observability.ts","sdk/config.ts","sdk/context-intent-contracts.ts","sdk/dependencies.ts","sdk/governance/assurance-mutation-error.ts","sdk/history-redact.ts","sdk/lifecycle/create.ts","sdk/lifecycle/task-composition.ts","sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts","sdk/linked-artifacts.ts","sdk/query/next.ts","sdk/runtime-input.ts","sdk/runtime/mutation-admission.ts","sdk/runtime/mutation-value-validation.ts","sdk/runtime/schema-preview.ts","sdk/test/run-phases.ts","sdk/workspace.ts"],emitting_commands:["*","create","next","task-composition","update","update-many"]},{code:"invalid_command_usage",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"invalid_event_cursor",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_cursor_mode",exit_code:2,sources:["cli/register-list-query.ts","sdk/mutation-events.ts","sdk/runtime-extended-actions.ts"]},{code:"invalid_event_follow_interval",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_limit",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_since",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_history_analytics_limit",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_minimum_sample",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_since",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_improvement_ledger",exit_code:1,sources:["sdk/improvement-ledger-validation.ts"]},{code:"invalid_improvement_metric",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_limit",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_timestamp",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_provenance_predicate",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"invalid_query_cursor",exit_code:2,stable:!0,sources:["sdk/pagination.ts","sdk/query/window-pagination.ts"]},{code:"invalid_read_output_session",exit_code:2,sources:["sdk/read-output-session.ts"]},{code:"invalid_reproducible_process_environment",exit_code:2,sources:["sdk/reproducibility/process.ts"]},{code:"invalid_workspace_snapshot_target",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"item_already_active",exit_code:4,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"item_already_exists",exit_code:4,stable:!0,sources:["sdk/lifecycle/create.ts"],emitting_commands:["create"]},{code:"item_deleted",exit_code:3,sources:["core/history/tombstone.ts"]},{code:"item_document_encoding_invalid",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_document_invalid",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_document_roundtrip_failed",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_format_version_unsupported",exit_code:4,sources:["core/item/item-format.ts"]},{code:"item_id_collision",exit_code:4,stable:!0,sources:["sdk/lifecycle/copy.ts"],emitting_commands:["copy"]},{code:"item_identity_ambiguous",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_identity_conflict",exit_code:4,sources:["sdk/governance/validate-history-drift.ts","sdk/lifecycle/item-revision.ts","sdk/merge/three-way.ts","sdk/query/declared-blockers.ts"]},{code:"item_identity_reserved",exit_code:4,sources:["core/history/history.ts"]},{code:"item_not_found",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/item-store.ts","core/telemetry/observability.ts","sdk/governance/validate-history-drift.ts"]},{code:"item_revision_conflict",exit_code:4,sources:["core/store/item-mutation-precondition.ts"]},{code:"likely_duplicate",exit_code:4,stable:!0,sources:["sdk/similarity.ts"]},{code:"linked_artifact_mutation_conflict",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_conflict",exit_code:4,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_key_misread",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_resource_positional_value",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"linked_test_command_immutable",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_command_not_executable",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_context_invalid",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_patch_fields_unsupported",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_remove_no_match",exit_code:3,sources:["sdk/test/execution.ts"]},{code:"linked_test_update_ambiguous",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_update_no_match",exit_code:3,sources:["sdk/test/update.ts"]},{code:"linked_test_value_not_quoted",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"list_source_incomplete",exit_code:1,stable:!0,sources:["sdk/query/list.ts"],emitting_commands:["list"]},{code:"local_package_archive_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"local_source_not_found_bare_name",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"lock_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/lock/lock.ts","core/telemetry/observability.ts"]},{code:"lock_lost",exit_code:4,sources:["core/lock/lock.ts"]},{code:"lock_path_unsafe",exit_code:4,sources:["core/lock/lock-confinement.ts"]},{code:"locks_stale_count",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"locks_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"malformed_plan_step_evidence",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"managed_state_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"managed_state_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_capabilities_absent",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"manifest_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_unknown_key",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_declares_an_unknown_top_level_key",probe_id:"author-manifest-unknown-key",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"manifest_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"mcp_annotation_file_unavailable",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"mcp_stdin_unavailable",exit_code:2,sources:["sdk/annotations.ts"]},{code:"mcp_task_not_found_or_not_authorized",exit_code:3,sources:["sdk/mcp/tasks.ts"]},{code:"merge_artifacts_ignored",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_bun_launcher_unavailable",exit_code:5,sources:["sdk/merge/install.ts"]},{code:"merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/item/item-format.ts"],aliases:["history_merge_conflict_markers_detected"]},{code:"merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_git_config_unwritable",exit_code:5,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_receipt_evidence_invalid",exit_code:4,sources:["core/diagnostics/remediation.ts","sdk/merge/reconcile.ts"]}];export{PM_ERROR_CODE_CATALOG_PART_1};
|
|
2
2
|
//# sourceMappingURL=generated-error-code-catalog-part-1.js.map
|