@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{$b as ae,Aa as $t,Eb as ke,Fb as Ee,Gb as se,Hb as Ae,Ia as ve,Jc as Gt,Xb as Re,Yb as Ft,Zb as Te,_ as Mt,ac as Se,bd as qt,cb as ie,nb as Bt,od as zt,sc as xe,ya as Ut,za as Lt}from"./chunk-YZUBG4W2.js";import{A as h,E as Pt,z as y}from"./chunk-QXOFSZR6.js";import{stripVTControlCharacters as qo}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="493a0675-0114-5b93-b3b4-5bd895ac691f")}catch{}})();var zo=["full","compact","brief","summary","counts"],Aa=["mutation","read","discovery","governance"],Kt=["error","warning","validation_summary","recovery_bundle"],Wo=["full","omit_explanation","limit_collections","compact_recovery","action_only"],Ko=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),Vo=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),Ho=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),Jo={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},Yo=3,Xo=2,Qo=192,Zo={error:{text:768,json:2e3},warning:{text:768,json:2e3},validation_summary:{text:1500,json:3e3},recovery_bundle:{text:768,json:2e3}},er=Kt.map(e=>({diagnostic_class:e,default_max_estimated_tokens_by_format:Zo[e],minimum_max_estimated_tokens:Qo,degradation_ladder:Wo,corrective_action_paths:["required","recovery.suggested_retry","recovery.suggested_retry_args","recovery.next_best_command","next_steps[0]"],token_estimate:"ceil(utf8_bytes / 4)"})),tr=new Map(er.map(e=>[e.diagnostic_class,e]));function nr(e){let[t=""]=ie(e).split(/\s+/u);return Ko.has(t)?"mutation":Vo.has(t)?"discovery":Ho.has(t)?"governance":"read"}function Vt(e,t=nr(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let o=Jo[t];return or({command:n,budget_class:t,default_max_estimated_tokens:o,default_max_estimated_tokens_by_format:{toon:o,json:Math.ceil(o*Yo/Xo)},degradation_ladder:zo,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function or(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var rr=Bt.map(e=>Vt(e)),ir=new Map(rr.map(e=>[e.command,e]));function Ht(e,t={}){let n=e.trim().replace(/\s+/gu," "),[o]=ie(n).split(" "),r=ir.get(o);return r?{...r,command:n}:t.generateFallback?Vt(n):null}function $(e){return Math.ceil(Math.max(0,e)/4)}function Jt(e){let t=tr.get(e);if(t===void 0)throw new TypeError(`diagnosticClass must be one of: ${Kt.join(", ")}`);return t}function j(e){return $(Buffer.byteLength(JSON.stringify(e,null,2),"utf8"))}function sr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Je(e){if(!sr(e))return;let t={};for(let n of["suggested_retry","suggested_retry_args","next_best_command","allowed_values","candidate_commands","missing","missing_required_fields","option_scope","retry_after_ms","waited_ms","owner_handoffs"]){let o=e[n];Array.isArray(o)?t[n]=n==="suggested_retry_args"?o:o.slice(0,3):o!==void 0&&(t[n]=o)}return Object.keys(t).length>0?t:void 0}function ar(e,t){return typeof e!="string"||e.length<=t?e:`${Re(e,Math.max(1,t-3))}...`}function L(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;let n="...",o=Array.from(e),r=0,i=o.length;for(;r<i;){let s=Math.ceil((r+i)/2),a=`${o.slice(0,s).join("")}${n}`;Buffer.byteLength(a,"utf8")<=t?r=s:i=s-1}return`${o.slice(0,r).join("")}${n}`}function Yt(e){let t={};for(let n of["code","required","recovery","next_steps","exit_code","type","title","detail","why","examples"])Object.hasOwn(e,n)&&e[n]!==void 0&&(t[n]=e[n]);for(let[n,o]of Object.entries(e))n!=="__proto__"&&!Object.hasOwn(t,n)&&(t[n]=o);return t}var cr=new Set(["limit_collections","compact_recovery","action_only"]),ur=new Set(["compact_recovery","action_only"]);function dr(e){let t={code:typeof e.code=="string"?e.code:"diagnostic",required:ar(e.required,160)??"Inspect the diagnostic code and retry with corrected input."},n=Je(e.recovery);return n!==void 0?t.recovery=n:Array.isArray(e.next_steps)&&(t.next_steps=e.next_steps.slice(0,1)),e.exit_code!==void 0&&(t.exit_code=e.exit_code),e.type!==void 0&&(t.type=e.type),t}function lr(e,t){let n=structuredClone(e);if(t!=="full"&&(delete n.why,delete n.examples),cr.has(t))for(let[o,r]of Object.entries(n))Array.isArray(r)&&(n[o]=r.slice(0,3));if(ur.has(t)){let o=Je(n.recovery);o?n.recovery=o:delete n.recovery}return t!=="action_only"?Yt(n):dr(n)}function J(e,t){let n={...e,diagnostic_output:{...t,estimated_tokens:0}};for(let o=0;o<4;o+=1){let r=j(n),i=n.diagnostic_output;if(i.estimated_tokens===r)break;i.estimated_tokens=r}return n}function fr(e,t,n){let o=J(e,t);for(let i of["recovery","exit_code"])j(o)<=n||e[i]===void 0||(delete e[i],o=J(e,t));let r=40;for(;j(o)>n&&r>4;)r-=4,e.code=L(String(e.code),r),e.required=L(String(e.required),r),o=J(e,t);return o}function _r(e,t){let n=e.diagnostic_output,{estimated_tokens:o,...r}=n,i=r.omitted_fields.slice(0,8).map(_=>L(_,32)),s={...r,omitted_fields:i,...r.omitted_fields.length>i.length?{omitted_fields_overflow_count:r.omitted_fields.length-i.length}:{}},a=Je(e.recovery),c=a&&j(a)<=48?a:void 0,d={code:L(String(e.code),320),required:L(String(e.required),320),...c?{recovery:c}:{},...e.exit_code!==void 0?{exit_code:e.exit_code}:{}},u=J(d,s);for(;j(u)>t&&s.omitted_fields.length>0;)s.omitted_fields.pop(),s.omitted_fields_overflow_count=r.omitted_fields.length-s.omitted_fields.length,u=J(d,s);return u=fr(d,s,t),u}function Ra(e,t={}){let n=e,o=t.diagnosticClass??"error",r=Jt(o),i=t.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<r.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${r.minimum_max_estimated_tokens}`);let s=i??r.default_max_estimated_tokens_by_format.json,a=j(n),c=Object.keys(n);if(a<=s)return Yt(structuredClone(n));let d;for(let[u,_]of r.degradation_ladder.entries()){let l=lr(n,_),f=c.filter(p=>!Object.hasOwn(l,p)),m=J(l,{diagnostic_class:o,format:"json",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:a,truncated:u>0,degradation_steps:r.degradation_ladder.slice(0,u+1),omitted_fields:f});if(d=m,j(m)<=s)break}return j(d)>s&&(d=_r(d,s)),d}function Wt(e){return qo(e).replace(/\r\n/gu,`
|
|
2
|
+
`).replace(/[^\P{Cc}\n]/gu," ")}function Ta(e,t,n={}){let o=n.diagnosticClass??"error",r=Jt(o),i=n.maxEstimatedTokens;if(i!==void 0&&(!Number.isSafeInteger(i)||i<r.minimum_max_estimated_tokens))throw new RangeError(`maxEstimatedTokens must be a safe integer >= ${r.minimum_max_estimated_tokens}`);let s=i??r.default_max_estimated_tokens_by_format.text,a=Wt(e),c=$(Buffer.byteLength(a,"utf8")),d=c>s,u=`What is required:
|
|
3
|
+
`,_=`
|
|
4
|
+
|
|
5
|
+
${L(a.trimStart().split(/\r?\n/u,1)[0].trim(),320)}
|
|
6
|
+
|
|
7
|
+
Diagnostic output exceeded its declared ${s}-token ceiling; rerun with structured JSON for the bounded recovery envelope.`,l=Wt(t).trim()||"Inspect the diagnostic code and retry with corrected input.",f=Math.max(1,s*4-Buffer.byteLength(`${u}${_}`,"utf8")),m=d?`${u}${L(l,f)}${_}`:a;return{output:m,diagnostic_output:{diagnostic_class:o,format:"text",budget:s,budget_source:i===void 0?"default":"explicit",original_estimated_tokens:c,estimated_tokens:$(Buffer.byteLength(m,"utf8")),truncated:d,degradation_steps:d?[...r.degradation_ladder]:["full"],omitted_fields:d?["explanation","collections"]:[]}}}var Ye=Object.freeze({required:"Adjust command input or tracker state and retry.",why:Object.freeze(["pm enforces explicit, deterministic contracts for data and command semantics.","Commander validates CLI contracts before execution.","Unexpected runtime failures can occur from environment or extension-level issues.","Validation protects data consistency and deterministic behavior across commands.","Required options define command intent and enforce deterministic write contracts."]),examples:Object.freeze(["pm --help","pm <command> --help"])});function Sa(e){return e?.trim()===Ye.required}function xa(e){let t=e?.trim();return t!==void 0&&Ye.why.includes(t)}function Ca(e){return(e??[]).filter(t=>!Ye.examples.includes(t.trim()))}var Ia=Object.freeze(["attempted_command","normalized_args","provided_fields"]);function ja(e){if(!e)return;let{attempted_command:t,normalized_args:n,provided_fields:o,...r}=e;return Object.values(r).some(i=>i!==void 0)?r:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a351971-6cfb-55eb-a266-3fec0af9eaa4")}catch{}})();var S=Object.freeze({comments:Object.freeze({paths:Object.freeze(["comments"]),total_key:"total_count"}),notes:Object.freeze({paths:Object.freeze(["notes"]),total_key:"total_count",delivered_row_counters:Object.freeze([Object.freeze({key:"structured_event_count",field:"format",equals:"json"})])}),learnings:Object.freeze({paths:Object.freeze(["learnings"]),total_key:"total_count"})});function B(e,t){return e===void 0?!1:(Object.hasOwn(S,e)?S[e]:void 0)?.paths.includes(t)===!0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a65d6520-0e6f-5627-a4dd-bd455c2db0fa")}catch{}})();var Zt=new WeakMap;function Ua(e,t){Zt.set(e,new Set(t))}var Ce='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',mr={context:{row_keys:["high_level","low_level"],fields:"supported"},get:{row_keys:["children"],fields:"supported"},list:{row_keys:["items"],fields:"supported"},next:{row_keys:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],fields:"unsupported"},search:{row_keys:["items"],fields:"supported"},activity:{row_keys:["activity_digest","compact_activity","provenance_activity","activity"],fields:"unsupported"},history:{row_keys:["compact_history","provenance_history","history","diff"],fields:"unsupported"},deps:{row_keys:["graph.nodes","graph.edges","context.nodes","context.edges"],fields:"unsupported"},health:{row_keys:["checks"],fields:"unsupported"},aggregate:{row_keys:["groups"],fields:"unsupported"},duplicates:{row_keys:["clusters"],fields:"unsupported"},stats:{row_keys:["by_type","by_status"],fields:"unsupported"},comments:{row_keys:["comments"],fields:"unsupported"},notes:{row_keys:["notes"],fields:"unsupported"},learnings:{row_keys:["learnings"],fields:"unsupported"},files:{row_keys:["files"],fields:"unsupported"},docs:{row_keys:["docs"],fields:"unsupported"},validate:{row_keys:["checks","warnings"],fields:"unsupported"},contracts:{row_keys:["command_summaries","commands"],fields:"unsupported"}},pr=[{command:"activity",complete_mode:"full",omissions_by_mode:{digest:[{name:"event_rows",restore_with:"--raw"}],compact:[{name:"provenance",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}},{command:"history",complete_mode:"full",omissions_by_mode:{compact:[{name:"raw_history",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}}];function La(e,t,n){if(e&&t)throw new h(`${n} cannot be combined with --full`,y.USAGE)}function x(e,t=new Set){let n=e.filter(o=>!t.has(o.name)).map(o=>({...o}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function $a(e,t){let n=pr.find(r=>r.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return x([]);let o=n.omissions_by_mode[t];if(o===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return x(o)}var gr=[{name:"hierarchy",restore_with:"--section hierarchy"},{name:"activity",restore_with:"--section activity"},{name:"progress",restore_with:"--section progress"},{name:"blockers",restore_with:"--section blockers"},{name:"recently_created",restore_with:"--section recently_created"},{name:"unparented",restore_with:"--section unparented"},{name:"files",restore_with:"--section files"},{name:"workload",restore_with:"--section workload"},{name:"staleness",restore_with:"--section staleness"},{name:"tests",restore_with:"--section tests"}];function R(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var yr=new Set([void 0,"tabular_when_uniform"]),hr=new Set(["collection","none"]),br=new Set(["supported","unsupported"]);function Xt(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function wr(e){return R(e)&&typeof e.command=="string"&&e.command.trim().length>0&&hr.has(e.row_kind)&&Xt(e.row_keys,!0)&&(e.continuation_row_keys===void 0||Xt(e.continuation_row_keys,!1))&&br.has(e.fields)&&yr.has(e.toon_encoding)&&(e.row_kind==="collection"?e.row_keys.length>0&&typeof e.jq_selector=="string"&&e.jq_selector.trim().length>0:e.row_keys.length===0&&e.jq_selector===void 0)}var Or={ancestors:["ids"],descendants:["ids"],predecessors:["ids"],successors:["ids"],paths:["paths"],impact:["affected"],audit:["findings"],communities:["communities"],redundancy:["redundant"],dominators:["bottlenecks"],slack:["rows"],centrality:["rows"],articulation:["articulation_points","bridges"],plan:["steps"]},vr={context:["sections_included","high_level","low_level"],get:["item"],list:["items","projection"],next:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items","projection"],activity:["activity_digest","compact_activity","provenance_activity","activity"],history:["compact_history","provenance_history","history","diff"],deps:["tree","graph","projection"],health:["checks"],aggregate:["groups"],duplicates:["clusters"],stats:["totals","by_type","by_status"],comments:["comments"],notes:["notes"],learnings:["learnings"],files:["files"],docs:["docs"],validate:["checks","warnings"],contracts:["command_summaries","commands","selected"]};function kr(e,t){let n=e.trim().toLowerCase().split(/\s+/u,1)[0],o=n?.startsWith("list-")?"list":n;if(o==="graph"){let s=typeof t.subcommand=="string"?t.subcommand:"";if(s.length===0)return;let a=Or[s];if(a===void 0)return;let c=a.filter(d=>Array.isArray(t[d])||R(t[d]));return{command:"graph",row_kind:c.length>0?"collection":"none",row_keys:c,fields:"unsupported",...c.length>0?{jq_selector:Ce}:{},toon_encoding:"tabular_when_uniform"}}let r=mr[o],i=vr[o];return r===void 0||i===void 0||!i.some(s=>Object.hasOwn(t,s))?void 0:(()=>{let s=r.row_keys.filter(a=>{let c=a.split(".").reduce((d,u)=>R(d)?d[u]:void 0,t);return Array.isArray(c)||R(c)});return{command:o,row_kind:s.length>0?"collection":"none",row_keys:s,fields:r.fields,...s.length>0?{jq_selector:Ce}:{},toon_encoding:"tabular_when_uniform"}})()}function Er(e){if(!R(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;let t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;let o=t.filter(s=>R(s)&&typeof s.name=="string"&&s.name.trim().length>0&&typeof s.restore_with=="string"&&s.restore_with.trim().length>0),r=n.filter(s=>typeof s=="string");if(o.length!==t.length||r.length!==n.length)return;let i=new Set(o.map(s=>s.name));if(!(i.size!==o.length||new Set(r).size!==r.length||r.some(s=>!i.has(s))))return x(o,new Set(r))}function Ar(e){if(!Array.isArray(e.sections_included))return;let t=x(gr,new Set(e.sections_included.filter(n=>typeof n=="string")));return R(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function Rr(e,t,n){if(e==="dependency_provenance")return!1;let o=en(e);if(o!==void 0){let r=n[o.facet];return R(r)&&Object.hasOwn(r,o.member)}return Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&R(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&R(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function en(e){let t=e.indexOf(".");return t===-1?void 0:{facet:e.slice(0,t),member:e.slice(t+1)}}function Tr(e){if(!R(e.item))return;let t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],o=["body","children","claim_state","linked","schedule"],r=Zt.get(e),i=a=>n.includes(a)||a==="body"||a==="dependency_provenance"?t:e,s=["body",...n,...o.slice(1),...r?.has("dependency_provenance")?["dependency_provenance"]:[],...r?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[],...[...r??[]].filter(a=>en(a)!==void 0)].filter(a=>r===void 0||r.has(a)||Object.hasOwn(i(a),a)).map(a=>({name:a,restore_with:a==="blockers"?"--full":a==="dependency_provenance"?"--fields dependencies":`--fields ${a}`}));return x(s,new Set(s.flatMap(({name:a})=>Rr(a,i(a),e)?[a]:[])))}function Qt(e){if(R(e.projection))return x([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function Sr(e){if(!R(e.projection))return x([]);if(typeof e.projection.mode=="string")return x([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function xr(e){if(!(!R(e.selected)||typeof e.selected.summary!="boolean"))return x([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function Cr(e,t){let n=Er(t);if(n!==void 0)return n;let[o]=e.split(/\s+/u,1);if(o==="context")return Ar(t);if(o==="get")return Tr(t);if(o==="list"||o.startsWith("list-"))return Qt(t);if(o==="search")return Qt(t)??x([{name:"projection_metadata",restore_with:"--full"}]);if(o==="health")return Sr(t);if(o==="contracts")return xr(t)}function tn(e,t){if(e===void 0||!R(t))return t;let n=Cr(e,t),o=t.row_contract,r=wr(o)?o:kr(e,t),i=r!==void 0?{...t,row_contract:r}:Object.hasOwn(t,"row_contract")?Object.fromEntries(Object.entries(t).filter(([s])=>s!=="row_contract")):t;return R(i.omission_receipt)||n===void 0?i:{...i,omission_receipt:n}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e1fd9abd-a586-5302-940e-eec2a3eb8641")}catch{}})();function Xe(e){let t=e.trim().toLowerCase().startsWith("extension:"),n=e.trim().toLowerCase().replace(/^extension:/u,"");if(Ae(n))return;let o=qt()?.commands??[],r=[...o].reverse().find(s=>s.command===n)?.command??(t?void 0:o.find(s=>s.action===n)?.command),i=[...o].reverse().find(s=>s.command===r);return i===void 0||Ae(i.command)||Ae(i.action)?void 0:i}function Ir(e){let t=Xe(e);return t?.read_output===void 0?void 0:t}function jr(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new h("Read-only extension commands must return a structured object.",y.USAGE,{code:"extension_read_output_invalid"});for(let n of e.row_keys){let o=t;for(let r of n.split("."))o=typeof o=="object"&&o!==null&&Object.hasOwn(o,r)?Reflect.get(o,r):void 0;if(o===null||typeof o!="object")throw new h(`Read-only extension result is missing declared row collection ${n}.`,y.USAGE,{code:"extension_read_output_invalid",required:`Return ${n} as an object or array (an empty collection is valid); an output_format service renders the compact receipt from it.`,why:"A command that declares read_output.row_keys promises those row collections, and pm checks them before projection, budgeting or custom formatting."})}}function nn(e,t){let n=Ir(e),o=n?.read_output;return o===void 0?t:(jr(o,t),{...t,row_contract:{command:`extension:${n.command}`,row_kind:o.row_keys.length>0?"collection":"none",row_keys:[...o.row_keys],fields:"supported",...o.row_keys.length>0?{jq_selector:Ce}:{},toon_encoding:"tabular_when_uniform"}})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="040fff2e-c66f-5091-9ea8-7dcdaf6e203b")}catch{}})();var Qe={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded","--after"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},learnings:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},duplicates:{amount:["--limit"]},"package-catalog":{},"package-manage":{},"comments-audit":{},assurance:{}},Ze=new Set(["--collapse","--fields","--section"]),Ie=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded --output-budget unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function je(e){return e.slice(2).replaceAll("-","_")}function on(e,t={}){let n=e==="package catalog"||e==="packages catalog"||e==="package-catalog"||(e==="package"||e==="packages"||e==="extension")&&(t.catalog===!0||t.target==="catalog"||t.action==="catalog")?"package-catalog":e==="package manage"||e==="package-manage"?"package-manage":e.split(" ")[0],o=n.startsWith("list-")?"list":n==="ctx"?"context":n;return se.includes(o)?o:void 0}function et(e){return new Map((Qe[e]?.include??[]).filter(t=>!Ze.has(t)&&Ie[t]===void 0).map(t=>[je(t),tt(t)]))}function tt(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2335ae7f-c7aa-5bdd-ac2e-e6d7a74be2e1")}catch{}})();var De="changed_fields",Dr="changed_field_count",nt="rows",Nr=new Set(["apply","rollback"]),cn=new Set(["deleted","would_delete"]),rn=256,sn={start_task:["claim","update"],pause_task:["update","release"],close_task:["close","release"]};function Pr(e,t){if(!T(e)||typeof e.action!="string"||typeof e.id!="string"||e.id.length===0)return null;let n=Object.hasOwn(sn,e.action)?sn[e.action]:void 0;if(!n||!n.every(i=>{let s=e[i];return T(s)&&T(s.item)&&s.item.id===e.id&&Array.isArray(s.changed_fields)&&s.changed_fields.every(a=>typeof a=="string")}))return null;let o=e[n.at(-1)],r=dn(o);return t.idOnly?r:!t.compactEnvelope&&t.changedFields!=="compact"?null:{...e,...t.compactEnvelope?{...r,changed_field_count:new Set(n.flatMap(i=>e[i].changed_fields)).size}:{},...Object.fromEntries(n.map(i=>[i,ln(e[i],t)]))}}function an(e){return typeof e!="string"||e.length<=rn?e:`${Re(e,rn-1)}\u2026`}function Mr(e){if(!T(e))return null;let t={...e};return t.reason=an(t.reason),T(t.previous_terminal)&&(t.previous_terminal=Object.fromEntries(Object.entries(t.previous_terminal).map(([n,o])=>[n,an(o)]))),t}function T(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function un(e){let t=e[De];if(!Array.isArray(t))return null;let n=Object.getPrototypeOf(e)===null?Object.create(null):{};for(let[o,r]of Object.entries(e))o!==De&&(n[o]=r);return n[Dr]=t.length,n}function Ur(e){return"item"in e&&Array.isArray(e[De])}function Lr(e){return typeof e.mode=="string"&&Nr.has(e.mode)&&Array.isArray(e[nt])}function $r(e,t){let n=Object.getPrototypeOf(e)===null?Object.create(null):{};return Object.assign(n,e),n[nt]=t,n}function dn(e){if(!T(e))return null;let t=T(e.item)?e.item:T(e.plan)?e.plan:null;if(t===null)return null;let n=typeof t.id=="string"?t.id:void 0,o=typeof e.outcome=="string"&&cn.has(e.outcome)?e.outcome:typeof t.status=="string"?t.status:void 0;return n?o?{id:n,status:o,...typeof e.deleted=="boolean"?{deleted:e.deleted}:{}}:{id:n}:null}function Br(e,t){if(!T(e))return null;if(T(e.plan)&&T(e.mutation_receipt)&&e.mutation_receipt.kind==="plan_mutation"&&e.mutation_receipt.id===e.plan.id&&e.mutation_receipt.action===e.action)return e.mutation_receipt;if(!t||!T(e.item)||typeof e.item.id!="string")return null;let n=e[De];if(!Array.isArray(n))return null;let o={id:e.item.id,...typeof e.outcome=="string"&&cn.has(e.outcome)?{status:e.outcome}:typeof e.item.status=="string"?{status:e.item.status}:{},...typeof e.deleted=="boolean"?{deleted:e.deleted}:{},...typeof e.previous_status=="string"?{previous_status:e.previous_status}:{},changed_field_count:n.length};return Fr(e,e.item,o),o}function Fr(e,t,n){let o=typeof e.close_reason=="string"?e.close_reason:typeof t.close_reason=="string"?t.close_reason:void 0;o!==void 0&&(n.close_reason=o);let r=Mr(e.recurrence);r!==null&&(n.recurrence=r),Array.isArray(e.warnings)&&e.warnings.length>0&&(n.warnings=e.warnings);for(let i of["recovery","follow_up","handoff","completion","start"])T(e[i])&&(n[i]=e[i]);if(typeof e.claimed_by=="string"||typeof e.released_by=="string")for(let i of["claimed_by","released_by","previous_assignee","forced","skipped","available","attempts","start_refused","suggestions"])Object.hasOwn(e,i)&&(n[i]=e[i])}function Gr(e){let t=Lr(e)?e[nt]:void 0;if(!Array.isArray(t))return{projected:e,changed:!1};let n=!1,o=t.map(r=>{if(!T(r))return r;let i=un(r);return i?(n=!0,i):r});return n?{projected:$r(e,o),changed:!0}:{projected:e,changed:!1}}function ln(e,t={}){let n=Pr(e,t);if(n!==null)return n;if(t.idOnly===!0){let a=dn(e);if(a!==null)return a}if(t.compactEnvelope===!0||t.changedFields==="compact"){let a=Br(e,t.compactEnvelope===!0);if(a!==null)return a}if((t.changedFields??"full")==="full"||!T(e))return e;let o=!1,r=e,i=Ur(e)?un(e):null;i!==null&&(r=i,o=!0);let s=Gr(r);return s.changed&&(r=s.projected,o=!0),o?r:e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1f8bc22d-02b9-522a-a2cd-0d34bf6e3ec3")}catch{}})();import{AsyncLocalStorage as Ai}from"node:async_hooks";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9bb3b2ed-c289-5b96-99ce-9df6e202c464")}catch{}})();var fn=new Set(["--pm-path","--path","--author","--expect-hash","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),qr=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function zr(e){let t=e.indexOf("=");return t>0&&fn.has(e.slice(0,t))}function Wr(e,t){return typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-")}function _n(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(fn.has(n)){t+=Wr(n,e[t+1])?1:0;continue}if(!(zr(n)||qr.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function Qa(e){let t=_n(e);return t===void 0?void 0:e[t].trim().toLowerCase()}import Kr from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7f08c44a-dfdf-5c23-8f68-0e3ed73582b0")}catch{}})();var ot=new WeakMap;function _c(e){ot.set(e,e.path)}function Vr(e){if(!process.env.PM_PATH?.trim())return;let t=Lt(e);return Mt($t(t),e)&&t===Ut(e)?void 0:Kr.relative(e,t)||"."}function mc(e,t=process.cwd()){let n=ot.has(e)?ot.get(e):e.path,o=n?.trim()?n:Vr(t),r=o?["--pm-path",o]:[];return e.noExtensions&&r.push("--no-extensions"),r}import{createHash as si}from"node:crypto";import{createHash as Zr}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f539ecb5-2f49-5867-96c7-48eddb81a628")}catch{}})();var Hr=new Set(["applied_bound","completeness","budget_retention_policy","continuation_contract","continuation_kind","continuation_path","filters","omission_receipt","output_budget_truncation","projection","read_output","read_session","row_contract","sorting"]);function E(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mn(e,t){let n=e;for(let o of t.split("."))if(Array.isArray(n)){if(!/^\d+$/u.test(o))return;n=n[Number(o)]}else{if(!E(n))return;n=n[o]}return n}function rt(e,t,n){let o=t.split("."),r=(i,s)=>{if(s===o.length)return n;let a=o[s];if(Array.isArray(i)){let d=Number(a),u=[...i];return u[d]=r(i[d],s+1),u}let c=i;return{...c,[a]:r(c[a],s+1)}};return r(e,0)}function it(e,t,n,o){let r=Y(e).find(a=>a.path===t);if(!r)return e;let i=Array.isArray(r.value)?r.value.slice(n,o):Object.fromEntries(Object.entries(r.value).slice(n,o)),s=rt(e,t,i);return E(s.summary)&&E(s.summary.focus_row_states)&&typeof s.summary.focus_row_states[t]=="string"&&(s.summary={...s.summary,focus_row_states:{...s.summary.focus_row_states,[t]:s.summary.focus_row_states[t].slice(n,o)}}),de(s),s}function Pe(e){let t=e.row_contract;return E(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function Jr(e){let t=e.row_contract;return E(t)&&Array.isArray(t.continuation_row_keys)?t.continuation_row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Pe(e)}function D(e){return Pe(e).flatMap(t=>{let n=mn(e,t);return Array.isArray(n)||E(n)?[{path:t,value:n}]:[]})}function Y(e){return Jr(e).flatMap(t=>{let n=mn(e,t);return Array.isArray(n)||E(n)?[{path:t,value:n}]:[]})}function ce(e){let t=D(e),n=new Set(t.map(r=>r.path)),o=(r,i)=>{if(Array.isArray(r)){n.has(i)||t.push({path:i,value:r}),r.forEach((s,a)=>o(s,`${i}.${a}`));return}if(E(r))for(let[s,a]of Object.entries(r))i.length===0&&Hr.has(s)||o(a,i.length===0?s:`${i}.${s}`)};return o(e,""),t}function X(e){return D(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function ue(e,t){let n=e;for(let o of D(n)){let r=Array.isArray(o.value)?o.value.map((i,s)=>t(i,o.path,s)):Object.fromEntries(Object.entries(o.value).map(([i,s],a)=>[i,t(s,o.path,a)]));n=rt(n,o.path,r)}return n}function pn(e,t,n=()=>!1){let o=e,r=!1;for(let i of D(o)){let s=Array.isArray(i.value)?i.value:Object.entries(i.value);if(s.length<=t)continue;r=!0;let a=n(i.path)?s.length-t:0,c=s.slice(a,a+t),d=Array.isArray(i.value)?c:Object.fromEntries(c);o=rt(o,i.path,d)}return{result:o,truncated:r}}var gn=["high_level","low_level","blocked_fallback"];function Ne(e){let t=e.status==="in_progress"?"i":"o";return e.blocked===!0?t.toUpperCase():t}function gc(e,t){if(!E(e.summary)||!E(e.summary.returned_focus))return;let n=new Map(t.map(o=>[o.id,o]));e.summary={...e.summary,focus_row_states:Object.fromEntries(gn.map(o=>[o,Array.isArray(e[o])?e[o].filter(E).map(r=>Ne(n.get(r.id)??r)).join(""):""]))}}function Yr(e,t){if(e!==void 0){if(typeof e!="string"||e.length!==t||!/^[iIoO]*$/u.test(e))throw new TypeError("Context focus classification receipt must contain one i/I/o/O code per delivered record");return e}}function Xr(e,t,n,o){let r=Array.isArray(t[n])?t[n].filter(E):[],i=Yr(o[n],r.length)??r.map(Ne).join(""),s=new Map(r.flatMap((d,u)=>d.id===void 0?[]:[[d.id,i[u]]])),a=Array.isArray(e[n])?e[n].filter(E):[],c=!1;return{states:a.map((d,u)=>{let _=s.get(d.id)??(d.id===void 0?i[u]:void 0)??Ne(d);return _!==Ne(d)&&(c=!0),_}).join(""),needsStates:c}}function Qr(e,t){typeof e.count=="number"&&(e.count_only===!0||t.count_only===!0?typeof t.count=="number"&&(e.count=t.count):Array.isArray(e.items)&&(e.count=e.items.length))}function de(e,t=e){if(Qr(e,t),!E(e.summary)||!E(e.summary.returned_focus))return;let n={...e.summary},o=E(t.summary)&&E(t.summary.focus_row_states)?t.summary.focus_row_states:{},r=gn.map(c=>({key:c,...Xr(e,t,c,o)})),i=Object.fromEntries(r.map(({key:c,states:d})=>[c,d])),s=r.some(c=>c.needsStates),a=Object.values(i).join("");typeof n.high_level=="number"&&(n.high_level=Array.isArray(e.high_level)?e.high_level.length:0),typeof n.low_level=="number"&&(n.low_level=Array.isArray(e.low_level)?e.low_level.length:0),n.returned_focus={active_items:a.length,in_progress:[...a].filter(c=>c.toLowerCase()==="i").length,open:[...a].filter(c=>c.toLowerCase()==="o").length,blocked:[...a].filter(c=>c===c.toUpperCase()).length},s?n.focus_row_states=i:delete n.focus_row_states,e.summary=n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e8cd9862-6b60-599e-9a19-b97fd7b1ce1f")}catch{}})();var ei=4096,ti=Object.freeze(["queue_draining","queue_entries","queue_exists","queue_high_retry_entries","queue_invalid_rows","queue_max_attempts","queue_rows_total","queue_size_bytes","pending_otel_spans","last_attempted_flush_at","last_failed_flush_at","last_otel_attempt_at","last_otel_failure_at","last_otel_success_at","last_successful_flush_at"]),hn=Object.freeze({health:Object.freeze({version:3,paths:Object.freeze(["checks"]),ignored_detail_field_names_by_row:Object.freeze({telemetry:ti}),guarantee:"nonvolatile_snapshot_and_stable_configuration"})});function Q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function bn(e,t,n=e,o){let r=Object.hasOwn(S,t)?S[t]:void 0;if(r?.delivered_row_counters===void 0)return;let i=r.paths[0],s=e[i],a=n[i];if(!Array.isArray(s)||!Array.isArray(a))return;let c=o??a.length,d=a.slice(Math.max(0,c-s.length),c);for(let u of r.delivered_row_counters)typeof e[u.key]=="number"&&(e[u.key]=d.filter(_=>Q(_)&&_[u.field]===u.equals).length)}function le(e){return Array.isArray(e)?e.map(le):Q(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,le(n)])):e}function yn(e,t){if(!Q(e))return le(e);let n=typeof e.name=="string"?e.name:void 0,o=n!==void 0&&Object.hasOwn(t.ignored_detail_field_names_by_row,n)?t.ignored_detail_field_names_by_row[n]:void 0;return Object.fromEntries(Object.entries(e).map(([r,i])=>r!=="details"||!o||!Q(i)?[r,le(i)]:[r,Object.fromEntries(Object.entries(i).filter(([s])=>!o.includes(s)).map(([s,a])=>[s,le(a)]))]))}function ni(e,t){return Array.isArray(e)?e.map(n=>yn(n,t)):yn(e,t)}function Me(e,t,n){let o=n?hn[n]:void 0,r=o?.paths.includes(e)===!0;return Zr("sha256").update(ve({path:e,value:r?ni(t,o):t,...r?{fingerprint_policy_version:o.version}:{}})).digest("base64url").slice(0,16)}function st(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint,...e.direction==="backward"?{d:"b"}:{}}),"utf8").toString("base64url")}function oi(e){return typeof e=="string"&&(F(e)===e||/^extension:\S(?:[^\r\n]*\S)?$/u.test(e))}function ri(e){return e===void 0||e==="b"}function ii(e){if(Se(e))throw new h("The read-output continuation cursor was shortened by output compaction: it contains an ellipsis, which no cursor encoder emits.",y.USAGE,{code:"read_output_cursor_invalid",reason:"cursor_compacted",required:"Pass the whole cursor the previous page emitted; a shortened cursor cannot resume the read.",nextSteps:["Re-read the previous page with a larger --output-budget (or --output-budget unbounded) and pass its whole output_cursor to --output-cursor."]})}function fe(e){if(ii(e),e.length>ei)throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!Q(t)||t.v!==1||!oi(t.c)||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0||!ri(t.d))throw new h("The read-output continuation cursor is malformed or unsupported.",y.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f,...t.d==="b"?{direction:"backward"}:{}}}function wn(e){if(!Array.isArray(e.assertions))return e;let t=n=>!Q(n)||n.verdict==="pass"?4:n.verdict==="retired"?3:n.enforcement==="block"?0:n.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((n,o)=>({row:n,index:o})).sort((n,o)=>t(n.row)-t(o.row)||n.index-o.index).map(({row:n})=>n),budget_retention_policy:"verdict_priority"}}function On(e,t,n){if(!n)return e;if(n.command!==t)throw new h(`The read-output cursor belongs to ${n.command}, not ${t}.`,y.USAGE,{code:"read_output_cursor_command_mismatch"});let o=Y(e).find(c=>c.path===n.path),r=o?Array.isArray(o.value)?o.value.length:Object.keys(o.value).length:0,i=B(t,n.path);if(!o||r!==n.total_rows||n.offset>r||i!==(n.direction==="backward")||Me(n.path,o.value,t)!==n.fingerprint)throw new h("The read-output continuation no longer matches the declared row collection; restart the bounded read.",y.USAGE,{code:"read_output_cursor_stale"});if(!i)return it(e,n.path,n.offset);let s=it(e,n.path,0,n.offset);for(let c of["count","returned_count"])typeof s[c]=="number"&&(s[c]=n.offset);let a=S[t].total_key;return typeof s[a]!="number"&&(s[a]=n.total_rows),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9c5d8732-3e10-5224-a558-e870397090f2")}catch{}})();var ct=1,vn=4096,ai=/^[A-Za-z0-9_-]+$/;function at(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function Nc(e,t){let n=[...Object.values(ke),...Ee],o=new Set(n.flatMap(r=>[at(r),r.slice(2).replaceAll("-","_")]));for(let r of t)if(r.cursor_semantics==="presentation"){o.add(at(r.flag));for(let i of r.aliases??[])o.add(at(i))}return Object.fromEntries(Object.entries(e).filter(([r])=>!o.has(r)))}function Pc(e,t){return si("sha256").update(e).update("\0").update(ve(t)).digest("hex").slice(0,24)}function _e(e,t,n,o){return Buffer.from(JSON.stringify({version:ct,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...o===void 0?{}:{snapshot:o}})).toString("base64url")}function G(e,t){return new h(e,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${t} to obtain a fresh cursor.`]})}function ci(e){return new h("Query cursor was shortened by output compaction: it contains an ellipsis, which no cursor encoder emits.",y.USAGE,{code:"invalid_query_cursor",reason:"cursor_compacted",required:"Pass the whole cursor the previous page emitted; a shortened cursor cannot resume the query.",nextSteps:[`Re-read the previous page with a larger --output-budget (or --output-budget unbounded) and pass its whole next_cursor to ${e}.`,`Or repeat the original query without ${e} to obtain a fresh cursor.`]})}function ui(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===ct&&typeof t.fingerprint=="string"&&typeof t.after_id=="string"&&t.after_id.length>0&&(t.after_index===void 0||Number.isSafeInteger(t.after_index)&&t.after_index>=0)&&(t.snapshot===void 0||typeof t.snapshot=="string"&&t.snapshot.length>0)}function ut(e,t="--after"){if(typeof e!="string")throw G("Query cursor is malformed.",t);let n=e.trim();if(Se(n))throw ci(t);if(n.length===0||n.length>vn||!ai.test(n))throw G("Query cursor is malformed.",t);let o;try{o=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw G("Query cursor is malformed.",t)}if(!ui(o)){let r=!1;try{fe(n),r=!0}catch{}throw r?new h(`An output cursor must be continued with --output-cursor, not ${t}.`,y.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${t} with --output-cursor ${n}; retain any producer ${t} cursor from the original page.`]}):G("Query cursor version or payload is unsupported.",t)}return o}function dt(e,t,n="--after"){let o=ut(e,n);if(o.fingerprint!==t)throw G(`Query cursor does not match the current filters, sort, or query (${o.fingerprint} != ${t}).`,n);return{after_id:o.after_id,...o.after_index===void 0?{}:{after_index:o.after_index},...o.snapshot===void 0?{}:{snapshot:o.snapshot}}}function Mc(e,t){return dt(e,t).after_id}function di(e,t,n,o,r="--after"){if(t===void 0)return 0;let i=dt(t,n,r),s=e.findIndex(a=>o(a)===i.after_id);if(s<0){if(i.after_index!==void 0)return Math.min(i.after_index,e.length);throw G(`Query cursor item ${i.after_id} is no longer present in this result set.`,r)}return s+1}function Uc(e,t){if(t.cursor!==void 0&&dt(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw G("Query cursor does not match the requested snapshot.","--after");let n=di(e,t.cursor,t.fingerprint,t.readId),o=e.slice(n,n+t.limit),r=o.length>0&&n+o.length<e.length,i=o.at(-1);return{rows:o,has_more:r,...r&&i!==void 0?{next_cursor:_e(t.fingerprint,t.readId(i),n+o.length-1,t.snapshot)}:{}}}var Lc=Object.freeze({version:ct,max_length:vn});import{randomUUID as pi}from"node:crypto";import{randomUUID as li}from"node:crypto";import{constants as Z}from"node:fs";import{lstat as kn,mkdir as fi,open as An,rename as _i,rm as mi}from"node:fs/promises";import Ue from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71b65888-baa5-5c5f-a02c-4a0fd818fadb")}catch{}})();var I={max_serving_rows:256,max_bytes:262144,max_event_bytes:32768,retained_byte_fraction:.5,max_events:2048,retention_days:30},k=class extends TypeError{code="context_usage_validation_failed";constructor(t){super(t),this.name="ContextUsageValidationError"}};function q(e){let t=Date.parse(e.now??new Date().toISOString());if(!Number.isFinite(t))throw new k("Context usage now must be a valid timestamp");return{iso:new Date(t).toISOString(),ms:t}}function Rn(e){let t=e.maxBytes??I.max_bytes,n=e.maxEvents??I.max_events,o=e.retentionDays??I.retention_days;if(!Number.isSafeInteger(t)||t<1024||t>I.max_bytes||!Number.isSafeInteger(n)||n<1||!Number.isFinite(o)||o<=0)throw new k("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");return{maxBytes:t,maxEvents:n,cutoff:q(e).ms-o*864e5}}async function Tn(e,t){if(!(await kn(Ue.dirname(e))).isDirectory())throw new k("Context usage runtime must be a real directory");try{if((await kn(e)).isSymbolicLink())throw new k("Context usage ledger must not be a symbolic link")}catch(o){if(!Pt(o))throw o}let n=await An(e,t|Z.O_NOFOLLOW|Z.O_NONBLOCK,384);try{let o=await n.stat();if(!o.isFile()||o.nlink!==1)throw new k("Context usage ledger must be an unshared regular file");return n}catch(o){throw await n.close(),o}}async function Le(e){let t=Rn(e);try{let n=await Tn(Ue.join(e.pmRoot,"runtime","context-usage.jsonl"),Z.O_RDONLY);try{let o=(await n.stat()).size,r=Math.max(0,o-t.maxBytes),i=Buffer.alloc(Math.min(o,t.maxBytes)),{bytesRead:s}=await n.read(i,0,i.length,r),a=i.subarray(0,s).toString("utf8");return(r>0?a.includes(`
|
|
8
|
+
`)?a.slice(a.indexOf(`
|
|
9
|
+
`)+1):"":a).split(`
|
|
10
|
+
`).flatMap(c=>{try{let d=JSON.parse(c);return d&&Date.parse(d.at)>=t.cutoff?[d]:[]}catch{return[]}}).slice(-t.maxEvents)}finally{await n.close()}}catch{return[]}}function En(e,t,n){let o=[],r=0;for(let i=e.length-1;i>=0&&o.length<n;i-=1){let s=`${JSON.stringify(e[i])}
|
|
11
|
+
`;if(r+=Buffer.byteLength(s),r>t)break;o.push(s)}return o.reverse().join("")}async function me(e,t,n){let o=Rn(e),r=Ue.join(e.pmRoot,"runtime","context-usage.jsonl"),i=Math.floor(o.maxBytes*I.retained_byte_fraction),s=Math.min(I.max_event_bytes,i);if(t.some(l=>Buffer.byteLength(`${JSON.stringify(l)}
|
|
12
|
+
`)>s))throw new k("Context usage event exceeds the declared byte ceiling");let a=t.filter(l=>Date.parse(l.at)>=o.cutoff),c=En(a,i,o.maxEvents),d=performance.now(),u=await Gt(e.pmRoot,"context-usage-ledger",30,`context-usage:${process.pid}`,!1,!1,3e3),_=performance.now()-d;try{await fi(Ue.dirname(r),{recursive:!0});let l=await Tn(r,Z.O_WRONLY|Z.O_CREAT|Z.O_APPEND);try{let f=(await l.stat()).size,m=n===void 0?void 0:await Le(e);if(m?.some(O=>O.kind==="delivery"&&O.serve_id===n))return{written_bytes:0,ledger_bytes:f,compacted:!1,lock_wait_ms:_};if(!(e.maxEvents!==void 0||e.retentionDays!==void 0)&&f+Buffer.byteLength(c)<=o.maxBytes)return await l.writeFile(c,"utf8"),{written_bytes:Buffer.byteLength(c),ledger_bytes:f+Buffer.byteLength(c),compacted:!1,lock_wait_ms:_};let p=En([...m??await Le(e),...a],i,o.maxEvents),g=`${r}.${process.pid}.${li()}.tmp`,b=await An(g,"wx",384);try{try{await b.writeFile(p,"utf8")}finally{await b.close()}return await l.close(),l=void 0,await _i(g,r),{written_bytes:Buffer.byteLength(p),ledger_bytes:Buffer.byteLength(p),compacted:!0,lock_wait_ms:_}}finally{await mi(g,{force:!0})}}finally{await l?.close()}}finally{await u()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e76b38ce-b2aa-589b-9d17-0952eca9e7a2")}catch{}})();var gi=864e5,$e=Symbol.for("@unbrained/pm-cli/context-usage-serving-receipt");function A(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}function Yc(e,t){let n=A(e);n!==null&&t!==null&&(n[$e]=t)}function pe(e,t){let n=A(e),o=A(t),r=n?.[$e];o!==null&&r!==void 0&&(o[$e]=r)}function yi(e){return A(e)?.[$e]??null}function xn(e){let t=A(e);for(let n of["read_output","context_intent"])if(A(t?.[n])?.result_omitted===!0)return!0;return!1}function N(e,t){typeof t=="string"&&t.trim().length>0&&e.add(t.trim())}function Cn(e,t){if(Array.isArray(t))for(let n of t)N(e,A(n)?.id)}function Sn(e,t){if(Array.isArray(t))for(let n of t)N(e,n)}function hi(e,t){let n=A(e.recommended)===null?[]:[e.recommended];for(let o of["ready","decision_needed","gate_needed","containers","blocked","held_by_others"])Array.isArray(e[o])&&n.push(...e[o]);for(let o of n){let r=A(o);N(t,r?.id);for(let i of Array.isArray(r?.blockers)?r.blockers:[])N(t,A(i)?.id);for(let i of Array.isArray(r?.unblocks)?r.unblocks:[])N(t,i)}}function bi(e,t){for(let n of["high_level","low_level","blocked_fallback","recently_created","unparented","activity","progress","blockers","staleness"])Cn(t,e[n]);for(let n of Array.isArray(e.blockers)?e.blockers:[])N(t,A(n)?.blocked_by);wi(e,t)}function wi(e,t){for(let r of Array.isArray(e.hierarchy)?e.hierarchy:[]){let i=A(r);N(t,i?.id),Cn(t,i?.children)}for(let r of["files","workload"])for(let i of Array.isArray(e[r])?e[r]:[])Sn(t,A(i)?.items);let n=A(e.agenda);for(let r of Array.isArray(n?.events)?n.events:[])N(t,A(r)?.item_id);let o=A(e.tests);Sn(t,o?.items_failing)}function Oi(e,t){let n=A(e);if(n===null||xn(e))return[];let o=new Set;return t==="next"?hi(n,o):bi(n,o),[...o]}async function Xc(e){let t=yi(e.result);if(t===null)return!1;let n=xn(e.result);return await vi({pmRoot:e.pmRoot,receipt:t,deliveredItemIds:Oi(e.result,t.surface),resultOmitted:n}),!0}async function Qc(e){if([process.env.PM_CONTEXT_USAGE_DISABLED==="1",e.enabled===!1].includes(!0))return null;if(!e.author.trim()||e.rows.some(r=>!r.id.trim()||!Number.isInteger(r.rank)||r.rank<1))throw new k("Context usage serving requires an author and valid ranked rows");let t=e.rows.map(r=>({id:r.id.trim(),rank:r.rank,included:r.included}));if(new Set(t.map(r=>r.id)).size!==t.length)throw new k("Context usage serving requires unique normalized row ids");let n=t.slice(0,I.max_serving_rows),o={serve_id:pi(),author:e.author.trim(),surface:e.surface,rows:t,recorded_item_ids:n.map(r=>r.id)};return o.storage=await me(e,[{kind:"serve",schema_version:2,serve_id:o.serve_id,at:q(e).iso,author:e.author.trim(),surface:e.surface,profile:e.profile.trim()||"balanced",rows:n,candidate_count:t.length,omitted_row_count:t.length-n.length,result_omitted:!1,packed_item_ids:n.filter(r=>r.included).map(r=>r.id)}]),o}async function vi(e){if(e.receipt===null||process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return;let t=new Set(e.receipt.rows.map(i=>i.id)),n=[...new Set(e.deliveredItemIds.map(i=>i.trim()))];if(n.some(i=>i.length===0||!t.has(i))||e.resultOmitted&&n.length>0)throw new k("Context usage delivery requires emitted ranked ids and zero ids for an omitted result");let o=new Set(e.receipt.recorded_item_ids??e.receipt.rows.map(i=>i.id)),r={kind:"delivery",schema_version:2,serve_id:e.receipt.serve_id,at:q(e).iso,author:e.receipt.author,surface:e.receipt.surface,result_omitted:e.resultOmitted,delivered_item_ids:n.filter(i=>o.has(i))};await me(e,[r],r.serve_id)}async function Zc(e){if(!(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)){if(!e.author.trim()||!e.itemId.trim()||!e.intent.trim())throw new k("Context usage touch requires author, itemId, and intent");await me(e,[{kind:"touch",at:q(e).iso,author:e.author.trim(),item_id:e.itemId.trim(),intent:e.intent.trim()}])}}async function eu(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1||e.itemIds.length===0)return;let t=e.author.trim(),n=e.intent.trim();if(!t||!n)throw new k("Context usage touch requires author and intent");let o=new Set;for(let s of e.itemIds){if(typeof s!="string")throw new k("Context usage touch requires string itemIds");let a=s.trim();if(!a)throw new k("Context usage touch requires non-empty itemId");o.add(a)}let r=q(e).iso,i=[...o].map(s=>({kind:"touch",at:r,author:t,item_id:s,intent:n}));await me(e,i)}function ki(e,t,n,o){return e.find(({entry:r,time:i})=>r.item_id===t&&i>=n&&i-n<=o)?.time}function Ei(e,t){let n=new Map;for(let o of e)o.kind==="delivery"&&o.schema_version===2&&o.author===t&&!n.has(o.serve_id)&&n.set(o.serve_id,o);return n}async function tu(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1"||e.enabled===!1)return{affinity:{},positive_judgments:0,serving_events:0,untrusted_serving_events:0};let t=await Le(e),n=q(e).ms,o=(e.horizonHours??24)*36e5;if(![Number.isFinite(o),o>0].every(Boolean))throw new k("Context usage horizonHours must be positive");let r=e.author.trim(),i=t.filter(l=>l.kind==="touch").filter(l=>l.author===r).map(l=>({entry:l,time:Date.parse(l.at)})),s=new Map,a=0,c=0,d=0,u=Ei(t,r);t.filter(l=>l.kind==="serve").filter(l=>l.author===r).forEach(l=>{if(![l.schema_version===2,!!l.serve_id].every(Boolean)){c+=1;return}a+=1;let f=Date.parse(l.at),m=u.get(l.serve_id),p=new Set(m?.delivered_item_ids??[]);for(let g of l.rows){if(!p.has(g.id))continue;let b=ki(i,g.id,f,o);if(b===void 0)continue;d+=1;let O=Math.max(0,(n-b)/gi);s.set(g.id,(s.get(g.id)??0)+Math.exp(-O/14))}});let _=Math.max(0,...s.values());return{affinity:Object.fromEntries([...s.entries()].map(([l,f])=>[l,_===0?.05:.05+.95*f/_])),positive_judgments:d,serving_events:a,untrusted_serving_events:c}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="100048de-2349-5062-b6c2-7176277ec38d")}catch{}})();var Ri="limit_overridden_by_intent",Mn=Object.freeze([{command:"context",intent:"orient",description:"Bounded active hierarchy, ownership, blockers, and recent progress.",included_field_groups:["summary","focus","hierarchy","blockers","activity"],token_budget:3e3,source:"core"},{command:"context",intent:"handoff",description:"Active ownership, evidence, decisions, and immediate continuation context.",included_field_groups:["summary","focus","in_progress","decisions","activity"],token_budget:2200,source:"core"},{command:"get",intent:"inspect",description:"Standard-depth item metadata, relationships, evidence, and lifecycle state.",included_field_groups:["item","children","claim_state","linked"],token_budget:3200,source:"core"},{command:"list",intent:"triage",description:"A budget-derived page of compact governance, ownership, priority, and blocker rows for triage.",included_field_groups:["identity","governance","ownership","dependencies"],token_budget:3200,source:"core"},{command:"next",intent:"execute",description:"The highest-ranked actionable work with concise ranking evidence.",included_field_groups:["recommended"],token_budget:1200,source:"core"},{command:"search",intent:"discover",description:"A budget-derived page of ranked canonical lineage candidates with compact match evidence.",included_field_groups:["identity","status","lineage","match"],token_budget:1800,source:"core"}]),Un=new Ai;function Ti(){return Un.getStore()??Mn}function mu(e,t){return Un.run(xi(e.workspaceContracts,e.packageContracts),t)}function Si(e,t){let n=e.command.trim().toLowerCase(),o=e.intent.trim().toLowerCase(),r=`${n}:${o}`;if(!/^[a-z0-9][a-z0-9-]*$/.test(n)||!/^[a-z0-9][a-z0-9-]*$/.test(o))throw new TypeError(`Invalid context intent command or name: ${r}`);if(e.description.trim().length===0)throw new TypeError(`Context intent ${r} requires a non-empty description`);if(!Number.isSafeInteger(e.token_budget)||e.token_budget<=0)throw new TypeError(`Context intent ${r} requires a positive integer token_budget`);let i=[...new Set(e.included_field_groups.map(s=>s.trim()).filter(Boolean))];if(i.length===0)throw new TypeError(`Context intent ${r} requires included_field_groups`);return{command:n,intent:o,description:e.description.trim(),included_field_groups:i,token_budget:e.token_budget,source:t}}function xi(e=[],t=[]){let n=[{source:"core",contracts:Mn,allowOverride:!1},{source:"package",contracts:t,allowOverride:!1},{source:"workspace",contracts:e,allowOverride:!0}],o=new Map,r=new Set;for(let i of n){r.clear();for(let s of i.contracts){let a=Si(s,i.source),c=`${a.command}:${a.intent}`;if(r.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);if(r.add(c),!i.allowOverride&&o.has(c))throw new TypeError(`Duplicate context intent declaration: ${c}`);o.set(c,a)}}return[...o.values()].sort((i,s)=>i.command.localeCompare(s.command)||i.intent.localeCompare(s.intent))}function Ln(e,t,n=Ti(),o=[]){let r=e.trim().toLowerCase(),i=t.trim().toLowerCase(),s=n.find(l=>l.command===r&&l.intent===i);if(s)return{...s,source:s.source??"core"};let a=n.filter(l=>l.command===r).map(l=>l.intent);if(a.length===0)return;let c=a.map(l=>{let f=Array.from({length:i.length+1},(m,p)=>p);for(let m=1;m<=l.length;m+=1){let p=f[0];f[0]=m;for(let g=1;g<=i.length;g+=1){let b=f[g];f[g]=Math.min(f[g]+1,f[g-1]+1,p+(l[m-1]===i[g-1]?0:1)),p=b}}return{candidate:l,distance:f[i.length]}}).sort((l,f)=>l.distance-f.distance||l.candidate.localeCompare(f.candidate))[0].candidate,d=[r,...o,"--for",i],u=[r,...o,"--for",c],_=xe(u);throw new h(`Unknown context intent "${i}" for ${r}. Did you mean "${c}"?`,y.USAGE,{code:"unknown_context_intent",reason:"unknown_intent",field:"for",flag:"--for",value:i,required:`Use a declared ${r} intent.`,why:"Intent names are command-local contracts and cannot be inferred from output section names.",nextSteps:[_],recovery:{recovery_mode:"compact",attempted_command:xe(d),allowed_values:[...a].sort(),suggested_retry:_,suggested_retry_args:u}})}function lt(e,t){let n=W(e.limit),o=String(n===void 0?t:Math.min(n,t));return(e.limit===void 0||n!==void 0)&&(e.limit=o),o}var $n={context:(e,t,n,o)=>{e.section===void 0&&e.depth===void 0&&(e.section=t.intent==="handoff"?["activity","progress","blockers"]:["hierarchy","blockers","activity"]),e.depth===void 0&&(e.depth=t.intent==="handoff"?"deep":"standard");let r=Fe(o,e.tokenBudget,t.token_budget),i=Ge("context",t.intent,r,n),s=lt(e,i);e.activityLimit===void 0&&(e.activityLimit=s)},get:e=>{e.depth===void 0&&e.fields===void 0&&(e.depth="standard")},list:(e,t,n,o)=>{e.brief===void 0&&e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.fields="id,title,status,type,priority,parent,assignee,risk,blocked_by");let r=Fe(o,e.tokenBudget,t.token_budget),i=Ge("list",t.intent,r,n);lt(e,i)},next:e=>{e.readyOnly===void 0&&(e.readyOnly=!0)},search:(e,t,n,o)=>{e.compact===void 0&&e.full===void 0&&e.fields===void 0&&(e.compact=!0);let r=Fe(o,e.tokenBudget,t.token_budget),i=Ge("search",t.intent,r,n);lt(e,i)}};function pu(e,t,n=[]){let o=t.tokenBudget??t.token_budget;if(typeof t.for!="string"){if(o!==void 0&&(e==="get"||e==="list"||e==="search"))throw new h("--token-budget requires a declared context intent selected with --for",y.USAGE,{code:"missing_required_option",field:"for",required:"Select a context intent with --for when setting --token-budget.",why:"A token-budget override has no projection contract to constrain without a selected intent.",nextSteps:["Retry with --for <intent> --token-budget <n>, or omit --token-budget."]});if(t.tokenBudget!==void 0||t.token_budget===void 0)return t;let c={...t,tokenBudget:o};return delete c.token_budget,c}let r=Ln(e,t.for,void 0,n),i=ge(t),s=W(o)!==void 0||typeof i=="number",a={...t};return a.tokenBudget===void 0&&o!==void 0&&(a.tokenBudget=o),delete a.token_budget,typeof i=="number"?a.tokenBudget=String(i):a.tokenBudget===void 0&&(a.tokenBudget=String(r.token_budget)),$n[e](a,r,s,i),a}var Ci={context:"bounded_sections",get:"standard_item",list:"bounded_fields_and_rows",next:"bounded_ranked_rows",search:"bounded_ranked_rows"},Be=256;function _t(e){return Array.isArray(e)?e.map(_t):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,typeof n=="string"&&ae(t)?n:_t(n)])):typeof e=="string"?Te(e):e}function W(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function ge(e){let t=e.outputBudget??e.output_budget;return t==="unbounded"?t:W(t)}function Ii(e){return ge(e)===void 0?"--token-budget":"--output-budget"}function Fe(e,t,n){return typeof e=="number"?e:ji(t,n)}function ji(e,t){let n=W(e);if(n===void 0)return t;if(n<Be)throw new h(`Context intent token budget must be at least ${Be}`,y.USAGE,{code:"invalid_argument_value",reason:"below_minimum",field:"tokenBudget",value:String(e),required:`Use an integer token budget of at least ${Be}.`,why:"Smaller ceilings cannot contain the minimum machine-readable intent receipt.",nextSteps:[`Retry with --token-budget ${Be} or omit the override.`]});return n}function Bn(e,t){return e==="context"?e==="context"&&t==="orient"?{overhead:1200,rowCost:600}:{overhead:800,rowCost:500}:{overhead:e==="list"?520:480,rowCost:16}}function Ge(e,t,n,o){if(e==="get"||e==="next")return;let{overhead:r,rowCost:i}=Bn(e,t),s=Math.max(e==="context"?1:2,Math.floor((n-r)/i));return o?s:Math.min(e==="context"?20:100,s)}function K(e,t,n){let o=te(n),r=n.outputRowContract===!0||n.output_row_contract===!0,i=t.estimated_tokens,s=i;for(let a=0;a<gt;a+=1){t.estimated_tokens=i;let c=M(r||!Object.hasOwn(e,"row_contract")?e:Object.fromEntries(Object.entries(e).filter(([d])=>d!=="row_contract")),o);if(c===i)return;i=c,s=Math.max(s,i)}t.estimated_tokens=s}var In={context:["high_level","low_level","blocked_fallback","recently_created","unparented","hierarchy","activity","blockers"],get:["children"],list:["items"],next:["ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items"]};function Fn(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof t.fingerprint!="string"||!Number.isSafeInteger(t.after_index)?void 0:{fingerprint:t.fingerprint,after_index:t.after_index,...typeof t.snapshot=="string"?{snapshot:t.snapshot}:{}}}catch{return}}function Di(e){if(e===null||typeof e!="object")return;if(typeof e.id=="string")return e.id;let t=e.item?.id;return typeof t=="string"?t:void 0}function Ni(e,t,n,o){let r=!1;for(;;){if(K(e,t,o),t.estimated_tokens<=t.token_budget||n.length<=1)return r;let i=Buffer.byteLength(JSON.stringify(n),"utf8"),s=(t.estimated_tokens-t.token_budget)*4;n.splice(-Math.min(n.length-1,Math.max(1,Math.ceil(s/Math.max(1,Math.ceil(i/n.length)))))),r=!0}}function Pi(e,t,n){let o=e.items,r=typeof e.next_cursor=="string",i=r?e.next_cursor:n.after;if(!Array.isArray(o)||typeof i!="string")return!1;let s=Fn(i);if(s===void 0)return!1;let a=o.length,c=[...o],d=!1;for(;;){if(d=Ni(e,t,o,n)||d,!d)return!1;let u=Di(o.at(-1));if(u===void 0)return o.splice(0,o.length,...c),K(e,t,n),!1;if(e.next_cursor=_e(s.fingerprint,u,r?s.after_index-(a-o.length):s.after_index+o.length,s.snapshot),K(e,t,n),t.estimated_tokens<=t.token_budget||o.length<=1)break}return typeof e.count=="number"&&(e.count=o.length),typeof e.applied_limit=="number"&&(e.applied_limit=o.length),!0}function Mi(e,t,n,o){if(e==="list"||e==="search")return Pi(t,n,o);if(e!=="next"||typeof t.next_cursor=="string")return!1;let r=!1;for(;;){if(K(t,n,o),n.estimated_tokens<=n.token_budget)return r;let i=In[e].map(l=>({key:l,rows:Array.isArray(t[l])?t[l]:[]})).filter(({rows:l})=>l.length>0).sort((l,f)=>f.rows.length-l.rows.length||l.key.localeCompare(f.key))[0];if(i===void 0)return r;let s=In[e].reduce((l,f)=>l+(Array.isArray(t[f])?t[f].length:0),0);if(s<=1)return r;let a=Math.min(i.rows.length,s-1),c=Buffer.byteLength(JSON.stringify(i.rows),"utf8"),d=Math.max(1,Math.ceil(c/i.rows.length)),u=(n.estimated_tokens-n.token_budget)*4,_=Math.min(a,Math.max(1,Math.ceil(u/d)));i.rows.splice(-_,_),r=!0}}function jn(e,t,n){if(typeof t.for!="string")return n;let o=e.startsWith("list-")?"list":e;if(!(o in $n))return n;let r=o,i=Ln(r,t.for),s=ge(t),a=Fe(s,t.tokenBudget??t.token_budget,i.token_budget),c={command:r,intent:i.intent,source:i.source,included_field_groups:[...i.included_field_groups],token_budget:a,declared_token_budget:i.token_budget,token_budget_override:a-i.token_budget,estimated_tokens:0,within_budget:!0,degradation:Ci[r],declaration_feasible:!0,result_omitted:!1},d={...n},u=Ge(r,i.intent,c.token_budget,W(t.tokenBudget??t.token_budget)!==void 0||typeof s=="number");if(u!==void 0){let p=W(t.limit),g=p!==void 0&&p<u;c.budget_derived_limit=u,c.binding_constraint=g?"explicit_limit":"token_budget",c.limit_reason=g?"The caller supplied a smaller row limit than the budget-derived ceiling.":"The selected intent token budget constrains the effective row ceiling.",d.budget_derived_limit=u,Gi({builtInCommand:r,intent:i.intent},c,d,t)}let _=Gn.get(t)??0,l=c.token_budget;c.token_budget=l-_;let f=s==="unbounded"?mt(d,c,t):Ui(r,d,c,t);c.declaration_feasible=c.estimated_tokens<=c.declared_token_budget;let m=qn(s,c,f,()=>Wn(e,r,i.intent,{...c,token_budget:l,estimated_tokens:c.estimated_tokens+_},d,t));return c.result_omitted&&(c.estimated_tokens+=_,c.declaration_feasible=c.estimated_tokens<=c.declared_token_budget),c.token_budget=l,m}function mt(e,t,n){let o={...e,context_intent:t};return K(o,t,n),o}function Ui(e,t,n,o){let r=mt(t,n,o);return n.estimated_tokens>n.token_budget&&(n.degradation="recursive_budget_compaction",r=mt(_t(t),n,o)),n.estimated_tokens>n.token_budget&&Mi(e,r,n,o)&&(n.degradation="budget_row_compaction",K(r,n,o)),r}var Gn=new WeakMap;function qn(e,t,n,o){return t.estimated_tokens<=t.token_budget||(t.within_budget=!1,e==="unbounded")?n:(t.degradation="budget_receipt_only",t.result_omitted=!0,typeof e=="number"?{output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},context_intent:t}:{budget_exceeded:{omitted_result:!0,reason:t.token_budget_override===0?"declared_budget_infeasible":"effective_budget_infeasible",restore_with:o()},context_intent:t})}var Li=["applied_limit","completeness","context_intent","count","filters","has_more","now","omission_receipt","projection","row_contract","sorting","total","truncated"];function $i(e,t){if(typeof e.after!="string"||e.after.length===0||ee(t))return t;let n=Fn(e.after)?.fingerprint??"opaque_cursor",o={...t};for(let r of Li)delete o[r];return o.continuation_contract={fingerprint:n,metadata:"reference",restore_with:"omit --after"},o}function P(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Bi(e,t){let n=e==="get"&&P(t.item)&&typeof t.item.id=="string"?t.item.id:e==="search"&&typeof t.query=="string"?t.query:void 0;return n===void 0?"":` ${zn(n)}`}function zn(e){return`'${e.replaceAll("'",`'"'"'`)}'`}function Fi(e){return typeof e.fields=="string"&&e.fields.trim()!==""?` --fields ${zn(e.fields)}`:""}function Gi(e,t,n,o){let r=W(o.limit),i=t.budget_derived_limit;if(r===void 0||r<=i)return;let{overhead:s,rowCost:a}=Bn(e.builtInCommand,e.intent),c=Math.max(t.token_budget,s+a*r);t.limit_reason=`The ${t.token_budget}-token ${e.intent} budget carries ${i} rows, so it reduced the caller's --limit ${r}.`,t.limit_override={flag:"--limit",requested:r,effective:i,...Number.isSafeInteger(c)?{token_budget_for_requested:c,restore_with:`${Ii(o)} ${c}`}:{}};let d=`${Ri}:--limit ${r}->${i}`;n.warnings=Array.isArray(n.warnings)?[...n.warnings,d]:[d],P(n.filters)&&(n.filters={...n.filters,requested_limit:String(r)})}function Wn(e,t,n,o,r,i){let s=Bi(t,r),a=t==="get"?"":` --limit ${o.budget_derived_limit??1}`,{output_budget:c}=ye({effective_budget_tokens:o.token_budget,measured_result_tokens:o.estimated_tokens});return`pm ${e}${s}${Fi(i)} --for ${n} --token-budget ${c}${a}`}function z(e,t){if(P(e))return typeof e[t]=="number"?e[t]:void 0}function Dn(e,t){let n=e;for(let o=0;o<8;o+=1){qi(n);let r=z(n.context_intent,"estimated_tokens"),i=z(n.read_output,"estimated_tokens"),s=z(n.read_session,"spent_this_call_tokens");if(P(n.context_intent)&&n.context_intent.result_omitted!==!0&&K(n,n.context_intent,t),n=pt(n,t),z(n.context_intent,"estimated_tokens")===r&&z(n.read_output,"estimated_tokens")===i&&z(n.read_session,"spent_this_call_tokens")===s)break}return n}function qi(e){let t=e.context_intent;P(t)&&Number(t.estimated_tokens)>Number(t.token_budget)&&(t.within_budget=!1)}function zi(e,t,n){let o=tn(e,nn(e??"",n));if(typeof o!="object"||o===null||Array.isArray(o))return pe(n,o),o;let r=e??"",i=o,s=jn(r,t,i),a=z(s.context_intent,"estimated_tokens"),c=ft(r,t,n,s),d=Nn(t,c,s.context_intent);if(d===void 0)return c;let u={...t};Gn.set(u,d.estimated-Number(a));let _=jn(r,u,i),l=ft(r,u,n,_),f=Nn(t,l,_.context_intent);if(f===void 0)return l;let m={...f.receipt,estimated_tokens:f.estimated};return ft(r,t,n,qn(ge(t),m,l,()=>Wn(r,m.command,m.intent,m,i,t)))}function Nn(e,t,n){let o=P(t.context_intent),r=o?t.context_intent:n;if(!P(r)||r.result_omitted===!0||Object.hasOwn(t,"output_budget_exceeded"))return;let i=r,s=o?i.estimated_tokens:M(t,te(e));return ge(e)==="unbounded"||s<=i.token_budget?void 0:{receipt:i,estimated:s}}function ft(e,t,n,o){let r=Pn(e,{...t,outputRowContract:t.outputRowContract===!0||t.output_row_contract===!0},$i(t,o));if(pe(n,r),t.outputRowContract===!0||t.output_row_contract===!0||!Object.hasOwn(r,"row_contract"))return P(r.context_intent)?Dn(r,t):r;let i=Object.fromEntries(Object.entries(r).filter(([a])=>a!=="row_contract"));Object.defineProperty(i,"row_contract",{value:r.row_contract,enumerable:!1,configurable:!0});let s=Dn(i,t);return delete s.row_contract,pe(r,s),s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cb1266f3-8375-586f-87c6-356cf7843969")}catch{}})();var ne=["result_rows","envelope","diagnostics","hints"],Wi=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,Ki=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,Vi=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,Hi=8;function yt(e){return Buffer.byteLength(e,"utf8")}function Kn(e){return yt(JSON.stringify(e)??"null")}function Ji(e,t){return Ki.test(e)?"diagnostics":Vi.test(e)?"hints":Wi.test(e)||Array.isArray(t)?"result_rows":"envelope"}function Yi(e){let t={result_rows:0,envelope:0,diagnostics:0,hints:0};if(typeof e!="object"||e===null||Array.isArray(e))return t[Array.isArray(e)?"result_rows":"envelope"]=Kn(e),t;for(let[n,o]of Object.entries(e))t[Ji(n,o)]+=Kn({[n]:o});return Object.values(t).every(n=>n===0)&&(t.envelope=1),t}function Xi(e,t){let n=ne.reduce((s,a)=>s+t[a],0),o=ne.map(s=>({section:s,value:e*t[s]/n})),r={result_rows:0,envelope:0,diagnostics:0,hints:0};for(let s of o)r[s.section]=Math.floor(s.value);let i=e-ne.reduce((s,a)=>s+r[a],0);for(let s of[...o].sort((a,c)=>c.value-Math.floor(c.value)-(a.value-Math.floor(a.value))||ne.indexOf(a.section)-ne.indexOf(c.section))){if(i===0)break;r[s.section]+=1,i-=1}return r}function Vn(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function Qi(e,t){let n=yt(t(e)),o=Xi(n,Yi(e)),r=Object.fromEntries(ne.map(a=>[a,{bytes:o[a],estimated_tokens:$(o[a])}])),i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:n,total_estimated_tokens:$(n),sections:r,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},s=Vn(e,i);for(let a=0;a<Hi;a+=1){let c=yt(t(s))-n;if(c===i.accounting_receipt_bytes)return s;i={...i,accounting_receipt_bytes:c,accounting_receipt_estimated_tokens:$(c)},s=Vn(e,i)}return s}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="787e6c05-d503-5602-a173-e6a59699cea6")}catch{}})();var bu=Object.freeze({comments:Object.freeze(["comments"]),notes:Object.freeze(["notes"]),learnings:Object.freeze(["learnings"])});(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8e86e884-98ca-5b28-838b-db3543051112")}catch{}})();var Hn=new Set(["body","item_hash","linked","claim_state","children","schedule","blockers"]),Ou=new Set(["linked","claim_state","children","schedule"]);import{encode as Ot}from"@toon-format/toon";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bafcd4e4-ec0f-5340-89ce-b85d822b2323")}catch{}})();function Jn(e,t={}){let n=[...new Set(e.flatMap(u=>Object.keys(u)))],o=t.compact?n.filter(u=>e.every(_=>Object.hasOwn(_,u)&&_[u]===null)):[],r=t.compact?n.filter(u=>e.every(_=>{if(!Object.hasOwn(_,u))return!0;let l=_[u];return Array.isArray(l)&&l.every(f=>typeof f=="string"&&f!==""&&!f.includes(";"))})):[],i=new Set(r),s=new Set(o),a=n.filter(u=>!i.has(u)&&e.some(_=>{let l=_[u];return l!==null&&typeof l=="object"})),c=new Set(a),d=[];return{rows:e.map((u,_)=>Object.fromEntries(n.filter(l=>!s.has(l)).map(l=>{if(!Object.hasOwn(u,l))return d.push([_,l]),[l,null];let f=u[l];return i.has(l)?[l,f.join(";")]:[l,c.has(l)?JSON.stringify(f):f]}))),encoding:{json_columns:a,absent:d,...r.length?{list_columns:Object.fromEntries(r.map(u=>[u,";"]))}:{},...o.length?{null_columns:o,null_column_index:o.map(u=>n.indexOf(u))}:{}}}}function Yn(e){let{json_columns:t,absent:n,...o}=e,r=new Map;for(let[i,s]of n){let a=r.get(s)??[];a.push(i),r.set(s,a)}return{...t.length>0?{json_columns:t}:{},...r.size>0?{absent_rows:Object.fromEntries(r)}:{},...o}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43d2915b-7301-5e96-89e0-51c8e817789e")}catch{}})();function C(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Zi=new Set(["brief","compact","fields"]);function Xn(e){if(!C(e))return!1;let t=e.fields;return Zi.has(e.mode)&&Object.keys(e).length===2&&Array.isArray(t)&&t.length>0&&t.every(n=>typeof n=="string"&&n.length>0)}function Qn(e,t){return e.every(n=>C(n)&&Object.keys(n).length===t.fields.length&&t.fields.every(o=>Object.hasOwn(n,o)))}function Zn(e,t){return e.mode==="fields"&&t===0?{projection:e}:{}}function eo(e,t){return typeof e.has_more=="boolean"&&e.truncated===e.has_more&&e.count===t&&typeof e.total=="number"&&Number.isSafeInteger(e.total)&&(e.has_more?e.total>t&&typeof e.next_cursor=="string"&&e.next_cursor.length>0:e.total===t&&e.next_cursor==null)}function es(e){return C(e)&&(e.status==="complete"||e.status==="unchecked")&&e.unreadable_item_count===0&&e.unreadable_directory_count===0}function ht(e,t="full_item_fields"){if(!C(e)||!Array.isArray(e.omitted_field_groups))return!1;let n=e.omitted_field_groups,o=n[0];return e.has_omissions===!0&&e.omitted_field_group_count===1&&Object.keys(e).length===3&&n.length===1&&C(o)&&Object.keys(o).length===2&&o.name===t&&o.restore_with==="--full"}function to(e){if(!C(e)||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!Xn(e.projection)||!Qn(e.items,e.projection)||!es(e.completeness)||!eo(e,e.items.length)||!ht(e.omission_receipt))return e;let{total:t,has_more:n,truncated:o,next_cursor:r,completeness:i,projection:s,now:a,omission_receipt:c,sorting:d,filters:u,..._}=e,l=i.status==="complete"&&!n&&Object.keys(i).length===3,{unreadable_item_count:f,unreadable_directory_count:m,...p}=i;return{..._,...l?{}:{total:t,has_more:n,completeness:p},...n?{next_cursor:r}:{},...os(d),...no(u,_.applied_limit,s),...Zn(s,e.items.length),details:"--full"}}function ts(e){return C(e)&&e.sort==="default"&&e.order==="asc"&&Object.keys(e).every(t=>t==="sort"||t==="order"||t==="effective_keys")}function ns(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&(e[1]==="asc"||e[1]==="desc")}function os(e){if(!ts(e))return{sorting:e};let t=e.effective_keys;return t===void 0?{}:!Array.isArray(t)||!t.every(ns)?{sorting:e}:{sorting:{effective_keys:t.map(([n,o])=>`${n} ${o}`).join(", ")}}}function rs(e,t){if(typeof e!="string"||t===void 0)return!1;let n=e.split(",").map(o=>o.trim()).filter(Boolean);return n.length===t.fields.length&&n.every((o,r)=>o===t.fields[r])}function no(e,t,n){if(!C(e))return e===void 0?{}:{filters:e};let o=Object.fromEntries(Object.entries(e).filter(([r,i])=>!(r==="limit"&&String(i)===String(t))&&!(r==="fields"&&rs(i,n))&&!(r==="runtime_filters"&&C(i)&&Object.keys(i).length===0)));return Object.keys(o).length===0?{}:{filters:o}}function is(e,t){return e.count===t&&!Object.hasOwn(e,"has_more")&&!Object.hasOwn(e,"truncated")&&e.next_cursor==null&&(e.total===void 0||e.total===t)}function ss(e){if(!Object.hasOwn(e,"projection"))return ht(e.omission_receipt,"projection_metadata")?{}:void 0;let t=e.projection;return Xn(t)&&t.mode==="fields"&&Qn(e.items,t)&&typeof e.now=="string"&&ht(e.omission_receipt)?{projection:t}:void 0}function oo(e){if(!C(e)||typeof e.query!="string"||!Array.isArray(e.items)||Object.hasOwn(e,"details")||!(eo(e,e.items.length)||is(e,e.items.length)))return e;let t=ss(e);if(t===void 0)return e;let{truncated:n,omission_receipt:o,filters:r,projection:i,now:s,mode_source:a,...c}=e;return{...c,...a==="settings"||t.projection===void 0&&a!==void 0?{mode_source:a}:{},...no(r,c.applied_limit,t.projection),...t.projection?Zn(t.projection,e.items.length):{},details:"--full"}}import{isBoxedPrimitive as as}from"node:util/types";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1b399abd-460a-55a5-9df2-db23537aac0d")}catch{}})();var ro=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/gu;function Su(e){return e.replaceAll(ro,"\uFFFD")}function cs(e,t,n){return n&&/^\d+$/u.test(t)?`${e}[${t}]`:/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function bt(e,t,n){if(typeof e=="string"){let o=e.search(ro);return o<0?void 0:{field:t,index:o}}if(!(e===null||typeof e!="object"||n.has(e))){n.add(e);for(let[o,r]of Object.entries(e)){let i=cs(t,o,Array.isArray(e)),s=bt(o,`${i} (key)`,n)??bt(r,i,n);if(s)return s}}}function io(e,t,n){if(e===null||typeof e!="object")return e;if(as(e)||typeof e.toJSON=="function")return JSON.parse(JSON.stringify({[t]:e}))[t];if(n.has(e))return n.get(e);let o=Array.isArray(e)?new Array(e.length):{};n.set(e,o);for(let r of Object.keys(e))Object.defineProperty(o,r,{value:io(e[r],r,n),enumerable:!0,configurable:!0,writable:!0});return o}function wt(e){let t=io(e,"",new WeakMap),n=bt(t,"$",new WeakSet);return n&&us(n),t}function us(e){throw new h(`Output field ${e.field} contains an unpaired surrogate code unit at index ${e.index}; structured output requires well-formed Unicode.`,y.USAGE,{code:"text_unpaired_surrogate",field:e.field,required:"Well-formed UTF-16 strings and object keys in both JSON and TOON output.",nextSteps:["Repair the producer's text before returning output; use toWellFormedText from @unbrained/pm-cli/sdk when replacement is intended."]})}function xu(e){wt(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f33393ac-6b72-5e46-92a5-f276d1fbfff1")}catch{}})();var ed=new Set(Object.values(y)),ls=new Map([["notes_count","notes"],["tests_count","tests"]]);var so=!1;function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vt(e){return typeof e=="object"&&e!==null&&e.code==="EPIPE"}function fs(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.SUCCESS)}function _s(){(process.exitCode===void 0||process.exitCode===y.SUCCESS)&&(process.exitCode=y.GENERIC_FAILURE)}function kt(e){if(e==="stdout"){fs();return}_s()}function ao(e){let t=e instanceof Error?e:new Error(String(e));setImmediate(()=>{throw t})}function ms(){so||(so=!0,process.stdout.on("error",e=>{if(vt(e)){kt("stdout");return}ao(e)}),process.stderr.on("error",e=>{if(vt(e)){kt("stderr");return}ao(e)}))}function ps(e,t){ms();try{return e==="stdout"?process.stdout.write(t):process.stderr.write(t),!0}catch(n){if(vt(n))return kt(e),!1;throw n}}function gs(e){return ps("stderr",e)}function co(e){return typeof e=="string"?JSON.stringify(e):typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":JSON.stringify(e)}function Et(e,t){let n=" ".repeat(t);return e.split(`
|
|
13
|
+
`).map(o=>`${n}${o}`).join(`
|
|
14
|
+
`)}function ys(e){let t=new Set,n=0;for(let o of e){let r=Object.keys(o);n+=r.length;for(let i of r)t.add(i)}return e.length*t.size<=n*2}function hs(e,t,n,o){let r=" ".repeat(n);if(!w(t)&&!Array.isArray(t))return`${r}${e}: ${co(t)}`;let i=e==="omission_receipt"?bs(t,n):void 0;if(i!==void 0)return i;if(Array.isArray(t)){if(t.length===0)return`${r}${e}: []`;let s=Et(Ot({[e]:t}),n);return o&&t.length>=1&&t.every(w)&&ys(t)?[!1,!0].map(a=>{let c=Jn(t,{compact:a});return Et(Ot({[e]:c.rows,[`${e}_encoding`]:Yn(c.encoding)}),n)}).reduce((a,c)=>Buffer.byteLength(c)<Buffer.byteLength(a)?c:a,s):s}return w(t)&&Object.keys(t).length===0?`${r}${e}: {}`:`${r}${e}:
|
|
15
|
+
${qe(t,n+1)}`}function bs(e,t){let n=" ".repeat(t);if(xs(e))return`${n}omission_receipt: complete`;let o=w(e)?ws(e):void 0;if(o===void 0)return;let r=`${n}omission_receipt:
|
|
16
|
+
${qe(e,t+1)}`,i=`${n}omission_receipt:
|
|
17
|
+
${qe(o,t+1)}`;return Buffer.byteLength(i)<Buffer.byteLength(r)?i:r}function ws(e){let t=e.omitted_field_groups;if(!Array.isArray(t)||t.length===0||Object.hasOwn(e,"restore_with"))return;let n=[],o;for(let r of t){if(!w(r)||Object.keys(r).length!==2)return;let{name:i,restore_with:s}=r;if(typeof i!="string"||i.length===0||typeof s!="string"||!s.endsWith(i))return;let a=s.slice(0,s.length-i.length);if(o!==void 0&&a!==o)return;o=a,n.push(i)}return Object.fromEntries(Object.entries(e).flatMap(([r,i])=>r==="omitted_field_groups"?[[r,n],["restore_with",`${o}<name>`]]:[[r,i]]))}function Os(e,t,n){let o=e.map(r=>V(r,t,n||t.preserveRowFacts&&w(r))).filter(r=>r!==void 0);return o.length>0||n?o:void 0}function V(e,t={omitDuplicateCountAliases:!0,preserveRowFacts:!0},n=!1){if(e===null)return n?null:void 0;if(Array.isArray(e))return Os(e,t,n);if(w(e)){let o=[],r=Object.entries(e).filter(([i,s])=>{let a=ls.get(i);return!t.omitDuplicateCountAliases||a===void 0||!w(e.collection_counts)||s!==e.collection_counts[a]});for(let[i,s]of r){if(i==="omitted_field_groups"&&Array.isArray(s)&&s.length===0){o.push([i,[]]);continue}let a=V(s,t,n);a!==void 0&&o.push([i,a])}return o.length>0||n?Object.fromEntries(o):void 0}return e}function qe(e,t){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?"[]":Et(Ot(e),t);if(w(e)){let o=Object.entries(e);return o.length===0?"{}":o.map(([r,i])=>hs(r,i,t,!Object.hasOwn(e,`${r}_encoding`)&&!(r==="checks"&&w(e.verdict)&&e.verdict.authority==="ok"))).join(`
|
|
18
|
+
`)}return`${n}${co(e)}`}var vs=new Set(["filters","now","projection","sorting"]);function ks(e){let t=V(e,{omitDuplicateCountAliases:!1,preserveRowFacts:!1});if(!w(t)||!Array.isArray(t.items))return t??null;let n=Object.fromEntries(Object.entries(t).filter(([o])=>!vs.has(o)));return n.has_more!==!0&&delete n.next_cursor,n}function Es(e){return!w(e)||e.ok!==!0||!w(e.verdict)||e.verdict.authority!=="ok"||!Array.isArray(e.checks)?e:{...e,checks:e.checks.map(As)}}function As(e){if(!w(e)||e.ok!==!0||!w(e.details)||Object.keys(e.details).length!==0)return e;let{details:t,...n}=e;return n}function uo(e,t,n=!1,o={}){if(e=wt(e),t==="json"){let i=n?ks(e):e,s=w(e)&&w(e.projection)&&e.projection.mode==="brief"&&Array.isArray(e.items);return`${JSON.stringify(i,null,s?void 0:2)}
|
|
19
|
+
`}let r=Ts(e,Rs(e,V(Es(oo(to(e))),ze),o.preserveEmptyItemCollections===!0),o.positionalRowPaths??[]);return r===void 0?`{}
|
|
20
|
+
`:`${qe(r,0)}
|
|
21
|
+
`}var ze={omitDuplicateCountAliases:!0,preserveRowFacts:!0};function At(e,t,n=!1){if(Array.isArray(e)){if(e.length===0)return[];let i=Array.isArray(t)?t:[],s=i.length===e.length,a=0,c=e.flatMap(d=>{let u=n||w(d),_=!s&&V(d,ze,u)===void 0,l=At(d,_?void 0:i[a++],u);return l===void 0?[]:[l]});return c.length>0?c:t}if(!w(e))return t;let o=w(t)?t:{},r=Object.entries(e).flatMap(([i,s])=>{let a=At(s,Object.hasOwn(o,i)?o[i]:void 0,n);return a===void 0?[]:[[i,a]]});return r.length>0||Object.keys(e).length===0?Object.fromEntries(r):t}function Rs(e,t,n){if(!n||!w(e))return t;let o=w(t)?t:{},r=new Map(Object.keys(e).filter(i=>i==="item"||Hn.has(i)).map(i=>[i,At(e[i],o[i])]));return lo(e,o,r)}function lo(e,t,n){let o=Object.entries(t).map(([i,s])=>[i,n.has(i)?n.get(i):s]),r=Object.keys(e);for(let[i,s]of n){if(Object.hasOwn(t,i)||s===void 0)continue;let a=new Set(r.slice(r.indexOf(i)+1)),c=o.findIndex(([d])=>a.has(d));o.splice(c===-1?o.length:c,0,[i,s])}return Object.fromEntries(o)}function Ts(e,t,n){if(!w(e))return t;let o=n.filter(s=>{let a=e[s];return Array.isArray(a)&&a.some(c=>V(c,ze,w(c))===void 0)});if(o.length===0)return t;let r=w(t)?t:{},i=new Map(o.map(s=>[s,e[s].map(a=>V(a,ze,!0))]));return lo(e,r,i)}var Ss=JSON.stringify({has_omissions:!1,omitted_field_group_count:0,omitted_field_groups:[]});function xs(e){let t=Object.entries(Object(e)).sort(([n],[o])=>n.localeCompare(o));return JSON.stringify(Object.fromEntries(t))===Ss}function td(e){let t=zt("error_format",{message:e}),n=t.handled&&typeof t.result=="string"?t.result:e;gs(n.endsWith(`
|
|
22
|
+
`)?n:`${n}
|
|
23
|
+
`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="21a8bc0d-7750-5528-9893-f13d295424fb")}catch{}})();var gt=8,Cs=64,Is=5,js=4,fo=100;function _o(e,t,n){if(e!=="get"||!Rt(n.item)||["fields","outputInclude","output_include","outputCursor","output_cursor"].some(c=>t[c]!==void 0)||t.full===!0||t.tree===!0||t.depth!==void 0&&t.depth!=="standard")return;let o=n.item,r=["linked","claim_state","schedule"],i=r.filter(c=>Object.hasOwn(n,c)),s=Object.fromEntries(Object.entries(n).filter(([c])=>!r.includes(c)));s.item=Object.fromEntries(Object.entries(o).filter(([c])=>c!=="body")),Object.hasOwn(o,"body")&&i.push("body");let a=[...Rt(n.omission_receipt)&&Array.isArray(n.omission_receipt.omitted_field_groups)?n.omission_receipt.omitted_field_groups:[],...i.map(c=>({name:c,restore_with:`--fields ${c}`}))];return s.omission_receipt={has_omissions:a.length>0,omitted_field_group_count:a.length,omitted_field_groups:a},s}function ye(e){let t=Math.trunc(e.effective_budget_tokens),n=Math.trunc(e.measured_result_tokens);if(!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(n)||n<=0)return{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"};let o=Math.max(t+1,n),r=Math.ceil(o*Is/js),i=Math.ceil(r/fo)*fo;return Number.isSafeInteger(i)?{output_budget:i,recovery_budget_multiplier:i/t,rule_version:"v1"}:{output_budget:"unbounded",recovery_budget_multiplier:null,rule_version:"v1"}}function oe(e,t,n=!1){let o=Object.getOwnPropertyDescriptor(e,"row_contract");o&&(n||o.enumerable===!1)&&Object.defineProperty(t,"row_contract",{...o,enumerable:!1})}function te(e){let t=e.resolvedOutputFormat??e.outputFormat??e.output_format??e.format;return t==="json"||t==="toon"?t:void 0}var he;function M(e,t){let n=t===void 0?JSON.stringify(e):he!==void 0&&he.format===t?Ds(he,e):uo(e,t);return Math.ceil(Buffer.byteLength(n,"utf8")/4)}function Ds(e,t){he=void 0;try{return e.render(t)}finally{he=e}}function Rt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Tt(e,t,n=!1){return typeof e=="string"?n?e:(e.length>Ft&&(t.compacted=!0),Te(e)):Array.isArray(e)?e.map(o=>Tt(o,t,n)):Rt(e)?Object.fromEntries(Object.entries(e).map(([o,r])=>[o,Tt(r,t,n||o==="focus_row_states"||typeof r=="string"&&ae(o))])):e}function U(e,t,n){let o=t.estimated_tokens;for(let r=0;r<gt;r+=1){t.estimated_tokens=o;let i=M(e,n);if(i===o)return;o=i}t.estimated_tokens=o}function Ns(e,t){return ce(e).filter(n=>(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length)>Math.max(1,t.get(n.path)??0)).map(n=>({collection:n,length:Array.isArray(n.value)?n.value.length:Object.keys(n.value).length})).sort((n,o)=>o.length-n.length||n.collection.path.localeCompare(o.collection.path))[0]?.collection}function Ps(e,t,n,o,r,i,s){for(let a=0;a<Cs;a+=1){if(i?.(e),U(e,t,r),t.estimated_tokens<=n)return;let c=Ns(e,o);if(!c)return;let d=Math.max(1,o.get(c.path)??0),u=Array.isArray(c.value)?[...c.value]:Object.entries(c.value),_=s(c.path),l=g=>{let b=_?u.length-g:0;if(Array.isArray(c.value)){c.value.length=g;for(let O=0;O<g;O+=1)c.value[O]=u[b+O]}else{for(let O of Object.keys(c.value))delete c.value[O];Object.defineProperties(c.value,Object.getOwnPropertyDescriptors(Object.fromEntries(u.slice(b,b+g))))}typeof e.count=="number"&&(e.count=X(e)),typeof e.returned_count=="number"&&(e.returned_count=X(e)),c.path==="items"&&(e.applied_limit=g),i?.(e),U(e,t,r)};t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],c.path])].sort((g,b)=>g.localeCompare(b)),e.has_more=!0,e.truncated=!0;let f=d,m=u.length-1,p=d;for(;f<=m;){let g=Math.floor((f+m)/2);l(g),t.estimated_tokens<=n?(p=g,f=g+1):m=g-1}l(p)}}function mo(e,t,n,o=new Map,r,i,s=!1,a=()=>!1){let c={compacted:!1},d=Object.fromEntries(Object.entries(e).map(([u,_])=>[u,Tt(_,c,s&&u==="diff"||typeof _=="string"&&ae(u))]));return oe(e,d),t.strings_compacted=c.compacted,d.read_output=t,Ps(d,t,n,o,r,i,a),U(d,t,r),d}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a8de41-54f9-5b59-8e58-7ac924ba6e08")}catch{}})();function fd(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"&&"context_ref"in e&&typeof e.context_ref=="string"&&e.context_ref.startsWith("session:")&&e.context_ref.endsWith(`:${e.id}`)}var St=256,xt=1e4,Ms=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,po=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,Us=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),Ls=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&Ms.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=St,reason:`token_budget must be a safe integer of at least ${St}.`},{valid:e=>Number.isSafeInteger(e.spent_tokens)&&e.spent_tokens>=0&&e.spent_tokens<=e.token_budget,reason:"spent_tokens must be a non-negative safe integer no larger than token_budget."},{valid:e=>Array.isArray(e.seen_item_ids)&&e.seen_item_ids.length<=xt&&e.seen_item_ids.every(t=>typeof t=="string"&&po.test(t)),reason:`seen_item_ids must contain at most ${xt} portable item identifiers.`}];function Ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function We(e){throw new h(`--output-session ${e}`,y.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function Ve(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{We("must be a valid JSON object.")}Ke(t)||We("must be a JSON object.");let n=Object.keys(t).filter(i=>!Us.has(i));n.length>0&&We(`contains unknown field "${n.sort()[0]}".`);let o=Ls.find(i=>!i.valid(t));o!==void 0&&We(o.reason);let r=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:r}}function go(e){if(Ke(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:Ke(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function $s(e){let t=new Set,n=0,o=D(e),r=new Set(o.map(({path:s})=>s)),i=Object.entries(e).flatMap(([s,a])=>Array.isArray(a)&&!r.has(s)?[{path:s,value:a}]:[]);for(let s of[...o,...i]){let a=Array.isArray(s.value)?s.value:Object.values(s.value);for(let c of a){if(!Ke(c))continue;if(typeof c.context_ref=="string"){n+=1;continue}let d=go(c);d!==void 0&&po.test(d)&&t.add(d)}}return{deliveredIds:t,suppressedRepeatCount:n}}function yo(e,t){let n=new Set(t.seen_item_ids);return ue(e,o=>{let r=go(o);return r!==void 0&&n.has(r)?{id:r,context_ref:`session:${t.id}:${r}`}:o})}function Ct(e,t,n){let{deliveredIds:o,suppressedRepeatCount:r}=$s(e),i=new Set(t.seen_item_ids),s=[...o].filter(p=>!i.has(p)).sort(),a=s.slice(0,xt-t.seen_item_ids.length),c=[...t.seen_item_ids,...a].sort(),d=s.length-a.length,u={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:o.size,...d===0?{}:{seen_item_overflow_count:d},suppressed_repeat_count:r,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --depth brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:c}},_={...e,read_session:u},l=p=>{u.spent_this_call_tokens=p,u.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,p),u.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+u.charged_this_call_tokens),u.remaining_tokens=Math.max(0,t.token_budget-u.spent_total_tokens),u.exhausted=u.remaining_tokens<St,u.next_state.spent_tokens=u.spent_total_tokens},f=0,m=0;for(let p=0;p<8;p+=1){l(f);let g=M(_,n);if(g===f)return _;m=Math.max(m,g),f=g}return l(m),_}function ho(e){return Math.max(0,e.token_budget-e.spent_tokens)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1cc0fcb7-2aaa-5233-bdfd-4b4d0fb3e9c1")}catch{}})();var be=Symbol.for("pm.readOutputInvocationProvenance");function md(e,t){return Reflect.set(e,be,{canonical_include_modes:[...t],explicit_legacy_aliases:[],sdk_invocation_observed:!0}),e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2a596392-747a-5b55-854d-1e80964468d3")}catch{}})();var H=["include","amount","cost","encoding"],Ao=["canonical","legacy","intent","default"],Oe=ke,Nd=Object.freeze(H.map(e=>Oe[e])),Pd=Ee;function Bs(e,t){let n=Ie[e];if(n!==void 0)return n;let o=t==="include"?Ze.has(e)?"<csv>":je(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${Oe[t]} ${o}.`}function Ro(e){let t=Qe[e]??{},n=Object.freeze(Object.fromEntries(H.map(o=>[o,Object.freeze({dimension:o,canonical_option:Oe[o],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[o]??[]).map(r=>Object.freeze({flag:r,semantics:Ie[r]===void 0?"replacement":"behavior_preserving",migration_hint:Bs(r,o),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:Ao,budget_retention_policy:e==="assurance"?"verdict_priority":Object.hasOwn(S,e)?"ordered_suffix":"ordered_prefix",projection_modes:Object.freeze([...et(e).keys()])})}var Fs=Object.freeze(se.map(Ro)),Gs=new Map(Fs.map(e=>[e.command,e]));function F(e,t={}){let n=ie(e.trim().toLowerCase()),o=Xe(n);return o!==void 0?o.read_output===void 0?void 0:`extension:${o.command}`:on(n,t)}var qs=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],bo={comments:["add","body","comment","text","stdin","file","edit","delete"],notes:["add","note","text","addJson","stdin","file","edit","delete"],learnings:["add","learning","text","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"],"package-catalog":["activate","adopt","adoptAll","deactivate","doctor","init","install","manage","migrate","reload","scaffold","uninstall"]};function zs(e){return qs.some(t=>t!=="outputFormat"&&t!=="output_format"&&e[t]!==void 0)}var Ws=[{keys:["outputInclude","output_include"],valid:e=>we(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||re(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||re(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputSession","output_session"],valid:e=>(Ve(e),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:e=>typeof e=="string"&&e.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}],Md="read_output_mutation_conflict",To=[{flag:"--output-include",keys:["outputInclude","output_include"]},{flag:"--output-limit",keys:["outputLimit","output_limit"]},{flag:"--output-budget",keys:["outputBudget","output_budget"]},{flag:"--output-session",keys:["outputSession","output_session"]},{flag:"--output-cursor",keys:["outputCursor","output_cursor"]},{flag:"--output-row-contract",keys:["outputRowContract","output_row_contract"]}],Ud=To.map(({flag:e})=>e);function Ks(e,t,n){let o=To.filter(({keys:a})=>a.some(c=>t[c]!==void 0)),r=o.map(({flag:a})=>a),i=o.flatMap(({keys:a})=>a.filter(c=>t[c]!==void 0)),s=r.join(", ");return new h(`Universal output controls (${s}) cannot be combined with a ${e} mutation; nothing was written.`,y.USAGE,{code:"read_output_mutation_conflict",field:r[0],details:{surface:e,output_controls:r,output_option_keys:i,mutation_options:[...n]},required:`Retry the ${e} mutation without ${s}. To bound or page the result, read it with those controls in a separate call after the write.`,why:"Universal output controls shape a read. A mutation returns its own bounded receipt, so the controls have nothing to shape and the write is refused before it runs.",examples:[...Vs[e]]})}var Vs={comments:['pm comments <id> --add "<text>"',"pm comments <id> --output-limit 5"],notes:['pm notes <id> --add "<text>"',"pm notes <id> --output-limit 5"],learnings:['pm learnings <id> --add "<text>"',"pm learnings <id> --output-limit 5"],files:["pm files <id> --add path=<path>","pm files <id> --output-limit 5"],docs:["pm docs <id> --add path=<path>","pm docs <id> --output-limit 5"],"package-catalog":["pm package install <source> --project","pm package catalog --output-limit 5"]};function Ld(e,t){let n=t.outputFormat??t.output_format;if(n!==void 0&&n!=="json"&&n!=="toon")throw new h("--output-format must be toon or json.",y.USAGE);if(!zs(t))return;let o=F(e,t);if(!o)throw new h(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,y.USAGE);if(Object.hasOwn(bo,o)){let r=o,i=bo[r].filter(s=>t[s]!==void 0&&t[s]!==!1);if(i.length>0)throw Ks(r,t,i)}for(let r of Ws){let i=r.keys.map(s=>t[s]).find(s=>s!==void 0);if(i!==void 0&&!r.valid(i))throw new h(r.message,y.USAGE)}}function So(e){let t=F(e);return t?et(t):new Map}function Hs(e,t,n){let o=we(t)??[],r=So(e),i=[],s=[],a=n,c=a[be],d=new Set(c?.canonical_include_modes??[]),u=new Set(c?.explicit_legacy_aliases??[]);for(let f of o){let m=r.get(f);if(m===void 0){i.push(f);continue}let p=`--${f.replaceAll("_","-")}`;jt(It(n,p))&&u.add(p),n[m]=!0,s.push(f),d.add(f)}let _=F(e)==="get"?i.filter(f=>f!=="item"):[],l=_.length>0;return l&&(n.fields=[...new Set([...we(n.fields)??[],..._])].join(","),d.add("fields")),(s.length>0||l)&&(a[be]={canonical_include_modes:[...d],explicit_legacy_aliases:[...u],...c?.cli_invocation_observed===!0?{cli_invocation_observed:!0}:{}}),{selectors:i,modes:s}}function $d(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:o,modes:r}=Hs(e,n,t);if(r.length===0)return;let i=o.length>0?o.join(","):void 0;t.outputInclude=i,Object.hasOwn(t,"output_include")&&(t.output_include=i)}function It(e,t){let n=tt(t);if(Object.hasOwn(e,n))return e[n];let o=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,o))return e[o];if(t==="--no-truncate"&&e.truncate===!1)return!0}function jt(e){return e!==void 0&&e!==!1&&e!==null}function we(e){let t=(Array.isArray(e)?e:[e]).flatMap(n=>typeof n=="string"?n.split(","):[]).map(n=>n.trim()).filter(Boolean);return t.length>0?[...new Set(t)]:void 0}function re(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function Js(e,t,n,o){for(let r of e.legacy_aliases){if(o(r.flag))continue;let i=It(t,r.flag),s={value:i,flag:r.flag};if(jt(i)&&n(s))return s}}function wo(e,t){let n=we(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:we(t.value)??[je(t.flag)]}}function Oo(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=re(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let o=re(t.value);return o===void 0?void 0:{source:"legacy",value:o}}function vo(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=re(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let o=re(t.value);return o===void 0?void 0:{source:"legacy",value:o}}function ko(e,t){if(e==="json"||e==="toon")return{source:"canonical",value:e};if(t)return t.flag==="--stream"||t.flag==="--follow"?{source:"legacy",value:"stream"}:t.value==="json"||t.value==="toon"?{source:"legacy",value:t.value}:void 0}function xo(e,t,n){if(!e)return!1;let o=new Set(e.explicit_legacy_aliases);if(e.cli_invocation_observed===!0||e.sdk_invocation_observed===!0)return!o.has(n);let r=new Set(e.canonical_include_modes.map(i=>`--${i.replaceAll("_","-")}`));return t==="include"&&r.has(n)&&!o.has(n)}function Ys(e,t,n,o){return e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||jt(It(o,"--no-truncate"))&&!xo(n,"amount","--no-truncate")||t.amount?.flag==="--no-truncate"||t.include?.flag==="--full"||n?.canonical_include_modes.includes("full")===!0}function Xs(e,t){return H.flatMap(n=>e[n]?.source==="canonical"||n==="include"&&(t?.canonical_include_modes.length??0)>0?[Oe[n]]:[])}function Co(e,t){let n=F(e,t);if(!n)return;let o=Gs.get(n)??Ro(n),r=t[be],i={include:b=>wo(void 0,b),amount:b=>Oo(void 0,b),cost:b=>vo(void 0,b),encoding:b=>ko(void 0,b)},s=Object.fromEntries(H.map(b=>[b,Js(o.dimensions[b],t,O=>i[b](O)!==void 0,O=>xo(r,b,O))])),a=H.flatMap(b=>{let O=s[b];return O?[O.flag]:[]}),c=H.flatMap(b=>{let O=s[b];return O?[o.dimensions[b].legacy_aliases.find(Go=>Go.flag===O.flag).migration_hint]:[]}),d=ko(t.outputFormat??t.output_format,s.encoding),u=wo(t.outputInclude??t.output_include,s.include),_=Oo(t.outputLimit??t.output_limit,s.amount),l=vo(t.outputBudget??t.output_budget,s.cost),f=Ys(e,s,r,t),m=Ht(e,{generateFallback:!0}),p=d?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon",g=l??(f?{source:"intent",value:"unbounded"}:{source:"default",value:m.default_max_estimated_tokens_by_format[p]});return{command:n,include:u,amount:_,cost:g,encoding:d,canonical_options_used:Xs({include:u,amount:_,cost:g,encoding:d},r),legacy_aliases_used:a,migration_hints:c,precedence:Ao}}function v(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Dt=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),Qs=["collection_counts","notes_count","tests_count"];function Io(e,t){let n=new Set(t.map(o=>o.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([o])=>n.has(o)))}function Zs(e){let t=v(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...Qs.filter(r=>Object.hasOwn(t,r))])].sort((r,i)=>r.localeCompare(i)),o=Object.keys(e).filter(r=>r!=="item"&&r!=="read_output"&&!Dt.has(r)).sort((r,i)=>r.localeCompare(i));return{item:t,itemFields:n,sections:o,valid:[...n,"item",...n.map(r=>`item.${r}`),...o]}}function ea(e,t){let n=Zs(e),o=t.filter(u=>!n.valid.includes(u));if(o.length>0)throw new h(`Unknown --output-include selector(s) for get: ${o.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,y.USAGE);let r=t.includes("item"),i=t.flatMap(u=>u.startsWith("item.")?[u.slice(5)]:n.itemFields.includes(u)?[u]:[]).filter((u,_,l)=>l.indexOf(u)===_);if(r&&i.length>0)throw new h("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",y.USAGE);let s=new Set(t.filter(u=>n.sections.includes(u))),a=Object.fromEntries(Object.entries(e).filter(([u])=>Dt.has(u)||s.has(u)));r?a.item=n.item:i.length>0&&(a.item=Io(n.item,i));let c=[...r?[]:i.length>0?n.itemFields.filter(u=>!i.includes(u)).map(u=>({name:`item.${u}`,restore_with:`--output-include item.${u}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(u=>!s.has(u)).map(u=>({name:u,restore_with:`--output-include ${u}`}))],d=[...v(a.omission_receipt)&&Array.isArray(a.omission_receipt.omitted_field_groups)?a.omission_receipt.omitted_field_groups:[],...c];return a.omission_receipt={has_omissions:d.length>0,omitted_field_group_count:d.length,omitted_field_groups:d},a}function Eo(e){let t=0;return ue({...e},n=>(v(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function ta(e,t,n,o){if(Eo(t)===0||Eo(n)>0)return;let r=[...So(e).keys()],i=r.length>0?` Declared ${e} projection modes: ${r.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new h(`Unknown --output-include selector(s) for ${e}: ${o.join(", ")}. No selector matched any returned row field.${i}`,y.USAGE)}function na(e,t,n){if(e==="get")return ea(t,n);let o=Pe(t),r=n.flatMap(s=>o.flatMap(a=>s.startsWith(`${a}.`)?[s.slice(a.length+1)]:[])),i=n.some(s=>Object.hasOwn(t,s.split(".")[0])&&!o.some(a=>s.startsWith(`${a}.`)));if(o.length>0&&(!i||r.length>0)){let s={...t},a=r.length>0?r:n,c=ue(s,d=>v(d)?Io(d,a):d);return ta(e,t,c,a),c}return Object.fromEntries(Object.entries(t).filter(([s])=>n.some(a=>a.split(".")[0]===s)||Dt.has(s)))}function oa(e,t,n,o){if(t==="unbounded")return e;let{result:r,truncated:i}=pn(e,t,s=>B(n,s));if(!i)return r;if(r.has_more=!0,r.truncated=!0,Po(r,n,[...o.entries()].flatMap(([s,a])=>a.rows>t?[{path:s,total_rows:a.totalRows}]:[])),typeof r.count=="number"){let s=v(r.projection)?r.projection.row_key:void 0;r.count=typeof s=="string"&&Array.isArray(r[s])?r[s].length:X(r)}return typeof r.returned_count=="number"&&(r.returned_count=X(r)),r.applied_bound={kind:"output_limit",source:"explicit",value:t},r}function ra(e){return H.filter(t=>e[t]!==void 0&&e[t]?.source!=="default"||e.canonical_options_used.includes(Oe[t]))}function He(e,t,n,o){let r=Ct(e,t,o);oe(e,r);for(let i=0;i<8;i+=1){let s=n.estimated_tokens,a=r.read_session.spent_this_call_tokens;U(r,n,o);let c=r;r=Ct(r,t,o),oe(c,r);let d=r.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&d===a)return r}return r}function pt(e,t){if(!v(e.read_output))return e;let n=te(t),o=e.read_output,r=Ve(t.outputSession??t.output_session);return r===void 0?(U(e,o,n),e):He(e,r,o,n)}function ia(e,t){if(e!=="validate")return t;let n=v(t.projection)?t.projection:void 0;if(!(Array.isArray(n?.declared_field_groups)?n.declared_field_groups:[]).some(u=>v(u)&&u.name==="diagnostic_rows"))return t;let o=[...new Set(ce(t).map(({path:u})=>u).filter(u=>/^checks\.\d+\.details\./u.test(u)))],r=o.filter(u=>!o.some(_=>_!==u&&u.startsWith(`${_}.`)));if(r.length===0)return t;let i=v(t.row_contract)?t.row_contract:{},s=Array.isArray(i.row_keys)?i.row_keys.filter(u=>typeof u=="string"):[],a=Array.isArray(i.continuation_row_keys)?i.continuation_row_keys.filter(u=>typeof u=="string"):[],c=s.length>0?s:r,d=[...new Set(r)];return JSON.stringify(c)===JSON.stringify(s)&&JSON.stringify(d)===JSON.stringify(a)?t:{...t,row_contract:{...i,row_keys:c,continuation_row_keys:d,jq_selector:typeof i.jq_selector=="string"?i.jq_selector:".checks[].details"}}}function sa(e,t){return e.include?.source==="canonical"&&!ee(t)}function aa(e,t,n,o,r){let i={...e};if(sa(t,e)&&(i=na(t.command,i,t.include.value)),t.command==="assurance"&&(i=wn(i)),de(i,e),i=On(i,t.command,o),t.command==="history"&&o){let c=["compact_history","provenance_history","history","diff"];if(i=Object.fromEntries(Object.entries(i).filter(([d])=>!c.includes(d)||d===o.path)),v(i.projection)&&(i.projection={...i.projection,row_key:o.path}),v(i.row_contract)){let d=i.row_contract;i.row_contract={...d,row_keys:[o.path],...Array.isArray(d.continuation_row_keys)?{continuation_row_keys:[o.path]}:{}}}i.count=Object.keys(i[o.path]).length}let s=e.count_only===!0?{...i,count_only:!0,count:e.count}:i,a=pa(i,e,t.command,o,r);return t.amount?.source==="canonical"&&(i=oa(i,t.amount.value,t.command,a.collectionsBeforeBudget),a.cursorContinuesExistingPage&&Uo(i,a.originalItems,a.cursorSource,!0,a.originalItemOffset)),de(i,s),Mo(i,t.command,a),{projected:n===void 0?i:yo(i,n),continuationState:a}}function ca(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default"||e.command==="context"&&e.cost.source==="legacy")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:ho(t)}]].sort((n,o)=>n.tokens-o.tokens)[0]}function jo(e){let t=e.canonical_options_used;return t&&t.length>0?{canonical_options_used:t}:{}}function Do(e,t){return v(e.context_intent)&&e.context_intent.command==="context"&&e.context_intent.token_budget===t&&e.context_intent.within_budget===!0}function ua(e,t,n){return e.command!=="next"||(t.tokenBudget??t.token_budget)===void 0?!1:!(v(n.context_intent)&&n.context_intent.command==="next"&&n.context_intent.within_budget===!0)}function No(e,t={}){return e?.source==="default"||e?.source==="legacy"&&!Do(t,e.tokens)?{budget_source:e.source,budget_tokens:e.tokens}:{}}function da(e,t,n,o,r,i){let s={contract_version:1,command:e.command,requested_dimensions:t,...No(o),precedence:e.precedence,...jo(e),legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:r}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},c=n===void 0?a:He(a,n,s,i);if(n===void 0&&U(c,s,i),n!==void 0&&s.estimated_tokens>o.tokens)throw new h("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",y.USAGE);return c}function la(e,t,n){return e.command==="context"&&e.cost?.source==="legacy"&&!Do(n,e.cost.value)||ua(e,t,n)||t.outputRowContract===!0||t.output_row_contract===!0||e.canonical_options_used.includes("--output-include")||e.command==="list"&&e.canonical_options_used.length>0&&e.include?.value.includes("full")===!0}function fa(e,t,n,o,r){if(t!==void 0||ee(n)||la(e,r,n))return!1;if(e.amount?.source==="canonical"&&e.amount.value!=="unbounded"){let i=e.amount.value;if(D(n).some(({value:s})=>(Array.isArray(s)?s.length:Object.keys(s).length)>i))return!1}return e.cost===void 0||e.cost.value==="unbounded"||e.cost.source==="legacy"&&e.command!=="context"||M(r.outputRowContract===!1?Object.fromEntries(Object.entries(n).filter(([i])=>i!=="row_contract")):n,o)<=e.cost.value}function Po(e,t,n){let o=Object.hasOwn(S,t)?S[t]:void 0,r=n.find(i=>o?.paths.includes(i.path));o!==void 0&&r!==void 0&&typeof e[o.total_key]!="number"&&(e[o.total_key]=r.total_rows)}function Mo(e,t,n){let o=S[t]?.paths[0];o!==void 0&&bn(e,t,n.producer,n.collectionsBeforeBudget.get(o)?.rows)}function _a(e,t,n,o){let r=n.backward?n.rows-o:n.baseOffset+o;return{path:t,cursor:st({command:e,path:t,offset:r,total_rows:n.totalRows,fingerprint:n.fingerprint,...n.backward?{direction:"backward"}:{}}),retained_rows:o,remaining_rows:n.backward?r:n.totalRows-r,total_rows:n.totalRows}}function ma(e,t,n,o,r,i,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],c=new Map(Y(e).map(m=>[m.path,Array.isArray(m.value)?m.value.length:Object.keys(m.value).length])),d=[...s.entries()].flatMap(([m,p])=>{let g=c.get(m);return g>=p.rows?[]:[_a(t.command,m,p,g)]}),u=d[0];Po(e,t.command,d);let _=u?"; page --output-cursor":"",l=o.source==="session"?`Truncated by the remaining ${o.tokens}-token session budget; start a new output session with a larger token_budget${_}.`:`${o.tokens}-token: raise --output-budget${_}`;n.migration_hints=[l,...t.migration_hints];let f=ye({effective_budget_tokens:o.tokens,measured_result_tokens:i});u&&!r&&(typeof e.next_cursor!="string"||e.continuation_kind==="output_cursor")&&(e.next_cursor=u.cursor),e.continuation_kind=r?"producer_cursor":u?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:o.source,budget_tokens:o.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:r,continuation_available:d.length>0,recovery_budget_multiplier:u?1:f.recovery_budget_multiplier,continuations:d,restore_with:u?"recovery":`Retry with --output-budget ${f.output_budget} because no declared row collection can be continued.`,recovery:u?{cursor:u.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:`--output-budget ${f.output_budget}`,sdk:{outputBudget:f.output_budget},mcp:{outputBudget:f.output_budget}}}}function Uo(e,t,n,o,r){if(typeof n!="string"||!Array.isArray(e.items))return!1;let i=e.items.length,s=t.length;if(i===0||i>=s)return!1;let a;try{a=ut(n)}catch{return!1}let c=a.after_index;if(c===void 0)return!1;let d=t[i-1];if(Object.prototype.toString.call(d)!=="[object Object]")return!1;let u=Reflect.get(d,"id");if(typeof u!="string"||u.length===0)return!1;let _=o?c-(s-i):c+r+i;return _<0?!1:(e.next_cursor=_e(a.fingerprint,u,_,a.snapshot),!0)}function pa(e,t,n,o,r){let i=new Map(Y(e).map(c=>{let d=Array.isArray(c.value)?c.value.length:Object.keys(c.value).length,u=o?.path===c.path,_=B(n,c.path);return[c.path,{rows:d,totalRows:u?o.total_rows:d,baseOffset:u&&!_?o.offset:0,backward:_,fingerprint:u?o.fingerprint:Me(c.path,c.value,n)}]})),s=typeof e.next_cursor=="string",a=o?.path==="items"?o.offset:0;return{collectionsBeforeBudget:i,originalItems:Array.isArray(t.items)?a>0?t.items.slice(a):t.items:[],originalItemOffset:a,cursorContinuesExistingPage:s,cursorSource:s?e.next_cursor:r.after,producer:t}}function ga(e,t,n,o,r,i,s,a,c,d){let u={...t,count_only:n},_=o.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(f=>v(f)&&f.verdict!=="pass").length:0,l=new Map;if(_>0&&l.set("assertions",_),o.command==="history"&&Array.isArray(e.diff))for(let f of ce(e))f.path.startsWith("diff.")&&l.set(f.path,Object.keys(f.value).length);return mo(e,r,i.tokens,l,d,f=>{de(f,u),Mo(f,o.command,a);let m=Uo(f,a.originalItems,a.cursorSource,a.cursorContinuesExistingPage,a.originalItemOffset);if(ma(f,o,r,i,m,c,a.collectionsBeforeBudget),o.command==="history"&&v(f.projection)){f.has_more=typeof f.next_cursor=="string"||f.applied_bound?.kind==="output_limit";let p=f.projection.row_key;typeof p=="string"&&Array.isArray(f[p])&&(f.count=f[p].length)}s!==void 0&&Object.assign(f,He(f,s,r,d))},o.command==="history"&&Array.isArray(e.diff),f=>B(o.command,f))}function Pn(e,t,n){let o=Co(e,t);if(!o)return n;let r=te(t),i=Ve(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?fe(s):void 0,c=ra(o),d=ia(o.command,n);if(a===void 0&&fa(o,i,d,r,t))return d;let u=ca(o,i),_=aa(d,o,i,a,t),l=_.projected;oe(l,l,t.outputRowContract===!1);let f=ee(l),m={contract_version:1,command:o.command,requested_dimensions:c,...No(u,l),precedence:o.precedence,...jo(o),legacy_aliases_used:o.legacy_aliases_used,migration_hints:o.migration_hints,estimated_tokens:0,within_budget:!f,strings_compacted:!1,rows_compacted:!1,result_omitted:f};if(l.read_output=m,l=i===void 0?l:He(l,i,m,r),U(l,m,r),u!==void 0&&m.estimated_tokens>u.tokens){let p=_o(o.command,t,l);p!==void 0&&(m.applied_depth="brief",m.degradation_reason="output_budget_reached",oe(l,p),l=pt(p,t)),m.estimated_tokens>u.tokens&&(l=ga(l,l,d.count_only===!0,o,m,u,i,_.continuationState,m.estimated_tokens,r))}return u!==void 0&&m.estimated_tokens>u.tokens?da(o,c,i,u,m.estimated_tokens,r):l}function ya(e){return v(e)&&v(e.context_intent)&&e.context_intent.result_omitted===!0}function ee(e){return ha(e)||ya(e)}function ha(e){return v(e)&&v(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function ds(e,t){let n=t.outputFormat??t.output_format;if(n==="json"||n==="toon")return n;let o=Co(e,t)?.encoding;return o?.value==="json"||o?.value==="toon"?o.value:void 0}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7e894d1f-fe1a-53f2-9a29-4e9846a9f986")}catch{}})();var Lo=["append","cancel","claim","close","comment_add","comment_edit","comment_delete","create","delete","docs_add","docs_remove","files_add","files_remove","files_discover","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","import","improvement_observe","learning_add","learning_edit","learning_delete","normalize","note_add","note_edit","note_delete","plan_create_metadata","plan_create_initial_step","plan_add_step","plan_reorder_step","plan_remove_step","plan_link_step","plan_unlink_step","plan_append_decision","plan_append_discovery","plan_append_validation","plan_resume","plan_approve","plan_materialize","plan_update_step","plan_complete_step","plan_block_step","policy_approve","policy_refused","release","reopen","restore","schema_migration","schema_migration_reference","test_run_track","tests_add","tests_remove","tests_update","update","update_audit","update_ownership_bypass","workspace_snapshot_restore","extension_migrations_apply","merge_reconcile"],$o=["history:author-acknowledge","settings:write","init:type_preset","templates:save","profile:apply-types","profile:apply-statuses","profile:apply-fields","profile:apply-config","schema:add-type","schema:remove-type","schema:add-status","schema:remove-status","schema:add-field","schema:remove-field","schema:apply-preset","schema:infer-types","schema:policy-put","schema:policy-remove","schema:policy-mode","assurance:bundle:apply","assurance:gate:verdict","telemetry:install_id","telemetry:first_run_prompt","telemetry:clear","item_format:auto_select_default","transaction_abandon"],Nt={"init:type-preset":"init:type_preset"},Bo=["^config:(?:set|unset):[a-z][a-z0-9_.:-]*$","^assurance:(?:measurement|invariant|gate):(?:put|remove)$","^schema_(?:rename_type|rename_status|remap_status|rename_field|remove_type|remove_status|remove_field)(?:_compensate)?$","^extension:[a-z][a-z0-9_-]*:[a-z][a-z0-9_]*$"],Fd={version:1,item:Lo,workspace:$o,aliases:Nt,patterns:Bo,read_policy:"preserve_original_operation",custom_operation_grammar:"extension:<package_name>:<snake_case_operation>",legacy_custom_operation_grammar:"lowercase segments separated by underscore, hyphen, colon, or dot; optional opaque colon-suffixed retry key",excluded_surfaces:["json_patch","on_write_hook","telemetry_span"]},ba=new Set([...Lo,...$o]),wa=Bo.map(e=>new RegExp(e,"u"));function Fo(e){return Object.hasOwn(Nt,e)?Nt[e]:e}function Gd(e){let t=Fo(e);if(ba.has(t)||wa.some(n=>n.test(t)))return t;throw new TypeError("Undeclared history operation; use a native contract identity or extension:<package_name>:<snake_case_operation>.")}function qd(e){let t=Fo(e),n=t.indexOf(":"),o=n<0?t:t.slice(0,n),r=n<0||n<t.length-1&&!/[\s\p{C}]/u.test(t.slice(n+1));if(/^[a-z][a-z0-9]*(?:[_.-][a-z0-9]+)*$/u.test(o)&&r)return t;throw new TypeError("History operation must use lowercase alphanumeric segments with an optional non-whitespace colon-suffixed retry key.")}export{ln as a,Ua as b,La as c,$a as d,fn as e,_n as f,Qa as g,_c as h,mc as i,zo as j,Aa as k,Kt as l,Wo as m,er as n,nr as o,Vt as p,or as q,rr as r,Ht as s,$ as t,Jt as u,Ra as v,Ta as w,Ye as x,Sa as y,xa as z,Ca as A,Ia as B,ja as C,gc as D,de as E,S as F,B as G,be as H,md as I,H as J,Nd as K,Pd as L,Fs as M,F as N,Md as O,Ud as P,Ld as Q,So as R,Hs as S,$d as T,Co as U,pt as V,Pn as W,ee as X,ha as Y,ds as Z,hn as _,Me as $,st as aa,fe as ba,Nc as ca,Pc as da,_e as ea,ut as fa,dt as ga,Mc as ha,di as ia,Uc as ja,Lc as ka,I as la,k as ma,Yc as na,pe as oa,Oi as pa,Xc as qa,Qc as ra,vi as sa,Zc as ta,eu as ua,tu as va,Ri as wa,Mn as xa,Ti as ya,mu as za,xi as Aa,Ln as Ba,pu as Ca,Fn as Da,Di as Ea,jn as Fa,zi as Ga,Qi as Ha,Hn as Ia,Ou as Ja,Su as Ka,xu as La,gs as Ma,uo as Na,td as Oa,ye as Pa,M as Qa,fd as Ra,xt as Sa,Ve as Ta,yo as Ua,Ct as Va,ho as Wa,Lo as Xa,$o as Ya,Nt as Za,Bo as _a,Fd as $a,Fo as ab,Gd as bb,qd as cb};
|
|
24
|
+
//# sourceMappingURL=chunk-S6GTALM4.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as ze}from"./chunk-2UQFFVQK.js";import{kb as q,lb as V,mb as W,nb as X,ra as Le,sa as Ae,va as Re,wa as ke}from"./chunk-63FM3TIG.js";import{F as me,b as j,c as B,f as ue}from"./chunk-52H6AELE.js";import{d as Be,e as Ge,h as $e}from"./chunk-DRBXOAGY.js";import{g as je}from"./chunk-XQZKGTZV.js";import{$ as Ue,P as z,R as H,T as Ne,V as R,aa as k,b as ce,ba as Pe,l as De,m as Ke,o as xe,p as Oe}from"./chunk-CZZKAGHE.js";import{Ba as Ce,Fa as Me,L as ve,N as E,ab as S,ca as Ie,gb as O,j as M,l as fe,r as Se,ra as Fe,sa as Ee,ta as Te}from"./chunk-EALGFJRP.js";import{ca as he,da as be,ea as $,ia as we}from"./chunk-S6GTALM4.js";import{Ac as G,bd as A,ca as h,kd as _e,sa as v,sc as pe,ta as x,uc as ye,yc as L,za as w,zc as ge}from"./chunk-YZUBG4W2.js";import{A as f,z as m}from"./chunk-QXOFSZR6.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="738a98bc-eaf0-578d-88e3-1c5f83c8894b")}catch{}})();function N(e,t="--limit"){if(e===void 0)return;let r=String(e).trim(),i=r.length===0?Number.NaN:Number(r);if(!Number.isInteger(i)||i<0)throw new f(`${t} must be a non-negative integer`,m.USAGE);return i}function He(e,t="--priority"){if(e===void 0)return;let r=String(e).trim(),i=r.length===0?Number.NaN:Number(r);if(!Number.isInteger(i)||i<0||i>4)throw new f(`${t} filter must be 0..4`,m.USAGE);return i}function ti(e,t,r="--type"){if(e===void 0)return;let i=x(e,t);if(!i)throw new f(`${r} filter must be one of ${t.types.join("|")}`,m.USAGE);return i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="75ecca0c-fac8-5a9b-9043-c65731daad4a")}catch{}})();function Y(e,t){if(e===void 0)return;let r=[],i="";for(let o=0;o<e.length;o+=1){let a=e[o];if(a==="\\"){let l=e[o+1];if(l===","||l==="\\"){i+=l,o+=1;continue}i+=a;continue}if(a===","){r.push(i),i="";continue}i+=a}r.push(i);let n=r.map(o=>o.trim());if(n.some(o=>o.length===0))throw new f(`${t.label} requires at least one non-empty value`,m.USAGE);let s=n.map(o=>t.normalize?.(o)??o);return[...new Set(s)]}function D(e,t){let r=Y(e,t);return r===void 0?void 0:new Set(r)}function qe(e,t,r="--type"){let i=Y(e,{label:r});if(i===void 0)return;let n=i.map(s=>{let o=x(s,t);if(!o)throw new f(`${r} filter token "${s}" must be one of ${t.types.join("|")}`,m.USAGE);return o});return new Set(n)}function Ve(e,t="--priority"){let r=Y(e,{label:t});if(r!==void 0)return new Set(r.map(i=>He(i,t)))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f9d73d74-7c4e-5ea9-b34c-c984b4c15ab3")}catch{}})();function We(e,t){let r=e.trim().toLowerCase();return t.alias_to_id.get(r)??r}function Je(e){return{isTerminal(t){return e.terminal_statuses.has(We(t,e))},classify(t){let r=We(t,e);return e.terminal_canceled_statuses.has(r)?"canceled":e.terminal_statuses.has(r)?"closed":e.blocked_statuses.has(r)?"blocked":e.draft_statuses.has(r)?"draft":r===e.open_status?"open":e.active_statuses.has(r)?"in_progress":"other"}}}function Q(e){return h(e.acceptance_criteria)===void 0}function J(e){return!Number.isFinite(e.estimated_minutes)}function Ze(e,t){return t.isTerminal(e.status)?h(e.resolution)===void 0:!1}function qt(e){return h(e.reviewer)===void 0}function Vt(e){return h(e.risk)===void 0}function Wt(e){return typeof e.confidence=="number"?!Number.isFinite(e.confidence):h(e.confidence)===void 0}function Xt(e){return h(e.sprint)===void 0}function Yt(e){return h(e.release)===void 0}function Z(e){return!!(e.acMissing||e.estimatesMissing||e.resolutionMissing||e.reviewerMissing||e.riskMissing||e.confidenceMissing||e.sprintMissing||e.releaseMissing||e.metadataMissing)}function Qt(e,t,r){return[[t.acMissing,Q(e)],[t.estimatesMissing,J(e)],[t.resolutionMissing,Ze(e,r)],[t.reviewerMissing,qt(e)],[t.riskMissing,Vt(e)],[t.confidenceMissing,Wt(e)],[t.sprintMissing,Xt(e)],[t.releaseMissing,Yt(e)]].every(([i,n])=>i!==!0||n)}function Jt(e,t){return Q(e)||J(e)||Ze(e,t)}function et(e,t,r){return Z(t)?!(!Qt(e,t,r)||t.metadataMissing&&!Jt(e,r)):!0}var ee=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function Zt(e,t){switch(t){case"acceptance_criteria":return!Q(e);case"estimated_minutes":return!J(e);case"resolution":return h(e.resolution)!==void 0;case"tags":return Array.isArray(e.tags)&&e.tags.length>0;default:return h(e.parent)!==void 0}}function er(e,t,r){return t==="resolution"?r.isTerminal(e.status):!0}function tr(e,t){return t===0?100:Math.round(e/t*1e3)/10}function Xe(){let e={};for(let t of ee)e[t]={present:0,applicable:0,percent:100};return e}function Ye(e,t,r){for(let i of ee){if(!er(t,i,r))continue;let n=e[i];n.applicable+=1,Zt(t,i)&&(n.present+=1)}}function Qe(e){for(let t of ee){let r=e[t];r.percent=tr(r.present,r.applicable)}}function di(e,t){let r=Xe(),i={};for(let n of e){Ye(r,n,t);let s=i[n.type]??(i[n.type]=Xe());Ye(s,n,t)}Qe(r);for(let n of Object.values(i))Qe(n);return{overall:r,by_type:i}}var rr={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function ir(e){return rr[e]}function nr(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function sr(e,t,r){switch(t){case"assignee":return[h(e.assignee)??null];case"parent":return[h(e.parent)??null];case"type":return[h(e.type)??null];case"status":return[h(e.status)??null];case"priority":return[typeof e.priority=="number"?`P${e.priority}`:null];default:{let i=r.tagPrefix?.trim(),n=(Array.isArray(e.tags)?e.tags:[]).filter(s=>typeof s=="string"&&s.length>0&&(!i||s.startsWith(i)));return n.length>0?n:[null]}}}function ci(e,t,r,i={}){let n=new Map,s=0;for(let a of e){s+=1;let l=r.classify(a.status);for(let d of sr(a,t,i)){let c=d??"\0empty",u=n.get(c);u||(u={label:d??ir(t),key:d,buckets:nr(),total:0},n.set(c,u)),u.buckets[l]+=1,u.total+=1}}let o=[...n.values()].sort((a,l)=>l.total!==a.total?l.total-a.total:a.key===null?1:l.key===null?-1:a.label.localeCompare(l.label));return{dimension:t,rows:o,total_items:s}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="67f9184e-08b6-5f21-9f92-e60974adbf1e")}catch{}})();var T=["notes","learnings","files","docs","tests","comments","deps","body","linked_command"];function I(e){return Array.isArray(e)&&e.length>0}function or(e){return typeof e=="string"&&e.trim().length>0}function ar(e){return Array.isArray(e)?e.some(t=>{if(typeof t!="object"||t===null)return!1;let r=t.command;return typeof r=="string"&&r.trim().length>0}):!1}function rt(e,t){switch(t){case"notes":return I(e.notes);case"learnings":return I(e.learnings);case"files":return I(e.files);case"docs":return I(e.docs);case"tests":return I(e.tests);case"comments":return I(e.comments);case"deps":return I(e.dependencies);case"body":return or(e.body);case"linked_command":return ar(e.tests)}}function it(e){return T.some(t=>e[t]!==void 0)}function nt(e,t){for(let r of T){let i=t[r];if(i===void 0)continue;let n=rt(e,r);if(i==="present"&&!n||i==="absent"&&n)return!1}return!0}function st(e){return T.some(t=>t!=="body"&&e[t]!==void 0)}function ot(e){return e.body!==void 0}function tt(e,t){return t===0?100:Math.round(e/t*1e3)/10}function lr(){let e={};for(let t of T)e[t]={present:0,total:0,percent:100};return e}function mi(e){let t=lr(),r=e.length;for(let o of e)for(let a of T)rt(o,a)&&(t[a].present+=1);for(let o of T)t[o].total=r,t[o].percent=tt(t[o].present,r);let i=t.body,n=r-i.present,s={present:n,total:r,percent:tt(n,r)};return{total_items:r,fields:t,body_populated:i,empty_body:s}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9a6eb9fd-03f3-562d-b3d5-08d6bb55ef8f")}catch{}})();var mt=e=>({acMissing:e.filterAcMissing===!0,estimatesMissing:e.filterEstimatesMissing===!0,resolutionMissing:e.filterResolutionMissing===!0,metadataMissing:e.filterMetadataMissing===!0,reviewerMissing:e.filterReviewerMissing===!0,riskMissing:e.filterRiskMissing===!0,confidenceMissing:e.filterConfidenceMissing===!0,sprintMissing:e.filterSprintMissing===!0,releaseMissing:e.filterReleaseMissing===!0}),at=[{field:"notes",presentKey:"hasNotes",absentKey:"noNotes",presentFlag:"--has-notes",absentFlag:"--no-notes"},{field:"learnings",presentKey:"hasLearnings",absentKey:"noLearnings",presentFlag:"--has-learnings",absentFlag:"--no-learnings"},{field:"files",presentKey:"hasFiles",absentKey:"noFiles",presentFlag:"--has-files",absentFlag:"--no-files"},{field:"docs",presentKey:"hasDocs",absentKey:"noDocs",presentFlag:"--has-docs",absentFlag:"--no-docs"},{field:"tests",presentKey:"hasTests",absentKey:"noTests",presentFlag:"--has-tests",absentFlag:"--no-tests"},{field:"comments",presentKey:"hasComments",absentKey:"noComments",presentFlag:"--has-comments",absentFlag:"--no-comments"},{field:"deps",presentKey:"hasDeps",absentKey:"noDeps",presentFlag:"--has-deps",absentFlag:"--no-deps"},{field:"body",presentKey:"hasBody",absentKey:"emptyBody",presentFlag:"--has-body",absentFlag:"--empty-body"},{field:"linked_command",presentKey:"hasLinkedCommand",absentKey:"noLinkedCommand",presentFlag:"--has-linked-command",absentFlag:"--no-linked-command"}],re=e=>{let t=at.find(r=>e[r.presentKey]===!0&&e[r.absentKey]===!0);if(t)throw new f(`Cannot combine ${t.presentFlag} with ${t.absentFlag} for the same field.`,m.USAGE);return Object.fromEntries(at.flatMap(r=>e[r.presentKey]===!0?[[r.field,"present"]]:e[r.absentKey]===!0?[[r.field,"absent"]]:[]))},lt=["priority","deadline","updated_at","created_at","title","parent"],dt=["asc","desc"],ft=new Set(Ne);function dr(e,t,r){let i=e.filter(o=>o.startsWith("item_list_item_read_failed:")).length,n=e.filter(o=>o.startsWith("item_list_directory_read_failed:")).length,s={status:t?"unchecked":i+n>0?"partial":"complete",unreadable_item_count:i,unreadable_directory_count:n};if(r&&s.status==="partial")throw new f(`List source is incomplete: ${i} item document(s) and ${n} item directory/directories could not be read.`,m.GENERIC_FAILURE,{code:"list_source_incomplete",why:"Strict list reads fail closed so agents and SDK consumers never treat an omitted item as a complete workspace.",nextSteps:["Run pm validate --check-storage-integrity to locate unreadable tracker artifacts.","Repair the reported files or align the installed decoder version, then retry."]});return s}function cr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length>0}var ur=[{key:"hasNotes",summaryKey:"has_notes"},{key:"hasLearnings",summaryKey:"has_learnings"},{key:"hasFiles",summaryKey:"has_files"},{key:"hasDocs",summaryKey:"has_docs"},{key:"hasTests",summaryKey:"has_tests"},{key:"hasComments",summaryKey:"has_comments"},{key:"hasDeps",summaryKey:"has_deps"},{key:"hasBody",summaryKey:"has_body"},{key:"hasLinkedCommand",summaryKey:"has_linked_command"},{key:"noNotes",summaryKey:"no_notes"},{key:"noLearnings",summaryKey:"no_learnings"},{key:"noFiles",summaryKey:"no_files"},{key:"noDocs",summaryKey:"no_docs"},{key:"noTests",summaryKey:"no_tests"},{key:"noComments",summaryKey:"no_comments"},{key:"noDeps",summaryKey:"no_deps"},{key:"emptyBody",summaryKey:"empty_body"},{key:"noLinkedCommand",summaryKey:"no_linked_command"}],mr=[{key:"filterReviewerMissing",summaryKey:"filter_reviewer_missing"},{key:"filterRiskMissing",summaryKey:"filter_risk_missing"},{key:"filterConfidenceMissing",summaryKey:"filter_confidence_missing"},{key:"filterSprintMissing",summaryKey:"filter_sprint_missing"},{key:"filterReleaseMissing",summaryKey:"filter_release_missing"}];function pt(e,t){for(let r of ur)t[r.key]===!0&&(e[r.summaryKey]=!0)}function yt(e,t){for(let r of mr)t[r.key]===!0&&(e[r.summaryKey]=!0)}function fr(e,t,r){for(let i of r){let n=t[i.optionKey];n!==void 0&&(e[i.summaryKey]=i.normalize?i.normalize(n):n)}}function gt(e){let t={};return pt(t,e),t}function _t(e){let t={};return yt(t,e),t}var pr=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"}],yr=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"},{optionKey:"limit",summaryKey:"limit"},{optionKey:"offset",summaryKey:"offset"},{optionKey:"includeBody",summaryKey:"include_body"},{optionKey:"compact",summaryKey:"compact"},{optionKey:"fields",summaryKey:"fields"}],gr=[{key:"filterAcMissing",summaryKey:"filter_ac_missing"},{key:"filterEstimatesMissing",summaryKey:"filter_estimates_missing"},{key:"filterResolutionMissing",summaryKey:"filter_resolution_missing"},{key:"filterMetadataMissing",summaryKey:"filter_metadata_missing"}],_r="-7d";function ht(e){let{filtersStatus:t,options:r,treeEnabled:i,treeDepth:n,sortField:s,sortOrder:o,runtimeFieldFilters:a}=e,l={};return t!==null&&(l.status=t),r.dependencyBlocked===!0&&(l.blocked_semantics="status_or_dependency"),fr(l,r,pr),wt(l,r),r.filterAcMissing===!0&&(l.filter_ac_missing=!0),r.filterEstimatesMissing===!0&&(l.filter_estimates_missing=!0),r.filterResolutionMissing===!0&&(l.filter_resolution_missing=!0),r.filterMetadataMissing===!0&&(l.filter_metadata_missing=!0),yt(l,r),pt(l,r),r.limit!==void 0&&(l.limit=r.limit),r.offset!==void 0&&(l.offset=r.offset),r.includeBody===!0&&(l.include_body=!0),r.fields!==void 0&&(l.fields=r.fields),i&&(l.tree=!0,n!==void 0&&(l.tree_depth=n)),s!==void 0&&(l.sort=s,l.order=o),cr(a)&&(l.runtime_filters=a),l}function ie(e,t,r){let i=E(e.status,r),n=E(t.status,r);if(i!==n)return i?1:-1;let s=e.priority-t.priority;if(s!==0)return s;let o=L(t.updated_at,e.updated_at);return o!==0?o:(e.id??"").localeCompare(t.id??"")}function hr(e,t){return[...e].sort((r,i)=>ie(r,i,t))}function ct(e,t){if(e!==void 0)return G(e,new Date,t)}function K(e,t){if(e==null)return;let r=String(e).trim();if(r.length!==0)return G(r,new Date,t)}function bt(e){let t=e.updatedAfter!=null&&String(e.updatedAfter).trim().length>0;if([e.today===!0,e.recent===!0,t].filter(r=>r).length>1)throw new f("Choose only one updated_at window: --today, --recent, or --updated-after.",m.USAGE);if(e.today===!0){let r=new Date;return r.setHours(0,0,0,0),r.toISOString()}return e.recent===!0?K(_r,"recent"):K(e.updatedAfter,"updated-after")}function wt(e,t){t.today===!0&&(e.today=!0),t.recent===!0&&(e.recent=!0)}function St(e){if(e==null)return;let t=String(e).trim();if(t.length===0)throw new f("--ids requires at least one non-empty item ID",m.USAGE);let r=t.split(",").map(i=>i.trim()).filter(i=>i.length>0);if(r.length===0)throw new f("--ids requires at least one non-empty item ID",m.USAGE);return new Set(r)}function ne(e){if(e===void 0)return;let t=String(e).trim(),r=t.length===0?Number.NaN:Number(t);if(!Number.isInteger(r)||r<0)throw new f("Offset filter must be a non-negative integer",m.USAGE);return r}function vt(e){if(e===void 0)return;let t=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)throw new f("List --fields requires a comma-separated list of field names",m.USAGE);return[...new Set(t)]}function It(e,t=e.projectionCommand??"list"){let r=e.compact===!0,i=e.brief===!0,n=e.full===!0,s=vt(e.fields);if(Number(r)+Number(i)+Number(n)+ +(s!==void 0)>1)throw new f("List projection options are mutually exclusive. Use one of --compact, --brief, --full, or --fields.",m.USAGE,{code:"projection_options_mutually_exclusive",recovery:{suggested_retry:`pm ${t} --brief`,suggested_retry_args:[t,"--brief"]}});if(n)return{mode:"full",fields:[]};if(i){let o=se(e.sort);return{mode:"brief",fields:[...new Set([...B,o??"priority"])]}}return r?{mode:"compact",fields:[...j]}:s?{mode:"fields",fields:[...new Set(s.map(o=>F(o)))]}:{mode:"full",fields:[]}}function F(e){return e.startsWith("item.")?e.slice(5):e}function br(e,t,r){if(e.mode!=="fields")return;let i=ue(t),n=new Set(i),s=e.fields.filter(o=>!n.has(F(o)));if(s.length>0){let o=[r,"--fields",e.fields.filter(a=>!s.includes(a)).join(",")||"id,title,status"];throw new f(`Unknown list --fields value(s): ${s.join(", ")}`,m.USAGE,{code:"unknown_field_projection",required:"Choose fields from recovery.allowed_values; each field also accepts an item. prefix.",examples:["pm list --status open --fields id,title,status","pm list --fields id,title,parent,priority --limit 10","pm list --all --fields id,title,body --limit 5"],recovery:{allowed_values:i,suggested_retry:pe(o),suggested_retry_args:o}})}}var wr=new Map([["updated","updated_at"],["update","updated_at"],["modified","updated_at"],["created","created_at"],["create","created_at"]]);function se(e){if(e===void 0)return;let t=e.trim().toLowerCase(),r=wr.get(t);if(r)return r;if(!lt.includes(t))throw new f(`Sort field must be one of ${lt.join("|")} (aliases: updated->updated_at, created->created_at)`,m.USAGE);return t}function Ft(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!dt.includes(t))throw new f(`Sort order must be one of ${dt.join("|")}`,m.USAGE);return t}function Sr(e){return N(e,"--tree-depth")}function Et(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new f("Assignee filter must be one of assigned|unassigned",m.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new f(`Invalid assignee filter "${e}". Allowed: assigned|unassigned`,m.USAGE);return t}function ut(e,t){return Ae(e,t,{strict:!0})}function Tt(e){return D(e,{label:"--tag",normalize:t=>t.toLowerCase()})}function vr(e,t,r){let i=Tt(t);if(i===void 0)return;let n=new Set(e.flatMap(o=>o.tags.map(a=>a.trim().toLowerCase()))),s=[...i].filter(o=>!n.has(o));s.length>0&&r.push(`unknown_tags:${s.join(",")}`)}function Ir(e,t){if(e&&[...e].some(r=>r.toLowerCase()==="none"||r.toLowerCase()==="null"))throw new f('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',m.USAGE);if(e!==void 0&&t==="unassigned")throw new f("Cannot combine --assignee with --assignee-filter unassigned",m.USAGE)}function Fr(e,t,r,i){let n=D(t.assignee,{label:"--assignee"}),s=Et(t.assigneeFilter);Ir(n,s);let o=mt(t),a=re(t);return{idsFilter:St(t.ids),statusSet:e&&e.length>0?new Set(e):void 0,excludeTerminal:t.excludeTerminal===!0,typeFilter:qe(t.type,r),tagFilters:Tt(t.tag),priorityFilter:Ve(t.priority),deadlineBefore:ct(t.deadlineBefore,"deadline-before"),deadlineAfter:ct(t.deadlineAfter,"deadline-after"),updatedAfter:bt(t),updatedBefore:K(t.updatedBefore,"updated-before"),createdAfter:K(t.createdAfter,"created-after"),createdBefore:K(t.createdBefore,"created-before"),assigneeFilter:n,assigneeModeFilter:s,parentFilter:t.parent?.trim(),treeEnabled:t.tree===!0,sprintFilter:D(t.sprint,{label:"--sprint"}),releaseFilter:D(t.release,{label:"--release"}),missingMetadataFilters:o,missingMetadataActive:Z(o),lifecycleClassifier:Je(i),contentFieldFilters:a,contentFiltersActive:it(a)}}function Er(e,t,r){return t.idsFilter&&!t.idsFilter.has(e.id)||t.statusSet&&!t.statusSet.has(e.status)||t.excludeTerminal&&E(e.status,r)||t.typeFilter&&!t.typeFilter.has(e.type)||t.tagFilters&&![...t.tagFilters].some(i=>(e.tags??[]).some(n=>n.trim().toLowerCase()===i))?!1:t.priorityFilter===void 0||t.priorityFilter.has(e.priority)}function Tr(e,t){return ge(e,t)}function Cr(e,t){return t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee?!1:t.assigneeFilter===void 0||e.assignee!==void 0&&t.assigneeFilter.has(e.assignee)}function Mr(e,t,r){let i=e.parent?.trim().toLowerCase(),n=[...new Set([...r?.get(e.id.trim().toLowerCase())??[],...i?[i]:[]])];return t.parentFilter!==void 0&&!t.treeEnabled&&!n.includes(t.parentFilter.trim().toLowerCase())||t.sprintFilter!==void 0&&(e.sprint===void 0||!t.sprintFilter.has(e.sprint))?!1:t.releaseFilter===void 0||e.release!==void 0&&t.releaseFilter.has(e.release)}function Lr(e,t,r,i,n){return!(!Er(e,t,r)||!Tr(e,t)||!Cr(e,t)||!Mr(e,t,n)||t.missingMetadataActive&&!et(e,t.missingMetadataFilters,t.lifecycleClassifier)||t.contentFiltersActive&&!nt(e,t.contentFieldFilters)||!ke(e,i))}function Ct(e,t,r,i,n,s,o){let a=Fr(t,r,i,n);return e.filter(l=>Lr(l,a,n,s,o))}function C(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function te(e,t,r,i){let n=e,s=typeof n.title=="string"?n.title:"",o=i??C(typeof n.parent=="string"?n.parent:void 0)??null;return{...e,tree_depth:t,tree_parent:o,tree_children:r,tree_title:`${" ".repeat(t)}${s}`}}function Ar(e,t){let r=new Map,i=new Map;for(let n of e){let s=n.id.trim().toLowerCase();r.set(s,n);let o=t?t.parents_by_child.get(s)??[]:[C(n.parent)?.toLowerCase()].filter(a=>a!==void 0);for(let a of o){let l=i.get(a)??[];l.push(n),i.set(a,l)}}return{byId:r,childrenByParent:i}}function Rr(e,t,r,i,n){return t?[...i.get(t.toLowerCase())??[]]:e.filter(s=>(n?n.parents_by_child.get(s.id.trim().toLowerCase())??[]:[C(s.parent)?.toLowerCase()].filter(o=>o!==void 0)).every(o=>!r.has(o)))}function Mt(e,t,r,i,n=e){let{byId:s,childrenByParent:o}=Ar(e,i),a=Rr(e,t,s,o,i),l=[],d=new Set,c=new Map(n.map(p=>[p.id.trim().toLowerCase(),p.id.trim()])),u=[...a].reverse().map(p=>({node:p,depth:0,parentId:t===void 0?void 0:c.get(t.trim().toLowerCase())??t.trim()}));for(;u.length>0;){let{node:p,depth:y,parentId:g}=u.pop(),_=p.id.trim().toLowerCase();if(d.has(_))continue;d.add(_);let b=o.get(_)??[];if(l.push(te(p,y,b.length,g)),!(r!==void 0&&y>=r))for(let P of[...b].reverse())u.push({node:P,depth:y+1,parentId:c.get(_)})}if(t===void 0&&r===void 0)for(let p of e){let y=p.id.trim().toLowerCase();d.has(y)||(d.add(y),l.push(te(p,0,o.get(y)?.length??0)))}return l}function Lt(e,t){return e===t?0:e===null?1:t===null?-1:e.localeCompare(t)}function At(e,t){return e===t?0:e===null?1:t===null?-1:L(e,t)}function Rt(e,t,r){switch(r){case"priority":return e.priority-t.priority;case"deadline":return At(e.deadline??null,t.deadline??null);case"updated_at":return L(e.updated_at,t.updated_at);case"created_at":return L(e.created_at,t.created_at);case"title":return(e.title??"").localeCompare(t.title??"");case"parent":return Lt(e.parent??null,t.parent??null);default:return 0}}function kt(e,t,r,i){return t?[...e].sort((n,s)=>{let o=Rt(n,s,t);if(o!==0)return r==="desc"?-o:o;let a=ie(n,s,i);return r==="desc"?-a:a}):hr(e,i)}function Dt(e,t,r=!1){let i=F(t.trim());if(i.length===0)return null;let n=e;return r&&i==="title"&&typeof n.tree_title=="string"?n.tree_title:Object.prototype.hasOwnProperty.call(n,i)?n[i]??null:null}function oe(e,t,r=!1){return t.mode==="full"?e:e.map(i=>{let n={};for(let s of t.fields)n[s]=Dt(i,s,r);return n})}function Kt(e){let t=[];for(let r of e)t.push(r.metadata_key);return[...t,...ce(A())]}function xt(e,t){let r=N(e.limit);if(r!==void 0)return r;if(e.noTruncate!==!0)return t>=1e4?20:void 0}function kr(e,t,r){return t.after===void 0?ne(t.offset)??0:we(e,t.after,r,i=>i.id)}function Ot(e,t,r){return{...e!==void 0?{applied_limit:e}:{},has_more:t,truncated:t,next_cursor:r??null}}async function Dr(e,t){let r=w(process.cwd(),t.path);await O(r);let i=await S(r),n=M(i.schema),s=fe(i.schema),o=e.projectionCommand??"list",a=It(e,o);return br(a,Kt(s.definitions),o),{pmRoot:r,settings:i,statusRegistry:n,runtimeFieldFilters:Re(e,s,"list"),typeRegistry:v(i,A()),projection:a}}async function Kr(e,t,r){let i=t.projection.fields.some(l=>F(l)==="body"),n=t.projection.mode==="full"||t.projection.fields.some(l=>ft.has(F(l))),s=re(e),o=st(s),a=ot(s);return e.includeBody||i||a?await Pe(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema):n||o?await Ue(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema):await k(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema)}function xr(e){let t=se(e.sort),r=Ft(e.order)??"asc",i=e.tree===!0;if(!i&&e.treeDepth!==void 0)throw new f("List --tree-depth requires --tree",m.USAGE);if(!t&&e.order!==void 0)throw new f("List --order requires --sort",m.USAGE);return{sortField:t,sortOrder:r,treeEnabled:i,treeDepth:i?Sr(e.treeDepth):void 0,parentRoot:i?C(e.parent):void 0}}function Or(e,t,r){let i=ut(t.status,r),n;t.lifecycleBucket==="in_progress"?n=[r.in_progress_status]:t.lifecycleBucket==="open"&&(n=[...r.active_statuses].filter(d=>d!==r.in_progress_status).sort((d,c)=>d.localeCompare(c)));let s=i??n??ut(e,r),o=Le(t.status),a=i||o?{...t,excludeTerminal:!1}:t,l="all";return o?l="all":i!==void 0?l=i.length===1?i[0]:i:t.lifecycleBucket!==void 0?l=t.lifecycleBucket:s!==void 0?l=s.length===1?s[0]:s:a.excludeTerminal===!0&&(l=null),{resolvedStatus:s,explicitAllStatuses:o,effectiveOptions:a,filtersStatus:l}}function Nr(e,t,r,i,n){if(t.after!==void 0&&t.offset!==void 0)throw new f("List --after cannot be combined with --offset.",m.USAGE);let s=xt(t,e.length),o=kr(e,t,n),a=s===void 0?e.slice(o):e.slice(o,o+s),l=oe(a,r,i),d=e.length,c=a.length>0&&o+a.length<d,u=c&&a.length>0?$(n,a[a.length-1].id,o+a.length-1):void 0;return{projected:l,totalMatched:d,pageExtras:Ot(s,c,u)}}function Nt(e,t,r,i){return be("list",{pmRoot:i,status:e,options:he(t,me),sort:r.sortField??"default",order:r.sortOrder,tree:r.treeEnabled,tree_depth:r.treeDepth??null})}async function Ur(e){let{options:t,runtime:r,statusSelection:i,ordering:n}=e,s=new Set(["status","limit","offset","compact","brief","full","fields","format","stream","includeBody","excludeTerminal","dependencyBlocked","lifecycleBucket","noTruncate","projectionCommand","truncate","notes","learnings","files","docs","tests","comments","deps","linkedCommand"]),o=[r.projection.mode==="full",r.projection.fields.some(y=>{let g=F(y);return g==="body"||ft.has(g)})].includes(!0);if([t.limit===void 0,t.after!==void 0,t.noTruncate===!0,t.includeBody===!0,t.dependencyBlocked===!0,t.strictRead===!0,n.treeEnabled,n.sortField!==void 0,o,_e(),Object.keys(r.runtimeFieldFilters).length>0,Object.entries(t).some(([y,g])=>g!==void 0&&!s.has(y))].includes(!0))return null;let a=await R(r.pmRoot,[...new Set(Object.values(r.typeRegistry.type_to_folder))]);if(!a)return null;let l=N(t.limit),d=ne(t.offset)??0,c=await z({pmRoot:r.pmRoot,expectedSourceCursor:a.source_cursor,query:{statuses:i.resolvedStatus,excludeStatuses:i.resolvedStatus===void 0&&i.effectiveOptions.excludeTerminal===!0?[...r.statusRegistry.terminal_statuses]:void 0,terminalStatuses:[...r.statusRegistry.terminal_statuses],limit:l,offset:d}});if(!c)return null;let u=c.items.length>0&&d+c.items.length<c.total,p=u?$(Nt(i.filtersStatus,t,n,r.pmRoot),c.items.at(-1).id,d+c.items.length-1):void 0;return{projected:oe(c.items,r.projection,!1),totalMatched:c.total,pageExtras:Ot(l,u,p)}}function Pr(e){let{filtersStatus:t,options:r,noTruncate:i,treeEnabled:n,treeDepth:s,sortField:o,sortOrder:a,runtimeFieldFilters:l}=e,d={};t!==null&&(d.status=t),r.dependencyBlocked===!0&&(d.blocked_semantics="status_or_dependency");let c=r;for(let u of yr){let p=c[u.optionKey];p!=null&&(d[u.summaryKey]=p)}for(let u of gr)c[u.key]===!0&&(d[u.summaryKey]=!0);return Object.assign(d,_t(r),gt(r)),wt(d,r),i&&(d.no_truncate=!0),r.strictRead===!0&&(d.strict_read=!0),n&&(d.tree=!0,s!==void 0&&(d.tree_depth=s)),o!==void 0&&(d.sort=o,d.order=a),d.runtime_filters=l,d}async function qi(e,t,r){let i=await Dr(t,r),n=[],s=xr(t),o=Or(e,t,i.statusRegistry),a=t.noTruncate===!0,l=await Ur({options:t,runtime:i,statusSelection:o,ordering:s}),d=l;if(!d){let g=await Kr(t,i,n),_=s.treeEnabled||C(t.parent)!==void 0?$e(Ge(g,Be())):void 0;vr(g,t.tag,n);let b=Ct(g,o.resolvedStatus,o.effectiveOptions,i.typeRegistry,i.statusRegistry,i.runtimeFieldFilters,_?.parents_by_child),P=t.dependencyBlocked===!0?(()=>{let zt=je(g,i.statusRegistry);return b.filter(Ht=>zt.has(Ht.id.trim().toLowerCase()))})():b,de=kt(P,s.sortField,s.sortOrder,i.statusRegistry),$t=s.treeEnabled?Mt(de,s.parentRoot,s.treeDepth,_,g):de;d=Nr($t,t,i.projection,s.treeEnabled,Nt(o.filtersStatus,t,s,i.pmRoot))}let c=ye(),u=[...new Set(n)].sort((g,_)=>g.localeCompare(_)),p=dr(u,l!==null,t.strictRead===!0),y=i.projection.mode==="full"?null:[...i.projection.fields];if(i.projection.mode==="compact"&&t.compact===!0){let g=ht({filtersStatus:o.filtersStatus,options:t,treeEnabled:s.treeEnabled,treeDepth:s.treeDepth,sortField:s.sortField,sortOrder:s.sortOrder,runtimeFieldFilters:i.runtimeFieldFilters});return{items:d.projected,count:d.projected.length,total:d.totalMatched,...d.pageExtras,completeness:p,filters:g,projection:{mode:"compact",fields:y},...u.length>0?{warnings:u}:{}}}return{items:d.projected,count:d.projected.length,total:d.totalMatched,...d.pageExtras,completeness:p,filters:Pr({filtersStatus:o.filtersStatus,options:t,noTruncate:a,treeEnabled:s.treeEnabled,treeDepth:s.treeDepth,sortField:s.sortField,sortOrder:s.sortOrder,runtimeFieldFilters:i.runtimeFieldFilters}),projection:{mode:i.projection.mode,fields:y},sorting:{sort:s.sortField??"default",order:s.sortField?s.sortOrder:"asc",...s.sortField===void 0&&!s.treeEnabled?{effective_keys:[["status_registry:nonterminal_before_terminal","asc"],["priority","asc"],["updated_at","desc"],["id","asc"]]}:{}},now:c,...u.length>0?{warnings:u}:{}}}var Vi={applyFilters:Ct,buildCompactListFilterSummary:ht,buildContentFilterEcho:gt,buildGovernanceMissingFilterEcho:_t,resolveContentFieldFilters:re,resolveMissingMetadataFilters:mt,compareBySortField:Rt,compareDefaultSort:ie,compareNullableString:Lt,compareNullableTimestamp:At,normalizeProjectionField:F,parseAssigneeFilter:Et,parseFieldSelectors:vt,parseIdsFilter:St,parseOffset:ne,parseProjectionConfig:It,resolveListUpdatedAfter:bt,resolveListPageLimit:xt,parseSortField:se,parseSortOrder:Ft,orderItemsAsTree:Mt,projectListItems:oe,readListFieldValue:Dt,runtimeMetadataKeysForProjection:Kt,sortItems:kt,trimNonEmpty:C,withTreeMetadata:te};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="eb2e6046-156c-56ee-a03a-ecaa1cccfb45")}catch{}})();function pn(e,t){let r=Me(e),i=e.length>0?e[e.length-1].after_hash:Te(),n=t===void 0||r.item_hash_version===void 0?void 0:Ee(t,r.item_hash_version,Se(e.at(-1)?.hash_algorithm)),s=t===void 0?void 0:n===void 0?Fe(t):n[Math.max(0,n.indexOf(i))],o=s===void 0?void 0:s===i,a=[...r.errors];return o===!1&&a.push("verify_failed:current_item_hash_mismatch"),{ok:a.length===0,entries:e.length,errors:a,latest_after_hash:e.length>0?e[e.length-1].after_hash:void 0,current_item_hash:s,current_matches_latest:o}}async function yn(e,t,r={}){let i=w(r.cwd??process.cwd(),r.pmRoot);await O(i);let n=await S(i),s=v(n,A()),o=await ze(i,e,n,s.type_to_folder),a=await Ie(o.historyPath,o.id);if(a.length===0)throw new f(`No history exists for ${o.id}; point-in-time reads are unavailable.`,m.NOT_FOUND);let l=Ke(t,a),d=Oe(xe(a,l.historyIndex),l),c=Ce(d,{schema:n.schema});if(c.metadata.id!==o.id)throw new f(`History target resolved to item ${c.metadata.id}, expected ${o.id}.`,m.GENERIC_FAILURE);let u=a[l.historyIndex],p=De(a,!0);return{document:c,reconstructed:!0,as_of_version:p===null?null:p+l.historyIndex+1,as_of_timestamp:u.ts,target:l,history_length:a.length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e524f0ad-faad-5d89-b8f5-1283979919ad")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="67d97df8-6551-52ed-9307-8b573a087831")}catch{}})();var U=1e6;function ae(e,t=U,r=.8,i=!1){let n=new Set,s=(c,u)=>{if(n.add(`${c}:${u}`),n.size>t)throw new f(`Duplicate sweep exceeded ${t} candidate pairs; narrow it with statuses or since.`,m.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the duplicate query or increase its similarity threshold. No partial result was returned."})};if(i||r===0){for(let c=0;c<e.length;c+=1)for(let u=0;u<c;u+=1)s(u,c);return n}let o=new Map;for(let{prepared:c}of e)for(let u of c.tokens)o.set(u,(o.get(u)??0)+1);let a=new Map,l=new Map,d=new Map;for(let[c,{prepared:u}]of e.entries()){let p=[...u.tokens].sort((_,b)=>o.get(_)-o.get(b)||_.localeCompare(b)),y=p.length-Math.ceil(r*p.length-1e-12)+1,g=[{index:a,keys:[u.normalized],lengthFilter:!1},{index:l,keys:r<=.99?u.issueCodes:[],lengthFilter:!1},{index:d,keys:p.length===0?[""]:p.slice(0,y),lengthFilter:!0}];for(let _ of g)jr(e,c,_,r,s)}return n}function jr(e,t,r,i,n){let s=e[t].prepared.tokens.length;for(let o of r.keys){let a=r.index.get(o)??[];for(let l of a){let d=e[l].prepared.tokens.length;r.lengthFilter&&Math.min(d,s)/Math.max(d,s)+1e-12<i||n(l,t)}a.push(t),r.index.set(o,a)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a5f450bd-8970-5b1b-8250-b76b7818e6e1")}catch{}})();var Br=3,Ut=20,Gr=.8,$r=100,Pt=1e3;function Gn(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`,`likely_duplicate_recovery:${e.recovery.action}:${e.recovery.item_id}`]}async function zr(e,t){let r=e.items[0],i=w(t.cwd??process.cwd(),t.pmRoot),n=M((await S(i)).schema);return E(r.status,n)?{action:"reopen",item_id:r.id,command:`pm item reopen ${r.id} "<recurrence reason>"`,args:["item","reopen",r.id,"<recurrence reason>"]}:{action:"reuse",item_id:r.id,command:`pm get ${r.id} --full`,args:["get",r.id,"--full"]}}function le(e){let t=e.limit??Br,r=e.threshold??Gr;if(!Number.isSafeInteger(t)||t<0||t>Ut)throw new f(`Similarity limit must be an integer from 0 to ${Ut}.`,m.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new f("Similarity threshold must be a number from 0 to 1.",m.USAGE);return{limit:t,threshold:r}}function jt(e){let t=e.limit??$r;if(!Number.isSafeInteger(t)||t<0||t>Pt)throw new f(`Duplicate cluster limit must be an integer from 0 to ${Pt}.`,m.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new f("Duplicate cluster --since must be a valid ISO timestamp.",m.USAGE);return{limit:t,since:r}}async function Hr(e,t){let r=w(e.cwd??process.cwd(),e.pmRoot),i=await S(r),n=v(i),s=e.statuses?.map(u=>u.trim().toLowerCase()).filter(Boolean);if(e.statuses!==void 0&&s?.length===0)throw new f("Duplicate cluster statuses must include at least one lifecycle status or all.",m.USAGE);let o=M(i.schema),a=s?.map(u=>{if(u==="all")return u;let p=ve(u,o);if(!p)throw new f(`Unknown duplicate-cluster status "${u}". Allowed: all, ${o.definitions.map(y=>y.id).join(", ")}.`,m.USAGE);return p}),l=a?.includes("all")===!0;if(l&&a?.some(u=>u!=="all"))throw new f('The "all" status cannot be combined with other statuses.',m.USAGE);let d=l?void 0:a,c=d?new Set(d):void 0;return{items:(await k(r,i.item_format,n.type_to_folder,void 0,i.schema)).filter(u=>(!c||c.has(u.status))&&(!t||new Date(u.created_at).getTime()>=t.getTime())),statuses:d}}var $n={buildDuplicateClusters:Gt,collectDuplicateCandidatePairs:ae,createDuplicateUnionFind:Bt};function Bt(e){let t=Array.from({length:e},(r,i)=>i);return{parent:t,findRoot:r=>{let i=r;for(;t[i]!==i;)i=t[i];for(;t[r]!==r;){let n=t[r];t[r]=i,r=n}return i}}}function qr(e,t,r,i){let n=[];for(let s of t){let[o,a]=s.split(":").map(u=>Number.parseInt(u,10)),l=X(e[o].prepared,e[a].prepared);if(l.score<r)continue;let d=i.findRoot(o),c=i.findRoot(a);d!==c&&(i.parent[c]=d),n.push({left_id:e[o].item.id,right_id:e[a].item.id,...l})}return n}function Gt(e,t,r,i){let n=new Map;for(let a of e.keys()){let l=r.findRoot(a),d=n.get(l)??[];d.push(a),n.set(l,d)}let s=new Map(e.map(({item:a},l)=>[a.id,r.findRoot(l)])),o=new Map;for(let a of t){let l=s.get(a.left_id),d=o.get(l)??[];d.push(a),o.set(l,d)}return[...n.values()].filter(a=>a.length>1).map(a=>{let l=(o.get(r.findRoot(a[0]))??[]).sort((d,c)=>c.score-d.score||d.left_id.localeCompare(c.left_id)||d.right_id.localeCompare(c.right_id));return{id:e[a[0]].item.id,items:a.map(d=>{let c=e[d].item;return{id:c.id,title:c.title,status:c.status,type:c.type}}),matches:l,max_score:l[0]?.score??0}}).sort((a,l)=>l.max_score-a.max_score||a.id.localeCompare(l.id)).slice(0,i)}function Vr(e,t,r,i,n){return t.filter(s=>!r.has(s.id)).map(s=>({id:s.id,title:s.title,status:s.status,type:s.type,...W(e,s.title)})).filter(s=>s.score>=i).sort((s,o)=>o.score-s.score||s.id.localeCompare(o.id)).slice(0,n)}async function Wr(e,t={}){let r=e.title.trim();if(r.length===0)throw new f("Similarity candidate title must not be empty.",m.USAGE);let{limit:i,threshold:n}=le(t),s=w(t.cwd??process.cwd(),t.pmRoot),o=await S(s),a=v(o),l=await R(s,Object.values(a.type_to_folder)),d=q(r),c=l&&d.length>0?await H({pmRoot:s,expectedSourceCursor:l.source_cursor,query:d.map(y=>`"${y.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(i*10,50)}):null,u=c===null?await k(s,o.item_format,a.type_to_folder,void 0,o.schema):c.items,p=Vr(r,u,new Set(e.excludeIds??[]),n,i);return{items:p,count:p.length,threshold:n,source:c?"persistent_index":"metadata_fallback"}}function Xr(e,t={}){let{threshold:r}=le({...t,limit:void 0}),{limit:i}=jt(t),n=new Set;for(let c of e){if(!c.id.trim()||n.has(c.id))throw new f("Duplicate analysis requires unique non-empty item ids.",m.USAGE);n.add(c.id)}let s=[...e].sort((c,u)=>c.id.localeCompare(u.id)).map(c=>({item:c,prepared:V(c.title)})),o=ae(s,U,r,t.exhaustive===!0),a=Bt(s.length),l=qr(s,o,r,a),d=Gt(s,l,a,i);return{clusters:d,count:d.length,threshold:r,cost:{item_count:s.length,algorithm:t.exhaustive===!0||r===0?"exhaustive":"prefix_exact",possible_pairs:s.length*(s.length-1)/2,pair_limit:U,recall_guarantee:"exact",candidate_pairs:o.size,scored_pairs:o.size}}}async function zn(e={}){le({...e,limit:void 0});let{since:t}=jt(e),{items:r,statuses:i}=await Hr(e,t);return{...Xr(r,e),source:"metadata_scan",filters:{statuses:i??null,since:e.since??null}}}async function Hn(e,t){if(t.mode==="off")return;let r=await Wr(e,t);if(r.count===0)return;let i=await zr(r,t),n=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!n){let s=r.items.map(a=>`${a.id} (${a.status}): ${a.title}`).join("; "),o=i.action==="reopen"?"Reopen the canonical item":"Reuse the canonical item";throw new f(`Likely duplicate item(s) found: ${s}. ${o} or pass --allow-duplicate with explicit intent.`,m.CONFLICT,{code:"likely_duplicate",required:`${o}, or explicitly acknowledge the duplicate with --allow-duplicate.`,recovery:{suggested_flags:["--allow-duplicate"],suggested_retry:i.command,suggested_retry_args:i.args}})}return{mode:t.mode,bypassed:n,result:r,recovery:i}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f091d0c3-f2a7-5d76-8656-4aebe82e9798")}catch{}})();function Vn(e,t){let r=t??{};return e.filter(i=>r[i.id]!==i.updated_at).map(i=>i.id).sort((i,n)=>i.localeCompare(n))}export{N as a,He as b,ti as c,Y as d,D as e,qe as f,Ve as g,Je as h,Z as i,et as j,di as k,ci as l,it as m,nt as n,mi as o,mt as p,re as q,lt as r,dt as s,fr as t,gt as u,_t as v,qi as w,Vi as x,pn as y,yn as z,Gn as A,$n as B,Wr as C,Xr as D,zn as E,Hn as F,Vn as G};
|
|
2
|
+
//# sourceMappingURL=chunk-UPUIDGNJ.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{b as K}from"./chunk-
|
|
1
|
+
import{b as K}from"./chunk-JE3MFEQZ.js";import{Xa as H,ab as P,cb as L,gb as V}from"./chunk-EALGFJRP.js";import{F as U}from"./chunk-LSWUTTE6.js";import{$ as G,Jc as $,sa as B,uc as W,za as E}from"./chunk-YZUBG4W2.js";import{a as X,b as y,c as q}from"./chunk-FOA7XKWP.js";import{A as v,C as S,E as j,F,I as N,z as w}from"./chunk-QXOFSZR6.js";import{access as le,readFile as A,realpath as _}from"node:fs/promises";import{constants as ue}from"node:fs";import{execFile as me}from"node:child_process";import c from"node:path";import{promisify as de}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="6d1f8e03-97b4-5d83-b85c-e47f39c07d48")}catch{}})();var se="PM_SOURCE_CONTEXT_ACCESS",ce="PM_ALLOW_SOURCE_CONTEXT_WRITES";function z(e){let r=e[se],i=r===void 0||r.trim().toLowerCase()==="write"?"write":"read_only",t=i==="read_only"&&e[ce]?.trim()==="1";return{access:i,write_override_applied:t,source_writes_allowed:i==="write"||t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="b1828465-0619-514c-8956-2a81dea9efbc")}catch{}})();var k=de(me),T="# pm-cli:merge-drivers:start",pe="# pm-cli:merge-drivers:end",x="# pm-cli:merge-drivers:v2:start",Q="# pm-cli:merge-drivers:v2:end",fe="merge-fence",ge="merge-attributes";function R(e){return`'${e.replaceAll("'",`'"'"'`)}'`}async function he(e,r){let i=await _(e);if(/(?:^|[\\/])bun-node-[^\\/]+[\\/]bun(?:\.exe)?$/iu.test(i))return;let{stdout:t}=await k(e,["--version"],{encoding:"utf8",windowsHide:!0,timeout:1e4});return t.trim()===r?i:void 0}async function ye(){let e=G(import.meta.url,["../../.."]),r=process.execPath,i=!1,t=await _(process.execPath),o=process.versions.bun,n=(process.env.PATH??"").split(c.delimiter).filter(a=>c.isAbsolute(a)).map(a=>c.join(a,o===void 0?c.basename(process.execPath):process.platform==="win32"?"bun.exe":"bun")),s=o===void 0?n:[process.env.npm_execpath??"",...n,t].filter(a=>c.isAbsolute(a)&&/^(?:bun|bun\.exe)$/iu.test(c.basename(a)));for(let a of s)try{if(await le(a,ue.X_OK),o!==void 0){let d=await he(a,o);if(d!==void 0){r=d,i=!0;break}continue}if(a!==t&&await _(a)===t){r=a;break}}catch{}if(o!==void 0&&!i)throw new v("Cannot install Bun merge drivers without a durable executable matching the current Bun version.",w.DEPENDENCY_FAILED,{code:"merge_bun_launcher_unavailable",why:"The current Bun process may be a temporary bunx launcher that Git cannot reuse after this command exits.",nextSteps:["Run with a durable version-matched Bun executable, expose one on an absolute PATH entry, or invoke pm through a Bun runner that publishes an absolute npm_execpath.","Retry pm merge install, then check pm health --strict-exit before merging branches."]});return`${R(r)} ${R(c.join(e,"dist","cli.js"))}`}var Z=[{key:"pm-item-toon",name:"pm field-aware TOON item document merge",artifact:"item",itemPath:"%P"},{key:"pm-item-markdown",name:"pm field-aware JSON-markdown item document merge",artifact:"item",itemPath:"%P"},{key:"pm-history",name:"pm append-only history stream merge",artifact:"history",itemPath:void 0},{key:"pm-relationship",name:"pm append-only relationship event store merge",artifact:"relationship",itemPath:void 0},{key:"pm-json",name:"pm key-level JSON config merge",artifact:"json",itemPath:void 0}];function we(e){let r=e.explicitPath?.trim(),i=e.environment.PM_SOURCE_WORKSPACE_ROOT?.trim(),t=e.environment.PM_SOURCE_PM_PATH?.trim(),o=z(e.environment),n=!!(i&&t),s=r===void 0&&n&&(e.dryRun||o.source_writes_allowed);if(r!==void 0){let a=E(e.cwd,r);return{pm_root:a,workspace_start:a,source_coordinates_available:n,source_context_selected:!1,source_policy:o}}return s?{pm_root:c.resolve(t),workspace_start:c.resolve(i),source_coordinates_available:!0,source_context_selected:!0,source_policy:o}:{pm_root:n?E(e.cwd,".agents/pm"):E(e.cwd),workspace_start:e.cwd,source_coordinates_available:n,source_context_selected:!1,source_policy:o}}async function ee(e){try{let{stdout:r}=await k("git",["rev-parse","--show-toplevel"],{cwd:e,env:y(),encoding:"utf8",windowsHide:!0,timeout:1e4});return await _(r.trim())}catch{return null}}async function te(e){let r=await ee(e);if(r===null)throw new v("pm merge install requires a git repository (merge drivers are git configuration).",w.USAGE);return r}function I(e,r){return c.relative(e,r).split(c.sep).join("/")}function J(e){return e.replace(/[\\*?[\]!]/gu,"\\$&")}function h(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}function Y(e,r){if(e[r]!=="'")return null;let i="";for(let t=r+1;t<e.length;t+=1){if(e.startsWith(`'"'"'`,t)){i+="'",t+=4;continue}if(e[t]==="'")return{value:i,nextOffset:t+1};i+=e[t]}return null}async function ve(e,r,i){if(L(r).filter(o=>o.constraint==="exact").some(o=>o.version!==i))return!1;let t=await ee(e);if(t!==null&&t!==await _(r)){let o=await Promise.all([t,r].map(async n=>{let s=await k("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:n,env:y(),timeout:1e4});return _(s.stdout.trim())}));if(o[0]===o[1])return!1}return!0}async function _e(e,r,i){let t=Y(e,0);if(t===null||e[t.nextOffset]!==" ")return!1;let o=Y(e,t.nextOffset+1);if(o===null||e.slice(o.nextOffset)!==r||!/^(?:node|bun)(?:\.exe)?$/iu.test(c.basename(t.value))||c.basename(o.value)!=="cli.js"||c.basename(c.dirname(o.value))!=="dist"||!await S(t.value)||!await S(o.value))return!1;try{let n=c.dirname(c.dirname(o.value)),s=JSON.parse(await A(c.join(n,"package.json"),"utf8")),a=typeof s.bin=="string"?s.bin:s.bin?.pm;return await ve(n,i,s.version)?s.name==="@unbrained/pm-cli"&&a==="dist/cli.js":!1}catch{return!1}}function O(e,r){let i=e.length>0?`${J(e)}/`:"",t=[`${h(`${i}**/*.toon`)} merge=pm-item-toon`,`${h(`${i}**/*.md`)} merge=pm-item-markdown`];for(let o of r){let n=J(o);t.push(`${h(`${i}${n}/*.toon`)} merge=pm-item-toon`),t.push(`${h(`${i}${n}/*.md`)} merge=pm-item-markdown`)}return t.push(`${h(`${i}**/*.jsonl`)} merge=pm-relationship`),t.push(`${h(`${i}history/*.jsonl`)} merge=pm-history`),t.push(`${h(`${i}settings.json`)} merge=pm-json`),t.push(`${h(`${i}**/*.json`)} merge=pm-json`),t.push(`${h(`${i}extensions/**`)} merge=text`),t.push(`${h(`${i}extensions/.managed-extensions.json`)} merge=pm-json`),t}function re(e){let r=[],i=0;for(;i<e.length;){let t=e.indexOf(T,i),o=e.indexOf(x,i),n=t===-1?o:o===-1?t:Math.min(t,o);if(n===-1)break;let s=n===o,a=s?x:T,d=s?Q:pe,u=e.indexOf(d,n+a.length),m=u===-1?e.length:u+d.length;r.push({start:n,end:m,closed:u!==-1,lines:e.slice(n+a.length,u===-1?m:u).split(`
|
|
2
2
|
`).map(l=>l.trim()).filter(Boolean)}),i=m}return r}function ie(e,r,i){let t=new Set(r),o=h(i.length>0?`${i}/`:"").slice(0,-1);return e.some(n=>t.has(n)||n.startsWith(o)&&/^[^/]+\/\*\.(?:toon|md)" merge=pm-item-(?:toon|markdown)$/u.test(n.slice(o.length)))}async function ne(e,r,i,t){let o=c.join(e,".gitattributes"),n=t?null:(await k("git",["rev-parse","--absolute-git-dir"],{cwd:e,env:y(),encoding:"utf8",windowsHide:!0,timeout:1e4})).stdout.trim(),s=n===null?null:await $(n,ge,120,"merge-fence",!1,!0,5e3);try{let a=await F(o)??"",d=[x,...i,Q].join(`
|
|
3
3
|
`),u=re(a),m=u.filter(p=>ie(p.lines,i,r));m.length===0&&r===".agents/pm"&&u.length===1&&u[0].lines.every(p=>!p.includes("/"))&&m.push(u[0]);let l;if(m.length>0){let p=m[0];l=a;for(let b of m.slice(1).reverse())l=`${l.slice(0,b.start)}${l.slice(b.end)}`;l=`${l.slice(0,p.start)}${d}${l.slice(p.end)}`}else{let p=a.trimEnd();l=`${p.length>0?`${p}
|
|
4
4
|
|
|
5
5
|
`:""}${d}
|
|
6
6
|
`}return l===a?{path:o,changed:!1}:(t||await N(o,l),{path:o,changed:!0})}finally{await s?.()}}function oe(e){let r=B(e,null);return[...new Set(Object.values(r.type_to_folder))].sort((i,t)=>i.localeCompare(t))}async function qe(e,r){let i=c.resolve(e),t=null,o="",n=i;for(let g=0;g<8;g+=1){let ae=c.join(n,".gitattributes");try{let C=await A(ae,"utf8");if(C.includes(x)||C.includes(T)){t=n,o=C;break}}catch{}let D=c.dirname(n);if(D===n)break;n=D}if(t===null)return{status:"not_installed",missing_patterns:[],stale_patterns:[],schema_scope:"project"};let s=c.join(t,".gitattributes"),a=I(t,i),d=re(o),u=O(a,r),m=d.filter(g=>ie(g.lines,u,a)),l=m.flatMap(g=>g.closed?g.lines:[]),p=new Set(l),b=new Set(u),f=u.filter(g=>!p.has(g)),M=l.filter(g=>!b.has(g));return{status:m.length!==1||!m[0].closed||f.length>0||M.length>0?"drift":"ok",path:s,missing_patterns:f,stale_patterns:M,schema_scope:"project"}}async function ze(e){let r=[],i=[];for(let t of Z){let o=`merge.${t.key}.driver`,n=` merge driver ${t.artifact} "%O" "%A" "%B"${t.itemPath===void 0?"":` --item-path ${t.itemPath}`}`;try{let{stdout:s}=await k("git",["config","--get",o],{cwd:e,env:y(),encoding:"utf8",windowsHide:!0,timeout:1e4}),a=s.trim();await _e(a,n,e)||i.push(o)}catch{r.push(o)}}return{status:r.length>0?"missing":i.length>0?"drift":"ok",missing_keys:r,drifted_keys:i}}async function Je(e){let r;try{r=await te(c.resolve(e))}catch{return{status:"no_git"}}let i=I(r,c.resolve(e)),t=await P(e),o=U(void 0,t.author_default),n=await $(e,fe,t.locks.ttl_seconds,o,!1,H(t).force_required_for_stale_lock,t.locks.wait_ms);try{let s=c.join(r,".gitattributes"),a;try{a=await A(s,"utf8")}catch(l){if(l instanceof Error&&"code"in l&&j(l))return{status:"not_installed",path:s};throw l}if(!a.includes(x)&&!a.includes(T))return{status:"not_installed",path:s};let d=await P(e),u=oe(d),m=await ne(r,i,O(i,u),!1);return{status:m.changed?"refreshed":"unchanged",path:m.path}}finally{await n()}}async function Ye(e,r){let i=we({cwd:process.cwd(),explicitPath:r.path,dryRun:e.dryRun===!0,environment:process.env}),t=i.pm_root;await V(t);let o=await te(i.workspace_start);return ke({pmRoot:t,workspaceRoot:o,dryRun:e.dryRun===!0,preCommitHook:e.preCommitHook===!0})}async function be(e,r){let i=(await k("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:e,env:y(),timeout:1e4})).stdout.trim(),t=await $(i,"merge-driver-config",120,"merge-install",!1,!0,5e3);try{let o=await q(e),n;try{n=(await k("git",["config",o,"--null","--get-regexp","."],{cwd:e,env:y(),timeout:1e4})).stdout}catch(a){if(typeof a!="object"||a===null||!("code"in a)||a.code!==1)throw a;n=""}let s=new Map(n.split("\0").filter(Boolean).map(a=>{let d=a.indexOf(`
|
|
7
|
-
`);return[a.slice(0,d),a.slice(d+1)]}));for(let a of r)s.get(a.key)!==a.value&&await X(e,[o,a.key,a.value])}finally{await t()}}async function ke(e){let r=c.resolve(e.pmRoot),i=c.resolve(e.workspaceRoot),t=e.dryRun===!0,o,n;try{[o,n]=await Promise.all([_(r),_(i)])}catch(f){throw new v(`Cannot resolve tracker root ${r} or workspace root ${i}: ${String(f)}`,w.NOT_FOUND,{code:"merge_root_not_found",nextSteps:["Initialize the tracker and ensure both paths are accessible.",'Retry "pm merge install" from the repository workspace.']})}let s=I(n,o);if(K(s))throw new v(`Tracker root ${r} is outside the git repository ${i}; there is nothing to configure for this repository.`,w.USAGE);let a=await P(o),d=oe(a),u=O(s,d),m=[],l=await ye(),p=e.preCommitHook===!0?await import("./settlement-hook-
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
`);return[a.slice(0,d),a.slice(d+1)]}));for(let a of r)s.get(a.key)!==a.value&&await X(e,[o,a.key,a.value])}finally{await t()}}async function ke(e){let r=c.resolve(e.pmRoot),i=c.resolve(e.workspaceRoot),t=e.dryRun===!0,o,n;try{[o,n]=await Promise.all([_(r),_(i)])}catch(f){throw new v(`Cannot resolve tracker root ${r} or workspace root ${i}: ${String(f)}`,w.NOT_FOUND,{code:"merge_root_not_found",nextSteps:["Initialize the tracker and ensure both paths are accessible.",'Retry "pm merge install" from the repository workspace.']})}let s=I(n,o);if(K(s))throw new v(`Tracker root ${r} is outside the git repository ${i}; there is nothing to configure for this repository.`,w.USAGE);let a=await P(o),d=oe(a),u=O(s,d),m=[],l=await ye(),p=e.preCommitHook===!0?await import("./settlement-hook-UXN76GMA.js").then(async f=>({plan:await f.prepareMergeSettlementHook(n,`${l} --pm-path ${R(s||".")}`),write:f.writeMergeSettlementHook})):void 0;for(let f of Z)m.push({key:`merge.${f.key}.name`,value:f.name}),m.push({key:`merge.${f.key}.driver`,value:`${l} merge driver ${f.artifact} "%O" "%A" "%B"${f.itemPath===void 0?"":` --item-path ${f.itemPath}`}`});if(!t)try{await be(n,m)}catch{throw new v(`Cannot install repository-local merge drivers in ${n}. Ensure the repository Git config is writable and no other Git process holds its lock, then retry.`,w.DEPENDENCY_FAILED,{code:"merge_git_config_unwritable",why:"pm merge install must persist clone-local driver commands before publishing their shared .gitattributes mappings.",nextSteps:["Make the repository Git config writable or wait for the process holding its lock to finish.",'Retry "pm merge install"; the operation is idempotent.','Use "pm merge install --dry-run --json" when the workspace is intentionally read-only.']})}let b=await ne(n,s,u,t);return p!==void 0&&!t&&await p.write(p.plan),{ok:!0,dry_run:t,workspace_root:n,pm_root:o,gitattributes:{path:b.path,changed:b.changed,patterns:u,schema_scope:"project"},git_config:m,...p===void 0?{}:{settlement_hook:{path:p.plan.path,changed:p.plan.changed}},guidance:["Commit .gitattributes so every branch and collaborator shares the merge mapping.",'git config is per-clone: each collaborator (and each fresh worktree/clone) runs "pm merge install" once.','After merging branches, run "pm merge reconcile --dry-run" to inspect the complete receipt and history repair, then apply "pm merge reconcile"; use --force only after explicitly accepting any discarded values.',"Custom item types registered later refresh this fence automatically (pm schema add-type/remove-type); rerun pm merge install only after out-of-band type-folder edits."],generated_at:W()}}import{execFile as xe}from"node:child_process";import{promisify as Ee}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="e57ef62f-fd40-5a33-9816-e24d8dba4d1d")}catch{}})();var $e=Ee(xe);async function nt(e,r){if(r.length===0)return[];let i;try{let n=$e("git",["check-ignore","--verbose","-z","--stdin"],{cwd:e,env:y(),timeout:1e4}),s=n.child.stdin;s!==null&&(s.on("error",()=>{n.child.kill()}),s.end(`${r.join("\0")}\0`)),{stdout:i}=await n}catch(n){if(typeof n=="object"&&n!==null&&"code"in n&&n.code===1)return[];throw new v("Git could not verify ignore rules for merge artifacts; no automatic settlement is safe until that check succeeds.",w.CONFLICT,{code:"merge_settlement_review_required",reason:"ignore_check_unavailable",nextSteps:["Check Git configuration and ignore-file readability, then retry pm merge reconcile --stage --dry-run."]})}let t=i.split("\0"),o=[];for(let n=0;n+3<t.length;n+=4){let[s,a,d,u]=t.slice(n,n+4);d.startsWith("!")||o.push({path:u,source:s,line:Number(a),pattern:d})}return o}export{se as a,ce as b,ee as c,oe as d,qe as e,ze as f,Je as g,Ye as h,ke as i,nt as j};
|
|
8
|
+
//# sourceMappingURL=chunk-W2KIQ7RF.js.map
|