@unbrained/pm-cli 2026.8.4 → 2026.8.5
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 +39 -13
- package/dist/cli/error-guidance.js +4 -4
- 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 +407 -407
- package/dist/cli-bundle/chunks/append-VXXGOXSG.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-QVO3VTA4.js → chunk-2WFXWAYX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NM5G7RLU.js → chunk-3FTILRJ2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VH2EAGUG.js → chunk-42E7YPLG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RB65T4RX.js → chunk-43HQQI6S.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-J4EPW4GT.js → chunk-45G53IU4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PQXEB7W4.js → chunk-4VN6GS4U.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-4YUBDMQM.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-D2MBVMVE.js → chunk-54FNT7U2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NRDKVOUE.js → chunk-5ZBOIPGP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3XZYTRPC.js → chunk-6MSQJOTG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GOICHIX4.js → chunk-7A5OT5J2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HTYC76A4.js → chunk-7C4PTJG6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BKMZTZYL.js → chunk-A62CYISG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5H47J5FG.js → chunk-BPELKUQD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HE3DZFN4.js → chunk-BXQLRKWF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BLINBTMX.js → chunk-CSI3WS5I.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KH4GVBMC.js → chunk-DXDREUXT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KIKLF2W4.js → chunk-E2RKBKWB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-377OOXUF.js → chunk-EGJ4JTUG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SULWTPQO.js → chunk-FPBQHMFT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V5K52PYW.js → chunk-GE4KCSZP.js} +35 -35
- package/dist/cli-bundle/chunks/{chunk-NPUJ7OLK.js → chunk-HNFD72UK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QMWUL66F.js → chunk-HWRRMBJO.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-L3AZOELJ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-CGY5I2GO.js → chunk-LKDGK44W.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-LN2WFEU4.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZSH4GNBH.js → chunk-M72BKL5Q.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HQ2WU7OY.js → chunk-MHK6LIWE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-H6FITE7D.js → chunk-NE5VRDAI.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NY4T3JWN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-DCJ6CM6F.js → chunk-OMXVBQ2N.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-OPVH7SKD.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-CU5ENFNP.js → chunk-OTHLDSFP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NH35JNK5.js → chunk-PMXJEU3F.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SVDH5CHC.js → chunk-Q35VBGOQ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-5PZGZMPG.js → chunk-R546TPDE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q5F6OI7C.js → chunk-RKAVWO3O.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JMKVCQSE.js → chunk-SSF4PIUR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PA5XRN2A.js → chunk-UN66FZRO.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FQ4EFFDU.js → chunk-UP7DTVMD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NFF3JAQR.js → chunk-UZBWIUYD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2POYGY53.js → chunk-V3774P7D.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-B5ZLCD5Z.js → chunk-V3EUXXOF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6S7I3UKV.js → chunk-VCKLFEUN.js} +19 -19
- package/dist/cli-bundle/chunks/{chunk-PYYPQLHC.js → chunk-VN5VITU3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WRL4KNDL.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-UJHUR3LZ.js → chunk-XCEZYMNI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JDPKBV5P.js → chunk-YEWNL576.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OB7TRZ2G.js → chunk-YSO3YFZ4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UVZREFZU.js → chunk-ZYHOB3SN.js} +2 -2
- package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +2 -0
- package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +2 -0
- package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +2 -0
- package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +2 -0
- package/dist/cli-bundle/chunks/{create-RLLCBCXM.js → create-XLKTXTUF.js} +2 -2
- package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +2 -0
- package/dist/cli-bundle/chunks/{deps-J4ONTF4X.js → deps-ITTY3GIC.js} +2 -2
- package/dist/cli-bundle/chunks/{docs-YL2DJ4WD.js → docs-W4OSRTYR.js} +2 -2
- package/dist/cli-bundle/chunks/{files-NGNAIYKK.js → files-EOK4AZI4.js} +2 -2
- package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +2 -0
- package/dist/cli-bundle/chunks/{history-compact-HW62K5XP.js → history-compact-7UGTMLL3.js} +2 -2
- package/dist/cli-bundle/chunks/{history-redact-HVBKUJOW.js → history-redact-4DZRMD6Z.js} +2 -2
- package/dist/cli-bundle/chunks/{history-repair-OPNBH5JJ.js → history-repair-UPOSZW5R.js} +2 -2
- package/dist/cli-bundle/chunks/{learnings-F36PZXT6.js → learnings-GMRNCBS3.js} +2 -2
- package/dist/cli-bundle/chunks/{profile-N3XMWBM7.js → profile-2MUUMHRE.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-BKGHBI7Y.js → register-list-query-LR3SQ5ZF.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-SUOHFVWM.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-ARRRKOVN.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-KWV6UD77.js → register-setup-O6AYP6NP.js} +2 -2
- package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +2 -0
- package/dist/cli-bundle/chunks/{schema-4PJQMGUY.js → schema-FJ4EA3XF.js} +2 -2
- package/dist/cli-bundle/chunks/update-YHV52CSS.js +2 -0
- package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-7J5TUBUJ.js +153 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ONIX2KKW.js → chunk-A7BJ5SS6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-B7LJWAZE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QM2BIVK7.js → chunk-BIMTMOS7.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-BOGRY7M6.js → chunk-FGKY4MBE.js} +10 -10
- package/dist/cli-bundle/focused-chunks/chunk-G6ETT4QK.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-C2QSL62X.js → chunk-GJ2TG2CW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RO5BQFG3.js → chunk-IPWSFADF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UFCPSWIL.js → chunk-MJ7HWSFK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2VIIXOAD.js → chunk-N5XU5UVK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-PG2RIZBX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OYTK4VNH.js → chunk-PIMMYG7Q.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-K37BB4JL.js → chunk-QVHKCI4T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SQXVGHMH.js → chunk-RUR5I3TK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SV3O7TSH.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-L6A4NVQC.js → chunk-UIL2M2NA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WVGJAD7L.js → chunk-VLYOEYML.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-W7BJEWHX.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DQ4PLKEE.js → chunk-WEM2E2PE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WVIVUWVL.js +5 -0
- package/dist/cli-bundle/focused-chunks/chunk-Y4LDYLLT.js +2 -0
- package/dist/cli-bundle/main.js +4 -4
- 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/loader.js +5 -2
- 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 +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +28 -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 +20 -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/contracts.d.ts +1 -0
- package/dist/sdk/contracts.js +3 -2
- 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/generated-error-code-catalog.js +499 -3
- 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 +2 -1
- package/dist/sdk/index.js +4 -3
- 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/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 +40 -10
- package/docs/EXTENSIONS.md +1 -1
- package/docs/MERGE_SAFETY.md +2 -0
- package/docs/PR_REVIEW_LOOP.md +10 -4
- package/docs/README.md +22 -22
- package/docs/RELEASING.md +3 -3
- package/docs/SCRIPTING.md +32 -9
- package/docs/SDK.md +91 -11
- 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 +3 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +292 -14
- 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-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-RRQBHQOV.js +0 -2
- 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/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-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-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-T5TSY36R.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-VT6BF2IX.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as o}from"./chunk-45G53IU4.js";import"./chunk-A62CYISG.js";import"./chunk-BPELKUQD.js";import"./chunk-RSIC5OPE.js";import"./chunk-5ZBOIPGP.js";import"./chunk-A6KGKEWT.js";import"./chunk-42E7YPLG.js";import"./chunk-M72BKL5Q.js";import"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},d=new e.Error().stack;d&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[d]="d79c73c8-07a5-5a39-aca5-4058264684d6")}catch{}})();export{o as runAppend};
|
|
2
|
+
//# sourceMappingURL=append-VXXGOXSG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as V}from"./chunk-FQ4EFFDU.js";import{c as N,f as W,g as q,h as z}from"./chunk-UVZREFZU.js";import{$e as g,A as l,Ad as U,C as d,Da as v,Kf as M,La as H,Mf as G,Nc as L,Oa as T,R,Xe as A,_e as I,af as C,b as k,c as O,cf as P,ff as S,hf as j,lc as B,uc as $,wc as D,yf as x,zd as F}from"./chunk-V5K52PYW.js";import X from"node:fs/promises";import Y 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]="7e0f84f6-9528-55c5-8976-6f85cd920486")}catch{}})();function oe(e,t,n){let r=new Set,o=[];for(let s of e){let i=s.trim();if(i.length===0||r.has(i))continue;r.add(i);let c=t.get(i);if(c===void 0){o.push({id:i,entries:0,selected:!1,skip_reason:"no_stream"});continue}if(c.entries<=n){o.push({id:i,entries:c.entries,selected:!1,skip_reason:"already_compact"});continue}o.push({id:i,entries:c.entries,selected:!0,skip_reason:null})}return o}function re(e,t){let n=[...e].sort((o,s)=>s.entries-o.entries||o.id.localeCompare(s.id)),r=[];for(let o of n){if(t.scope==="closed"&&o.bucket!=="closed"){r.push({id:o.id,entries:o.entries,selected:!1,skip_reason:"scope_mismatch"});continue}if(o.entries<=t.minEntries){r.push({id:o.id,entries:o.entries,selected:!1,skip_reason:"already_compact"});continue}if(t.allOver!==void 0&&o.entries<=t.allOver){r.push({id:o.id,entries:o.entries,selected:!1,skip_reason:"below_threshold"});continue}r.push({id:o.id,entries:o.entries,selected:!0,skip_reason:null})}return r}function K(e,t){if(t.ids!==void 0&&t.ids.length>0){let n=new Map(e.map(r=>[r.id,r]));return oe(t.ids,n,t.minEntries)}return re(e,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]="c6609492-75a9-5111-b9b3-1b81908f3084")}catch{}})();function ne(e,t){if(e===void 0)return{kind:"default",raw:null,compactCount:t.length,retainedCount:0};let n=e.trim();if(n.length===0)throw new d("history-compact --before requires a non-empty value.",l.USAGE);if(/^\d+$/.test(n)){let s=Number.parseInt(n,10);if(!Number.isSafeInteger(s)||s<1||s>t.length+1)throw new d(`history-compact --before version must be between 1 and ${t.length+1}.`,l.USAGE);let i=Math.max(0,Math.min(t.length,s-1));return{kind:"version",raw:n,compactCount:i,retainedCount:t.length-i}}let r=Date.parse(n);if(!Number.isFinite(r))throw new d(`Invalid history-compact --before value "${e}". Use a version number or ISO timestamp.`,l.USAGE);let o=0;for(let[s,i]of t.entries()){let c=Date.parse(i.ts);if(!Number.isFinite(c))throw new d(`History for this item contains invalid timestamp at entry ${s+1}.`,l.GENERIC_FAILURE);if(c>=r)break;o+=1}return{kind:"timestamp",raw:n,compactCount:o,retainedCount:t.length-o}}function ie(e,t){let n=I(),r=I();for(let o=0;o<e.length;o+=1){let s=e[o];if(g(n)!==s.before_hash)throw new d(`history-compact detected before-hash drift at entry ${o+1}; run pm history-repair first.`,l.CONFLICT);if(n=N(n,s.patch,o+1,s.op),g(n)!==s.after_hash)throw new d(`history-compact detected after-hash drift at entry ${o+1}; run pm history-repair first.`,l.CONFLICT);o+1===t&&(r=structuredClone(n))}return{checkpoint:r,finalReplay:n}}function se(e,t,n){let r=structuredClone(t),o=[];for(let[s,i]of e.entries()){let c=g(r);r=N(r,i.patch,n+s+1,i.op),o.push({...i,before_hash:c,after_hash:g(r)})}return{entries:o,finalReplay:r}}async function ce(e,t,n){let r=e.located?await M(e.located,{schema:t.schema}):null;return r?{loadedItem:r,currentItemRawBeforeLock:r.raw,matchedChainBefore:g(P(r.document))===n[n.length-1]?.after_hash}:{loadedItem:null,currentItemRawBeforeLock:null,matchedChainBefore:null}}function ae(e,t){return typeof e.message=="string"&&e.message.trim().length>0?e.message:t.raw===null?`history-compact compacted full stream (${t.compactCount} entr${t.compactCount===1?"y":"ies"}).`:`history-compact compacted ${t.compactCount} entr${t.compactCount===1?"y":"ies"} before ${t.raw}.`}function le(e){return e.raw===null?`history-compact baseline snapshot after compacting ${e.compactCount} entr${e.compactCount===1?"y":"ies"}.`:`history-compact baseline snapshot before ${e.raw}.`}function de(e){if(!e.changed)return{rewrittenEntries:e.historyEntries,baselineEntryAdded:!1,auditEntryAdded:!1};let{checkpoint:t,finalReplay:n}=ie(e.historyEntries,e.boundary.compactCount),r=e.historyEntries.slice(e.boundary.compactCount),o=se(r,t,e.boundary.compactCount),i=[A({nowIso:R(),author:e.author,op:"history_compact_baseline",before:C(I()),after:C(t),message:le(e.boundary)}),...o.entries];return e.dryRun||i.push(A({nowIso:R(),author:e.author,op:"history_compact",before:C(n),after:C(n),message:ae(e.options,e.boundary)})),{rewrittenEntries:i,baselineEntryAdded:!0,auditEntryAdded:!e.dryRun}}async function ue(e){return q({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItemRawBeforeLock,operation:"history-compact",author:e.author,force:e.force,itemDocument:e.loadedItem?.document??null,applyRewrite:async({historyRawUnderLock:t})=>W({historyPath:e.historyPath,nextHistoryRaw:j(e.rewrittenEntries),historyRawUnderLock:t}),applyPostRewrite:async()=>$({path:e.historyPath,scope:"project",op:"history_compact:history"})})}async function fe(e,t,n){let r=H(process.cwd(),n.path);if(!await k(T(r)))throw new d(`Tracker is not initialized at ${r}. Run pm init first.`,l.NOT_FOUND);let o=await x(r),s=v(o,B()),i=await z(r,e,o,s.type_to_folder),c=i.historyPath,y=await O(c);if(y===null)throw new d(`No history stream exists for ${i.id}.`,l.NOT_FOUND);let a=await U(c,i.id);if(a.length===0)throw new d(`No history entries exist for ${i.id}; nothing to compact.`,l.USAGE);let h=S(a);if(!h.ok)throw new d(`history-compact requires a valid history chain (${h.errors.join(", ")}). Run pm history-repair ${i.id} first.`,l.CONFLICT);let u=ne(t.before,a),f=u.compactCount>0,w=!!t.dryRun,b=F(t.author,o.author_default),m=[];f||m.push("history_compact_noop_before_boundary");let _=await ce(i,o,a);_.matchedChainBefore===!1&&m.push("history_compact_item_chain_mismatch");let{rewrittenEntries:p,baselineEntryAdded:J,auditEntryAdded:Q}=de({historyEntries:a,boundary:u,changed:f,dryRun:w,author:b,options:t}),E=S(p);if(!E.ok)throw new d(`history-compact produced an invalid rewritten chain (${E.errors.join(", ")}).`,l.GENERIC_FAILURE);f&&!w&&m.push(...await ue({pmRoot:r,subject:i,settings:o,typeRegistry:s,historyRawBeforeLock:y,currentItemRawBeforeLock:_.currentItemRawBeforeLock,author:b,force:t.force,loadedItem:_.loadedItem,historyPath:c,rewrittenEntries:p}));let Z=u.retainedCount>0?u.compactCount+1:null;return{id:i.id,dry_run:w,changed:f,compact_boundary:{kind:u.kind,before:u.raw,entries_compacted:u.compactCount,entries_retained:u.retainedCount,first_retained_entry:Z},history:{path:c,entries_scanned:a.length,entries_after:p.length,baseline_entry_added:J,audit_entry_added:Q,verify_ok:E.ok,verify_errors:E.errors},item:{exists:i.located!==null,path:i.located?.itemPath??null,matched_chain_before:_.matchedChainBefore},warnings:[...new Set(m)].sort((ee,te)=>ee.localeCompare(te)),generated_at:R()}}var he=3;function Pe(e,t){let n=t.ids!==void 0&&t.ids.length>0,r=t.allOver!==void 0||t.scope!==void 0;if((e!==void 0?1:0)+(n?1:0)+(r?1:0)===0)throw new d("history-compact: provide an item <id>, or a bulk selector (--ids, --all-over <N>, --closed, or --all-streams).",l.USAGE);if(e!==void 0&&(n||r))throw new d("history-compact: <id> and bulk selectors (--ids/--all-over/--closed/--all-streams) are mutually exclusive; pass one item id, or use bulk mode without a positional id.",l.USAGE);if(n&&r)throw new d("history-compact: --ids is mutually exclusive with --all-over/--closed/--all-streams; pass an explicit id list or a scan selector, not both.",l.USAGE)}function me(e){let t=0;for(let n of e.split(/\r?\n/))n.trim().length>0&&(t+=1);return t}async function pe(e){let t=L(e.settings.schema),n=V(t),r=await G(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema),o=new Map(r.map(a=>[a.id,n.classify(a.status)])),s=Y.join(e.pmRoot,"history"),i=[],c=[];if(!await k(s))return{candidates:i,preselectionErrors:c};let y=(await X.readdir(s)).filter(a=>a.endsWith(".jsonl")).sort((a,h)=>a.localeCompare(h));for(let a of y){let h=Y.join(s,a),u=a.slice(0,-6);try{let f=await X.readFile(h,"utf8");await D({path:h,scope:"project"}),i.push({id:u,entries:me(f),bucket:o.get(u)??null})}catch(f){c.push({id:u,outcome:"errored",entries_before:0,entries_after:null,skip_reason:null,changed:!1,error:f instanceof Error?f.message:String(f)})}}return{candidates:i,preselectionErrors:c}}async function ye(e){if(!e.row.selected)return{selected:!1,compacted:!1,errored:!1,result:{id:e.row.id,outcome:"skipped",entries_before:e.row.entries,entries_after:null,skip_reason:e.row.skip_reason,changed:!1,error:null}};try{let t=await fe(e.row.id,{dryRun:e.dryRun,author:e.options.author,message:e.options.message,force:e.options.force},e.global);return{selected:!0,compacted:!0,errored:!1,result:{id:e.row.id,outcome:"compacted",entries_before:e.row.entries,entries_after:t.history.entries_after,skip_reason:null,changed:t.changed,error:null}}}catch(t){return{selected:!0,compacted:!1,errored:!0,result:{id:e.row.id,outcome:"errored",entries_before:e.row.entries,entries_after:null,skip_reason:null,changed:!1,error:t instanceof Error?t.message:String(t)}}}}async function je(e,t){let n=H(process.cwd(),t.path);if(!await k(T(n)))throw new d(`Tracker is not initialized at ${n}. Run pm init first.`,l.NOT_FOUND);let r=await x(n),o=v(r,B()),{candidates:s,preselectionErrors:i}=await pe({pmRoot:n,settings:r,typeToFolder:o.type_to_folder}),c=e.ids!==void 0&&e.ids.length>0?"ids":"scan",y=e.minEntries??he,a=r.history.compact_policy,h=c==="scan"&&e.allOver===void 0&&a.enabled,u=e.allOver??(h?a.max_entries:void 0),f=K(s,{ids:e.ids,scope:e.scope,minEntries:y,allOver:u}),w=!!e.dryRun,b=[...i],m={streams_considered:s.length+i.length,selected:0,items_compacted:0,items_skipped:0,items_errored:i.length};for(let _ of f){let p=await ye({row:_,options:e,dryRun:w,global:t});if(b.push(p.result),!p.selected){m.items_skipped+=1;continue}m.selected+=1,p.compacted&&(m.items_compacted+=1),p.errored&&(m.items_errored+=1)}return{bulk:!0,dry_run:w,mode:c,scope:e.scope??null,criteria:{min_entries:y,all_over:u??null,policy_threshold_applied:h},totals:m,results:b,generated_at:R()}}export{fe as a,he as b,Pe as c,je as d};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as V}from"./chunk-UP7DTVMD.js";import{c as N,f as W,g as q,h as z}from"./chunk-ZYHOB3SN.js";import{A as l,Ad as U,Af as x,C as d,Da as v,La as H,Mf as M,Nc as L,Oa as T,Of as G,R,Ze as A,af as I,b as k,bf as g,c as O,cf as C,ef as P,hf as S,jf as j,lc as B,uc as $,wc as D,zd as F}from"./chunk-GE4KCSZP.js";import X from"node:fs/promises";import Y 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]="7e0f84f6-9528-55c5-8976-6f85cd920486")}catch{}})();function oe(e,t,n){let r=new Set,o=[];for(let s of e){let i=s.trim();if(i.length===0||r.has(i))continue;r.add(i);let c=t.get(i);if(c===void 0){o.push({id:i,entries:0,selected:!1,skip_reason:"no_stream"});continue}if(c.entries<=n){o.push({id:i,entries:c.entries,selected:!1,skip_reason:"already_compact"});continue}o.push({id:i,entries:c.entries,selected:!0,skip_reason:null})}return o}function re(e,t){let n=[...e].sort((o,s)=>s.entries-o.entries||o.id.localeCompare(s.id)),r=[];for(let o of n){if(t.scope==="closed"&&o.bucket!=="closed"){r.push({id:o.id,entries:o.entries,selected:!1,skip_reason:"scope_mismatch"});continue}if(o.entries<=t.minEntries){r.push({id:o.id,entries:o.entries,selected:!1,skip_reason:"already_compact"});continue}if(t.allOver!==void 0&&o.entries<=t.allOver){r.push({id:o.id,entries:o.entries,selected:!1,skip_reason:"below_threshold"});continue}r.push({id:o.id,entries:o.entries,selected:!0,skip_reason:null})}return r}function K(e,t){if(t.ids!==void 0&&t.ids.length>0){let n=new Map(e.map(r=>[r.id,r]));return oe(t.ids,n,t.minEntries)}return re(e,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]="c6609492-75a9-5111-b9b3-1b81908f3084")}catch{}})();function ne(e,t){if(e===void 0)return{kind:"default",raw:null,compactCount:t.length,retainedCount:0};let n=e.trim();if(n.length===0)throw new d("history-compact --before requires a non-empty value.",l.USAGE);if(/^\d+$/.test(n)){let s=Number.parseInt(n,10);if(!Number.isSafeInteger(s)||s<1||s>t.length+1)throw new d(`history-compact --before version must be between 1 and ${t.length+1}.`,l.USAGE);let i=Math.max(0,Math.min(t.length,s-1));return{kind:"version",raw:n,compactCount:i,retainedCount:t.length-i}}let r=Date.parse(n);if(!Number.isFinite(r))throw new d(`Invalid history-compact --before value "${e}". Use a version number or ISO timestamp.`,l.USAGE);let o=0;for(let[s,i]of t.entries()){let c=Date.parse(i.ts);if(!Number.isFinite(c))throw new d(`History for this item contains invalid timestamp at entry ${s+1}.`,l.GENERIC_FAILURE);if(c>=r)break;o+=1}return{kind:"timestamp",raw:n,compactCount:o,retainedCount:t.length-o}}function ie(e,t){let n=I(),r=I();for(let o=0;o<e.length;o+=1){let s=e[o];if(g(n)!==s.before_hash)throw new d(`history-compact detected before-hash drift at entry ${o+1}; run pm history-repair first.`,l.CONFLICT);if(n=N(n,s.patch,o+1,s.op),g(n)!==s.after_hash)throw new d(`history-compact detected after-hash drift at entry ${o+1}; run pm history-repair first.`,l.CONFLICT);o+1===t&&(r=structuredClone(n))}return{checkpoint:r,finalReplay:n}}function se(e,t,n){let r=structuredClone(t),o=[];for(let[s,i]of e.entries()){let c=g(r);r=N(r,i.patch,n+s+1,i.op),o.push({...i,before_hash:c,after_hash:g(r)})}return{entries:o,finalReplay:r}}async function ce(e,t,n){let r=e.located?await M(e.located,{schema:t.schema}):null;return r?{loadedItem:r,currentItemRawBeforeLock:r.raw,matchedChainBefore:g(P(r.document))===n[n.length-1]?.after_hash}:{loadedItem:null,currentItemRawBeforeLock:null,matchedChainBefore:null}}function ae(e,t){return typeof e.message=="string"&&e.message.trim().length>0?e.message:t.raw===null?`history-compact compacted full stream (${t.compactCount} entr${t.compactCount===1?"y":"ies"}).`:`history-compact compacted ${t.compactCount} entr${t.compactCount===1?"y":"ies"} before ${t.raw}.`}function le(e){return e.raw===null?`history-compact baseline snapshot after compacting ${e.compactCount} entr${e.compactCount===1?"y":"ies"}.`:`history-compact baseline snapshot before ${e.raw}.`}function de(e){if(!e.changed)return{rewrittenEntries:e.historyEntries,baselineEntryAdded:!1,auditEntryAdded:!1};let{checkpoint:t,finalReplay:n}=ie(e.historyEntries,e.boundary.compactCount),r=e.historyEntries.slice(e.boundary.compactCount),o=se(r,t,e.boundary.compactCount),i=[A({nowIso:R(),author:e.author,op:"history_compact_baseline",before:C(I()),after:C(t),message:le(e.boundary)}),...o.entries];return e.dryRun||i.push(A({nowIso:R(),author:e.author,op:"history_compact",before:C(n),after:C(n),message:ae(e.options,e.boundary)})),{rewrittenEntries:i,baselineEntryAdded:!0,auditEntryAdded:!e.dryRun}}async function ue(e){return q({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItemRawBeforeLock,operation:"history-compact",author:e.author,force:e.force,itemDocument:e.loadedItem?.document??null,applyRewrite:async({historyRawUnderLock:t})=>W({historyPath:e.historyPath,nextHistoryRaw:j(e.rewrittenEntries),historyRawUnderLock:t}),applyPostRewrite:async()=>$({path:e.historyPath,scope:"project",op:"history_compact:history"})})}async function fe(e,t,n){let r=H(process.cwd(),n.path);if(!await k(T(r)))throw new d(`Tracker is not initialized at ${r}. Run pm init first.`,l.NOT_FOUND);let o=await x(r),s=v(o,B()),i=await z(r,e,o,s.type_to_folder),c=i.historyPath,y=await O(c);if(y===null)throw new d(`No history stream exists for ${i.id}.`,l.NOT_FOUND);let a=await U(c,i.id);if(a.length===0)throw new d(`No history entries exist for ${i.id}; nothing to compact.`,l.USAGE);let h=S(a);if(!h.ok)throw new d(`history-compact requires a valid history chain (${h.errors.join(", ")}). Run pm history-repair ${i.id} first.`,l.CONFLICT);let u=ne(t.before,a),f=u.compactCount>0,w=!!t.dryRun,b=F(t.author,o.author_default),m=[];f||m.push("history_compact_noop_before_boundary");let _=await ce(i,o,a);_.matchedChainBefore===!1&&m.push("history_compact_item_chain_mismatch");let{rewrittenEntries:p,baselineEntryAdded:J,auditEntryAdded:Q}=de({historyEntries:a,boundary:u,changed:f,dryRun:w,author:b,options:t}),E=S(p);if(!E.ok)throw new d(`history-compact produced an invalid rewritten chain (${E.errors.join(", ")}).`,l.GENERIC_FAILURE);f&&!w&&m.push(...await ue({pmRoot:r,subject:i,settings:o,typeRegistry:s,historyRawBeforeLock:y,currentItemRawBeforeLock:_.currentItemRawBeforeLock,author:b,force:t.force,loadedItem:_.loadedItem,historyPath:c,rewrittenEntries:p}));let Z=u.retainedCount>0?u.compactCount+1:null;return{id:i.id,dry_run:w,changed:f,compact_boundary:{kind:u.kind,before:u.raw,entries_compacted:u.compactCount,entries_retained:u.retainedCount,first_retained_entry:Z},history:{path:c,entries_scanned:a.length,entries_after:p.length,baseline_entry_added:J,audit_entry_added:Q,verify_ok:E.ok,verify_errors:E.errors},item:{exists:i.located!==null,path:i.located?.itemPath??null,matched_chain_before:_.matchedChainBefore},warnings:[...new Set(m)].sort((ee,te)=>ee.localeCompare(te)),generated_at:R()}}var he=3;function Pe(e,t){let n=t.ids!==void 0&&t.ids.length>0,r=t.allOver!==void 0||t.scope!==void 0;if((e!==void 0?1:0)+(n?1:0)+(r?1:0)===0)throw new d("history-compact: provide an item <id>, or a bulk selector (--ids, --all-over <N>, --closed, or --all-streams).",l.USAGE);if(e!==void 0&&(n||r))throw new d("history-compact: <id> and bulk selectors (--ids/--all-over/--closed/--all-streams) are mutually exclusive; pass one item id, or use bulk mode without a positional id.",l.USAGE);if(n&&r)throw new d("history-compact: --ids is mutually exclusive with --all-over/--closed/--all-streams; pass an explicit id list or a scan selector, not both.",l.USAGE)}function me(e){let t=0;for(let n of e.split(/\r?\n/))n.trim().length>0&&(t+=1);return t}async function pe(e){let t=L(e.settings.schema),n=V(t),r=await G(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema),o=new Map(r.map(a=>[a.id,n.classify(a.status)])),s=Y.join(e.pmRoot,"history"),i=[],c=[];if(!await k(s))return{candidates:i,preselectionErrors:c};let y=(await X.readdir(s)).filter(a=>a.endsWith(".jsonl")).sort((a,h)=>a.localeCompare(h));for(let a of y){let h=Y.join(s,a),u=a.slice(0,-6);try{let f=await X.readFile(h,"utf8");await D({path:h,scope:"project"}),i.push({id:u,entries:me(f),bucket:o.get(u)??null})}catch(f){c.push({id:u,outcome:"errored",entries_before:0,entries_after:null,skip_reason:null,changed:!1,error:f instanceof Error?f.message:String(f)})}}return{candidates:i,preselectionErrors:c}}async function ye(e){if(!e.row.selected)return{selected:!1,compacted:!1,errored:!1,result:{id:e.row.id,outcome:"skipped",entries_before:e.row.entries,entries_after:null,skip_reason:e.row.skip_reason,changed:!1,error:null}};try{let t=await fe(e.row.id,{dryRun:e.dryRun,author:e.options.author,message:e.options.message,force:e.options.force},e.global);return{selected:!0,compacted:!0,errored:!1,result:{id:e.row.id,outcome:"compacted",entries_before:e.row.entries,entries_after:t.history.entries_after,skip_reason:null,changed:t.changed,error:null}}}catch(t){return{selected:!0,compacted:!1,errored:!0,result:{id:e.row.id,outcome:"errored",entries_before:e.row.entries,entries_after:null,skip_reason:null,changed:!1,error:t instanceof Error?t.message:String(t)}}}}async function je(e,t){let n=H(process.cwd(),t.path);if(!await k(T(n)))throw new d(`Tracker is not initialized at ${n}. Run pm init first.`,l.NOT_FOUND);let r=await x(n),o=v(r,B()),{candidates:s,preselectionErrors:i}=await pe({pmRoot:n,settings:r,typeToFolder:o.type_to_folder}),c=e.ids!==void 0&&e.ids.length>0?"ids":"scan",y=e.minEntries??he,a=r.history.compact_policy,h=c==="scan"&&e.allOver===void 0&&a.enabled,u=e.allOver??(h?a.max_entries:void 0),f=K(s,{ids:e.ids,scope:e.scope,minEntries:y,allOver:u}),w=!!e.dryRun,b=[...i],m={streams_considered:s.length+i.length,selected:0,items_compacted:0,items_skipped:0,items_errored:i.length};for(let _ of f){let p=await ye({row:_,options:e,dryRun:w,global:t});if(b.push(p.result),!p.selected){m.items_skipped+=1;continue}m.selected+=1,p.compacted&&(m.items_compacted+=1),p.errored&&(m.items_errored+=1)}return{bulk:!0,dry_run:w,mode:c,scope:e.scope??null,criteria:{min_entries:y,all_over:u??null,policy_threshold_applied:h},totals:m,results:b,generated_at:R()}}export{fe as a,he as b,Pe as c,je as d};
|
|
2
|
+
//# sourceMappingURL=chunk-2WFXWAYX.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-VN5VITU3.js";import{a as X}from"./chunk-HNFD72UK.js";import{a as m}from"./chunk-FB7G2HY2.js";import{u as y}from"./chunk-RKAVWO3O.js";import{a as R,b as A,c as S,d as T,n as q,r as Y}from"./chunk-A62CYISG.js";import{a as L,b as j,c as z,d as B,e as G,k as $}from"./chunk-42E7YPLG.js";import{k as H}from"./chunk-M72BKL5Q.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-GE4KCSZP.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-3FTILRJ2.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{A as a,C as l}from"./chunk-
|
|
1
|
+
import{A as a,C as l}from"./chunk-GE4KCSZP.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="d5003dd5-f208-5734-9711-dff935d8c851")}catch{}})();var d="-",h=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function S(t){let e=t.trim();if(e==="")return[];let o=(_(e)??e.split(",")).map(i=>i.trim()).filter(Boolean).map(i=>i.toLowerCase());return Array.from(new Set(o)).sort((i,r)=>i.localeCompare(r))}function y(t){if(!Array.isArray(t)||t.length===0)return[];let e=[];for(let n of t)if(typeof n=="string")for(let o of S(n))e.push(o);return Array.from(new Set(e)).sort((n,o)=>n.localeCompare(o))}function w(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim().toLowerCase()).filter(Boolean):[]}function U(t){return typeof t!="string"?[]:t.split(";").map(e=>e.trim()).filter(Boolean)}function z(t,e,n){let o=t.map(c=>c.trim()).filter(Boolean);for(let c of e??[]){let s=c.trim();if(s.includes(";"))throw new l('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',a.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});s.length>0&&!o.includes(s)&&o.push(s)}let i=[],r=o;for(let c of n??[]){let s=c.trim();if(s.length!==0){if(!r.includes(s)){i.push(s);continue}r=r.filter(u=>u!==s)}}return{criteria:r,unmatchedRemovals:i}}function G(t,e){let n=w(t);if(!e||e.length===0)return Array.from(new Set(n)).sort((i,r)=>i.localeCompare(r));let o=new Set(n);for(let i of y(e))o.add(i);return Array.from(o).sort((i,r)=>i.localeCompare(r))}function K(t,e){let n=Array.from(new Set(w(t))).sort((i,r)=>i.localeCompare(r));if(!e||e.length===0)return n;let o=new Set(y(e));return o.size===0?n:n.filter(i=>!o.has(i))}function _(t){if(!t.startsWith("["))return null;let e;try{e=JSON.parse(t)}catch{return null}return e.map(o=>typeof o=="string"||typeof o=="number"||typeof o=="boolean"?String(o):"").filter(o=>o.length>0)}function m(t){return t.replace(/\r\n/g,`
|
|
2
2
|
`)}function g(t){let e=m(t).trim();if(!e.startsWith("```"))return t;let n=e.split(`
|
|
3
3
|
`);return n.length<2||n.at(-1)?.trim()!=="```"?t:n.slice(1,-1).join(`
|
|
4
4
|
`)}function b(t){let e=[],n="",o=!1,i=!1;for(let r of t){if(i){n+=r,i=!1;continue}if(r==="\\"){n+=r,i=!0;continue}if(r==='"'){o=!o,n+=r;continue}if(r===","&&!o){e.push(n.trim()),n="";continue}n+=r}return n.trim()&&e.push(n.trim()),e}function A(t){let e=t.trim();if(e.startsWith('"')&&e.endsWith('"')){try{let n=JSON.parse(e);if(typeof n=="string")return n}catch{}return e.slice(1,-1).replace(/\\"/g,'"')}return t}function x(t){let e=t.indexOf("="),n=t.indexOf(":"),o=e>0,i=n>0;return o&&i?Math.min(e,n):o?e:i?n:-1}function $(t,e){if((e==="--add"||e==="--add-glob")&&(/[./\\]/.test(t)||/\.[a-z]{1,6}$/i.test(t.trim())))return"For file/doc paths use: path=<file-path>[,scope=project|global]. The scope field is optional and defaults to project (example: path=src/api.ts or path=README.md,scope=project). ";if(e!=="--event")return"";let n=t.toLowerCase(),o=n.includes("recur_")||n.includes("recurrence")?' Recurrence list values must stay in one field and use "|" delimiters (for example recur_by_weekday=mon|wed or recur_by_month_day=1|15).':"",i=n.includes("recur_byweekday")?" Use recur_by_weekday (with underscores) for weekday recurrence filters.":"";return`${o}${i}`}function k(t,e){let n=t.replaceAll(/\s+/g," ").trim(),o=n.length>160?`${n.slice(0,157)}...`:n,i=$(t,e);return`Invalid ${e} value "${o}". Expected key=value entries separated by commas. `+i+`Also accepts markdown-style key/value lines (for example "- path: README.md"). Use ${e} ${d} to read piped stdin input.`}function C(t){let e=g(t).trim();if(e.length===0||!e.includes(`
|
|
5
5
|
`)&&!e.startsWith("-")&&!e.startsWith("*")&&!e.startsWith("+"))return null;let n={},o,i=m(e).split(`
|
|
6
6
|
`).map(r=>r.trim()).filter(r=>r.length>0);for(let r of i){let c=r.match(/^(?:[-*+]\s+)?([a-zA-Z0-9_.-]+)\s*(=|:)\s*(.*)$/);if(c){let s=c[1].trim();n[s]=A(c[3].trim()),o=s;continue}if(o&&h.has(o.toLowerCase())){n[o]=`${n[o]}
|
|
7
7
|
${r}`;continue}return null}return n}function D(t,e){let n=g(t).trim();if(!n)throw new l(`${e} cannot be empty`,a.USAGE);let o=C(n);if(o)return o;let i={},r,c=b(n);for(let s of c){let u=x(s);if(u>0){let f=s.slice(0,u).trim(),p=A(s.slice(u+1).trim());i[f]=p,r=f;continue}if(r&&h.has(r.toLowerCase())){i[r]=`${i[r]},${s.trim()}`;continue}throw new l(k(t,e),a.USAGE)}return i}var v=/^[A-Za-z]:[\\/]/,T=/^(?:[-*+]\s+)?[A-Za-z_][A-Za-z0-9_.-]*\s*=/;function V(t){let e=t.trim();return v.test(e)?!1:T.test(e)}function N(t,e,n){let o=new Set(n.map(r=>r.toLowerCase())),i=Object.keys(t).filter(r=>!o.has(r.toLowerCase()));if(i.length>0)throw new l(`${e} does not recognize key${i.length>1?"s":""} ${i.map(r=>`"${r}"`).join(", ")}. Allowed keys: ${n.join(", ")}.`,a.USAGE);for(let r of Object.keys(t)){let c=r.toLowerCase();if(c!==r){if(Object.hasOwn(t,c))throw new l(`${e} provides key "${r}" more than once after case normalization.`,a.USAGE);t[c]=t[r],delete t[r]}}}async function O(t){if(process.stdin.isTTY===!0)throw new l(`${t} value "${d}" requires piped stdin input. Pipe content into the command, or end manual stdin with Ctrl+D (Unix/macOS) or Ctrl+Z then Enter (Windows).`,a.USAGE);return process.stdin.setEncoding("utf8"),await new Promise((e,n)=>{let o="";process.stdin.on("data",i=>{o+=i}),process.stdin.on("end",()=>{e(m(o))}),process.stdin.on("error",i=>{n(i)})})}function P(){let t,e,n=async r=>{if(e&&e!==r)throw new l(`Only one option may use "${d}" stdin token per command invocation. Already used by ${e}.`,a.USAGE);return e=r,t||(t=O(r)),await t};return{resolveValue:async(r,c)=>{if(r!==void 0)return r.trim()!==d?r:await n(c)},resolveList:async(r,c)=>{if(!r)return;let s=r.map((p,E)=>p.trim()===d?E:-1).filter(p=>p>=0);if(s.length===0)return r;if(s.length>1)throw new l(`${c} accepts "${d}" stdin token at most once per command invocation`,a.USAGE);let u=await n(c),f=[...r];return f[s[0]]=u,f}}}function W(t,e){let n=Number(t);if(!Number.isFinite(n))throw new l(`Invalid ${e} value "${t}"`,a.USAGE);return n}function j(t,e){let n=t.trim(),o=Number(n);if(n===""||!Number.isInteger(o)||o<0)throw new l(`Invalid ${e} value "${t}". Expected a non-negative integer.`,a.USAGE);return o}export{S as a,U as b,z as c,G as d,K as e,D as f,V as g,N as h,P as i,W as j,j as k};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-42E7YPLG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as I,d as T,e as x,h as H}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as I,d as T,e as x,h as H}from"./chunk-ZYHOB3SN.js";import{A as c,Ad as y,Af as E,C as f,Da as l,La as p,Oa as u,Xe as _,Ye as w,b as h,df as b,hf as v,lc as g}from"./chunk-GE4KCSZP.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new t.Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="bccbd81b-988f-569d-8dbf-c0998d813953")}catch{}})();function G(t,r){let n=v(t),i=t.length>0?t[t.length-1].after_hash:w(),o=r===void 0?void 0:_(r),d=o===void 0?void 0:o===i,e=[...n.errors];return d===!1&&e.push("verify_failed:current_item_hash_mismatch"),{ok:e.length===0,entries:t.length,errors:e,latest_after_hash:t.length>0?t[t.length-1].after_hash:void 0,current_item_hash:o,current_matches_latest:d}}async function X(t,r,n={}){let i=p(n.cwd??process.cwd(),n.pmRoot);if(!await h(u(i)))throw new f(`Tracker is not initialized at ${i}. Run pm init first.`,c.NOT_FOUND);let o=await E(i),d=l(o,g()),e=await H(i,t,o,d.type_to_folder),s=await y(e.historyPath,e.id);if(s.length===0)throw new f(`No history exists for ${e.id}; point-in-time reads are unavailable.`,c.NOT_FOUND);let a=I(r,s),R=x(T(s,a.historyIndex),a),m=b(R,{schema:o.schema});if(m.metadata.id!==e.id)throw new f(`History target resolved to item ${m.metadata.id}, expected ${e.id}.`,c.GENERIC_FAILURE);let D=s[a.historyIndex];return{document:m,reconstructed:!0,as_of_version:a.historyIndex+1,as_of_timestamp:D.ts,target:a,history_length:s.length}}export{G as a,X as b};
|
|
2
|
+
//# sourceMappingURL=chunk-43HQQI6S.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{i as c}from"./chunk-
|
|
1
|
+
import{i as c}from"./chunk-42E7YPLG.js";import{A as o,Af as f,C as d,La as y,Oa as b,Sf as m,b as l,zd as u}from"./chunk-GE4KCSZP.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="9e3ba7e9-8822-53ba-981e-e177be5219f3")}catch{}})();async function I(t,e,i){if(e.body===void 0)throw new d("Missing required --body text",o.USAGE);let g=c(),n=y(process.cwd(),i.path);if(!await l(b(n)))throw new d(`Tracker is not initialized at ${n}. Run pm init first.`,o.NOT_FOUND);let s=await f(n),h=u(e.author,s.author_default),r=(await g.resolveValue(e.body,"--body")).trim();if(r.length===0)throw new d("--body text cannot be empty; append requires non-blank content and empty appends would only rewrite updated_at.",o.USAGE,{code:"append_empty_body",required:"Provide non-empty body text positionally, via --body, or with - for stdin.",examples:['pm append pm-a1b2 --body "Progress note"',"pm append pm-a1b2 --body -"]});let p=await m({pmRoot:n,settings:s,id:t,op:"append",author:h,message:e.message,force:e.force,mutate(a){let w=a.body.trim().length>0?`
|
|
2
2
|
|
|
3
3
|
`:"";return a.body=`${a.body.trimEnd()}${w}${r}
|
|
4
4
|
`,{changedFields:["body"]}}});return{item:p.item,appended:r,changed_fields:p.changedFields}}export{I as a};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-45G53IU4.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as B}from"./chunk-A6KGKEWT.js";import{f as m,g as j,h,i as q}from"./chunk-
|
|
1
|
+
import{a as B}from"./chunk-A6KGKEWT.js";import{f as m,g as j,h,i as q}from"./chunk-42E7YPLG.js";import{A as l,Af as W,C as u,Cb as O,Da as G,La as K,Lf as z,Ma as F,Mf as V,Oa as U,Sf as Y,b as N,ha as E,lc as M,zd as $}from"./chunk-GE4KCSZP.js";import ct from"node:fs/promises";import f from"node:path";import dt from"fast-glob";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="2b9ba0a4-396f-5870-bc89-e7fc789bb49d")}catch{}})();var it=/^[a-z][a-z0-9+.-]+:\/\//i;function _(t){return it.test(t.trim())}(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="3fe80124-596b-591c-9f0d-fbbc129c6bb4")}catch{}})();var pt=["path","scope","note"],lt=["pattern","glob","path","scope","note"],ut=["path"],ft=["from","to"],mt=new Set(["note","scope"]);function Z(t){let e=t??"project";if(!E.includes(e))throw new u(`Invalid scope "${t}". Valid scopes: ${E.join(", ")} (default: project).`,l.USAGE);return e}function H(t){return t.startsWith("```")||t.includes(`
|
|
2
2
|
`)||/^(?:[-*+]\s+)?(?:path|scope|note)\s*[:=]/i.test(t)?!0:j(t)}function ht(t){return t.flatMap(e=>{let o=e.trim();return o.length===0||H(o)||!o.includes(",")?[e]:B(o)})}function gt(t,e){return t?ht(t).map(o=>{let n=o.trim(),r=H(n)?m(o,"--add"):{path:n};if(h(r,"--add",pt),!r.path)throw new u(`--add requires path=<value> or a bare ${e} path`,l.USAGE);return{path:r.path,scope:Z(r.scope),note:r.note?.trim()||void 0}}):[]}function bt(t){return t?t.map(e=>{let o=e.trim();if(!o)throw new u("--add-glob requires a glob pattern value",l.USAGE);if(o.includes("=")||/^(?:[-*+]\s+)?(?:pattern|glob|path)\s*[:=]/i.test(o)||o.startsWith("```")){let n=m(o,"--add-glob");h(n,"--add-glob",lt);let r=n.pattern?.trim()||n.glob?.trim()||n.path?.trim();if(!r)throw new u("--add-glob key/value form requires pattern=<glob>",l.USAGE);return{pattern:r,scope:Z(n.scope),note:n.note?.trim()||void 0}}return{pattern:o,scope:"project"}}):[]}function vt(t){return t?t.map(e=>{let o=e.trim();if(!o)throw new u("--remove requires a path value",l.USAGE);if(o.includes("=")||/^(?:[-*+]\s+)?path\s*[:=]/i.test(o)||o.startsWith("```")){let n=m(o,"--remove"),r=Object.keys(n).filter(i=>mt.has(i.toLowerCase()));if(r.length>0)throw new u(`--remove identifies a linked artifact by path only and does not accept ${r.map(i=>`"${i}"`).join(", ")}. Pass just the path (path=<value>, path:<value>, or a bare path); record removal context with --message "<why removed>".`,l.USAGE);if(h(n,"--remove",ut),!n.path)throw new u("--remove key/value form requires path=<value>",l.USAGE);return n.path}return o}):[]}function At(t){return t?t.map(e=>{let o=m(e,"--migrate");h(o,"--migrate",ft);let n=o.from?.trim(),r=o.to?.trim();if(!n||!r)throw new u("--migrate requires from=<value> and to=<value>",l.USAGE);return{from:n,to:r}}):[]}function y(t,e){let o=t;for(let n of e)o.startsWith(n.from)&&(o=`${n.to}${o.slice(n.from.length)}`);return o}function x(t){return t.split(f.sep).join("/")}function k(t,e,o=process.cwd()){let n=t.trim();if(_(n))return n;if(f.isAbsolute(n)||/^[A-Za-z]:[\\/]/.test(n))return x(n.replaceAll("\\",f.sep));let r=f.relative(e,o);return r.startsWith(`..${f.sep}`)||r===".."||f.isAbsolute(r)?x(f.normalize(n)):x(f.relative(e,f.resolve(o,n)))}async function wt(t,e=process.cwd(),o=process.cwd()){let n=[];for(let r of t){let i=f.isAbsolute(r.pattern),s=await dt(r.pattern,{cwd:o,absolute:i,onlyFiles:!0,dot:!0,unique:!0,followSymbolicLinks:!0}),a=[...new Set(s.map(d=>k(d,e,o)))].sort((d,c)=>d.localeCompare(c));for(let d of a)n.push({path:d,scope:r.scope,note:r.note})}return n}function Et(t,e,o){if(e===void 0)return t;if(!o)throw new u("--note requires --add or --add-glob in the same invocation (the note annotates the links being added)",l.USAGE);let n=e.trim();return n.length===0?t:t.map(r=>r.note===void 0?{...r,note:n}:r)}function _t(t){return`${t.path}::${t.scope}`}function yt(t){return[...t].sort((e,o)=>{let n=e.path.localeCompare(o.path);return n!==0?n:e.scope.localeCompare(o.scope)})}function xt(t){return[...new Map(t.map(e=>[_t(e),e])).values()].map(e=>({...e,note:e.note?.trim()||void 0}))}async function kt(t,e=process.cwd()){let o=[...new Set(t)].sort((a,d)=>a.localeCompare(d)),n=[],r=[],i=[],s=[];for(let a of o){if(_(a)){s.push(a.trim());continue}let d=f.isAbsolute(a)?a:f.resolve(e,a);try{(await ct.stat(d)).isFile()?n.push(a):i.push(a)}catch(c){if(typeof c=="object"&&c!==null&&"code"in c&&c.code==="ENOENT"){r.push(a);continue}i.push(a)}}return{checked:o.length,existing_files:n,missing_paths:r,non_file_paths:i,remote_references:s}}function Rt(t,e,o,n){let r=0;for(let s=0;s<t.length;s+=1){let a=y(t[s].path,n);a!==t[s].path&&(t[s]={...t[s],path:a},r+=1)}return{adds:e.map(s=>{let a=y(s.path,n);return a!==s.path&&(r+=1),{...s,path:a}}),removes:o.map(s=>y(s,n)),count:r}}function St(t,e,o,n){for(let i of e)t.some(s=>s.path===i.path&&s.scope===i.scope)||t.push(i);if(o.length>0)for(let i=t.length-1;i>=0;i-=1)o.includes(t[i].path)&&t.splice(i,1);let r=xt(t);return n?r:yt(r)}async function X(t){let e=t.artifacts.map(o=>o.path);return{id:t.id,artifacts:t.artifacts,changed:t.changed,count:t.artifacts.length,migrations_applied:t.migrationsApplied&&t.migrationsApplied>0?t.migrationsApplied:void 0,validation:t.options.validatePaths?await kt(e,t.workspaceRoot):void 0}}async function Yt(t,e,o,n){let{metadataKey:r}=n,i=q(),s=K(process.cwd(),o.path),a=F(s),d=process.cwd();if(!await N(U(s)))throw new u(`Tracker is not initialized at ${s}. Run pm init first.`,l.NOT_FOUND);let c=await W(s),J=G(c,M()),Q=await i.resolveList(e.add,"--add"),tt=await i.resolveList(e.addGlob,"--add-glob"),et=await i.resolveList(e.remove,"--remove"),ot=await i.resolveList(e.migrate,"--migrate"),R=gt(Q,n.bareNoun).map(p=>({...p,path:k(p.path,a,d)})),S=bt(tt),nt=await wt(S,a,d),T=Et([...R,...nt],e.note,R.length>0||S.length>0),L=vt(et).map(p=>k(p,a,d)),I=At(ot);if(!(T.length>0||L.length>0||I.length>0)){let p=await z(s,t,c.id_prefix,c.item_format,J.type_to_folder);if(!p)throw new u(`Item ${t} not found`,l.NOT_FOUND);let v=(await V(p,{schema:c.schema})).document.metadata[r]??[];return X({id:p.id,artifacts:v,changed:!1,options:e,workspaceRoot:a})}let rt=$(e.author,c.author_default),g=await Y({pmRoot:s,settings:c,id:t,op:n.op,author:rt,message:e.message,force:e.force,skipNoop:!0,mutate(p){let b=p.metadata,v=b[r]??[],C=[...v],A=Rt(C,T,L,I),w=St(C,A.adds,A.removes,n.supportsAppendStable&&e.appendStable===!0);w.length>0?b[r]=w:delete b[r];let D=!O(v,w);return{changedFields:D?[r]:[],warnings:D&&A.count>0?[`path_migrations_applied:${A.count}`]:[]}}}),st=g.item[r]??[],P=g.warnings.find(p=>p.startsWith("path_migrations_applied:")),at=P?Number(P.slice(24)):0;return X({id:g.item.id,artifacts:st,changed:g.changedFields.includes(r),migrationsApplied:at,options:e,workspaceRoot:a})}function Bt(t,e){let o={};for(let[n,r]of Object.entries(t))o[n==="artifacts"?e:n]=r;return o}export{_ as a,Z as b,gt as c,bt as d,vt as e,At as f,y as g,x as h,wt as i,Et as j,_t as k,yt as l,xt as m,kt as n,Yt as o,Bt as p};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-4VN6GS4U.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{hb as z,ib as K,jb as S,mb as F,oa as P,ob as L,pb as B}from"./chunk-UN66FZRO.js";import{b as x}from"./chunk-VCKLFEUN.js";import{k as D,n as j}from"./chunk-LN2WFEU4.js";import{R as v,X as G}from"./chunk-YEWNL576.js";import{A as c,Ad as N,Bb as k,C as d,bb as $,sf as C,u as O,uf as U}from"./chunk-GE4KCSZP.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]="27725b9d-2a1d-54ae-8191-12ebace6ef6a")}catch{}})();import ie 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]="91be2c5d-c495-54bc-ac79-b4c645ad2c6e")}catch{}})();var T=["op","id","reason","options"],J=[...T,"ref"],W=["schema_version","mutations"],Q="[a-z][a-z0-9._-]{0,63}",Y=new RegExp(`^${Q}$`,"u"),ee=new RegExp(`(^|,)id=@(${Q})(?=,|$)`,"gu"),q=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),E=["item","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],te=new Set(["created_at","updated_at","closed_at","version","format_version","path","author"]),se=new Set([...te,"completed_at","id"]),_=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...O,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]),V={create:D.map(e=>e.target),update:j.map(e=>e.target),close:v.map(e=>q(e.flag)).filter(e=>e!=="reason"),release:G.map(e=>q(e.flag))};function ut(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new d("createCompensation must be close or delete.",c.USAGE);t.createCompensation=n}for(let r of["lockTtlSeconds","lockWaitMs"]){let o=e[r];if(o===void 0)continue;let i=typeof o=="number"||typeof o=="string"&&o.trim().length>0?Number(o):Number.NaN;if(!Number.isSafeInteger(i)||i<=0)throw new d(`${r} must be a positive safe integer.`,c.USAGE);t[r]=i}return t}function p(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function g(e,t){let n=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),r;for(let o of t){let i=$(e,o,n);i!==null&&(r===void 0||i<r.distance)&&(r={key:o,distance:i})}return r?.key}function y(e,t,n){let r=g(t,n);return new d(r===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${r}"?`,c.USAGE,{code:"stdin_json_unknown_key",required:`Use documented ${e} keys only.`,why:"Strict structured input prevents silent typos from creating incomplete or unintended mutations.",nextSteps:[r===void 0?`Remove or correct "${t}".`:`Replace "${t}" with "${r}".`]})}function R(e,t){try{return JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw new d(`${t} must be valid JSON: ${r}`,c.USAGE,{code:"stdin_json_invalid",required:`Pipe one valid JSON ${t.toLowerCase()} into stdin.`,why:"Structured mutation input must parse deterministically before any tracker write begins."})}}function ae(e,t){if(!p(e))throw new d(`Mutation ${t+1} must be an object.`,c.USAGE);for(let n of Object.keys(e))if(!T.includes(n))throw y(`mutation ${t+1}`,n,T);return e}function ce(e,t,n){if(e!==void 0){if(!p(e))throw new d(`Mutation ${n+1} options must be an object.`,c.USAGE);for(let r of Object.keys(e))if(!V[t].includes(r))throw y(`mutation ${n+1} ${t} options`,r,V[t]);return e}}function de(e,t){let n=ae(e,t),{op:r,id:o,reason:i}=n;if(r!=="create"&&r!=="update"&&r!=="close"&&r!=="release")throw new d(`Mutation ${t+1} op must be create, update, close, or release.`,c.USAGE);let s=ce(n.options,r,t);if(typeof o!="string"||o.trim().length===0)throw new d(`Mutation ${t+1} requires a non-empty id.`,c.USAGE);let a=o.trim();if(r==="close"){if(typeof i!="string"||i.trim().length===0)throw new d(`Mutation ${t+1} close requires a non-empty reason.`,c.USAGE);return{op:r,id:a,reason:i.trim(),...s===void 0?{}:{options:s}}}if(r==="release")return{op:r,id:a,...s===void 0?{}:{options:s}};if(!p(s))throw new d(`Mutation ${t+1} ${r} requires an options object.`,c.USAGE);return{op:r,id:a,options:s}}function ne(e){let t=R(e,"Mutation batch"),n=Array.isArray(t)?t:p(t)&&Array.isArray(t.mutations)?t.mutations:void 0;if(n===void 0||n.length===0)throw new d("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",c.USAGE);return n.map((r,o)=>de(r,o))}function ue(e,t,n){let r=ie.createHash("sha256").update(e).update("\0").update(t).digest("hex"),o=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${C(n)}${o}`}function H(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),r=t[n];if(r===void 0)throw new d(`Unknown mutation reference "${e}".`,c.USAGE);return r}function X(e,t){if(typeof e!="string")return e;let n=e.replace(ee,(r,o,i)=>{let s=t[i];if(s===void 0)throw new d(`Unknown mutation reference "@${i}".`,c.USAGE);return`${o}id=${s}`});if(/(^|,)id=@/u.test(n))throw new d(`Malformed mutation reference in dependency "${e}".`,c.USAGE);return n}function pe(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(ee)].map(t=>t[1]).filter(t=>t!==void 0)}function fe(e){let t=new Map;for(let i of e){if(i.op!=="create"||typeof i.ref!="string")continue;let s=p(i.options)?i.options:{},a=Array.isArray(s.dep)?s.dep:s.dep===void 0?[]:[s.dep];t.set(i.ref,[s.parent,s.blockedBy,...a].flatMap(pe))}let n=new Set,r=new Set,o=i=>{if(n.has(i))throw new d(`Mutation reference cycle includes "@${i}".`,c.USAGE);if(!r.has(i)){n.add(i);for(let s of t.get(i))t.has(s)&&o(s);n.delete(i),r.add(i)}};for(let i of t.keys())o(i)}function le(e){let t=R(e,"Mutation document"),n=Array.isArray(t)?{schema_version:1,mutations:t}:t;if(!p(n))throw new d("Mutation document must be a JSON array or object.",c.USAGE);for(let r of Object.keys(n))if(!W.includes(r))throw y("mutation document",r,W);if(n.schema_version!==void 0&&n.schema_version!==1)throw new d("Mutation document schema_version must be 1.",c.USAGE);if(!Array.isArray(n.mutations)||n.mutations.length===0)throw new d("Mutation document requires a non-empty mutations array.",c.USAGE);return n.mutations.map((r,o)=>{if(!p(r))throw new d(`Mutation ${o+1} must be an object.`,c.USAGE);for(let i of Object.keys(r))if(!J.includes(i))throw y(`mutation ${o+1}`,i,J);return{...r}})}function me(e,t){let n=Object.create(null);for(let[r,o]of e.entries())if(o.ref!==void 0){if(o.op!=="create")throw new d(`Mutation ${r+1} ref is only valid for create operations.`,c.USAGE);if(typeof o.ref!="string"||!Y.test(o.ref))throw new d(`Mutation ${r+1} ref must match ${Y.source}.`,c.USAGE);if(n[o.ref]!==void 0)throw new d(`Duplicate mutation ref "${o.ref}".`,c.USAGE);n[o.ref]=typeof o.id=="string"&&o.id.trim().length>0?U(o.id,t.idPrefix):ue(t.transactionId,o.ref,t.idPrefix)}return n}function pt(e,t){let n=le(e),r=me(n,t);fe(n);let o=n.map(a=>{let u={...a},m=typeof u.ref=="string"?u.ref:void 0;if(delete u.ref,m!==void 0?u.id=r[m]:u.id=H(u.id,r),p(u.options)){let f={...u.options};for(let w of["parent","blockedBy"])f[w]!==void 0&&(f[w]=H(f[w],r));Array.isArray(f.dep)?f.dep=f.dep.map(w=>X(w,r)):f.dep!==void 0&&(f.dep=X(f.dep,r)),u.options=f}return u}),i=ne(JSON.stringify(o)),s=i.filter(a=>a.op==="create").map(a=>a.id);if(new Set(s).size!==s.length)throw new d("Duplicate resolved create id in mutation document.",c.USAGE);return{schema_version:1,mutations:i,references:r}}function re(e,t){return t.filter(n=>e[n]!==void 0&&e[n]!==null).map(n=>{let r=String(e[n]);return`${n}=${/[",\n\r\\]/u.test(r)?JSON.stringify(r):r}`}).join(",")}function ye(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(p))throw new d(`${n} must be an array of objects.`,c.USAGE);return e.map(r=>re(r,t))}}function he(e,t){return e==="tags"&&Array.isArray(t)&&t.every(n=>typeof n=="string")?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"?String(t):t}function Z(e,t,n=!1){let r=[["dependencies","dep",["id","kind","created_at","author","source_kind"]],["comments","comment",["text","created_at","author"]],["notes","note",["text","created_at","author"]],["learnings","learning",["text","created_at","author"]],["files","file",["path","scope","note"]],["tests","test",["command","scope","timeout_seconds"]],["docs","doc",["path","scope","note"]],["reminders","reminder",["at","text","created_at"]],["events","event",["start_at","end_at","title","location"]],["type_options","typeOption",["key","value"]]];for(let[o,i,s]of r){let a=t[o],u=ye(n&&["comments","notes","learnings"].includes(o)&&Array.isArray(a)?a.filter(m=>!p(m)||m.created_at===void 0):a,s,o);u!==void 0&&u.length>0&&(e[i]=u)}}function we(e,t){for(let n of Object.keys(e)){if(t){if(!E.includes(n))throw y("item envelope",n,E);continue}if(!_.has(n)&&g(n,[..._])===void 0&&g(n,E)==="item")throw y("item envelope",n,E)}}function _e(e){let t=Object.hasOwn(e,"item");we(e,t);let n=t?e.item:e;if(!p(n))throw new d("Item document item must be an object.",c.USAGE);return{item:n,...t&&p(e.linked)?{linked:e.linked}:{}}}function Ee(e,t,n,r){if(!(r==="update"?se:te).has(t)){if(!_.has(t)){if(g(t,[..._])!==void 0)throw y("item document",t,[..._]);let s=Array.isArray(e.field)?e.field:[];s.push(re({key:t,value:typeof n=="string"?n:JSON.stringify(n)},["key","value"])),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(i,s)=>s.toUpperCase())]=he(t,n))}}function ft(e,t,n={}){let r=R(e,"Item document");if(!p(r))throw new d("Item document must be a JSON object.",c.USAGE);let{item:o,linked:i}=_e(r),s={};for(let[a,u]of Object.entries(o))Ee(s,a,u,t);return Z(s,o,t==="update"),i!==void 0&&Z(s,i),{...s,...Object.fromEntries(Object.entries(n).filter(([,a])=>a!==void 0)),stdinJson:void 0}}function lt(e){return ne(JSON.stringify(e))}import ge from"node:crypto";import Ae 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]="ed638747-7a72-5332-87fc-c82088457b91")}catch{}})();async function l(e,t){try{let r=(await P(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(n){if(n instanceof d&&n.exitCode===c.NOT_FOUND)return;throw n}}function I(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=ge.createHash("sha256").update(k(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function be(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function h(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}async function A(e,t,n,r){let o=await N(Ae.join(e,"history",`${t}.jsonl`),t),i=h(n,r,"apply"),s=h(n,r,"compensate");for(let a=o.length-1;a>=0;a-=1){let u=o[a].message;if(u===i)return!0;if(u===s)return!1}return!1}async function M(e,t){let n=await l(e,t.id);if(n?.updatedAt===void 0)throw new d(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,c.NOT_FOUND);return{target_updated_at:n.updatedAt}}async function b(e,t,n,r){let o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r.target_updated_at:void 0;typeof o=="string"&&await l(e.pmRoot,t)!==void 0&&await B(t,o,{force:!0,author:e.author,message:h(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot})}function oe(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"create"}}},async apply(){let o=(await z({...t.options,author:e.author,id:t.id},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"create"}},async compensate(){let r=await l(e.pmRoot,t.id);if(r!==void 0){if(e.createCompensation==="delete"){await L(t.id,{force:!0,author:e.author,message:`Compensate interrupted bulk transaction ${e.transactionId}`},{pmRoot:e.pmRoot});return}r.closedAt===void 0&&await S(t.id,`Compensated: interrupted bulk transaction ${e.transactionId}`,{force:!0,author:e.author},{pmRoot:e.pmRoot})}}}}function Se(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let o=(await K(t.id,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"update"}},async compensate(r){await b(e,t.id,n,r)}}}function Te(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"close"}}:r.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"close"}}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let o=(await S(t.id,t.reason,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"close"}},async compensate(r){await b(e,t.id,n,r)}}}function Re(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"release"}}:r.assignee!==void 0||r.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"release"}}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let o=(await F(t.id,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"release"}},async compensate(r){await b(e,t.id,n,r)}}}function Ie(e,t,n){let r=I(t,n);switch(t.op){case"create":return oe(e,t,r);case"update":return Se(e,t,r);case"close":return Te(e,t,r);case"release":return Re(e,t,r)}}function Me(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`)}async function Oe(e){let t=[...e.mutations];if(t.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");for(let[s,a]of t.entries())Me(a,s);let n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let r={pmRoot:e.pmRoot,author:e.author,transactionId:e.transactionId,createCompensation:n},o=await x({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,steps:t.map((s,a)=>Ie(r,s,a)),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),i={};for(let[s,a]of t.entries()){let u=I(a,s),m=o.results[u];i[be(a,s)]=m}return{transactionId:o.transactionId,status:"committed",recovered:o.recovered,results:i}}function $e(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function St(e){return Oe({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:$e(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Tt={buildCreateStep:oe,bulkHistoryMarker:h,compensateByRestore:b,deriveStepId:I,isUpdateMarkerApplied:A,readItemSnapshot:l};export{ut as a,ne as b,pt as c,ft as d,lt as e,Oe as f,$e as g,St as h,Tt as i};
|
|
2
|
+
//# sourceMappingURL=chunk-4YUBDMQM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as T}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as T}from"./chunk-5ZBOIPGP.js";import{f as F,i as I}from"./chunk-42E7YPLG.js";import{A as s,Af as N,C as o,Da as _,La as g,Lf as O,Mf as k,Oa as U,R as E,Sf as x,b as K,lc as C,zd as G}from"./chunk-GE4KCSZP.js";import{readFile as L}from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eeb7b433-094b-5c4f-bc81-d4988ac297b4")}catch{}})();function P(e,n){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new o(`Structured context events are append-only and cannot be ${n}.`,s.USAGE,{code:"structured_event_immutable"})}function V(e,n){return n===void 0?e:n===0?[]:e.slice(Math.max(0,e.length-n))}function p(e,n){let r=e[n];return Array.isArray(r)?r:[]}function se(e,n={}){let r=e.trim();if(!r)return"";let t=/^(?:[-*+]\s*)?text\s*[:=]/i.exec(r);if(n.stripPlainTextPrefix===!0&&t&&!r.startsWith("```"))return r.slice(t[0].length).trim()||r;if(!(/^(?:[-*+]\s*)?text\s*[:=]/im.test(r)||r.startsWith("```")))return r;try{let i=F(r,"--add");return Object.keys(i).map(m=>m.trim().toLowerCase()).some(m=>m!=="text")?r:i.text?.trim()||r}catch{return r}}function j(e){return typeof e=="object"&&e!==null&&"code"in e}async function H(e,n){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new o(`Specify ${n} text using only one input source: --add, --stdin, or --file`,s.USAGE);let t=I();if(e.add!==void 0)return{value:await t.resolveValue(e.add,"--add")??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return{value:await t.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let a=e.file.trim();if(!a)throw new o("--file path cannot be empty",s.USAGE);try{return{value:await L(a,"utf8"),emptyFlag:"--file"}}catch(i){if(j(i)&&i.code==="ENOENT")throw new o(`--file path not found: ${a}`,s.USAGE);let w=i instanceof Error?i.message:String(i);throw new o(`Failed to read --file path "${a}": ${w}`,s.USAGE)}}async function de(e,n){if(e.edit!==void 0&&e.delete!==void 0)throw new o("Specify only one of --edit or --delete",s.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new o("--delete cannot be combined with replacement text",s.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new o("--delete must be a positive integer",s.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new o("--edit must be a positive integer",s.USAGE);let r=await H(e,n);if(e.edit!==void 0){if(!r)throw new o("--edit requires replacement text from --add, --stdin, or --file",s.USAGE);return{mode:"edit",index:e.edit,...r}}return r?{mode:"add",...r}:{mode:"list"}}function v(e,n){throw e instanceof o&&e.exitCode===s.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new o(e.message,e.exitCode,{code:"ownership_conflict",required:n.required,examples:n.examples,nextSteps:n.nextSteps}):e}function M(e){return e==="comments"?"--stdin":"--add -"}function z(e,n){if((n.input.emptyFlag??"--add")!=="--add")return;let t=e.trim();if(!/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(t))return;let a=M(n.collectionKey),i=n.input.mode==="edit"?`pm ${n.collectionKey} <id> --edit <index>`:`pm ${n.collectionKey} <id>`;throw new o(`--add value "${t}" looks like an option, not annotation text. Use ${a} to read stdin, or use text=${t} for literal dash-leading text.`,s.USAGE,{code:"annotation_flag_like_value",required:`Use ${a} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${i} ${a}`,`${i} --add text=${t}`]})}function W(e,n){if(e.input.mode!=="list"||n.message===void 0)return;let r=e.collectionKey.replace(/s$/,"");throw new o(`--message labels a ${r} mutation but does not provide ${r} text. Pass text positionally or with --add, --stdin, or --file.`,s.USAGE,{code:"annotation_message_without_text",required:`Provide ${r} text through a content source; --message only annotates the history entry of a mutation.`,examples:[`pm ${e.collectionKey} <id> --add "text" --message "why"`,`pm ${e.collectionKey} <id> ${M(e.collectionKey)}`]})}async function le(e,n,r,t){W(t,n);let a=g(process.cwd(),r.path);if(!await K(U(a)))throw new o(`Tracker is not initialized at ${a}. Run pm init first.`,s.NOT_FOUND);let i=await N(a),w=_(i,C()),y=T(n.limit);if(t.input.mode==="list"){let d=await O(a,e,i.id_prefix,i.item_format,w.type_to_folder);if(!d)throw new o(`Item ${e} not found`,s.NOT_FOUND);let l=await k(d,{schema:i.schema}),f=p(l.document.metadata,t.collectionKey);return b(d.id,t.collectionKey,f,y,n.includeMeta===!0)}let m=G(n.author,i.author_default);if(t.input.mode==="delete"){let d=t.deleteOp??t.op,l;try{l=await x({pmRoot:a,settings:i,id:e,op:d,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(u){let c=p(u.metadata,t.collectionKey),h=R(t.input.index,c.length,t.collectionKey);return P(c[h],"deleted"),c.splice(h,1),u.metadata[t.collectionKey]=c,{changedFields:[t.collectionKey]}}})}catch(u){v(u,t.conflictGuidance)}let f=p(l.item,t.collectionKey);return b(l.item.id,t.collectionKey,f,y,n.includeMeta===!0)}let D=t.input.rawValue??t.input.value??"";z(D,t);let $=t.parseText(t.input.value??"");if(!$.trim())throw new o(`${t.input.emptyFlag??"--add"} text cannot be empty`,s.USAGE);if(t.input.mode==="edit"){let d=t.editOp??t.op,l;try{l=await x({pmRoot:a,settings:i,id:e,op:d,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(u){let c=p(u.metadata,t.collectionKey),h=R(t.input.index,c.length,t.collectionKey),S=c[h];return P(S,"edited"),c[h]={...S,text:$,edited_at:E()},u.metadata[t.collectionKey]=c,{changedFields:[t.collectionKey]}}})}catch(u){v(u,t.conflictGuidance)}let f=p(l.item,t.collectionKey);return b(l.item.id,t.collectionKey,f,y,n.includeMeta===!0)}let A;try{A=await x({pmRoot:a,settings:i,id:e,op:t.op,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(d){let l=p(d.metadata,t.collectionKey),f={created_at:E(),author:m,text:$};return l.push(t.createEntry(f)),d.metadata[t.collectionKey]=l,{changedFields:[t.collectionKey]}}})}catch(d){v(d,t.conflictGuidance)}let q=p(A.item,t.collectionKey);return b(A.item.id,t.collectionKey,q,y,n.includeMeta===!0)}function R(e,n,r){if(e===void 0||!Number.isInteger(e)||e<1||e>n){let t=r.replace(/s$/,""),a=`${t.charAt(0).toUpperCase()}${t.slice(1)}`,i=n===1?`1 ${t}`:`${n} ${r}`;throw new o(`${a} index ${e??"(missing)"} out of range (item has ${i})`,s.USAGE)}return e-1}function b(e,n,r,t,a){let i=V(r,t);return{id:e,[n]:i,count:i.length,...a?{total_count:r.length,returned_count:i.length,has_more:i.length<r.length,...t!==void 0?{limit:t}:{}}:{}}}export{V as a,p as b,se as c,j as d,de as e,v as f,le as g,R as h};
|
|
2
|
+
//# sourceMappingURL=chunk-54FNT7U2.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as i,C as t}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{A as i,C as t}from"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function f(e,n="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new t(`${n} must be a non-negative number`,i.USAGE);return Math.floor(r)}export{f as a};
|
|
2
|
+
//# sourceMappingURL=chunk-5ZBOIPGP.js.map
|