@unbrained/pm-cli 2026.8.4 → 2026.8.6
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 +2 -2
- package/CHANGELOG.md +53 -13
- package/dist/cli/error-guidance.js +4 -4
- package/dist/cli/main.js +12 -37
- package/dist/cli/register-setup.d.ts +1 -1
- package/dist/cli/register-setup.js +46 -20
- package/dist/cli/register-structured-mutation.d.ts +2 -0
- package/dist/cli/register-structured-mutation.js +124 -12
- package/dist/cli-bundle/bundle-manifest.json +397 -397
- package/dist/cli-bundle/chunks/append-XAJ5Z4XS.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-QVO3VTA4.js → chunk-343QETLI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q5F6OI7C.js → chunk-3KFVGGRE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6S7I3UKV.js → chunk-3ZJRFYY2.js} +19 -19
- package/dist/cli-bundle/chunks/{chunk-NFF3JAQR.js → chunk-4AVFKHHC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5H47J5FG.js → chunk-4OVGQW22.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-D2MBVMVE.js → chunk-5PBP2ZP3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-5ZKQPA44.js +2 -0
- package/dist/cli-bundle/chunks/chunk-A3XQ7VPU.js +2 -0
- package/dist/cli-bundle/chunks/chunk-AJE3AHPD.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-2POYGY53.js → chunk-AOBDLU4T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PYYPQLHC.js → chunk-AYRUGRNS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QMWUL66F.js → chunk-BP6EMEDP.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-UVZREFZU.js → chunk-C3YABSJK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RB65T4RX.js → chunk-CA3BURYF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KIKLF2W4.js → chunk-D7I3TUGV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PQXEB7W4.js → chunk-DQGJ2RWT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OB7TRZ2G.js → chunk-DWOAOZHZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SVDH5CHC.js → chunk-E7BFPLUZ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-CGY5I2GO.js → chunk-F4NREH3G.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DCJ6CM6F.js → chunk-FDBRXV25.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NM5G7RLU.js → chunk-GU3TSEHD.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HS7OVAUN.js +164 -0
- package/dist/cli-bundle/chunks/{chunk-CU5ENFNP.js → chunk-JFZIS6JF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GOICHIX4.js → chunk-JQ4NZ5EB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HE3DZFN4.js → chunk-L6LGKJX3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BLINBTMX.js → chunk-M357ZCOR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NRDKVOUE.js → chunk-M4VEE3FK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HTYC76A4.js → chunk-MCS73BKB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BKMZTZYL.js → chunk-MDTH7SAE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-H6FITE7D.js → chunk-NE5VRDAI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NPUJ7OLK.js → chunk-OXY3SJ3N.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-PECV7L5T.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-KH4GVBMC.js → chunk-Q3VOP62W.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FQ4EFFDU.js → chunk-QJ7C3JIW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VH2EAGUG.js → chunk-R6LSRGPS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HQ2WU7OY.js → chunk-R6RKEYYW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PA5XRN2A.js → chunk-RAFUN7IX.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-RUAU5OSH.js +2 -0
- package/dist/cli-bundle/chunks/chunk-SD3YXU2U.js +56 -0
- package/dist/cli-bundle/chunks/{chunk-JMKVCQSE.js → chunk-SV3YQ4RY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-B5ZLCD5Z.js → chunk-SVV3DQES.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-J4EPW4GT.js → chunk-SXECIECW.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-T45OHXDW.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-NH35JNK5.js → chunk-TPKDJ5WL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZSH4GNBH.js → chunk-UVVXHGYS.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-V663653R.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-5PZGZMPG.js → chunk-WSI5KZQJ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3XZYTRPC.js → chunk-XPOQQJTX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UJHUR3LZ.js → chunk-YCCDXBNU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ZFBWCKYF.js +2 -0
- package/dist/cli-bundle/chunks/close-DI66JMSB.js +2 -0
- package/dist/cli-bundle/chunks/close-many-VFKT6U3O.js +2 -0
- package/dist/cli-bundle/chunks/comments-E73HIEZJ.js +2 -0
- package/dist/cli-bundle/chunks/copy-WBYVLCPC.js +2 -0
- package/dist/cli-bundle/chunks/{create-RLLCBCXM.js → create-TG67IVFI.js} +2 -2
- package/dist/cli-bundle/chunks/delete-6XKUVVQN.js +2 -0
- package/dist/cli-bundle/chunks/{deps-J4ONTF4X.js → deps-AJUGP2OH.js} +2 -2
- package/dist/cli-bundle/chunks/{docs-YL2DJ4WD.js → docs-QOCLDRKJ.js} +2 -2
- package/dist/cli-bundle/chunks/{files-NGNAIYKK.js → files-3ST5TY64.js} +2 -2
- package/dist/cli-bundle/chunks/focus-R2AWS63Y.js +2 -0
- package/dist/cli-bundle/chunks/{history-compact-HW62K5XP.js → history-compact-7BJFML4S.js} +2 -2
- package/dist/cli-bundle/chunks/{history-redact-HVBKUJOW.js → history-redact-WJN3HYXR.js} +2 -2
- package/dist/cli-bundle/chunks/{history-repair-OPNBH5JJ.js → history-repair-XDNZUB7F.js} +2 -2
- package/dist/cli-bundle/chunks/{learnings-F36PZXT6.js → learnings-SZMUPVNA.js} +2 -2
- package/dist/cli-bundle/chunks/{profile-N3XMWBM7.js → profile-KL53JIAC.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-BKGHBI7Y.js → register-list-query-QH7ONPKU.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-OCRQNZK4.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-HIBJXRGB.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-QWBQ6HBS.js +2 -0
- package/dist/cli-bundle/chunks/restore-FXA5QPM7.js +2 -0
- package/dist/cli-bundle/chunks/{schema-4PJQMGUY.js → schema-QJ27OTRV.js} +2 -2
- package/dist/cli-bundle/chunks/update-7GBO4SXG.js +2 -0
- package/dist/cli-bundle/chunks/update-many-VF6ZKQUO.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-27DK4A5O.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-4JC3AOGS.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-6KDHXURF.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-74CWP3A4.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-7AZDTGPA.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-7YTZ7A4E.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ONIX2KKW.js → chunk-CL3NB7VW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EAXXF2HW.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-L6A4NVQC.js → chunk-EYO4F74Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-GEYU23YS.js +153 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DQ4PLKEE.js → chunk-GIERI4YU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-GSW2Y7VZ.js +5 -0
- package/dist/cli-bundle/focused-chunks/{chunk-WVGJAD7L.js → chunk-LKQXXO62.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UFCPSWIL.js → chunk-MBBMTDD3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OYTK4VNH.js → chunk-ME4XVOBJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RO5BQFG3.js → chunk-N7QN3NE6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QL5H3AQH.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-TQMFQYXR.js +29 -0
- package/dist/cli-bundle/focused-chunks/{chunk-SQXVGHMH.js → chunk-XNVXIQ4B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BOGRY7M6.js → chunk-YHDCGUIW.js} +10 -10
- package/dist/cli-bundle/focused-chunks/{chunk-K37BB4JL.js → chunk-YLPZHWX7.js} +2 -2
- package/dist/cli-bundle/main.js +13 -13
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +28 -28
- 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 +1 -1
- 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 +1 -1
- package/dist/core/extensions/activation-summary.d.ts +4 -0
- package/dist/core/extensions/activation-summary.js +5 -2
- package/dist/core/extensions/contribution-inventory.d.ts +1 -0
- package/dist/core/extensions/contribution-inventory.js +35 -2
- package/dist/core/extensions/extension-hook-runtime.js +5 -3
- package/dist/core/extensions/extension-types.d.ts +18 -1
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/loader.js +8 -13
- package/dist/core/extensions/preflight-ownership.d.ts +5 -0
- package/dist/core/extensions/preflight-ownership.js +42 -0
- package/dist/core/item/item-format.js +14 -20
- package/dist/core/shared/constants.js +3 -2
- package/dist/core/store/item-store.js +2 -2
- package/dist/core/store/settings.js +2 -2
- package/dist/mcp/server.js +12 -6
- package/dist/mcp/tool-definitions.js +14 -7
- package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +18 -18
- package/dist/sdk/cli-contracts/agent-output-contracts.js +51 -23
- package/dist/sdk/cli-contracts/commander-mutation-options.js +26 -2
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +4 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +34 -2
- package/dist/sdk/cli-contracts/registration-helpers.js +4 -2
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +10 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +21 -5
- package/dist/sdk/cli-contracts/tool-schema.js +4 -2
- package/dist/sdk/cli-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts.js +4 -4
- package/dist/sdk/cli-program.js +3 -3
- package/dist/sdk/compose.d.ts +2 -2
- package/dist/sdk/compose.js +7 -2
- package/dist/sdk/contracts.d.ts +1 -0
- package/dist/sdk/contracts.js +3 -2
- package/dist/sdk/define.d.ts +3 -1
- package/dist/sdk/define.js +3 -8
- package/dist/sdk/dependency-provenance.d.ts +2 -0
- package/dist/sdk/dependency-provenance.js +7 -3
- package/dist/sdk/error-code-catalog.d.ts +23 -0
- package/dist/sdk/error-code-catalog.js +25 -5
- package/dist/sdk/extension/install-sources.d.ts +43 -5
- package/dist/sdk/extension/install-sources.js +36 -2
- package/dist/sdk/extension/migrations.d.ts +114 -0
- package/dist/sdk/extension/migrations.js +175 -0
- package/dist/sdk/extension/scaffold.js +14 -9
- package/dist/sdk/extension/source-resolution.d.ts +50 -0
- package/dist/sdk/extension/source-resolution.js +66 -0
- package/dist/sdk/extension.d.ts +5 -1
- package/dist/sdk/extension.js +24 -26
- package/dist/sdk/generated-error-code-catalog.js +499 -3
- package/dist/sdk/governance/health.js +11 -2
- package/dist/sdk/graph/governance.js +3 -3
- package/dist/sdk/graph/remediation.js +3 -3
- package/dist/sdk/graph/run.js +4 -8
- package/dist/sdk/index.d.ts +7 -2
- package/dist/sdk/index.js +9 -4
- package/dist/sdk/item-transaction.d.ts +51 -6
- package/dist/sdk/item-transaction.js +132 -22
- package/dist/sdk/lifecycle/create.d.ts +4 -0
- package/dist/sdk/lifecycle/create.js +26 -10
- package/dist/sdk/lifecycle-policy.d.ts +9 -0
- package/dist/sdk/lifecycle-policy.js +22 -9
- package/dist/sdk/merge/driver.js +6 -3
- package/dist/sdk/output-contracts.d.ts +67 -0
- package/dist/sdk/output-contracts.js +173 -0
- package/dist/sdk/package-import-adapters.js +2 -2
- package/dist/sdk/package-migrations.d.ts +10 -0
- package/dist/sdk/package-migrations.js +21 -0
- package/dist/sdk/runtime.d.ts +2 -0
- package/dist/sdk/runtime.js +6 -2
- package/dist/sdk/structured-mutations.d.ts +23 -0
- package/dist/sdk/structured-mutations.js +219 -10
- package/dist/sdk/workspace-snapshot.js +58 -12
- package/dist/sdk/workspace.js +30 -4
- package/docs/COMMANDS.md +49 -10
- package/docs/EXTENSIONS.md +3 -3
- package/docs/EXTENSION_LIFECYCLE.md +46 -0
- package/docs/MERGE_SAFETY.md +2 -0
- package/docs/PR_REVIEW_LOOP.md +10 -4
- package/docs/README.md +23 -22
- package/docs/RELEASING.md +36 -23
- package/docs/SCRIPTING.md +32 -9
- package/docs/SDK.md +122 -14
- package/docs/SELF_DESCRIBING_CONTEXT_CONTRACTS.md +13 -0
- package/docs/TESTING.md +25 -0
- package/docs/examples/sdk-contract-consumer/README.md +11 -1
- package/docs/examples/sdk-contract-consumer/package.json +2 -1
- package/docs/examples/sdk-contract-consumer/parse-receipt.mjs +22 -0
- package/marketplace.json +2 -2
- package/package.json +5 -4
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +508 -32
- package/dist/cli-bundle/chunks/append-DHBRLHHS.js +0 -2
- package/dist/cli-bundle/chunks/chunk-2INN52SU.js +0 -8
- package/dist/cli-bundle/chunks/chunk-377OOXUF.js +0 -55
- package/dist/cli-bundle/chunks/chunk-6RSK4IFN.js +0 -20
- package/dist/cli-bundle/chunks/chunk-ASJJKA57.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IYAVULRN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-JDPKBV5P.js +0 -2
- package/dist/cli-bundle/chunks/chunk-RRQBHQOV.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SULWTPQO.js +0 -8
- package/dist/cli-bundle/chunks/chunk-V5K52PYW.js +0 -164
- package/dist/cli-bundle/chunks/chunk-XBLOD5TZ.js +0 -2
- package/dist/cli-bundle/chunks/close-VLHNN6YB.js +0 -2
- package/dist/cli-bundle/chunks/close-many-LSJNZKU6.js +0 -2
- package/dist/cli-bundle/chunks/comments-AAIA6A6X.js +0 -2
- package/dist/cli-bundle/chunks/copy-Z7YMLEHN.js +0 -2
- package/dist/cli-bundle/chunks/delete-KNOHHQJM.js +0 -2
- package/dist/cli-bundle/chunks/focus-LFRCGALV.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-GU3DCECN.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-PTWH727R.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-KWV6UD77.js +0 -2
- package/dist/cli-bundle/chunks/restore-4HZSLILR.js +0 -2
- package/dist/cli-bundle/chunks/update-E6LPS5IV.js +0 -2
- package/dist/cli-bundle/chunks/update-many-OSIC6KRO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2VIIXOAD.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-5MTKO7TV.js +0 -153
- package/dist/cli-bundle/focused-chunks/chunk-6GIZK7VQ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-AOP2WIZZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-C2QSL62X.js +0 -28
- package/dist/cli-bundle/focused-chunks/chunk-CL75YW32.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-E7OFMWGT.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-I5F5UK3Q.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QM2BIVK7.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-T5TSY36R.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-VT6BF2IX.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as re,h as de,j as A}from"./chunk-XBLOD5TZ.js";import{A as y,Bb as J,C as _,Da as X,Jf as se,Kd as Y,Kf as oe,La as q,Mf as ie,Nc as V,Ne as C,Oa as H,Qd as $,Qe as N,Sd as Z,Td as ee,Wd as te,b as z,cd as O,ib as v,lc as Q,yf as ne}from"./chunk-V5K52PYW.js";import{createHash as Te}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]="dea35fb9-9f9f-56ce-afc0-f4dc993012c3")}catch{}})();var be=64,xe=8;function Re(e,t){let s=(e.dependencies??[]).map(n=>{if(typeof n!="object"||n===null)return"";let o=n;return`${typeof o.kind=="string"?o.kind:"related"}:${typeof o.id=="string"?o.id:""}`}).sort().join(",");return[e.id,e.title,e.status,t(e.status)?"1":"0",typeof e.type=="string"?e.type.trim():"",e.parent??"",e.blocked_by??"",s].join("\0")}function ae(e,t=n=>n==="closed"||n==="canceled",s=v()){let n=e.filter(i=>typeof i?.id=="string"&&i.id.trim().length>0).map(i=>Re(i,t)).sort(),o=s.list().map(i=>J(i)).sort();return Te("sha256").update(n.join("")).update("").update(o.join("")).digest("hex")}function ce(e,t,s){let n=t??s;if(!Number.isInteger(n)||n<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`);return n}var M=class{#e=new Map;#t;#n;constructor(t={}){this.#t=ce("maxResultsPerWorkspace",t.maxResultsPerWorkspace,be),this.#n=ce("maxWorkspaces",t.maxWorkspaces,xe)}lookup(t,s,n){let o=this.#e.get(t),i=!0;(o===void 0||o.fingerprint!==s)&&(o={fingerprint:s,assembly:n(),results:new Map},i=!1,!this.#e.has(t)&&this.#e.size>=this.#n&&this.#e.delete(this.#e.keys().next().value)),this.#e.delete(t),this.#e.set(t,o);let d=o,r=this.#t;return{assembly:d.assembly,assemblyReused:i,fingerprint:s,memoize(c,f){let a=d.results.get(c);if(a!==void 0||d.results.has(c))return d.results.delete(c),d.results.set(c,a),{value:structuredClone(a),reused:!0};let l=f();return d.results.size>=r&&d.results.delete(d.results.keys().next().value),d.results.set(c,structuredClone(l)),{value:l,reused:!1}}}}clear(){this.#e.clear()}},ue=new M;function le(){return ue}function ut(){ue.clear()}(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]="31a800f7-1374-5e7c-ad23-ae3d8ebcebe0")}catch{}})();var Le=["prerequisite","dependent","ancestor","descendant","provenance","related"],Ce=new TextEncoder;function P(e,t,s){let n=e??t;if(!Number.isInteger(n)||n<1)throw new TypeError(`Relationship context ${s} must be positive`);return n}function S(e){return Math.max(1,Math.ceil(Ce.encode(JSON.stringify(e)).byteLength/4))}function U(e,t,s){let n=s.resolve(e.kind);if(n?.ordering){let i=(n.precedence??"source_before_target")==="source_before_target"?e.source:e.target;return t===i?"prerequisite":"dependent"}if(n?.hierarchy){let i=(n.hierarchyDirection??"source_parent")==="source_parent"?e.source:e.target;return t===i?"ancestor":"descendant"}return e.kind==="discovered_from"||e.kind==="incident_from"?"provenance":"related"}function Se(e,t,s,n){let o=e.filter(i=>i.source===t&&i.target===s||i.target===t&&i.source===s).map(i=>U(i,s,n));return[...new Set(o)].sort()}function De(e){return Le.find(t=>e.includes(t))}function Ie(e,t,s,n){let o=n.direction??"both",i=n.maxDepth??3;if(!Number.isInteger(i)||i<0)throw new TypeError("Relationship context maxDepth must be non-negative");let d=new Set([t]),r=[{id:t,distance:0}],c=[],f=0,a=!1;for(let l=0;l<r.length;l+=1){n.signal?.throwIfAborted();let u=r[l];if(u.distance>=i&&a)continue;let g=e.neighborEdges(u.id,{direction:o,kinds:n.kinds,signal:n.signal});if(f+=g.meta.inspectedEdges,u.distance>=i){g.value.some(m=>!d.has(m.id))&&(a=!0);continue}for(let{id:m,edge:p}of g.value){if(d.has(m))continue;d.add(m);let h={id:m,distance:u.distance+1,via:u.id,role:U(p,m,s)};c.push(h),r.push(h)}}return c.sort((l,u)=>l.distance-u.distance||l.id.localeCompare(u.id)),{rows:c,visitedNodes:r.length,inspectedEdges:f,depthTruncated:a}}function Be(e,t,s,n){let o={prerequisite:0,dependent:0,ancestor:0,descendant:0,provenance:0,related:0},i=e.neighborEdges(t,{direction:n.direction??"both",kinds:n.kinds,signal:n.signal}).value;for(let{id:d,edge:r}of i)o[U(r,d,s)]+=1;return{directEdges:o,directTotal:i.length,rootEdges:i.map(({edge:d})=>d)}}function Oe(e){let t=[],s=e.initialTokens;for(let n of e.candidates){if(t.length>=e.nodeLimit)break;let o=n.distance===1?Se(e.rootEdges,e.rootId,n.id,e.registry):[],i={...e.details.get(n.id)??{id:n.id},distance:n.distance,role:o.length>0?De(o):n.role,via:n.via,reasons:o.length>0?o:[`${n.role} via ${n.via} (depth ${n.distance})`]},d=S(i);if(s+d>e.tokenBudget)break;t.push(i),s+=d}if(e.candidates.length>0&&t.length===0)throw new TypeError("Relationship context tokenBudget cannot fit one node");return{nodes:t,usedTokens:s}}function $e(e){let t=e.options.kinds?new Set(e.options.kinds.map(i=>e.registry.require(i).kind)):void 0,s=e.graph.edges().filter(i=>{if(!e.included.has(i.source)||!e.included.has(i.target))return!1;if(t===void 0||t.has(i.kind))return!0;let d=e.registry.resolve(i.kind)?.inverse;return d!==void 0&&t.has(d)}),n=[],o=e.initialTokens;for(let i of s){if(n.length>=e.edgeLimit)break;let d=S(i);if(o+d>e.tokenBudget)break;n.push(i),o+=d}return{edges:n,usedTokens:o,candidateCount:s.length}}function fe(e,t,s,n={}){if(!e.nodes().includes(t))throw new TypeError(`Relationship node not found: ${t}`);let o=P(n.nodeLimit,20,"nodeLimit"),i=P(n.edgeLimit,40,"edgeLimit"),d=P(n.tokenBudget,1200,"tokenBudget"),r=n.registry??v(),c=new Map(s.map(T=>[T.id,T])),f=c.get(t)??{id:t},{evidence:a=[],...l}=f,u=[...a],g=Ie(e,t,r,n),{rootEdges:m,...p}=Be(e,t,r,n),h=Z("relationship-context",{rootId:t,direction:n.direction??"both",kinds:[...n.kinds??[]].sort(),maxDepth:n.maxDepth??3}),k=te(g.rows,n.cursor,h,({id:T})=>T),E=g.rows.slice(k),w=S(l)+S(u);if(w>d)throw new TypeError("Relationship context tokenBudget cannot fit root and evidence");let G=Oe({candidates:E,details:c,rootEdges:m,rootId:t,registry:r,nodeLimit:o,tokenBudget:d,initialTokens:w}),{nodes:R}=G,we=new Set([t,...R.map(({id:T})=>T)]),j=$e({graph:e,included:we,options:n,registry:r,edgeLimit:i,tokenBudget:d,initialTokens:G.usedTokens}),{edges:D,usedTokens:ve}=j,L=k+R.length,I=L<g.rows.length,W=R.at(-1),B=j.candidateCount-D.length,K=g.depthTruncated||I||B>0,Ee={rootId:t,...l.status===void 0?{}:{rootStatus:l.status},...p,discoveredNodes:g.rows.length,returnedNodes:R.length,returnedEdges:D.length,omittedNodes:g.rows.length-L,omittedEdges:B,evidenceCount:u.length,hasMore:I};return{root:l,summary:Ee,nodes:R,edges:D,evidence:u,meta:{exact:!0,truncated:K,completeness:K?"truncated":"complete",nodeLimit:o,edgeLimit:i,tokenBudget:d,usedTokens:ve,visitedNodes:g.visitedNodes,inspectedEdges:g.inspectedEdges,omittedNodes:g.rows.length-L,omittedEdges:B,...I&&W?{nextCursor:ee(h,W.id,L-1)}:{}}}}(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]="a3535267-c69a-5a44-bdf9-02925e02aaeb")}catch{}})();var Ne=["tree","graph","context"],Ae=["none","repeated"],Me=["outgoing","incoming","both"],Pe=32,Ue=200,Fe=400,Ge=16e3;function je(e){let t=e?.trim().toLowerCase()??"tree";if(Ne.includes(t))return t;throw new _(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,y.USAGE)}function b(e,t){if(e===void 0)return;let s=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(s)||s<1)throw new _(`Invalid --${t} value "${e}". Use a positive integer.`,y.USAGE);return s}function pe(e){if(e===void 0)return;let t=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(t)||t<0)throw new _(`Invalid --max-depth value "${e}". Use a non-negative integer.`,y.USAGE);return t}function We(e){let t=e?.trim().toLowerCase()??"none";if(Ae.includes(t))return t;throw new _(`Invalid --collapse value "${e}". Use "none" or "repeated".`,y.USAGE)}function Ke(e){let t=e?.trim().toLowerCase()??"both";if(Me.includes(t))return t;throw new _(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,y.USAGE)}function ze(e,t=v()){if(e===void 0)return;let s=(Array.isArray(e)?e:[e]).flatMap(o=>o.split(",")).map(o=>o.trim()).filter(o=>o.length>0);if(s.length===0)return;let n=new Set;for(let o of s){let i=t.resolve(o);if(!i){let d=t.list().map(r=>r.kind).join(", ");throw new _(`Invalid --kind value "${o}". Registered kinds: ${d}.`,y.USAGE)}n.add(i.kind)}return[...n].sort()}function Xe(e){if(!e||e.length===0)return[];let t=e.map(({id:n,kind:o})=>({id:n.trim(),kind:o.trim().toLowerCase()})).sort((n,o)=>{let i=n.kind.localeCompare(o.kind);return i!==0?i:n.id.localeCompare(o.id)}),s=new Map;for(let n of t){let o=`${n.kind.toLowerCase()}::${n.id.toLowerCase()}`;s.has(o)||s.set(o,{id:n.id,kind:n.kind})}return[...s.values()]}function qe(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:Xe(e.dependencies)}}function He(e){return C(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function Je(e,t,s,n,o,i,d,r,c){for(let f of t.dependencies){let a=Math.max(1,Math.ceil(JSON.stringify({from:e.id,to:f.id,kind:f.kind}).length/3));if(r.nodes>=r.nodeLimit){e.truncated=!0,r.reasons.add("node_limit");break}if(r.edges>=r.edgeLimit){e.truncated=!0,r.reasons.add("edge_limit");break}if(r.estimatedTokens+a>=r.tokenBudget){e.truncated=!0,r.reasons.add("token_budget");break}r.edges+=1,r.estimatedTokens+=a,e.dependencies.push(ge(f.id,s,n,o,i,d,r,c+1,f.kind))}}function Qe(e,t,s,n,o,i,d,r){return d.estimatedTokens>=d.tokenBudget&&t?.dependencies.length?(e.truncated=!0,d.reasons.add("token_budget"),!0):!t||e.cycle?!0:n!==void 0&&r>=n?(t.dependencies.length>0&&(e.truncated=!0,d.reasons.add("max_depth")),!0):o==="repeated"&&i.has(s)?(e.collapsed=!0,!0):!1}function ge(e,t,s,n,o,i,d,r=0,c){let f=e.trim().toLowerCase(),a=t.get(f),l={id:a?.id??e,title:a?.title,type:a?.type,status:a?.status,via:c,missing:!a,cycle:s.has(f),dependencies:[]};if(d.nodes+=1,d.estimatedTokens+=He(l),Qe(l,a,f,n,o,i,d,r))return l;o==="repeated"&&i.add(f);let u=new Set(s);return u.add(f),Je(l,a,t,u,n,o,i,d,r),l}function me(e,t){return!e||e.missing&&!t.missing?t:{...e,title:e.title??t.title,type:e.type??t.type,status:e.status??t.status}}function Ve(e){let t=new Map,s=new Map,n=[e];for(;n.length>0;){let r=n.pop();t.set(r.id,me(t.get(r.id),{id:r.id,title:r.title,type:r.type,status:r.status,missing:r.missing}));for(let c of r.dependencies){t.set(c.id,me(t.get(c.id),{id:c.id,title:c.title,type:c.type,status:c.status,missing:c.missing}));let f=c.via??"related",a=`${r.id}::${c.id}::${f}`;s.has(a)||s.set(a,{from:r.id,to:c.id,kind:f}),c.cycle||n.push(c)}}let o=[...t.values()].sort((r,c)=>r.id.localeCompare(c.id)),i=[...s.values()].sort((r,c)=>{let f=r.from.localeCompare(c.from);if(f!==0)return f;let a=r.to.localeCompare(c.to);return a!==0?a:r.kind.localeCompare(c.kind)}),d=o.filter(r=>r.missing).map(r=>r.id);return{root_id:e.id,nodes:o,edges:i,missing_ids:d}}function he(e,t,s){let n=new Set,o=new Set,i=new Set,d=new Set,r=[{id:e,depth:0}],c=0;for(;c<r.length;){let f=r[c++],a=f.id.trim().toLowerCase();n.add(a);let l=t.get(a);if(!l){i.add(a);continue}if(!(s!==void 0&&f.depth>=s)&&!d.has(a)){d.add(a);for(let u of l.dependencies)o.add(`${a}::${u.id.trim().toLowerCase()}::${u.kind}`),r.push({id:u.id,depth:f.depth+1})}}return{node_count:n.size,edge_count:o.size,edge_basis:"deduplicated_directed",missing_count:i.size}}function ke(e,t=v()){let s=pe(e.maxDepth),n=b(e.nodeLimit,"node-limit"),o=b(e.edgeLimit,"edge-limit"),i=b(e.tokenBudget,"token-budget"),d=ze(e.kind,t);return{direction:Ke(e.direction),...d===void 0?{}:{kinds:d},...s===void 0?{}:{maxDepth:s},...n===void 0?{}:{nodeLimit:n},...o===void 0?{}:{edgeLimit:o},...i===void 0?{}:{tokenBudget:i},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function ye(e,t,s,n){return fe(e.graph,t,e.details.map(o=>o.id===t&&n.length>0?{...o,evidence:n}:o),s)}function Bt(e,t,s,n=[]){let o=A(t);return ye(o,e,ke(s,o.graph.registry()),n)}function F(e,t,s,n){for(let o of s.slice(0,n)){let i=o?.trim();i&&e.push(`${t}:${i}`)}}async function Ye(e,t,s,n){let o=await se(e,t,s.id_prefix,s.item_format,n);if(!o)return[];let{document:i}=await oe(o,{schema:s.schema}),d=i.metadata,r=d.files??[],c=d.tests??[],f=d.docs??[],a=[["files",r.length],["tests",c.length],["docs",f.length],["comments",(d.comments??[]).length],["notes",(d.notes??[]).length],["learnings",(d.learnings??[]).length]];if(a.every(([,u])=>u===0))return[];let l=[`linked:${a.map(([u,g])=>`${u}=${g}`).join(",")}`];return F(l,"file",r.map(u=>u.path),3),F(l,"test",c.map(u=>u.command??u.path),2),F(l,"doc",f.map(u=>u.path),2),l}function Ze(e){let{canonicalId:t,context:s,missingCount:n,missingReferences:o,referenceLimit:i,summaryOnly:d}=e;return{id:t,format:"context",node_count:s.nodes.length+1,edge_count:s.edges.length,edge_basis:"deduplicated_directed",missing_count:n,missing_scope:"traversal",missing_reference_count:o.length,...d?{}:{missing_references:o.slice(0,i),context:s}}}function et(e){let{row:t,missingReachableSet:s,packetIds:n,filteredKinds:o,registry:i}=e;if(t.no_active_blocker_sentinel||!s.has(t.target_id.trim().toLowerCase())||!n.has(t.holder_id))return!1;if(o===void 0)return!0;let d=i.resolve(t.kind);return d!==void 0&&(o.has(d.kind)||d.inverse!==void 0&&o.has(d.inverse))}function _e(e,t,s){let n;for(;;){let o=C(new TextEncoder().encode(N($("deps",e),t)).byteLength);if(o===n)return o;s(o),n=o}}function tt(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function nt(e){try{return ye(e.assembly,e.canonicalId,{...e.contextOptions,...e.internalTokenBudget===void 0?{}:{tokenBudget:e.internalTokenBudget}},e.rootEvidence)}catch(t){if(e.smallestResult!==void 0&&tt(t))return e.smallestResult;throw t}}function st(e){let{assembly:t,canonicalId:s,contextOptions:n,rootEvidence:o,summaryOnly:i,outputFormat:d,missingCount:r,missingReferences:c}=e,a=n.edgeLimit??40,l=n.tokenBudget,u,g;for(;;){let m=nt({assembly:t,canonicalId:s,contextOptions:n,internalTokenBudget:l,rootEvidence:o,smallestResult:g});if("format"in m)return m;let p=m;u??=p.meta.tokenBudget,l??=u;let h=Ze({canonicalId:s,context:p,missingCount:r,missingReferences:c,referenceLimit:a,summaryOnly:i});if(g=h,i||(p.meta.tokenBudget=u,p.meta.usedTokens=_e(x(h,!1),d,w=>{p.meta.usedTokens=w}),p.meta.usedTokens<=u))return h;if(a>0){a-=1;continue}let k=l,E=k*u/p.meta.usedTokens;l=Math.min(k-1,Math.max(1,Math.floor(E*.9)))}}function ot(e){let{assembly:t,canonicalId:s,options:n,rootEvidence:o,summaryOnly:i,outputFormat:d}=e,r=ke(n,t.graph.registry()),c=t.graph.closure(s,{direction:r.direction,...r.kinds===void 0?{}:{kinds:r.kinds},maxDepth:r.maxDepth??3}),f=c.value.filter(p=>t.missingIdSet.has(p.toLowerCase())),a=new Set(f.map(p=>p.toLowerCase())),l=t.graph.registry(),u=r.kinds?new Set(r.kinds.map(p=>l.require(p).kind)):void 0,g=new Set([s,...c.value]),m=[...t.dangling.active,...t.dangling.legacy_terminal].filter(p=>et({row:p,missingReachableSet:a,packetIds:g,filteredKinds:u,registry:l}));return st({assembly:t,canonicalId:s,contextOptions:r,rootEvidence:o,summaryOnly:i,outputFormat:d,missingCount:f.length,missingReferences:m})}function it(e){let t=[e],s;for(;t.length>0;){let n=t.pop();n.dependencies.length>0&&(s=n,t.push(...n.dependencies))}return s?(s.dependencies.pop(),s.truncated=!0,!0):!1}function rt(e,t,s,n,o,i,d){let r=o??Pe,c=b(s.nodeLimit,"node-limit")??Ue,f=b(s.edgeLimit,"edge-limit")??Fe,a=b(s.tokenBudget,"token-budget")??Ge,l={nodeLimit:c,edgeLimit:f,tokenBudget:a,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},u=ge(e,n,new Set,r,t==="graph"?"repeated":i,new Set,l),g=he(e,n,void 0),m;for(;;){let p=Ve(u),h=l.reasons.size===0?void 0:{reasons:[...l.reasons].sort(),limits:{max_depth:r,node_limit:c,edge_limit:f,token_budget:a},estimated_tokens:0,total_node_count:g.node_count,total_edge_count:g.edge_count,omitted_node_count:Math.max(0,g.node_count-p.nodes.length),omitted_edge_count:Math.max(0,g.edge_count-p.edges.length)},k={id:e,format:t,node_count:p.nodes.length,edge_count:p.edges.length,edge_basis:"deduplicated_directed",missing_count:p.missing_ids.length,...h?{truncation:h}:{}};if(m=t==="tree"?{...k,tree:u}:{...k,graph:p},(m.truncation===void 0?C(new TextEncoder().encode(N($("deps",x(m,!1)),d)).byteLength):_e(x(m,!1),d,w=>{m.truncation.estimated_tokens=w}))<=a)return m;if(!it(u))return l.reasons.add("token_budget"),m;l.reasons.add("token_budget")}}function x(e,t){let s={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"};return{...e,projection:{mode:t?"summary":"full",declared_field_groups:[s],included_field_groups:t?[]:[s.name]}}}async function Ot(e,t,s){let n=q(process.cwd(),s.path);if(!await z(H(n)))throw new _(`Tracker is not initialized at ${n}. Run pm init first.`,y.NOT_FOUND);let o=je(t.format),i=pe(t.maxDepth),d=We(t.collapse);Y(t.summary===!0,t.full===!0,"--summary");let r=t.summary===!0,c=await ne(n),f=X(c,Q()),a=await ie(n,c.item_format,f.type_to_folder,void 0,c.schema),l=V(c.schema),u=new Map(a.map(m=>[m.id.trim().toLowerCase(),qe(m)])),g=de(a,m=>O(m,l));for(let m of[...g.active,...g.legacy_terminal]){let p=u.get(m.holder_id.trim().toLowerCase()),h=m.kind.trim().toLowerCase();p&&!p.dependencies.some(k=>k.id.trim().toLowerCase()===m.target_id.trim().toLowerCase()&&k.kind===h)&&p.dependencies.push({id:m.target_id,kind:h})}if(!u.has(e.trim().toLowerCase()))throw new _(`Item ${e} not found`,y.NOT_FOUND);if(o==="context"){let m=u.get(e.trim().toLowerCase()).id,p=r?[]:await Ye(n,m,c,f.type_to_folder),h=w=>O(w,l),k=re(),E=le().lookup(n,ae(a,h,k),()=>A(a,h,k));return x(ot({assembly:E.assembly,canonicalId:m,options:t,rootEvidence:p,summaryOnly:r,outputFormat:s.json===!0?"json":"toon"}),r)}return r?x({id:e,format:o,...he(e,u,i)},!0):x(rt(e,o,t,u,i,d,s.json===!0?"json":"toon"),!1)}export{ae as a,M as b,le as c,ut as d,fe as e,Ne as f,Ae as g,Me as h,b as i,pe as j,Ke as k,ze as l,Bt as m,Ot as n};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{g as re,i as de,k as A}from"./chunk-PECV7L5T.js";import{A as y,Af as ne,Bb as J,C as _,Da as X,Kd as Y,La as q,Lf as se,Mf as oe,Nc as V,Oa as H,Of as ie,Pe as C,Qd as $,Sd as Z,Se as N,Td as ee,Wd as te,b as z,cd as O,jb as v,lc as Q}from"./chunk-HS7OVAUN.js";import{createHash as Te}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]="dea35fb9-9f9f-56ce-afc0-f4dc993012c3")}catch{}})();var be=64,xe=8;function Re(e,t){let s=(e.dependencies??[]).map(n=>{if(typeof n!="object"||n===null)return"";let o=n;return`${typeof o.kind=="string"?o.kind:"related"}:${typeof o.id=="string"?o.id:""}`}).sort().join(",");return[e.id,e.title,e.status,t(e.status)?"1":"0",typeof e.type=="string"?e.type.trim():"",e.parent??"",e.blocked_by??"",s].join("\0")}function ae(e,t=n=>n==="closed"||n==="canceled",s=v()){let n=e.filter(i=>typeof i?.id=="string"&&i.id.trim().length>0).map(i=>Re(i,t)).sort(),o=s.list().map(i=>J(i)).sort();return Te("sha256").update(n.join("")).update("").update(o.join("")).digest("hex")}function ce(e,t,s){let n=t??s;if(!Number.isInteger(n)||n<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`);return n}var M=class{#e=new Map;#t;#n;constructor(t={}){this.#t=ce("maxResultsPerWorkspace",t.maxResultsPerWorkspace,be),this.#n=ce("maxWorkspaces",t.maxWorkspaces,xe)}lookup(t,s,n){let o=this.#e.get(t),i=!0;(o===void 0||o.fingerprint!==s)&&(o={fingerprint:s,assembly:n(),results:new Map},i=!1,!this.#e.has(t)&&this.#e.size>=this.#n&&this.#e.delete(this.#e.keys().next().value)),this.#e.delete(t),this.#e.set(t,o);let d=o,r=this.#t;return{assembly:d.assembly,assemblyReused:i,fingerprint:s,memoize(c,f){let a=d.results.get(c);if(a!==void 0||d.results.has(c))return d.results.delete(c),d.results.set(c,a),{value:structuredClone(a),reused:!0};let l=f();return d.results.size>=r&&d.results.delete(d.results.keys().next().value),d.results.set(c,structuredClone(l)),{value:l,reused:!1}}}}clear(){this.#e.clear()}},ue=new M;function le(){return ue}function ut(){ue.clear()}(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]="31a800f7-1374-5e7c-ad23-ae3d8ebcebe0")}catch{}})();var Le=["prerequisite","dependent","ancestor","descendant","provenance","related"],Ce=new TextEncoder;function P(e,t,s){let n=e??t;if(!Number.isInteger(n)||n<1)throw new TypeError(`Relationship context ${s} must be positive`);return n}function S(e){return Math.max(1,Math.ceil(Ce.encode(JSON.stringify(e)).byteLength/4))}function U(e,t,s){let n=s.resolve(e.kind);if(n?.ordering){let i=(n.precedence??"source_before_target")==="source_before_target"?e.source:e.target;return t===i?"prerequisite":"dependent"}if(n?.hierarchy){let i=(n.hierarchyDirection??"source_parent")==="source_parent"?e.source:e.target;return t===i?"ancestor":"descendant"}return e.kind==="discovered_from"||e.kind==="incident_from"?"provenance":"related"}function Se(e,t,s,n){let o=e.filter(i=>i.source===t&&i.target===s||i.target===t&&i.source===s).map(i=>U(i,s,n));return[...new Set(o)].sort()}function De(e){return Le.find(t=>e.includes(t))}function Ie(e,t,s,n){let o=n.direction??"both",i=n.maxDepth??3;if(!Number.isInteger(i)||i<0)throw new TypeError("Relationship context maxDepth must be non-negative");let d=new Set([t]),r=[{id:t,distance:0}],c=[],f=0,a=!1;for(let l=0;l<r.length;l+=1){n.signal?.throwIfAborted();let u=r[l];if(u.distance>=i&&a)continue;let g=e.neighborEdges(u.id,{direction:o,kinds:n.kinds,signal:n.signal});if(f+=g.meta.inspectedEdges,u.distance>=i){g.value.some(m=>!d.has(m.id))&&(a=!0);continue}for(let{id:m,edge:p}of g.value){if(d.has(m))continue;d.add(m);let h={id:m,distance:u.distance+1,via:u.id,role:U(p,m,s)};c.push(h),r.push(h)}}return c.sort((l,u)=>l.distance-u.distance||l.id.localeCompare(u.id)),{rows:c,visitedNodes:r.length,inspectedEdges:f,depthTruncated:a}}function Be(e,t,s,n){let o={prerequisite:0,dependent:0,ancestor:0,descendant:0,provenance:0,related:0},i=e.neighborEdges(t,{direction:n.direction??"both",kinds:n.kinds,signal:n.signal}).value;for(let{id:d,edge:r}of i)o[U(r,d,s)]+=1;return{directEdges:o,directTotal:i.length,rootEdges:i.map(({edge:d})=>d)}}function Oe(e){let t=[],s=e.initialTokens;for(let n of e.candidates){if(t.length>=e.nodeLimit)break;let o=n.distance===1?Se(e.rootEdges,e.rootId,n.id,e.registry):[],i={...e.details.get(n.id)??{id:n.id},distance:n.distance,role:o.length>0?De(o):n.role,via:n.via,reasons:o.length>0?o:[`${n.role} via ${n.via} (depth ${n.distance})`]},d=S(i);if(s+d>e.tokenBudget)break;t.push(i),s+=d}if(e.candidates.length>0&&t.length===0)throw new TypeError("Relationship context tokenBudget cannot fit one node");return{nodes:t,usedTokens:s}}function $e(e){let t=e.options.kinds?new Set(e.options.kinds.map(i=>e.registry.require(i).kind)):void 0,s=e.graph.edges().filter(i=>{if(!e.included.has(i.source)||!e.included.has(i.target))return!1;if(t===void 0||t.has(i.kind))return!0;let d=e.registry.resolve(i.kind)?.inverse;return d!==void 0&&t.has(d)}),n=[],o=e.initialTokens;for(let i of s){if(n.length>=e.edgeLimit)break;let d=S(i);if(o+d>e.tokenBudget)break;n.push(i),o+=d}return{edges:n,usedTokens:o,candidateCount:s.length}}function fe(e,t,s,n={}){if(!e.nodes().includes(t))throw new TypeError(`Relationship node not found: ${t}`);let o=P(n.nodeLimit,20,"nodeLimit"),i=P(n.edgeLimit,40,"edgeLimit"),d=P(n.tokenBudget,1200,"tokenBudget"),r=n.registry??v(),c=new Map(s.map(T=>[T.id,T])),f=c.get(t)??{id:t},{evidence:a=[],...l}=f,u=[...a],g=Ie(e,t,r,n),{rootEdges:m,...p}=Be(e,t,r,n),h=Z("relationship-context",{rootId:t,direction:n.direction??"both",kinds:[...n.kinds??[]].sort(),maxDepth:n.maxDepth??3}),k=te(g.rows,n.cursor,h,({id:T})=>T),E=g.rows.slice(k),w=S(l)+S(u);if(w>d)throw new TypeError("Relationship context tokenBudget cannot fit root and evidence");let G=Oe({candidates:E,details:c,rootEdges:m,rootId:t,registry:r,nodeLimit:o,tokenBudget:d,initialTokens:w}),{nodes:R}=G,we=new Set([t,...R.map(({id:T})=>T)]),j=$e({graph:e,included:we,options:n,registry:r,edgeLimit:i,tokenBudget:d,initialTokens:G.usedTokens}),{edges:D,usedTokens:ve}=j,L=k+R.length,I=L<g.rows.length,W=R.at(-1),B=j.candidateCount-D.length,K=g.depthTruncated||I||B>0,Ee={rootId:t,...l.status===void 0?{}:{rootStatus:l.status},...p,discoveredNodes:g.rows.length,returnedNodes:R.length,returnedEdges:D.length,omittedNodes:g.rows.length-L,omittedEdges:B,evidenceCount:u.length,hasMore:I};return{root:l,summary:Ee,nodes:R,edges:D,evidence:u,meta:{exact:!0,truncated:K,completeness:K?"truncated":"complete",nodeLimit:o,edgeLimit:i,tokenBudget:d,usedTokens:ve,visitedNodes:g.visitedNodes,inspectedEdges:g.inspectedEdges,omittedNodes:g.rows.length-L,omittedEdges:B,...I&&W?{nextCursor:ee(h,W.id,L-1)}:{}}}}(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]="a3535267-c69a-5a44-bdf9-02925e02aaeb")}catch{}})();var Ne=["tree","graph","context"],Ae=["none","repeated"],Me=["outgoing","incoming","both"],Pe=32,Ue=200,Fe=400,Ge=16e3;function je(e){let t=e?.trim().toLowerCase()??"tree";if(Ne.includes(t))return t;throw new _(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,y.USAGE)}function b(e,t){if(e===void 0)return;let s=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(s)||s<1)throw new _(`Invalid --${t} value "${e}". Use a positive integer.`,y.USAGE);return s}function pe(e){if(e===void 0)return;let t=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(t)||t<0)throw new _(`Invalid --max-depth value "${e}". Use a non-negative integer.`,y.USAGE);return t}function We(e){let t=e?.trim().toLowerCase()??"none";if(Ae.includes(t))return t;throw new _(`Invalid --collapse value "${e}". Use "none" or "repeated".`,y.USAGE)}function Ke(e){let t=e?.trim().toLowerCase()??"both";if(Me.includes(t))return t;throw new _(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,y.USAGE)}function ze(e,t=v()){if(e===void 0)return;let s=(Array.isArray(e)?e:[e]).flatMap(o=>o.split(",")).map(o=>o.trim()).filter(o=>o.length>0);if(s.length===0)return;let n=new Set;for(let o of s){let i=t.resolve(o);if(!i){let d=t.list().map(r=>r.kind).join(", ");throw new _(`Invalid --kind value "${o}". Registered kinds: ${d}.`,y.USAGE)}n.add(i.kind)}return[...n].sort()}function Xe(e){if(!e||e.length===0)return[];let t=e.map(({id:n,kind:o})=>({id:n.trim(),kind:o.trim().toLowerCase()})).sort((n,o)=>{let i=n.kind.localeCompare(o.kind);return i!==0?i:n.id.localeCompare(o.id)}),s=new Map;for(let n of t){let o=`${n.kind.toLowerCase()}::${n.id.toLowerCase()}`;s.has(o)||s.set(o,{id:n.id,kind:n.kind})}return[...s.values()]}function qe(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:Xe(e.dependencies)}}function He(e){return C(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function Je(e,t,s,n,o,i,d,r,c){for(let f of t.dependencies){let a=Math.max(1,Math.ceil(JSON.stringify({from:e.id,to:f.id,kind:f.kind}).length/3));if(r.nodes>=r.nodeLimit){e.truncated=!0,r.reasons.add("node_limit");break}if(r.edges>=r.edgeLimit){e.truncated=!0,r.reasons.add("edge_limit");break}if(r.estimatedTokens+a>=r.tokenBudget){e.truncated=!0,r.reasons.add("token_budget");break}r.edges+=1,r.estimatedTokens+=a,e.dependencies.push(ge(f.id,s,n,o,i,d,r,c+1,f.kind))}}function Qe(e,t,s,n,o,i,d,r){return d.estimatedTokens>=d.tokenBudget&&t?.dependencies.length?(e.truncated=!0,d.reasons.add("token_budget"),!0):!t||e.cycle?!0:n!==void 0&&r>=n?(t.dependencies.length>0&&(e.truncated=!0,d.reasons.add("max_depth")),!0):o==="repeated"&&i.has(s)?(e.collapsed=!0,!0):!1}function ge(e,t,s,n,o,i,d,r=0,c){let f=e.trim().toLowerCase(),a=t.get(f),l={id:a?.id??e,title:a?.title,type:a?.type,status:a?.status,via:c,missing:!a,cycle:s.has(f),dependencies:[]};if(d.nodes+=1,d.estimatedTokens+=He(l),Qe(l,a,f,n,o,i,d,r))return l;o==="repeated"&&i.add(f);let u=new Set(s);return u.add(f),Je(l,a,t,u,n,o,i,d,r),l}function me(e,t){return!e||e.missing&&!t.missing?t:{...e,title:e.title??t.title,type:e.type??t.type,status:e.status??t.status}}function Ve(e){let t=new Map,s=new Map,n=[e];for(;n.length>0;){let r=n.pop();t.set(r.id,me(t.get(r.id),{id:r.id,title:r.title,type:r.type,status:r.status,missing:r.missing}));for(let c of r.dependencies){t.set(c.id,me(t.get(c.id),{id:c.id,title:c.title,type:c.type,status:c.status,missing:c.missing}));let f=c.via??"related",a=`${r.id}::${c.id}::${f}`;s.has(a)||s.set(a,{from:r.id,to:c.id,kind:f}),c.cycle||n.push(c)}}let o=[...t.values()].sort((r,c)=>r.id.localeCompare(c.id)),i=[...s.values()].sort((r,c)=>{let f=r.from.localeCompare(c.from);if(f!==0)return f;let a=r.to.localeCompare(c.to);return a!==0?a:r.kind.localeCompare(c.kind)}),d=o.filter(r=>r.missing).map(r=>r.id);return{root_id:e.id,nodes:o,edges:i,missing_ids:d}}function he(e,t,s){let n=new Set,o=new Set,i=new Set,d=new Set,r=[{id:e,depth:0}],c=0;for(;c<r.length;){let f=r[c++],a=f.id.trim().toLowerCase();n.add(a);let l=t.get(a);if(!l){i.add(a);continue}if(!(s!==void 0&&f.depth>=s)&&!d.has(a)){d.add(a);for(let u of l.dependencies)o.add(`${a}::${u.id.trim().toLowerCase()}::${u.kind}`),r.push({id:u.id,depth:f.depth+1})}}return{node_count:n.size,edge_count:o.size,edge_basis:"deduplicated_directed",missing_count:i.size}}function ke(e,t=v()){let s=pe(e.maxDepth),n=b(e.nodeLimit,"node-limit"),o=b(e.edgeLimit,"edge-limit"),i=b(e.tokenBudget,"token-budget"),d=ze(e.kind,t);return{direction:Ke(e.direction),...d===void 0?{}:{kinds:d},...s===void 0?{}:{maxDepth:s},...n===void 0?{}:{nodeLimit:n},...o===void 0?{}:{edgeLimit:o},...i===void 0?{}:{tokenBudget:i},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function ye(e,t,s,n){return fe(e.graph,t,e.details.map(o=>o.id===t&&n.length>0?{...o,evidence:n}:o),s)}function Bt(e,t,s,n=[]){let o=A(t);return ye(o,e,ke(s,o.graph.registry()),n)}function F(e,t,s,n){for(let o of s.slice(0,n)){let i=o?.trim();i&&e.push(`${t}:${i}`)}}async function Ye(e,t,s,n){let o=await se(e,t,s.id_prefix,s.item_format,n);if(!o)return[];let{document:i}=await oe(o,{schema:s.schema}),d=i.metadata,r=d.files??[],c=d.tests??[],f=d.docs??[],a=[["files",r.length],["tests",c.length],["docs",f.length],["comments",(d.comments??[]).length],["notes",(d.notes??[]).length],["learnings",(d.learnings??[]).length]];if(a.every(([,u])=>u===0))return[];let l=[`linked:${a.map(([u,g])=>`${u}=${g}`).join(",")}`];return F(l,"file",r.map(u=>u.path),3),F(l,"test",c.map(u=>u.command??u.path),2),F(l,"doc",f.map(u=>u.path),2),l}function Ze(e){let{canonicalId:t,context:s,missingCount:n,missingReferences:o,referenceLimit:i,summaryOnly:d}=e;return{id:t,format:"context",node_count:s.nodes.length+1,edge_count:s.edges.length,edge_basis:"deduplicated_directed",missing_count:n,missing_scope:"traversal",missing_reference_count:o.length,...d?{}:{missing_references:o.slice(0,i),context:s}}}function et(e){let{row:t,missingReachableSet:s,packetIds:n,filteredKinds:o,registry:i}=e;if(t.no_active_blocker_sentinel||!s.has(t.target_id.trim().toLowerCase())||!n.has(t.holder_id))return!1;if(o===void 0)return!0;let d=i.resolve(t.kind);return d!==void 0&&(o.has(d.kind)||d.inverse!==void 0&&o.has(d.inverse))}function _e(e,t,s){let n;for(;;){let o=C(new TextEncoder().encode(N($("deps",e),t)).byteLength);if(o===n)return o;s(o),n=o}}function tt(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function nt(e){try{return ye(e.assembly,e.canonicalId,{...e.contextOptions,...e.internalTokenBudget===void 0?{}:{tokenBudget:e.internalTokenBudget}},e.rootEvidence)}catch(t){if(e.smallestResult!==void 0&&tt(t))return e.smallestResult;throw t}}function st(e){let{assembly:t,canonicalId:s,contextOptions:n,rootEvidence:o,summaryOnly:i,outputFormat:d,missingCount:r,missingReferences:c}=e,a=n.edgeLimit??40,l=n.tokenBudget,u,g;for(;;){let m=nt({assembly:t,canonicalId:s,contextOptions:n,internalTokenBudget:l,rootEvidence:o,smallestResult:g});if("format"in m)return m;let p=m;u??=p.meta.tokenBudget,l??=u;let h=Ze({canonicalId:s,context:p,missingCount:r,missingReferences:c,referenceLimit:a,summaryOnly:i});if(g=h,i||(p.meta.tokenBudget=u,p.meta.usedTokens=_e(x(h,!1),d,w=>{p.meta.usedTokens=w}),p.meta.usedTokens<=u))return h;if(a>0){a-=1;continue}let k=l,E=k*u/p.meta.usedTokens;l=Math.min(k-1,Math.max(1,Math.floor(E*.9)))}}function ot(e){let{assembly:t,canonicalId:s,options:n,rootEvidence:o,summaryOnly:i,outputFormat:d}=e,r=ke(n,t.graph.registry()),c=t.graph.closure(s,{direction:r.direction,...r.kinds===void 0?{}:{kinds:r.kinds},maxDepth:r.maxDepth??3}),f=c.value.filter(p=>t.missingIdSet.has(p.toLowerCase())),a=new Set(f.map(p=>p.toLowerCase())),l=t.graph.registry(),u=r.kinds?new Set(r.kinds.map(p=>l.require(p).kind)):void 0,g=new Set([s,...c.value]),m=[...t.dangling.active,...t.dangling.legacy_terminal].filter(p=>et({row:p,missingReachableSet:a,packetIds:g,filteredKinds:u,registry:l}));return st({assembly:t,canonicalId:s,contextOptions:r,rootEvidence:o,summaryOnly:i,outputFormat:d,missingCount:f.length,missingReferences:m})}function it(e){let t=[e],s;for(;t.length>0;){let n=t.pop();n.dependencies.length>0&&(s=n,t.push(...n.dependencies))}return s?(s.dependencies.pop(),s.truncated=!0,!0):!1}function rt(e,t,s,n,o,i,d){let r=o??Pe,c=b(s.nodeLimit,"node-limit")??Ue,f=b(s.edgeLimit,"edge-limit")??Fe,a=b(s.tokenBudget,"token-budget")??Ge,l={nodeLimit:c,edgeLimit:f,tokenBudget:a,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},u=ge(e,n,new Set,r,t==="graph"?"repeated":i,new Set,l),g=he(e,n,void 0),m;for(;;){let p=Ve(u),h=l.reasons.size===0?void 0:{reasons:[...l.reasons].sort(),limits:{max_depth:r,node_limit:c,edge_limit:f,token_budget:a},estimated_tokens:0,total_node_count:g.node_count,total_edge_count:g.edge_count,omitted_node_count:Math.max(0,g.node_count-p.nodes.length),omitted_edge_count:Math.max(0,g.edge_count-p.edges.length)},k={id:e,format:t,node_count:p.nodes.length,edge_count:p.edges.length,edge_basis:"deduplicated_directed",missing_count:p.missing_ids.length,...h?{truncation:h}:{}};if(m=t==="tree"?{...k,tree:u}:{...k,graph:p},(m.truncation===void 0?C(new TextEncoder().encode(N($("deps",x(m,!1)),d)).byteLength):_e(x(m,!1),d,w=>{m.truncation.estimated_tokens=w}))<=a)return m;if(!it(u))return l.reasons.add("token_budget"),m;l.reasons.add("token_budget")}}function x(e,t){let s={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"};return{...e,projection:{mode:t?"summary":"full",declared_field_groups:[s],included_field_groups:t?[]:[s.name]}}}async function Ot(e,t,s){let n=q(process.cwd(),s.path);if(!await z(H(n)))throw new _(`Tracker is not initialized at ${n}. Run pm init first.`,y.NOT_FOUND);let o=je(t.format),i=pe(t.maxDepth),d=We(t.collapse);Y(t.summary===!0,t.full===!0,"--summary");let r=t.summary===!0,c=await ne(n),f=X(c,Q()),a=await ie(n,c.item_format,f.type_to_folder,void 0,c.schema),l=V(c.schema),u=new Map(a.map(m=>[m.id.trim().toLowerCase(),qe(m)])),g=de(a,m=>O(m,l));for(let m of[...g.active,...g.legacy_terminal]){let p=u.get(m.holder_id.trim().toLowerCase()),h=m.kind.trim().toLowerCase();p&&!p.dependencies.some(k=>k.id.trim().toLowerCase()===m.target_id.trim().toLowerCase()&&k.kind===h)&&p.dependencies.push({id:m.target_id,kind:h})}if(!u.has(e.trim().toLowerCase()))throw new _(`Item ${e} not found`,y.NOT_FOUND);if(o==="context"){let m=u.get(e.trim().toLowerCase()).id,p=r?[]:await Ye(n,m,c,f.type_to_folder),h=w=>O(w,l),k=re(),E=le().lookup(n,ae(a,h,k),()=>A(a,h,k));return x(ot({assembly:E.assembly,canonicalId:m,options:t,rootEvidence:p,summaryOnly:r,outputFormat:s.json===!0?"json":"toon"}),r)}return r?x({id:e,format:o,...he(e,u,i)},!0):x(rt(e,o,t,u,i,d,s.json===!0?"json":"toon"),!1)}export{ae as a,M as b,le as c,ut as d,fe as e,Ne as f,Ae as g,Me as h,b as i,pe as j,Ke as k,ze as l,Bt as m,Ot as n};
|
|
2
|
+
//# sourceMappingURL=chunk-F4NREH3G.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o,p as s}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{o,p as s}from"./chunk-DQGJ2RWT.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]="c4c82f8f-7890-5ed2-8f0f-a82ba42cf807")}catch{}})();async function f(e,t,n){let d=await o(e,t,n,{metadataKey:"docs",op:"docs_add",bareNoun:"doc",supportsAppendStable:!1});return s(d,"docs")}export{f as a};
|
|
2
|
+
//# sourceMappingURL=chunk-FDBRXV25.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Z}from"./chunk-PYYPQLHC.js";import{a as X}from"./chunk-NPUJ7OLK.js";import{a as m}from"./chunk-FB7G2HY2.js";import{u as y}from"./chunk-Q5F6OI7C.js";import{a as R,b as A,c as S,d as T,n as q,r as Y}from"./chunk-BKMZTZYL.js";import{a as L,b as j,c as z,d as B,e as G,k as $}from"./chunk-VH2EAGUG.js";import{k as H}from"./chunk-ZSH4GNBH.js";import{A as d,C as l,Cb as N,Da as U,Ea as E,H as k,La as M,Lc as K,Nc as O,Oa as C,Pc as D,R as v,V as I,Vc as F,ad as V,b as w,lc as P,yf as W,zd as x}from"./chunk-V5K52PYW.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]="61fe3a97-39e6-53de-8663-8e70d931a2d4")}catch{}})();var Q=1,g="update-many",fe=new Set(["author","message","force","ownershipMetadataBypass","ownershipDependencyBypass"]),me=["--status","--priority","--type","--tags","--description","--body","--deadline","--estimate","--assignee","--dep","--dep-remove","--comment","--note","--learning","--file","--test","--doc","--replace-deps","--replace-tests","--replace-files","--replace-docs","--unset","--clear-*"].join(", "),ye={title:"title",description:"description",body:"body",status:"status",closeReason:"close_reason",priority:"priority",type:"type",deadline:"deadline",estimatedMinutes:"estimated_minutes",acceptanceCriteria:"acceptance_criteria",definitionOfReady:"definition_of_ready",order:"order",goal:"goal",objective:"objective",value:"value",impact:"impact",outcome:"outcome",whyNow:"why_now",assignee:"assignee",parent:"parent",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release",blockedBy:"blocked_by",blockedReason:"blocked_reason",unblockNote:"unblock_note",reporter:"reporter",severity:"severity",environment:"environment",reproSteps:"repro_steps",resolution:"resolution",expectedResult:"expected_result",actualResult:"actual_result",affectedVersion:"affected_version",fixedVersion:"fixed_version",component:"component",regression:"regression",customerImpact:"customer_impact"},_e=[{field:"dependencies",addKey:"dep",removeKey:"depRemove",clearKey:"clearDeps",replaceKey:"replaceDeps"},{field:"comments",addKey:"comment",clearKey:"clearComments"},{field:"notes",addKey:"note",clearKey:"clearNotes"},{field:"learnings",addKey:"learning",clearKey:"clearLearnings"},{field:"files",addKey:"file",clearKey:"clearFiles",replaceKey:"replaceFiles"},{field:"tests",addKey:"test",clearKey:"clearTests",replaceKey:"replaceTests"},{field:"docs",addKey:"doc",clearKey:"clearDocs",replaceKey:"replaceDocs"},{field:"reminders",addKey:"reminder",clearKey:"clearReminders"},{field:"events",addKey:"event",clearKey:"clearEvents"},{field:"type_options",addKey:"typeOption",clearKey:"clearTypeOptions"}],ge={close_reason:"close_reason","close-reason":"close_reason",deadline:"deadline",estimate:"estimated_minutes",estimated_minutes:"estimated_minutes","estimated-minutes":"estimated_minutes",acceptance_criteria:"acceptance_criteria","acceptance-criteria":"acceptance_criteria",ac:"acceptance_criteria",definition_of_ready:"definition_of_ready","definition-of-ready":"definition_of_ready",order:"order",rank:"order",goal:"goal",objective:"objective",value:"value",impact:"impact",outcome:"outcome",why_now:"why_now","why-now":"why_now",assignee:"assignee",parent:"parent",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release",blocked_by:"blocked_by","blocked-by":"blocked_by",blocked_reason:"blocked_reason","blocked-reason":"blocked_reason",unblock_note:"unblock_note","unblock-note":"unblock_note",reporter:"reporter",severity:"severity",environment:"environment",repro_steps:"repro_steps","repro-steps":"repro_steps",resolution:"resolution",expected_result:"expected_result","expected-result":"expected_result",actual_result:"actual_result","actual-result":"actual_result",affected_version:"affected_version","affected-version":"affected_version",fixed_version:"fixed_version","fixed-version":"fixed_version",component:"component",regression:"regression",customer_impact:"customer_impact","customer-impact":"customer_impact",type_options:"type_options","type-options":"type_options",tags:"tags"},h=e=>{let t={};for(let[n,i]of Object.entries(e))fe.has(n)||i!==void 0&&(t[n]=i);return t},ee=e=>Object.keys(h(e)).length>0,te=e=>typeof e=="string"?e.trim():e,he=e=>{let t=String(e).trim(),n=Number(t);return Number.isInteger(n)?n:t},_=e=>{let t=String(e).trim(),n=Number(t);return Number.isFinite(n)?n:t},be=e=>{let t=String(e).trim().toLowerCase();return new Map([["true",!0],["1",!0],["false",!1],["0",!1]]).get(t)??te(e)},we={priority:he,estimatedMinutes:_,order:_,rank:_,regression:be},ne=(e,t)=>{if(t!==void 0)return(we[e]??te)(t)},oe=e=>{let t=e.trim().toLowerCase().replaceAll("-","_");return ge[t]??t},f=(e,t)=>N(e,t),ie=(e,t)=>t!==void 0?t:e==="type_options"?{}:[],se=(e,t)=>Array.isArray(t)?t.length:e==="type_options"&&t&&typeof t=="object"?Object.keys(t).length:0,ke=e=>e.replace?"replace":e.clear?"clear_or_reset":e.removeCount>0?"merge_remove":"append",J=(e,t)=>t===void 0?void 0:e[t],p=e=>Array.isArray(e)?e.length:0,ve=(e,t,n)=>{let i=n[e.addKey],o=J(n,e.removeKey),r=p(i),s=p(o),a=n[e.clearKey]===!0,c=J(n,e.replaceKey)===!0;if(![a,c,r>0,s>0].includes(!0))return;let u=ie(e.field,t[e.field]);return{field:e.field,before:u,after:{operation:ke({replace:c,clear:a,removeCount:s}),clear:a,replace:c,add_count:r,remove_count:s,before_count:se(e.field,u)}}},re=(e,t)=>{let n=[];for(let i of _e){let o=ve(i,e,t);o!==void 0&&n.push(o)}return n},ae=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],ce=(e,t)=>{if(![t.tags!==void 0,p(t.addTags)>0,p(t.removeTags)>0].includes(!0))return;let n=ae(e.tags),i=t.tags===void 0?n:L(t.tags),o=B(i,t.addTags),r=G(o,t.removeTags).slice().sort((a,c)=>a.localeCompare(c)),s=n.slice().sort((a,c)=>a.localeCompare(c));if(!f(s,r))return{field:"tags",before:n,after:r}},Ie=(e,t)=>{let n=e.acceptance_criteria,i=t.acceptanceCriteria===void 0?n:String(t.acceptanceCriteria).trim(),o=z(j(i),t.addAc,t.removeAc),r=o.unmatchedRemovals.map(a=>`remove_ac_unmatched:${a}`),s=o.criteria.join("; ");return f(n,s)||n===void 0&&s===""?{warnings:r}:{change:{field:"acceptance_criteria",before:n,after:s},warnings:r}},Re=(e,t,n)=>{for(let[i,o]of Object.entries(ye)){let r=n[i];if(r===void 0)continue;let s=t[o],a=ne(i,r);f(s,a)||e.push({field:o,before:s,after:a})}},Ae=(e,t,n,i)=>{let o=F(n,i,["update_many"]);for(let[r,s]of Object.entries(o)){let a=t[r];f(a,s)||e.push({field:r,before:a,after:s})}},Se=(e,t,n)=>{for(let i of n??[]){let o=oe(i),r=t[o];r!==void 0&&e.push({field:o,before:r,after:null})}},de=(e,t,n={})=>{let i=e,o=[],r=[],s=ce(i,n);if(s&&o.push(s),Re(o,i,n),p(n.addAc)>0||p(n.removeAc)>0){let a=Ie(i,n),c=o.filter(u=>u.field!=="acceptance_criteria");o.splice(0,o.length,...c),a.change!==void 0&&o.push(a.change),r.push(...a.warnings)}return o.push(...re(i,n)),Ae(o,i,n,t),Se(o,i,n.unset),{id:e.id,changes:o,...r.length>0?{warnings:r}:{}}},le=(e,t)=>Y(e,t,{strict:!0,flagLabel:"--filter-status"}),ue=e=>{if(e?.ids!=null&&String(e.ids).trim().length===0)throw new l("--ids requires at least one non-empty item ID",d.USAGE)},Te=[({update:e})=>{e.priority!==void 0&&q(e.priority)},({update:e,settings:t,pmRoot:n})=>{if(e.type===void 0)return;let i=U(t,P());if(!E(e.type,i))throw new l(H(e.type,i.types,K(n,t.schema)),d.USAGE)},({update:e,statusRegistry:t})=>{if(e.status!==void 0&&!V(e.status,t)){let n=t.definitions.map(i=>i.id);throw new l(`Invalid --status value "${e.status}". Allowed: ${n.join(", ")}`,d.USAGE)}},({update:e})=>{e.deadline!==void 0&&I(e.deadline,new Date,"deadline")},({update:e})=>{e.estimatedMinutes!==void 0&&$(e.estimatedMinutes,"estimated-minutes")}],pe=(e,t,n,i)=>{let o={update:e,settings:t,statusRegistry:n,pmRoot:i};for(let r of Te)r(o)},Ue=async e=>{let t=await S(e.pmRoot,g,e.rollbackId,Q),n=e.options.update?.message??`Rollback update-many checkpoint ${t.id}`,i=await T(t.items,(o,r)=>X(o,r,{author:e.options.update?.author,message:n,force:e.options.update?.force??!0},e.global));return{mode:"rollback",matched_count:t.items.length,dry_run:!1,rollback_checkpoint_id:t.id,checkpoint:{id:t.id,created_at:t.created_at,path:t.path,rollback_command:`pm update-many --rollback ${t.id}`},restored_count:i.restored_ids.length,failed_count:i.failed_count,rows:i.rows,ids:i.restored_ids}},Ee=async e=>{let t={schema_version:Q,id:e.checkpointId,created_at:e.nowValue,author:x(e.options.update?.author,"unknown"),status_filter:e.statusFilter??null,list_filters:e.filters,update_options:e.updateSummary,items:e.checkpointItems},n=await A(e.pmRoot,g,e.checkpointId,t);return{id:e.checkpointId,created_at:e.nowValue,path:n,rollback_command:`pm update-many --rollback ${e.checkpointId}`}},Me=(e,t)=>{if(e==null)return;let n=[...new Set(String(e).split(",").map(o=>o.trim()).filter(o=>o.length>0))],i=new Set(t.map(o=>o.id));return n.filter(o=>!i.has(o))},b=e=>e.unmatchedIds===void 0?{}:{unmatched_ids:e.unmatchedIds,unmatched_count:e.unmatchedIds.length},Ce=async e=>{let t=M(process.cwd(),e.path);if(!await w(C(t)))throw new l(`Tracker is not initialized at ${t}. Run pm init first.`,d.NOT_FOUND);let n=await W(t);return{pmRoot:t,settings:n,statusRegistry:O(n.schema),runtimeFieldRegistry:D(n.schema)}},Ne=e=>{if(e.options.dryRun===!0)throw new l("--dry-run cannot be combined with --rollback",d.USAGE);if(m(e.options.list,e.options.status))throw new l("Rollback mode does not accept filter options",d.USAGE);if(Object.keys(e.updateSummary).length>0)throw new l("Rollback mode does not accept update mutation flags",d.USAGE);return Ue({pmRoot:e.runtime.pmRoot,rollbackId:e.rollbackId,options:e.options,global:e.global})},Pe=async e=>{le(e.options.status,e.runtime.statusRegistry);let t=await y(void 0,{...e.options.list,status:e.options.status,compact:void 0,brief:void 0,fields:void 0,includeBody:!0,full:!0},e.global),n=t.items.map(o=>de(o,e.runtime.runtimeFieldRegistry,e.options.update)),i=e.options.list?.ids==null?[]:(await y(void 0,{ids:e.options.list.ids,noTruncate:!0,full:!0},e.global)).items;return{listed:t,planned:n,actionable:n.filter(o=>o.changes.length>0),updateSummary:e.updateSummary,unmatchedIds:Me(e.options.list?.ids,i)}},Ke=e=>({mode:"dry_run",matched_count:e.listed.items.length,dry_run:!0,filters:e.listed.filters,planned_update_options:e.updateSummary,item_plans:e.planned,ids:[],...b(e)}),Oe=e=>({mode:"apply",matched_count:e.listed.items.length,dry_run:!1,filters:e.listed.filters,planned_update_options:e.updateSummary,updated_count:0,skipped_count:e.listed.items.length,failed_count:0,rows:e.planned.map(t=>({id:t.id,status:"skipped",...t.warnings?{warnings:t.warnings}:{}})),ids:[],...b(e)}),De=async e=>{let t=[],n=[],i=e.options.update.message??`update-many apply ${e.checkpointId}`,o=new Map(e.plans.map(s=>[s.id,s])),r=new Set(e.plans.filter(s=>s.changes.length>0).map(s=>s.id));for(let s of e.items){if(!r.has(s.id)){let a=o.get(s.id)?.warnings;t.push({id:s.id,status:"skipped",...a?{warnings:a}:{}});continue}try{let a=await Z(s.id,{...e.options.update,message:i,runtimeFieldCommands:["update_many"]},e.global);t.push({id:s.id,status:"updated",changed_fields:a.changed_fields,warnings:a.warnings}),n.push(s.id)}catch(a){t.push({id:s.id,status:"failed",error:k(a)})}}return{rows:t,updatedIds:n}},Fe=async e=>{if(e.plan.actionable.length===0)return Oe(e.plan);let t=v(),n=R(g,t),i=new Set(e.plan.actionable.map(c=>c.id)),o=e.plan.listed.items.filter(c=>i.has(c.id)).map(c=>({id:c.id,target_updated_at:c.updated_at})),r=e.options.checkpoint===!1?void 0:await Ee({pmRoot:e.runtime.pmRoot,checkpointId:n,nowValue:t,options:e.options,statusFilter:e.options.status,filters:e.plan.listed.filters,updateSummary:e.plan.updateSummary,checkpointItems:o}),s=await De({items:e.plan.listed.items,plans:e.plan.planned,options:e.options,global:e.global,checkpointId:n}),a=c=>s.rows.filter(u=>u.status===c).length;return{mode:"apply",matched_count:e.plan.listed.items.length,dry_run:!1,filters:e.plan.listed.filters,planned_update_options:e.plan.updateSummary,...r?{checkpoint:r}:{},updated_count:a("updated"),skipped_count:a("skipped"),failed_count:a("failed"),rows:s.rows,ids:s.updatedIds,...b(e.plan)}},$e=async(e,t)=>{let n=await Ce(t),i=typeof e.rollback=="string"?e.rollback:void 0,o=h(e.update);if(ue(e.list),i!==void 0)return Ne({runtime:n,rollbackId:i,options:e,global:t,updateSummary:o});if(!ee(e.update))throw new l(`No update-many mutation flags provided. Add at least one mutation flag (for example: ${me}).`,d.USAGE);pe(e.update,n.settings,n.statusRegistry,n.pmRoot);let r=await Pe({options:e,global:t,runtime:n,updateSummary:o});return e.dryRun===!0?Ke(r):Fe({runtime:n,options:e,global:t,plan:r})},qe={assertPlannedUpdateValuesValid:pe,buildCollectionMutationPlans:re,buildPlannedItemDiff:de,buildTagMutationPlan:ce,collectionValueCount:se,hasAnyUpdateMutationInput:ee,hasListFilters:m,normalizeStatusFilter:le,normalizeCollectionBeforeValue:ie,normalizeExistingTags:ae,normalizeUnsetField:oe,rejectBlankIdsFilter:ue,sanitizeUpdateOptionsForSummary:h,toComparablePreviewValue:ne};export{$e as a,qe as b};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as Z}from"./chunk-AYRUGRNS.js";import{a as X}from"./chunk-OXY3SJ3N.js";import{a as m}from"./chunk-FB7G2HY2.js";import{u as y}from"./chunk-3KFVGGRE.js";import{a as R,b as A,c as S,d as T,n as q,r as Y}from"./chunk-MDTH7SAE.js";import{a as L,b as j,c as z,d as B,e as G,k as $}from"./chunk-R6LSRGPS.js";import{k as H}from"./chunk-UVVXHGYS.js";import{A as d,Af as W,C as l,Cb as N,Da as U,Ea as E,H as k,La as M,Lc as K,Nc as O,Oa as C,Pc as D,R as v,V as I,Vc as F,ad as V,b as w,lc as P,zd as x}from"./chunk-HS7OVAUN.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]="61fe3a97-39e6-53de-8663-8e70d931a2d4")}catch{}})();var Q=1,g="update-many",fe=new Set(["author","message","force","ownershipMetadataBypass","ownershipDependencyBypass"]),me=["--status","--priority","--type","--tags","--description","--body","--deadline","--estimate","--assignee","--dep","--dep-remove","--comment","--note","--learning","--file","--test","--doc","--replace-deps","--replace-tests","--replace-files","--replace-docs","--unset","--clear-*"].join(", "),ye={title:"title",description:"description",body:"body",status:"status",closeReason:"close_reason",priority:"priority",type:"type",deadline:"deadline",estimatedMinutes:"estimated_minutes",acceptanceCriteria:"acceptance_criteria",definitionOfReady:"definition_of_ready",order:"order",goal:"goal",objective:"objective",value:"value",impact:"impact",outcome:"outcome",whyNow:"why_now",assignee:"assignee",parent:"parent",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release",blockedBy:"blocked_by",blockedReason:"blocked_reason",unblockNote:"unblock_note",reporter:"reporter",severity:"severity",environment:"environment",reproSteps:"repro_steps",resolution:"resolution",expectedResult:"expected_result",actualResult:"actual_result",affectedVersion:"affected_version",fixedVersion:"fixed_version",component:"component",regression:"regression",customerImpact:"customer_impact"},_e=[{field:"dependencies",addKey:"dep",removeKey:"depRemove",clearKey:"clearDeps",replaceKey:"replaceDeps"},{field:"comments",addKey:"comment",clearKey:"clearComments"},{field:"notes",addKey:"note",clearKey:"clearNotes"},{field:"learnings",addKey:"learning",clearKey:"clearLearnings"},{field:"files",addKey:"file",clearKey:"clearFiles",replaceKey:"replaceFiles"},{field:"tests",addKey:"test",clearKey:"clearTests",replaceKey:"replaceTests"},{field:"docs",addKey:"doc",clearKey:"clearDocs",replaceKey:"replaceDocs"},{field:"reminders",addKey:"reminder",clearKey:"clearReminders"},{field:"events",addKey:"event",clearKey:"clearEvents"},{field:"type_options",addKey:"typeOption",clearKey:"clearTypeOptions"}],ge={close_reason:"close_reason","close-reason":"close_reason",deadline:"deadline",estimate:"estimated_minutes",estimated_minutes:"estimated_minutes","estimated-minutes":"estimated_minutes",acceptance_criteria:"acceptance_criteria","acceptance-criteria":"acceptance_criteria",ac:"acceptance_criteria",definition_of_ready:"definition_of_ready","definition-of-ready":"definition_of_ready",order:"order",rank:"order",goal:"goal",objective:"objective",value:"value",impact:"impact",outcome:"outcome",why_now:"why_now","why-now":"why_now",assignee:"assignee",parent:"parent",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release",blocked_by:"blocked_by","blocked-by":"blocked_by",blocked_reason:"blocked_reason","blocked-reason":"blocked_reason",unblock_note:"unblock_note","unblock-note":"unblock_note",reporter:"reporter",severity:"severity",environment:"environment",repro_steps:"repro_steps","repro-steps":"repro_steps",resolution:"resolution",expected_result:"expected_result","expected-result":"expected_result",actual_result:"actual_result","actual-result":"actual_result",affected_version:"affected_version","affected-version":"affected_version",fixed_version:"fixed_version","fixed-version":"fixed_version",component:"component",regression:"regression",customer_impact:"customer_impact","customer-impact":"customer_impact",type_options:"type_options","type-options":"type_options",tags:"tags"},h=e=>{let t={};for(let[n,i]of Object.entries(e))fe.has(n)||i!==void 0&&(t[n]=i);return t},ee=e=>Object.keys(h(e)).length>0,te=e=>typeof e=="string"?e.trim():e,he=e=>{let t=String(e).trim(),n=Number(t);return Number.isInteger(n)?n:t},_=e=>{let t=String(e).trim(),n=Number(t);return Number.isFinite(n)?n:t},be=e=>{let t=String(e).trim().toLowerCase();return new Map([["true",!0],["1",!0],["false",!1],["0",!1]]).get(t)??te(e)},we={priority:he,estimatedMinutes:_,order:_,rank:_,regression:be},ne=(e,t)=>{if(t!==void 0)return(we[e]??te)(t)},oe=e=>{let t=e.trim().toLowerCase().replaceAll("-","_");return ge[t]??t},f=(e,t)=>N(e,t),ie=(e,t)=>t!==void 0?t:e==="type_options"?{}:[],se=(e,t)=>Array.isArray(t)?t.length:e==="type_options"&&t&&typeof t=="object"?Object.keys(t).length:0,ke=e=>e.replace?"replace":e.clear?"clear_or_reset":e.removeCount>0?"merge_remove":"append",J=(e,t)=>t===void 0?void 0:e[t],p=e=>Array.isArray(e)?e.length:0,ve=(e,t,n)=>{let i=n[e.addKey],o=J(n,e.removeKey),r=p(i),s=p(o),a=n[e.clearKey]===!0,c=J(n,e.replaceKey)===!0;if(![a,c,r>0,s>0].includes(!0))return;let u=ie(e.field,t[e.field]);return{field:e.field,before:u,after:{operation:ke({replace:c,clear:a,removeCount:s}),clear:a,replace:c,add_count:r,remove_count:s,before_count:se(e.field,u)}}},re=(e,t)=>{let n=[];for(let i of _e){let o=ve(i,e,t);o!==void 0&&n.push(o)}return n},ae=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],ce=(e,t)=>{if(![t.tags!==void 0,p(t.addTags)>0,p(t.removeTags)>0].includes(!0))return;let n=ae(e.tags),i=t.tags===void 0?n:L(t.tags),o=B(i,t.addTags),r=G(o,t.removeTags).slice().sort((a,c)=>a.localeCompare(c)),s=n.slice().sort((a,c)=>a.localeCompare(c));if(!f(s,r))return{field:"tags",before:n,after:r}},Ie=(e,t)=>{let n=e.acceptance_criteria,i=t.acceptanceCriteria===void 0?n:String(t.acceptanceCriteria).trim(),o=z(j(i),t.addAc,t.removeAc),r=o.unmatchedRemovals.map(a=>`remove_ac_unmatched:${a}`),s=o.criteria.join("; ");return f(n,s)||n===void 0&&s===""?{warnings:r}:{change:{field:"acceptance_criteria",before:n,after:s},warnings:r}},Re=(e,t,n)=>{for(let[i,o]of Object.entries(ye)){let r=n[i];if(r===void 0)continue;let s=t[o],a=ne(i,r);f(s,a)||e.push({field:o,before:s,after:a})}},Ae=(e,t,n,i)=>{let o=F(n,i,["update_many"]);for(let[r,s]of Object.entries(o)){let a=t[r];f(a,s)||e.push({field:r,before:a,after:s})}},Se=(e,t,n)=>{for(let i of n??[]){let o=oe(i),r=t[o];r!==void 0&&e.push({field:o,before:r,after:null})}},de=(e,t,n={})=>{let i=e,o=[],r=[],s=ce(i,n);if(s&&o.push(s),Re(o,i,n),p(n.addAc)>0||p(n.removeAc)>0){let a=Ie(i,n),c=o.filter(u=>u.field!=="acceptance_criteria");o.splice(0,o.length,...c),a.change!==void 0&&o.push(a.change),r.push(...a.warnings)}return o.push(...re(i,n)),Ae(o,i,n,t),Se(o,i,n.unset),{id:e.id,changes:o,...r.length>0?{warnings:r}:{}}},le=(e,t)=>Y(e,t,{strict:!0,flagLabel:"--filter-status"}),ue=e=>{if(e?.ids!=null&&String(e.ids).trim().length===0)throw new l("--ids requires at least one non-empty item ID",d.USAGE)},Te=[({update:e})=>{e.priority!==void 0&&q(e.priority)},({update:e,settings:t,pmRoot:n})=>{if(e.type===void 0)return;let i=U(t,P());if(!E(e.type,i))throw new l(H(e.type,i.types,K(n,t.schema)),d.USAGE)},({update:e,statusRegistry:t})=>{if(e.status!==void 0&&!V(e.status,t)){let n=t.definitions.map(i=>i.id);throw new l(`Invalid --status value "${e.status}". Allowed: ${n.join(", ")}`,d.USAGE)}},({update:e})=>{e.deadline!==void 0&&I(e.deadline,new Date,"deadline")},({update:e})=>{e.estimatedMinutes!==void 0&&$(e.estimatedMinutes,"estimated-minutes")}],pe=(e,t,n,i)=>{let o={update:e,settings:t,statusRegistry:n,pmRoot:i};for(let r of Te)r(o)},Ue=async e=>{let t=await S(e.pmRoot,g,e.rollbackId,Q),n=e.options.update?.message??`Rollback update-many checkpoint ${t.id}`,i=await T(t.items,(o,r)=>X(o,r,{author:e.options.update?.author,message:n,force:e.options.update?.force??!0},e.global));return{mode:"rollback",matched_count:t.items.length,dry_run:!1,rollback_checkpoint_id:t.id,checkpoint:{id:t.id,created_at:t.created_at,path:t.path,rollback_command:`pm update-many --rollback ${t.id}`},restored_count:i.restored_ids.length,failed_count:i.failed_count,rows:i.rows,ids:i.restored_ids}},Ee=async e=>{let t={schema_version:Q,id:e.checkpointId,created_at:e.nowValue,author:x(e.options.update?.author,"unknown"),status_filter:e.statusFilter??null,list_filters:e.filters,update_options:e.updateSummary,items:e.checkpointItems},n=await A(e.pmRoot,g,e.checkpointId,t);return{id:e.checkpointId,created_at:e.nowValue,path:n,rollback_command:`pm update-many --rollback ${e.checkpointId}`}},Me=(e,t)=>{if(e==null)return;let n=[...new Set(String(e).split(",").map(o=>o.trim()).filter(o=>o.length>0))],i=new Set(t.map(o=>o.id));return n.filter(o=>!i.has(o))},b=e=>e.unmatchedIds===void 0?{}:{unmatched_ids:e.unmatchedIds,unmatched_count:e.unmatchedIds.length},Ce=async e=>{let t=M(process.cwd(),e.path);if(!await w(C(t)))throw new l(`Tracker is not initialized at ${t}. Run pm init first.`,d.NOT_FOUND);let n=await W(t);return{pmRoot:t,settings:n,statusRegistry:O(n.schema),runtimeFieldRegistry:D(n.schema)}},Ne=e=>{if(e.options.dryRun===!0)throw new l("--dry-run cannot be combined with --rollback",d.USAGE);if(m(e.options.list,e.options.status))throw new l("Rollback mode does not accept filter options",d.USAGE);if(Object.keys(e.updateSummary).length>0)throw new l("Rollback mode does not accept update mutation flags",d.USAGE);return Ue({pmRoot:e.runtime.pmRoot,rollbackId:e.rollbackId,options:e.options,global:e.global})},Pe=async e=>{le(e.options.status,e.runtime.statusRegistry);let t=await y(void 0,{...e.options.list,status:e.options.status,compact:void 0,brief:void 0,fields:void 0,includeBody:!0,full:!0},e.global),n=t.items.map(o=>de(o,e.runtime.runtimeFieldRegistry,e.options.update)),i=e.options.list?.ids==null?[]:(await y(void 0,{ids:e.options.list.ids,noTruncate:!0,full:!0},e.global)).items;return{listed:t,planned:n,actionable:n.filter(o=>o.changes.length>0),updateSummary:e.updateSummary,unmatchedIds:Me(e.options.list?.ids,i)}},Ke=e=>({mode:"dry_run",matched_count:e.listed.items.length,dry_run:!0,filters:e.listed.filters,planned_update_options:e.updateSummary,item_plans:e.planned,ids:[],...b(e)}),Oe=e=>({mode:"apply",matched_count:e.listed.items.length,dry_run:!1,filters:e.listed.filters,planned_update_options:e.updateSummary,updated_count:0,skipped_count:e.listed.items.length,failed_count:0,rows:e.planned.map(t=>({id:t.id,status:"skipped",...t.warnings?{warnings:t.warnings}:{}})),ids:[],...b(e)}),De=async e=>{let t=[],n=[],i=e.options.update.message??`update-many apply ${e.checkpointId}`,o=new Map(e.plans.map(s=>[s.id,s])),r=new Set(e.plans.filter(s=>s.changes.length>0).map(s=>s.id));for(let s of e.items){if(!r.has(s.id)){let a=o.get(s.id)?.warnings;t.push({id:s.id,status:"skipped",...a?{warnings:a}:{}});continue}try{let a=await Z(s.id,{...e.options.update,message:i,runtimeFieldCommands:["update_many"]},e.global);t.push({id:s.id,status:"updated",changed_fields:a.changed_fields,warnings:a.warnings}),n.push(s.id)}catch(a){t.push({id:s.id,status:"failed",error:k(a)})}}return{rows:t,updatedIds:n}},Fe=async e=>{if(e.plan.actionable.length===0)return Oe(e.plan);let t=v(),n=R(g,t),i=new Set(e.plan.actionable.map(c=>c.id)),o=e.plan.listed.items.filter(c=>i.has(c.id)).map(c=>({id:c.id,target_updated_at:c.updated_at})),r=e.options.checkpoint===!1?void 0:await Ee({pmRoot:e.runtime.pmRoot,checkpointId:n,nowValue:t,options:e.options,statusFilter:e.options.status,filters:e.plan.listed.filters,updateSummary:e.plan.updateSummary,checkpointItems:o}),s=await De({items:e.plan.listed.items,plans:e.plan.planned,options:e.options,global:e.global,checkpointId:n}),a=c=>s.rows.filter(u=>u.status===c).length;return{mode:"apply",matched_count:e.plan.listed.items.length,dry_run:!1,filters:e.plan.listed.filters,planned_update_options:e.plan.updateSummary,...r?{checkpoint:r}:{},updated_count:a("updated"),skipped_count:a("skipped"),failed_count:a("failed"),rows:s.rows,ids:s.updatedIds,...b(e.plan)}},$e=async(e,t)=>{let n=await Ce(t),i=typeof e.rollback=="string"?e.rollback:void 0,o=h(e.update);if(ue(e.list),i!==void 0)return Ne({runtime:n,rollbackId:i,options:e,global:t,updateSummary:o});if(!ee(e.update))throw new l(`No update-many mutation flags provided. Add at least one mutation flag (for example: ${me}).`,d.USAGE);pe(e.update,n.settings,n.statusRegistry,n.pmRoot);let r=await Pe({options:e,global:t,runtime:n,updateSummary:o});return e.dryRun===!0?Ke(r):Fe({runtime:n,options:e,global:t,plan:r})},qe={assertPlannedUpdateValuesValid:pe,buildCollectionMutationPlans:re,buildPlannedItemDiff:de,buildTagMutationPlan:ce,collectionValueCount:se,hasAnyUpdateMutationInput:ee,hasListFilters:m,normalizeStatusFilter:le,normalizeCollectionBeforeValue:ie,normalizeExistingTags:ae,normalizeUnsetField:oe,rejectBlankIdsFilter:ue,sanitizeUpdateOptionsForSummary:h,toComparablePreviewValue:ne};export{$e as a,qe as b};
|
|
2
|
+
//# sourceMappingURL=chunk-GU3TSEHD.js.map
|