@unbrained/pm-cli 2026.11.15 → 2026.11.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/error-guidance.js +2 -2
- package/dist/cli/help-content.js +2 -2
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-TESRFVGF.js → chunk-2D26HRXB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VWKLTHYQ.js → chunk-2WNORBVN.js} +36 -25
- package/dist/cli-bundle/chunks/{chunk-J6L3Q5J4.js → chunk-4I7YG3VZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QZNDEZYI.js → chunk-4WIVCOA7.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-A3WCP4TU.js +6 -0
- package/dist/cli-bundle/chunks/chunk-AB5S6TWE.js +124 -0
- package/dist/cli-bundle/chunks/{chunk-KLWGIEDC.js → chunk-BV7J3LRH.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-GCSKHCYK.js → chunk-DZWRNL6R.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KSLPRST2.js → chunk-E4BQRZF2.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-ERD2RYWM.js +31 -0
- package/dist/cli-bundle/chunks/chunk-F7P42FL5.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-E4B2HWH7.js → chunk-FZ4XWWLO.js} +23 -23
- package/dist/cli-bundle/chunks/{chunk-7AODVNHX.js → chunk-I3T2FVUA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PMIGRSNZ.js → chunk-IGEBFNWE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YLPZE2TK.js → chunk-IYICNCK2.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-J257NZRD.js +20 -0
- package/dist/cli-bundle/chunks/{chunk-Q6GBRK27.js → chunk-JD3XWF66.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FSE624WQ.js → chunk-JLHD7OQ2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DBUBX4DL.js → chunk-KGOGLKL2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZWUS65LN.js → chunk-LC4DJVXR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LC6DL446.js → chunk-NHNM3GIP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZVDXGAYV.js → chunk-NYN5OR2T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6UTBX62V.js → chunk-OFZQEQ6X.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GAFALSR2.js → chunk-QGL5IAP4.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-HMVZSXB4.js → chunk-R24NZ2TB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-S5UXBECQ.js → chunk-VJLZHOTP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YJNY5MKP.js → chunk-VO2HSB5F.js} +2 -2
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-42Y2CSEQ.js → indexed-receipt-blobs-HNLN6UXH.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-JCEDTAVX.js → item-revision-PSOL5I4H.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-55QTCU2M.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-IQHBRFAJ.js → mutation-actor-BDBBH3ZS.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-DF6BFGG6.js → mutation-admission-WUN7JYVJ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-DNKPQB76.js → register-list-query-AESCVO6H.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-WVTDFLEF.js → register-mutation-SKCEP5QU.js} +2 -2
- package/dist/cli-bundle/chunks/register-operations-ZT4OYCF3.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-2RTG3LII.js → register-setup-JVWNS2TY.js} +2 -2
- package/dist/cli-bundle/chunks/{settlement-hook-W5ULPKIE.js → settlement-hook-MVVVUIVZ.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-YFNK7U26.js → stage-RMU3JAWM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YZUBG4W2.js → chunk-3WVMEA2A.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-CZZKAGHE.js → chunk-5UVJOAUP.js} +6 -6
- package/dist/cli-bundle/focused-chunks/{chunk-EALGFJRP.js → chunk-5WQ3LNUK.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-6E4X7MQA.js +26 -0
- package/dist/cli-bundle/focused-chunks/{chunk-JE3MFEQZ.js → chunk-7SEPCQV2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XQZKGTZV.js → chunk-7XHE335U.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-52H6AELE.js → chunk-BEHIMEV2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JXA77YIV.js → chunk-CZFZCSOX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-W2KIQ7RF.js → chunk-DFBHW7HP.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-WGYR3X6O.js → chunk-DZMP3VYQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-HHMMIHZP.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-LSWUTTE6.js → chunk-HPC2M6JD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2UQFFVQK.js → chunk-HR5FEUUL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-S6GTALM4.js → chunk-J7ESCE7M.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-KRNF3WTC.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DXMQ32EH.js → chunk-KWZLY35A.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-Z6HCQYSW.js → chunk-M4IA4LC6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YTNUUEY6.js → chunk-NASE6JC2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ONM2R32I.js +65 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QXOFSZR6.js → chunk-PDXSMSO5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BSY6FZ3Y.js → chunk-PEL4SQXV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DRBXOAGY.js → chunk-QJ647CQE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SFATIM77.js +12 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7GCAZJT4.js → chunk-UBBTBNUY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UPUIDGNJ.js → chunk-ZCN35TCK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZSQ2FT22.js +44 -0
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-LSBWMXKS.js → indexed-receipt-blobs-ADMQXF3N.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-YO7YGQYE.js → item-revision-GNKYO6GZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-7A3Q4CAJ.js → item-transaction-AUUQHR5Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-UQHBNHOF.js → mutation-actor-OBRD7HFZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-G565NLPE.js → mutation-admission-6TX3EOJX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{settlement-hook-UXN76GMA.js → settlement-hook-5U2M75BY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-F3YJGNRK.js → stage-LERF2YJU.js} +2 -2
- package/dist/cli-bundle/main.js +6 -6
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +57 -57
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/diagnostics/remediation.js +1 -1
- package/dist/core/output/mutation-projection.js +1 -1
- package/dist/core/shared/errors.d.ts +22 -0
- package/dist/core/shared/errors.js +1 -1
- package/dist/core/store/item-store.d.ts +15 -4
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/telemetry/policy.d.ts +21 -2
- package/dist/core/telemetry/policy.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/completion/bash.js +1 -1
- package/dist/sdk/completion/fish.js +2 -1
- package/dist/sdk/completion/zsh.js +12 -2
- package/dist/sdk/flag-invocation-contracts.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/health.js +2 -2
- package/dist/sdk/governance/in-progress-work-health.d.ts +49 -0
- package/dist/sdk/governance/in-progress-work-health.js +2 -0
- package/dist/sdk/governance/stale-work.d.ts +143 -2
- package/dist/sdk/governance/stale-work.js +1 -1
- package/dist/sdk/governance.d.ts +1 -1
- package/dist/sdk/governance.js +1 -1
- package/dist/sdk/history-compact.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/lifecycle/claim.d.ts +46 -3
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/task-composition.js +1 -1
- package/dist/sdk/ownership-source.d.ts +32 -0
- package/dist/sdk/ownership-source.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/context.d.ts +5 -1
- package/dist/sdk/query/context.js +2 -2
- package/dist/sdk/query/next.d.ts +19 -3
- package/dist/sdk/query/next.js +1 -1
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/docs/AGENT_GUIDE.md +2 -0
- package/docs/COMMANDS.md +22 -0
- package/docs/CONFIGURATION.md +20 -7
- package/docs/LIFECYCLE_COMMANDS.md +8 -1
- package/docs/MUTATION_INTEGRITY.md +79 -1
- package/docs/SDK.md +28 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
- package/marketplace.json +1 -1
- package/node_modules/commander/Readme.md +6 -32
- package/node_modules/commander/index.js +1 -1
- package/node_modules/commander/lib/command.js +22 -9
- package/node_modules/commander/lib/help.js +6 -2
- package/node_modules/commander/lib/option.js +1 -1
- package/node_modules/commander/package.json +2 -1
- package/node_modules/commander/typings/index.d.ts +6 -3
- package/node_modules/semver/classes/range.js +2 -2
- package/node_modules/semver/internal/constants.js +30 -0
- package/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
- package/node_modules/semver/package.json +1 -1
- package/package.json +3 -3
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-ASGAELBQ.js +0 -9
- package/dist/cli-bundle/chunks/chunk-E74OMFBZ.js +0 -6
- package/dist/cli-bundle/chunks/chunk-FYOIH56R.js +0 -20
- package/dist/cli-bundle/chunks/chunk-IXV5UM4U.js +0 -31
- package/dist/cli-bundle/chunks/chunk-NAX554KY.js +0 -124
- package/dist/cli-bundle/chunks/item-transaction-BSMGKZ4S.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-NR5MTT5T.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-63FM3TIG.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-FK2X6MJY.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-JRRHN2PZ.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-LQZ5F6LE.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-RMCODWHZ.js +0 -65
- package/dist/cli-bundle/focused-chunks/chunk-WVYXR3YX.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as E}from"./chunk-
|
|
1
|
+
import{b as E}from"./chunk-7SEPCQV2.js";import{b as I}from"./chunk-FOA7XKWP.js";import"./chunk-PDXSMSO5.js";import{execFile as O}from"node:child_process";import{realpath as v}from"node:fs/promises";import b from"node:path";import{promisify as M}from"node:util";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new n.Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="5d2c2c37-5ff2-5dab-84f1-55a7fa8d5a27")}catch{}})();var w=M(O),x="[a-f0-9]{40}(?:[a-f0-9]{24})?",N=new RegExp(`^100(?:644|755) (${x}) 0$`,"u"),R=new RegExp(`^(${x}) blob (\\d+)$`,"u");async function _(n,o,a){let t=w("git",n,{...a,encoding:"buffer"}),e=t.child.stdin;return e!==null&&(e.on("error",()=>{t.child.kill()}),e.end(`${o.join(`
|
|
2
2
|
`)}
|
|
3
3
|
`)),(await t).stdout}function B(n,o){let a=new Map;for(let t of n.split("\0")){let e=t.indexOf(" "),i=t.slice(e+1),r=N.exec(t.slice(0,e));r!==null&&o.has(i)&&a.set(i,r[1])}return a}function D(n,o,a){let t=[],e=[],i=0;for(let r of n.trimEnd().split(/\r?\n/u)){let s=R.exec(r);if(s===null||!o.has(s[1]))continue;let c=Number(s[2]);!Number.isSafeInteger(c)||c>a||(e.length>0&&i+c+128>a&&(t.push(e),e=[],i=0),e.push({id:s[1],size:c}),i+=c+128)}return e.length>0&&t.push(e),t}function S(n,o,a){let t=0;for(let{id:e,size:i}of o){let r=n.indexOf(10,t)+1;if(r===0||n.subarray(t,r-1).toString("ascii")!==`${e} blob ${i}`||n[r+i]!==10)throw new Error("Invalid indexed receipt batch framing");a.set(e,n.subarray(r,r+i).toString("utf8")),t=r+i+1}if(t!==n.length)throw new Error("Unexpected indexed receipt batch data")}async function k(n,o,a,t,e,i={}){let r=I();r.GIT_NO_REPLACE_OBJECTS="1",e===void 0&&process.env.GIT_INDEX_FILE!==void 0&&(r.GIT_INDEX_FILE=b.resolve(process.env.GIT_INDEX_FILE));let s={cwd:n,env:r,windowsHide:!0,timeout:1e4,maxBuffer:t+256};try{let c=(await w("git",["rev-parse","--show-toplevel"],{...s,encoding:"utf8"})).stdout.trim(),[g,y]=await Promise.all([v(c),v(e??o)]),d=b.relative(g,e===void 0?y:b.resolve(e)).replaceAll("\\","/");if(E(d))return new Map;s.cwd=g;let m=new Map(a.map(f=>[`${d}/${f}`,f])),T=(await w("git",["ls-files","--stage","-z","--",`:(literal)${d}/`],{...s,encoding:"utf8"})).stdout,p=B(T,new Set(m.keys()));if(p.size===0)return new Map;let u=new Set(p.values()),$=(await _(["cat-file","--batch-check"],[...u],s)).toString("utf8"),l=new Map;for(let f of D($,u,t))S(await _(["cat-file","--batch"],f.map(h=>h.id),s),f,l);if(i.failOnReadError&&l.size!==u.size)throw new Error("Unable to read every indexed receipt blob");return new Map([...p].filter(([,f])=>l.has(f)).map(([f,h])=>[m.get(f),l.get(h)]))}catch(c){if(i.failOnReadError)throw c;return new Map}}export{k as readIndexedReceiptBlobs};
|
|
4
|
-
//# sourceMappingURL=indexed-receipt-blobs-
|
|
4
|
+
//# sourceMappingURL=indexed-receipt-blobs-ADMQXF3N.js.map
|
package/dist/cli-bundle/focused-chunks/{item-revision-YO7YGQYE.js → item-revision-GNKYO6GZ.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=item-revision-
|
|
1
|
+
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-NASE6JC2.js";import"./chunk-HR5FEUUL.js";import"./chunk-6E4X7MQA.js";import"./chunk-7XHE335U.js";import"./chunk-GHQVM6K6.js";import{A as c,B as d,y as a,z as b}from"./chunk-5UVJOAUP.js";import"./chunk-5WQ3LNUK.js";import"./chunk-C3O6JJPO.js";import"./chunk-J7ESCE7M.js";import"./chunk-HPC2M6JD.js";import"./chunk-3WVMEA2A.js";import"./chunk-PDXSMSO5.js";export{f as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,e as ITEM_REVISION_CONFLICT_CODE,w as assertExpectHashAdmissible,t as bindExpectedItemRevisions,c as bindItemRevisionScope,a as createItemRevisionScope,k as describeItemRevisionChanges,y as dispatchWithExpectedItemRevisions,q as enrichItemRevisionConflict,o as expectHashInvocationRewrittenError,x as expectHashRequiresMutationError,m as isItemRevisionConflict,u as isTrackerRevisionGuarded,l as itemRevisionConflictRowFields,d as itemRevisionScopeReceipt,v as itemRevisionUncheckedWarning,g as normalizeExpectedItemHash,h as parseExpectHashSpecs,i as readItemRevision,j as resolveExpectedItemRevisions,r as runWithBoundItemRevisionScope,b as runWithItemRevisionScope,p as scopeItemRevisionConflict,n as throwFirstItemRevisionConflict,s as withExpectedItemRevisions};
|
|
2
|
+
//# sourceMappingURL=item-revision-GNKYO6GZ.js.map
|
package/dist/cli-bundle/focused-chunks/{item-transaction-7A3Q4CAJ.js → item-transaction-AUUQHR5Z.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as Ce,C as Ne,E as z,H as Ue,J as je,K as De,M as Fe,a as ke,p as J}from"./chunk-FK2X6MJY.js";import"./chunk-WGYR3X6O.js";import"./chunk-WVYXR3YX.js";import{A as Me,B as W,C as Re,y as M,z as L}from"./chunk-RMCODWHZ.js";import"./chunk-YTNUUEY6.js";import"./chunk-W2KIQ7RF.js";import"./chunk-JE3MFEQZ.js";import"./chunk-BSY6FZ3Y.js";import"./chunk-7GCAZJT4.js";import"./chunk-SVOOGGAK.js";import"./chunk-JXA77YIV.js";import{T as be,W as Ee}from"./chunk-LQZ5F6LE.js";import"./chunk-Z6HCQYSW.js";import"./chunk-DXMQ32EH.js";import{Ea as Ie}from"./chunk-JRRHN2PZ.js";import"./chunk-UPUIDGNJ.js";import"./chunk-2UQFFVQK.js";import{H as x}from"./chunk-63FM3TIG.js";import{ra as me,xa as fe}from"./chunk-52H6AELE.js";import"./chunk-DRBXOAGY.js";import"./chunk-XQZKGTZV.js";import"./chunk-GHQVM6K6.js";import{aa as $e,l as K,x as k}from"./chunk-CZZKAGHE.js";import{Sa as Oe,Wa as Ae,ab as Te,c as he,ca as b,e as P,f as ye,i as we,na as $,ra as q}from"./chunk-EALGFJRP.js";import"./chunk-I5LGPUWH.js";import"./chunk-C3O6JJPO.js";import"./chunk-S6GTALM4.js";import{e as ge}from"./chunk-LSWUTTE6.js";import{Aa as pe,Ia as le,ad as ve,bd as G,gd as _e,hd as Se,sa as F}from"./chunk-YZUBG4W2.js";import"./chunk-EGN2HFRU.js";import"./chunk-FOA7XKWP.js";import{A as p,E as D,G as ue,H as A,l as se,q as O,s as ce,x as de,z as m}from"./chunk-QXOFSZR6.js";import Z from"node:crypto";import{constants as Y}from"node:fs";import{cp as at,lstat as qe,mkdir as st,mkdtemp as Ke,open as ct,readdir as dt,realpath as Le,rm as We,stat as Q,writeFile as Je}from"node:fs/promises";import{tmpdir as ze}from"node:os";import d 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]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var et=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...se,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);(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]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function B(e,t,r){let n=e?.estimatedMinutes;if(!(n===void 0||typeof n=="string"))throw new p(`Mutation ${r+1} ${t} option "estimatedMinutes" must be a string.`,m.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(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]="37abb7b8-a5c3-5bdd-ad3a-9dc5189e834f")}catch{}})();var tt=["op","id","reason","options","unique","match"],nt=[...tt,"ref"],dn=[...nt,"item"];var Ge="[a-z][a-z0-9._-]{0,63}",un=new RegExp(`^${Ge}$`,"u"),pn=new RegExp(`(^|,)id=@(${Ge})(?=,|$)`,"gu"),Pe=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,r)=>r.toUpperCase());var rt=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count","pm_format_version","claim_principal","test_runs","deferred_fields"]),ln=new Set([...rt,"completed_at","id"]),mn={create:be.map(e=>e.target),update:Ee.map(e=>e.target),close:me.map(e=>Pe(e.flag)).filter(e=>e!=="reason"),release:fe.map(e=>Pe(e.flag))};function it(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ot(e,t){return e<t?-1:+(e!==t)}function V(e){return Array.isArray(e)?e.map(V):it(e)?Object.fromEntries(Object.entries(e).sort(([t],[r])=>ot(t,r)).map(([t,r])=>[t,V(r)])):e}function _(e){return typeof e=="string"?e.trim():JSON.stringify(V(e))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5bde03cb-def4-549f-89d5-6822bd2235e6")}catch{}})();async function ut(e,t){if(!Ae(e))return{schema:P(t.schema),typeDefinitionsFromFile:[]};let r=await bt(e,t.schema);return{schema:r.schema,typeDefinitionsFromFile:r.type_definitions_from_file??[]}}async function pt(e,t,r,n){let i=F({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...r.typeDefinitionsFromFile]}},G());return(await $e(e,t.item_format,i.type_to_folder,void 0,r.schema)).flatMap(s=>{let o=s[n];return o==null?[]:[{id:s.id,value:o}]})}function ee(e){let t=new Map,r=async n=>{let i=await Te(e),s=await ut(e,i),o=new Map;for(let a of await pt(e,i,s,n)){let c=_(a.value);o.set(c,[...o.get(c)??[],a.id])}return o};return{lookup(n){let i=t.get(n)??r(n);return t.set(n,i),i},async recordCreate(n){for(let[i,s]of t){let o=n[i];if(o==null)continue;let a=await s,c=_(o);a.set(c,[...a.get(c)??[],String(n.id)])}},invalidate(){t.clear()}}}async function lt(e,t){let r=_(t.value),n=(await e.lookup(t.key)).get(r)??[];if(n.length!==0)throw new p(`Upsert key "${t.key}" value ${JSON.stringify(r)} now matches existing item ${n.join(", ")}; the plan was resolved before it existed.`,m.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function mt(e,t,r){let n=e.metadata[r.key],i=_(r.value);if(_(n)!==i)throw new p(`Item ${t} no longer carries upsert key "${r.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,m.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function xe(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function N(e,t){let r={...e,...t};return e===void 0?r:x(e,r)}async function v(e,t){try{let r=(await J(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(r){if(r instanceof p&&r.exitCode===m.NOT_FOUND)return;throw r}}function te(e,t){let r=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),n=Z.createHash("sha256").update(le(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${r}-${n}`}function ft(e,t){let r=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${r}`}function f(e,t,r){return`bulk-item-transaction ${e} ${t} ${r}`}function ne(e,t){return e===t||(e?.startsWith(`${t} | `)??!1)}async function T(e,t,r,n){let i=await b(d.join(e,"history",`${t}.jsonl`),t),s=f(r,n,"apply"),o=f(r,n,"compensate");for(let a=i.length-1;a>=0;a-=1){let c=i[a].message;if(ne(c,s))return!0;if(c===o)return!1}return!1}async function re(e,t){let r=await v(e,t.id);if(r?.updatedAt===void 0)throw new p(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,m.NOT_FOUND);let n=await b(d.join(e,"history",`${r.id}.jsonl`),r.id);if(n.length===0)throw new p(`Bulk ${t.op} target ${t.id} has no restorable history`,m.NOT_FOUND);return{target_updated_at:r.updatedAt,target_version:String(K(n)+n.length),target_history_hash:$(n),target_history_length:n.length}}function E(e,t,r){return new p(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${r}; review item ${t} history before recovery.`,m.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function Be(e,t){let r=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(n=>typeof n=="string"&&n.startsWith(r))}function ht(e,t,r){let{expectedHistory:n,length:i,version:s}=t;if($(e)===n)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||$(e.slice(0,i))!==n||s!==String(K(e)+i))throw E(r,r.itemId,r.stepId);let o=f(r.transactionId,r.stepId,"apply"),a=e.slice(i),c=h=>ne(h.message,o)||h.context?.item_transaction_step===o,u=f(r.transactionId,r.stepId,"compensate");if(a.filter(h=>c(h)||h.message===u).at(-1)?.message===u)return!1;let l=a.filter(c);if(l.length===0)return!1;let S=e.at(-1).after_hash===l.at(-1).after_hash&&a.every(h=>Be(h,r.transactionId));if(l.length!==a.length&&!S)throw E(r,r.itemId,r.stepId);return!0}async function U(e,t,r,n){let i=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let s=i.target_updated_at,o=await v(e.pmRoot,t);if(o===void 0)return;let a=await b(d.join(e.pmRoot,"history",`${o.id}.jsonl`),o.id),c=i.target_history_hash;if(typeof c=="string"){if(!ht(a,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:o.id,stepId:r}))return}else{if(o.updatedAt===s)return;if(!await T(e.pmRoot,o.id,e.transactionId,r))throw E(e,o.id,r)}let u=()=>De(t,typeof i.target_version=="string"?i.target_version:s,{force:!0,author:e.author,message:f(e.transactionId,r,"compensate")},{pmRoot:e.pmRoot});await k({pmRoot:e.pmRoot,id:o.id,validate:l=>{if(q(l)!==a.at(-1).after_hash)throw E(e,o.id,r)}},u)}function Ve(e,t,r){return{id:r,async inspect(){let n=await v(e.pmRoot,t.id);if(n===void 0)return{state:"pending"};if(n.closedAt!==void 0){let i=await b(d.join(e.pmRoot,"history",`${n.id}.jsonl`),n.id),s=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(o=>o.op==="close").at(-1)?.patch.some(o=>o.op==="add"||o.op==="replace"?o.path==="/metadata/close_reason"&&o.value===s:!1)??!1)throw new p(`Created item ${n.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,m.CONFLICT,{code:"transaction_create_compensated",item_id:n.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${n.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:n.id,op:"create"}}},async apply(){t.unique!==void 0&&await lt(e.uniqueIndex,t.unique);let n=await Ce(N(t.options,{author:e.author,id:t.id,message:f(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot}),i=n.item;return e.onCreateWarnings?.(String(i.id),n.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await yt(e,t.id,r)}}}async function yt(e,t,r){let n=await v(e.pmRoot,t);if(n===void 0||e.createCompensation==="close"&&n.closedAt!==void 0)return;let i=await b(d.join(e.pmRoot,"history",`${n.id}.jsonl`),n.id),s=f(e.transactionId,r,"apply"),o=f(e.transactionId,r,"compensate"),a=i.filter(c=>ne(c.message,s)||c.message===o).at(-1);if(a?.message!==o){if(a===void 0||!i.every(c=>Be(c,e.transactionId)))throw E(e,n.id,r);await k({pmRoot:e.pmRoot,id:n.id,validate:c=>{if(q(c)!==i.at(-1).after_hash)throw E(e,n.id,r)}},async()=>{let c={force:!0,author:e.author,message:o};e.createCompensation==="delete"?await je(t,c,{pmRoot:e.pmRoot}):await z(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,{...c,validateClose:"off"},{pmRoot:e.pmRoot})})}}function wt(e,t,r){return{id:r,compensatePending:!0,async inspect(){let n=await v(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await T(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return re(e.pmRoot,t)},async apply(){let n=()=>Ne(t.id,N(t.options,{author:e.author,message:f(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot}),i=t.match,s=i,o=(await k({pmRoot:e.pmRoot,id:String((await J(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:a=>{s!==void 0&&mt(a,t.id,s)},committed:a=>{i!==void 0&&(s={key:i.key,value:structuredClone(a.metadata[i.key])})},historyContext:{item_transaction_step:f(e.transactionId,r,"apply")}},n)).item;return e.uniqueIndex.invalidate(),{id:String(o.id),op:"update"}},async compensate(n){await U(e,t.id,r,n)}}}function gt(e,t,r){return{id:r,async inspect(){let n=await v(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await T(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"close"}}:n.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:n.id,op:"close"}}},async prepareCompensation(){return re(e.pmRoot,t)},async apply(){let n=(await z(t.id,t.reason,N(t.options,{author:e.author,message:f(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(n.id),op:"close"}},async compensate(n){await U(e,t.id,r,n)}}}function vt(e,t,r){return{id:r,async inspect(){let n=await v(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await T(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"release"}}:n.assignee!==void 0||n.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:n.id,op:"release"}}},async prepareCompensation(){return re(e.pmRoot,t)},async apply(){let n=(await Ue(t.id,N(t.options,{author:e.author,message:f(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(n.id),op:"release"}},async compensate(n){await U(e,t.id,r,n)}}}function ie(e,t,r){let n=te(t,r);switch(t.op){case"create":return Ve(e,t,n);case"update":return wt(e,t,n);case"close":return gt(e,t,n);case"release":return vt(e,t,n)}}function _t(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`);if(e.op==="create"&&e.unique!==void 0&&!xe(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!xe(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);B(e.options,e.op,t)}function Ye(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[r,n]of e.entries()){if(_t(n,r),n.op!=="create"||n.unique===void 0)continue;let{key:i,value:s}=n.unique,o=t.get(i)??new Map,a=_(s),c=o.get(a);if(c!==void 0)throw new p(`Bulk create mutations ${c+1} and ${r+1} share the upsert key value ${JSON.stringify(a)} for "${i}".`,m.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});o.set(a,r),t.set(i,o)}}function He(e){let t=[...e];return Ye(t),t.map(r=>{let n=structuredClone(r);return r.options!==void 0&&n.options!==void 0&&x(r.options,n.options),n})}function Xe(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([r,n])=>{let i=`${t}/${r.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(r)?[i]:Xe(n,i)})}async function H(e,t,r){try{return await r()}catch(n){throw n instanceof p?new p(n.message,n.exitCode,{...n.context,transaction_operation:{index:t,op:e.op,id:e.id}}):n}}function Ze(e,t,r,n){let i=d.relative(e,t),s=i.split(d.sep);return s[0]==="extensions"&&s[2]==="node_modules"&&!n.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`))?!1:["locks","runtime","search"].includes(i.split(d.sep)[0])?n.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`)):i===""||r===void 0||r.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`))}async function I(e,t){let r=await qe(t);if(r.isSymbolicLink())await Q(t);else if(r.isDirectory()||r.isFile())return r;throw A(d.relative(e,t))}async function St(e,t){let r=await ct(t,Y.O_RDONLY|Y.O_NOFOLLOW|Y.O_NONBLOCK);try{let n=await r.stat();if(!n.isFile())throw A(d.relative(e,t));let i=Z.createHash("sha256");if(n.size>0)for await(let s of r.createReadStream({highWaterMark:64*1024,end:n.size-1,autoClose:!1}))i.update(s);return i.digest()}finally{await r.close()}}async function X(e,t,r){let n=Z.createHash("sha256");async function i(s){for(let o of(await dt(s)).sort()){let a=d.join(s,o);Ze(e,a,t,r)&&((await I(e,a)).isDirectory()?await i(a):(n.update(JSON.stringify(d.relative(e,a))),n.update(await St(e,a))))}}return await i(e),n.digest("hex")}function R(){return new p("Tracker changed while preparing the transaction preview; retry against stable state.",m.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function oe(e){if(!D(e))return!1;let t=e.path;if(typeof t!="string")return!1;let r=d.resolve(t),n=r;for(;;)try{let i=await qe(n);return n!==r&&i.isDirectory()}catch(i){if(!D(i))return!1;let s=d.dirname(n);if(s===n)return!1;n=s}}async function C(e,t){let r=d.join(e,t);try{let n=e;for(let i of t.split(d.sep).slice(0,-1))n=d.join(n,i),await I(e,n);if(!(await I(e,r)).isFile())throw A(t);return await ue(r,A(t))}catch(n){if(await oe(n))return;throw n}}async function Qe(e,t,r,n){let i=P(r);for(let[s,o]of Object.entries(i.files)){let a=d.relative(e,ye(e,o,he[s]));if(a===""||!d.resolve(e,a).startsWith(d.join(e,d.sep)))throw new p("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",m.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${s}`});i.files[s]=a;let c=await C(e,a);if(n?.set(a,c),c!==void 0){let u=d.join(t,a);await st(d.dirname(u),{recursive:!0}),await Je(u,c)}}return we(t,i)}async function bt(e,t){await Q(e);let r=await Ke(d.join(ze(),"pm-schema-plan-"));try{let n=await Le(e);return await Qe(n,d.join(r,"configuration"),t)}catch(n){throw await oe(n)?R():n}finally{await We(r,{recursive:!0,force:!0})}}async function Et(e,t,r){let n=new Map,i=await C(e,O);n.set(O,i);let s;try{s=JSON.parse(i??"null")}catch{s=null}let o=Oe(s),a=o.success?o.data:void 0,c=await Qe(e,t,a?.schema,n),u=c.schema,l=d.relative(e,ge(e));n.set(l,await C(e,l));let S=F({...de,item_types:{definitions:[...a?.item_types?.definitions??[],...c.type_definitions_from_file??[]]}},r),h=pe(e)===e?[...ce.filter(Boolean),O,ke,"transactions",...S.folders,...n.keys()].map(w=>d.normalize(w)):void 0,y=a===void 0?void 0:JSON.stringify({...s,schema:{...a.schema,files:u.files}});return{configuration:n,ownedPaths:h,stagedSettings:y,registryFolders:S.folders}}async function Ot(e,t,r){await Q(e);try{let n=await Le(e),i=await Et(n,d.join(d.dirname(t),"configuration"),r),s=[...i.configuration.keys(),...i.registryFolders].map(u=>d.normalize(u)),o=await X(n,i.ownedPaths,s);await at(n,t,{recursive:!0,dereference:!1,filter:async u=>Ze(n,u,i.ownedPaths,s)?(await I(n,u),!0):!1});let[a,c]=await Promise.all([X(n,i.ownedPaths,s),X(t,i.ownedPaths,s)]);if(o!==a||o!==c)throw R();for(let[u,l]of i.configuration)if(await C(t,u)!==l)throw R();i.stagedSettings!==void 0&&await Je(d.join(t,O),i.stagedSettings)}catch(n){throw await oe(n)?R():n}}async function Ln(e){let t=M(e),r=He(e.mutations),n=G(),i=Se(),s=await Ke(d.join(ze(),"pm-transaction-preview-")),o=d.join(s,"tracker");try{await Ot(t.pmRoot,o,n);let a=!1,c=[],u=[],l=new Set;return await _e(i,()=>Fe({path:o,noExtensions:!0},async()=>{ve(n);let S={...t,pmRoot:o,createCompensation:"close",uniqueIndex:ee(o)},h=r.map((y,w)=>{let g=ie({...S,onCreateWarnings:(j,ae)=>{ae.length>0&&c.push({index:w,id:j,op:"create",warnings:ae})}},y,w);return{...g,inspect:()=>H(y,w,()=>g.inspect()),prepareCompensation:()=>H(y,w,async()=>g.prepareCompensation?.()),apply:()=>H(y,w,async()=>{let j=await g.apply();return l.add(w),j})}});if(await L({...t,pmRoot:o,steps:h,onTransition:({transition:y})=>{y==="committed"&&(a=!0)}}),a)for(let[y,w]of r.entries()){let g=(await Ie(w.id,{path:o},{full:!0})).item;u.push({index:y,id:String(g.id),op:w.op,execution:l.has(y)?"applied":"adopted",item:g,commit_time_fields:Xe(g)})}})),{records:u,validated:a,state:a?"staged_snapshot":"replayed_committed_plan",warnings:c,unresolved_commit_constraints:["concurrent_tracker_changes","extension_write_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await We(s,{recursive:!0,force:!0})}}async function At(e){let t=M(e),r=He(e.mutations),n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:n,uniqueIndex:ee(t.pmRoot)},s=await L({...t,steps:r.map((a,c)=>ie(i,a,c)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:r,createCompensation:n})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),o={};for(let[a,c]of r.entries()){let u=te(c,a),l=s.results[u];o[ft(c,a)]=l}return{transactionId:s.transactionId,status:"committed",recovered:s.recovered,results:o}}function Tt(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 Wn(e){return At({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:Tt(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Jn={buildCreateStep:Ve,bulkHistoryMarker:f,compensateByRestore:U,deriveStepId:te,isUpdateMarkerApplied:T,readItemSnapshot:v};async function zn(e,t){let r=await Me(e,t);return r===void 0?void 0:{journal:r,planDigest:W(r)}}function $t(e,t){let r=t.recoveryData;if(r===null||typeof r!="object"||Array.isArray(r)||r.kind!=="item-mutations-v1"||!Array.isArray(r.mutations)||!["close","delete"].includes(String(r.createCompensation)))throw new p("Transaction has no supported item recovery plan",m.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let n=r.mutations;Ye(n);let i={...e,createCompensation:r.createCompensation,uniqueIndex:ee(e.pmRoot)};return n.map((s,o)=>ie(i,s,o))}async function Bn(e){let t=M(e),r=await Re({...e,...t,resolveSteps:n=>$t({...e,...t},n)});return{journal:r,planDigest:W(r)}}export{Jn as _testOnlyItemTransaction,Bn as abandonItemTransaction,Tt as buildItemCompletionMutations,Wn as commitItemCompletion,At as commitItemMutations,pt as listUpsertKeyCandidates,bt as loadGuardedRuntimeSchema,Ln as previewItemMutations,zn as readItemTransaction,ut as resolveTransactionSchema};
|
|
2
|
-
//# sourceMappingURL=item-transaction-
|
|
1
|
+
import{B as Ce,C as Ne,E as z,H as Ue,J as je,K as De,M as Fe,a as ke,p as J}from"./chunk-ZSQ2FT22.js";import"./chunk-DZMP3VYQ.js";import"./chunk-HHMMIHZP.js";import{A as Me,B as W,C as Re,y as M,z as L}from"./chunk-ONM2R32I.js";import"./chunk-NASE6JC2.js";import"./chunk-DFBHW7HP.js";import"./chunk-7SEPCQV2.js";import"./chunk-PEL4SQXV.js";import"./chunk-UBBTBNUY.js";import"./chunk-SVOOGGAK.js";import"./chunk-CZFZCSOX.js";import{T as be,W as Ee}from"./chunk-KRNF3WTC.js";import"./chunk-M4IA4LC6.js";import"./chunk-KWZLY35A.js";import{Fa as Ie}from"./chunk-SFATIM77.js";import"./chunk-ZCN35TCK.js";import"./chunk-HR5FEUUL.js";import{H as x}from"./chunk-6E4X7MQA.js";import{ra as me,xa as fe}from"./chunk-BEHIMEV2.js";import"./chunk-QJ647CQE.js";import"./chunk-7XHE335U.js";import"./chunk-GHQVM6K6.js";import{aa as $e,l as K,x as k}from"./chunk-5UVJOAUP.js";import{Ta as Oe,Xa as Ae,bb as Te,c as he,ca as b,e as P,f as ye,i as we,oa as $,sa as q}from"./chunk-5WQ3LNUK.js";import"./chunk-I5LGPUWH.js";import"./chunk-C3O6JJPO.js";import"./chunk-J7ESCE7M.js";import{e as ge}from"./chunk-HPC2M6JD.js";import{Aa as pe,Ia as le,ad as ve,bd as G,gd as _e,hd as Se,sa as F}from"./chunk-3WVMEA2A.js";import"./chunk-EGN2HFRU.js";import"./chunk-FOA7XKWP.js";import{A as p,E as D,G as ue,H as A,l as se,q as O,s as ce,x as de,z as m}from"./chunk-PDXSMSO5.js";import Z from"node:crypto";import{constants as Y}from"node:fs";import{cp as at,lstat as qe,mkdir as st,mkdtemp as Ke,open as ct,readdir as dt,realpath as Le,rm as We,stat as Q,writeFile as Je}from"node:fs/promises";import{tmpdir as ze}from"node:os";import d 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]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var et=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...se,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);(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]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function B(e,t,r){let n=e?.estimatedMinutes;if(!(n===void 0||typeof n=="string"))throw new p(`Mutation ${r+1} ${t} option "estimatedMinutes" must be a string.`,m.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(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]="37abb7b8-a5c3-5bdd-ad3a-9dc5189e834f")}catch{}})();var tt=["op","id","reason","options","unique","match"],nt=[...tt,"ref"],dn=[...nt,"item"];var Ge="[a-z][a-z0-9._-]{0,63}",un=new RegExp(`^${Ge}$`,"u"),pn=new RegExp(`(^|,)id=@(${Ge})(?=,|$)`,"gu"),Pe=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,r)=>r.toUpperCase());var rt=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count","pm_format_version","claim_principal","test_runs","deferred_fields"]),ln=new Set([...rt,"completed_at","id"]),mn={create:be.map(e=>e.target),update:Ee.map(e=>e.target),close:me.map(e=>Pe(e.flag)).filter(e=>e!=="reason"),release:fe.map(e=>Pe(e.flag))};function it(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ot(e,t){return e<t?-1:+(e!==t)}function V(e){return Array.isArray(e)?e.map(V):it(e)?Object.fromEntries(Object.entries(e).sort(([t],[r])=>ot(t,r)).map(([t,r])=>[t,V(r)])):e}function _(e){return typeof e=="string"?e.trim():JSON.stringify(V(e))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5bde03cb-def4-549f-89d5-6822bd2235e6")}catch{}})();async function ut(e,t){if(!Ae(e))return{schema:P(t.schema),typeDefinitionsFromFile:[]};let r=await bt(e,t.schema);return{schema:r.schema,typeDefinitionsFromFile:r.type_definitions_from_file??[]}}async function pt(e,t,r,n){let i=F({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...r.typeDefinitionsFromFile]}},G());return(await $e(e,t.item_format,i.type_to_folder,void 0,r.schema)).flatMap(s=>{let o=s[n];return o==null?[]:[{id:s.id,value:o}]})}function ee(e){let t=new Map,r=async n=>{let i=await Te(e),s=await ut(e,i),o=new Map;for(let a of await pt(e,i,s,n)){let c=_(a.value);o.set(c,[...o.get(c)??[],a.id])}return o};return{lookup(n){let i=t.get(n)??r(n);return t.set(n,i),i},async recordCreate(n){for(let[i,s]of t){let o=n[i];if(o==null)continue;let a=await s,c=_(o);a.set(c,[...a.get(c)??[],String(n.id)])}},invalidate(){t.clear()}}}async function lt(e,t){let r=_(t.value),n=(await e.lookup(t.key)).get(r)??[];if(n.length!==0)throw new p(`Upsert key "${t.key}" value ${JSON.stringify(r)} now matches existing item ${n.join(", ")}; the plan was resolved before it existed.`,m.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function mt(e,t,r){let n=e.metadata[r.key],i=_(r.value);if(_(n)!==i)throw new p(`Item ${t} no longer carries upsert key "${r.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,m.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function xe(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function N(e,t){let r={...e,...t};return e===void 0?r:x(e,r)}async function v(e,t){try{let r=(await J(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(r){if(r instanceof p&&r.exitCode===m.NOT_FOUND)return;throw r}}function te(e,t){let r=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),n=Z.createHash("sha256").update(le(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${r}-${n}`}function ft(e,t){let r=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${r}`}function f(e,t,r){return`bulk-item-transaction ${e} ${t} ${r}`}function ne(e,t){return e===t||(e?.startsWith(`${t} | `)??!1)}async function T(e,t,r,n){let i=await b(d.join(e,"history",`${t}.jsonl`),t),s=f(r,n,"apply"),o=f(r,n,"compensate");for(let a=i.length-1;a>=0;a-=1){let c=i[a].message;if(ne(c,s))return!0;if(c===o)return!1}return!1}async function re(e,t){let r=await v(e,t.id);if(r?.updatedAt===void 0)throw new p(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,m.NOT_FOUND);let n=await b(d.join(e,"history",`${r.id}.jsonl`),r.id);if(n.length===0)throw new p(`Bulk ${t.op} target ${t.id} has no restorable history`,m.NOT_FOUND);return{target_updated_at:r.updatedAt,target_version:String(K(n)+n.length),target_history_hash:$(n),target_history_length:n.length}}function E(e,t,r){return new p(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${r}; review item ${t} history before recovery.`,m.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function Be(e,t){let r=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(n=>typeof n=="string"&&n.startsWith(r))}function ht(e,t,r){let{expectedHistory:n,length:i,version:s}=t;if($(e)===n)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||$(e.slice(0,i))!==n||s!==String(K(e)+i))throw E(r,r.itemId,r.stepId);let o=f(r.transactionId,r.stepId,"apply"),a=e.slice(i),c=h=>ne(h.message,o)||h.context?.item_transaction_step===o,u=f(r.transactionId,r.stepId,"compensate");if(a.filter(h=>c(h)||h.message===u).at(-1)?.message===u)return!1;let l=a.filter(c);if(l.length===0)return!1;let S=e.at(-1).after_hash===l.at(-1).after_hash&&a.every(h=>Be(h,r.transactionId));if(l.length!==a.length&&!S)throw E(r,r.itemId,r.stepId);return!0}async function U(e,t,r,n){let i=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let s=i.target_updated_at,o=await v(e.pmRoot,t);if(o===void 0)return;let a=await b(d.join(e.pmRoot,"history",`${o.id}.jsonl`),o.id),c=i.target_history_hash;if(typeof c=="string"){if(!ht(a,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:o.id,stepId:r}))return}else{if(o.updatedAt===s)return;if(!await T(e.pmRoot,o.id,e.transactionId,r))throw E(e,o.id,r)}let u=()=>De(t,typeof i.target_version=="string"?i.target_version:s,{force:!0,author:e.author,message:f(e.transactionId,r,"compensate")},{pmRoot:e.pmRoot});await k({pmRoot:e.pmRoot,id:o.id,validate:l=>{if(q(l)!==a.at(-1).after_hash)throw E(e,o.id,r)}},u)}function Ve(e,t,r){return{id:r,async inspect(){let n=await v(e.pmRoot,t.id);if(n===void 0)return{state:"pending"};if(n.closedAt!==void 0){let i=await b(d.join(e.pmRoot,"history",`${n.id}.jsonl`),n.id),s=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(o=>o.op==="close").at(-1)?.patch.some(o=>o.op==="add"||o.op==="replace"?o.path==="/metadata/close_reason"&&o.value===s:!1)??!1)throw new p(`Created item ${n.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,m.CONFLICT,{code:"transaction_create_compensated",item_id:n.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${n.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:n.id,op:"create"}}},async apply(){t.unique!==void 0&&await lt(e.uniqueIndex,t.unique);let n=await Ce(N(t.options,{author:e.author,id:t.id,message:f(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot}),i=n.item;return e.onCreateWarnings?.(String(i.id),n.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await yt(e,t.id,r)}}}async function yt(e,t,r){let n=await v(e.pmRoot,t);if(n===void 0||e.createCompensation==="close"&&n.closedAt!==void 0)return;let i=await b(d.join(e.pmRoot,"history",`${n.id}.jsonl`),n.id),s=f(e.transactionId,r,"apply"),o=f(e.transactionId,r,"compensate"),a=i.filter(c=>ne(c.message,s)||c.message===o).at(-1);if(a?.message!==o){if(a===void 0||!i.every(c=>Be(c,e.transactionId)))throw E(e,n.id,r);await k({pmRoot:e.pmRoot,id:n.id,validate:c=>{if(q(c)!==i.at(-1).after_hash)throw E(e,n.id,r)}},async()=>{let c={force:!0,author:e.author,message:o};e.createCompensation==="delete"?await je(t,c,{pmRoot:e.pmRoot}):await z(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,{...c,validateClose:"off"},{pmRoot:e.pmRoot})})}}function wt(e,t,r){return{id:r,compensatePending:!0,async inspect(){let n=await v(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await T(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return re(e.pmRoot,t)},async apply(){let n=()=>Ne(t.id,N(t.options,{author:e.author,message:f(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot}),i=t.match,s=i,o=(await k({pmRoot:e.pmRoot,id:String((await J(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:a=>{s!==void 0&&mt(a,t.id,s)},committed:a=>{i!==void 0&&(s={key:i.key,value:structuredClone(a.metadata[i.key])})},historyContext:{item_transaction_step:f(e.transactionId,r,"apply")}},n)).item;return e.uniqueIndex.invalidate(),{id:String(o.id),op:"update"}},async compensate(n){await U(e,t.id,r,n)}}}function gt(e,t,r){return{id:r,async inspect(){let n=await v(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await T(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"close"}}:n.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:n.id,op:"close"}}},async prepareCompensation(){return re(e.pmRoot,t)},async apply(){let n=(await z(t.id,t.reason,N(t.options,{author:e.author,message:f(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(n.id),op:"close"}},async compensate(n){await U(e,t.id,r,n)}}}function vt(e,t,r){return{id:r,async inspect(){let n=await v(e.pmRoot,t.id);return n===void 0?{state:"pending"}:await T(e.pmRoot,n.id,e.transactionId,r)?{state:"applied",result:{id:n.id,op:"release"}}:n.assignee!==void 0||n.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:n.id,op:"release"}}},async prepareCompensation(){return re(e.pmRoot,t)},async apply(){let n=(await Ue(t.id,N(t.options,{author:e.author,message:f(e.transactionId,r,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(n.id),op:"release"}},async compensate(n){await U(e,t.id,r,n)}}}function ie(e,t,r){let n=te(t,r);switch(t.op){case"create":return Ve(e,t,n);case"update":return wt(e,t,n);case"close":return gt(e,t,n);case"release":return vt(e,t,n)}}function _t(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`);if(e.op==="create"&&e.unique!==void 0&&!xe(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!xe(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);B(e.options,e.op,t)}function Ye(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[r,n]of e.entries()){if(_t(n,r),n.op!=="create"||n.unique===void 0)continue;let{key:i,value:s}=n.unique,o=t.get(i)??new Map,a=_(s),c=o.get(a);if(c!==void 0)throw new p(`Bulk create mutations ${c+1} and ${r+1} share the upsert key value ${JSON.stringify(a)} for "${i}".`,m.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});o.set(a,r),t.set(i,o)}}function He(e){let t=[...e];return Ye(t),t.map(r=>{let n=structuredClone(r);return r.options!==void 0&&n.options!==void 0&&x(r.options,n.options),n})}function Xe(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([r,n])=>{let i=`${t}/${r.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(r)?[i]:Xe(n,i)})}async function H(e,t,r){try{return await r()}catch(n){throw n instanceof p?new p(n.message,n.exitCode,{...n.context,transaction_operation:{index:t,op:e.op,id:e.id}}):n}}function Ze(e,t,r,n){let i=d.relative(e,t),s=i.split(d.sep);return s[0]==="extensions"&&s[2]==="node_modules"&&!n.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`))?!1:["locks","runtime","search"].includes(i.split(d.sep)[0])?n.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`)):i===""||r===void 0||r.some(o=>i===o||i.startsWith(`${o}${d.sep}`)||o.startsWith(`${i}${d.sep}`))}async function I(e,t){let r=await qe(t);if(r.isSymbolicLink())await Q(t);else if(r.isDirectory()||r.isFile())return r;throw A(d.relative(e,t))}async function St(e,t){let r=await ct(t,Y.O_RDONLY|Y.O_NOFOLLOW|Y.O_NONBLOCK);try{let n=await r.stat();if(!n.isFile())throw A(d.relative(e,t));let i=Z.createHash("sha256");if(n.size>0)for await(let s of r.createReadStream({highWaterMark:64*1024,end:n.size-1,autoClose:!1}))i.update(s);return i.digest()}finally{await r.close()}}async function X(e,t,r){let n=Z.createHash("sha256");async function i(s){for(let o of(await dt(s)).sort()){let a=d.join(s,o);Ze(e,a,t,r)&&((await I(e,a)).isDirectory()?await i(a):(n.update(JSON.stringify(d.relative(e,a))),n.update(await St(e,a))))}}return await i(e),n.digest("hex")}function R(){return new p("Tracker changed while preparing the transaction preview; retry against stable state.",m.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function oe(e){if(!D(e))return!1;let t=e.path;if(typeof t!="string")return!1;let r=d.resolve(t),n=r;for(;;)try{let i=await qe(n);return n!==r&&i.isDirectory()}catch(i){if(!D(i))return!1;let s=d.dirname(n);if(s===n)return!1;n=s}}async function C(e,t){let r=d.join(e,t);try{let n=e;for(let i of t.split(d.sep).slice(0,-1))n=d.join(n,i),await I(e,n);if(!(await I(e,r)).isFile())throw A(t);return await ue(r,A(t))}catch(n){if(await oe(n))return;throw n}}async function Qe(e,t,r,n){let i=P(r);for(let[s,o]of Object.entries(i.files)){let a=d.relative(e,ye(e,o,he[s]));if(a===""||!d.resolve(e,a).startsWith(d.join(e,d.sep)))throw new p("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",m.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${s}`});i.files[s]=a;let c=await C(e,a);if(n?.set(a,c),c!==void 0){let u=d.join(t,a);await st(d.dirname(u),{recursive:!0}),await Je(u,c)}}return we(t,i)}async function bt(e,t){await Q(e);let r=await Ke(d.join(ze(),"pm-schema-plan-"));try{let n=await Le(e);return await Qe(n,d.join(r,"configuration"),t)}catch(n){throw await oe(n)?R():n}finally{await We(r,{recursive:!0,force:!0})}}async function Et(e,t,r){let n=new Map,i=await C(e,O);n.set(O,i);let s;try{s=JSON.parse(i??"null")}catch{s=null}let o=Oe(s),a=o.success?o.data:void 0,c=await Qe(e,t,a?.schema,n),u=c.schema,l=d.relative(e,ge(e));n.set(l,await C(e,l));let S=F({...de,item_types:{definitions:[...a?.item_types?.definitions??[],...c.type_definitions_from_file??[]]}},r),h=pe(e)===e?[...ce.filter(Boolean),O,ke,"transactions",...S.folders,...n.keys()].map(w=>d.normalize(w)):void 0,y=a===void 0?void 0:JSON.stringify({...s,schema:{...a.schema,files:u.files}});return{configuration:n,ownedPaths:h,stagedSettings:y,registryFolders:S.folders}}async function Ot(e,t,r){await Q(e);try{let n=await Le(e),i=await Et(n,d.join(d.dirname(t),"configuration"),r),s=[...i.configuration.keys(),...i.registryFolders].map(u=>d.normalize(u)),o=await X(n,i.ownedPaths,s);await at(n,t,{recursive:!0,dereference:!1,filter:async u=>Ze(n,u,i.ownedPaths,s)?(await I(n,u),!0):!1});let[a,c]=await Promise.all([X(n,i.ownedPaths,s),X(t,i.ownedPaths,s)]);if(o!==a||o!==c)throw R();for(let[u,l]of i.configuration)if(await C(t,u)!==l)throw R();i.stagedSettings!==void 0&&await Je(d.join(t,O),i.stagedSettings)}catch(n){throw await oe(n)?R():n}}async function Ln(e){let t=M(e),r=He(e.mutations),n=G(),i=Se(),s=await Ke(d.join(ze(),"pm-transaction-preview-")),o=d.join(s,"tracker");try{await Ot(t.pmRoot,o,n);let a=!1,c=[],u=[],l=new Set;return await _e(i,()=>Fe({path:o,noExtensions:!0},async()=>{ve(n);let S={...t,pmRoot:o,createCompensation:"close",uniqueIndex:ee(o)},h=r.map((y,w)=>{let g=ie({...S,onCreateWarnings:(j,ae)=>{ae.length>0&&c.push({index:w,id:j,op:"create",warnings:ae})}},y,w);return{...g,inspect:()=>H(y,w,()=>g.inspect()),prepareCompensation:()=>H(y,w,async()=>g.prepareCompensation?.()),apply:()=>H(y,w,async()=>{let j=await g.apply();return l.add(w),j})}});if(await L({...t,pmRoot:o,steps:h,onTransition:({transition:y})=>{y==="committed"&&(a=!0)}}),a)for(let[y,w]of r.entries()){let g=(await Ie(w.id,{path:o},{full:!0})).item;u.push({index:y,id:String(g.id),op:w.op,execution:l.has(y)?"applied":"adopted",item:g,commit_time_fields:Xe(g)})}})),{records:u,validated:a,state:a?"staged_snapshot":"replayed_committed_plan",warnings:c,unresolved_commit_constraints:["concurrent_tracker_changes","extension_write_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await We(s,{recursive:!0,force:!0})}}async function At(e){let t=M(e),r=He(e.mutations),n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:n,uniqueIndex:ee(t.pmRoot)},s=await L({...t,steps:r.map((a,c)=>ie(i,a,c)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:r,createCompensation:n})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),o={};for(let[a,c]of r.entries()){let u=te(c,a),l=s.results[u];o[ft(c,a)]=l}return{transactionId:s.transactionId,status:"committed",recovered:s.recovered,results:o}}function Tt(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 Wn(e){return At({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:Tt(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Jn={buildCreateStep:Ve,bulkHistoryMarker:f,compensateByRestore:U,deriveStepId:te,isUpdateMarkerApplied:T,readItemSnapshot:v};async function zn(e,t){let r=await Me(e,t);return r===void 0?void 0:{journal:r,planDigest:W(r)}}function $t(e,t){let r=t.recoveryData;if(r===null||typeof r!="object"||Array.isArray(r)||r.kind!=="item-mutations-v1"||!Array.isArray(r.mutations)||!["close","delete"].includes(String(r.createCompensation)))throw new p("Transaction has no supported item recovery plan",m.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let n=r.mutations;Ye(n);let i={...e,createCompensation:r.createCompensation,uniqueIndex:ee(e.pmRoot)};return n.map((s,o)=>ie(i,s,o))}async function Bn(e){let t=M(e),r=await Re({...e,...t,resolveSteps:n=>$t({...e,...t},n)});return{journal:r,planDigest:W(r)}}export{Jn as _testOnlyItemTransaction,Bn as abandonItemTransaction,Tt as buildItemCompletionMutations,Wn as commitItemCompletion,At as commitItemMutations,pt as listUpsertKeyCandidates,bt as loadGuardedRuntimeSchema,Ln as previewItemMutations,zn as readItemTransaction,ut as resolveTransactionSchema};
|
|
2
|
+
//# sourceMappingURL=item-transaction-AUUQHR5Z.js.map
|
package/dist/cli-bundle/focused-chunks/{mutation-actor-UQHBNHOF.js → mutation-actor-OBRD7HFZ.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as t,D as s,E as r}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=mutation-actor-
|
|
1
|
+
import{C as t,D as s,E as r}from"./chunk-HPC2M6JD.js";import"./chunk-3WVMEA2A.js";import"./chunk-PDXSMSO5.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new o.Error().stack;e&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[e]="44d57a71-ac49-5db8-b461-ce985801bb3c")}catch{}})();function d(o){let e=s(o),n={...e.harness===void 0?{}:{harness:e.harness},...e.model===void 0?{}:{model:e.model},...e.model_source===void 0?{}:{model_source:e.model_source},...e.instance===void 0?{}:{instance:e.instance}};return Object.freeze({author:o,author_source:t(o),principal:r(o),...Object.keys(n).length===0?{}:{agent:Object.freeze(n)}})}export{d as resolveMutationActor};
|
|
2
|
+
//# sourceMappingURL=mutation-actor-OBRD7HFZ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as E,y as N}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=mutation-admission-
|
|
1
|
+
import{t as E,y as N}from"./chunk-PEL4SQXV.js";import"./chunk-CZFZCSOX.js";import{T as y,W as C}from"./chunk-KRNF3WTC.js";import"./chunk-6E4X7MQA.js";import{Oa as h,Ua as w}from"./chunk-BEHIMEV2.js";import"./chunk-5UVJOAUP.js";import{bb as A,l as T,m as O,z as R}from"./chunk-5WQ3LNUK.js";import"./chunk-I5LGPUWH.js";import"./chunk-C3O6JJPO.js";import"./chunk-J7ESCE7M.js";import"./chunk-HPC2M6JD.js";import{a as g,za as _}from"./chunk-3WVMEA2A.js";import{A as f}from"./chunk-PDXSMSO5.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new t.Error().stack;o&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[o]="d19ff816-7570-5e8a-a4de-ad2ca48f0df0")}catch{}})();function b(t,o,r,a=!1){let d=[...r].map(n=>({candidate:n,distance:g(o,n,3)})).filter(n=>n.distance!==null).sort((n,i)=>n.distance-i.distance||n.candidate.localeCompare(i.candidate))[0]?.candidate,s=a?`Put mutation fields under options (options.${o}).`:d?`Did you mean "${d}"?`:"Use the declared command options or the field option for registered item fields.";throw new f(`Unknown ${t} ${a?"argument":"option"} "${o}". ${s} No changes were made.`,2,{code:"invalid_argument_value",reason:"unknown_mutation_option",changed:!1,field:o,required:s,nextSteps:[s]})}async function j(t,o,r,a,d){if(E(o))return;let s=t==="create"?y:C,n=(t==="create"?h:w).map(({flag:e})=>e.slice(2).replace(/-([a-z])/gu,(m,v)=>v.toUpperCase())),i=new Set([...s.flatMap(e=>[e.target,...e.keys]),...n]),l=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];for(let e of["author","message","force","fullChangedFields","idOnly",...l])i.add(e);let S=new Set(["action","options","path","cwd","author","force","noExtensions","no_extensions","fullChangedFields","idOnly",...l,...d,...t==="update"?["id"]:[]]);for(let e of Object.keys(o))S.has(e)||b(t,e,i,i.has(e));let u=o.options;if(u!==void 0&&!N(u))throw new f("Mutation options must be an object. No changes were made.",2,{code:"invalid_argument_value",changed:!1});let c=[...new Set([...Object.keys(u??{}),...Object.keys(r)])].filter(e=>!i.has(e));if(c.length===0)return;let p=T((await A(_(process.cwd(),a))).schema).command_to_fields.get(t)??[];for(let e of p)i.add(O(e));for(let e of c)p.some(m=>R({[e]:!0},m)===!0)||b(t,e,i)}export{j as assertNativeMutationOptions};
|
|
2
|
+
//# sourceMappingURL=mutation-admission-6TX3EOJX.js.map
|
package/dist/cli-bundle/focused-chunks/{settlement-hook-UXN76GMA.js → settlement-hook-5U2M75BY.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{b as d}from"./chunk-EGN2HFRU.js";import{b as l}from"./chunk-FOA7XKWP.js";import{A as m,E as c,I as p,z as s}from"./chunk-
|
|
1
|
+
import{b as d}from"./chunk-EGN2HFRU.js";import{b as l}from"./chunk-FOA7XKWP.js";import{A as m,E as c,I as p,z as s}from"./chunk-PDXSMSO5.js";import{execFile as f}from"node:child_process";import{chmod as h,lstat as u}from"node:fs/promises";import{promisify as w}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5b6eab08-f707-586f-bb05-484bd9160551")}catch{}})();var y=w(f),g=`#!/bin/sh
|
|
2
2
|
# pm-cli:lossless-merge-settlement:v1
|
|
3
3
|
`;async function I(e,t){let r=(await y("git",["rev-parse","--path-format=absolute","--git-path","hooks/pre-commit"],{cwd:e,env:l(),timeout:1e4})).stdout.trim(),o,i=!1;try{o=await d(r,65536)??"",i=process.platform==="win32"||((await u(r)).mode&73)!==0}catch(a){if(!c(a))throw a}if(o!==void 0&&!o.startsWith(g))throw new m("The pre-commit hook already exists and is not owned by pm; it was preserved.",s.CONFLICT,{code:"merge_settlement_hook_conflict",recovery:{suggested_retry:"pm merge install --dry-run"},nextSteps:["Integrate pm merge reconcile --stage into your existing hook after reviewing its policy, or keep manual settlement. pm never replaces an existing unowned hook."]});let n=`${g}merge_head=$(git rev-parse --git-path MERGE_HEAD) || exit 1
|
|
4
4
|
[ -f "$merge_head" ] || exit 0
|
|
5
5
|
exec ${t} merge reconcile --stage
|
|
6
6
|
`;return{path:r,changed:o!==n||!i,content:n}}async function H(e){e.changed&&(await p(e.path,e.content),await h(e.path,493))}export{I as prepareMergeSettlementHook,H as writeMergeSettlementHook};
|
|
7
|
-
//# sourceMappingURL=settlement-hook-
|
|
7
|
+
//# sourceMappingURL=settlement-hook-5U2M75BY.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as w,j as y}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=stage-
|
|
1
|
+
import{c as w,j as y}from"./chunk-DFBHW7HP.js";import{b as g}from"./chunk-7SEPCQV2.js";import"./chunk-GHQVM6K6.js";import"./chunk-5WQ3LNUK.js";import"./chunk-J7ESCE7M.js";import"./chunk-HPC2M6JD.js";import{za as h}from"./chunk-3WVMEA2A.js";import{b as u}from"./chunk-FOA7XKWP.js";import{A as f,z as d}from"./chunk-PDXSMSO5.js";import{execFile as _}from"node:child_process";import{realpath as b}from"node:fs/promises";import l from"node:path";import{promisify as x}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7f4b2fc8-c9c6-51ff-a345-b76b8abdacf4")}catch{}})();var R=x(_);function c(e){return new f(`Automatic merge settlement refused: ${e}`,d.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"},nextSteps:["Inspect receipts, repair streams and Git changes. Resolve competing values or unrelated drift explicitly, then run pm merge reconcile and stage the reviewed artifacts manually."]})}async function $(e){let t=process.env.GIT_INDEX_FILE;if(t===void 0)return;let a=(await e(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(l.resolve(t)!==l.resolve(a))throw c("an alternate Git index requires explicit manual settlement")}async function I(e,t){if(t.length===0)return[];let a=t.map(s=>`:(literal)${s}`),o=new Set((await e(["ls-files","--cached","-z","--",...a])).stdout.split("\0")),i=t.filter(s=>!o.has(s)).map(s=>`:(literal)${s}`);if(i.length>0&&(await e(["diff","--cached","--name-only","--diff-filter=D","-z","--",...i])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return i}async function G(e){let{git:t,preview:a,paths:o,newReceiptPathspecs:i}=e,s=!1;try{i.length>0&&(s=!0,await t(["add","--",...i]));let n=await e.apply();if(!n.ok||JSON.stringify(n.receipts.summaries)!==JSON.stringify(a.receipts.summaries)||n.repair.streams.some(p=>!a.repair.streams.some(m=>m.id===p.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return o.length>0&&await t(["add","--",...o.map(p=>`:(literal)${p}`)]),{...n,staged_paths:o,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(n){throw s&&await t(["reset","--quiet","--",...i]),n}}function k(e){if(e.repair.totals.failed>0||e.receipts.missing_history_references_after>0||e.receipts.summaries.some(t=>t.conflict_fields.length>0)||e.repair.streams.some(t=>t.merge_receipt_proof?.trusted!==!0)||e.validation.checks.some(t=>t.name!=="history_drift"&&t.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function S(e){try{return{...e,path:await b(h(process.cwd(),e.path))}}catch{throw c("the tracker root cannot be resolved")}}async function F(e){let{preview:t}=e;k(t);let{path:a}=await S(e.global),o=await w(a);if(o===null)throw c("a Git workspace is required");let i=r=>R("git",r,{cwd:o,env:u(),timeout:1e4});if(await $(i),(await i(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let s=[...new Set([...[...new Set([...t.repair.streams.map(r=>r.id),...t.receipts.summaries.map(r=>r.item_id)])].map(r=>l.join(a,"history",`${r}.jsonl`)),...t.receipts.summaries.map(r=>l.join(a,"merge-receipts",`${r.receipt_id}.json`))])].map(r=>l.relative(o,r).replaceAll("\\","/"));if(s.some(g))throw c("reconciliation artifacts must belong to this Git workspace");let n=await y(o,s);if(n.length>0)throw new f(`Automatic merge settlement refused: required artifacts are ignored by Git: ${n.map(r=>`${r.path} (${r.source}:${r.line}: ${r.pattern})`).join(", ")}. Remove or narrow the owning ignore rules because merge receipts must travel with the commit.`,d.CONFLICT,{code:"merge_settlement_review_required",reason:"ignored_merge_artifacts",paths:n.map(r=>r.path),nextSteps:["Remove or narrow the named ignore rules, preserve receipt and history files, then retry pm merge reconcile --stage --dry-run before applying pm merge reconcile --stage. Do not force-add ignored proof as a substitute for fixing the shared policy."]});let p=s.map(r=>`:(literal)${r}`),m=t.receipts.summaries.map(r=>l.relative(o,l.join(a,"merge-receipts",`${r.receipt_id}.json`)).replaceAll("\\","/"));if(p.length>0)try{await i(["diff","--quiet","--",...p])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let v=await I(i,m);return e.dryRun?{...t,staged_paths:[]}:G({...e,git:i,paths:s,newReceiptPathspecs:v})}export{S as resolveMergeSettlementGlobal,F as stageLosslessMergeReconciliation};
|
|
2
|
+
//# sourceMappingURL=stage-LERF2YJU.js.map
|