@unbrained/pm-cli 2026.9.14 → 2026.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +12 -0
- package/dist/cli-bundle/bundle-manifest.json +148 -148
- package/dist/cli-bundle/chunks/{chunk-5JIJAWIF.js → chunk-3AHONKLL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DBHQIS6Z.js → chunk-3RB6Z7XE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZYRN2OG3.js → chunk-5P5PYCZX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-B6W5LIXK.js → chunk-BOZ4HVYL.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-J4DRE3WN.js +237 -0
- package/dist/cli-bundle/chunks/{chunk-GQMILIC5.js → chunk-RKPUO75B.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-O7SRS7Y3.js → chunk-RM2OGG65.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-D5AJQU7F.js → chunk-UKLOSZV6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XEV7BHH3.js → chunk-WDF7PP4P.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-A2Q64TGR.js → chunk-WLJJ4MAU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BY3ID7QI.js → chunk-Y2P3DSSO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NYE6EREL.js → chunk-YMMLKKEP.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-B2U36YWL.js → register-list-query-IWSPNFFD.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-GX42CQYR.js → register-mutation-3DVF4R64.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-ZV34KX5E.js → register-operations-LXP3MECQ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-W4OS7IZW.js → register-setup-KFQSNBDX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GGDO6VBT.js → chunk-4YTDKIPF.js} +17 -17
- package/dist/cli-bundle/focused-chunks/{chunk-ZFNRD7EN.js → chunk-533DCWPY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FNLAQJES.js → chunk-5SBU4QDC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KWP3QTN7.js → chunk-63YRRGKX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-N23WTRCC.js → chunk-6C3CUU2G.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-ENJH7CBZ.js → chunk-AXDAIBT3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6WZBO4VQ.js → chunk-BMATJLPT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FHQLQOUZ.js → chunk-JKJYXCT6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-D4FQV6TY.js → chunk-MD7ADLME.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7BUJABHB.js → chunk-OGGF2RBL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-CPQQIVDL.js → chunk-PBJC2ZNA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UFSMYVZF.js → chunk-SHF57M2H.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-C5NQVXKE.js → chunk-UACMCSCC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LFGTCEHX.js → chunk-YBQTVE5S.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-O4EROPO3.js → chunk-ZHX3433X.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZOE2NSJB.js +20 -0
- package/dist/cli-bundle/main.js +2 -2
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +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 +40 -40
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +1 -1
- package/dist/core/extensions/index.d.ts +7 -0
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/lock/lock.js +2 -2
- package/dist/core/telemetry/policy.d.ts +2 -0
- package/dist/core/telemetry/policy.js +1 -1
- package/dist/core/telemetry/read-sampling.d.ts +8 -0
- package/dist/core/telemetry/read-sampling.js +3 -0
- package/dist/core/telemetry/runtime.js +2 -2
- package/docs/CONFIGURATION.md +6 -2
- package/marketplace.json +2 -2
- 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-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli-bundle/chunks/chunk-33PER336.js +0 -236
- package/dist/cli-bundle/focused-chunks/chunk-CMCSUANO.js +0 -20
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{P as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{P as i}from"./chunk-4YTDKIPF.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="261c726f-338d-5618-8f6b-051b41a38c99")}catch{}})();var u=["id","title","status","type","priority","parent","updated_at"],E=["id","status","type","title"],p={list:"brief","list-all":"full","list-draft":"full","list-open":"brief","list-in-progress":"brief","list-blocked":"brief","list-closed":"brief","list-canceled":"full"},o=["tree_depth","tree_parent","tree_children","tree_title"];function f(e=[]){return[...new Set([...i,"body",...o,...e])].flatMap(t=>[t,`item.${t}`]).sort()}var m=["brief","standard","deep"],r=["body","linked","claim_state","children","schedule"],l=["linked.files","linked.tests","linked.docs"],c=["claim_state.claimed","claim_state.assignee","claim_state.last_claim","claim_state.last_release"],a=["schedule.deadline","schedule.start_at","schedule.end_at","schedule.location","schedule.reminders","schedule.events"];function T(e=[]){return[...[...new Set([...i,...e,"notes_count","tests_count","collection_counts"])].flatMap(s=>[s,`item.${s}`]),...r,...l,...c,...a].sort()}var I=["id","title","status","type","priority","updated_at","score","matched_fields"],d=["score","matched_fields","highlights"],n=["id","title","description","type","status","priority","tags","created_at","updated_at","deadline","assignee","author","estimated_minutes","acceptance_criteria","dependencies","comments","notes","learnings","reminders","events","files","tests","docs","close_reason","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result","affected_version","fixed_version","component","regression","customer_impact","definition_of_ready","order","rank","goal","objective","value","impact","outcome","why_now","plan"];function S(e=[]){let t=[...new Set(e)];return[...d,...n,...n.map(s=>`item.${s}`),...t,...t.map(s=>`item.${s}`)].sort()}export{u as a,E as b,p as c,f as d,m as e,T as f,I as g,S as h};
|
|
2
|
+
//# sourceMappingURL=chunk-533DCWPY.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{e as d}from"./chunk-
|
|
1
|
+
import{e as d}from"./chunk-OGGF2RBL.js";import{o as c,ya as w,za as m}from"./chunk-4YTDKIPF.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24688724-53cd-5375-ae7e-cfe098cd0dc8")}catch{}})();var _=new Map(c.map(e=>[e.toLowerCase(),e])),$=/^[A-Za-z][A-Za-z0-9_-]*$/;function g(e,t){if(!$.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function y(e){return _.get(e.trim().toLowerCase())}function A(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function I(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function b(e){let t=new Map;for(let o of e){let n=o.trim();if(n.length===0)continue;let i=n.toLowerCase();t.has(i)||t.set(i,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function S(e){let t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");g(t,"Type name");let o=y(t);if(o)throw new Error(`Cannot redefine built-in item type "${o}". Built-in types are reserved: ${c.join(", ")}.`);let n=e.description?.trim(),i=e.defaultStatus?.trim(),a=e.folder?.trim(),r=a&&a.length>0?m(a):void 0,s=b(e.aliases??[]);for(let l of s){g(l,"Alias");let f=y(l);if(f)throw new Error(`Alias "${l}" collides with built-in item type "${f}". Built-in types are reserved: ${c.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:i&&i.length>0?i:void 0,folder:r,aliases:s}}function x(e,t){let o=e.name.toLowerCase(),n=new Map;for(let a of t.definitions){if(typeof a.name!="string")continue;let r=a.name.trim();if(!(r.length===0||r.toLowerCase()===o)){n.set(r.toLowerCase(),r);for(let s of A(a.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),r)}}let i=n.get(o);if(i)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${i}".`);for(let a of e.aliases){let r=n.get(a.toLowerCase());if(r)throw new Error(`Alias "${a}" already maps to existing item type "${r}".`)}}function h(e,t){return typeof t=="string"&&t.trim().length>0?m(t).toLowerCase():w(e).toLowerCase()}function D(e,t,o){let n=e.name.toLowerCase(),i=h(e.name,e.folder),a=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${i}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(let s of t.definitions){if(typeof s.name!="string")continue;let l=s.name.trim();l.length===0||l.toLowerCase()===n||h(l,s.folder)===i&&a(l)}let r=o?.get(i);r!==void 0&&r.toLowerCase()!==n&&a(r)}function j(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:L(t)}}function L(e){let t=C(e);if(!t)return[];let o=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.name!="string"||i.name.trim().length===0||o.push(i)}return o}function C(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){let o=t.item_types;if(Array.isArray(o.definitions))return o.definitions}}function z(e,t){let o=t.name.toLowerCase(),n=e.definitions.slice(),i=n.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===o),a=i>=0?n[i]:void 0,r=b([...A(a?.aliases),...t.aliases]),s={...a,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),r.length>0?s.aliases=r:s.aliases!==void 0&&delete s.aliases,T(s,"description",t.description),T(s,"default_status",t.defaultStatus),i>=0?n[i]=s:n.push(s),n.sort((l,f)=>l.name.localeCompare(f.name)),{file:{definitions:n},definition:s,replaced:i>=0,...a&&typeof a.name=="string"?{previousName:a.name}:{}}}function F(e,t){let o=(t??"").trim();if(o.length===0)throw new Error("Type name must not be empty.");let n=y(o);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${c.join(", ")}.`);let i=o.toLowerCase(),a=e.definitions.slice(),r=a.findIndex(l=>typeof l.name=="string"&&l.name.trim().toLowerCase()===i);if(r<0)return{file:{definitions:a},removed:!1};let[s]=a.splice(r,1);return{file:{definitions:a},removed:!0,definition:s}}function T(e,t,o){let n=e;o!==void 0&&(n[t]=o)}function M(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
|
|
2
2
|
`}function E(e,t){let o=e.trim().length>0?e.trim():e,n=t?.trim()||".agents/pm/schema/types.json";return`To register a custom type, run: pm schema add-type "${I(o)}" (writes ${n}).`}function O(e,t,o){return`Invalid type value "${e}". Allowed: ${t.join(", ")}. ${E(e,o)}`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8c5aba7a-21a0-5d99-943a-877085caca57")}catch{}})();function v(e){return typeof e=="string"?e.trim().toLowerCase():""}function u(e,t){let o=d(e);return o.length===0?"":t?.alias_to_id?.get(o)??o}function U(e){let t=Array.isArray(e?.type_workflows)?e.type_workflows:[],o=new Map;for(let n of t){let i=v(n?.type);if(i.length===0||!Array.isArray(n?.allowed_transitions))continue;let a=n.allowed_transitions,r=o.get(i)??{pairs:[],denyAll:!1};a.length===0&&(r.denyAll=!0);for(let s of a){if(!Array.isArray(s)||s.length!==2)continue;let l=d(s[0]),f=d(s[1]);l.length===0||f.length===0||r.pairs.some(p=>p[0]===l&&p[1]===f)||r.pairs.push([l,f])}o.set(i,r)}return[...o.entries()].filter(([,n])=>n.pairs.length>0||n.denyAll).map(([n,i])=>({type:n,allowed_transitions:i.pairs})).sort((n,i)=>n.type.localeCompare(i.type))}function J(e){let t=v(e.typeName),o=e.typeWorkflows.find(r=>r.type===t);if(!o)return{allowed:!0,hasRule:!1,allowedTransitions:[]};let n=u(e.fromStatus,e.statusRegistry),i=u(e.toStatus,e.statusRegistry);return n.length>0&&n===i?{allowed:!0,hasRule:!0,allowedTransitions:o.allowed_transitions}:{allowed:o.allowed_transitions.some(r=>{let s=u(r[0],e.statusRegistry),l=u(r[1],e.statusRegistry);return s===n&&l===i}),hasRule:!0,allowedTransitions:o.allowed_transitions}}function W(e){return e.length===0?"(no transitions allowed)":e.map(t=>`${t[0]} -> ${t[1]}`).join(", ")}export{y as a,I as b,S as c,x as d,D as e,j as f,z as g,F as h,M as i,O as j,U as k,J as l,W as m};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-5SBU4QDC.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as $o,c as $r,d as Or,e as Yc,g as Xc,h as Do,i as Zc,j as en,k as tn,l as Qc,m as el,n as Po,o as rl,p as nn,q as rn,r as il,s as ol,t as No}from"./chunk-LFGTCEHX.js";import{e as Hr,f as Uo,h as zo}from"./chunk-CPQQIVDL.js";import{B as wl,C as jr,D as vl,E as jo,G as bl,H as kl,J as Sl,K as Ur,M as zr,a as Wc,g as To,i as qc}from"./chunk-C5NQVXKE.js";import{K as Cd}from"./chunk-D4FQV6TY.js";import{A as ld,E as Jo,F as ri,Ia as Sd,Ja as Ed,Na as xd,Oa as Rd,U as ii,Ua as Zo,V as dd,W as Vo,X as Hn,Z as Ko,a as Bo,b as td,ba as ud,ca as md,da as fd,ea as pd,fa as oi,g as nd,h as rd,ha as hd,i as id,ia as _d,ja as gd,ka as Mt,l as ni,la as yd,ma as un,mb as Td,na as wd,oa as Yo,p as Un,pa as mn,q as od,qa as vd,r as sd,ra as bd,s as zn,sa as kd,t as ad,ta as Xo,v as Go,w as cd}from"./chunk-CMCSUANO.js";import{a as Gc,b as Qt,c as Oo,d as Jc,e as Vc,f as ot,g as Dr,h as Kc,i as bt}from"./chunk-FNLAQJES.js";import{$ as Gr,Aa as jl,C as B,Ca as cn,Cb as ed,D as El,Da as jn,Db as Lt,Ea as Ul,Fa as Kr,Fb as ti,G as Se,Ga as Pt,H as Ho,Ha as me,Ia as Yr,Ja as zl,Jb as Wn,Ka as qo,La as Xr,Lb as si,Ma as ln,N as xl,Na as Zr,O as Wr,Oa as Hl,Pa as Ee,Qa as Wl,R as qr,Ra as T,S as Br,Sa as Qr,Sb as Id,U as Rl,V as Oe,Vb as Ad,X as kt,Y as Il,Z as Al,_ as Cl,_a as ql,aa as Tl,ab as Bl,bb as Gl,cb as St,db as Jl,eb as Vl,fa as $l,ga as Wo,ha as Jr,ia as sn,ib as Kl,jb as Yl,ka as Vr,kb as Xl,la as Ol,ma as Dl,oa as Pl,pb as ei,qa as Nl,rb as Zl,sa as Ll,tb as Q,ub as De,vb as Pe,wa as an,wb as Ql,xa as Ml,xb as dn,yb as st,za as Fl,zb as Nt}from"./chunk-N23WTRCC.js";import{b as Yt,e as de,f as $e,h as be,i as Je,m as ke,n as tl,o as Pr,q as nl}from"./chunk-7BUJABHB.js";import{$ as g,$a as Mc,Aa as q,Ab as Ge,Ac as pl,Fa as Fn,Ga as N,Ha as qe,Ia as Cr,Ic as H,Ja as Ot,Kb as Bc,La as Dc,Lc as Z,Ma as Tr,Nc as Fe,Oa as Pc,Ob as Nr,Oc as hl,Pb as sl,Pc as Mr,Qa as X,Qb as Lo,Rb as Mo,Rd as C,S as Ec,Sb as Fo,Sd as yl,T as xc,Ta as Nc,Td as on,Ub as al,Ud as Fr,V as Rc,Vb as cl,Vd as Dt,Wc as _l,X as Ic,Xa as Lc,Xc as Ve,Y as Ar,Ya as Xt,Yb as ll,Z as Ac,Zc as gl,_d as ce,a as Rr,aa as y,bb as Ao,d as Ir,dc as dl,ha as Cc,i as bc,ia as Mn,ja as P,ka as vt,l as kc,la as F,m as Sc,ma as V,na as ae,nb as Fc,ob as jc,pb as A,qa as fe,qb as Uc,ra as Te,rb as ve,sa as Tc,tb as Co,ub as zc,uc as ul,vb as Hc,w as Io,wb as Zt,wc as Lr,xc as ml,ya as $c,yb as Be,yc as fl,za as Oc}from"./chunk-GGDO6VBT.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="00d2200c-d308-51a6-acc4-8da90afaf6d6")}catch{}})();var L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},xe=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Ke=class extends TypeError{measurement_id;source_kind;field;check;constructor(t,n){super(t),this.name="AssuranceSourceResolutionError",this.measurement_id=n.measurement_id,this.source_kind=n.source_kind,this.field=n.field,this.check=n.check}};async function fn(e){try{return await e()}catch(t){throw t instanceof L?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function $d(e){try{return await e()}catch(t){throw t instanceof xe?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Z_}from"node:crypto";import Q_ 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]="b00dcab2-22c6-55b7-b93d-f6f5413d4b04")}catch{}})();var pn=1e3;(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]="00ad9b34-4feb-5812-8755-801869cce3ad")}catch{}})();var Dd=1,Ft=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],Qo=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],eg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],tg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,ai=30,ci=5e3,Pd=4,ng=50;function at(e,t){if(!tg.test(e))throw new L(`${t} must be a stable lowercase id`)}function rg(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function qn(e){let t=eg.filter(i=>e[i]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function ts(e,t){return A(e)===A(t)}function Nd(e,t){if(t.polarity==="equals")return ts(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let r=t.value;return e.every(i=>r.includes(i))}if(typeof e!="number")return!1;let n=t.value;return t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?e<=n:t.polarity==="floor"||t.polarity==="monotone_nondecreasing"?e>=n:e===0}function Ld(e){let t=qn(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>Nd(r.observed,t)===(r.expected==="pass"))}function ig(e,t){if(e.polarity!==t.polarity)return!0;if(typeof e.value=="number"&&typeof t.value=="number")return e.polarity==="ceiling"||e.polarity==="monotone_nonincreasing"?t.value>e.value:e.polarity==="floor"||e.polarity==="monotone_nondecreasing"?t.value<e.value:t.value!==e.value;if(e.polarity==="subset_of"){let n=e.value,r=t.value;return!Array.isArray(n)||!Array.isArray(r)||r.some(i=>!n.includes(i))}return!ts(e.value,t.value)}function og(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||A(e.scope)!==A(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return ig(qn(e),qn(t))||n[t.enforcement]<n[e.enforcement]||r}function sg(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new L("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,r=Number(t)+Number(n);if(e.field!==void 0&&r!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new L("items source equals/state requires field")}function ag(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new L("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(n=>n!==void 0).length>1)throw new L("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new L("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new L("dependency_kind source source_kind_state must be present or missing")}function cg(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new L("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new L("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new L("prose_edge_gap exemption selectors must not be empty")}}function ns(e){at(e.id,"measurement.id"),e.max_cost!==void 0&&rg(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new L(`measurement.source.kind must be one of ${Qo.join(", ")}`);let n=Reflect.get(t,"kind");if(!Qo.includes(n))throw new L(`measurement.source.kind must be one of ${Qo.join(", ")}`);let r=t;if(r.kind==="items"&&sg(r),r.kind==="dependency_kind"&&ag(r),r.kind==="prose_edge_gap"&&cg(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new L(`${r.kind} source requires field`);return r.kind==="provider"&&(at(r.provider,"provider source provider"),at(r.key,"provider source key")),e}function rs(e){if(at(e.id,"assertion.id"),at(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new L("assertion.owner_item_id is required");let t=qn(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new L(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new L("retired assertion requires retire_reason");e.scope.kind==="filter"&&at(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(r=>r.expected==="pass")||!n.some(r=>r.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!Ld(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function lg(e){if(!Array.isArray(e.allowed_providers))throw new L("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)at(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new L("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!Ft.includes(t))throw new L(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new L(`gate provider policy trigger ${t} is invalid`)}}function Md(e){if(at(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new L("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new L("gate requires at least one assertion");for(let t of e.assertion_ids)at(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${Ft.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!Ft.includes(t))throw new L(`gate trigger must be one of ${Ft.join(", ")}`);return e.provider_policy&&lg(e.provider_policy),e}function hn(e){if(e.version!==Dd)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(ns(r),t.has(`measurement:${r.id}`))throw new L(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(rs(r),t.has(`assertion:${r.id}`))throw new L(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){Md(r);let i=r.assertion_ids.filter(o=>!e.assertions.some(s=>s.id===o));if(i.length>0)throw new L(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new L(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of Fd(e))if(!n.has(r))throw new L(`${i.join(", ")} references missing measurement ${r}`);return e}function is(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)is(n,t)}function Fd(e){let t=new Map,n=(r,i)=>{let o=t.get(r)??[];o.push(i),t.set(r,o)};for(let r of e.assertions)n(r.measurement_id,`assertion ${r.id}`),r.scope.kind==="filter"&&n(r.scope.measurement_id,`assertion ${r.id} scope`);for(let r of e.measurements){if(r.source.kind!=="derived")continue;let i=[];is(r.source.expression,i);for(let o of i)n(o,`derived measurement ${r.id}`)}return t}function dg(e,t){let n=e.assertion_ids.flatMap(o=>{let s=t.assertions.find(a=>a.id===o);return[s.measurement_id,...s.scope.kind==="filter"?[s.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let o=n.pop();if(r.has(o))continue;r.add(o);let s=t.measurements.find(a=>a.id===o);s.source.kind==="provider"?i.add(s.source.provider):s.source.kind==="derived"&&is(s.source.expression,n)}return i}function Bn(){return{version:Dd,measurements:[],assertions:[],gates:[]}}function ug(e,t){let n=t.items.filter(r=>(e.statuses===void 0||e.statuses.includes(r.status))&&(e.types===void 0||e.types.includes(r.type))&&(e.tags===void 0||e.tags.every(i=>r.tags?.includes(i)))&&(e.field===void 0||(()=>{let i=r[e.field];if(e.state!==void 0){let o=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?o:!o}return ts(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function mg(e,t){return e.source_kind!==void 0?t?.toLowerCase()===e.source_kind.trim().toLowerCase():e.source_kind_prefix!==void 0?t?.toLowerCase().startsWith(e.source_kind_prefix.trim().toLowerCase())===!0:e.source_kind_state==="present"?t!==void 0&&t.length>0:e.source_kind_state==="missing"?t===void 0||t.length===0:!0}function fg(e,t){let n=[],r=Ao(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let o of i.dependencies??[]){let s=Ao(o.kind)??o.kind.trim().toLowerCase(),a=o.source_kind?.trim();s===r&&mg(e,a)&&n.push(`${i.id}->${o.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function pg(e){let t=[e.description,e.body].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);for(let n of["comments","notes","learnings"]){let r=e[n];if(Array.isArray(r)){for(let i of r)if(typeof i=="string")t.push(i);else if(typeof i=="object"&&i!==null){let o=Reflect.get(i,"text");typeof o=="string"&&t.push(o)}}}return t}function hg(e,t,n,r){return e.some(i=>i.holder_id.trim().toLowerCase()===t.toLowerCase()&&(i.target_id===void 0||i.target_id.trim().toLowerCase()===n.toLowerCase())&&(i.text_contains===void 0||r.toLowerCase().includes(i.text_contains.trim().toLowerCase())))}function es(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function _g(e){let t=new Map,n=new Set,r=[],i=/\b[a-z][a-z0-9]*-[a-z0-9]+\b/giu,o=0;for(let s of e){t.set(s.id.toLowerCase(),s.id);for(let a of s.dependencies??[])n.add(es(s.id,a.id));for(let a of[s.parent,s.blocked_by])typeof a=="string"&&n.add(es(s.id,a));for(let a of pg(s)){let c=[...a.matchAll(i)].map(l=>l[0]);o+=c.length,r.push({holder_id:s.id,segment:a,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:o}}function gg(e,t){let n=_g(t.items),r=new Map;for(let s of n.prose_mentions){let a=s.mentioned_ids.map(l=>n.canonical_ids.get(l.toLowerCase())).filter(l=>l!==void 0&&l!==s.holder_id),c=[...new Set(a)];for(let l of c){let d=es(s.holder_id,l);if(n.linked_pairs.has(d)||hg(e.exemptions??[],s.holder_id,l,s.segment))continue;let u=c.some(m=>m!==l);r.get(d)?.explicit===!0&&!u||r.set(d,{contributor:`${s.holder_id}->${l}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],o=i.map(s=>s.contributor).sort();return{value:o.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:o.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(s=>s.explicit).length,implicit_subject:i.filter(s=>!s.explicit).length}}}function yg(e,t){return{value:t.history.filter(r=>(e.op===void 0||r.op===e.op)&&(e.author===void 0||r.author===e.author)&&(e.harness===void 0||r.agent_harness===e.harness)&&(e.model===void 0||r.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function wg(e,t){let n=t.items.filter(r=>{let i=r[e.link],o=Array.isArray(i)&&i.length>0;return e.state==="present"?o:!o});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function vg(e,t){let n=e.source;return n.kind==="items"?ug(n,t):n.kind==="dependency_kind"?fg(n,t):n.kind==="prose_edge_gap"?gg(n,t):n.kind==="history"?yg(n,t):n.kind==="links"?wg(n,t):null}function jd(e,t){return e.reduce((n,r)=>({units:n.units+r.units,items_scanned:n.items_scanned+r.items_scanned,history_entries:n.history_entries+r.history_entries,provider_calls:n.provider_calls+r.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function bg(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,r)=>n+r,0);if(e==="subtract")return t.slice(1).reduce((n,r)=>n-r,t[0]);if(e==="multiply")return t.reduce((n,r)=>n*r,1);if(e==="divide"){if(t.slice(1).includes(0))throw new TypeError("derived divide cannot divide by zero");return t.slice(1).reduce((n,r)=>n/r,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function Ud(e,t,n){let r=new Array(e.length),i=0,o=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let s=i;i+=1,r[s]=await n(e[s],s)}});return await Promise.all(o),r}async function zd(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let s=n.find(l=>l.id===e.measurement);if(!s)throw new TypeError(`derived measurement references missing ${e.measurement}`);let a=await Hd(s,t,n,r,i);if(typeof a.value!="number")throw new TypeError(`derived measurement ${s.id} is not numeric`);let c=i.charged.has(s.id)?[]:[a.cost];return i.charged.add(s.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let o=await Ud(e.operands,Pd,s=>zd(s,t,n,r,i));return{value:bg(e.operator,o.map(s=>s.value)),costs:o.flatMap(s=>s.costs),population_size:Math.max(0,...o.map(s=>s.population_size)),contributors:[...new Set(o.flatMap(s=>s.contributors))]}}async function kg(e,t,n,r,i){ns(e);let o=Date.now(),s,a=[],c=0;if(e.source.kind==="derived"){let u=await zd(e.source.expression,t,n,[...r,e.id],i);s={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=vg(e,t);u!==null?s=u:(s=await t.external(e.source),c=1)}let l={units:s.cost,items_scanned:e.source.kind==="items"||e.source.kind==="dependency_kind"||e.source.kind==="prose_edge_gap"||e.source.kind==="links"?t.items.length:0,history_entries:e.source.kind==="history"?t.history.length:0,provider_calls:c,duration_ms:Date.now()-o},d=jd([...a,l],Date.now()-o);if(e.max_cost!==void 0&&d.units>e.max_cost)throw new xe(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${d.units}`);return{id:e.id,definition_fingerprint:`sha256:${Z_("sha256").update(A(e)).digest("hex")}`,value:s.value,population_size:s.population_size,cost:d,contributors:s.contributors??[],...s.partitions?{partitions:s.partitions}:{}}}function Hd(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let o=i.cache.get(e.id);if(o)return o;let s=kg(e,t,n,r,i).catch(a=>{if(a instanceof Ke&&a.measurement_id===void 0){let c={measurement_id:e.id,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}},l=new Ke(a.message,c);throw l.cause=a,l}throw a});return i.cache.set(e.id,s),s}async function os(e,t,n=[e]){return Hd(e,t,n,[],{cache:new Map,charged:new Set})}function Sg(e,t){return typeof e!="number"||typeof t.value!="number"?null:t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?t.value-e:(t.polarity==="floor"||t.polarity==="monotone_nondecreasing",e-t.value)}function Eg(e,t,n={}){rs(e);let r=qn(e),i=e.lifetime==="retire"&&n.owner_terminal===!0;return{assertion_id:e.id,measurement_id:e.measurement_id,measurement_definition_fingerprint:t.definition_fingerprint,scope:e.scope,population_size:t.population_size,observed:t.value,bound:r,distance:Sg(t.value,r),verdict:i?"retired":Nd(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:Ld(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function xg(e,t,n,r){let i=dg(e,t);if(i.size===0)return;let o=e.provider_policy,s=o?.triggers[r];if(!o||!s)throw new xe(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(o.allowed_providers),c={low:0,medium:1,high:2};for(let l of i){if(!a.has(l))throw new xe(`assurance gate ${e.id} refuses provider ${l}`);let d=n.provider_capabilities?.[l];if(!d)throw new xe(`assurance provider ${l} has no declared capabilities`);if(c[d.cost_class]>c[s.max_cost_class])throw new xe(`assurance gate ${e.id} refuses ${d.cost_class}-cost provider ${l} at trigger ${r}`);if(d.network&&!s.allow_network)throw new xe(`assurance gate ${e.id} refuses network provider ${l} at trigger ${r}`)}}async function Od(e,t,n,r,i){try{return await os(n,r,i)}catch(o){if(o instanceof Ke){let s=o.check?` check ${o.check}`:"",a=o.measurement_id??n.id,c=new xe(`assurance gate ${e} assertion ${t} measurement ${a} source ${o.source_kind}${s} field ${o.field} could not resolve: ${o.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:o.source_kind,field:o.field,...o.check?{check:o.check}:{}});throw c.cause=o,c}throw o}}async function Wd(e,t,n,r){hn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new xe(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new xe(`assurance gate ${e} does not declare trigger ${r.trigger}`);xg(i,t,n,r.trigger);let o=await Ud(i.assertion_ids,Pd,async c=>{let l=t.assertions.find(p=>p.id===c),d=t.measurements.find(p=>p.id===l.measurement_id),u=n;if(l.scope.kind==="active"){let p=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(_=>!p.has(_.status))}}else if(l.scope.kind==="filter"){let p=l.scope.measurement_id,_=t.measurements.find(v=>v.id===p),h=await Od(i.id,l.id,_,n,t.measurements),w=new Set(h.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(p=>p.id===l.owner_item_id),f=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return Eg(l,await Od(i.id,l.id,d,u,t.measurements),{owner_terminal:f})}),s=o.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=o.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:i.id,tree_id:n.tree_id,trigger:r.trigger,dry_run:r.dry_run===!0,evaluated_at:new Date().toISOString(),verdict:s?"block":a?"warn":"pass",exit_code:s?1:0,assertions:o,assertions_total:o.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:jd(o.map(c=>c.cost),Math.max(0,...o.map(c=>c.cost.duration_ms)))}}function li(e){return Q_.join(e,"assurance.json")}async function qd(e){let t=await V(li(e));return t===null?Bn():di(t)}function di(e){try{return hn(JSON.parse(e))}catch(t){throw new y("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",g.GENERIC_FAILURE,{code:"assurance_registry_invalid",reason:String(t),nextSteps:["Restore a valid assurance.json from version control or repair its declaration references.","Run pm assurance list measurement after the repair."]})}}function ui(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function Rg(e,t){e==="measurement"?ns(t):e==="assertion"?rs(t):Md(t)}async function Gn(e,t){let n=structuredClone(ui(await qd(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function ss(e,t,n){let r=ui(await qd(e),t).find(i=>i.id===n);if(!r)throw new TypeError(`assurance ${t} ${n} not found`);return structuredClone(r)}async function mi(e,t,n,r={}){Rg(t,n);let i=await T(e),o=B(r.author,i.author_default),s=await ln({pmRoot:e,filePath:li(e),op:`assurance:${t}:put`,author:o,message:r.message,lockTtlSeconds:ai,lockWaitMs:ci,mutate:a=>{let c=a===null?Bn():di(a),l=ui(c,t),d=l.findIndex(m=>m.id===n.id),u=d<0?"created":"updated";if(t==="assertion"&&d>=0&&og(l[d],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return d<0?l.push(structuredClone(n)):l[d]=structuredClone(n),hn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
1
|
+
import{a as $o,c as $r,d as Or,e as Yc,g as Xc,h as Do,i as Zc,j as en,k as tn,l as Qc,m as el,n as Po,o as rl,p as nn,q as rn,r as il,s as ol,t as No}from"./chunk-YBQTVE5S.js";import{e as Hr,f as Uo,h as zo}from"./chunk-PBJC2ZNA.js";import{B as wl,C as jr,D as vl,E as jo,G as bl,H as kl,J as Sl,K as Ur,M as zr,a as Wc,g as To,i as qc}from"./chunk-UACMCSCC.js";import{K as Cd}from"./chunk-MD7ADLME.js";import{A as ld,E as Jo,F as ri,Ia as Sd,Ja as Ed,Na as xd,Oa as Rd,U as ii,Ua as Zo,V as dd,W as Vo,X as Hn,Z as Ko,a as Bo,b as td,ba as ud,ca as md,da as fd,ea as pd,fa as oi,g as nd,h as rd,ha as hd,i as id,ia as _d,ja as gd,ka as Mt,l as ni,la as yd,ma as un,mb as Td,na as wd,oa as Yo,p as Un,pa as mn,q as od,qa as vd,r as sd,ra as bd,s as zn,sa as kd,t as ad,ta as Xo,v as Go,w as cd}from"./chunk-ZOE2NSJB.js";import{a as Gc,b as Qt,c as Oo,d as Jc,e as Vc,f as ot,g as Dr,h as Kc,i as bt}from"./chunk-5SBU4QDC.js";import{$ as Gr,$a as ql,Aa as jl,Ab as Nt,C as B,Ca as cn,D as El,Da as jn,Db as ed,Ea as Ul,Eb as Lt,Fa as Kr,G as Se,Ga as Pt,Gb as ti,H as Ho,Ha as me,Ia as Yr,Ja as zl,Ka as qo,Kb as Wn,La as Xr,Ma as ln,Mb as si,N as xl,Na as Zr,O as Wr,Oa as Hl,Qa as Ee,R as qr,Ra as Wl,S as Br,Sa as T,Ta as Qr,Tb as Id,U as Rl,V as Oe,Wb as Ad,X as kt,Y as Il,Z as Al,_ as Cl,aa as Tl,bb as Bl,cb as Gl,db as St,eb as Jl,fa as $l,fb as Vl,ga as Wo,ha as Jr,ia as sn,jb as Kl,ka as Vr,kb as Yl,la as Ol,lb as Xl,ma as Dl,oa as Pl,qa as Nl,qb as ei,sa as Ll,sb as Zl,ub as Q,vb as De,wa as an,wb as Pe,xa as Ml,xb as Ql,yb as dn,za as Fl,zb as st}from"./chunk-6C3CUU2G.js";import{b as Yt,e as de,f as $e,h as be,i as Je,m as ke,n as tl,o as Pr,q as nl}from"./chunk-OGGF2RBL.js";import{$ as g,$a as Mc,Aa as q,Ab as Ge,Ac as pl,Fa as Fn,Ga as N,Ha as qe,Ia as Cr,Ic as H,Ja as Ot,Kb as Bc,La as Dc,Lc as Z,Ma as Tr,Nc as Fe,Oa as Pc,Ob as Nr,Oc as hl,Pb as sl,Pc as Mr,Qa as X,Qb as Lo,Rb as Mo,Rd as C,S as Ec,Sb as Fo,Sd as yl,T as xc,Ta as Nc,Td as on,Ub as al,Ud as Fr,V as Rc,Vb as cl,Vd as Dt,Wc as _l,X as Ic,Xa as Lc,Xc as Ve,Y as Ar,Ya as Xt,Yb as ll,Z as Ac,Zc as gl,_d as ce,a as Rr,aa as y,bb as Ao,d as Ir,dc as dl,ha as Cc,i as bc,ia as Mn,ja as P,ka as vt,l as kc,la as F,m as Sc,ma as V,na as ae,nb as Fc,ob as jc,pb as A,qa as fe,qb as Uc,ra as Te,rb as ve,sa as Tc,tb as Co,ub as zc,uc as ul,vb as Hc,w as Io,wb as Zt,wc as Lr,xc as ml,ya as $c,yb as Be,yc as fl,za as Oc}from"./chunk-4YTDKIPF.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="00d2200c-d308-51a6-acc4-8da90afaf6d6")}catch{}})();var L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},xe=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Ke=class extends TypeError{measurement_id;source_kind;field;check;constructor(t,n){super(t),this.name="AssuranceSourceResolutionError",this.measurement_id=n.measurement_id,this.source_kind=n.source_kind,this.field=n.field,this.check=n.check}};async function fn(e){try{return await e()}catch(t){throw t instanceof L?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function $d(e){try{return await e()}catch(t){throw t instanceof xe?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Z_}from"node:crypto";import Q_ 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]="b00dcab2-22c6-55b7-b93d-f6f5413d4b04")}catch{}})();var pn=1e3;(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]="00ad9b34-4feb-5812-8755-801869cce3ad")}catch{}})();var Dd=1,Ft=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],Qo=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],eg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],tg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,ai=30,ci=5e3,Pd=4,ng=50;function at(e,t){if(!tg.test(e))throw new L(`${t} must be a stable lowercase id`)}function rg(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function qn(e){let t=eg.filter(i=>e[i]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function ts(e,t){return A(e)===A(t)}function Nd(e,t){if(t.polarity==="equals")return ts(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let r=t.value;return e.every(i=>r.includes(i))}if(typeof e!="number")return!1;let n=t.value;return t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?e<=n:t.polarity==="floor"||t.polarity==="monotone_nondecreasing"?e>=n:e===0}function Ld(e){let t=qn(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>Nd(r.observed,t)===(r.expected==="pass"))}function ig(e,t){if(e.polarity!==t.polarity)return!0;if(typeof e.value=="number"&&typeof t.value=="number")return e.polarity==="ceiling"||e.polarity==="monotone_nonincreasing"?t.value>e.value:e.polarity==="floor"||e.polarity==="monotone_nondecreasing"?t.value<e.value:t.value!==e.value;if(e.polarity==="subset_of"){let n=e.value,r=t.value;return!Array.isArray(n)||!Array.isArray(r)||r.some(i=>!n.includes(i))}return!ts(e.value,t.value)}function og(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||A(e.scope)!==A(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return ig(qn(e),qn(t))||n[t.enforcement]<n[e.enforcement]||r}function sg(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new L("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,r=Number(t)+Number(n);if(e.field!==void 0&&r!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new L("items source equals/state requires field")}function ag(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new L("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(n=>n!==void 0).length>1)throw new L("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new L("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new L("dependency_kind source source_kind_state must be present or missing")}function cg(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new L("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new L("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new L("prose_edge_gap exemption selectors must not be empty")}}function ns(e){at(e.id,"measurement.id"),e.max_cost!==void 0&&rg(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new L(`measurement.source.kind must be one of ${Qo.join(", ")}`);let n=Reflect.get(t,"kind");if(!Qo.includes(n))throw new L(`measurement.source.kind must be one of ${Qo.join(", ")}`);let r=t;if(r.kind==="items"&&sg(r),r.kind==="dependency_kind"&&ag(r),r.kind==="prose_edge_gap"&&cg(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new L(`${r.kind} source requires field`);return r.kind==="provider"&&(at(r.provider,"provider source provider"),at(r.key,"provider source key")),e}function rs(e){if(at(e.id,"assertion.id"),at(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new L("assertion.owner_item_id is required");let t=qn(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new L(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new L("retired assertion requires retire_reason");e.scope.kind==="filter"&&at(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(r=>r.expected==="pass")||!n.some(r=>r.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!Ld(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function lg(e){if(!Array.isArray(e.allowed_providers))throw new L("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)at(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new L("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!Ft.includes(t))throw new L(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new L(`gate provider policy trigger ${t} is invalid`)}}function Md(e){if(at(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new L("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new L("gate requires at least one assertion");for(let t of e.assertion_ids)at(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${Ft.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!Ft.includes(t))throw new L(`gate trigger must be one of ${Ft.join(", ")}`);return e.provider_policy&&lg(e.provider_policy),e}function hn(e){if(e.version!==Dd)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(ns(r),t.has(`measurement:${r.id}`))throw new L(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(rs(r),t.has(`assertion:${r.id}`))throw new L(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){Md(r);let i=r.assertion_ids.filter(o=>!e.assertions.some(s=>s.id===o));if(i.length>0)throw new L(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new L(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of Fd(e))if(!n.has(r))throw new L(`${i.join(", ")} references missing measurement ${r}`);return e}function is(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)is(n,t)}function Fd(e){let t=new Map,n=(r,i)=>{let o=t.get(r)??[];o.push(i),t.set(r,o)};for(let r of e.assertions)n(r.measurement_id,`assertion ${r.id}`),r.scope.kind==="filter"&&n(r.scope.measurement_id,`assertion ${r.id} scope`);for(let r of e.measurements){if(r.source.kind!=="derived")continue;let i=[];is(r.source.expression,i);for(let o of i)n(o,`derived measurement ${r.id}`)}return t}function dg(e,t){let n=e.assertion_ids.flatMap(o=>{let s=t.assertions.find(a=>a.id===o);return[s.measurement_id,...s.scope.kind==="filter"?[s.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let o=n.pop();if(r.has(o))continue;r.add(o);let s=t.measurements.find(a=>a.id===o);s.source.kind==="provider"?i.add(s.source.provider):s.source.kind==="derived"&&is(s.source.expression,n)}return i}function Bn(){return{version:Dd,measurements:[],assertions:[],gates:[]}}function ug(e,t){let n=t.items.filter(r=>(e.statuses===void 0||e.statuses.includes(r.status))&&(e.types===void 0||e.types.includes(r.type))&&(e.tags===void 0||e.tags.every(i=>r.tags?.includes(i)))&&(e.field===void 0||(()=>{let i=r[e.field];if(e.state!==void 0){let o=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?o:!o}return ts(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function mg(e,t){return e.source_kind!==void 0?t?.toLowerCase()===e.source_kind.trim().toLowerCase():e.source_kind_prefix!==void 0?t?.toLowerCase().startsWith(e.source_kind_prefix.trim().toLowerCase())===!0:e.source_kind_state==="present"?t!==void 0&&t.length>0:e.source_kind_state==="missing"?t===void 0||t.length===0:!0}function fg(e,t){let n=[],r=Ao(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let o of i.dependencies??[]){let s=Ao(o.kind)??o.kind.trim().toLowerCase(),a=o.source_kind?.trim();s===r&&mg(e,a)&&n.push(`${i.id}->${o.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function pg(e){let t=[e.description,e.body].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);for(let n of["comments","notes","learnings"]){let r=e[n];if(Array.isArray(r)){for(let i of r)if(typeof i=="string")t.push(i);else if(typeof i=="object"&&i!==null){let o=Reflect.get(i,"text");typeof o=="string"&&t.push(o)}}}return t}function hg(e,t,n,r){return e.some(i=>i.holder_id.trim().toLowerCase()===t.toLowerCase()&&(i.target_id===void 0||i.target_id.trim().toLowerCase()===n.toLowerCase())&&(i.text_contains===void 0||r.toLowerCase().includes(i.text_contains.trim().toLowerCase())))}function es(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function _g(e){let t=new Map,n=new Set,r=[],i=/\b[a-z][a-z0-9]*-[a-z0-9]+\b/giu,o=0;for(let s of e){t.set(s.id.toLowerCase(),s.id);for(let a of s.dependencies??[])n.add(es(s.id,a.id));for(let a of[s.parent,s.blocked_by])typeof a=="string"&&n.add(es(s.id,a));for(let a of pg(s)){let c=[...a.matchAll(i)].map(l=>l[0]);o+=c.length,r.push({holder_id:s.id,segment:a,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:o}}function gg(e,t){let n=_g(t.items),r=new Map;for(let s of n.prose_mentions){let a=s.mentioned_ids.map(l=>n.canonical_ids.get(l.toLowerCase())).filter(l=>l!==void 0&&l!==s.holder_id),c=[...new Set(a)];for(let l of c){let d=es(s.holder_id,l);if(n.linked_pairs.has(d)||hg(e.exemptions??[],s.holder_id,l,s.segment))continue;let u=c.some(m=>m!==l);r.get(d)?.explicit===!0&&!u||r.set(d,{contributor:`${s.holder_id}->${l}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],o=i.map(s=>s.contributor).sort();return{value:o.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:o.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(s=>s.explicit).length,implicit_subject:i.filter(s=>!s.explicit).length}}}function yg(e,t){return{value:t.history.filter(r=>(e.op===void 0||r.op===e.op)&&(e.author===void 0||r.author===e.author)&&(e.harness===void 0||r.agent_harness===e.harness)&&(e.model===void 0||r.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function wg(e,t){let n=t.items.filter(r=>{let i=r[e.link],o=Array.isArray(i)&&i.length>0;return e.state==="present"?o:!o});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function vg(e,t){let n=e.source;return n.kind==="items"?ug(n,t):n.kind==="dependency_kind"?fg(n,t):n.kind==="prose_edge_gap"?gg(n,t):n.kind==="history"?yg(n,t):n.kind==="links"?wg(n,t):null}function jd(e,t){return e.reduce((n,r)=>({units:n.units+r.units,items_scanned:n.items_scanned+r.items_scanned,history_entries:n.history_entries+r.history_entries,provider_calls:n.provider_calls+r.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function bg(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,r)=>n+r,0);if(e==="subtract")return t.slice(1).reduce((n,r)=>n-r,t[0]);if(e==="multiply")return t.reduce((n,r)=>n*r,1);if(e==="divide"){if(t.slice(1).includes(0))throw new TypeError("derived divide cannot divide by zero");return t.slice(1).reduce((n,r)=>n/r,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function Ud(e,t,n){let r=new Array(e.length),i=0,o=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let s=i;i+=1,r[s]=await n(e[s],s)}});return await Promise.all(o),r}async function zd(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let s=n.find(l=>l.id===e.measurement);if(!s)throw new TypeError(`derived measurement references missing ${e.measurement}`);let a=await Hd(s,t,n,r,i);if(typeof a.value!="number")throw new TypeError(`derived measurement ${s.id} is not numeric`);let c=i.charged.has(s.id)?[]:[a.cost];return i.charged.add(s.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let o=await Ud(e.operands,Pd,s=>zd(s,t,n,r,i));return{value:bg(e.operator,o.map(s=>s.value)),costs:o.flatMap(s=>s.costs),population_size:Math.max(0,...o.map(s=>s.population_size)),contributors:[...new Set(o.flatMap(s=>s.contributors))]}}async function kg(e,t,n,r,i){ns(e);let o=Date.now(),s,a=[],c=0;if(e.source.kind==="derived"){let u=await zd(e.source.expression,t,n,[...r,e.id],i);s={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=vg(e,t);u!==null?s=u:(s=await t.external(e.source),c=1)}let l={units:s.cost,items_scanned:e.source.kind==="items"||e.source.kind==="dependency_kind"||e.source.kind==="prose_edge_gap"||e.source.kind==="links"?t.items.length:0,history_entries:e.source.kind==="history"?t.history.length:0,provider_calls:c,duration_ms:Date.now()-o},d=jd([...a,l],Date.now()-o);if(e.max_cost!==void 0&&d.units>e.max_cost)throw new xe(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${d.units}`);return{id:e.id,definition_fingerprint:`sha256:${Z_("sha256").update(A(e)).digest("hex")}`,value:s.value,population_size:s.population_size,cost:d,contributors:s.contributors??[],...s.partitions?{partitions:s.partitions}:{}}}function Hd(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let o=i.cache.get(e.id);if(o)return o;let s=kg(e,t,n,r,i).catch(a=>{if(a instanceof Ke&&a.measurement_id===void 0){let c={measurement_id:e.id,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}},l=new Ke(a.message,c);throw l.cause=a,l}throw a});return i.cache.set(e.id,s),s}async function os(e,t,n=[e]){return Hd(e,t,n,[],{cache:new Map,charged:new Set})}function Sg(e,t){return typeof e!="number"||typeof t.value!="number"?null:t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?t.value-e:(t.polarity==="floor"||t.polarity==="monotone_nondecreasing",e-t.value)}function Eg(e,t,n={}){rs(e);let r=qn(e),i=e.lifetime==="retire"&&n.owner_terminal===!0;return{assertion_id:e.id,measurement_id:e.measurement_id,measurement_definition_fingerprint:t.definition_fingerprint,scope:e.scope,population_size:t.population_size,observed:t.value,bound:r,distance:Sg(t.value,r),verdict:i?"retired":Nd(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:Ld(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function xg(e,t,n,r){let i=dg(e,t);if(i.size===0)return;let o=e.provider_policy,s=o?.triggers[r];if(!o||!s)throw new xe(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(o.allowed_providers),c={low:0,medium:1,high:2};for(let l of i){if(!a.has(l))throw new xe(`assurance gate ${e.id} refuses provider ${l}`);let d=n.provider_capabilities?.[l];if(!d)throw new xe(`assurance provider ${l} has no declared capabilities`);if(c[d.cost_class]>c[s.max_cost_class])throw new xe(`assurance gate ${e.id} refuses ${d.cost_class}-cost provider ${l} at trigger ${r}`);if(d.network&&!s.allow_network)throw new xe(`assurance gate ${e.id} refuses network provider ${l} at trigger ${r}`)}}async function Od(e,t,n,r,i){try{return await os(n,r,i)}catch(o){if(o instanceof Ke){let s=o.check?` check ${o.check}`:"",a=o.measurement_id??n.id,c=new xe(`assurance gate ${e} assertion ${t} measurement ${a} source ${o.source_kind}${s} field ${o.field} could not resolve: ${o.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:o.source_kind,field:o.field,...o.check?{check:o.check}:{}});throw c.cause=o,c}throw o}}async function Wd(e,t,n,r){hn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new xe(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new xe(`assurance gate ${e} does not declare trigger ${r.trigger}`);xg(i,t,n,r.trigger);let o=await Ud(i.assertion_ids,Pd,async c=>{let l=t.assertions.find(p=>p.id===c),d=t.measurements.find(p=>p.id===l.measurement_id),u=n;if(l.scope.kind==="active"){let p=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(_=>!p.has(_.status))}}else if(l.scope.kind==="filter"){let p=l.scope.measurement_id,_=t.measurements.find(v=>v.id===p),h=await Od(i.id,l.id,_,n,t.measurements),w=new Set(h.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(p=>p.id===l.owner_item_id),f=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return Eg(l,await Od(i.id,l.id,d,u,t.measurements),{owner_terminal:f})}),s=o.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=o.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:i.id,tree_id:n.tree_id,trigger:r.trigger,dry_run:r.dry_run===!0,evaluated_at:new Date().toISOString(),verdict:s?"block":a?"warn":"pass",exit_code:s?1:0,assertions:o,assertions_total:o.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:jd(o.map(c=>c.cost),Math.max(0,...o.map(c=>c.cost.duration_ms)))}}function li(e){return Q_.join(e,"assurance.json")}async function qd(e){let t=await V(li(e));return t===null?Bn():di(t)}function di(e){try{return hn(JSON.parse(e))}catch(t){throw new y("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",g.GENERIC_FAILURE,{code:"assurance_registry_invalid",reason:String(t),nextSteps:["Restore a valid assurance.json from version control or repair its declaration references.","Run pm assurance list measurement after the repair."]})}}function ui(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function Rg(e,t){e==="measurement"?ns(t):e==="assertion"?rs(t):Md(t)}async function Gn(e,t){let n=structuredClone(ui(await qd(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function ss(e,t,n){let r=ui(await qd(e),t).find(i=>i.id===n);if(!r)throw new TypeError(`assurance ${t} ${n} not found`);return structuredClone(r)}async function mi(e,t,n,r={}){Rg(t,n);let i=await T(e),o=B(r.author,i.author_default),s=await ln({pmRoot:e,filePath:li(e),op:`assurance:${t}:put`,author:o,message:r.message,lockTtlSeconds:ai,lockWaitMs:ci,mutate:a=>{let c=a===null?Bn():di(a),l=ui(c,t),d=l.findIndex(m=>m.id===n.id),u=d<0?"created":"updated";if(t==="assertion"&&d>=0&&og(l[d],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return d<0?l.push(structuredClone(n)):l[d]=structuredClone(n),hn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
2
2
|
`,result:{changed:!0,action:u,kind:t,id:n.id}}}});return{...s.result,changed:s.changed}}async function as(e,t,n={}){let r=Bn();r.measurements=structuredClone(t.measurements),r.assertions=structuredClone(t.assertions),r.gates=structuredClone(t.gates),hn(r);let i=await T(e),o=B(n.author,i.author_default),s=await ln({pmRoot:e,filePath:li(e),op:"assurance:bundle:apply",author:o,message:n.message,lockTtlSeconds:ai,lockWaitMs:ci,mutate:a=>{let c=a===null?Bn():di(a),l=[],d=[],u=(m,f,p)=>{for(let _ of f){let h=m.find(w=>w.id===_.id);if(!h){m.push(structuredClone(_)),l.push(`${p}:${_.id}`);continue}if(A(h)!==A(_))throw new L(`assurance bundle refuses to replace divergent ${p} ${_.id}`);d.push(`${p}:${_.id}`)}};return u(c.measurements,r.measurements,"measurement"),u(c.assertions,r.assertions,"assertion"),u(c.gates,r.gates,"gate"),hn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
3
3
|
`,result:{changed:l.length>0,created_ids:l,unchanged_ids:d}}}});return{...s.result,changed:s.changed}}async function Bd(e,t,n,r={}){let i=await T(e),o=B(r.author,i.author_default),s=await ln({pmRoot:e,filePath:li(e),op:`assurance:${t}:remove`,author:o,message:r.message,lockTtlSeconds:ai,lockWaitMs:ci,mutate:a=>{let c=a===null?Bn():di(a);if(t==="measurement"){let u=Fd(c).get(n);if(u&&u.length>0)throw new L(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new L(`assurance assertion ${n} is referenced by gate`);let l=ui(c,t),d=l.findIndex(u=>u.id===n);if(d<0)throw new L(`assurance ${t} ${n} not found`);return l.splice(d,1),hn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
4
4
|
`,result:{changed:!0,action:"removed",kind:t,id:n}}}});return{...s.result,changed:s.changed}}async function Gd(e,t,n={}){if(t.dry_run)throw new TypeError("dry-run assurance verdicts are not persisted");let r=await T(e);await Xr({pmRoot:e,op:"assurance:gate:verdict",author:B(n.author,r.author_default),context:{assurance_verdict:t},message:n.message??`Assurance gate ${t.gate_id} returned ${t.verdict}`,lockTtlSeconds:ai,lockWaitMs:ci})}async function Jd(e,t={}){let n=t.limit??ng;if(!Number.isInteger(n)||n<1||n>pn)throw new TypeError(`assurance verdict limit must be an integer from 1 through ${pn}`);return(await Gr(Yr(e),me)).reverse().filter(i=>i.op==="assurance:gate:verdict").map(i=>i.context?.assurance_verdict).filter(i=>typeof i=="object"&&i!==null&&"gate_id"in i).filter(i=>t.gate_id===void 0||i.gate_id===t.gate_id).slice(0,n)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7470da18-4b85-5090-8ede-7de708b1f4ff")}catch{}})();var Jn=["software-delivery","research","agent-evaluation","operations"];function Vd(e,t,n,r,i){return{id:e,measurement_id:t,owner_item_id:n,scope:{kind:"active"},ceiling:r,lifetime:"hold",enforcement:i,negative_control:{cases:[{observed:r,expected:"pass"},{observed:r+1,expected:"fail"}]}}}function fi(e,t,n,r,i){let o=`preset-${e}`,s=i.map(c=>({id:`${o}-missing-${c}`,description:`Active items missing ${c} evidence.`,source:{kind:"links",link:c,state:"missing"}})),a=s.map(c=>Vd(`${c.id}-zero`,c.id,r,0,"warn"));return{id:e,title:t,description:n,declarations:{measurements:s,assertions:a,gates:[{id:`${o}-readiness`,description:n,assertion_ids:a.map(c=>c.id),triggers:["ci","scheduled"]}]}}}function pi(e,t){return e==="software-delivery"?fi(e,"Software delivery","Warn when active delivery work lacks executable tests or documentation.",t,["tests","docs"]):e==="research"?fi(e,"Research","Warn when active research work lacks reproducibility files or documentation.",t,["files","docs"]):e==="agent-evaluation"?fi(e,"Agent evaluation","Warn when active evaluation work lacks executable scenarios or recorded artifacts.",t,["tests","files"]):fi(e,"Operations","Warn when active operational work lacks runbook documentation or repair evidence.",t,["docs","files"])}function Kd(e,t,n,r={}){return as(e,pi(t,n).declarations,r)}async function Yd(e,t){let n=new Set(e.terminal_statuses??["closed","canceled"]),r={...e,items:e.items.filter(o=>!n.has(o.status))};return await Promise.all(["files","tests","docs"].map(async o=>{let s={id:`derived-active-missing-${o}`,description:`Observed active items missing ${o} evidence.`,source:{kind:"links",link:o,state:"missing"}},c=(await os(s,r)).value,l=Vd(`${s.id}-ceiling`,s.id,t,c,"observe"),d=`active-missing-${o}`;return{id:d,population_size:r.items.length,scope:{kind:"active"},observed:c,declarations:{measurements:[s],assertions:[l],gates:[{id:`derived-${d}`,description:`Observe the accepted ${o} evidence baseline.`,assertion_ids:[l.id],triggers:["ci","scheduled"]}]}}}))}function Xd(e,t,n={}){return as(e,{measurements:t.flatMap(r=>r.declarations.measurements),assertions:t.flatMap(r=>r.declarations.assertions),gates:t.flatMap(r=>r.declarations.gates)},n)}async function Zd(e,t,n,r={}){let i=t.enforcement==="observe"?"warn":"block";if(t.enforcement==="block"||n!==i)throw new TypeError(`assurance assertion ${t.id} promotion must be ${t.enforcement} -> ${i}`);return mi(e,"assertion",{...t,enforcement:n},{...r,message:r.message??`Promote assurance assertion ${t.id} from ${t.enforcement} to ${n}`})}import tu from"node:fs/promises";import{createRequire as Ig}from"node:module";import Re 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]="a0014621-9e3d-5620-8f36-081811054843")}catch{}})();function Qd(e,t){let n=Re.relative(t,e);if(n.length>0&&n!==".."&&!n.startsWith(`..${Re.sep}`)&&!Re.isAbsolute(n))return n.split(Re.sep).join("/");let r=Re.resolve(e),i=0xcbf29ce484222325n;for(let s=0;s<r.length;s+=1)i^=BigInt(r.charCodeAt(s)),i=BigInt.asUintN(64,i*0x100000001b3n);return`<external>/${i.toString(16).padStart(16,"0")}/${Re.basename(Re.dirname(e))}/package.json`}function Ag(e){return e.includes(`${Re.sep}.pnpm${Re.sep}`)?"pnpm":e.includes(`${Re.sep}node_modules${Re.sep}`)?"npm":"other"}async function eu(e){try{let t=JSON.parse(await tu.readFile(e,"utf8"));return t.name==="@unbrained/pm-cli"&&typeof t.version=="string"&&t.version.trim().length>0?t.version.trim():void 0}catch{return}}async function cs(e){try{return await tu.realpath(e)}catch{return Re.resolve(e)}}async function nu(e,t,n=Te(import.meta.url,["../../.."])){let r=await cs(t),i=await cs(Re.join(n,"package.json")),o=await eu(i),s=new Map;o!==void 0&&s.set(i,{version:o,path:Qd(i,r),layout:"host",consumers:["pm-cli-host"]});for(let l of e)try{let d=Ig(l.entry_path).resolve("@unbrained/pm-cli/package.json"),u=await cs(d),m=await eu(u);if(m===void 0)continue;let f=u,p=s.get(f);if(p){p.consumers.includes(l.name)||(p.consumers.push(l.name),p.consumers.sort((_,h)=>_.localeCompare(h)));continue}s.set(f,{version:m,path:Qd(u,r),layout:Ag(u),consumers:[l.name]})}catch{}let a=[...s.values()].sort((l,d)=>l.path.localeCompare(d.path)),c=o===void 0?[]:a.filter(l=>l.version!==o);return{host_version:o??null,copies:a,mismatches:c,warnings:c.map(l=>`extension_host_pm_cli_version_skew:${o}:${l.version}:${l.consumers.join("+")}`)}}import{createHash as pu}from"node:crypto";import Vn from"node:fs/promises";import Kn from"node:path";import{Option as UC}from"commander";(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]="7ffd5046-9154-52e7-94ce-192b07b8ceae")}catch{}})();function Cg(e,t){let n=[],r=new Set;for(let i of t.keys){if(!Object.hasOwn(e,i))continue;let o=e[i];if(o!=null){if(typeof o=="string"){n.push(o);continue}if(!Array.isArray(o)||!o.every(s=>typeof s=="string"))return;r.has(o)||(r.add(o),n.push(...o))}}return n.length>0?n.join("; "):void 0}function hi(e,t){return e.find(r=>r.target===t)??{target:t,keys:[t]}}function j(e,t){return e[t]===!0?!0:void 0}function ct(e,t){return e[t]===!1?!0:void 0}function ru(e,t){return t.some(n=>e[n]===!0)?!0:void 0}function iu(e,t){for(let[n,r]of Object.entries(t))n==="__proto__"||n==="constructor"||n==="prototype"||Object.hasOwn(e,n)||(e[n]=r)}function ou(e){let t=i=>To(e,hi(Hr,i)),n=i=>qc(e,hi(Uo,i)),r={title:t("title"),description:t("description"),body:t("body"),status:t("status"),closeReason:t("closeReason"),priority:t("priority"),type:t("type"),tags:t("tags"),addTags:n("addTags"),removeTags:n("removeTags"),deadline:t("deadline"),estimatedMinutes:t("estimatedMinutes"),acceptanceCriteria:Cg(e,hi(Uo,"acceptanceCriteria")),addAc:n("addAc"),removeAc:n("removeAc"),definitionOfReady:t("definitionOfReady"),order:t("order"),rank:t("rank"),goal:t("goal"),objective:t("objective"),value:t("value"),impact:t("impact"),outcome:t("outcome"),whyNow:t("whyNow"),author:t("author"),message:t("message"),force:!!e.force,ownershipMetadataBypass:e.ownershipMetadataBypass===!0?!0:void 0,ownershipDependencyBypass:e.ownershipDependencyBypass===!0?!0:void 0,assignee:t("assignee"),parent:t("parent"),allowUnresolvedDeps:ru(e,["allowUnresolvedDeps","allow_unresolved_deps"])===!0,reviewer:t("reviewer"),risk:t("risk"),confidence:t("confidence"),sprint:t("sprint"),release:t("release"),blockedBy:t("blockedBy"),blockedReason:t("blockedReason"),unblockNote:t("unblockNote"),reporter:t("reporter"),severity:t("severity"),environment:t("environment"),reproSteps:t("reproSteps"),resolution:t("resolution"),expectedResult:t("expectedResult"),actualResult:t("actualResult"),affectedVersion:t("affectedVersion"),fixedVersion:t("fixedVersion"),component:t("component"),regression:e.regression===!0?"true":t("regression"),customerImpact:t("customerImpact"),dep:n("dep"),depRemove:n("depRemove"),replaceDeps:j(e,"replaceDeps"),replaceTests:j(e,"replaceTests"),replaceFiles:j(e,"replaceFiles"),replaceDocs:j(e,"replaceDocs"),comment:n("comment"),note:n("note"),learning:n("learning"),file:n("file"),test:n("test"),doc:n("doc"),reminder:n("reminder"),event:n("event"),typeOption:n("typeOption"),field:n("field"),unset:n("unset"),clearDeps:j(e,"clearDeps"),clearComments:j(e,"clearComments"),clearNotes:j(e,"clearNotes"),clearLearnings:j(e,"clearLearnings"),clearFiles:j(e,"clearFiles"),clearTests:j(e,"clearTests"),clearDocs:j(e,"clearDocs"),clearReminders:j(e,"clearReminders"),clearEvents:j(e,"clearEvents"),clearTypeOptions:j(e,"clearTypeOptions")};return iu(r,e),r}function te(e,t){let n=hi(Wc,t),r=To(e,n);if(r!==void 0)return r;for(let i of n.keys){let o=e[i];if(Array.isArray(o)){let s=o.filter(a=>typeof a=="string");if(s.length>0)return s.join(",")}if(t==="ids"&&typeof o=="string")return o;if(typeof o=="number"&&Number.isFinite(o))return String(o)}}function Tg(e){let t=j(e,"filterFilesMissing"),n=j(e,"filterDocsMissing");return{filterReviewerMissing:j(e,"filterReviewerMissing"),filterRiskMissing:j(e,"filterRiskMissing"),filterConfidenceMissing:j(e,"filterConfidenceMissing"),filterSprintMissing:j(e,"filterSprintMissing"),filterReleaseMissing:j(e,"filterReleaseMissing"),hasNotes:j(e,"hasNotes"),hasLearnings:j(e,"hasLearnings"),hasFiles:j(e,"hasFiles"),hasDocs:j(e,"hasDocs"),hasTests:j(e,"hasTests"),hasComments:j(e,"hasComments"),hasDeps:j(e,"hasDeps"),hasBody:j(e,"hasBody"),hasLinkedCommand:j(e,"hasLinkedCommand"),noNotes:ct(e,"notes"),noLearnings:ct(e,"learnings"),noFiles:ct(e,"files")??t,filterFilesMissing:t,noDocs:ct(e,"docs")??n,filterDocsMissing:n,noTests:ct(e,"tests"),noComments:ct(e,"comments"),noDeps:ct(e,"deps"),emptyBody:j(e,"emptyBody"),noLinkedCommand:ct(e,"linkedCommand")}}function su(e){let t={status:te(e,"status"),type:te(e,"type"),tag:te(e,"tag"),priority:te(e,"priority"),deadlineBefore:te(e,"deadlineBefore"),deadlineAfter:te(e,"deadlineAfter"),updatedAfter:te(e,"updatedAfter"),updatedBefore:te(e,"updatedBefore"),createdAfter:te(e,"createdAfter"),createdBefore:te(e,"createdBefore"),today:j(e,"today"),recent:j(e,"recent"),ids:te(e,"ids"),assignee:te(e,"assignee"),assigneeFilter:te(e,"assigneeFilter"),parent:te(e,"parent"),sprint:te(e,"sprint"),release:te(e,"release"),limit:te(e,"limit"),offset:te(e,"offset"),noTruncate:ct(e,"truncate"),includeBody:j(e,"includeBody"),strictRead:j(e,"strictRead"),compact:j(e,"compact"),brief:j(e,"brief"),full:j(e,"full"),fields:te(e,"fields"),sort:te(e,"sort"),order:te(e,"order"),tree:j(e,"tree"),treeDepth:te(e,"treeDepth"),filterAcMissing:j(e,"filterAcMissing"),filterEstimatesMissing:ru(e,["filterEstimatesMissing","filterEstimateMissing"]),filterResolutionMissing:j(e,"filterResolutionMissing"),filterMetadataMissing:j(e,"filterMetadataMissing"),...Tg(e)};return iu(t,e),t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fb87ff0c-88c8-52f9-9dc3-f37fec674425")}catch{}})();var $g=Symbol("pm.mcp-mutation-transport"),Og=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function gi(e){return $g in e}function yi(e,t){return gi(e)?ad(t):Go(e,t)}function ZC(e,t,n=[]){let r=Go(e,{...e,...t});for(let i of n)Reflect.deleteProperty(r,i);return r}function $(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n:void 0}function ie(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0?n:void 0:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function QC(e,t){let n=e[t];return typeof n=="string"?n:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function _n(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function us(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new y(`${t} must be a finite integer.`,g.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let n=Number(e);if(!Number.isInteger(n))throw new y(`${t} must be a finite integer.`,g.USAGE);return n}}function eT(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:$(e,"limit")??$(t,"limit")}function tT(e){let t=$(e,"outputFormat");return{json:!0,quiet:!0,author:$(e,"author"),path:$(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:$(e,"outputInclude"),outputLimit:ie(e,"outputLimit"),outputBudget:ie(e,"outputBudget"),outputSession:$(e,"outputSession"),outputCursor:$(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var Dg=new Set(["tags","blockedBy","blocked_by","skills","fields"]),cu=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),Pg=new Set([...cu].filter(e=>e!=="file")),Ng=new Set(["files","files-discover","docs","test","test-all"]),lu=new Set(["comments","notes","learnings"]);function Lg(e,t){if(!(!lu.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new y(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,g.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var Mg=new Set(["claim","release","start-task","pause-task","close-task"]),Fg={"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable"],release:["pause"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun"],package:["dryRun"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},jg=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function du(e,t=""){let n={},r=Ng.has(t),i=t==="files"||t==="files-discover"||t==="docs",o=lu.has(t)?Pg:cu;for(let[s,a]of Object.entries(e)){if(Array.isArray(a)&&Dg.has(s)){n[s]=a.join(",");continue}if(s==="note"&&i){n[s]=a;continue}if(typeof a=="string"&&o.has(s)){n[s]=[a];continue}if(typeof a=="string"&&r&&(s==="add"||s==="remove")){n[s]=[a];continue}n[s]=a}return n}function Ug(e,t,n){let r=$(e,"author");return r!==void 0?r:n!==void 0&&Mg.has(n)?$(e,"assignee")??$(t,"assignee"):void 0}function zg(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function nT(e,t){let n=_n(e.options)?e.options:void 0,r=Lc(e.options),i={},o=c=>{r[c]!==void 0||e[c]===void 0||(i[c]=e[c])};for(let c of Fg[t??""]??[])o(c);for(let c of jg)o(c);t!==void 0&&gi(e)&&Lg(t,r);let s=du({...i,...r},t);if(t==="history-attest"&&gi(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new y("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",g.USAGE);let a=gi(e)?e:n??e;return yi(a,zg(s,Ug(e,s,t)))}function rT(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function iT(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function Hg(e){let t=[],n=!0;for(let r of e.trim().toLowerCase()){if(r>="a"&&r<="z"||r>="0"&&r<="9"){t.push(r),n=!1;continue}n||(t.push("-"),n=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function oT(e){return!Og.has(Hg(e))}function sT(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function ms(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function aT(e,t){let n=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),r={};for(let[o,s]of Object.entries(e))n.has(o)||(r[o]=s);let i={...r,...t};return delete i.args,i}function cT(e,t){let n=yi(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:n}}function ds(e){return{type:ie(e,"filterType"),tag:ie(e,"filterTag"),priority:ie(e,"filterPriority"),deadlineBefore:ie(e,"filterDeadlineBefore"),deadlineAfter:ie(e,"filterDeadlineAfter"),updatedAfter:ie(e,"filterUpdatedAfter"),updatedBefore:ie(e,"filterUpdatedBefore"),createdAfter:ie(e,"filterCreatedAfter"),createdBefore:ie(e,"filterCreatedBefore"),ids:Jo(e.ids),assignee:ie(e,"filterAssignee"),assigneeFilter:ie(e,"filterAssigneeFilter")??ie(e,"filterAssignee_filter"),parent:ie(e,"filterParent"),sprint:ie(e,"filterSprint"),release:ie(e,"filterRelease"),limit:ie(e,"limit"),offset:ie(e,"offset")}}function ls(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return ms(e)}function _i(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function lT(e){let t=ls(e.kind),n=ls(e.exemptIsolate),r=ls(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:_i(e.maxDepth),limit:_i(e.limit),after:$(e,"after"),direction:$(e,"direction"),maxPaths:_i(e.maxPaths),sample:_i(e.sample),...n===void 0?{}:{exemptIsolate:n},...r===void 0?{}:{exemptIsolateType:r},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function uu(e){let t=su(e);return e.ids!==void 0&&(t.ids=Jo(e.ids)),t}function dT(e){return{status:$(e,"filterStatus"),list:_n(e.list)?uu(e.list):ds(e),reason:$(e,"reason"),resolution:$(e,"resolution"),expectedResult:$(e,"expectedResult")??$(e,"expected_result")??$(e,"expected"),actualResult:$(e,"actualResult")??$(e,"actual_result")??$(e,"actual"),validateClose:$(e,"validateClose")??$(e,"validate_close"),author:$(e,"author"),message:$(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:$(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var Wg=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function au(e){let t={};for(let[n,r]of Object.entries(e))Wg.has(n)||(t[n]=r);return mu(t)}function mu(e){let t=du(e,"update-many");for(let n of Hr)for(let r of n.keys){let i=t[r];typeof i=="number"&&Number.isFinite(i)&&(t[r]=String(i))}return ou(t)}function uT(e){if(_n(e.list)||_n(e.update)){let t=_n(e.update)?e.update:au(e),n=yi(e,mu(t));return{status:ie(e,"filterStatus"),list:_n(e.list)?uu(e.list):ds(e),update:cd(t,n),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:$(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}return{status:ie(e,"filterStatus"),list:ds(e),update:yi(e,au(e)),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:$(e,"rollback"),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fd8c4c35-98bb-5f3b-927d-8696125af703")}catch{}})();function Ne(e,t){throw new y(e,g.USAGE,t)}var qg="2026-07-15T06:22:12.276Z",Bg=Date.parse(qg),Gg=[["attributed","attributed"],["legacy_unknown","actionable_unknown"]],fu=e=>typeof e=="string"?e:"",hu=e=>{let t=e??{},n=fu(t.author).trim().toLowerCase(),r=Number(["","unknown"].includes(n)),i=+(Date.parse(fu(t.ts))>=Bg);return Gg[r][i]};function _u(e,t,n=20,r=new Set,i=!1){let o=[],s=[],a={legacy_unknown:0,actionable_unknown:0},c=Math.max(0,n),l=0,d=0,u=0;for(let[m,f]of t.split(/\r?\n/).entries()){let p;try{p=JSON.parse(f)}catch{continue}l+=1;let _=hu(p);if(_!=="attributed"){if(d+=1,_==="actionable_unknown"&&r.has(`${e}:${m+1}`)){u+=1;continue}a[_]+=1,i&&_==="actionable_unknown"&&s.push({item_id:e,line:m+1}),o.length<c&&o.push({item_id:e,line:m+1})}}return{checked_events:l,unknown_event_count:d,legacy_unknown_event_count:a.legacy_unknown,actionable_unknown_event_count:a.actionable_unknown,acknowledged_actionable_event_count:u,samples:o,samples_truncated:a.legacy_unknown+a.actionable_unknown>o.length,actionable_events:s}}var bT=(e,t,n=20,r=new Set)=>_u(e,t,n,r);function gu(e){let t=new Set;for(let n of e.split(/\r?\n/)){let r;try{r=JSON.parse(n)}catch{continue}let o=(typeof r=="object"&&r!==null&&typeof r.context=="object"&&r.context!==null?r.context:{}).author_acknowledgment;if(!(typeof o!="object"||o===null||!Array.isArray(o.events)))for(let s of o.events)typeof s=="object"&&s!==null&&typeof s.item_id=="string"&&Number.isSafeInteger(s.line)&&t.add(`${s.item_id}:${String(s.line)}`)}return t}var Yn=async(e,t=20,n=!1)=>{let r=Kn.join(e,"history"),i;try{i=(await Vn.readdir(r)).filter(w=>w.endsWith(".jsonl")).sort((w,v)=>w.localeCompare(v))}catch{i=[]}let o=new Set,s=[],a=[],c=0,l=0,d=0,u=0,m=0,f=0,p="_workspace.jsonl",_=new Set;if(i.includes(p))try{_=gu(await Vn.readFile(Kn.join(r,p),"utf8"))}catch{_=new Set}for(let w of i){let v;try{v=await Vn.readFile(Kn.join(r,w),"utf8")}catch{continue}let k=w.slice(0,-6),S=_u(k,v,t-s.length,_,n);c+=1,l+=S.checked_events,d+=S.unknown_event_count,u+=S.legacy_unknown_event_count,m+=S.actionable_unknown_event_count,f+=S.acknowledged_actionable_event_count,S.unknown_event_count>0&&o.add(k),s.push(...S.samples),n&&a.push(...S.actionable_events)}let h=u+m;return{checked_streams:c,checked_events:l,unknown_event_count:d,legacy_unknown_event_count:u,actionable_unknown_event_count:m,acknowledged_actionable_event_count:f,affected_item_ids:[...o].sort((w,v)=>w.localeCompare(v)),samples:s,samples_truncated:h>s.length,...n?{actionable_events:a}:{}}};function Jg(e){return[...new Map(e.map(t=>[`${t.item_id}:${t.line}`,{item_id:t.item_id,line:t.line}])).values()].sort((t,n)=>t.item_id.localeCompare(n.item_id)||t.line-n.line)}async function Vg(e){try{return gu(await Vn.readFile(Kn.join(e,"history","_workspace.jsonl"),"utf8"))}catch{return new Set}}function Kg(e){return(e.item_id===me||/^[a-z0-9][a-z0-9-]*$/iu.test(e.item_id))&&Number.isSafeInteger(e.line)&&e.line>=1}function Yg(e,t,n){let r=n[e.line-1]??"",i;try{i=JSON.parse(r)}catch{Ne(`Unknown-author acknowledgment target ${e.item_id}:${e.line} is not readable.`,{code:"history_author_acknowledge_target_unreadable"})}return hu(i)!=="actionable_unknown"&&Ne(`Author acknowledgment target ${e.item_id}:${e.line} is not an actionable unknown-author event.`,{code:"history_author_acknowledge_target_not_actionable"}),{...e,source_event_hash:pu("sha256").update(r).digest("hex"),disposition:t.has(`${e.item_id}:${e.line}`)?"already_acknowledged":"actionable"}}async function yu(e,t,n){let r=t.events??[],i=+(t.all_actionable===!0)+ +(r.length>0);i===0&&Ne("Specify exactly one selector: events or all_actionable.",{code:"history_author_acknowledge_selector_required"}),i>1&&Ne("Author acknowledgment accepts either explicit events or all_actionable, not both.",{code:"history_author_acknowledge_selector_conflict"}),(!Number.isSafeInteger(n)||n<0)&&Ne("Author acknowledgment coordinate_limit must be a non-negative integer.",{code:"history_author_acknowledge_preview_limit_invalid"});let o=Jg(t.all_actionable===!0?(await Yn(e,0,!0)).actionable_events:r),s=await Vg(e),a=new Map;for(let m of o)if(Kg(m)||Ne(`Unknown-author acknowledgment target ${m.item_id}:${m.line} is not readable.`,{code:"history_author_acknowledge_target_unreadable"}),!a.has(m.item_id))try{a.set(m.item_id,(await Vn.readFile(Kn.join(e,"history",`${m.item_id}.jsonl`),"utf8")).split(/\r?\n/u))}catch{Ne(`Unknown-author acknowledgment target ${m.item_id}:${m.line} is not readable.`,{code:"history_author_acknowledge_target_unreadable"})}let c=o.map(m=>Yg(m,s,a.get(m.item_id))),l=t.all_actionable===!0?"all_actionable":"events",d=pu("sha256").update(JSON.stringify({version:1,selection:l,coordinates:c})).digest("hex"),u=c.filter(({disposition:m})=>m==="actionable").length;return{plan:{selection:{kind:l},selected_count:c.length,actionable_count:u,already_acknowledged_count:c.length-u,omitted_count:Math.max(0,c.length-n),coordinates:c.slice(0,n),plan_fingerprint:d},completeCoordinates:c}}async function kT(e,t,n=50){return(await yu(e,t,n)).plan}function Xg(e,t){let n=e.length>0;return n&&t&&Ne("Specify exactly one selector: repeat --event or pass --all-actionable.",{code:"history_author_acknowledge_selector_conflict",required:"Exactly one of --event or --all-actionable",examples:['pm history-author-acknowledge --event pm-a1b2:4 --attributed-author agent --reviewer maintainer --reason "Verified provenance"','pm history-author-acknowledge --all-actionable --attributed-author import-agent --reviewer maintainer --reason "Reviewed the complete actionable set"']}),!n&&!t&&Ne("Specify exactly one selector: repeat --event or pass --all-actionable.",{code:"history_author_acknowledge_selector_required",required:"Exactly one of --event or --all-actionable",examples:['pm history-author-acknowledge --event pm-a1b2:4 --attributed-author agent --reviewer maintainer --reason "Verified provenance"','pm history-author-acknowledge --all-actionable --attributed-author import-agent --reviewer maintainer --reason "Reviewed the complete actionable set"']}),{events:Zg(e),all_actionable:t}}function Zg(e){return e.map(t=>{let n=t.lastIndexOf(":"),r=t.slice(0,n).trim(),i=Number(t.slice(n+1)),o=r===me||/^[a-z0-9][a-z0-9-]*$/iu.test(r);return(n<1||!o||!Number.isSafeInteger(i)||i<1)&&Ne(`history-author-acknowledge --event expects <item-id>:<one-based-line>, received "${t}".`,{code:"history_author_acknowledge_target_unreadable"}),{item_id:r,line:i}})}function ST(e,t){let n=Xg(ms(t.historyEvent),t.allActionable===!0||t.all_actionable===!0);return Qg(e,{events:n.events,all_actionable:n.all_actionable,dry_run:t.dryRun===!0||t.dry_run===!0,plan_fingerprint:$(t,"planFingerprint")??$(t,"plan_fingerprint"),coordinate_limit:typeof t.limit=="number"?t.limit:typeof t.limit=="string"?Number(t.limit):void 0,attributed_author:$(t,"attributedAuthor")??$(t,"attributed_author")??void 0,reviewer:$(t,"reviewer"),reason:$(t,"reason")})}async function Qg(e,t){let n=t.reviewer?.trim()??"",r=t.attributed_author?.trim()??"",i=t.reason?.trim()??"",o=await yu(e,t,t.coordinate_limit??50);if(t.dry_run===!0)return{dry_run:!0,mutated:!1,acknowledged:0,outcome:"preview",exit_code:g.SUCCESS,plan:o.plan};if([n.length>0,n.toLowerCase()!=="unknown",r.length>0,r.toLowerCase()!=="unknown",i.length>0].includes(!1)&&Ne("Author acknowledgment requires events, reviewer, attributed_author, and reason.",{code:"history_author_acknowledge_required_values_missing"}),t.plan_fingerprint?.trim()||Ne("Author acknowledgment apply requires plan_fingerprint from a fresh dry-run preview.",{code:"history_author_acknowledge_plan_fingerprint_required",recovery:{suggested_retry:"Rerun history-author-acknowledge with --dry-run, then pass --plan-fingerprint <value>."}}),t.plan_fingerprint.trim()!==o.plan.plan_fingerprint)throw new y("Author acknowledgment selection changed after preview; no history was mutated.",g.CONFLICT,{code:"history_author_acknowledge_plan_conflict",recovery:{suggested_retry:"Rerun history-author-acknowledge with --dry-run and apply the fresh plan_fingerprint."}});let a=o.completeCoordinates.filter(({disposition:u})=>o.plan.selection.kind==="events"||u==="actionable").map(({item_id:u,line:m})=>({item_id:u,line:m}));if(a.length===0)return{dry_run:!1,mutated:!1,acknowledged:0,outcome:"no_effect",exit_code:g.NO_EFFECT,plan:o.plan};let c=await T(e),l=await Xr({pmRoot:e,op:"history:author-acknowledge",author:n,context:{author_acknowledgment:{events:a,attributed_author:r}},message:i,lockTtlSeconds:c.locks.ttl_seconds,lockWaitMs:c.locks.wait_ms}),d=o.plan.actionable_count>0&&o.plan.already_acknowledged_count>0?{outcome:"partial_effect",exit_code:g.PARTIAL_EFFECT}:{outcome:"effect",exit_code:g.SUCCESS};return{dry_run:!1,mutated:!0,acknowledged:a.length,...d,plan:o.plan,history_path:l.historyPath}}(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]="0daf7c89-abc5-5c35-ba3f-9772a50408c0")}catch{}})();var Xn={type:"string",minLength:1,maxLength:128,pattern:"\\S"},wi={type:"array",minItems:1,maxItems:Lo,items:Xn},wu={...wi,items:{...Xn,pattern:"^(?!(?:.*\\.)?(?:__proto__|constructor|prototype)(?:\\.|$))[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$"}},ey={type:"object",additionalProperties:!1,required:["id","rule"],properties:{id:{type:"string",minLength:1,maxLength:128,pattern:"^[a-zA-Z0-9][a-zA-Z0-9._-]*$"},description:{type:"string",minLength:1,maxLength:500,pattern:"\\S"},effect:{enum:["advise","warn","refuse"]},subject:{type:"object",additionalProperties:!1,properties:{...Object.fromEntries(["types","tags","statuses","operations","parents"].map(e=>[e,wi])),dependency:{type:"object",additionalProperties:!1,required:["kind"],properties:{kind:Xn,id:Xn}}}},rule:{oneOf:[{type:"object",additionalProperties:!1,required:["kind","fields"],properties:{kind:{const:"require_fields"},fields:wu}},{type:"object",additionalProperties:!1,required:["kind","authors"],properties:{kind:{const:"authors"},authors:wi}},...["field_writers","approval"].map(e=>({type:"object",additionalProperties:!1,required:["kind","fields","authors"],properties:{kind:{const:e},fields:wu,authors:wi}})),{type:"object",additionalProperties:!1,required:["kind","allowed"],properties:{kind:{const:"transition"},allowed:{type:"array",maxItems:Lo,items:{type:"array",minItems:2,maxItems:2,items:Xn}}}}]}}},RT={$schema:"https://json-schema.org/draft/2020-12/schema",title:"pm workflow policy registry",type:"object",additionalProperties:!1,required:["version","policies"],properties:{version:{const:1},enforcement:{enum:["advise","refuse"],default:"advise"},policies:{type:"array",maxItems:sl,items:ey}}};(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]="42dee0a5-d003-5e44-8b2d-d74a23d3f2ce")}catch{}})();async function vu(e,t,n,r){let i=await St(e).catch(()=>null);return i===null?{check:{name:"completeness",status:"error",ok:!1,details:{policy_registry_readable:!1,policy_registry_path:"schema/policies.json",remediation_hint:"Repair schema/policies.json, then rerun pm validate."}},warnings:["validate_completeness_policy_registry_unreadable"]}:bu(i,t,n,r)}function ty(e,t,n){return e===0?"undeclared":t===0?"empty":n===0?"inapplicable":n===t?"covered":"partial"}function bu(e,t,n=5,r=!1){let i=[],o=new Map,s=e.policies.filter(h=>h.rule.kind==="require_fields"),a=s.filter(h=>h.subject?.operations===void 0),c=new Set,l=0,d=0,u=0,m=0,f=0,p=ll(e);for(let h of t){let w=p({operation:"",author:"",before:h,after:h,completeness_only:!0});l+=+(w.decisions.length>0),d+=w.decisions.length,w.decisions.forEach(S=>c.add(S.policy_id));let v=w.decisions.filter(S=>!S.satisfied);if(v.length===0)continue;m+=1;let k=o.get(h.type)??{items:0,violations:0,missing_fields:0};k.items+=1;for(let S of v)u+=1,k.violations+=1,k.missing_fields+=S.missing_fields.length,S.effect==="refuse"&&(f+=1),i.length<n&&i.push({id:h.id,type:h.type,status:h.status,decision:S});o.set(h.type,k)}let _=r||f>0?"error":u>0?"warn":"ok";return{check:{name:"completeness",status:_,ok:_==="ok",details:{scope:"operation_independent_require_fields",declared_requirement_count:s.length,state_requirement_count:a.length,applicable_requirement_count:c.size,requirement_application_count:d,governed_items:l,ungoverned_items:t.length-l,contract_status:ty(s.length,t.length,l),applied_policy_ids:[...c].sort().slice(0,Math.max(0,n)),applied_policy_ids_truncated:c.size>Math.max(0,n),checked_items:t.length,incomplete_items:m,violation_count:u,refused_violations:f,missing_by_type:Object.fromEntries(o),violations:i,violations_truncated:i.length<u,enforcement:e.enforcement}},warnings:[...u>0?[`validate_completeness_missing_fields:${u}`]:[],...r?["validate_completeness_source_incomplete"]:[]]}}import ny 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]="f54fe358-8f4c-5bf4-ae2a-9c92cd08c953")}catch{}})();function ry(){return{version:1,enforcement:"advise",policies:[...[["Epic",["goal","objective","body"]],["Story",["description","value","acceptance_criteria"]],["Decision",["body","resolution"]],["Feature",["acceptance_criteria","expected_result"]],["Task",["description"]],["Issue",["repro_steps","expected_result"]],["Chore",["description"]]].map(([t,n])=>({id:`completeness-${t.toLowerCase()}`,effect:"advise",description:`Evidence expected when ${t} work reaches completion.`,subject:{types:[t],statuses:["closed"]},rule:{kind:"require_fields",fields:[...n]}})),{id:"completeness-resolution",effect:"advise",subject:{statuses:["closed"]},rule:{kind:"require_fields",fields:["resolution","expected_result","actual_result"]}}]}}function Eu(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{throw new y("Policy definition must be valid JSON.",g.USAGE)}if(typeof t!="object"||t===null||Array.isArray(t))throw new y("Policy definition must be an object.",g.USAGE);return t}async function iy(e,t){let n=N(process.cwd(),e.path);await Q(n);let r=await T(n);return{pmRoot:n,settings:r,author:B(t,r.author_default)}}function ku(e,t,n,r){if(e==="policy-mode")return Fo({...n,enforcement:t});let i=n.policies.filter(a=>a.id!==t);if(e==="policy-remove")return{...n,policies:i};let o=Mo(r.definition),s=Fo({...n,policies:[...i,o].sort((a,c)=>a.id.localeCompare(c.id))});if(Buffer.byteLength(`${JSON.stringify(s,null,2)}
|
|
@@ -56,4 +56,4 @@ ${o}`,g.GENERIC_FAILURE)}}async function u0(){return Tc(import.meta.url,["../../
|
|
|
56
56
|
`);le(e.progressEnabled,"writing keyword artifacts"),await ae(t,`${JSON.stringify(e.manifest,null,2)}
|
|
57
57
|
`),await ae(n,`${i}
|
|
58
58
|
`);let o=[];if(e.mode!=="keyword")try{le(e.progressEnabled,"writing vectorization status ledger"),await vd(e.pmRoot,e.vectorizationLedgerEntries,e.vectorizationEmbeddingMetadata)}catch(s){o.push(`search_vectorization_status_ledger_write_failed:${s instanceof Error?s.message:String(s)}`)}return o}async function eW(e,t){let n=M0(e.mode),r=L0(e),i=e.full===!0;le(r,`start mode=${n}`);let o=N(process.cwd(),t.path);await Q(o);let s=ii(await T(o)).settings,a=null;try{a=await ce(o,dd,s.locks.ttl_seconds,B(void 0,"pm-reindex"),!1,s.governance.force_required_for_stale_lock,s.locks.wait_ms)}catch(c){throw c instanceof y&&c.exitCode===g.CONFLICT?new y("Another pm reindex run is already active for this project. Wait for it to finish before starting a new keyword, semantic, or hybrid reindex.",g.CONFLICT,{code:"reindex_already_running",type:"urn:pm-cli:error:reindex_already_running",why:"Semantic reindex can be expensive and duplicate runs compete for the same local embedding model and vector store.",nextSteps:["Check active pm reindex processes before starting another reindex.","Rerun with --progress when you need non-interactive visibility."]}):c}try{let c=U0(s),l=z0(s),d=J0({requestedMode:n,pmRoot:o,settings:s,extensionEmbedding:c,extensionVectorAdapter:l}),u=n;le(r,"loading item corpus");let m=await V0({pmRoot:o,settings:s}),f=m.warnings,{documentCandidates:p,metadataDocuments:_}=m;le(r,`loaded_items=${_.length}`);let h=C(),w=G0(u,h,_),v=Er.join(o,_c),k=Er.join(o,gc),S=u==="keyword"?await wc(o,p,s.schema,f):_,x=[],I={},E=null,b=B0(u);if(u==="keyword"&&await K0({pmRoot:o,settings:s,forceFullSemantic:i,extensionEmbedding:c,reindexWarnings:f}),u!=="keyword"){let U=await nC({pmRoot:o,settings:s,requestedMode:n,activeEmbeddingProvider:d.activeEmbeddingProvider,activeVectorStore:d.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:l,documentCandidates:p,metadataDocuments:_,documentsForKeywordArtifacts:S,forceFullSemantic:i,reindexWarnings:f,semanticWarnings:x,semanticSummary:b,progressEnabled:r});S=U.documentsForKeywordArtifacts,I=U.vectorizationLedgerEntries,E=U.vectorizationEmbeddingMetadata}let D=await rC({pmRoot:o,mode:u,manifest:w,documentsForKeywordArtifacts:S,settings:s,vectorizationLedgerEntries:I,vectorizationEmbeddingMetadata:E,progressEnabled:r}),z=[...await Z({path:v,scope:"project",op:"reindex:manifest"}),...await Z({path:k,scope:"project",op:"reindex:embeddings"}),...await Mr({mode:u,total_items:_.length})];return le(r,"done"),{ok:!0,mode:u,total_items:_.length,semantic:b,artifacts:{manifest:_c,embeddings:gc},warnings:[...f,...x,...D,...z],generated_at:h}}finally{await a?.()}}export{W$ as a,um as b,L as c,xe as d,Ke as e,fn as f,$d as g,Dd as h,Ft as i,Qo as j,og as k,ns as l,rs as m,Md as n,hn as o,Bn as p,os as q,Eg as r,Wd as s,Gn as t,ss as u,mi as v,as as w,Bd as x,Gd as y,Jd as z,Jn as A,pi as B,Kd as C,Yd as D,Xd as E,Zd as F,nu as G,ZC as H,$ as I,ie as J,QC as K,us as L,eT as M,tT as N,du as O,nT as P,rT as Q,iT as R,Hg as S,oT as T,sT as U,ms as V,aT as W,cT as X,ds as Y,lT as Z,dT as _,mu as $,uT as aa,qg as ba,hu as ca,bT as da,Yn as ea,kT as fa,Xg as ga,Zg as ha,ST as ia,Qg as ja,Dy as ka,Py as la,lt as ma,dO as na,zy as oa,ey as pa,RT as qa,bu as ra,ry as sa,GT as ta,Aw as ua,hD as va,gD as wa,yD as xa,tr as ya,wD as za,vD as Aa,bD as Ba,kD as Ca,SD as Da,ED as Ea,xD as Fa,RD as Ga,ID as Ha,AD as Ia,CD as Ja,Cf as Ka,ra as La,xu as Ma,Ru as Na,Cu as Oa,Ct as Pa,VL as Qa,KL as Ra,YL as Sa,XL as Ta,cM as Ua,pp as Va,wa as Wa,AM as Xa,_t as Ya,CM as Za,TM as _a,_E as $a,vE as ab,Ap as bb,py as cb,$u as db,Sa as eb,SF as fb,EF as gb,bi as hb,ki as ib,Qp as jb,vj as kb,nh as lb,ih as mb,Rh as nb,Lj as ob,ch as pb,Ah as qb,A1 as rb,C1 as sb,QR as tb,eI as ub,D1 as vb,P1 as wb,N1 as xb,L1 as yb,nI as zb,rI as Ab,iI as Bb,M1 as Cb,$h as Db,sI as Eb,Oh as Fb,Wa as Gb,Ph as Hb,aI as Ib,cI as Jb,lI as Kb,Ja as Lb,Va as Mb,J1 as Nb,V1 as Ob,K1 as Pb,jI as Qb,XU as Rb,k_ as Sb,br as Tb,x_ as Ub,R_ as Vb,I_ as Wb,cc as Xb,VA as Yb,Oz as Zb,O_ as _b,D_ as $b,P_ as ac,nH as bc,dH as cc,DH as dc,GH as ec,JH as fc,VH as gc,eW as hc};
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-63YRRGKX.js.map
|