@unbrained/pm-cli 2026.9.13 → 2026.9.14
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 +22 -0
- package/dist/cli/commander-usage.js +2 -2
- package/dist/cli/error-guidance.js +1 -1
- package/dist/cli/extension-command-help.d.ts +2 -2
- package/dist/cli/extension-command-help.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +152 -152
- package/dist/cli-bundle/chunks/chunk-33PER336.js +236 -0
- package/dist/cli-bundle/chunks/{chunk-KM4XVZR7.js → chunk-5JIJAWIF.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-A2Q64TGR.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-XM7RWQLM.js → chunk-B6W5LIXK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YDSV4QIQ.js → chunk-BY3ID7QI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YQTJACN5.js → chunk-D5AJQU7F.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZZI7IHMM.js → chunk-DBHQIS6Z.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LA44JECQ.js → chunk-GQMILIC5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3DWX3CKN.js → chunk-NYE6EREL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XEZOGC3P.js → chunk-O7SRS7Y3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GBK5MV6N.js → chunk-XEV7BHH3.js} +26 -26
- package/dist/cli-bundle/chunks/{chunk-GQQR6JAL.js → chunk-ZYRN2OG3.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-WMJTBWNW.js → register-list-query-B2U36YWL.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-EXGOXP3D.js → register-mutation-GX42CQYR.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-2H4CDRGU.js → register-operations-ZV34KX5E.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-NYBWGPOS.js → register-setup-W4OS7IZW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FBCLVOBE.js → chunk-6WZBO4VQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OENAWWP4.js → chunk-7BUJABHB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-F66QJWI4.js → chunk-C5NQVXKE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-CMCSUANO.js +20 -0
- package/dist/cli-bundle/focused-chunks/{chunk-FPNI4U2B.js → chunk-CPQQIVDL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-V7PSTKHD.js → chunk-D4FQV6TY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TUHRUFID.js → chunk-ENJH7CBZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DSJYL4VP.js → chunk-FHQLQOUZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-B6JAANOH.js → chunk-FNLAQJES.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-GGDO6VBT.js +30 -0
- package/dist/cli-bundle/focused-chunks/{chunk-SDQCJF4H.js → chunk-KWP3QTN7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XCCM7P7V.js → chunk-LFGTCEHX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KP3N6PVZ.js → chunk-N23WTRCC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZAMG7HBB.js → chunk-O4EROPO3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-UFSMYVZF.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-LQ67C7ZO.js → chunk-ZFNRD7EN.js} +2 -2
- package/dist/cli-bundle/main.js +19 -19
- 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 +24 -24
- 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 +15 -15
- 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 +8 -8
- package/dist/core/output/output.js +3 -3
- package/dist/core/telemetry/runtime.d.ts +35 -8
- package/dist/core/telemetry/runtime.js +5 -4
- package/dist/sdk/agent/command-suggestions.d.ts +6 -0
- package/dist/sdk/agent/command-suggestions.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +7 -3
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/telemetry.js +1 -1
- package/docs/AGENT_UX_CONTRACTS.md +10 -2
- package/docs/CLI_GRAMMAR.md +28 -0
- package/docs/CONFIGURATION.md +35 -1
- package/docs/generated/AGENT_CAPABILITY_ROUTING.md +1 -1
- package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +1 -0
- package/marketplace.json +2 -2
- package/package.json +5 -5
- 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-6KHYW3FH.js +0 -235
- package/dist/cli-bundle/chunks/chunk-AKTBOX6U.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-7JR6M2JR.js +0 -30
- package/dist/cli-bundle/focused-chunks/chunk-YUXBHIUV.js +0 -20
- package/dist/cli-bundle/focused-chunks/chunk-ZF5PXK6A.js +0 -2
|
@@ -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-XCCM7P7V.js";import{e as Hr,f as Uo,h as zo}from"./chunk-FPNI4U2B.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-F66QJWI4.js";import{K as Cd}from"./chunk-V7PSTKHD.js";import{A as ld,E as Jo,F as ri,Ia as Sd,Ja as Ed,Na as xd,Oa as Rd,Ta as Zo,U as ii,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,lb as Td,ma as un,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-YUXBHIUV.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-B6JAANOH.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-KP3N6PVZ.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-OENAWWP4.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-7JR6M2JR.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-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)}
|
|
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-KWP3QTN7.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as w}from"./chunk-
|
|
1
|
+
import{c as w}from"./chunk-FNLAQJES.js";import{e as a,g as I}from"./chunk-7BUJABHB.js";import{$ as f,P as k,aa as u,ja as m,qa as T,r as h,s as _,t as b}from"./chunk-GGDO6VBT.js";import C from"node:fs/promises";import p 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]="8269d712-f438-5f18-8137-ed9a0358e23b")}catch{}})();var U=["extensions","docs","examples","assets","prompts"],R=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function q(e){return U.includes(e)}function G(e,t){if(t==null)return[];let n=Array.isArray(t)?t:[t],o=[];for(let r of n){if(typeof r!="string"||r.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,f.USAGE);o.push(r.trim())}return[...new Set(o)].sort((r,i)=>r.localeCompare(i))}function J(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",f.USAGE);let t={},n=e;for(let[o,r]of Object.entries(n)){if(!q(o))continue;let i=G(o,r);i.length>0&&(t[o]=i)}return t}function d(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n.trim():void 0}function E(e){if(!Array.isArray(e))return;let t=e.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0);return t.length>0?[...new Set(t)].sort((n,o)=>n.localeCompare(o)):void 0}function x(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={docs:d(t,"docs"),npm:d(t,"npm"),repository:d(t,"repository"),report:d(t,"report")};return Object.values(n).some(o=>typeof o=="string")?n:void 0}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={image:d(t,"image"),video:d(t,"video")};return Object.values(n).some(o=>typeof o=="string")?n:void 0}function Y(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={display_name:d(t,"display_name")??d(t,"displayName"),category:d(t,"category"),summary:d(t,"summary"),links:K(t.links),media:V(t.media),tags:E(t.tags)};return Object.values(n).some(o=>o!==void 0)?n:void 0}async function B(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let n;try{n=JSON.parse(await C.readFile(t,"utf8"))}catch(l){throw new u(`Failed to parse package manifest at "${t}": ${String(l)}`,f.USAGE)}if(typeof n!="object"||n===null||Array.isArray(n))throw new u(`Package manifest at "${t}" must be a JSON object.`,f.USAGE);let o=n,r=o.pm,i=r!=null,s=typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{};return{source:i?"pm":"convention",package_json_path:t,package_name:typeof o.name=="string"?o.name:void 0,package_version:typeof o.version=="string"?o.version:void 0,package_private:o.private===!0,package_description:typeof o.description=="string"?o.description:void 0,package_keywords:E(o.keywords),package_homepage:typeof o.homepage=="string"?o.homepage:void 0,package_repository_url:x(o.repository),package_bugs_url:x(o.bugs),aliases:E(s.aliases),resources:J(r),catalog:Y(s.catalog)}}async function j(e){if(!await m(e))return[];let t=await C.readdir(e,{withFileTypes:!0}),n=[];for(let o of t){if(!o.isDirectory())continue;let r=p.join(e,o.name);await m(p.join(r,"manifest.json"))&&n.push(r)}return n.sort((o,r)=>o.localeCompare(r))}async function ve(e){if(await m(p.join(e,"manifest.json")))return[e];let n=(await B(e)).resources.extensions??[],o=new Set;for(let r of n){if(r.includes("*")||r.startsWith("!"))throw new u(`Package extension entry "${r}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,f.USAGE);let i=p.resolve(e,r);if(!T(e,i))throw new u(`Package extension entry "${r}" resolves outside package root.`,f.USAGE);if(await m(p.join(i,"manifest.json"))){o.add(i);continue}for(let s of await j(i))o.add(s)}if(n.length===0)for(let r of R.extensions)for(let i of await j(p.join(e,r)))o.add(i);return[...o].sort((r,i)=>r.localeCompare(i))}(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]="2bc00b8e-0d9f-5af8-9667-d46136ff52b0")}catch{}})();var D=1,S=6,$=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function A(e){return"#".repeat(e)}function F(e){if(!e.includes("`"))return`\`${e}\``;let t=0,n=0;for(let i of e)n=i==="`"?n+1:0,t=Math.max(t,n);let o="`".repeat(t+1),r=e.startsWith("`")||e.endsWith("`")?" ":"";return`${o}${r}${e}${r}${o}`}function W(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(F).join(", ")}`}function H(e,t,n){let o=[`${A(t)} ${e}`,""];return n.length===0?(o.push("_None._",""),o):(o.push(...n.map(r=>`- ${F(r)}`),""),o)}function X(e,t,n){return e===0&&!n?[]:[`${A(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function be(e,t={}){let n=t.headingLevel??2;if(!Number.isInteger(n)||n<D||n>S)throw new RangeError(`headingLevel must be an integer in [${D}, ${S}], received ${String(t.headingLevel)}`);let o=Math.min(n+1,S),r=t.includeEmpty===!0,i=t.title??"Extension surfaces",s=[`${A(n)} ${i}`,""];(r||e.capabilities.length>0)&&s.push(W(e.capabilities),"");for(let[c,y]of $){let g=e[c]??[];g.length===0&&!r||s.push(...H(y,o,g))}return s.push(...X(e.preflight_overrides,o,r)),!(e.preflight_overrides>0||$.some(([c])=>(e[c]?.length??0)>0))&&!r&&s.push("_This extension registers no surfaces._",""),`${s.join(`
|
|
2
2
|
`).trimEnd()}
|
|
3
3
|
`}(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]="ebcb45a2-996a-5194-8086-efe882dbcacc")}catch{}})();var Q=["agile","ops","research"],Z={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function Ae(e){if(e===void 0)return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length===0)throw new Error("Type preset name must not be empty.");if(t==="agile"||t==="ops"||t==="research")return t;throw new Error(`Invalid type preset "${e}". Allowed: ${Q.join(", ")}.`)}function ke(e){return Z[e].map(t=>w(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]="f9535c02-9214-5d5e-bac0-2dabbe5d395e")}catch{}})();var ee=new Set(_),te=new Set(b),N=new Set([...k.filter(e=>e!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),ne=["create","update"];function M(e){if(typeof e!="string")return"";let t=e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return t.startsWith("--")?t.slice(2):t}function O(e){return e.replaceAll("_","-")}function oe(e,t){let n=new Set;for(let o of e){let r=M(o);r.length>0&&r!==t&&n.add(r)}return[...n].sort((o,r)=>o.localeCompare(r))}function re(e){let t=new Set;for(let n of e??[]){let o=n.trim();o.length>0&&t.add(o)}return[...t].sort((n,o)=>n.localeCompare(o))}function ie(e){let t=new Set,n=[];for(let o of e??[]){let r=o.trim().toLowerCase();if(r.length!==0){if(!te.has(r))throw new Error(`Invalid field command "${o}". Allowed: ${b.join(", ")}.`);t.has(r)||(t.add(r),n.push(r))}}return e===void 0||n.length===0?[...ne]:n}function Ce(e){let t=a(e.key);if(t.length===0)throw new Error("Field key must not be empty.");if(N.has(t))throw new Error(`Cannot define custom field "${t}": custom schema field "${t}" collides with built-in item metadata "${t}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...N].sort((g,P)=>g.localeCompare(P)).join(", ")}.`);let n=typeof e.type=="string"&&e.type.trim().length>0?e.type.trim().toLowerCase():"string";if(!ee.has(n))throw new Error(`Invalid field type "${e.type}". Allowed: ${_.join(", ")}.`);let o=n,r=ie(e.commands),i=M(e.cliFlag),s=i.length>0&&i!==O(t)?i:void 0,l=s??O(t),c=oe(e.aliases??[],l),y=e.description?.trim();return{key:t,type:o,commands:r,description:y&&y.length>0?y:void 0,cliFlag:s,cliAliases:c,required:e.required===!0,requiredOnCreate:e.requiredOnCreate===!0,allowUnset:e.allowUnset!==!1,requiredTypes:re(e.requiredTypes)}}function se(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function ae(e){let t=se(e);if(!t)return[];let n=[];for(let o of t){if(typeof o!="object"||o===null||Array.isArray(o))continue;let r=o;typeof r.key!="string"||r.key.trim().length===0||n.push(r)}return n}function De(e){if(e==null||e.trim().length===0)return{fields:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:ae(t)}}function $e(e){return`${JSON.stringify({fields:e.fields},null,2)}
|
|
4
4
|
`}function Fe(e,t){let n=e.fields.find(s=>a(s.key)===t.key),o=n!==void 0,r=e.fields.filter(s=>a(s.key)!==t.key),i={...n,key:t.key,type:t.type,commands:[...t.commands]};return L(i,"description",t.description),L(i,"cli_flag",t.cliFlag),t.cliAliases.length>0?i.cli_aliases=[...t.cliAliases]:delete i.cli_aliases,z(i,"required",t.required),z(i,"required_on_create",t.requiredOnCreate),t.allowUnset===!1?i.allow_unset=!1:delete i.allow_unset,t.requiredTypes.length>0?i.required_types=[...t.requiredTypes]:delete i.required_types,r.push(i),r.sort((s,l)=>a(s.key).localeCompare(a(l.key))),{file:{fields:r},definition:i,replaced:o}}function Ne(e,t){let n=a(t);if(n.length===0)throw new Error("Field key must not be empty.");let o=[],r=e.fields.filter(i=>a(i.key)===n?(o.push(i),!1):!0);return o.length===0?{file:{fields:r},removed:!1}:{file:{fields:r},removed:!0,definition:o[0]}}function L(e,t,n){let o=e;n!==void 0&&n.length>0?o[t]=n:delete o[t]}function z(e,t,n){let o=e;n?o[t]=!0:delete o[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]="e3a1e65b-55d7-5206-b3e7-cac3ac29745c")}catch{}})();var le=new Set(h),v=new Set(I.map(e=>a(e.id)).filter(e=>e.length>0));function ce(e){let t=new Set;for(let n of e){let o=a(n);o.length>0&&t.add(o)}return[...t].sort((n,o)=>n.localeCompare(o))}function Ue(e){let t=a(e.id);if(t.length===0)throw new Error("Status id must not be empty.");if(v.has(t))throw new Error(`Cannot add-status the built-in status "${t}". Built-in statuses are reserved: ${[...v].join(", ")}.`);let n;if(e.roles!==void 0){n=[];let s=new Set;for(let l of e.roles){let c=typeof l=="string"?l.trim().toLowerCase():"";if(c.length!==0){if(!le.has(c))throw new Error(`Invalid status role "${l}". Allowed roles: ${h.join(", ")}.`);s.has(c)||(s.add(c),n.push(c))}}if(n.length===0)throw new Error(`Status role must include at least one lifecycle role. Allowed roles: ${h.join(", ")}.`)}let o=e.aliases===void 0?void 0:ce(e.aliases).filter(s=>s!==t),r=e.description?.trim(),i=typeof e.order=="number"&&Number.isFinite(e.order)?Math.trunc(e.order):void 0;return{id:t,roles:n,aliases:o,description:r&&r.length>0?r:void 0,order:i}}function de(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function fe(e){let t=de(e);if(!t)return[];let n=[];for(let o of t){if(typeof o!="object"||o===null||Array.isArray(o))continue;let r=o;typeof r.id!="string"||r.id.trim().length===0||n.push(r)}return n}function Re(e){if(e==null||e.trim().length===0)return{statuses:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:fe(t)}}function qe(e){return`${JSON.stringify({statuses:e.statuses},null,2)}
|
|
5
5
|
`}function Ge(e,t,n){let o=e.statuses.slice(),r=o.findIndex(l=>a(l.id)===t.id),i=r>=0?o[r]:n,s={...i,id:t.id};return t.roles!==void 0&&(t.roles.length>0?s.roles=[...t.roles]:s.roles!==void 0&&delete s.roles),t.aliases!==void 0&&(t.aliases.length>0?s.aliases=[...t.aliases]:s.aliases!==void 0&&delete s.aliases),t.description!==void 0&&(s.description=t.description),t.order!==void 0&&(s.order=t.order),r>=0?o[r]=s:o.push(s),{file:{statuses:o},definition:s,replaced:i!==void 0}}function Je(e,t){let n=a(t);if(n.length===0)throw new Error("Status id must not be empty.");if(v.has(n))throw new Error(`Cannot remove built-in status "${n}". Built-in statuses are reserved: ${[...v].join(", ")}.`);let o=e.statuses.slice(),r=o.findIndex(s=>a(s.id)===n);if(r<0)return{file:{statuses:o},removed:!1};let[i]=o.splice(r,1);return{file:{statuses:o},removed:!0,definition:i}}function Ke(e,t){let n=[e.id,...e.aliases??[]];for(let o of n){let r=a(o);if(r.length===0)continue;let i=t.get(r);if(i!==void 0&&i!==e.id)throw new Error(`Status token "${r}" already belongs to status "${i}". Choose a different id/alias to avoid shadowing it.`)}}export{U as a,R as b,B as c,ve as d,Q as e,Z as f,Ae as g,ke as h,Ce as i,De as j,$e as k,Fe as l,Ne as m,v as n,Ue as o,Re as p,qe as q,Ge as r,Je as s,Ke as t,be as u};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-LFGTCEHX.js.map
|