@unbrained/pm-cli 2026.11.23 → 2026.11.24
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/main.js +5 -5
- package/dist/cli/register-annotations.js +1 -1
- package/dist/cli/runtime/invocation-options.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-2UQU7HRR.js → chunk-23K6DQQY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-O7JHS64G.js → chunk-37UDIJ2K.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-7IROAPWI.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-KZHIBEJL.js → chunk-7VRFEURZ.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-7X253M6Z.js +3 -0
- package/dist/cli-bundle/chunks/chunk-AWB5KBJS.js +2 -0
- package/dist/cli-bundle/chunks/chunk-DQDRA3SW.js +2 -0
- package/dist/cli-bundle/chunks/chunk-FXJYZBWV.js +113 -0
- package/dist/cli-bundle/chunks/{chunk-BSRIVYTM.js → chunk-HNKK2UG6.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HZZLSBIJ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-I2OJ5B4A.js +2 -0
- package/dist/cli-bundle/chunks/chunk-I3BFCKZR.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ENKXRSFZ.js → chunk-MXUSC5RS.js} +31 -31
- package/dist/cli-bundle/chunks/chunk-PLIUU37C.js +3 -0
- package/dist/cli-bundle/chunks/chunk-PQUBVRV5.js +2 -0
- package/dist/cli-bundle/chunks/chunk-PW7U7WCE.js +3 -0
- package/dist/cli-bundle/chunks/chunk-SSALO4DB.js +2 -0
- package/dist/cli-bundle/chunks/chunk-STOOTHZZ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-TKRY22SO.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-AEOHUSUI.js → chunk-TVIJ2VCU.js} +68 -68
- package/dist/cli-bundle/chunks/{chunk-F2Z6XLZB.js → chunk-VJSGUXGU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-H7JEXRIN.js → chunk-WWTPNIC2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-J2PDAVBC.js → chunk-XFADNMGD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TZY5MVJF.js → chunk-YOPTAIBD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CFWLQFJM.js → chunk-YW2HBHRO.js} +50 -51
- package/dist/cli-bundle/chunks/chunk-Z7MFVRDV.js +2 -0
- package/dist/cli-bundle/chunks/chunk-ZOX4SWRL.js +8 -0
- package/dist/cli-bundle/chunks/chunk-ZYCOM4MS.js +9 -0
- package/dist/cli-bundle/chunks/field-option-collisions-W66HSWMK.js +2 -0
- package/dist/cli-bundle/{focused-chunks/item-revision-YDACCDVY.js → chunks/item-revision-D3LSBNIR.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-M6NTBYH3.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-OKL3CQVX.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-EKPEOZMF.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-L4IBU64P.js → register-list-query-3LBV6CS2.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-72AGTMNE.js +21 -0
- package/dist/cli-bundle/chunks/register-operations-XERFG2SH.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-W22L34Z4.js +2 -0
- package/dist/cli-bundle/chunks/runtime-schema-JP2KBHBY.js +2 -0
- package/dist/cli-bundle/chunks/stage-T2LKWN7C.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-24VRBNKE.js +26 -0
- package/dist/cli-bundle/focused-chunks/chunk-3ELVASVA.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-XRS3VNC6.js → chunk-3GT4A3ZN.js} +23 -23
- package/dist/cli-bundle/focused-chunks/{chunk-IROZDIDX.js → chunk-3OCDKITJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3Z7MCUJM.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-46MP7IZN.js +5 -0
- package/dist/cli-bundle/focused-chunks/{chunk-OTMMOKPM.js → chunk-5LDBS6MS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZHWPCVQL.js → chunk-B6BNHKUW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-C7WHWI7K.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-EUQGZPGO.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UFTUNBMY.js → chunk-FDZPRJXJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-GXP7Q4XM.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-HL47UQZJ.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-LMFIAQ2V.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-LMU7DDOA.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-OZOCEB2Q.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NQTEE66P.js → chunk-Q2HY44LV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-REFMQY47.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-RIQUIHYU.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QQIIMMFU.js → chunk-RLO2HCZT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-SMMOZ3H3.js +100 -0
- package/dist/cli-bundle/focused-chunks/chunk-UVTUX54T.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-Y2ESLKCF.js → chunk-XDBHD4CY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-YD66IRSL.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Z7W2RQIB.js +2 -0
- package/dist/cli-bundle/focused-chunks/field-option-collisions-UODPSV6W.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-revision-QH7RNBX4.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-ZO72OINF.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-actor-PHVLKG4I.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-admission-ZSG5OECH.js +2 -0
- package/dist/cli-bundle/focused-chunks/runtime-schema-6RQMIDTN.js +2 -0
- package/dist/cli-bundle/focused-chunks/stage-AQMKRVX4.js +2 -0
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +4 -4
- 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 +63 -63
- 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/profile/profile-lint.d.ts +1 -1
- package/dist/core/profile/profile-lint.js +1 -1
- package/dist/core/schema/fields-file.js +2 -2
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/schema/runtime-schema.d.ts +2 -0
- package/dist/core/schema/runtime-schema.js +1 -1
- package/dist/sdk/extension/command-options.d.ts +26 -1
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -2
- 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/index.d.ts +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output-contracts.d.ts +11 -0
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/schema/field-flag-spelling.d.ts +22 -0
- package/dist/sdk/schema/field-flag-spelling.js +2 -0
- package/dist/sdk/schema/field-option-collisions.js +1 -1
- package/docs/COMMANDS.md +1 -1
- package/docs/EXTENSIONS.md +1 -1
- package/docs/READ_OUTPUT_CONTRACTS.md +2 -0
- package/docs/SDK.md +20 -1
- package/docs/SDK_AUDITED_MUTATIONS.md +11 -0
- package/marketplace.json +1 -1
- package/package.json +1 -1
- 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-5WZZ5XEN.js +0 -3
- package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +0 -2
- package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +0 -2
- package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +0 -2
- package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +0 -115
- package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +0 -2
- package/dist/cli-bundle/chunks/chunk-OPJF254V.js +0 -9
- package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +0 -2
- package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +0 -8
- package/dist/cli-bundle/chunks/item-revision-FMD4KWBB.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +0 -2
- package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +0 -21
- package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +0 -2
- package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +0 -102
- package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +0 -2
- package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{B as Le,C as Je,E as Z,H as We,J as Be,K as Ve,M as Ye,N as He,a as Pe,p as H}from"./chunk-XRS3VNC6.js";import"./chunk-LQYYPXUK.js";import"./chunk-YSJKQLFR.js";import{A as V,B as Ge,C as Y,D as qe,y as ze,z as j}from"./chunk-ZHWPCVQL.js";import"./chunk-O7Z73ALG.js";import"./chunk-Y2ESLKCF.js";import"./chunk-RIE3SJSE.js";import"./chunk-XYPEZGTR.js";import"./chunk-6LKTEKHS.js";import"./chunk-K53OIT5J.js";import"./chunk-QQIIMMFU.js";import{T as Ne,W as je}from"./chunk-IROZDIDX.js";import"./chunk-TD544C74.js";import"./chunk-I66IKYKP.js";import{Ga as Ke}from"./chunk-NQTEE66P.js";import"./chunk-OXOCZJC6.js";import"./chunk-6LPXMFLM.js";import{H as W}from"./chunk-UFTUNBMY.js";import{ra as _e,xa as Se}from"./chunk-IR2J3NOT.js";import"./chunk-ITKDHSBR.js";import"./chunk-QLAHEDT6.js";import"./chunk-BKPUUW5O.js";import{L as xe,R as De,b as ye,l as B}from"./chunk-OTMMOKPM.js";import{i as Ue,m as Fe,s as N}from"./chunk-HMDQDRV2.js";import"./chunk-BWOVFE5B.js";import"./chunk-X6CXWWNB.js";import{Bd as Ae,Cd as $e,Dd as J,Ga as E,Pd as Te,Sf as Ie,Tf as k,Yf as Me,Zf as Ce,af as C,fc as Ee,ff as Re,hc as L,ic as Oe,kf as T,lc as be,pe as ke,ra as K,te as M,ud as ve,ya as ge}from"./chunk-Z2X7HH3C.js";import"./chunk-IIP6LZ5E.js";import"./chunk-AIDL2ZNT.js";import{A as p,E as q,G as we,H as $,l as le,q as A,s as me,x as he,z as l}from"./chunk-A6VEMCRR.js";import oe from"node:crypto";import{constants as te,readFileSync as It}from"node:fs";import{cp as Mt,lstat as it,mkdir as Ct,mkdtemp as ot,open as Nt,readdir as jt,realpath as st,rm as at,stat as se,writeFile as ct}from"node:fs/promises";import{tmpdir as dt}from"node:os";import u from"node:path";var Et=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...le,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function X(e,t,n){let r=e?.estimatedMinutes;if(!(r===void 0||typeof r=="string"))throw new p(`Mutation ${n+1} ${t} option "estimatedMinutes" must be a string.`,l.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."]})}var Ot=["op","id","reason","options","unique","match"],bt=[...Ot,"ref"],xn=[...bt,"item"];var Xe="[a-z][a-z0-9._-]{0,63}",Dn=new RegExp(`^${Xe}$`,"u"),Pn=new RegExp(`(^|,)id=@(${Xe})(?=,|$)`,"gu"),Ze=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase());var vt=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"]),zn=new Set([...vt,"completed_at","id"]),Gn={create:Ne.map(e=>e.target),update:je.map(e=>e.target),close:_e.map(e=>Ze(e.flag)).filter(e=>e!=="reason"),release:Se.map(e=>Ze(e.flag))};function At(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function $t(e,t){return e<t?-1:+(e!==t)}function Q(e){return Array.isArray(e)?e.map(Q):At(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>$t(t,n)).map(([t,n])=>[t,Q(n)])):e}function O(e){return typeof e=="string"?e.trim():JSON.stringify(Q(e))}var Tt=["id","updated_at","pm_format_version","type"],kt="import";function Qe(e,t){if(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/u.test(e)||e in Object.prototype)throw new TypeError(`${t} names an invalid field ${JSON.stringify(e)}; use a front-matter field name of letters, digits and underscores`);if(Tt.includes(e))throw new TypeError(`${t} cannot change "${e}"; the item writer derives it, or an update row owns it`)}function U(e){return Array.isArray(e)?`array of ${e.length}`:typeof e}var Rt=["__proto__","constructor","prototype"];function et(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype}function R(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?Array.from(e).every(R):et(e)?Object.entries(e).every(([t,n])=>!Rt.includes(t)&&R(n)):!1}function ee(e,t){let{set:n,unset:r}=e;if(n!==void 0&&!et(n))throw new TypeError(`${t} set must be a plain object of front-matter fields`);if(r!==void 0&&!Array.isArray(r))throw new TypeError(`${t} unset must be an array of front-matter field names`);let i=Object.keys(n??{}),s=r??[];if(i.length+s.length===0)throw new TypeError(`${t} requires at least one field in set or unset`);for(let o of i)if(Qe(o,t),n[o]===null||!R(n[o]))throw new TypeError(`${t} set "${o}" must be a non-null JSON value (no undefined, non-finite number, sparse array, class instance, or __proto__/constructor/prototype key); remove a field with unset`);for(let o of s){if(Qe(o,t),o==="body"||o==="front_matter")throw new TypeError(`${t} cannot unset "${o}"; the item format reserves that name`);if(i.includes(o))throw new TypeError(`${t} both sets and unsets "${o}"`)}if(new Set(s).size!==s.length)throw new TypeError(`${t} unset repeats a field`)}async function tt(e){ee(e,`Finalization of ${e.id}`);let t=await N(e.pmRoot),n={schema:t.schema,extensionFieldNames:ye(k())},r=await De({pmRoot:e.pmRoot,settings:t,id:e.id,op:kt,author:e.author,message:e.message,force:e.force===!0,extensionFieldNames:n.extensionFieldNames,mutate:i=>{let s=structuredClone(i.metadata),o=i.metadata;for(let[c,f]of Object.entries(e.set??{}))o[c]=structuredClone(f);for(let c of e.unset??[])delete o[c];let a;try{ve(i.metadata);let c=J(i,n),f=J(Ae($e(c,n),n),n);if(E(f)!==E(c))throw new TypeError("the stored item reads back as a different document; a set field collides with a name the item format reserves");a=c.metadata;let h=Object.entries(e.set??{}).find(([m,w])=>U(a[m])!==U(w));if(h!==void 0)throw new TypeError(`set "${h[0]}" is not stored as declared (${U(h[1])} normalizes to ${a[h[0]]===void 0?"an absent field":U(a[h[0]])})`)}catch(c){throw new p(`Finalization of ${e.id} would not store a readable item with the declared fields: ${c.message}`,l.USAGE,{code:"finalization_invalid_document",item_id:e.id,required:"Declare set and unset fields that leave a valid item under the workspace schema, with each set value in the shape its field stores.",why:"A finalization writes front-matter fields exactly, so the patched document is read back through the item reader, and each declared value is checked against what would be stored, before anything is written.",nextSteps:[`Run pm get ${e.id} --json to compare the current fields with the finalization, then correct the patch and retry the transaction.`]})}return{changedFields:[...new Set([...Object.keys(s),...Object.keys(a)])].filter(c=>Object.hasOwn(s,c)!==Object.hasOwn(a,c)||E(s[c])!==E(a[c])).sort((c,f)=>c.localeCompare(f))}}});return{item:r.item,changedFields:r.changedFields}}async function Ut(e,t){if(!Fe(e))return{schema:L(t.schema),typeDefinitionsFromFile:[]};let n=await Ht(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function Ft(e,t,n,r){let i=K({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},k());return(await xe(e,t.item_format,i.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[r];return a==null?[]:[{id:o.id,value:a}]})}function ae(e){let t=new Map,n=async r=>{let i=await N(e),s=await Ut(e,i),o=new Map;for(let a of await Ft(e,i,s,r)){let d=O(a.value);o.set(d,[...o.get(d)??[],a.id])}return o};return{lookup(r){let i=t.get(r)??n(r);return t.set(r,i),i},async recordCreate(r){for(let[i,s]of t){let o=r[i];if(o==null)continue;let a=await s,d=O(o);a.set(d,[...a.get(d)??[],String(r.id)])}},invalidate(){t.clear()}}}async function xt(e,t){let n=O(t.value),r=(await e.lookup(t.key)).get(n)??[];if(r.length!==0)throw new p(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${r.join(", ")}; the plan was resolved before it existed.`,l.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 ut(e,t,n){let r=e.metadata[n.key],i=O(n.value);if(O(r)!==i)throw new p(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,l.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 nt(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 P(e,t){let n={...e,...t};return e===void 0?n:W(e,n)}async function _(e,t){try{let r=(await H(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 p&&n.exitCode===l.NOT_FOUND)return;throw n}}function ce(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=oe.createHash("sha256").update(E(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function Dt(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function y(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}function de(e,t){return e===t||(e?.startsWith(`${t} | `)??!1)}async function v(e,t,n,r){let i=await M(u.join(e,"history",`${t}.jsonl`),t),s=y(n,r,"apply"),o=y(n,r,"compensate");for(let a=i.length-1;a>=0;a-=1){let d=i[a].message;if(de(d,s))return!0;if(d===o)return!1}return!1}async function z(e,t){let n=await _(e,t.id);if(n?.updatedAt===void 0)throw new p(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,l.NOT_FOUND);let r=await M(u.join(e,"history",`${n.id}.jsonl`),n.id);if(r.length===0)throw new p(`Bulk ${t.op} target ${t.id} has no restorable history`,l.NOT_FOUND);return{target_updated_at:n.updatedAt,target_version:String(B(r)+r.length),target_history_hash:C(r),target_history_length:r.length}}function b(e,t,n){return new p(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${n}; review item ${t} history before recovery.`,l.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 ft(e,t){let n=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(r=>typeof r=="string"&&r.startsWith(n))}function Pt(e,t,n){let{expectedHistory:r,length:i,version:s}=t;if(C(e)===r)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||C(e.slice(0,i))!==r||s!==String(B(e)+i))throw b(n,n.itemId,n.stepId);let o=y(n.transactionId,n.stepId,"apply"),a=e.slice(i),d=m=>de(m.message,o)||m.context?.item_transaction_step===o,c=y(n.transactionId,n.stepId,"compensate");if(a.filter(m=>d(m)||m.message===c).at(-1)?.message===c)return!1;let f=a.filter(d);if(f.length===0)return!1;let h=e.at(-1).after_hash===f.at(-1).after_hash&&a.every(m=>ft(m,n.transactionId));if(f.length!==a.length&&!h)throw b(n,n.itemId,n.stepId);return!0}async function pt(e,t){let n=u.join(e,"history",`${t}.jsonl`),r=await ke(n,t);return{history:r.entries,assertOwnedUnderLock:(i,s)=>{let o;try{o=It(n).equals(r.raw_bytes)&&Re(i)===r.entries.at(-1).after_hash}catch(a){throw Object.assign(s(),{cause:a})}if(!o)throw s()}}}async function I(e,t,n,r){let i=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let s=i.target_updated_at,o=await _(e.pmRoot,t);if(o===void 0)return;let{history:a,assertOwnedUnderLock:d}=await pt(e.pmRoot,o.id),c=i.target_history_hash,f=typeof c=="string";if(typeof c=="string"){if(!Pt(a,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:o.id,stepId:n}))return}else{if(o.updatedAt===s)return;if(!await v(e.pmRoot,o.id,e.transactionId,n))throw b(e,o.id,n)}let h=()=>Ve(t,typeof i.target_version=="string"?i.target_version:s,{force:!0,author:e.author,message:y(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot});await T({pmRoot:e.pmRoot,id:o.id,validate:m=>{d(m,()=>b(e,o.id,n))},compensation:mt(e,t,n,"restore",f)},h)}var lt=new WeakMap;function mt(e,t,n,r,i){let s=i?ze(e.pmRoot,e.transactionId):void 0,o=s===void 0?void 0:lt.get(s);if(!(o?.stepId!==n||o.itemId!==t||o.operation!==r))return{transaction_id:e.transactionId,step_id:n,operations:[r],overrides:[]}}function ht(e,t,n){return{id:n,async inspect(){let r=await _(e.pmRoot,t.id);if(r===void 0)return{state:"pending"};if(r.closedAt!==void 0){let i=await M(u.join(e.pmRoot,"history",`${r.id}.jsonl`),r.id),s=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(d=>d.op==="close").at(-1)?.patch.some(d=>d.op==="add"||d.op==="replace"?d.path==="/metadata/close_reason"&&d.value===s:!1)??!1)throw new p(`Created item ${r.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,l.CONFLICT,{code:"transaction_create_compensated",item_id:r.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 ${r.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:r.id,op:"create"}}},async apply(){t.unique!==void 0&&await xt(e.uniqueIndex,t.unique);let r=await Le(P(t.options,{author:e.author,id:t.id,message:y(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=r.item;return e.onCreateWarnings?.(String(i.id),r.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await zt(e,t.id,n)}}}async function zt(e,t,n){let r=await _(e.pmRoot,t);if(r===void 0||e.createCompensation==="close"&&r.closedAt!==void 0)return;let{history:i,assertOwnedUnderLock:s}=await pt(e.pmRoot,r.id),o=y(e.transactionId,n,"apply"),a=y(e.transactionId,n,"compensate"),d=i.filter(c=>de(c.message,o)||c.message===a).at(-1);if(d?.message!==a){if(d===void 0||!i.every(c=>ft(c,e.transactionId)))throw b(e,r.id,n);await T({pmRoot:e.pmRoot,id:r.id,validate:c=>{s(c,()=>b(e,r.id,n))},compensation:mt(e,t,n,e.createCompensation==="delete"?"delete":"close",!0)},async()=>{let c={force:!0,author:e.author,message:a};e.createCompensation==="delete"?await Be(t,c,{pmRoot:e.pmRoot}):await Z(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,{...c,validateClose:"off"},{pmRoot:e.pmRoot})})}}function Gt(e,t,n){return{id:n,compensatePending:!0,async inspect(){let r=await _(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await v(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return z(e.pmRoot,t)},async apply(){let r=()=>Je(t.id,P(t.options,{author:e.author,message:y(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=t.match,s=i,a=(await T({pmRoot:e.pmRoot,id:await yt(e.pmRoot,t.id),validate:d=>{s!==void 0&&ut(d,t.id,s)},committed:d=>{i!==void 0&&(s={key:i.key,value:structuredClone(d.metadata[i.key])})},historyContext:{item_transaction_step:y(e.transactionId,n,"apply")}},r)).item;return e.uniqueIndex.invalidate(),{id:String(a.id),op:"update"}},async compensate(r){await I(e,t.id,n,r)}}}async function yt(e,t){return String((await H(t,{},{pmRoot:e})).item.id)}function qt(e,t,n){let r=y(e.transactionId,n,"apply");return{id:n,compensatePending:!0,async inspect(){let i=await _(e.pmRoot,t.id);return i===void 0||!await v(e.pmRoot,i.id,e.transactionId,n)?{state:"pending"}:{state:"applied",result:{id:i.id,op:t.op}}},async prepareCompensation(){return z(e.pmRoot,t)},async apply(){let i=await yt(e.pmRoot,t.id),{match:s}=t;return await He(e.pmRoot,()=>T({pmRoot:e.pmRoot,id:i,validate:o=>{s!==void 0&&ut(o,t.id,s)},historyContext:{item_transaction_step:r}},()=>tt({pmRoot:e.pmRoot,id:i,author:e.author,message:r,force:t.force,...t.set===void 0?{}:{set:t.set},...t.unset===void 0?{}:{unset:t.unset}}))),e.uniqueIndex.invalidate(),{id:i,op:t.op}},async compensate(i){await I(e,t.id,n,i)}}}function Kt(e,t,n){return{id:n,async inspect(){let r=await _(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await v(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 z(e.pmRoot,t)},async apply(){let i=(await Z(t.id,t.reason,P(t.options,{author:e.author,message:y(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(i.id),op:"close"}},async compensate(r){await I(e,t.id,n,r)}}}function Lt(e,t,n){return{id:n,async inspect(){let r=await _(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await v(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 z(e.pmRoot,t)},async apply(){let i=(await We(t.id,P(t.options,{author:e.author,message:y(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(i.id),op:"release"}},async compensate(r){await I(e,t.id,n,r)}}}function ue(e,t,n){let r=ce(t,n),i=Jt(e,t,r);return lt.set(i,{transactionId:e.transactionId,stepId:r,itemId:t.id,operation:t.op!=="create"?"restore":e.createCompensation==="delete"?"delete":"close"}),i}function Jt(e,t,n){switch(t.op){case"create":return ht(e,t,n);case"update":return Gt(e,t,n);case"close":return Kt(e,t,n);case"release":return Lt(e,t,n);case"finalize":return qt(e,t,n)}}function Wt(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","finalize"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, release, or finalize`);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(Bt(e,t),e.op==="finalize"){Vt(e,t);return}X(e.options,e.op,t)}function Bt(e,t){if(e.op==="create"&&e.unique!==void 0&&!nt(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.op==="finalize")&&e.match!==void 0&&!nt(e.match))throw new TypeError(`Bulk ${e.op} mutation ${t+1} match must be an object with a non-empty key and a value`)}var rt=["op","id","set","unset","match","force"];function Vt(e,t){let n=`Bulk finalize mutation ${t+1}`,r=Object.keys(e).filter(i=>!rt.includes(i));if(r.length>0)throw new TypeError(`${n} has unsupported keys: ${r.join(", ")}; a finalization carries only ${rt.join(", ")}`);if(e.force!==void 0&&typeof e.force!="boolean")throw new TypeError(`${n} force must be a boolean`);if(e.match!==void 0&&!R(e.match))throw new TypeError(`${n} match must be a plain object with a JSON value`);ee(e,n)}function ie(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,r]of e.entries()){if(Wt(r,n),r.op!=="create"||r.unique===void 0)continue;let{key:i,value:s}=r.unique,o=t.get(i)??new Map,a=O(s),d=o.get(a);if(d!==void 0)throw new p(`Bulk create mutations ${d+1} and ${n+1} share the upsert key value ${JSON.stringify(a)} for "${i}".`,l.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,n),t.set(i,o)}}function wt(e){let t=[...e];ie(t);let n=t.map(r=>{let i=structuredClone(r);return r.op!=="finalize"&&i.op!=="finalize"&&r.options!==void 0&&i.options!==void 0&&W(r.options,i.options),i});return ie(n),n}function gt(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([n,r])=>{let i=`${t}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(n)?[i]:gt(r,i)})}async function ne(e,t,n){try{return await n()}catch(r){throw r instanceof p?new p(r.message,r.exitCode,{...r.context,transaction_operation:{index:t,op:e.op,id:e.id}}):r}}function _t(e,t,n,r){let i=u.relative(e,t),s=i.split(u.sep);return s[0]==="extensions"&&s[2]==="node_modules"&&!r.some(o=>i===o||i.startsWith(`${o}${u.sep}`)||o.startsWith(`${i}${u.sep}`))?!1:["locks","runtime","search"].includes(i.split(u.sep)[0])?r.some(o=>i===o||i.startsWith(`${o}${u.sep}`)||o.startsWith(`${i}${u.sep}`)):i===""||n===void 0||n.some(o=>i===o||i.startsWith(`${o}${u.sep}`)||o.startsWith(`${i}${u.sep}`))}async function x(e,t){let n=await it(t);if(n.isSymbolicLink())await se(t);else if(n.isDirectory()||n.isFile())return n;throw $(u.relative(e,t))}async function Yt(e,t){let n=await Nt(t,te.O_RDONLY|te.O_NOFOLLOW|te.O_NONBLOCK);try{let r=await n.stat();if(!r.isFile())throw $(u.relative(e,t));let i=oe.createHash("sha256");if(r.size>0)for await(let s of n.createReadStream({highWaterMark:64*1024,end:r.size-1,autoClose:!1}))i.update(s);return i.digest()}finally{await n.close()}}async function re(e,t,n){let r=oe.createHash("sha256");async function i(s){for(let o of(await jt(s)).sort()){let a=u.join(s,o);_t(e,a,t,n)&&((await x(e,a)).isDirectory()?await i(a):(r.update(JSON.stringify(u.relative(e,a))),r.update(await Yt(e,a))))}}return await i(e),r.digest("hex")}function F(){return new p("Tracker changed while preparing the transaction preview; retry against stable state.",l.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function fe(e){if(!q(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=u.resolve(t),r=n;for(;;)try{let i=await it(r);return r!==n&&i.isDirectory()}catch(i){if(!q(i))return!1;let s=u.dirname(r);if(s===r)return!1;r=s}}async function D(e,t){let n=u.join(e,t);try{let r=e;for(let i of t.split(u.sep).slice(0,-1))r=u.join(r,i),await x(e,r);if(!(await x(e,n)).isFile())throw $(t);return await we(n,$(t))}catch(r){if(await fe(r))return;throw r}}async function St(e,t,n,r){let i=L(n);for(let[s,o]of Object.entries(i.files)){let a=u.relative(e,Oe(e,o,Ee[s]));if(a===""||!u.resolve(e,a).startsWith(u.join(e,u.sep)))throw new p("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",l.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${s}`});i.files[s]=a;let d=await D(e,a);if(r?.set(a,d),d!==void 0){let c=u.join(t,a);await Ct(u.dirname(c),{recursive:!0}),await ct(c,d)}}return be(t,i)}async function Ht(e,t){await se(e);let n=await ot(u.join(dt(),"pm-schema-plan-"));try{let r=await st(e);return await St(r,u.join(n,"configuration"),t)}catch(r){throw await fe(r)?F():r}finally{await at(n,{recursive:!0,force:!0})}}async function Zt(e,t,n){let r=new Map,i=await D(e,A);r.set(A,i);let s;try{s=JSON.parse(i??"null")}catch{s=null}let o=Ue(s),a=o.success?o.data:void 0,d=await St(e,t,a?.schema,r),c=d.schema,f=u.relative(e,Te(e));r.set(f,await D(e,f));let h=K({...he,item_types:{definitions:[...a?.item_types?.definitions??[],...d.type_definitions_from_file??[]]}},n),m=ge(e)===e?[...me.filter(Boolean),A,Pe,"transactions",...h.folders,...r.keys()].map(g=>u.normalize(g)):void 0,w=a===void 0?void 0:JSON.stringify({...s,schema:{...a.schema,files:c.files}});return{configuration:r,ownedPaths:m,stagedSettings:w,registryFolders:h.folders}}async function Xt(e,t,n){await se(e);try{let r=await st(e),i=await Zt(r,u.join(u.dirname(t),"configuration"),n),s=[...i.configuration.keys(),...i.registryFolders].map(c=>u.normalize(c)),o=await re(r,i.ownedPaths,s);await Mt(r,t,{recursive:!0,dereference:!1,filter:async c=>_t(r,c,i.ownedPaths,s)?(await x(r,c),!0):!1});let[a,d]=await Promise.all([re(r,i.ownedPaths,s),re(t,i.ownedPaths,s)]);if(o!==a||o!==d)throw F();for(let[c,f]of i.configuration)if(await D(t,c)!==f)throw F();i.stagedSettings!==void 0&&await ct(u.join(t,A),i.stagedSettings)}catch(r){throw await fe(r)?F():r}}async function Ir(e){let t=j(e),n=wt(e.mutations),r=k(),i=Ce(),s=await ot(u.join(dt(),"pm-transaction-preview-")),o=u.join(s,"tracker");try{await Xt(t.pmRoot,o,r);let a=!1,d=[],c=[],f=new Set;return await Me(i,()=>Ye({path:o,noExtensions:!0},async()=>{Ie(r);let h={...t,pmRoot:o,createCompensation:"close",uniqueIndex:ae(o)},m=n.map((w,g)=>{let S=ue({...h,onCreateWarnings:(G,pe)=>{pe.length>0&&d.push({index:g,id:G,op:"create",warnings:pe})}},w,g);return{...S,inspect:()=>ne(w,g,()=>S.inspect()),prepareCompensation:()=>ne(w,g,async()=>S.prepareCompensation?.()),apply:()=>ne(w,g,async()=>{let G=await S.apply();return f.add(g),G})}});if(await V({...t,pmRoot:o,steps:m,onTransition:({transition:w})=>{w==="committed"&&(a=!0)}}),a)for(let[w,g]of n.entries()){let S=(await Ke(g.id,{path:o},{full:!0})).item;c.push({index:w,id:String(S.id),op:g.op,execution:f.has(w)?"applied":"adopted",item:S,commit_time_fields:gt(S)})}})),{records:c,validated:a,state:a?"staged_snapshot":"replayed_committed_plan",warnings:d,unresolved_commit_constraints:["concurrent_tracker_changes","extension_write_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await at(s,{recursive:!0,force:!0})}}async function Qt(e){let t=j(e),n=wt(e.mutations),r=e.createCompensation??"close";if(!["close","delete"].includes(r))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:r,uniqueIndex:ae(t.pmRoot)},s=await V({...t,steps:n.map((a,d)=>ue(i,a,d)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:n,createCompensation:r})),...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,d]of n.entries()){let c=ce(d,a),f=s.results[c];o[Dt(d,a)]=f}return{transactionId:s.transactionId,status:"committed",recovered:s.recovered,results:o}}function en(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 Mr(e){return Qt({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:en(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Cr={buildCreateStep:ht,bulkHistoryMarker:y,compensateByRestore:I,deriveStepId:ce,isUpdateMarkerApplied:v,readItemSnapshot:_};async function Nr(e,t){let n=await Ge(e,t);return n===void 0?void 0:{journal:n,planDigest:Y(n)}}function tn(e,t){let n=t.recoveryData;if(n===null||typeof n!="object"||Array.isArray(n)||n.kind!=="item-mutations-v1"||!Array.isArray(n.mutations)||!["close","delete"].includes(String(n.createCompensation)))throw new p("Transaction has no supported item recovery plan",l.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 r=n.mutations;ie(r);let i={...e,createCompensation:n.createCompensation,uniqueIndex:ae(e.pmRoot)};return r.map((s,o)=>ue(i,s,o))}async function jr(e){let t=j(e),n=await qe({...e,...t,resolveSteps:r=>tn({...e,...t},r)});return{journal:n,planDigest:Y(n)}}export{Cr as _testOnlyItemTransaction,jr as abandonItemTransaction,en as buildItemCompletionMutations,Mr as commitItemCompletion,Qt as commitItemMutations,Ft as listUpsertKeyCandidates,Ht as loadGuardedRuntimeSchema,Ir as previewItemMutations,Nr as readItemTransaction,Ut as resolveTransactionSchema};
|
|
2
|
-
//# sourceMappingURL=item-transaction-UKEQCTKB.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{le as t,me as r,ne as s}from"./chunk-Z2X7HH3C.js";import"./chunk-A6VEMCRR.js";function c(n){let e=r(n),o={...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:n,author_source:t(n),principal:s(n),...Object.keys(o).length===0?{}:{agent:Object.freeze(o)}})}export{c as resolveMutationActor};
|
|
2
|
-
//# sourceMappingURL=mutation-actor-AS465LRX.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Q as y,t as _,y as f}from"./chunk-XYPEZGTR.js";import"./chunk-QQIIMMFU.js";import{T as A,W as L,a as T}from"./chunk-IROZDIDX.js";import"./chunk-UFTUNBMY.js";import{F as g,Oa as C,Ua as E}from"./chunk-IR2J3NOT.js";import"./chunk-OTMMOKPM.js";import{s as M}from"./chunk-HMDQDRV2.js";import"./chunk-BWOVFE5B.js";import"./chunk-X6CXWWNB.js";import{a as w,ad as b,oc as R,pc as N,xa as S}from"./chunk-Z2X7HH3C.js";import{A as m}from"./chunk-A6VEMCRR.js";function l(e,t,n,i=!1){let s=[...n].map(o=>({candidate:o,distance:w(t,o,3)})).filter(o=>o.distance!==null).sort((o,d)=>o.distance-d.distance||o.candidate.localeCompare(d.candidate))[0]?.candidate,a=i?`Put mutation fields under options (options.${t}).`:s?`Did you mean "${s}"?`:"Use the declared command options or the field option for registered item fields.";throw new m(`Unknown ${e} ${i?"argument":"option"} "${t}". ${a} No changes were made.`,2,{code:"invalid_argument_value",reason:"unknown_mutation_option",changed:!1,field:t,required:a,nextSteps:[a]})}var p=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function $(e){let t=e==="create"?A:L,i=(e==="create"?C:E).map(({flag:s})=>s.slice(2).replace(/-([a-z])/gu,(a,o)=>o.toUpperCase()));return new Set([...t.flatMap(s=>[s.target,...s.keys]),...i,"author","message","force","fullChangedFields","idOnly",...p])}function F(e){if(e!==void 0&&!f(e))throw new m("Mutation options must be an object. No changes were made.",2,{code:"invalid_argument_value",changed:!1})}async function v(e,t){let i=R((await M(S(process.cwd(),t))).schema).command_to_fields.get(e)??[];return{targets:i.map(s=>N(s)),reads:s=>i.some(a=>b({[s]:!0},a)===!0)}}async function h(e,t,n,i,s,a=(o,d)=>l(e,o,d)){let o=[...n].filter(r=>!i.has(r));if(o.length===0)return;let d=await v(t,s);for(let r of d.targets)i.add(r);for(let r of o)d.reads(r)||a(r,i)}async function ee(e,t,n,i,s){if(_(t))return;let a=$(e),o=new Set(["action","options","path","cwd","author","force","noExtensions","no_extensions","fullChangedFields","idOnly",...p,...s,...e==="update"?["id"]:[]]);for(let r of Object.keys(t))o.has(r)||l(e,r,a,a.has(r));let d=t.options;F(d),await h(e,e,new Set([...Object.keys(d??{}),...Object.keys(n)]),a,i)}var I=new Set([...y].filter(e=>e!=="filterStatus"&&(e.startsWith("filter")||e==="ids"||e==="limit"||e==="offset"))),k=e=>e.replace(/_([a-z])/gu,(t,n)=>n.toUpperCase()),O=new Map([["for","Bound the selection with list.limit."],["tokenBudget","Bound the selection with list.limit."],["token_budget","Bound the selection with list.limit."],["all",'State the status selection as filterStatus: "all" beside the list record.'],["status","State the status selection as filterStatus beside the list record."]]),K=["compact","brief","fields","includeBody","full"];async function U(e,t){let n=K.filter(s=>Object.hasOwn(e,s));if(n.length===0)return;let i=await v("list",t);for(let s of n)i.reads(s)&&c(`update-many "list.${s}" is not read beside this selection.`,`list.${s}`,"The bulk selection clears this list option, so the schema field's filter under that name is not applied; select the rows another way.")}var j=["excludeTerminal","lifecycleBucket","dependencyBlocked"];function P(){let e=g.map(({flag:n})=>n.replace(/^--(?:no-)?/u,"").replace(/-([a-z])/gu,(i,s)=>s.toUpperCase())),t=new Set([...e,...T.flatMap(n=>n.keys),"filterEstimateMissing",...j]);for(let n of O.keys())t.delete(n);return t}function c(e,t,n,i="unknown_mutation_option"){throw new m(`${e} ${n} No changes were made.`,2,{code:"invalid_argument_value",reason:i,changed:!1,field:t,required:n,nextSteps:[n]})}function D(){let e=$("update");e.delete("id");for(let t of e)/File$|^stdin/u.test(t)&&e.delete(t);return e.add("documentAnnotationSnapshot"),e}function B(e){for(let t of["list","update"]){let n=e[t];n!=null&&!f(n)&&c(`update-many "${t}" must be an object.`,t,`Pass ${t} as an object, or omit it.`,"invalid_mutation_option_value")}}async function x(e,t,n){Object.hasOwn(e,"id")&&l("update-many list","id",new Set(["ids"])),Object.hasOwn(e,"status")&&c('update-many "list.status" is not read beside this selection.',"list.status",O.get("status"));let i=[...t].find(s=>I.has(s));i!==void 0&&c(`update-many "${i}" is not read beside this selection.`,i,`Put the selection inside list, or drop the list record; a flat "${i}" beside it is not read.`),await U(e,n),await h("update-many list","list",Object.keys(e),P(),n,(s,a)=>{let o=O.get(s);o===void 0&&l("update-many list",s,a),c(`update-many "list.${s}" is not read beside this selection.`,`list.${s}`,o)})}function Y(e,t,n){for(let i of e)t.has(i)||(n.has(i)&&c(`Unknown update-many option "${i}".`,i,`Put update fields inside update (update.${i}); beside a nested update record an outer key selects rows or controls the run.`),l("update-many",i,t))}async function te(e,t,n){if(_(e))return;let i=e.options;F(i);let s=D(),a=new Set([...y,"author","message","force","fullChangedFields","idOnly",...p]),o=new Set([...s,...a]),d=new Set(["action","options","path","cwd","author","noExtensions","no_extensions","fullChangedFields","idOnly",...p]);for(let u of Object.keys(e))d.has(u)||l("update-many",u,o,o.has(u));let r=new Set([...Object.keys(i??{}),...Object.keys(t)].map(u=>p.includes(k(u))?k(u):u));if(B(t),f(t.list)&&await x(t.list,r,n),!f(t.update)){await h("update-many","update_many",r,o,n);return}Y(r,a,s),await h("update-many","update_many",Object.keys(t.update),s,n)}export{ee as assertNativeMutationOptions,te as assertNativeUpdateManyOptions};
|
|
2
|
-
//# sourceMappingURL=mutation-admission-E5UHJZFE.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as w,j as y}from"./chunk-Y2ESLKCF.js";import{b as u}from"./chunk-RIE3SJSE.js";import"./chunk-BKPUUW5O.js";import"./chunk-HMDQDRV2.js";import{xa as h}from"./chunk-Z2X7HH3C.js";import{c as g}from"./chunk-AIDL2ZNT.js";import{A as f,z as d}from"./chunk-A6VEMCRR.js";import{execFile as x}from"node:child_process";import{realpath as R}from"node:fs/promises";import p from"node:path";import{promisify as $}from"node:util";var b=$(x);function c(t){return new f(`Automatic merge settlement refused: ${t}`,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 G(t){let e=process.env.GIT_INDEX_FILE;if(e===void 0)return;let s=(await t(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(p.resolve(e)!==p.resolve(s))throw c("an alternate Git index requires explicit manual settlement")}async function k(t,e){if(e.length===0)return[];let s=e.map(n=>`:(literal)${n}`),a=new Set((await t(["ls-files","--cached","-z","--",...s])).stdout.split("\0")),i=e.filter(n=>!a.has(n)).map(n=>`:(literal)${n}`);if(i.length>0&&(await t(["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 I(t){let{git:e,preview:s,paths:a,newReceiptPathspecs:i}=t,n=!1;try{i.length>0&&(n=!0,await e(["add","--",...i]));let o=await t.apply();if(!o.ok||JSON.stringify(o.receipts.summaries)!==JSON.stringify(s.receipts.summaries)||o.repair.streams.some(m=>!s.repair.streams.some(l=>l.id===m.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return a.length>0&&await e(["add","--",...a.map(m=>`:(literal)${m}`)]),{...o,staged_paths:a,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(o){throw n&&await e(["reset","--quiet","--",...i]),o}}function S(t){if(t.repair.totals.failed>0||t.receipts.missing_history_references_after>0||t.receipts.summaries.some(e=>e.conflict_fields.length>0)||t.repair.streams.some(e=>e.merge_receipt_proof?.trusted!==!0)||t.validation.checks.some(e=>e.name!=="history_drift"&&e.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function q(t){try{return{...t,path:await R(h(process.cwd(),t.path))}}catch{throw c("the tracker root cannot be resolved")}}async function z(t){let{preview:e}=t;S(e);let{path:s}=await q(t.global),a=await w(s);if(a===null)throw c("a Git workspace is required");let i=r=>b("git",r,{cwd:a,env:g(),timeout:1e4});if(await G(i),(await i(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let o=[...new Set([...[...new Set([...e.repair.streams.map(r=>r.id),...e.receipts.summaries.map(r=>r.item_id)])].map(r=>p.join(s,"history",`${r}.jsonl`)),...e.receipts.summaries.map(r=>p.join(s,"merge-receipts",`${r.receipt_id}.json`))])].map(r=>p.relative(a,r).replaceAll("\\","/"));if(o.some(u))throw c("reconciliation artifacts must belong to this Git workspace");let m=await y(a,o);if(m.length>0)throw new f(`Automatic merge settlement refused: required artifacts are ignored by Git: ${m.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:m.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 l=o.map(r=>`:(literal)${r}`),v=e.receipts.summaries.map(r=>p.relative(a,p.join(s,"merge-receipts",`${r.receipt_id}.json`)).replaceAll("\\","/"));if(l.length>0)try{await i(["diff","--quiet","--",...l])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let _=await k(i,v);return t.dryRun?{...e,staged_paths:[]}:I({...t,git:i,paths:o,newReceiptPathspecs:_})}export{q as resolveMergeSettlementGlobal,z as stageLosslessMergeReconciliation};
|
|
2
|
-
//# sourceMappingURL=stage-36J7YLGI.js.map
|