@unbrained/pm-cli 2026.10.8 → 2026.10.9
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 +17 -0
- package/dist/cli/register-list-query.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +151 -151
- package/dist/cli-bundle/chunks/{chunk-ZHIMZ65M.js → chunk-55MK3QQM.js} +30 -30
- package/dist/cli-bundle/chunks/{chunk-34L2BS2Z.js → chunk-5MOFELIF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZBVAZ7XX.js → chunk-5NR6TDYB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OG66KEOF.js → chunk-5TCQ5J3V.js} +74 -78
- package/dist/cli-bundle/chunks/{chunk-K6E2FFUT.js → chunk-CPZOW6L2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TNU56MZI.js → chunk-E4XR5LKU.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RCFZ6H2Y.js → chunk-KOGF6O6W.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-JDTBPW4Y.js → chunk-N7GKWO4G.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-L7U5FSZ5.js → chunk-NIF7JOPW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MJVRF67I.js → chunk-P5NS7EFC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HFCIAXLP.js → chunk-QQHNXCO3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FOLSEOJ2.js → chunk-XW3BLWFF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UGFN5NJ2.js → chunk-ZNXRGATT.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-PYVSPGPV.js → register-list-query-2YOWMNWY.js} +7 -7
- package/dist/cli-bundle/chunks/{register-mutation-WXP3YLIN.js → register-mutation-ILOWFMTV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-WL25C3NP.js → register-operations-BMK65YM3.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-PFKYNEQI.js → register-setup-24TFFK6N.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PEBOVLEG.js → chunk-2ATAD56F.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6TKAFFEB.js → chunk-2CJWTLQG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EOUORVJA.js → chunk-362645PL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-V3EPBB6V.js → chunk-AU6VJGTY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-L3CZNKZE.js → chunk-B3YW6H2I.js} +16 -20
- package/dist/cli-bundle/focused-chunks/{chunk-XT7JAVHI.js → chunk-DMSADMEU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2KSPGWLH.js → chunk-DSLNUL2Q.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-A3W6HFFO.js → chunk-EZ4367G4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MW2TQHZ3.js → chunk-IARAEFMA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OSKXYRYZ.js → chunk-MCVWZUGK.js} +27 -27
- package/dist/cli-bundle/focused-chunks/{chunk-F2ME5MJY.js → chunk-PBCYGO7X.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PBPPIGUL.js → chunk-PLTTMQAW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OLCJ2PJS.js → chunk-SAN3KPX4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DRHJOG5X.js → chunk-W5AE7GKZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LZQGEVKT.js → chunk-WAOXID5J.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BDT5EALU.js → chunk-WOEZJUA2.js} +2 -2
- package/dist/cli-bundle/main.js +2 -2
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +22 -22
- 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 +50 -50
- 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 +7 -7
- package/dist/core/history/event-index.d.ts +1 -2
- package/dist/core/history/event-index.js +2 -2
- package/dist/core/output/output.d.ts +16 -14
- package/dist/core/output/output.js +6 -10
- package/dist/core/store/item-metadata-query-index.d.ts +1 -2
- package/dist/core/store/item-metadata-query-index.js +1 -1
- package/dist/core/store/sqlite-runtime.d.ts +15 -0
- package/dist/core/store/sqlite-runtime.js +2 -0
- package/dist/sdk/output/table-rows.d.ts +37 -0
- package/dist/sdk/output/table-rows.js +2 -0
- package/dist/sdk/output.d.ts +1 -0
- package/dist/sdk/output.js +2 -2
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output-contracts.d.ts +3 -3
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/test/workspace-snapshot.d.ts +1 -1
- package/dist/sdk/test/workspace-snapshot.js +1 -1
- package/docs/AGENT_OUTPUT_ENCODINGS.md +119 -0
- package/docs/PACKAGE_GATE_ACCEPTANCE.md +56 -0
- package/docs/README.md +2 -0
- package/docs/TESTING.md +11 -3
- package/marketplace.json +2 -2
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +2 -2
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +2 -2
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as ft,E as Xt,F as gi,Ia as Ai,O as st,Q as ue,Qa as q,R as at,Ra as Mi,S as ct,Sa as $i,T as bi,Ua as Te,V as Ei,Va as Oi,W as Ci,Wa as Li,X as lt,Xa as Ni,Y as Ii,Ya as Pi,Z as ut,Za as ji,_ as mt,aa as xi,ab as Ui,bb as Bi,db as Wi,ea as Ti,eb as zi,fa as Jt,g as pi,h as hi,hb as Vi,ib as Zt,jb as en,kb as W,oa as Ri,ob as Ki,pb as Yi,ub as Qi,wb as Ji,za as fe}from"./chunk-2KSPGWLH.js";import{e as it,f as Yt,g as ti,h as ni}from"./chunk-V3EPBB6V.js";import{Na as jr,Va as Ur}from"./chunk-BDT5EALU.js";import{$a as _i,Ab as G,Ba as ui,Bb as ne,Cb as re,D as ee,Eb as ki,Fb as me,Ia as ot,Ib as Si,Ja as mi,Ka as fi,Mb as Ce,Ob as Ie,Rb as xe,Sb as Di,T as L,Tb as Fi,U as R,Ub as pt,V as J,Xa as M,Y as di,Yb as Gi,Zb as Hi,_a as yi,aa as te,ac as qi,cb as wi,eb as Qt,f as ri,fa as li,g as ii,h as oi,i as si,j as ai,n as Ee,oc as Xi,w as ci,wb as dt,yb as vi}from"./chunk-OSKXYRYZ.js";import{b as Ar,n as P,p as Q}from"./chunk-F2ME5MJY.js";import{$ as f,$a as T,$c as le,$d as Xr,Ab as Pr,Ba as zt,Bd as Vr,Cd as Kr,Ea as ke,Fa as Ye,Ge as Kt,H as de,Hd as Yr,Ka as $r,La as Or,M as Wt,Mc as C,Me as Zr,N as Ve,Ne as ei,Rc as Se,V as Tr,Va as D,Vc as Br,Yd as F,Z as Rr,aa as h,ad as Gr,ae as E,bb as Lr,be as Qr,cd as Qe,ce as H,db as Vt,ed as Je,fb as Xe,fd as Ze,gd as Hr,i as xr,ie as et,jd as qr,kd as Wr,ke as tt,ld as zr,me as nt,pe as Jr,qe as rt,sa as Dr,ta as Ke,tb as Nr,ua as Fr,ya as Mr}from"./chunk-L3CZNKZE.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]="7dd9061f-1b49-5ecb-a306-74f09283fe57")}catch{}})();var Qs="PmCliError";function Jm(e){if(!Zs(e)||e.code!=="item_already_exists"||e.exitCode!==f.CONFLICT)return!1;let t=e.context;return typeof t=="object"&&t!==null&&t.code==="item_already_exists"&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.path=="string"&&t.path.trim().length>0}function Js(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=f.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function Zi(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new h(e,Js(t.exitCode??f.USAGE),t.context??{});return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function Zs(e){if(!(e instanceof Error)||e.name!==Qs)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)}(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]="b70f6764-9f83-5371-8ebc-1d0d5703bc1f")}catch{}})();var ea=["invalid_envelope","source_incomplete","source_unchecked","filtered_corpus","terminal_items_excluded","strict_read_unproven","page_incomplete","count_mismatch","projection_incomplete","field_omission","omission_receipt_missing","omission_receipt_invalid","read_output_missing","read_output_invalid","read_output_dimensions_incomplete","budget_compaction","budget_omission","session_projection","invalid_item_id","duplicate_item_id"],tn=class extends Error{receipt;constructor(t){super(`Complete-list certification failed: ${t.map(n=>n.code).join(", ")}.`),this.name="PmCompleteListValidationError",this.receipt={contract_version:1,contract:"complete_list",findings:t,recovery:{suggested_retry:"pm list --all --output-include full --strict-read --no-truncate --output-budget unbounded --output-limit unbounded --json",sdk:"await client.listAllComplete()"}}}};function tf(e={}){return Yr({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e,t,n,r){t&&e.push({code:n,message:r})}function ta(e,t){let n=z(e.completeness)?e.completeness:{};I(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),I(t,n.status!=="complete"&&n.status!=="partial","source_unchecked","The source scan did not prove completeness.");let r=n.unreadable_item_count,i=n.unreadable_directory_count;I(t,n.status==="complete"&&(r!==0||i!==0)&&Number.isSafeInteger(r)&&Number.isSafeInteger(i),"source_incomplete","The source scan reports unreadable tracker artifacts despite a complete status."),I(t,n.status==="complete"&&(!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||Number(r)<0||Number(i)<0),"source_unchecked","The source scan did not report safe non-negative unreadable counts.");let o=z(e.filters)?e.filters:{},s=z(o.runtime_filters)?o.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return I(t,o.status!=="all"||Object.keys(s).length>0||Object.keys(o).some(d=>!a.has(d)),"filtered_corpus","The list did not explicitly select every lifecycle status."),I(t,o.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),I(t,o.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),o}function na(e,t,n){I(n,e.has_more!==!1||e.next_cursor!==null||e.truncated!==!1||e.applied_limit!==void 0||t.no_truncate!==!0,"page_incomplete","Pagination or a row ceiling may have withheld items."),I(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let r=z(e.projection)?e.projection:{};I(n,r.mode!=="full"||r.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let i=z(e.omission_receipt)?e.omission_receipt:void 0;I(n,i===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),I(n,i!==void 0&&(i.has_omissions!==!1||i.omitted_field_group_count!==0||!Number.isSafeInteger(i.omitted_field_group_count)||!Array.isArray(i.omitted_field_groups)||i.omitted_field_groups.length!==0),"omission_receipt_invalid","The field-omission receipt is malformed or contradicts its no-omission claim."),I(n,i?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function ra(e){return e.contract_version!==1||e.command!=="list"||e.within_budget!==!0||e.strings_compacted!==!1||e.rows_compacted!==!1||e.result_omitted!==!1}function ia(e){if(!Array.isArray(e.requested_dimensions))return!1;let t=new Set(e.requested_dimensions);return["include","amount","cost"].every(n=>t.has(n))}function oa(e,t){let n=z(e.read_output)?e.read_output:void 0;I(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),I(t,n!==void 0&&ra(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),I(t,n!==void 0&&!ia(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),I(t,n?.strings_compacted===!0||n?.rows_compacted===!0||e.output_budget_truncation!==void 0,"budget_compaction","Universal output shaping compacted the result.");let r=z(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;I(t,n?.result_omitted===!0||r?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),I(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function sa(e,t){let n=e.map(r=>z(r)&&typeof r.id=="string"?r.id.trim():"");I(t,n.some(r=>r.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),I(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function aa(e){if(!z(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:ea[0],message:"The result must be an object with an items array."}]};let t=e,n=[],r=ta(t,n);return na(t,r,n),oa(t,n),sa(t.items,n),{ok:n.length===0,findings:n}}function ca(e){let t=aa(e);if(!t.ok)throw new tn(t.findings);let n=e;return{...n,complete_list:{contract_version:1,item_count:n.items.length,unique_item_id_count:new Set(n.items.map(r=>r.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function nf(e){ca(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="499dfc08-cf70-55fe-8868-65c3107e3a91")}catch{}})();async function af(e,t={}){let n=await Qi({pmRoot:T(process.cwd(),e.path),exhaustive:t.exhaustive,...t.status===void 0?{}:{statuses:t.status.flatMap(r=>r.split(",").map(i=>i.trim()).filter(Boolean))},...t.since===void 0?{}:{since:t.since},...t.threshold===void 0?{}:{threshold:t.threshold},...t.limit===void 0?{}:{limit:t.limit}});return{...n,clusters:n.clusters.map(r=>{let i=r.id;return{...r,canonical_id:i,close_command:`pm close <duplicate-id> --duplicate-of ${i}`}}),guidance:{strategy:"review_then_close_duplicate",command:"pm close <duplicate-id> --duplicate-of <canonical-id>"}}}(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]="1433b417-e41f-5963-a551-094132afd717")}catch{}})();var eo=16;async function to(e,t,n){let r=D(t,C()).type_to_folder,i=[],o=new Set,s=n;for(;s&&i.length<eo;){let a=s.trim().toLowerCase();if(!a||o.has(a))break;o.add(a);let d=await ne(e,s,t.id_prefix,t.item_format,r);if(!d)break;let c=await re(d,{schema:t.schema});i.push(c.document.metadata.id),s=c.document.metadata.parent}return i}async function ff(e){await oi({pmRoot:e.pmRoot,principal:e.principal,itemId:e.itemId,lineageIds:await to(e.pmRoot,e.settings,e.itemId)})}async function pf(e){await si(e)}async function hf(e){await ai({pmRoot:e.pmRoot,principal:e.principal,...e.itemId?{itemId:e.itemId,lineageIds:await to(e.pmRoot,e.settings,e.itemId)}:{}})}var gf={lineage_depth:eo,active_items:64,evidence_rows:32};function no(e){if(!e)return;let t={};for(let n of e.active_item_ids)t[n]=1;e.focused_item_id&&(t[e.focused_item_id]=1);for(let n of e.evidence){let r=/^lineage:(.+)$/u.exec(n)?.[1];r&&t[r]===void 0&&(t[r]=.75)}return Object.keys(t).length>0?t:void 0}import{encode as da}from"@toon-format/toon";(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]="809a4d75-4915-585d-9fc8-ad3e9ef15b1f")}catch{}})();var nn=["agenda","day","week","month"],rn=["markdown","toon","json"],la=["sun","mon","tue","wed","thu","fri","sat"],ua=365,ma=365,oo=28,fa=1e3;function on(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new h(`${t} must be a non-negative integer`,f.USAGE);return n}function pa(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw new h("Calendar include filter must not be empty",f.USAGE);let r=new Set;for(let i of n){if(i==="deadlines"||i==="deadline"){r.add("deadlines");continue}if(i==="reminders"||i==="reminder"){r.add("reminders");continue}if(i==="events"||i==="event"||i==="scheduled"){r.add("events");continue}throw new h("Calendar include filter must be deadlines|reminders|events|scheduled|all",f.USAGE)}return r}function so(e,t){let n;for(let r of t){let i=xr(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function ha(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!nn.includes(t)){let n=so(t,nn);throw new h(`Calendar view must be one of ${nn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function ga(e){if(!e)return;let t=e.trim().toLowerCase();if(!rn.includes(t)){let n=so(t,rn);throw new h(`Calendar format must be one of ${rn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function Sf(e,t){let n=ga(e.format);if(t.json&&n&&n!=="json")throw new h("Cannot combine --json with --format markdown|toon",f.USAGE);return t.json?"json":n??"markdown"}function ya(e,t){if(e===void 0)return;let n=L(e,t);if(!n){let r=t.definitions.map(i=>i.id);throw new h(`Calendar status filter must be one of ${r.join("|")}`,f.USAGE)}return n}function _a(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new h("Calendar assignee filter must be one of assigned|unassigned",f.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new h(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,f.USAGE);return t}function ht(e){return new Date(e).toISOString().slice(0,10)}function ao(e,t){if(!t||t==="UTC")return ht(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,i=n.find(s=>s.type==="month")?.value,o=n.find(s=>s.type==="day")?.value;if(r&&i&&o)return`${r}-${i}-${o}`}catch{}return ht(e)}function dn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function V(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function co(e){let t=new Date(dn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return V(t.toISOString(),r)}function wa(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function ba(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function va(e,t){return E(e,t)>=0?e:t}function ro(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function io(e,t){e.set(t,(e.get(t)??0)+1)}function ka(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,i)=>de(r)-de(i));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,i)=>r-i);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,i)=>r.localeCompare(i));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function lo(e,t,n,r){let i=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==t||i.getUTCDate()!==n))return i.toISOString()}function uo(e){return la[new Date(e).getUTCDay()]}function Sa(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function Ea(e){let t=new Set;for(let n of e??[]){let r=Sa(n);r&&t.add(r)}return t}function Ca(e,t,n,r,i){let o=e??V(n,-(r??ma)),s=t??V(e??n,i??ua);return{start:o,end:E(s,o)>0?s:V(o,1)}}function Ia(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[uo(e)],o=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??fa,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:Ea(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(i)].sort((s,a)=>de(s)-de(a)),sortedMonthDays:[...new Set(o)].sort((s,a)=>s-a),occurrences:[],produced:0}}function gt(e,t){return E(t,e.startAt)<0?"continue":e.until&&E(t,e.until)>0||E(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,E(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function yt(e,t){let n=uo(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function xa(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(yt(e,t)&>(e,t)==="stop");n+=1)t=V(t,e.interval);return e.occurrences}function Ta(e,t,n){let r=de(n),i=V(t,r),o=new Date(i);return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function Ra(e){let t=co(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=V(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=Ta(e,r,i);if(yt(e,o)&>(e,o)==="stop")return e.occurrences}}return e.occurrences}function Aa(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let o of e.sortedMonthDays){let s=lo(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!yt(e,s))&>(e,s)==="stop")return e.occurrences}}return e.occurrences}function Da(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=t+r*e.interval;for(let o of e.sortedMonthDays){let s=lo(i,n,o,e.startDate);if(!(!s||!yt(e,s))&>(e,s)==="stop")return e.occurrences}}return e.occurrences}function Fa(e,t,n,r){let i=Ia(e,t,n,r);return t.freq==="daily"?xa(i):t.freq==="weekly"?Ra(i):t.freq==="monthly"?Aa(i):Da(i)}function mo(e){return[...e].sort((t,n)=>{let r=E(t.at,n.at);if(r!==0)return r;let i=t.item_priority-n.item_priority;if(i!==0)return i;let o=t.item_id.localeCompare(n.item_id);if(o!==0)return o;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function ln(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Ma(e){return e.deadline?{at:e.deadline,date:ht(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...ln(e),item_deadline:e.deadline}:null}function $a(e){return(e.reminders??[]).map(t=>({at:t.at,date:ht(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...ln(e)}))}function Oa(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function La(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Na(e,t,n,r){let i=ka(t.recurrence),o=Oa(t.start_at,t.end_at);return(t.recurrence?Fa(t.start_at,t.recurrence,n,r):[t.start_at]).map(s=>({at:s,date:t.all_day===!0?s.slice(0,10):ao(s,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:La(s,t,o),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:i,...ln(e)}))}function Pa(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Ma(o):null;s&&i.push(s),n.has("reminders")&&i.push(...$a(o));for(let a of n.has("events")?o.events??[]:[])i.push(...Na(o,a,t,r))}return mo(i)}function ja(e,t,n,r,i){let o=$i(t.type,n),s=t.tag?.trim().toLowerCase(),a=Mi(t.priority),d=ya(t.status,r),c=t.assignee?.trim(),l=_a(t.assigneeFilter),u=t.sprint?.trim(),m=t.release?.trim();if(c&&(c.toLowerCase()==="none"||c.toLowerCase()==="null"))throw new h('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',f.USAGE);if(c!==void 0&&l==="unassigned")throw new h("Cannot combine --assignee with --assignee-filter unassigned",f.USAGE);return e.filter(p=>Ua(p,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:d,assigneeFilter:c,assigneeModeFilter:l,sprintFilter:u,releaseFilter:m,runtimeFieldFilters:i}))}function Ua(e,t){return Ba(e,t)&&Ga(e,t)&&ct(e,t.runtimeFieldFilters)}function Ba(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function Ga(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function Ha(e,t,n){return!(t&&E(e.at,t)<0||n&&E(e.at,n)>=0)}function sn(e,t,n){return e.trim().toLowerCase()==="today"?dn(t):H(e,new Date(t),n)}function qa(e,t,n){let r=t.date?sn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?sn(t.from,n,"--from"):void 0,a=t.to?sn(t.to,n,"--to"):void 0;if(s&&a&&E(s,a)>=0)throw new h("Calendar --from must be before --to",f.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new h("--from and --to are only supported for --view agenda",f.USAGE);if(e==="agenda")return Wa(r,t,n,i,o,s,a);if(e==="day"){let c=dn(r);return an(r,n,i,o,c,V(c,1))}if(e==="week"){let c=co(r);return an(r,n,i,o,c,V(c,7))}let d=wa(r);return an(r,n,i,o,d,ba(r))}function Wa(e,t,n,r,i,o,s){if(i)throw new h("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",f.USAGE);return{anchor:e,start:o??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function an(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:va(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function za(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:mo(r)}))}function Va(e){let t=new Set,n=new Map,r=new Map,i=0,o=0,s=0,a=0;for(let d of e)t.add(d.item_id),io(n,d.item_type),io(r,d.item_status),d.kind==="deadline"?i+=1:d.kind==="reminder"?o+=1:(s+=1,d.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:i,reminders:o,scheduled:s,by_kind:{deadline:i,reminder:o,event:s},by_type:ro(n),by_status:ro(r),recurring_events:a}}function Ka(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function fo(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(o=>o.type==="hour")?.value,i=n.find(o=>o.type==="minute")?.value;if(r&&i)return`${r}:${i}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function cn(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function Ya(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===ao(e.event_end,e.event_timezone)?fo(e.event_end,e.event_timezone):e.event_end:null}function Xa(e){let t=`${fo(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let i=Ya(e);return i&&n.push(`end=${i}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function Ef(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${Ka(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- by-kind: ${cn(e.summary.by_kind)}`),t.push(`- by-type: ${cn(e.summary.by_type)}`),t.push(`- by-status: ${cn(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),t.join(`
|
|
1
|
+
import{$ as ft,E as Xt,F as gi,Ia as Ai,O as st,Q as ue,Qa as q,R as at,Ra as Mi,S as ct,Sa as $i,T as bi,Ua as Te,V as Ei,Va as Oi,W as Ci,Wa as Li,X as lt,Xa as Ni,Y as Ii,Ya as Pi,Z as ut,Za as ji,_ as mt,aa as xi,ab as Ui,bb as Bi,db as Wi,ea as Ti,eb as zi,fa as Jt,g as pi,h as hi,hb as Vi,ib as Zt,jb as en,kb as W,oa as Ri,ob as Ki,pb as Yi,ub as Qi,wb as Ji,za as fe}from"./chunk-DSLNUL2Q.js";import{e as it,f as Yt,g as ti,h as ni}from"./chunk-AU6VJGTY.js";import{Na as jr,Va as Ur}from"./chunk-WOEZJUA2.js";import{$a as _i,Ab as G,Ba as ui,Bb as ne,Cb as re,D as ee,Eb as ki,Fb as me,Ia as ot,Ib as Si,Ja as mi,Ka as fi,Mb as Ce,Ob as Ie,Rb as xe,Sb as Di,T as L,Tb as Fi,U as R,Ub as pt,V as J,Xa as M,Y as di,Yb as Gi,Zb as Hi,_a as yi,aa as te,ac as qi,cb as wi,eb as Qt,f as ri,fa as li,g as ii,h as oi,i as si,j as ai,n as Ee,oc as Xi,w as ci,wb as dt,yb as vi}from"./chunk-MCVWZUGK.js";import{b as Ar,n as P,p as Q}from"./chunk-PBCYGO7X.js";import{$ as f,$a as T,$c as le,$d as Xr,Ab as Pr,Ba as zt,Bd as Vr,Cd as Kr,Ea as ke,Fa as Ye,Ge as Kt,H as de,Hd as Yr,Ka as $r,La as Or,M as Wt,Mc as C,Me as Zr,N as Ve,Ne as ei,Rc as Se,V as Tr,Va as D,Vc as Br,Yd as F,Z as Rr,aa as h,ad as Gr,ae as E,bb as Lr,be as Qr,cd as Qe,ce as H,db as Vt,ed as Je,fb as Xe,fd as Ze,gd as Hr,i as xr,ie as et,jd as qr,kd as Wr,ke as tt,ld as zr,me as nt,pe as Jr,qe as rt,sa as Dr,ta as Ke,tb as Nr,ua as Fr,ya as Mr}from"./chunk-B3YW6H2I.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]="7dd9061f-1b49-5ecb-a306-74f09283fe57")}catch{}})();var Qs="PmCliError";function Jm(e){if(!Zs(e)||e.code!=="item_already_exists"||e.exitCode!==f.CONFLICT)return!1;let t=e.context;return typeof t=="object"&&t!==null&&t.code==="item_already_exists"&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.path=="string"&&t.path.trim().length>0}function Js(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=f.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function Zi(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new h(e,Js(t.exitCode??f.USAGE),t.context??{});return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function Zs(e){if(!(e instanceof Error)||e.name!==Qs)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)}(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]="b70f6764-9f83-5371-8ebc-1d0d5703bc1f")}catch{}})();var ea=["invalid_envelope","source_incomplete","source_unchecked","filtered_corpus","terminal_items_excluded","strict_read_unproven","page_incomplete","count_mismatch","projection_incomplete","field_omission","omission_receipt_missing","omission_receipt_invalid","read_output_missing","read_output_invalid","read_output_dimensions_incomplete","budget_compaction","budget_omission","session_projection","invalid_item_id","duplicate_item_id"],tn=class extends Error{receipt;constructor(t){super(`Complete-list certification failed: ${t.map(n=>n.code).join(", ")}.`),this.name="PmCompleteListValidationError",this.receipt={contract_version:1,contract:"complete_list",findings:t,recovery:{suggested_retry:"pm list --all --output-include full --strict-read --no-truncate --output-budget unbounded --output-limit unbounded --json",sdk:"await client.listAllComplete()"}}}};function tf(e={}){return Yr({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e,t,n,r){t&&e.push({code:n,message:r})}function ta(e,t){let n=z(e.completeness)?e.completeness:{};I(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),I(t,n.status!=="complete"&&n.status!=="partial","source_unchecked","The source scan did not prove completeness.");let r=n.unreadable_item_count,i=n.unreadable_directory_count;I(t,n.status==="complete"&&(r!==0||i!==0)&&Number.isSafeInteger(r)&&Number.isSafeInteger(i),"source_incomplete","The source scan reports unreadable tracker artifacts despite a complete status."),I(t,n.status==="complete"&&(!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||Number(r)<0||Number(i)<0),"source_unchecked","The source scan did not report safe non-negative unreadable counts.");let o=z(e.filters)?e.filters:{},s=z(o.runtime_filters)?o.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return I(t,o.status!=="all"||Object.keys(s).length>0||Object.keys(o).some(d=>!a.has(d)),"filtered_corpus","The list did not explicitly select every lifecycle status."),I(t,o.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),I(t,o.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),o}function na(e,t,n){I(n,e.has_more!==!1||e.next_cursor!==null||e.truncated!==!1||e.applied_limit!==void 0||t.no_truncate!==!0,"page_incomplete","Pagination or a row ceiling may have withheld items."),I(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let r=z(e.projection)?e.projection:{};I(n,r.mode!=="full"||r.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let i=z(e.omission_receipt)?e.omission_receipt:void 0;I(n,i===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),I(n,i!==void 0&&(i.has_omissions!==!1||i.omitted_field_group_count!==0||!Number.isSafeInteger(i.omitted_field_group_count)||!Array.isArray(i.omitted_field_groups)||i.omitted_field_groups.length!==0),"omission_receipt_invalid","The field-omission receipt is malformed or contradicts its no-omission claim."),I(n,i?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function ra(e){return e.contract_version!==1||e.command!=="list"||e.within_budget!==!0||e.strings_compacted!==!1||e.rows_compacted!==!1||e.result_omitted!==!1}function ia(e){if(!Array.isArray(e.requested_dimensions))return!1;let t=new Set(e.requested_dimensions);return["include","amount","cost"].every(n=>t.has(n))}function oa(e,t){let n=z(e.read_output)?e.read_output:void 0;I(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),I(t,n!==void 0&&ra(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),I(t,n!==void 0&&!ia(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),I(t,n?.strings_compacted===!0||n?.rows_compacted===!0||e.output_budget_truncation!==void 0,"budget_compaction","Universal output shaping compacted the result.");let r=z(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;I(t,n?.result_omitted===!0||r?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),I(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function sa(e,t){let n=e.map(r=>z(r)&&typeof r.id=="string"?r.id.trim():"");I(t,n.some(r=>r.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),I(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function aa(e){if(!z(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:ea[0],message:"The result must be an object with an items array."}]};let t=e,n=[],r=ta(t,n);return na(t,r,n),oa(t,n),sa(t.items,n),{ok:n.length===0,findings:n}}function ca(e){let t=aa(e);if(!t.ok)throw new tn(t.findings);let n=e;return{...n,complete_list:{contract_version:1,item_count:n.items.length,unique_item_id_count:new Set(n.items.map(r=>r.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function nf(e){ca(e)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="499dfc08-cf70-55fe-8868-65c3107e3a91")}catch{}})();async function af(e,t={}){let n=await Qi({pmRoot:T(process.cwd(),e.path),exhaustive:t.exhaustive,...t.status===void 0?{}:{statuses:t.status.flatMap(r=>r.split(",").map(i=>i.trim()).filter(Boolean))},...t.since===void 0?{}:{since:t.since},...t.threshold===void 0?{}:{threshold:t.threshold},...t.limit===void 0?{}:{limit:t.limit}});return{...n,clusters:n.clusters.map(r=>{let i=r.id;return{...r,canonical_id:i,close_command:`pm close <duplicate-id> --duplicate-of ${i}`}}),guidance:{strategy:"review_then_close_duplicate",command:"pm close <duplicate-id> --duplicate-of <canonical-id>"}}}(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]="1433b417-e41f-5963-a551-094132afd717")}catch{}})();var eo=16;async function to(e,t,n){let r=D(t,C()).type_to_folder,i=[],o=new Set,s=n;for(;s&&i.length<eo;){let a=s.trim().toLowerCase();if(!a||o.has(a))break;o.add(a);let d=await ne(e,s,t.id_prefix,t.item_format,r);if(!d)break;let c=await re(d,{schema:t.schema});i.push(c.document.metadata.id),s=c.document.metadata.parent}return i}async function ff(e){await oi({pmRoot:e.pmRoot,principal:e.principal,itemId:e.itemId,lineageIds:await to(e.pmRoot,e.settings,e.itemId)})}async function pf(e){await si(e)}async function hf(e){await ai({pmRoot:e.pmRoot,principal:e.principal,...e.itemId?{itemId:e.itemId,lineageIds:await to(e.pmRoot,e.settings,e.itemId)}:{}})}var gf={lineage_depth:eo,active_items:64,evidence_rows:32};function no(e){if(!e)return;let t={};for(let n of e.active_item_ids)t[n]=1;e.focused_item_id&&(t[e.focused_item_id]=1);for(let n of e.evidence){let r=/^lineage:(.+)$/u.exec(n)?.[1];r&&t[r]===void 0&&(t[r]=.75)}return Object.keys(t).length>0?t:void 0}import{encode as da}from"@toon-format/toon";(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]="809a4d75-4915-585d-9fc8-ad3e9ef15b1f")}catch{}})();var nn=["agenda","day","week","month"],rn=["markdown","toon","json"],la=["sun","mon","tue","wed","thu","fri","sat"],ua=365,ma=365,oo=28,fa=1e3;function on(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw new h(`${t} must be a non-negative integer`,f.USAGE);return n}function pa(e){if(!e)return new Set(["deadlines","reminders","events"]);let t=e.trim().toLowerCase();if(t==="all")return new Set(["deadlines","reminders","events"]);let n=t.split(/[|,]/).map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw new h("Calendar include filter must not be empty",f.USAGE);let r=new Set;for(let i of n){if(i==="deadlines"||i==="deadline"){r.add("deadlines");continue}if(i==="reminders"||i==="reminder"){r.add("reminders");continue}if(i==="events"||i==="event"||i==="scheduled"){r.add("events");continue}throw new h("Calendar include filter must be deadlines|reminders|events|scheduled|all",f.USAGE)}return r}function so(e,t){let n;for(let r of t){let i=xr(e,r,2);i!==null&&(n===void 0||i<n.distance)&&(n={choice:r,distance:i})}return n?.choice}function ha(e){if(!e)return"agenda";let t=e.trim().toLowerCase();if(!nn.includes(t)){let n=so(t,nn);throw new h(`Calendar view must be one of ${nn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function ga(e){if(!e)return;let t=e.trim().toLowerCase();if(!rn.includes(t)){let n=so(t,rn);throw new h(`Calendar format must be one of ${rn.join("|")}${n?`. Did you mean "${n}"?`:"."}`,f.USAGE)}return t}function Sf(e,t){let n=ga(e.format);if(t.json&&n&&n!=="json")throw new h("Cannot combine --json with --format markdown|toon",f.USAGE);return t.json?"json":n??"markdown"}function ya(e,t){if(e===void 0)return;let n=L(e,t);if(!n){let r=t.definitions.map(i=>i.id);throw new h(`Calendar status filter must be one of ${r.join("|")}`,f.USAGE)}return n}function _a(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new h("Calendar assignee filter must be one of assigned|unassigned",f.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new h(`Invalid calendar assignee filter "${e}". Allowed: assigned|unassigned`,f.USAGE);return t}function ht(e){return new Date(e).toISOString().slice(0,10)}function ao(e,t){if(!t||t==="UTC")return ht(e);try{let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),r=n.find(s=>s.type==="year")?.value,i=n.find(s=>s.type==="month")?.value,o=n.find(s=>s.type==="day")?.value;if(r&&i&&o)return`${r}-${i}-${o}`}catch{}return ht(e)}function dn(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0)).toISOString()}function V(e,t){let n=new Date(e);return new Date(n.getTime()+t*24*60*60*1e3).toISOString()}function co(e){let t=new Date(dn(e)),n=t.getUTCDay(),r=n===0?-6:1-n;return V(t.toISOString(),r)}function wa(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1,0,0,0,0)).toISOString()}function ba(e){let t=new Date(e);return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth()+1,1,0,0,0,0)).toISOString()}function va(e,t){return E(e,t)>=0?e:t}function ro(e){return Object.fromEntries([...e.entries()].sort(([t],[n])=>t.localeCompare(n)))}function io(e,t){e.set(t,(e.get(t)??0)+1)}function ka(e){if(!e)return null;let t=[`freq=${e.freq}`];if(e.interval!==void 0&&t.push(`interval=${e.interval}`),e.count!==void 0&&t.push(`count=${e.count}`),e.until&&t.push(`until=${e.until}`),e.by_weekday&&e.by_weekday.length>0){let n=[...e.by_weekday].sort((r,i)=>de(r)-de(i));t.push(`by_weekday=${n.join("|")}`)}if(e.by_month_day&&e.by_month_day.length>0){let n=[...e.by_month_day].sort((r,i)=>r-i);t.push(`by_month_day=${n.join("|")}`)}if(e.exdates&&e.exdates.length>0){let n=[...e.exdates].sort((r,i)=>r.localeCompare(i));t.push(`exdates=${n.join("|")}`)}return t.join(",")}function lo(e,t,n,r){let i=new Date(Date.UTC(e,t,n,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds()));if(!(i.getUTCFullYear()!==e||i.getUTCMonth()!==t||i.getUTCDate()!==n))return i.toISOString()}function uo(e){return la[new Date(e).getUTCDay()]}function Sa(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():null}function Ea(e){let t=new Set;for(let n of e??[]){let r=Sa(n);r&&t.add(r)}return t}function Ca(e,t,n,r,i){let o=e??V(n,-(r??ma)),s=t??V(e??n,i??ua);return{start:o,end:E(s,o)>0?s:V(o,1)}}function Ia(e,t,n,r){let i=t.by_weekday!==void 0?[...t.by_weekday]:[uo(e)],o=t.by_month_day!==void 0?[...t.by_month_day]:[new Date(e).getUTCDate()];return{startAt:e,startDate:new Date(e),window:n,maxOccurrences:r??fa,interval:t.interval??1,countLimit:t.count??Number.POSITIVE_INFINITY,until:t.until,excluded:Ea(t.exdates),weekdayFilter:t.by_weekday!==void 0?new Set(t.by_weekday):void 0,monthDayFilter:t.by_month_day!==void 0?new Set(t.by_month_day):void 0,sortedWeekdays:[...new Set(i)].sort((s,a)=>de(s)-de(a)),sortedMonthDays:[...new Set(o)].sort((s,a)=>s-a),occurrences:[],produced:0}}function gt(e,t){return E(t,e.startAt)<0?"continue":e.until&&E(t,e.until)>0||E(t,e.window.end)>=0?"stop":e.excluded.has(t)?"continue":(e.produced+=1,E(t,e.window.start)>=0&&e.occurrences.push(t),e.produced>=e.countLimit||e.occurrences.length>=e.maxOccurrences?"stop":"continue")}function yt(e,t){let n=uo(t),r=new Date(t).getUTCDate(),i=!e.weekdayFilter||e.weekdayFilter.has(n),o=!e.monthDayFilter||e.monthDayFilter.has(r);return i&&o}function xa(e){let t=e.startAt;for(let n=0;n<e.maxOccurrences&&!(yt(e,t)&>(e,t)==="stop");n+=1)t=V(t,e.interval);return e.occurrences}function Ta(e,t,n){let r=de(n),i=V(t,r),o=new Date(i);return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),e.startDate.getUTCHours(),e.startDate.getUTCMinutes(),e.startDate.getUTCSeconds(),e.startDate.getUTCMilliseconds())).toISOString()}function Ra(e){let t=co(e.startAt);for(let n=0;n<e.maxOccurrences;n+=1){let r=V(t,n*e.interval*7);for(let i of e.sortedWeekdays){let o=Ta(e,r,i);if(yt(e,o)&>(e,o)==="stop")return e.occurrences}}return e.occurrences}function Aa(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=new Date(Date.UTC(t,n+r*e.interval,1,0,0,0,0));for(let o of e.sortedMonthDays){let s=lo(i.getUTCFullYear(),i.getUTCMonth(),o,e.startDate);if(!(!s||!yt(e,s))&>(e,s)==="stop")return e.occurrences}}return e.occurrences}function Da(e){let t=e.startDate.getUTCFullYear(),n=e.startDate.getUTCMonth();for(let r=0;r<e.maxOccurrences;r+=1){let i=t+r*e.interval;for(let o of e.sortedMonthDays){let s=lo(i,n,o,e.startDate);if(!(!s||!yt(e,s))&>(e,s)==="stop")return e.occurrences}}return e.occurrences}function Fa(e,t,n,r){let i=Ia(e,t,n,r);return t.freq==="daily"?xa(i):t.freq==="weekly"?Ra(i):t.freq==="monthly"?Aa(i):Da(i)}function mo(e){return[...e].sort((t,n)=>{let r=E(t.at,n.at);if(r!==0)return r;let i=t.item_priority-n.item_priority;if(i!==0)return i;let o=t.item_id.localeCompare(n.item_id);if(o!==0)return o;let s=t.kind.localeCompare(n.kind);if(s!==0)return s;let a=String(t.event_title).localeCompare(String(n.event_title));return a!==0?a:String(t.reminder_text).localeCompare(String(n.reminder_text))})}function ln(e){return{item_id:e.id,item_title:e.title,item_type:e.type,item_status:e.status,item_priority:e.priority,item_assignee:e.assignee??null,item_deadline:e.deadline??null,item_tags:e.tags}}function Ma(e){return e.deadline?{at:e.deadline,date:ht(e.deadline),kind:"deadline",reminder_text:null,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...ln(e),item_deadline:e.deadline}:null}function $a(e){return(e.reminders??[]).map(t=>({at:t.at,date:ht(t.at),kind:"reminder",reminder_text:t.text,event_title:null,event_end:null,event_location:null,event_all_day:null,event_timezone:null,event_recurring:null,event_recurrence_rule:null,...ln(e)}))}function Oa(e,t){if(!t)return null;let n=Date.parse(t)-Date.parse(e);return Number.isFinite(n)&&n>0?n:null}function La(e,t,n){return t.recurrence&&n!==null?new Date(new Date(e).getTime()+n).toISOString():t.end_at??null}function Na(e,t,n,r){let i=ka(t.recurrence),o=Oa(t.start_at,t.end_at);return(t.recurrence?Fa(t.start_at,t.recurrence,n,r):[t.start_at]).map(s=>({at:s,date:t.all_day===!0?s.slice(0,10):ao(s,t.timezone),kind:"event",reminder_text:t.description??null,event_title:t.title??e.title,event_end:La(s,t,o),event_location:t.location??null,event_all_day:t.all_day??null,event_timezone:t.timezone??null,event_recurring:!!t.recurrence,event_recurrence_rule:i,...ln(e)}))}function Pa(e,t,n,r){let i=[];for(let o of e){let s=n.has("deadlines")?Ma(o):null;s&&i.push(s),n.has("reminders")&&i.push(...$a(o));for(let a of n.has("events")?o.events??[]:[])i.push(...Na(o,a,t,r))}return mo(i)}function ja(e,t,n,r,i){let o=$i(t.type,n),s=t.tag?.trim().toLowerCase(),a=Mi(t.priority),d=ya(t.status,r),c=t.assignee?.trim(),l=_a(t.assigneeFilter),u=t.sprint?.trim(),m=t.release?.trim();if(c&&(c.toLowerCase()==="none"||c.toLowerCase()==="null"))throw new h('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',f.USAGE);if(c!==void 0&&l==="unassigned")throw new h("Cannot combine --assignee with --assignee-filter unassigned",f.USAGE);return e.filter(p=>Ua(p,{typeFilter:o,tagFilter:s,priorityFilter:a,statusFilter:d,assigneeFilter:c,assigneeModeFilter:l,sprintFilter:u,releaseFilter:m,runtimeFieldFilters:i}))}function Ua(e,t){return Ba(e,t)&&Ga(e,t)&&ct(e,t.runtimeFieldFilters)}function Ba(e,t){return!(t.typeFilter&&e.type!==t.typeFilter||t.tagFilter&&!e.tags.some(n=>n.trim().toLowerCase()===t.tagFilter)||t.priorityFilter!==void 0&&e.priority!==t.priorityFilter||t.statusFilter&&e.status!==t.statusFilter)}function Ga(e,t){return!(t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee||t.assigneeFilter!==void 0&&e.assignee!==t.assigneeFilter||t.sprintFilter!==void 0&&e.sprint!==t.sprintFilter||t.releaseFilter!==void 0&&e.release!==t.releaseFilter)}function Ha(e,t,n){return!(t&&E(e.at,t)<0||n&&E(e.at,n)>=0)}function sn(e,t,n){return e.trim().toLowerCase()==="today"?dn(t):H(e,new Date(t),n)}function qa(e,t,n){let r=t.date?sn(t.date,n,"--date"):n,i=t.past===!0,o=t.fullPeriod===!0,s=t.from?sn(t.from,n,"--from"):void 0,a=t.to?sn(t.to,n,"--to"):void 0;if(s&&a&&E(s,a)>=0)throw new h("Calendar --from must be before --to",f.USAGE);if(e!=="agenda"&&(t.from!==void 0||t.to!==void 0))throw new h("--from and --to are only supported for --view agenda",f.USAGE);if(e==="agenda")return Wa(r,t,n,i,o,s,a);if(e==="day"){let c=dn(r);return an(r,n,i,o,c,V(c,1))}if(e==="week"){let c=co(r);return an(r,n,i,o,c,V(c,7))}let d=wa(r);return an(r,n,i,o,d,ba(r))}function Wa(e,t,n,r,i,o,s){if(i)throw new h("--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.",f.USAGE);return{anchor:e,start:o??(t.date?e:r?void 0:n),end:s,fullPeriod:!1}}function an(e,t,n,r,i,o){let s=n||r;return{anchor:e,start:s?i:va(i,t),end:o,periodStart:i,periodEnd:o,fullPeriod:s}}function za(e){let t=new Map;for(let n of e){let r=t.get(n.date)??[];r.push(n),t.set(n.date,r)}return[...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({date:n,count:r.length,events:mo(r)}))}function Va(e){let t=new Set,n=new Map,r=new Map,i=0,o=0,s=0,a=0;for(let d of e)t.add(d.item_id),io(n,d.item_type),io(r,d.item_status),d.kind==="deadline"?i+=1:d.kind==="reminder"?o+=1:(s+=1,d.event_recurring===!0&&(a+=1));return{events:e.length,items:t.size,deadlines:i,reminders:o,scheduled:s,by_kind:{deadline:i,reminder:o,event:s},by_type:ro(n),by_status:ro(r),recurring_events:a}}function Ka(e){let t=e.start??"unbounded",n=e.end??"unbounded";return`${t} -> ${n}`}function fo(e,t){if(t&&t!=="UTC")try{let n=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(e)),r=n.find(o=>o.type==="hour")?.value,i=n.find(o=>o.type==="minute")?.value;if(r&&i)return`${r}:${i}`}catch{}return`${new Date(e).toISOString().slice(11,16)}Z`}function cn(e){let t=Object.entries(e);return t.length===0?"empty":t.map(([n,r])=>`${n}=${r}`).join(", ")}function Ya(e){return e.event_end?e.event_all_day===!0?e.event_end.slice(0,10):e.date===ao(e.event_end,e.event_timezone)?fo(e.event_end,e.event_timezone):e.event_end:null}function Xa(e){let t=`${fo(e.at,e.event_timezone)} [${e.kind}] ${e.item_id} type=${e.item_type} p${e.item_priority} ${e.item_status} ${e.item_title}`;if(e.kind==="reminder"){let n=e.reminder_text??"";return`${t} \u2014 ${n} reminder=${JSON.stringify(n)}`}if(e.kind==="event"){let n=[],r=e.event_title??e.item_title;e.event_title!==null&&e.event_title!==e.item_title&&(n.push(r),n.push(`title=${JSON.stringify(r)}`)),e.event_recurring&&(n.push("(recurring)"),n.push("recurring=true"));let i=Ya(e);return i&&n.push(`end=${i}`),e.event_all_day!==null&&n.push(`all_day=${e.event_all_day?"true":"false"}`),e.event_timezone&&n.push(`timezone=${e.event_timezone}`),e.event_location&&(n.push(`@ ${e.event_location}`),n.push(`location=${JSON.stringify(e.event_location)}`)),e.event_recurrence_rule&&n.push(`recurrence=${e.event_recurrence_rule}`),e.reminder_text&&n.push(`description=${JSON.stringify(e.reminder_text)}`),`${t} \u2014 ${n.join(" ")}`}return t}function Ef(e){let t=[];if(t.push(`# pm calendar (${e.view})`),t.push(""),t.push(`- now: ${e.now}`),t.push(`- window: ${Ka(e.range)}`),e.range.period_start&&e.range.period_end&&(t.push(`- period: ${e.range.period_start} -> ${e.range.period_end}`),t.push(`- period-mode: ${e.range.full_period?"full-period":"active-window"}`)),t.push(`- events: ${e.summary.events} (deadlines: ${e.summary.deadlines}, reminders: ${e.summary.reminders}, scheduled: ${e.summary.scheduled})`),t.push(`- items: ${e.summary.items}`),t.push(`- by-kind: ${cn(e.summary.by_kind)}`),t.push(`- by-type: ${cn(e.summary.by_type)}`),t.push(`- by-status: ${cn(e.summary.by_status)}`),t.push(`- recurring-events: ${e.summary.recurring_events}`),t.push(""),e.events.length===0)return t.push("No calendar events matched the selected filters."),t.join(`
|
|
2
2
|
`);for(let n of e.days){t.push(`## ${n.date} (${n.count})`);for(let r of n.events)t.push(`- ${Xa(r)}`);t.push("")}if(e.warnings&&e.warnings.length>0){t.push("### warnings");for(let n of e.warnings)t.push(`- ${n}`);t.push("")}return Qa(t.join(`
|
|
3
3
|
`))}function Cf(e){return da(e)}function Qa(e){let t=e.length;for(;t>0&&e[t-1]===`
|
|
4
4
|
`;)t-=1;return e.slice(0,t)}function Ja(e){let t=F(),n=ha(e.view),r=qa(n,e,t),i=q(e.limit),o=pa(e.include),s=on(e.recurrenceLookaheadDays,"Calendar recurrence lookahead days"),a=on(e.recurrenceLookbackDays,"Calendar recurrence lookback days"),d=on(e.occurrenceLimit,"Calendar occurrence limit");if(d!==void 0&&d<1)throw new h("Calendar occurrence limit must be >= 1",f.USAGE);let c=o.has("events")&&!o.has("deadlines")&&!o.has("reminders"),l=e.to!==void 0||s!==void 0||a!==void 0||d!==void 0,u=c&&!l;return{nowValue:t,view:n,rangeBounds:r,limit:i,includeSources:o,occurrenceLimit:d,recurrenceLookaheadDays:u?oo:s,recurrenceLookbackWindowDays:u&&a===void 0?0:a,eventsOnlyCapApplied:u}}function Za(e,t){t&&e.push(`recurring_events_default_cap_applied:lookback=0d,lookahead=${oo}d -- use --recurrence-lookback-days/--recurrence-lookahead-days or --to for wider range`)}function ec(e,t){return{type:e.type??null,tag:e.tag??null,priority:e.priority??null,status:e.status??null,assignee:e.assignee??null,assignee_filter:e.assigneeFilter??null,sprint:e.sprint??null,release:e.release??null,runtime_filters:t,limit:e.limit??null,include:e.include??null,full_period:e.fullPeriod===!0?"true":null,recurrence_lookahead_days:e.recurrenceLookaheadDays??null,recurrence_lookback_days:e.recurrenceLookbackDays??null,occurrence_limit:e.occurrenceLimit??null}}function tc(e,t){return{start:t.start??null,end:t.end??null,period_start:t.periodStart??null,period_end:t.periodEnd??null,full_period:t.fullPeriod,past:e.past===!0,from:e.from??null,to:e.to??null}}async function po(e,t){let n=T(process.cwd(),t.path);await G(n);let r=Ja(e),i=await M(n),o=P(i.schema),s=Q(i.schema),a=at(e,s,"calendar"),d=D(i,C()),c=[];Za(c,r.eventsOnlyCapApplied);let l=await me(n,i.item_format,d.type_to_folder,c,i.schema),u=ja(l,e,d,o,a),m=Ca(r.rangeBounds.start,r.rangeBounds.end,r.nowValue,r.recurrenceLookbackWindowDays,r.recurrenceLookaheadDays),p=Pa(u,m,r.includeSources,r.occurrenceLimit).filter(w=>Ha(w,r.rangeBounds.start,r.rangeBounds.end)),g=r.limit===void 0?p:p.slice(0,r.limit),_=za(g),y=[...new Set(c)].sort((w,S)=>w.localeCompare(S));return{view:r.view,output_default:"markdown",now:r.nowValue,anchor:r.rangeBounds.anchor,range:tc(e,r.rangeBounds),filters:ec(e,a),summary:Va(g),events:g,days:_,...y.length>0?{warnings:y}:{}}}import rc from"node:fs/promises";import _o 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]="2e0c4f91-ea56-5bec-b071-448eff719fec")}catch{}})();var un={version:1,aliases:{}};function _t(e=[]){let t=new Set(Ee),n=r=>{/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(r)&&t.add(r)};for(let r of e){for(let i of Object.keys(r.provenance_environment_keys??{}))n(i);for(let i of Object.keys(r.provenance_resolvers??{}))n(i);for(let i of r.provenance_unavailable_dimensions??[])n(i)}return[...t].sort()}function ho(e){if(e===void 0)return;let t=(typeof e=="string"?[e]:e).flatMap(n=>n.split(",")).map(n=>n.trim()).filter(n=>n.length>0);return t.length===0?void 0:new Set(t)}function mn(e,t){if(e.agent_harness?.trim())return{agent_harness:e.agent_harness,harness_source:"recorded"};let n=t.aliases[e.author];return n?{agent_harness:n,harness_source:"vocabulary"}:{harness_source:"unresolved"}}function nc(e,t=Ee){let n=new Set(t),r=new Map,i=e.provenance===void 0?[]:typeof e.provenance=="string"?[e.provenance]:e.provenance;for(let o of i.flatMap(s=>s.split(","))){let s=o.indexOf("=");if(s<0)throw new h(`Provenance predicate must use dimension=value; received "${o.trim()}".`,f.USAGE,{code:"invalid_provenance_predicate"});let a=o.slice(0,s).trim().toLowerCase(),d=o.slice(s+1).trim();if(!n.has(a))throw new h(`Unknown provenance dimension "${a||o.trim()}". Declared dimensions: ${[...n].sort().join(", ")}.`,f.USAGE,{code:"unknown_provenance_dimension"});if(d.length===0)throw new h(`Provenance predicate must use dimension=value; received "${o.trim()}".`,f.USAGE,{code:"invalid_provenance_predicate"});let c=r.get(a)??new Set;c.add(d),r.set(a,c)}return r}function wt(e,t=un,n={}){let r=mn(e,t);return{...n.itemId===void 0?{}:{item_id:n.itemId},...n.version===void 0?{}:{version:n.version},ts:e.ts,op:e.op,author:e.author,...e.author_source===void 0?{}:{author_source:e.author_source},...r,vocabulary_version:t.version,...e.agent_instance===void 0?{}:{agent_instance:e.agent_instance},agent_provenance:e.agent_provenance??{},...e.message===void 0?{}:{message:e.message}}}function bt(e,t=un,n=Ee){let r=ho(e.harness),i=ho(e.agentInstance),o=nc(e,n);return s=>{let a=mn(s,t).agent_harness;if(r&&(!a||!r.has(a))||i&&!i.has(s.agent_instance??""))return!1;for(let[d,c]of o){let l=s.agent_provenance?.[d];if(!l||!c.has(l.value))return!1}return!0}}function vt(e,t=un,n=Ee){let r=new Set(n),i=new Map,o=0;for(let s of e){for(let a of Object.keys(s.agent_provenance??{}))r.add(a);mn(s,t).agent_harness?o+=1:i.set(s.author,(i.get(s.author)??0)+1)}return{entries:e.length,vocabulary_version:t.version,harness:{resolved:o,unresolved:e.length-o,unresolved_authors:[...i].map(([s,a])=>({author:s,entries:a})).sort((s,a)=>a.entries-s.entries||s.author.localeCompare(a.author)).slice(0,20)},dimensions:[...r].sort().map(s=>{let a=0,d=0;for(let c of e){let l=c.agent_provenance?.[s];l===null?d+=1:l!==void 0&&(a+=1)}return{dimension:s,observed:a,unavailable:d,legacy_missing:e.length-a-d}})}}(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]="a4394793-55d4-5049-ab20-707c1c3d9f2c")}catch{}})();var ic=20,oc=5,sc=15,ac="-24h";function Uf(e){let t={...e};return t.full===!0?(t.raw=!0,t.compact=!1):t.raw===!0&&t.compact===void 0&&(t.compact=!0),delete t.full,t}var cc={digest:"activity_digest",compact:"compact_activity",provenance:"provenance_activity",full:"activity"};function fn(e,t){if(e===void 0)return;let n=e.trim();if(n.length===0)throw new h(`${t} must not be empty`,f.USAGE);return n}function go(e,t,n){if(e===void 0)return;let r=e.trim();if(r.length===0)throw new h("Activity time bounds must not be empty",f.USAGE);let i=n==="--from"&&/^\d+[hdwm]$/iu.test(r)?`-${r}`:r;return H(i,new Date(t),n)}function dc(e,t,n){return!(e.ts.length===0&&(t||n)||t&&E(e.ts,t)<0||n&&E(e.ts,n)>=0)}function yo(e,t){return t===void 0?e:e.slice(0,t)}function Re(e,t=""){return typeof e=="string"?e:t}function lc(e,t){return{...t,id:e,ts:Re(t.ts),author:Re(t.author,"unknown"),op:Re(t.op,"unknown"),patch:Array.isArray(t.patch)?t.patch:[],before_hash:Re(t.before_hash),after_hash:Re(t.after_hash)}}function uc(e){return[...e].sort((t,n)=>{let r=n.ts.localeCompare(t.ts);if(r!==0)return r;let i=t.id.localeCompare(n.id);return i!==0?i:t.op.localeCompare(n.op)})}async function mc(e){try{return(await rc.readdir(e)).filter(t=>t.endsWith(".jsonl")).sort((t,n)=>t.localeCompare(n))}catch(t){if(Fr(t))return[];throw t}}function fc(e){return e.raw!==!0&&e.compact!==!0&&e.provenance!==!0?"digest":e.provenance===!0?"provenance":e.compact===!0||e.raw===!0&&e.compact!==!1?"compact":"full"}function pc(e,t,n){if(e.unbounded!==!0)return t!==void 0?t:n==="digest"?sc:n==="compact"?ic:oc}function hc(e,t){let n=F(),r=t==="digest",i=go(e.to??(r?n:void 0),n,"--to"),o=go(e.from??(r?ac:void 0),e.from===void 0&&r?i:n,"--from");if(o&&i&&E(o,i)>=0)throw new h("Activity --from must be before --to",f.USAGE);let s=ue(e.limit);if(e.unbounded===!0&&s!==void 0)throw new h("Activity --unbounded cannot be combined with --limit",f.USAGE);return{id:fn(e.id,"Activity --id"),op:fn(e.op,"Activity --op"),author:fn(e.author,"Activity --author"),from:o,to:i,limit:pc(e,s,t),limitSource:e.unbounded===!0||s!==void 0?"explicit":"default",harness:e.harness,agentInstance:e.agentInstance,provenance:e.provenanceFilter}}async function gc(e){let t=T(process.cwd(),e.path);return await G(t),{pmRoot:t,settings:await M(t)}}async function yc(e){let t=D(e.settings,C()),n=await me(e.pmRoot,e.settings.item_format,t.type_to_folder,void 0,e.settings.schema);await _i({pmRoot:e.pmRoot,settings:e.settings,itemIds:n.map(i=>i.id),commandLabel:"activity"});let r=_o.join(e.pmRoot,"history");return await Se({path:r,scope:"project"}),{historyDir:r,itemsById:new Map(n.map(i=>[i.id,{title:i.title,type:i.type,status:i.status}]))}}function _c(e,t,n){return n.op&&e.op!==n.op||n.author&&e.author!==n.author?!1:dc(t,n.from,n.to)}async function wc(e,t){let n=[];for(let r of await mc(e)){let i=r.slice(0,-6);if(t.id&&i!==t.id)continue;let o=await te(_o.join(e,r),i);for(let s of o){let a=lc(i,s);_c(s,a,t)&&n.push(a)}}return n}function bc(e){return e.map(t=>({id:t.id,op:t.op,ts:t.ts,author:t.author,...t.message?{msg:t.message}:{}}))}function vc(e){let t=[...e.entries()].sort(([r,i],[o,s])=>s-i||r.localeCompare(o)),n=t.slice(0,4).map(([r,i])=>`${r}:${i}`);return t.length>n.length&&n.push(`+${t.length-n.length}`),n.join(",")}function kc(e,t){let n=new Map;for(let r of e){let i=n.get(r.id);if(i===void 0){n.set(r.id,{firstTs:r.ts,lastTs:r.ts,eventCount:1,operations:new Map([[r.op,1]])});continue}i.eventCount+=1,E(r.ts,i.firstTs)<0&&(i.firstTs=r.ts),E(r.ts,i.lastTs)>0&&(i.lastTs=r.ts),i.operations.set(r.op,(i.operations.get(r.op)??0)+1)}return[...n.entries()].map(([r,i])=>{let o=t.get(r);return{id:r,type:o?.type??"unknown",status:o?.status??"unknown",title:(o?.title??"(item metadata unavailable)").slice(0,160),event_count:i.eventCount,first_ts:i.firstTs,last_ts:i.lastTs,operations:vc(i.operations)}}).sort((r,i)=>E(i.last_ts,r.last_ts)||r.id.localeCompare(i.id))}function Sc(e){let t=new Map;for(let i of e)t.set(i.op,(t.get(i.op)??0)+1);let n=[...t.entries()].sort((i,o)=>o[1]-i[1]||i[0].localeCompare(o[0])),r=n.slice(0,8);return r.length<n.length&&r.push([`+${String(n.length-r.length)}`,n.slice(r.length).reduce((i,[,o])=>i+o,0)]),Object.fromEntries(r)}function Ec(e,t,n,r,i){if(e==="digest"){let s=kc(t,r),a=yo(s,n);return{rows:{activity_digest:a},compact:!1,totalRows:s.length,returnedRows:a.length}}let o=yo(t,n);return e==="compact"?{rows:{compact_activity:bc(o)},compact:!0,totalRows:t.length,returnedRows:o.length}:e==="provenance"?{rows:{provenance_activity:o.map(i)},compact:!1,totalRows:t.length,returnedRows:o.length}:{rows:{activity:o},compact:!1,totalRows:t.length,returnedRows:o.length}}async function wo(e,t){let n=await gc(t),r=fc(e),i=hc(e,r),o=await yc(n),s=_t(n.settings.agent_identity.harness_signals),a=n.settings.agent_identity.identity_vocabulary,d=bt({harness:i.harness,agentInstance:i.agentInstance,provenance:i.provenance},a,s),c=uc(await wc(o.historyDir,i)).filter(d),l=Ec(r,c,i.limit,o.itemsById,m=>wt(m,a,{itemId:m.id})),u=l.totalRows-l.returnedRows;return{...l.rows,compact:l.compact,projection:{mode:r,row_key:cc[r]},omission_receipt:Qe("activity",r),count:l.returnedRows,total_count:l.totalRows,limit:i.limit??null,omitted_count:u,has_more:u>0,...r==="digest"?{activity_summary:{window:{from:i.from,to:i.to},event_count:c.length,item_count:l.totalRows,author_count:new Set(c.map(m=>m.author)).size,operation_counts:Sc(c)}}:{},...e.provenanceSummary===!0?{provenance_summary:vt(c,a,s)}:{},applied_bound:{kind:i.limit===void 0?"unbounded":"limit",source:i.limitSource,value:i.limit??null}}}(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]="9cdfc765-7370-57bb-a4dc-be2df8aa1e6f")}catch{}})();var bo="1970-01-01T00:00:00.000Z";function Ae(e){if(typeof e!="string")return null;let t=e.trim();if(!Xr(t)&&!/^\d{4}-\d{2}-\d{2}$/u.test(t))return null;try{return H(t,new Date(Number.NaN),"context signal recency coordinate")}catch{return null}}(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]="e750a203-8bef-5bfd-85a5-a584c2105472")}catch{}})();var pn=["structural","recency","activity_density","graph_proximity","claim_focus","priority_pressure","risk_pressure","deadline_pressure","knowledge_density","author_affinity","usage_affinity","semantic_similarity"],Cc=Symbol("no-context-author"),Ic=Symbol("no-item-assignee");function vo(e,t){if(typeof e!="string")return t;let n=e.trim().toLowerCase();return n.length>0?n:t}function xc(e){if(typeof e!="string")return;let t=/^v?(\d{4})\.(\d{1,2})\.(\d{1,2})(?:$|[-+])/u.exec(e.trim());if(!t)return;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),o=new Date(Date.UTC(n,r-1,i));return o.getUTCFullYear()===n&&o.getUTCMonth()===r-1&&o.getUTCDate()===i?o.toISOString():void 0}function Tc(e){let t=xc(e.release);return t!==void 0?{source:"release_cohort",coordinate:t}:{source:"created_at",coordinate:Ae(e.created_at)??bo}}function Rc(e){if(!["substantive_history","release_cohort","created_at"].includes(e.source)||(e.source==="substantive_history"?e.history_op!==void 0&&typeof e.history_op!="string"||e.event_class!==void 0&&e.event_class!=="substantive":e.history_op!==void 0||e.event_class!==void 0))throw new TypeError("Context signal recency provenance must match its source");let t=Ae(e.coordinate);if(t===null)throw new TypeError("Context signal recency coordinate must be a valid absolute timestamp with millisecond precision");return{...e,coordinate:t}}function Ac(e,t){let n=typeof e=="number"?e:typeof e=="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)?1-Math.min(Math.max(n,0),t)/t:0}function Dc(e,t){let n=typeof e=="string"?Date.parse(e):e instanceof Date?e.getTime():typeof e=="number"?e:Number.NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return 0;let r=(n-t)/864e5;return r<=0?1:1/(1+r/30)}function Fc(e){let t=typeof e=="string"?e.trim().toLowerCase():void 0;return t==="critical"||t==="high"?1:t==="medium"?.5:t==="low"?.1:0}function kt(e,t,n){return e?.[t]??n}function St(e,t){let n=new Map(e.map(c=>{let l=t.recencyEvidence?.[c.id];return[c.id,l===void 0?Tc(c):Rc(l)]})),r=[...e].sort((c,l)=>{let u=n.get(c.id).coordinate,m=n.get(l.id).coordinate;return E(m,u)||c.id.localeCompare(l.id)}),i=new Map(r.map((c,l)=>[c.id,l])),o=Math.max(e.length-1,1),s=vo(t.author,Cc),a=L("in_progress",t.statusRegistry),d=Date.parse(t.now);return e.map(c=>{let l=vo(c.assignee,Ic)===s,u=(c.comments?.length??0)+(c.notes?.length??0)+(c.learnings?.length??0);return{id:c.id,item:c,signal_provenance:{recency:n.get(c.id)},signals:{recency:e.length===1?1:1-i.get(c.id)/o,activity_density:t.activityDensity?.[c.id],graph_proximity:kt(t.graphProximity,c.id,c.parent?.3:0),claim_focus:kt(t.claimFocus,c.id,R(c.status,t.statusRegistry)===a?1:l?.75:0),priority_pressure:Ac(c.priority,4),risk_pressure:Fc(c.risk),deadline_pressure:Dc(c.deadline,d),knowledge_density:kt(t.knowledgeDensity,c.id,Math.min(u/5,1)),author_affinity:kt(t.authorAffinity,c.id,l?1:0),usage_affinity:t.usageAffinity?.[c.id],semantic_similarity:t.semanticSimilarity?.[c.id]}}})}var Mc="context_relevance",$c={structural:.4,recency:.35,activity_density:.25,graph_proximity:.15,claim_focus:.6,priority_pressure:.35,risk_pressure:.2,deadline_pressure:.45,knowledge_density:.25,author_affinity:.2,usage_affinity:.3,semantic_similarity:.5},Oc=new TextEncoder;function Lc(e){let t=new Set;for(let n of e){if(typeof n.id!="string"||n.id.trim().length===0||t.has(n.id))throw new TypeError("Context relevance candidates require unique non-empty ids");t.add(n.id);for(let[r,i]of Object.entries(n.signals??{})){if(r==="structural"||!pn.includes(r))throw new TypeError(`Unknown context relevance signal: ${r}`);if(i!==void 0&&(!Number.isFinite(i)||i<0||i>1))throw new TypeError(`Context relevance signal ${r} must be a finite number from 0 to 1`)}}}function Nc(e){let t={...$c};for(let[n,r]of Object.entries(e??{}))r!==void 0&&pn.includes(n)&&(t[n]=r);for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<0)throw new TypeError(`Context relevance weight ${n} must be a finite non-negative number`);return t}function So(e,t={}){Lc(e);let n=Nc(t.weights),r=Math.max(e.length-1,1),i=new Set(["structural"]);for(let a of e)for(let[d,c]of Object.entries(a.signals??{}))c!==void 0&&i.add(d);let o=pn.filter(a=>i.has(a)),s=e.map((a,d)=>{let c={structural:e.length===1?1:1-d/r,...a.signals},l={},u=0,m=0;for(let p of o){let g=c[p];if(g===void 0)continue;let _=g*n[p];l[p]=_,u+=_,m+=n[p]}return{...a,baseline_rank:d+1,rank:0,score:m===0?0:u/m,contributions:l}});return s.sort((a,d)=>d.score-a.score||a.baseline_rank-d.baseline_rank),s.forEach((a,d)=>{a.rank=d+1}),{model:"default-weighted-v1",available_signals:o,ranked:s}}async function Pc(e,t={}){let n=So(e,t);if(!t.scorer)return n;let r=await t.scorer({candidates:e,default_report:n}),i=new Map;for(let s of r){if(i.has(s.id)||!Number.isFinite(s.score))throw new TypeError("Context relevance scorer must return one finite score for every candidate");i.set(s.id,s.score)}if(i.size!==e.length||e.some(s=>!i.has(s.id)))throw new TypeError("Context relevance scorer must return one finite score for every candidate");let o=n.ranked.map(s=>{let a=i.get(s.id);return{...s,score:a,contributions:{custom:a}}});return o.sort((s,a)=>a.score-s.score||s.baseline_rank-a.baseline_rank),o.forEach((s,a)=>{s.rank=a+1}),{model:"custom",available_signals:n.available_signals,ranked:o}}async function Et(e,t,n={}){let r=So(t,n),i=await Br(Mc,{surface:e,candidates:t,default_report:r});if(!i.handled)return i.warnings.length>0?{...r,warnings:i.warnings}:r;if(!Array.isArray(i.result)||!i.result.every(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.score=="number"&&Number.isFinite(o.score)))return{...r,warnings:[...i.warnings,"extension_context_relevance_invalid_result"]};try{let o=await Pc(t,{...n,scorer:()=>i.result});return i.warnings.length>0?{...o,warnings:i.warnings}:o}catch{return{...r,warnings:[...i.warnings,"extension_context_relevance_invalid_result"]}}}var jc=["ndcg","reciprocal_rank","required_recall","continuity_coverage","token_budget_adherence"];function ko(e,t){return e.length===0?1:e.filter(n=>t.has(n)).length/e.length}function Uc(e){if(!Number.isFinite(e.actual_tokens)||e.actual_tokens<0||!Number.isFinite(e.token_budget)||e.token_budget<=0)throw new TypeError("Context ranking token counts require actual_tokens >= 0 and token_budget > 0");let t=e.judgments??{},n=e.ranked_ids.map(c=>Math.max(0,t[c]??0)),r=Object.values(t).map(c=>Math.max(0,c)).sort((c,l)=>l-c).slice(0,n.length||1),i=c=>c.reduce((l,u,m)=>l+(2**u-1)/Math.log2(m+2),0),o=i(r),s=n.findIndex(c=>c>0),a=new Set(e.ranked_ids),d=e.actual_tokens<=e.token_budget;return{ndcg:o===0?1:i(n)/o,reciprocal_rank:s<0?0:1/(s+1),required_recall:ko(e.required_ids??[],a),continuity_coverage:ko(e.continuity_ids??[],a),token_budget_adherence:d?1:e.token_budget/e.actual_tokens,within_token_budget:d}}function Bc(e){return Math.ceil(Oc.encode(JSON.stringify(e)).byteLength/4)}function Gc(e){return Math.round(e*1e4)/1e4}function Hc(e,t){let n=t==="context"?[...e.high_level??[],...e.low_level??[],...e.blocked_fallback??[]].map(o=>o.id):[...e.recommended?[e.recommended]:[],...e.ready??[]].map(o=>o.id),r=new Set(n),i=(e.ranking?.items??[]).filter(o=>r.has(o.id)).map(o=>({id:o.id,contributions:o.contributions}));return{rankedIds:n,attribution:i}}async function qc(e,t){if(e.id.trim().length===0||e.rationale.trim().length===0)throw new TypeError("Context evaluation scenarios require non-empty id and rationale values");let n=e.surface==="context"?await t.context({...e.options,explainRanking:!0,outputBudget:e.options?.outputBudget??"unbounded"}):await t.next({...e.options,explainRanking:!0,outputBudget:e.options?.outputBudget??"unbounded"}),{rankedIds:r,attribution:i}=Hc(n,e.surface),o={...n,ranking:void 0},s=Bc(o);return{id:e.id,surface:e.surface,rationale:e.rationale,ranked_ids:r,actual_tokens:s,metrics:Uc({ranked_ids:r,judgments:e.judgments,required_ids:e.required_ids,continuity_ids:e.continuity_ids,actual_tokens:s,token_budget:e.token_budget}),attribution:i}}function Wc(e,t){if(e.length===0)throw new TypeError("Context evaluation requires at least one scenario report");let n=jc;for(let o of n)if(!Number.isFinite(t[o]))throw new TypeError(`Context evaluation threshold ${o} must be a finite number`);let r=Object.fromEntries(n.map(o=>[o,Gc(e.reduce((s,a)=>s+a.metrics[o],0)/e.length)])),i=n.filter(o=>r[o]<t[o]).map(o=>`${o}:${r[o]}<${t[o]}`);return{scenario_count:e.length,aggregate:r,scenarios:[...e],passed:i.length===0,failures:i}}async function Kf(e,t,n){let r=[];for(let i of e)r.push(await qc(i,t));return Wc(r,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]="d07ec2dc-762a-58ab-83ee-734ca1bf76a7")}catch{}})();var zc={balanced:{redundancyPenalty:.35,uncertaintyPenalty:.2},context:{redundancyPenalty:.45,uncertaintyPenalty:.15},next:{redundancyPenalty:.25,uncertaintyPenalty:.3}},Vc=["identity","summary","full"];function Kc(e){if(!e.id.trim()||!Number.isInteger(e.rank)||e.rank<1)throw new TypeError("Context packing candidates require a non-empty id and positive integer rank");if(!Number.isFinite(e.score)||e.score<0)throw new TypeError("Context packing candidate scores must be finite and non-negative");let t=Vc.map(n=>e.token_costs[n]);if(t.some(n=>!Number.isInteger(n)||n<1)||t[0]>t[1]||t[1]>t[2])throw new TypeError("Context projection costs must be positive monotone integers");if(e.uncertainty!==void 0&&(!Number.isFinite(e.uncertainty)||e.uncertainty<0))throw new TypeError("Context packing uncertainty must be finite and non-negative")}function Yc(e){if(!Number.isInteger(e.tokenBudget)||e.tokenBudget<1)throw new TypeError("Context packing tokenBudget must be a positive integer");let t=e.profile??"balanced",n=zc[t];if(!n)throw new TypeError("Unknown context packing profile");let r=e.redundancyPenalty??n.redundancyPenalty,i=e.uncertaintyPenalty??n.uncertaintyPenalty;if(!Number.isFinite(r)||r<0||r>1||!Number.isFinite(i)||i<0)throw new TypeError("Context packing penalties must be finite and within their supported ranges");if(e.latencyBudgetMs!==void 0&&(!Number.isFinite(e.latencyBudgetMs)||e.latencyBudgetMs<=0))throw new TypeError("Context packing latencyBudgetMs must be positive");return{redundancy:r,uncertainty:i,profile:t}}function Xc(e){let t=new Set;for(let n of e){if(Kc(n),t.has(n.id))throw new TypeError("Context packing candidates require unique ids");t.add(n.id)}return[...e].sort((n,r)=>n.rank-r.rank||n.id.localeCompare(r.id))}function Qc(e,t,n,r,i){let o=-1,s=0;for(let a=0;a<e.length;a+=1){if(a%128===0&&i()>=r)return{index:o,evaluated:s,timedOut:!0};let d=e[a];if(d.token_costs.identity>t)continue;s+=1;let c=o<0?void 0:e[o],l=n(d)/d.token_costs.identity,u=c===void 0?Number.NEGATIVE_INFINITY:n(c)/c.token_costs.identity;(l>u||l===u&&c!==void 0&&(d.rank<c.rank||d.rank===c.rank&&d.id.localeCompare(c.id)<0))&&(o=a)}return{index:o,evaluated:s,timedOut:!1}}function Jc(e){let t=new Set,n=[],r=e.tokenBudget,i=c=>{let l=c.lineage??c.cluster,u=l&&t.has(l)?1-e.redundancyPenalty:1;return Math.max(0,(c.score-e.uncertaintyPenalty*(c.uncertainty??0))*u)},o=c=>{let l=c.token_costs.identity;n.push({...c,projection:"identity",tokens:l,marginal_value:i(c)}),r-=l;let u=c.lineage??c.cluster;u&&t.add(u)};for(let c of e.ordered.filter(l=>l.required))c.token_costs.identity<=r&&o(c);let s=e.ordered.filter(c=>!c.required),a=!0,d=0;for(;s.length>0;){let c=Qc(s,r,i,e.deadline,e.readClock);if(d+=c.evaluated,c.timedOut&&(a=!1),c.index<0||c.timedOut)break;o(s.splice(c.index,1)[0])}return{included:n,remaining:r,selectionComplete:a,evaluatedCandidates:d}}function Zc(e,t){let n=t;for(let r of["summary","full"]){let i=r==="summary"?"identity":"summary",o=[...e].sort((s,a)=>{let d=s.token_costs[r]-s.token_costs[i],c=a.token_costs[r]-a.token_costs[i];return a.marginal_value/Math.max(c,1)-s.marginal_value/Math.max(d,1)||s.rank-a.rank||s.id.localeCompare(a.id)});for(let s of o){if(s.projection!==i)continue;let a=s.token_costs[r]-s.tokens;a>n||(s.projection=r,s.tokens+=a,n-=a)}}return n}function Eo(e,t){let n=Yc(t),r=Xc(e),i=t.readClock??performance.now.bind(performance),o=t.latencyBudgetMs===void 0?Number.POSITIVE_INFINITY:i()+t.latencyBudgetMs,s=Jc({ordered:r,tokenBudget:t.tokenBudget,redundancyPenalty:n.redundancy,uncertaintyPenalty:n.uncertainty,deadline:o,readClock:i}),{included:a}=s,d=Zc(a,s.remaining);a.sort((l,u)=>l.rank-u.rank||l.id.localeCompare(u.id));let c=new Set(a.map(l=>l.id));return{included:a,omitted_ids:r.filter(l=>!c.has(l.id)).map(l=>l.id),token_budget:t.tokenBudget,used_tokens:t.tokenBudget-d,remaining_tokens:d,complete:s.selectionComplete&&a.length===e.length&&a.every(l=>l.projection==="full"),selection_complete:s.selectionComplete,termination_reason:s.selectionComplete?"exhausted":"latency_budget",evaluated_candidates:s.evaluatedCandidates,latency_budget_ms:t.latencyBudgetMs??null,profile:n.profile,degradation_ladder:["full","summary","identity"]}}import De from"node:fs/promises";import Fe from"node:path";import{createHash as Co,randomUUID as ed}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01eff51c-7656-5c3f-b0c0-28594fca8a1e")}catch{}})();var hn=3,gn=2,Io=["recency","activity_density","graph_proximity","priority_pressure","risk_pressure","knowledge_density"],td=new Set(["substantive_history","release_cohort","created_at"]),nd={context_signal_store_invalid:{code:"context_signal_store_invalid",meaning:"The persisted context-signal snapshot was unreadable or invalid and was rebuilt from authoritative items.",recovery_command:"pm context",recovery_effect:"Re-read context and confirm the rebuilt snapshot can be loaded without the warning."},context_signal_store_stale:{code:"context_signal_store_stale",meaning:"The persisted context-signal snapshot did not match the authoritative cursor or item corpus and was rebuilt.",recovery_command:"pm context",recovery_effect:"Re-read context and confirm the rebuilt snapshot is now fresh."},context_signal_store_write_failed:{code:"context_signal_store_write_failed",meaning:"Context signals were rebuilt in memory, but the derived snapshot could not be persisted.",recovery_command:"pm context",recovery_effect:"Retry the derived snapshot write and confirm the warning clears after storage access is restored."}};function pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xo(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function rd(e){let t={};for(let n of Io){let r=e[n];if(r!==void 0){if(!xo(r))throw new TypeError(`Context relevance signal ${n} must be a finite number from 0 to 1`);t[n]=r}}return t}function id(e,t){let n=e.map(i=>[i.id,t(i)]),r=Math.max(0,...n.map(([,i])=>i));return Object.fromEntries(n.map(([i,o])=>[i,r===0?0:o/r]))}function od(e){let t=new Map(e.map(i=>[i.id,0])),n=i=>{t.set(i,(t.get(i)??0)+1)};for(let i of e){typeof i.parent=="string"&&i.parent.trim()&&(n(i.id),n(i.parent.trim()));for(let o of i.dependencies??[])typeof o.id!="string"||!o.id.trim()||(n(i.id),n(o.id.trim()))}let r=Math.max(0,...t.values());return Object.fromEntries(e.map(i=>[i.id,r===0?0:t.get(i.id)/r]))}function To(e,t){return{...t,activityDensity:t.activityDensity??id(e,n=>(n.comments?.length??0)+(n.notes?.length??0)+(n.learnings?.length??0)+(n.test_runs?.length??0)),graphProximity:t.graphProximity??od(e)}}function wn(e){let t=Co("sha256");for(let{id:n,signal_provenance:{recency:r}}of[...e].sort((i,o)=>i.id.localeCompare(o.id)))t.update(JSON.stringify([n,r.source,r.coordinate,r.history_op??null,r.event_class??null]));return`sha256:${t.digest("hex")}`}function sd(e){if(!pe(e))return null;let t=e.signal_provenance;if(![typeof e.id=="string",pe(e.signals),pe(t)].every(Boolean))return null;let n=t.recency;if(!pe(n))return null;let r=Ae(n.coordinate);if(r===null)return null;let i=new Set(Io),o=Object.entries(e.signals);return!o.every(([s,a])=>i.has(s)&&xo(a))||![typeof n.source=="string"&&td.has(n.source),["undefined","string"].includes(typeof n.history_op),[void 0,"substantive","maintenance"].includes(n.event_class),n.source==="substantive_history"?n.event_class===void 0||n.event_class==="substantive":n.history_op===void 0&&n.event_class===void 0].every(Boolean)?null:{id:e.id,signals:Object.fromEntries(o),signal_provenance:{recency:{source:n.source,coordinate:r,history_op:n.history_op,event_class:n.event_class}}}}function ad(e,t){let n=Array.from(e,sd);if(n.some(i=>i===null))return null;let r=n;return new Set(r.map(i=>i.id)).size!==r.length||r.some(i=>i.id.trim().length===0)||t!==wn(r)?null:r.sort((i,o)=>i.id.localeCompare(o.id))}function cd(e){if(!pe(e)||e.format_version!==hn||e.signal_set_version!==gn||typeof e.source_cursor!="string"||e.source_cursor.trim().length===0||typeof e.recency_evidence_fingerprint!="string"||!/^sha256:[a-f0-9]{64}$/u.test(e.recency_evidence_fingerprint)||typeof e.generated_at!="string"||!Number.isFinite(Date.parse(e.generated_at))||e.source!=="derived_index"&&e.source!=="scan_fallback"||!Array.isArray(e.items))return null;let t=ad(e.items,e.recency_evidence_fingerprint);return t===null?null:{format_version:hn,signal_set_version:gn,source_cursor:e.source_cursor,recency_evidence_fingerprint:e.recency_evidence_fingerprint,generated_at:e.generated_at,source:e.source,items:t}}function Ro(e){if(typeof e.sourceCursor!="string"||e.sourceCursor.trim().length===0)throw new TypeError("Context signal source cursor must be non-empty");if(!Number.isFinite(Date.parse(e.now)))throw new TypeError("Context signal snapshot clock must be a valid timestamp");if(e.source!=="derived_index"&&e.source!=="scan_fallback")throw new TypeError("Context signal snapshot source must be derived_index or scan_fallback")}function Ao(e,t,n=wn(e)){let r=e.map(({id:o})=>o);if(new Set(r).size!==r.length||r.some(o=>o.trim().length===0))throw new TypeError("Context signal snapshot item IDs must be unique and non-empty");let i=e.map(({id:o,signals:s,signal_provenance:a})=>({id:o,signals:rd(s),signal_provenance:a})).sort((o,s)=>o.id.localeCompare(s.id));return Object.freeze({format_version:hn,signal_set_version:gn,source_cursor:t.sourceCursor,recency_evidence_fingerprint:n,generated_at:t.now,source:t.source,items:Object.freeze(i.map(o=>Object.freeze(o)))})}function op(e,t){return Ro(t),Ao(St(e,To(e,t)),t)}var yn=class{filePath;constructor(t){if(typeof t!="string"||t.trim().length===0)throw new TypeError("Context signal store path must be non-empty");this.filePath=Fe.resolve(t)}async read(){try{return JSON.parse(await De.readFile(this.filePath,"utf8"))}catch(t){if(pe(t)&&Ke(t))return null;throw t}}async write(t){let n=Fe.dirname(this.filePath);await De.mkdir(n,{recursive:!0});let r=Fe.join(n,`.${Fe.basename(this.filePath)}.${ed()}.tmp`);try{await De.writeFile(r,`${JSON.stringify(t)}
|
|
@@ -9,4 +9,4 @@ import{$ as ft,E as Xt,F as gi,Ia as Ai,O as st,Q as ue,Qa as q,R as at,Ra as Mi
|
|
|
9
9
|
`)}catch{}}function Ls(e,t){return[`vector_index_stale:${e}`,`vector_index_recovery:${t.args.join(" ")}`,...t.follow_up_args?[`vector_index_recovery_follow_up:${t.follow_up_args.join(" ")}`]:[]]}function Ut(e,t,n,r){if(!t.active)throw new h(`Search mode '${e}' requires a configured embedding provider in settings.providers.openai or settings.providers.ollama`,f.USAGE);if(!n.active&&!r)throw new h(`Search mode '${e}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,f.USAGE);return{provider:t.active,vectorStore:n.active??null}}var B=Ye;function He(e){let t=C(),n=pi(t,e);if(!n)return null;let r=n.runtime_definition??n.definition,i=r.query,o=r.queryExpansion??r.query_expansion,s=r.rerank,a=B(r.name)??B(n.definition.name)??e;if(!a)return null;let d={providerName:a,...typeof i=="function"?{query:i}:{},...typeof o=="function"?{queryExpansion:o}:{},...typeof s=="function"?{rerank:s}:{}};return!d.query&&!d.queryExpansion&&!d.rerank?null:d}function rr(e){let t=B(e.search?.provider),n=He(t);return n?.query?{providerName:n.providerName,query:n.query}:null}function ir(e){let t=C(),n=B(e.vector_store?.adapter),r=hi(t,n);if(!r)return null;let i=r.runtime_definition??r.definition,o=i.query;if(typeof o!="function")return null;let s=i.upsert;return{adapterName:B(i.name)??B(r.definition.name)??n??"extension",query:o,...typeof s=="function"?{upsert:s}:{}}}function or(e,t,n){let r=Array.isArray(t)?t:t?.hits;if(!Array.isArray(r))throw new h(`Extension search provider "${e}" must return an array of hits or { hits: [...] }`,f.GENERIC_FAILURE);let i=new Set,o=[];for(let s of r){if(typeof s!="object"||s===null)continue;let a=B(s.id),d=s.score;if(!a||typeof d!="number"||!Number.isFinite(d)||i.has(a))continue;let c=n.get(a);if(!c)continue;let l=s.matched_fields,u=Array.isArray(l)&&l.every(m=>typeof m=="string")?[...new Set(l.map(m=>m.trim()).filter(m=>m.length>0))].sort((m,p)=>m.localeCompare(p)):[`provider:${e}`];i.add(a),o.push({item:c.metadata,score:d,matched_fields:u})}return o}function sr(e,t){let n=[],r=new Map;for(let i of e){if(r.has(i.id))continue;let o=t.get(i.id);o&&(r.set(i.id,i.score),n.push({item:o.metadata,score:i.score,matched_fields:["semantic"]}))}return{semanticHits:n,semanticScores:r}}function Nt(e,t){let n=t.filter(d=>d.exact_id_match===!0);if(n.length===0)return e;let r=new Set(n.map(d=>d.item.id)),i=e.filter(d=>!r.has(d.item.id)),o=i.reduce((d,c)=>Math.max(d,c.score),0),s=n.sort((d,c)=>c.score-d.score),a=o+s.length+1;return[...s.map((d,c)=>({...d,score:a-c,matched_fields:["id"]})),...i]}function Bt(e,t,n,r,i="semantic"){let o=new Map(n.map(u=>[u.item.id,u.score])),s=new Map(n.map(u=>[u.item.id,u.matched_fields])),a=Ge(t),d=Ge(o),c=new Set([...t.keys(),...o.keys()]),l=1-r;return[...c].map(u=>{let m=e.get(u),p=a.get(u)??0,g=d.get(u)??0,_=p*r+g*l;if(_<=0)return null;let y=new Set;t.has(u)&&y.add(i);for(let w of s.get(u)??[])y.add(w);return{item:m.metadata,score:_,matched_fields:[...y].sort((w,S)=>w.localeCompare(S))}}).filter(u=>u!==null)}function ar(e){let t=e.configuredProvider?.trim().toLowerCase();return t==="bm25"?"explicit":t==="auto"&&!e.hasEmbeddingProvider&&!e.hasExtensionSearchProvider?"auto-fallback":null}function cr(e){let t=e.filteredDocuments.map(s=>({id:s.metadata.id,text:Ss(xi(s,{fields:e.corpusFields}))})),n=vs(t),r=ks(n,Hn(e.query),e.bm25Params),i=new Map(e.filteredDocuments.map(s=>[s.metadata.id,s]));if(e.requestedMode==="semantic"){let s=[...r].map(([a,d])=>({item:i.get(a).metadata,score:d,matched_fields:["bm25"]}));return Nt(s,e.keywordHits)}let o=Bt(i,r,e.keywordHits,e.hybridSemanticWeight,"bm25");return Nt(o,e.keywordHits)}function dr(e){let t=new Map;for(let r of e)for(let i of r){let o=t.get(i.id);(!o||i.score>o.score)&&t.set(i.id,i)}let n=[...t.values()];return n.sort((r,i)=>r.score!==i.score?i.score-r.score:r.id.localeCompare(i.id)),n}function lr(e){let t=e.metadata,n=Array.isArray(t?.tags)?t.tags.join(" "):"";return[t?.title,t?.description,t?.type,t?.status,n,e.body].map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0).join(`
|
|
10
10
|
`)}async function Mm(e,t){let n=e.queryExpansion.enabled?Cs(t,e.queryExpansion.max_queries):[t],r=n.length>0?n:[t];if(!e.queryExpansion.enabled)return r;if(e.queryExpansionExtension?.expand)try{let i=await Promise.resolve(e.queryExpansionExtension.expand({query:t,mode:e.requestedMode,settings:e.settings}));return xs(r,Is(i),e.queryExpansion.max_queries)}catch{return e.warnings.push(`search_query_expansion_provider_failed:${e.queryExpansionExtension.providerName}:using_builtin`),r}return e.queryExpansion.provider&&e.queryExpansion.provider!=="openai"&&e.queryExpansion.provider!=="ollama"&&e.warnings.push(`search_query_expansion_provider_unavailable:${e.queryExpansion.provider}:using_builtin`),r}async function $m(e,t,n,r){if(e.extensionVectorAdapter?.query)try{return await Promise.resolve(e.extensionVectorAdapter.query({vector:t,limit:n,settings:e.settings}))}catch(i){if(!e.vectorStore)throw new h(`Extension vector adapter query failed and no built-in fallback store is configured (${i instanceof Error?i.message:String(i)})`,f.GENERIC_FAILURE);return e.warnings.push(`search_vector_adapter_failed:${e.extensionVectorAdapter.adapterName}:using_builtin`),await Jt(e.vectorStore,t,n,r)}if(e.vectorStore)return await Jt(e.vectorStore,t,n,r);throw new h("Semantic search requires either a configured vector store or an extension vector adapter query handler",f.USAGE)}function Om(e,t,n){return[...e].sort((r,i)=>r.score!==i.score?i.score-r.score:r.item.id.localeCompare(i.item.id)).slice(0,n).map(r=>{let i=t.get(r.item.id);return i?{hit:r,text:lr(i)}:null}).filter(r=>r!==null)}async function Lm(e,t,n){if(!e.rerankExtension?.rerank)return null;try{let r=await Promise.resolve(e.rerankExtension.rerank({query:t,mode:"hybrid",model:e.rerank.model,top_k:e.rerank.top_k,settings:e.settings,candidates:n.map(o=>({id:o.hit.item.id,text:o.text,score:o.hit.score}))})),i=As(r);return i.length>0?new Map(i.map(o=>[o.id,o.score])):(e.warnings.push(`search_rerank_provider_invalid_response:${e.rerankExtension.providerName}:using_builtin`),null)}catch{return e.warnings.push(`search_rerank_provider_failed:${e.rerankExtension.providerName}:using_builtin`),null}}async function Nm(e,t,n){let r=await Lm(e,t,n);if(r)return r;let i=n.map(o=>({id:o.hit.item.id,text:o.text}));try{return await Fs(e.provider,e.rerank.model,t,i,e.embeddingTimeoutMs)}catch{return e.warnings.push("search_rerank_failed:using_hybrid_scores"),null}}function Pm(e,t){let n=new Set(t.keys()),r=e.map(i=>{let o=t.get(i.item.id);if(o===void 0)return i;let s=new Set(i.matched_fields);return s.add("rerank"),{...i,score:o,matched_fields:[...s].sort((a,d)=>a.localeCompare(d))}});return r.sort((i,o)=>{let s=n.has(i.item.id),a=n.has(o.item.id);return s!==a?s?-1:1:i.score!==o.score?o.score-i.score:i.item.id.localeCompare(o.item.id)}),r}async function jm(e,t,n,r){if(!e.rerank.enabled||n.length<=1)return n;let i=Om(n,r,e.rerank.top_k),o=await Nm(e,t,i);return o&&o.size>0?Pm(n,o):n}async function ur(e){let t=Math.max(e.limit??e.maxResults,e.maxResults),n=e.embeddingTimeoutMs!==void 0?{timeout_ms:e.embeddingTimeoutMs}:{},r=e.vectorQueryTimeoutMs!==void 0?{timeout_ms:e.vectorQueryTimeoutMs}:{},i=e.query.trim(),o=await Mm(e,i),s=await lt(e.provider,o,n),a=await Promise.all(s.map(async g=>await $m(e,g,t,r))),d=dr(a),c=new Map(e.filteredDocuments.map(g=>[g.metadata.id,g])),{semanticHits:l,semanticScores:u}=sr(d,c),m=u.size;if(e.requestedMode==="semantic")return{hits:Nt(l,e.keywordHits),vectorMatchCount:m};let p=await jm(e,i,Bt(c,u,e.keywordHits,e.hybridSemanticWeight),c);return{hits:Nt(p,e.keywordHits),vectorMatchCount:m}}function Ns(e){let t=He(e.provider??void 0);return t?.queryExpansion?{providerName:t.providerName,expand:t.queryExpansion}:null}function Ps(e){let t=He(B(e.search?.provider));return t?.rerank?{providerName:t.providerName,rerank:t.rerank}:null}import Gt from"node:fs/promises";import mr 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]="de9a1cbd-f277-52ef-adc6-66225f2d2f4f")}catch{}})();function fr(e){let t=(e.files??[]).map(s=>({scope:s.scope,path:s.path.trim()})),n=(e.docs??[]).map(s=>({scope:s.scope,path:s.path.trim()})),r=(e.tests??[]).filter(s=>typeof s.path=="string"&&s.path.trim().length>0).map(s=>({scope:s.scope,path:s.path.trim()})),i=[...t,...n,...r].filter(s=>s.path.length>0).sort((s,a)=>s.scope.localeCompare(a.scope)||s.path.localeCompare(a.path)),o=new Map;for(let s of i)o.set(`${s.scope}:${s.path}`,s);return[...o.values()]}async function js(e){let t=mr.resolve(e);try{let n=await Gt.realpath(t);return{resolved:t,realpath:n}}catch{return null}}async function pr(e,t){let[n,r]=await Promise.all([js(e),js(t)]);return{projectContainmentRoot:n,globalContainmentRoot:r}}async function hr(e,t){let n=fr(e.metadata),r=[];for(let i of n){let o=i.scope==="global"?t.globalContainmentRoot:t.projectContainmentRoot;if(!o)continue;let s=mr.resolve(o.resolved,i.path);if(!zt(o.resolved,s))continue;let a;try{a=await Gt.realpath(s)}catch{continue}if(zt(o.realpath,a))try{await Se({path:s,scope:i.scope}),r.push(await Gt.readFile(s,"utf8"))}catch{}}return r.join(`
|
|
11
11
|
`)}async function gr(e,t,n,r){let i=Ar(C()),o=async(c,l,u)=>{let m=async(p,g)=>{await Se({path:p,scope:"project"});let _=await Gt.readFile(p,"utf8");return di(_,{format:g,schema:r,extensionFieldNames:i,onWarning:y=>s.push(y)}).body};try{return await m(l,u)}catch{let p=u==="toon"?"json_markdown":"toon",g=Vt(e,c.type,c.id,p,n);try{return await m(g,p)}catch{return s.push(`item_list_item_read_failed:${mr.relative(e,g)}`),""}}},s=[],a=await vi(e,t,n,s,r),d=[];if(a.length===0){let c=await ki(e,t,n,s,r);for(let l of c){let u=Vt(e,l.type,l.id,t,n),m=await o(l,u,t);d.push({metadata:l,body:m})}return{documents:d,warnings:[...new Set(s)].sort((l,u)=>l.localeCompare(u))}}for(let c of a){if(typeof c.body=="string"){d.push({metadata:c.metadata,body:c.body});continue}let l=await o(c.metadata,c.item_path,c.item_format);d.push({metadata:c.metadata,body:l})}return{documents:d,warnings:[...new Set(s)].sort((c,l)=>c.localeCompare(l))}}async function Us(e,t,n){let r=new Map;if(!e||t!=="keyword"&&t!=="hybrid")return r;let i=process.cwd(),o=await pr(i,Lr(i)),s=await Promise.all(n.map(async a=>[a.metadata.id,await hr(a,o)]));for(let[a,d]of s)r.set(a,d);return r}(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]="17122985-4157-5732-9142-444327cb273d")}catch{}})();var Bs=["tag","status","type","priority"];function yr(e){let t={},n=[];for(let r of e.split(/\s+/).filter(i=>i.length>0)){let i=r.indexOf(":"),o=i>0?r.slice(0,i).toLowerCase():"",s=i>0?r.slice(i+1):"",a=Bs.includes(o)?o:void 0;if(a&&s.length>0&&t[a]===void 0){t[a]=s;continue}n.push(r)}return{residualQuery:n.join(" "),inlineFilters:t}}function _r(e,t,n){let r={...e};for(let i of Bs){let o=t[i];if(o!==void 0){if(Ye(r[i])!==void 0){n.push(`search_inline_filter_ignored:${i}:flag_takes_precedence`);continue}r[i]=o}}return r}function Gs(e,t){let n=[],r=yr(e),i=Object.keys(r.inlineFilters).length>0;if(i&&r.residualQuery.trim().length===0)throw new h("Inline field:value tokens consumed the entire query, leaving no search terms.",f.USAGE,{examples:["pm search auth tag:area:search","pm list --tag area:search --status open"],nextSteps:["Add keyword terms alongside the inline filters, or use pm list for pure tag/status/type/priority filtering."]});let o=i?r.residualQuery:e,s=_r(t,r.inlineFilters,n);return{query:o,options:s,inlineWarnings:n,highlight:s.highlight===!0,includeLinked:Ft(s.includeLinked),titleExact:Ft(s.titleExact),phraseExact:Ft(s.phraseExact),matchMode:gs(typeof s.matchMode=="string"?s.matchMode:void 0),minScoreOverride:ys(s.minScore),countOnly:s.count===!0,tokens:$t(o),normalizedQuery:U(o),limit:ue(s.limit),projection:Mt(s,e),modeWasExplicit:typeof s.mode=="string"&&s.mode.trim().length>0}}function Hs(e){if(e.after!==void 0&&e.count===!0)throw new h("Search --after cannot be combined with --count.",f.USAGE)}(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]="d7beacb7-66a5-581f-93f0-68ceb4b8e41e")}catch{}})();function br(e,t,n,r,i,o,s,a,d,c,l,u,m,p){let g=m?{total:0,count_only:!0}:{};if(c.mode==="compact"&&r.compact===!0){let y=ye({mode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,runtimeFieldFilters:u});return{query:e.trim(),mode:t,...Er(p),items:[],count:0,...g,filters:y,...l.length>0?{warnings:l}:{}}}let _=c.mode==="full"?null:[...c.fields];return{query:e.trim(),mode:t,mode_source:p,items:[],count:0,...g,filters:_e({effectiveMode:t,matchMode:n,options:r,includeLinked:i,titleExact:r.titleExact===!0,phraseExact:r.phraseExact===!0,scoreThreshold:o,hybridSemanticWeight:s,queryExpansion:a,rerank:d,runtimeFieldFilters:u??{}}),projection:{mode:c.mode,fields:_},now:F(),...l.length>0?{warnings:l}:{}}}function vr(e,t){let n=t.trim();if(n.length===0)return null;if(n==="score")return e.score;if(n==="matched_fields")return e.matched_fields;if(n.startsWith("item.")){let o=n.slice(5);return o.length===0?null:e.item[o]??null}let r=e,i=e.item;return Object.prototype.hasOwnProperty.call(i,n)?i[n]??null:Object.prototype.hasOwnProperty.call(r,n)?r[n]??null:null}function kr(e,t){return t.mode==="full"?e.map(({matched_all_terms:n,exact_id_match:r,...i})=>i):e.map(n=>{let r={};for(let i of t.fields)r[i]=vr(n,i);return r})}function Sr(e,t){return br(e.query,e.effectiveMode,e.matchMode,e.options,e.includeLinked,e.scoreThreshold,e.hybridSemanticWeight,e.queryExpansion,e.rerank,e.projection,e.warnings,e.runtimeFieldFilters,t,e.modeSource)}function qs(e,t){if(e.projection.mode==="compact"&&e.options.compact===!0)return wr({query:e.query.trim(),mode:e.effectiveMode,...Er(e.modeSource),items:[],count:t,total:t,count_only:!0,filters:ye({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let n=e.projection.mode==="full"?null:[...e.projection.fields];return wr({query:e.query.trim(),mode:e.effectiveMode,mode_source:e.modeSource,items:[],count:t,total:t,count_only:!0,filters:_e({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:e.projection.mode,fields:n},now:F()},e.warnings)}function Er(e){return e==="settings"?{mode_source:e}:{}}function wr(e,t){return t.length===0?e:{...e,warnings:t}}function qe(e,t){return t?{...e,workspace_memory:t}:e}function Ws(e,t,n){if(!e.highlight)return{hits:n,projection:e.projection};let r=new Map(t.map(o=>[o.metadata.id,o])),i=n.map(o=>({...o,highlights:Lt(r.get(o.item.id),o.matched_fields,e.tokens)}));return e.projection.mode==="full"||e.projection.fields.includes("highlights")?{hits:i,projection:e.projection}:{hits:i,projection:{mode:e.projection.mode,fields:[...e.projection.fields,"highlights"]}}}function zs(e,t,n,r,i,o){let s=r<n?{total:n}:{};if(e.projection.mode==="compact"&&e.options.compact===!0)return wr({query:e.query.trim(),mode:e.effectiveMode,...Er(e.modeSource),items:t,count:t.length,...s,...o,filters:ye({mode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,runtimeFieldFilters:e.runtimeFieldFilters})},e.warnings);let a=i.mode==="full"?null:[...i.fields];return{query:e.query.trim(),mode:e.effectiveMode,mode_source:e.modeSource,items:t,count:t.length,...s,...o,filters:_e({effectiveMode:e.effectiveMode,matchMode:e.matchMode,options:e.options,includeLinked:e.includeLinked,titleExact:e.titleExact,phraseExact:e.phraseExact,scoreThreshold:e.scoreThreshold,hybridSemanticWeight:e.hybridSemanticWeight,queryExpansion:e.queryExpansion,rerank:e.rerank,runtimeFieldFilters:e.runtimeFieldFilters}),projection:{mode:i.mode,fields:a},now:F(),...e.warnings.length>0?{warnings:e.warnings}:{}}}(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]="3bfd872f-6ed7-551c-a027-3748493de3e9")}catch{}})();var Vy={applyFilters:Yn,applyExactQueryFilters:Kn,applyInlineQueryFilters:_r,buildHitHighlights:Lt,buildVerboseSearchFilters:_e,buildExplicitSemanticFallbackWarning:tr,buildCompactSearchFilterSummary:ye,buildHybridLexicalScore:er,buildRerankCorpus:lr,buildSemanticHits:sr,classifyImplicitSemanticFallbackReason:jt,collectErrorCauseCodes:Pt,collectExactPhraseFields:zn,collectLinkedPaths:fr,combineHybridHits:Bt,computeBuiltInBm25Hits:cr,computeSemanticOrHybridHits:ur,resolveBuiltInBm25Mode:ar,countOccurrences:Ot,dependencyEntries:Be,documentContainsExactPhrase:Vn,emptySearchResult:br,highlightFieldSnippet:Qn,loadDocuments:gr,markTokenRuns:Xn,parseInlineQueryFilters:yr,maybeEmitVectorIndexStaleWarning:nr,loadLinkedCorpus:hr,mergeVectorHitsById:dr,normalizeExtensionProviderHits:or,normalizeScoreMap:Ge,parseProjectionConfig:Mt,parseTimestampWindow:oe,parseTokens:$t,projectSearchHits:kr,readSearchFieldValue:vr,requireSemanticDependencies:Ut,resolveExtensionSearchProvider:rr,resolveExtensionSearchProviderByName:He,resolveExtensionVectorAdapter:ir,resolveLinkedCorpusRoots:pr,scoreDocument:Jn,sortHits:Zn,stringArray:we,textEntries:K,validateSearchProjectionFields:Ln};async function Um(e,t){let n=T(process.cwd(),t.path);await G(n);let r=await M(n),i=bi(r).settings,o=P(i.schema),s=Q(i.schema);Ln(e.projection,s,e.query);let a=at(e.options,s,"search"),d=D(i,C()),c=Ci(i),l=Ti(i,n),u=rr(i),m=ir(i),p=hs(e.options.semanticWeight),g=Ts(i,c.active?.name??null),_=Rs(i,c.active?.model??B(i.search?.embedding_model)??"text-embedding-3-small");return{pmRoot:n,settings:i,statusRegistry:o,runtimeFieldRegistry:s,runtimeFieldFilters:a,typeRegistry:d,maxResults:Nn(i),scoreThreshold:e.minScoreOverride??jn(i),semanticWeightProvided:e.options.semanticWeight!==void 0,semanticWeightOverride:p,hybridSemanticWeight:p??Un(i),tuning:Bn(i),providerResolution:c,vectorResolution:l,extensionSearchProvider:u,extensionVectorAdapter:m,bm25Mode:ar({configuredProvider:B(i.search?.provider),hasEmbeddingProvider:c.active!==null,hasExtensionSearchProvider:u!==null}),queryExpansion:g,queryExpansionExtension:Ns(g),rerank:_,rerankExtension:Ps(i),...Bm({requested:e.options.mode,settings:i,configuredProvider:r.search?.provider??null,providerResolution:c,vectorResolution:l,extensionSearchProvider:u,extensionVectorAdapter:m})}}function Bm(e){let t=Ei(e.providerResolution.active?.name,e.configuredProvider)==="configured"&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null),n=e.extensionSearchProvider!==null||t,r=Pn({requested:e.requested,settings:e.settings,semanticRunnable:n});return{effectiveMode:r.mode,modeSource:r.source}}async function Gm(e,t){let n=await gr(t.pmRoot,t.settings.item_format??"toon",t.typeRegistry.type_to_folder,t.settings.schema),r=st(typeof e.options.status=="string"?e.options.status:void 0,t.statusRegistry,{strict:!0}),i=Ni(t.statusRegistry),o=Yn(n.documents,e.options,t.typeRegistry,t.runtimeFieldFilters,r,i);return{warnings:n.warnings,allDocuments:n.documents,filteredDocuments:Kn(o,e.normalizedQuery,{titleExact:e.titleExact,phraseExact:e.phraseExact||e.matchMode==="exact"})}}async function Hm(e,t,n){let r=await Us(e.includeLinked,t.effectiveMode,n),i=e.matchMode==="or";return n.map(o=>er(o,e.tokens,e.normalizedQuery,e.includeLinked,r,t.tuning,t.settings.id_prefix,i)).filter(o=>o!==null).filter(o=>e.matchMode!=="and"||o.matched_all_terms===!0)}async function qm(e,t,n,r,i){if(t.bm25Mode===null||t.effectiveMode==="keyword")return null;let o=cr({requestedMode:t.effectiveMode,query:e.query,filteredDocuments:n,keywordHits:r,corpusFields:Ii(t.settings),bm25Params:Es(t.settings),hybridSemanticWeight:t.hybridSemanticWeight});return t.bm25Mode==="auto-fallback"&&i.push(`search_${t.effectiveMode}_offline_bm25:no_embedding_provider:using_lexical_bm25`),o}async function Wm(e,t,n,r){if(!t.extensionSearchProvider)return null;let i=t.providerResolution.active!==null&&(t.vectorResolution.active!==null||t.extensionVectorAdapter!==null);try{let o=await Promise.resolve(t.extensionSearchProvider.query({query:e.query,mode:t.effectiveMode,tokens:e.tokens,options:e.options,settings:t.settings,documents:n}));return or(t.extensionSearchProvider.providerName,o,r)}catch(o){if(!i)throw new h(`Extension search provider "${t.extensionSearchProvider.providerName}" failed: ${o instanceof Error?o.message:String(o)}`,f.GENERIC_FAILURE);return null}}function zm(e,t,n,r){return t.vectorMatchCount>0?t.hits:(r.push(`search_${e}_degraded:no_vector_matches:results_are_lexical`),e==="semantic"?n:t.hits)}async function Vm(e,t,n,r,i){let o=!e.extensionSearchProvider&&e.providerResolution.active!==null&&(e.vectorResolution.active!==null||e.extensionVectorAdapter!==null);i&&o&&await nr(e.pmRoot,n,r),e.extensionSearchProvider||Ut(t,e.providerResolution,e.vectorResolution,e.extensionVectorAdapter!==null)}async function Km(e){let{prepared:t,runtime:n,filteredDocuments:r,keywordHits:i,warnings:o,modeWasExplicit:s}=e,a=i,d=await qm(t,n,r,i,o),c=n.effectiveMode;if(d!==null||c==="keyword")return{effectiveMode:n.effectiveMode,hits:d??a};try{if(await Vm(n,c,r,o,s),r.length===0||t.limit===0)return{effectiveMode:n.effectiveMode,hits:[]};let l=new Map(r.map(u=>[u.metadata.id,u]));if(a=await Wm(t,n,r,l)??a,a===i){let{provider:u,vectorStore:m}=Ut(c,n.providerResolution,n.vectorResolution,n.extensionVectorAdapter!==null),p=await ur({requestedMode:c,query:t.query,filteredDocuments:r,keywordHits:i,hybridSemanticWeight:n.hybridSemanticWeight,limit:t.limit,maxResults:n.maxResults,provider:u,vectorStore:m,extensionVectorAdapter:n.extensionVectorAdapter,queryExpansion:n.queryExpansion,queryExpansionExtension:n.queryExpansionExtension,rerank:n.rerank,rerankExtension:n.rerankExtension,warnings:o,settings:n.settings});a=zm(c,p,i,o)}return{effectiveMode:n.effectiveMode,hits:a}}catch(l){return o.push(tr(n.effectiveMode,l)),{effectiveMode:"keyword",hits:i}}}function Vs(e){e.searchOptions.after!==void 0&&qr(e.searchOptions.after,Gn(e))}async function Ky(e,t,n){Hs(t);let r=Gs(e,t),i=await Um(r,n),o=await Gm(r,i),s=o.warnings;s.push(...r.inlineWarnings);let a=await It(o.allDocuments.map(k=>k.metadata),{pmRoot:i.pmRoot,statusRegistry:i.statusRegistry,now:F()});s.push(...a.warnings);let d=Oo(a,r.query);i.effectiveMode==="hybrid"&&i.semanticWeightProvided&&i.semanticWeightOverride===void 0&&s.push("search_hybrid_semantic_weight_override_invalid:using_settings_default");let c={query:r.query,modeSource:i.modeSource,matchMode:r.matchMode,options:r.options,includeLinked:r.includeLinked,titleExact:r.titleExact,phraseExact:r.phraseExact,scoreThreshold:i.scoreThreshold,hybridSemanticWeight:i.hybridSemanticWeight,queryExpansion:i.queryExpansion,rerank:i.rerank,projection:r.projection,warnings:s,runtimeFieldFilters:i.runtimeFieldFilters};if(i.effectiveMode==="keyword"&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return Vs({query:r.query,mode:i.effectiveMode,searchOptions:r.options,pmRoot:i.pmRoot}),qe(Sr({...c,effectiveMode:i.effectiveMode},r.countOnly),d);let l=await Hm(r,i,o.filteredDocuments),u=await Km({prepared:r,runtime:i,filteredDocuments:o.filteredDocuments,keywordHits:l,warnings:s,modeWasExplicit:r.modeWasExplicit});if(u.effectiveMode!=="keyword"&&u.hits.length===0&&(o.filteredDocuments.length===0||r.limit===0&&!r.countOnly))return Vs({query:r.query,mode:u.effectiveMode,searchOptions:r.options,pmRoot:i.pmRoot}),qe(Sr({...c,effectiveMode:u.effectiveMode},r.countOnly),d);let m=u.hits.filter(k=>k.exact_id_match===!0||k.score>=i.scoreThreshold),p=Zn(m,i.statusRegistry),g=p.length,_=_s({pmRoot:i.pmRoot,sorted:p,query:r.query,mode:u.effectiveMode,searchOptions:r.options,limit:r.limit??i.maxResults}),y={...c,effectiveMode:u.effectiveMode};if(r.countOnly)return qe(qs(y,g),d);let{hits:w,projection:S}=Ws(r,o.filteredDocuments,_.limited),b=kr(w,S);return qe(zs(y,b,g,_.limited.length,S,_.pageExtras),d)}(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]="f303192a-cac2-588b-b988-e3a8132f4199")}catch{}})();var Ks=["ndcg","mrr","precision","recall"];function Ym(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Eval minimum must be an object of metric floors");let t={};for(let[n,r]of Object.entries(e)){if(!Ks.some(i=>i===n))throw new TypeError(`Unknown eval minimum metric: ${n}`);if(typeof r!="number"||!Number.isFinite(r)||r<0||r>1)throw new TypeError(`Eval minimum.${n} must be a finite number in [0, 1]`);t[n]=r}return t}function Xy(e,t){let n=Ym(t),r=[];for(let i of Ks){let o=n[i];if(o===void 0)continue;let s=e[i];!Number.isFinite(s)||s<0||s>1?r.push(`${i}:invalid`):s<o&&r.push(`${i}:${s}<${o}`)}return r}export{Qs as a,Jm as b,Zi as c,Zs as d,ea as e,tn as f,tf as g,aa as h,ca as i,nf as j,af as k,oh as l,to as m,ff as n,pf as o,hf as p,gf as q,no as r,Sf as s,Ef as t,Cf as u,po as v,_t as w,nc as x,wt as y,vt as z,Uf as A,wo as B,pn as C,St as D,Mc as E,So as F,Pc as G,Et as H,jc as I,Uc as J,qc as K,Wc as L,Kf as M,zc as N,Eo as O,hn as P,gn as Q,nd as R,cd as S,op as T,yn as U,_n as V,Ct as W,fd as X,yd as Y,It as Z,Ed as _,$o as $,Cd as aa,Oo as ba,Id as ca,Md as da,Me as ea,Np as fa,kn as ga,Ld as ha,Nd as ia,En as ja,ie as ka,In as la,xn as ma,Tn as na,he as oa,Le as pa,Tt as qa,Pp as ra,Nl as sa,jp as ta,Gl as ua,Zp as va,eh as wa,th as xa,nh as ya,rh as za,uh as Aa,mh as Ba,ls as Ca,us as Da,ms as Ea,jh as Fa,Uh as Ga,Qh as Ha,Nn as Ia,Pn as Ja,jn as Ka,Un as La,Bn as Ma,Gn as Na,_s as Oa,ye as Pa,_e as Qa,Pt as Ra,jt as Sa,Os as Ta,Ls as Ua,Vy as Va,Ky as Wa,Ks as Xa,Ym as Ya,Xy as Za};
|
|
12
|
-
//# sourceMappingURL=chunk-
|
|
12
|
+
//# sourceMappingURL=chunk-EZ4367G4.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as za,c as Gr,d as qr,e as yd,g as wd,h as Ga,i as vd,j as sn,k as cn,l as bd,m as kd,n as qa,o as xd,p as dn,q as ln,r as Ad,s as Id,t as Ba}from"./chunk-DRHJOG5X.js";import{e as ei,f as Xa,h as Za}from"./chunk-LZQGEVKT.js";import{B as Hd,C as Xr,D as zd,E as Ya,G as Wd,H as Gd,J as qd,K as Zr,M as Qr,a as ud,g as Ha,i as md}from"./chunk-6TKAFFEB.js";import{K as tu}from"./chunk-EOUORVJA.js";import{D as ro,E as pi,Ha as Bl,Ia as Vl,Ma as Jl,Na as Kl,T as fi,U as kl,V as io,W as Kn,Y as ao,aa as Pl,ba as Nl,ca as Ll,da as Ml,ea as gi,f as pl,g as fl,ga as jl,h as hl,ha as Fl,ia as Ul,ja as qt,k as mi,ka as Hl,kb as Zl,la as hn,ma as zl,mb as co,na as oo,nb as Ql,o as Vn,oa as _n,ob as eu,p as _l,pa as Wl,q as gl,qa as Gl,r as Jn,ra as ql,s as yl,sa as so,u as no,v as wl,wb as lo,z as vl}from"./chunk-2KSPGWLH.js";import{a as fd,b as on,c as Wa,d as hd,e as _d,f as ot,g as Br,h as gd,i as xt}from"./chunk-PBPPIGUL.js";import{$ as Xd,$a as bl,Aa as sl,Ab as ne,Ba as cl,Bb as ve,Cb as be,D as G,Da as Rt,Db as Ol,E as Bd,Ea as Bn,Eb as _i,Fa as dl,Fb as ct,Ga as oi,Gb as dt,H as Ce,Ha as Gt,I as Qa,Ia as ce,Ja as si,Jb as Dl,Ka as ll,Kb as lt,La as to,Ma as ci,Na as fn,O as Vd,Oa as di,P as ti,Pa as ul,S as ni,T as ri,Ta as Te,V as Jd,W as Me,Wa as ml,Xa as T,Y as It,Ya as li,Yb as Yn,Z as Kd,Za as ui,_ as Yd,_b as yi,aa as st,ba as Zd,fc as Yl,ga as Qd,gb as Sl,ha as eo,hb as El,ia as ii,ic as Xl,ja as mn,jb as xl,kb as Al,la as ai,lb as Ct,ma as el,mb as Il,na as tl,nb as Rl,pa as nl,qb as Cl,ra as rl,rb as Tl,ta as il,va as al,wb as hi,xa as pn,ya as ol,yb as $l}from"./chunk-OSKXYRYZ.js";import{b as rn,e as le,g as Le,i as Re,j as Ke,n as ge,o as Sd,p as Vr,r as Ed}from"./chunk-F2ME5MJY.js";import{$ as g,$a as L,$c as Ye,$d as At,Ac as Kr,Ba as fe,Bb as Ve,Bc as Pd,Ca as Ne,Cc as Nd,Da as Qc,Db as Je,Ec as Ld,Fa as ee,Ia as ed,Mc as H,Na as td,Nb as pd,Pc as X,Rc as He,S as Bc,Sb as Jr,Sc as Md,T as Vc,Ta as nd,Tb as Rd,Tc as Yr,Ua as rd,Ub as Va,V as Jc,Va as W,Vb as Ja,Wb as Ka,X as Kc,Y as zr,Yb as Cd,Yd as $,Z as Yc,Zb as Td,Zd as Ud,_a as qn,_c as jd,_d as un,a as Ur,aa as y,ab as Be,ac as $d,ae as Wt,bb as Wr,bd as Fd,cb as Ut,d as Hr,eb as id,fb as Ht,fe as te,ha as Xc,hb as ad,hc as Od,i as Wc,ib as od,jb as sd,ka as Zc,l as Gc,m as qc,ma as Fa,ra as Gn,rb as cd,sa as O,sb as zt,ta as Et,tb as C,ua as F,ub as dd,va as V,vb as Ie,w as ja,xb as Ua,ya as Z,yb as ld,yc as Dd,zb as an}from"./chunk-L3CZNKZE.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]="081bf1eb-4b9a-5fa9-a272-34ae781d250c")}catch{}})();var M=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},$e=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Xe=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 gn(e){try{return await e()}catch(t){throw t instanceof M?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function nu(e){try{return await e()}catch(t){throw t instanceof $e?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Kg}from"node:crypto";import Yg 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 yn=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]="416aaf09-e4f6-5d10-aee0-eba374f1cd83")}catch{}})();var iu=1,Bt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],uo=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],Xg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],Zg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,wi=30,vi=5e3,au=4,Qg=50;function ut(e,t){if(!Zg.test(e))throw new M(`${t} must be a stable lowercase id`)}function ey(e,t){if(!Number.isFinite(e)||e<0)throw new M(`${t} must be a finite non-negative number`)}function Xn(e){let t=Xg.filter(i=>e[i]!==void 0);if(t.length!==1)throw new M(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function po(e,t){return C(e)===C(t)}function ou(e,t){if(t.polarity==="equals")return po(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 su(e){let t=Xn(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>ou(r.observed,t)===(r.expected==="pass"))}function ty(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!po(e.value,t.value)}function ny(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||C(e.scope)!==C(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return ty(Xn(e),Xn(t))||n[t.enforcement]<n[e.enforcement]||r}function ry(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new M("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 M("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new M("items source equals/state requires field")}function iy(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new M("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(t=>t!==void 0).length>1)throw new M("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 M("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 M("dependency_kind source source_kind_state must be present or missing")}function ay(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new M("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 M("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 M("prose_edge_gap exemption selectors must not be empty")}}function fo(e){ut(e.id,"measurement.id"),e.max_cost!==void 0&&ey(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new M(`measurement.source.kind must be one of ${uo.join(", ")}`);let n=Reflect.get(t,"kind");if(!uo.includes(n))throw new M(`measurement.source.kind must be one of ${uo.join(", ")}`);let r=t;if(r.kind==="items"&&ry(r),r.kind==="dependency_kind"&&iy(r),r.kind==="prose_edge_gap"&&ay(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new M(`${r.kind} source requires field`);return r.kind==="provider"&&(ut(r.provider,"provider source provider"),ut(r.key,"provider source key")),e}function ho(e){if(ut(e.id,"assertion.id"),ut(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new M("assertion.owner_item_id is required");let t=Xn(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new M(`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 M("retired assertion requires retire_reason");e.scope.kind==="filter"&&ut(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 M("assertion negative control requires pass and fail cases");if(!su(e))throw new M(`assertion ${e.id} negative control does not prove its bound`);return e}function oy(e){if(!Array.isArray(e.allowed_providers))throw new M("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)ut(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new M("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!Bt.includes(t))throw new M(`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 M(`gate provider policy trigger ${t} is invalid`)}}function cu(e){if(ut(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new M("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new M("gate requires at least one assertion");for(let t of e.assertion_ids)ut(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new M(`gate.triggers is required and must be an array of ${Bt.join(", ")}`);if(e.triggers.length===0)throw new M("gate requires at least one trigger");for(let t of e.triggers)if(!Bt.includes(t))throw new M(`gate trigger must be one of ${Bt.join(", ")}`);return e.provider_policy&&oy(e.provider_policy),e}function wn(e){if(e.version!==iu)throw new M(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(fo(r),t.has(`measurement:${r.id}`))throw new M(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(ho(r),t.has(`assertion:${r.id}`))throw new M(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){cu(r);let i=r.assertion_ids.filter(a=>!e.assertions.some(o=>o.id===a));if(i.length>0)throw new M(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new M(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of du(e))if(!n.has(r))throw new M(`${i.join(", ")} references missing measurement ${r}`);return e}function _o(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)_o(n,t)}function du(e){let t=new Map,n=(r,i)=>{let a=t.get(r)??[];a.push(i),t.set(r,a)};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=[];_o(r.source.expression,i);for(let a of i)n(a,`derived measurement ${r.id}`)}return t}function sy(e,t){let n=e.assertion_ids.flatMap(a=>{let o=t.assertions.find(s=>s.id===a);return[o.measurement_id,...o.scope.kind==="filter"?[o.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let a=n.pop();if(r.has(a))continue;r.add(a);let o=t.measurements.find(s=>s.id===a);o.source.kind==="provider"?i.add(o.source.provider):o.source.kind==="derived"&&_o(o.source.expression,n)}return i}function Zn(){return{version:iu,measurements:[],assertions:[],gates:[]}}function cy(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 a=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?a:!a}return po(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function dy(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 ly(e,t){let n=[],r=Fa(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let a of i.dependencies??[]){let o=Fa(a.kind)??a.kind.trim().toLowerCase(),s=a.source_kind?.trim();o===r&&dy(e,s)&&n.push(`${i.id}->${a.id}${s?`@${s}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function uy(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 a=Reflect.get(i,"text");typeof a=="string"&&t.push(a)}}}return t}function my(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 mo(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function py(e){let t=new Map,n=new Set,r=[],i=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,a=0;for(let o of e){t.set(o.id.toLowerCase(),o.id);for(let s of o.dependencies??[])n.add(mo(o.id,s.id));for(let s of[o.parent,o.blocked_by])typeof s=="string"&&n.add(mo(o.id,s));for(let s of uy(o)){let c=[...s.matchAll(i)].map(d=>d[0]);a+=c.length,r.push({holder_id:o.id,segment:s,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:a}}function fy(e,t){let n=py(t.items),r=new Map;for(let o of n.prose_mentions){let s=o.mentioned_ids.map(d=>n.canonical_ids.get(d.toLowerCase())).filter(d=>d!==void 0&&d!==o.holder_id),c=[...new Set(s)];for(let d of c){let l=mo(o.holder_id,d);if(n.linked_pairs.has(l)||my(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);r.get(l)?.explicit===!0&&!u||r.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],a=i.map(o=>o.contributor).sort();return{value:a.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:a.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(o=>o.explicit).length,implicit_subject:i.filter(o=>!o.explicit).length}}}function hy(e,t){return{value:t.history.filter(n=>(e.op===void 0||n.op===e.op)&&(e.author===void 0||n.author===e.author)&&(e.harness===void 0||n.agent_harness===e.harness)&&(e.model===void 0||n.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function _y(e,t){let n=t.items.filter(r=>{let i=r[e.link],a=Array.isArray(i)&&i.length>0;return e.state==="present"?a:!a});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function gy(e,t){let n=e.source;return n.kind==="items"?cy(n,t):n.kind==="dependency_kind"?ly(n,t):n.kind==="prose_edge_gap"?fy(n,t):n.kind==="history"?hy(n,t):n.kind==="links"?_y(n,t):null}function lu(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 yy(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 uu(e,t,n){let r=new Array(e.length),i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let o=i;i+=1,r[o]=await n(e[o],o)}});return await Promise.all(a),r}async function mu(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let o=n.find(d=>d.id===e.measurement);if(!o)throw new TypeError(`derived measurement references missing ${e.measurement}`);let s=await pu(o,t,n,r,i);if(typeof s.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=i.charged.has(o.id)?[]:[s.cost];return i.charged.add(o.id),{value:s.value,costs:c,population_size:s.population_size,contributors:s.contributors}}let a=await uu(e.operands,au,o=>mu(o,t,n,r,i));return{value:yy(e.operator,a.map(o=>o.value)),costs:a.flatMap(o=>o.costs),population_size:Math.max(0,...a.map(o=>o.population_size)),contributors:[...new Set(a.flatMap(o=>o.contributors))]}}async function wy(e,t,n,r,i){fo(e);let a=Date.now(),o,s=[],c=0;if(e.source.kind==="derived"){let u=await mu(e.source.expression,t,n,[...r,e.id],i);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},s=u.costs}else{let u=gy(e,t);u!==null?o=u:(o=await t.external(e.source),c=1)}let d={units:o.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()-a},l=lu([...s,d],Date.now()-a);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new $e(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${Kg("sha256").update(C(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function pu(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let a=i.cache.get(e.id);if(a)return a;let o=wy(e,t,n,r,i).catch(s=>{if(s instanceof Xe&&s.measurement_id===void 0){let c={measurement_id:e.id,source_kind:s.source_kind,field:s.field,...s.check?{check:s.check}:{}},d=new Xe(s.message,c);throw d.cause=s,d}throw s});return i.cache.set(e.id,o),o}async function go(e,t,n=[e]){return pu(e,t,n,[],{cache:new Map,charged:new Set})}function vy(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,e-t.value)}function by(e,t,n={}){ho(e);let r=Xn(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:vy(t.value,r),verdict:i?"retired":ou(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:su(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function ky(e,t,n,r){let i=sy(e,t);if(i.size===0)return;let a=e.provider_policy,o=a?.triggers[r];if(!a||!o)throw new $e(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let s=new Set(a.allowed_providers),c={low:0,medium:1,high:2};for(let d of i){if(!s.has(d))throw new $e(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new $e(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new $e(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!o.allow_network)throw new $e(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function ru(e,t,n,r,i){try{return await go(n,r,i)}catch(a){if(a instanceof Xe){let o=a.check?` check ${a.check}`:"",s=a.measurement_id??n.id,c=new $e(`assurance gate ${e} assertion ${t} measurement ${s} source ${a.source_kind}${o} field ${a.field} could not resolve: ${a.message}`,{gate_id:e,assertion_id:t,measurement_id:s,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}});throw c.cause=a,c}throw a}}async function fu(e,t,n,r){wn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new $e(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new $e(`assurance gate ${e} does not declare trigger ${r.trigger}`);ky(i,t,n,r.trigger);let a=await uu(i.assertion_ids,au,async c=>{let d=t.assertions.find(p=>p.id===c),l=t.measurements.find(p=>p.id===d.measurement_id),u=n;if(d.scope.kind==="active"){let p=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(h=>!p.has(h.status))}}else if(d.scope.kind==="filter"){let p=d.scope.measurement_id,h=t.measurements.find(v=>v.id===p),_=await ru(i.id,d.id,h,n,t.measurements),w=new Set(_.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(p=>p.id===d.owner_item_id),f=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return by(d,await ru(i.id,d.id,l,u,t.measurements),{owner_terminal:f})}),o=a.some(c=>c.verdict==="fail"&&c.enforcement==="block"),s=a.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:o?"block":s?"warn":"pass",exit_code:o?1:0,assertions:a,assertions_total:a.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:lu(a.map(c=>c.cost),Math.max(0,...a.map(c=>c.cost.duration_ms)))}}function bi(e){return Yg.join(e,"assurance.json")}async function hu(e){let t=await V(bi(e));return t===null?Zn():ki(t)}function ki(e){try{return wn(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 Si(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function Sy(e,t){e==="measurement"?fo(t):e==="assertion"?ho(t):cu(t)}async function Qn(e,t){let n=structuredClone(Si(await hu(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function yo(e,t,n){let r=Si(await hu(e),t).find(i=>i.id===n);if(!r)throw new TypeError(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Ei(e,t,n,r={}){Sy(t,n);let i=await T(e),a=G(r.author,i.author_default),o=await fn({pmRoot:e,filePath:bi(e),op:`assurance:${t}:put`,author:a,message:r.message,lockTtlSeconds:wi,lockWaitMs:vi,mutate:s=>{let c=s===null?Zn():ki(s),d=Si(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&ny(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new M(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),wn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
1
|
+
import{a as za,c as Gr,d as qr,e as yd,g as wd,h as Ga,i as vd,j as sn,k as cn,l as bd,m as kd,n as qa,o as xd,p as dn,q as ln,r as Ad,s as Id,t as Ba}from"./chunk-W5AE7GKZ.js";import{e as ei,f as Xa,h as Za}from"./chunk-WAOXID5J.js";import{B as Hd,C as Xr,D as zd,E as Ya,G as Wd,H as Gd,J as qd,K as Zr,M as Qr,a as ud,g as Ha,i as md}from"./chunk-2CJWTLQG.js";import{K as tu}from"./chunk-362645PL.js";import{D as ro,E as pi,Ha as Bl,Ia as Vl,Ma as Jl,Na as Kl,T as fi,U as kl,V as io,W as Kn,Y as ao,aa as Pl,ba as Nl,ca as Ll,da as Ml,ea as gi,f as pl,g as fl,ga as jl,h as hl,ha as Fl,ia as Ul,ja as qt,k as mi,ka as Hl,kb as Zl,la as hn,ma as zl,mb as co,na as oo,nb as Ql,o as Vn,oa as _n,ob as eu,p as _l,pa as Wl,q as gl,qa as Gl,r as Jn,ra as ql,s as yl,sa as so,u as no,v as wl,wb as lo,z as vl}from"./chunk-DSLNUL2Q.js";import{a as fd,b as on,c as Wa,d as hd,e as _d,f as ot,g as Br,h as gd,i as xt}from"./chunk-PLTTMQAW.js";import{$ as Xd,$a as bl,Aa as sl,Ab as ne,Ba as cl,Bb as ve,Cb as be,D as G,Da as Rt,Db as Ol,E as Bd,Ea as Bn,Eb as _i,Fa as dl,Fb as ct,Ga as oi,Gb as dt,H as Ce,Ha as Gt,I as Qa,Ia as ce,Ja as si,Jb as Dl,Ka as ll,Kb as lt,La as to,Ma as ci,Na as fn,O as Vd,Oa as di,P as ti,Pa as ul,S as ni,T as ri,Ta as Te,V as Jd,W as Me,Wa as ml,Xa as T,Y as It,Ya as li,Yb as Yn,Z as Kd,Za as ui,_ as Yd,_b as yi,aa as st,ba as Zd,fc as Yl,ga as Qd,gb as Sl,ha as eo,hb as El,ia as ii,ic as Xl,ja as mn,jb as xl,kb as Al,la as ai,lb as Ct,ma as el,mb as Il,na as tl,nb as Rl,pa as nl,qb as Cl,ra as rl,rb as Tl,ta as il,va as al,wb as hi,xa as pn,ya as ol,yb as $l}from"./chunk-MCVWZUGK.js";import{b as rn,e as le,g as Le,i as Re,j as Ke,n as ge,o as Sd,p as Vr,r as Ed}from"./chunk-PBCYGO7X.js";import{$ as g,$a as L,$c as Ye,$d as At,Ac as Kr,Ba as fe,Bb as Ve,Bc as Pd,Ca as Ne,Cc as Nd,Da as Qc,Db as Je,Ec as Ld,Fa as ee,Ia as ed,Mc as H,Na as td,Nb as pd,Pc as X,Rc as He,S as Bc,Sb as Jr,Sc as Md,T as Vc,Ta as nd,Tb as Rd,Tc as Yr,Ua as rd,Ub as Va,V as Jc,Va as W,Vb as Ja,Wb as Ka,X as Kc,Y as zr,Yb as Cd,Yd as $,Z as Yc,Zb as Td,Zd as Ud,_a as qn,_c as jd,_d as un,a as Ur,aa as y,ab as Be,ac as $d,ae as Wt,bb as Wr,bd as Fd,cb as Ut,d as Hr,eb as id,fb as Ht,fe as te,ha as Xc,hb as ad,hc as Od,i as Wc,ib as od,jb as sd,ka as Zc,l as Gc,m as qc,ma as Fa,ra as Gn,rb as cd,sa as O,sb as zt,ta as Et,tb as C,ua as F,ub as dd,va as V,vb as Ie,w as ja,xb as Ua,ya as Z,yb as ld,yc as Dd,zb as an}from"./chunk-B3YW6H2I.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]="081bf1eb-4b9a-5fa9-a272-34ae781d250c")}catch{}})();var M=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},$e=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Xe=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 gn(e){try{return await e()}catch(t){throw t instanceof M?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function nu(e){try{return await e()}catch(t){throw t instanceof $e?new y(t.message,g.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Kg}from"node:crypto";import Yg 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 yn=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]="416aaf09-e4f6-5d10-aee0-eba374f1cd83")}catch{}})();var iu=1,Bt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],uo=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],Xg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],Zg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,wi=30,vi=5e3,au=4,Qg=50;function ut(e,t){if(!Zg.test(e))throw new M(`${t} must be a stable lowercase id`)}function ey(e,t){if(!Number.isFinite(e)||e<0)throw new M(`${t} must be a finite non-negative number`)}function Xn(e){let t=Xg.filter(i=>e[i]!==void 0);if(t.length!==1)throw new M(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function po(e,t){return C(e)===C(t)}function ou(e,t){if(t.polarity==="equals")return po(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 su(e){let t=Xn(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>ou(r.observed,t)===(r.expected==="pass"))}function ty(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!po(e.value,t.value)}function ny(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||C(e.scope)!==C(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return ty(Xn(e),Xn(t))||n[t.enforcement]<n[e.enforcement]||r}function ry(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new M("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 M("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new M("items source equals/state requires field")}function iy(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new M("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(t=>t!==void 0).length>1)throw new M("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 M("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 M("dependency_kind source source_kind_state must be present or missing")}function ay(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new M("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 M("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 M("prose_edge_gap exemption selectors must not be empty")}}function fo(e){ut(e.id,"measurement.id"),e.max_cost!==void 0&&ey(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new M(`measurement.source.kind must be one of ${uo.join(", ")}`);let n=Reflect.get(t,"kind");if(!uo.includes(n))throw new M(`measurement.source.kind must be one of ${uo.join(", ")}`);let r=t;if(r.kind==="items"&&ry(r),r.kind==="dependency_kind"&&iy(r),r.kind==="prose_edge_gap"&&ay(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new M(`${r.kind} source requires field`);return r.kind==="provider"&&(ut(r.provider,"provider source provider"),ut(r.key,"provider source key")),e}function ho(e){if(ut(e.id,"assertion.id"),ut(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new M("assertion.owner_item_id is required");let t=Xn(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new M(`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 M("retired assertion requires retire_reason");e.scope.kind==="filter"&&ut(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 M("assertion negative control requires pass and fail cases");if(!su(e))throw new M(`assertion ${e.id} negative control does not prove its bound`);return e}function oy(e){if(!Array.isArray(e.allowed_providers))throw new M("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)ut(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new M("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!Bt.includes(t))throw new M(`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 M(`gate provider policy trigger ${t} is invalid`)}}function cu(e){if(ut(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new M("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new M("gate requires at least one assertion");for(let t of e.assertion_ids)ut(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new M(`gate.triggers is required and must be an array of ${Bt.join(", ")}`);if(e.triggers.length===0)throw new M("gate requires at least one trigger");for(let t of e.triggers)if(!Bt.includes(t))throw new M(`gate trigger must be one of ${Bt.join(", ")}`);return e.provider_policy&&oy(e.provider_policy),e}function wn(e){if(e.version!==iu)throw new M(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(fo(r),t.has(`measurement:${r.id}`))throw new M(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(ho(r),t.has(`assertion:${r.id}`))throw new M(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){cu(r);let i=r.assertion_ids.filter(a=>!e.assertions.some(o=>o.id===a));if(i.length>0)throw new M(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new M(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of du(e))if(!n.has(r))throw new M(`${i.join(", ")} references missing measurement ${r}`);return e}function _o(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)_o(n,t)}function du(e){let t=new Map,n=(r,i)=>{let a=t.get(r)??[];a.push(i),t.set(r,a)};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=[];_o(r.source.expression,i);for(let a of i)n(a,`derived measurement ${r.id}`)}return t}function sy(e,t){let n=e.assertion_ids.flatMap(a=>{let o=t.assertions.find(s=>s.id===a);return[o.measurement_id,...o.scope.kind==="filter"?[o.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let a=n.pop();if(r.has(a))continue;r.add(a);let o=t.measurements.find(s=>s.id===a);o.source.kind==="provider"?i.add(o.source.provider):o.source.kind==="derived"&&_o(o.source.expression,n)}return i}function Zn(){return{version:iu,measurements:[],assertions:[],gates:[]}}function cy(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 a=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?a:!a}return po(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function dy(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 ly(e,t){let n=[],r=Fa(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let a of i.dependencies??[]){let o=Fa(a.kind)??a.kind.trim().toLowerCase(),s=a.source_kind?.trim();o===r&&dy(e,s)&&n.push(`${i.id}->${a.id}${s?`@${s}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function uy(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 a=Reflect.get(i,"text");typeof a=="string"&&t.push(a)}}}return t}function my(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 mo(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function py(e){let t=new Map,n=new Set,r=[],i=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,a=0;for(let o of e){t.set(o.id.toLowerCase(),o.id);for(let s of o.dependencies??[])n.add(mo(o.id,s.id));for(let s of[o.parent,o.blocked_by])typeof s=="string"&&n.add(mo(o.id,s));for(let s of uy(o)){let c=[...s.matchAll(i)].map(d=>d[0]);a+=c.length,r.push({holder_id:o.id,segment:s,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:a}}function fy(e,t){let n=py(t.items),r=new Map;for(let o of n.prose_mentions){let s=o.mentioned_ids.map(d=>n.canonical_ids.get(d.toLowerCase())).filter(d=>d!==void 0&&d!==o.holder_id),c=[...new Set(s)];for(let d of c){let l=mo(o.holder_id,d);if(n.linked_pairs.has(l)||my(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);r.get(l)?.explicit===!0&&!u||r.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],a=i.map(o=>o.contributor).sort();return{value:a.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:a.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(o=>o.explicit).length,implicit_subject:i.filter(o=>!o.explicit).length}}}function hy(e,t){return{value:t.history.filter(n=>(e.op===void 0||n.op===e.op)&&(e.author===void 0||n.author===e.author)&&(e.harness===void 0||n.agent_harness===e.harness)&&(e.model===void 0||n.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function _y(e,t){let n=t.items.filter(r=>{let i=r[e.link],a=Array.isArray(i)&&i.length>0;return e.state==="present"?a:!a});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function gy(e,t){let n=e.source;return n.kind==="items"?cy(n,t):n.kind==="dependency_kind"?ly(n,t):n.kind==="prose_edge_gap"?fy(n,t):n.kind==="history"?hy(n,t):n.kind==="links"?_y(n,t):null}function lu(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 yy(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 uu(e,t,n){let r=new Array(e.length),i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let o=i;i+=1,r[o]=await n(e[o],o)}});return await Promise.all(a),r}async function mu(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let o=n.find(d=>d.id===e.measurement);if(!o)throw new TypeError(`derived measurement references missing ${e.measurement}`);let s=await pu(o,t,n,r,i);if(typeof s.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=i.charged.has(o.id)?[]:[s.cost];return i.charged.add(o.id),{value:s.value,costs:c,population_size:s.population_size,contributors:s.contributors}}let a=await uu(e.operands,au,o=>mu(o,t,n,r,i));return{value:yy(e.operator,a.map(o=>o.value)),costs:a.flatMap(o=>o.costs),population_size:Math.max(0,...a.map(o=>o.population_size)),contributors:[...new Set(a.flatMap(o=>o.contributors))]}}async function wy(e,t,n,r,i){fo(e);let a=Date.now(),o,s=[],c=0;if(e.source.kind==="derived"){let u=await mu(e.source.expression,t,n,[...r,e.id],i);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},s=u.costs}else{let u=gy(e,t);u!==null?o=u:(o=await t.external(e.source),c=1)}let d={units:o.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()-a},l=lu([...s,d],Date.now()-a);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new $e(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${Kg("sha256").update(C(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function pu(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let a=i.cache.get(e.id);if(a)return a;let o=wy(e,t,n,r,i).catch(s=>{if(s instanceof Xe&&s.measurement_id===void 0){let c={measurement_id:e.id,source_kind:s.source_kind,field:s.field,...s.check?{check:s.check}:{}},d=new Xe(s.message,c);throw d.cause=s,d}throw s});return i.cache.set(e.id,o),o}async function go(e,t,n=[e]){return pu(e,t,n,[],{cache:new Map,charged:new Set})}function vy(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,e-t.value)}function by(e,t,n={}){ho(e);let r=Xn(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:vy(t.value,r),verdict:i?"retired":ou(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:su(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function ky(e,t,n,r){let i=sy(e,t);if(i.size===0)return;let a=e.provider_policy,o=a?.triggers[r];if(!a||!o)throw new $e(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let s=new Set(a.allowed_providers),c={low:0,medium:1,high:2};for(let d of i){if(!s.has(d))throw new $e(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new $e(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new $e(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!o.allow_network)throw new $e(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function ru(e,t,n,r,i){try{return await go(n,r,i)}catch(a){if(a instanceof Xe){let o=a.check?` check ${a.check}`:"",s=a.measurement_id??n.id,c=new $e(`assurance gate ${e} assertion ${t} measurement ${s} source ${a.source_kind}${o} field ${a.field} could not resolve: ${a.message}`,{gate_id:e,assertion_id:t,measurement_id:s,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}});throw c.cause=a,c}throw a}}async function fu(e,t,n,r){wn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new $e(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new $e(`assurance gate ${e} does not declare trigger ${r.trigger}`);ky(i,t,n,r.trigger);let a=await uu(i.assertion_ids,au,async c=>{let d=t.assertions.find(p=>p.id===c),l=t.measurements.find(p=>p.id===d.measurement_id),u=n;if(d.scope.kind==="active"){let p=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(h=>!p.has(h.status))}}else if(d.scope.kind==="filter"){let p=d.scope.measurement_id,h=t.measurements.find(v=>v.id===p),_=await ru(i.id,d.id,h,n,t.measurements),w=new Set(_.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(p=>p.id===d.owner_item_id),f=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return by(d,await ru(i.id,d.id,l,u,t.measurements),{owner_terminal:f})}),o=a.some(c=>c.verdict==="fail"&&c.enforcement==="block"),s=a.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:o?"block":s?"warn":"pass",exit_code:o?1:0,assertions:a,assertions_total:a.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:lu(a.map(c=>c.cost),Math.max(0,...a.map(c=>c.cost.duration_ms)))}}function bi(e){return Yg.join(e,"assurance.json")}async function hu(e){let t=await V(bi(e));return t===null?Zn():ki(t)}function ki(e){try{return wn(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 Si(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function Sy(e,t){e==="measurement"?fo(t):e==="assertion"?ho(t):cu(t)}async function Qn(e,t){let n=structuredClone(Si(await hu(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function yo(e,t,n){let r=Si(await hu(e),t).find(i=>i.id===n);if(!r)throw new TypeError(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Ei(e,t,n,r={}){Sy(t,n);let i=await T(e),a=G(r.author,i.author_default),o=await fn({pmRoot:e,filePath:bi(e),op:`assurance:${t}:put`,author:a,message:r.message,lockTtlSeconds:wi,lockWaitMs:vi,mutate:s=>{let c=s===null?Zn():ki(s),d=Si(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&ny(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new M(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),wn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
2
2
|
`,result:{changed:!0,action:u,kind:t,id:n.id}}}});return{...o.result,changed:o.changed}}async function wo(e,t,n={}){let r=Zn();r.measurements=structuredClone(t.measurements),r.assertions=structuredClone(t.assertions),r.gates=structuredClone(t.gates),wn(r);let i=await T(e),a=G(n.author,i.author_default),o=await fn({pmRoot:e,filePath:bi(e),op:"assurance:bundle:apply",author:a,message:n.message,lockTtlSeconds:wi,lockWaitMs:vi,mutate:s=>{let c=s===null?Zn():ki(s),d=[],l=[],u=(m,f,p)=>{for(let h of f){let _=m.find(w=>w.id===h.id);if(!_){m.push(structuredClone(h)),d.push(`${p}:${h.id}`);continue}if(C(_)!==C(h))throw new M(`assurance bundle refuses to replace divergent ${p} ${h.id}`);l.push(`${p}:${h.id}`)}};return u(c.measurements,r.measurements,"measurement"),u(c.assertions,r.assertions,"assertion"),u(c.gates,r.gates,"gate"),wn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
3
3
|
`,result:{changed:d.length>0,created_ids:d,unchanged_ids:l}}}});return{...o.result,changed:o.changed}}async function _u(e,t,n,r={}){let i=await T(e),a=G(r.author,i.author_default),o=await fn({pmRoot:e,filePath:bi(e),op:`assurance:${t}:remove`,author:a,message:r.message,lockTtlSeconds:wi,lockWaitMs:vi,mutate:s=>{let c=s===null?Zn():ki(s);if(t==="measurement"){let u=du(c).get(n);if(u&&u.length>0)throw new M(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new M(`assurance assertion ${n} is referenced by gate`);let d=Si(c,t),l=d.findIndex(u=>u.id===n);if(l<0)throw new M(`assurance ${t} ${n} not found`);return d.splice(l,1),wn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
4
4
|
`,result:{changed:!0,action:"removed",kind:t,id:n}}}});return{...o.result,changed:o.changed}}async function gu(e,t,n={}){if(t.dry_run)throw new TypeError("dry-run assurance verdicts are not persisted");let r=await T(e);await ci({pmRoot:e,op:"assurance:gate:verdict",author:G(n.author,r.author_default),context:{assurance_verdict:t},message:n.message??`Assurance gate ${t.gate_id} returned ${t.verdict}`,lockTtlSeconds:wi,lockWaitMs:vi})}async function yu(e,t={}){let n=t.limit??Qg;if(!Number.isInteger(n)||n<1||n>yn)throw new TypeError(`assurance verdict limit must be an integer from 1 through ${yn}`);return(await st(si(e),ce)).reverse().filter(r=>r.op==="assurance:gate:verdict").map(r=>r.context?.assurance_verdict).filter(r=>typeof r=="object"&&r!==null&&"gate_id"in r).filter(r=>t.gate_id===void 0||r.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]="caa9f916-c7ce-5e74-a00b-dd0fc6a41b5d")}catch{}})();var er={type:"string",minLength:1,maxLength:128,pattern:"\\S"},xi={type:"array",minItems:1,maxItems:Va,items:er},wu={...xi,items:{...er,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,xi])),dependency:{type:"object",additionalProperties:!1,required:["kind"],properties:{kind:er,id:er}}}},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:xi}},...["field_writers","approval"].map(e=>({type:"object",additionalProperties:!1,required:["kind","fields","authors"],properties:{kind:{const:e},fields:wu,authors:xi}})),{type:"object",additionalProperties:!1,required:["kind","allowed"],properties:{kind:{const:"transition"},allowed:{type:"array",maxItems:Va,items:{type:"array",minItems:2,maxItems:2,items:er}}}}]}}},o$={$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:Rd,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]="808f3bb5-cca5-5f9c-b557-7923c79ae6ce")}catch{}})();async function vu(e,t,n,r){let i=await Ct(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 xy(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=[],a=new Map,o=e.policies.filter(_=>_.rule.kind==="require_fields"),s=o.filter(_=>_.subject?.operations===void 0),c=new Set,d=0,l=0,u=0,m=0,f=0,p=$d(e);for(let _ of t){let w=p({operation:"",author:"",before:_,after:_,completeness_only:!0});d+=+(w.decisions.length>0),l+=w.decisions.length,w.decisions.forEach(k=>c.add(k.policy_id));let v=w.decisions.filter(k=>!k.satisfied);if(v.length===0)continue;m+=1;let S=a.get(_.type)??{items:0,violations:0,missing_fields:0};S.items+=1;for(let k of v)u+=1,S.violations+=1,S.missing_fields+=k.missing_fields.length,k.effect==="refuse"&&(f+=1),i.length<n&&i.push({id:_.id,type:_.type,status:_.status,decision:k});a.set(_.type,S)}let h=r||f>0?"error":u>0?"warn":"ok";return{check:{name:"completeness",status:h,ok:h==="ok",details:{scope:"operation_independent_require_fields",declared_requirement_count:o.length,state_requirement_count:s.length,applicable_requirement_count:c.size,requirement_application_count:l,governed_items:d,ungoverned_items:t.length-d,contract_status:xy(o.length,t.length,d),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(a),violations:i,violations_truncated:i.length<u,enforcement:e.enforcement}},warnings:[...u>0?[`validate_completeness_missing_fields:${u}`]:[],...r?["validate_completeness_source_incomplete"]:[]]}}import Ay 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]="0c3bed4d-4a17-5004-a1c5-65f6acec2a9b")}catch{}})();function Iy(){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(([e,t])=>({id:`completeness-${e.toLowerCase()}`,effect:"advise",description:`Evidence expected when ${e} work reaches completion.`,subject:{types:[e],statuses:["closed"]},rule:{kind:"require_fields",fields:[...t]}})),{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 Ry(e,t){let n=L(process.cwd(),e.path);await ne(n);let r=await T(n);return{pmRoot:n,settings:r,author:G(t,r.author_default)}}function ku(e,t,n,r){if(e==="policy-mode")return Ka({...n,enforcement:t});let i=n.policies.filter(s=>s.id!==t);if(e==="policy-remove")return{...n,policies:i};let a=Ja(r.definition),o=Ka({...n,policies:[...i,a].sort((s,c)=>s.id.localeCompare(c.id))});if(Buffer.byteLength(`${JSON.stringify(o,null,2)}
|
|
@@ -73,4 +73,4 @@ ${a}`,g.GENERIC_FAILURE)}}function Na(e){return typeof e.tag=="string"&&e.tag.tr
|
|
|
73
73
|
`);de(e.progressEnabled,"writing keyword artifacts"),await Z(t,`${JSON.stringify(e.manifest,null,2)}
|
|
74
74
|
`),await Z(n,`${i}
|
|
75
75
|
`);let a=[];if(e.mode!=="keyword")try{de(e.progressEnabled,"writing vectorization status ledger"),await Wl(e.pmRoot,e.vectorizationLedgerEntries,e.vectorizationEmbeddingMetadata)}catch(o){a.push(`search_vectorization_status_ledger_write_failed:${o instanceof Error?o.message:String(o)}`)}return a}async function Vq(e,t){let n=xT(e.mode),r=ET(e),i=e.full===!0;de(r,`start mode=${n}`);let a=L(process.cwd(),t.path);await ne(a);let o=fi(await T(a)).settings,s=null;try{s=await te(a,kl,o.locks.ttl_seconds,G(void 0,"pm-reindex"),!1,o.governance.force_required_for_stale_lock,o.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=RT(o),d=CT(o),l=NT({requestedMode:n,pmRoot:a,settings:o,extensionEmbedding:c,extensionVectorAdapter:d}),u=n;de(r,"loading item corpus");let m=await LT({pmRoot:a,settings:o}),f=m.warnings,{documentCandidates:p,metadataDocuments:h}=m;de(r,`loaded_items=${h.length}`);let _=$(),w=PT(u,_,h),v=Lr.join(a,Fc),S=Lr.join(a,Uc),k=u==="keyword"?await zc(a,p,o.schema,f):h,x=[],D={},E=null,b=DT(u);if(u==="keyword"&&await MT({pmRoot:a,settings:o,forceFullSemantic:i,extensionEmbedding:c,reindexWarnings:f}),u!=="keyword"){let R=await GT({pmRoot:a,settings:o,requestedMode:n,activeEmbeddingProvider:l.activeEmbeddingProvider,activeVectorStore:l.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:d,documentCandidates:p,metadataDocuments:h,documentsForKeywordArtifacts:k,forceFullSemantic:i,reindexWarnings:f,semanticWarnings:x,semanticSummary:b,progressEnabled:r});k=R.documentsForKeywordArtifacts,D=R.vectorizationLedgerEntries,E=R.vectorizationEmbeddingMetadata}let N=await qT({pmRoot:a,mode:u,manifest:w,documentsForKeywordArtifacts:k,settings:o,vectorizationLedgerEntries:D,vectorizationEmbeddingMetadata:E,progressEnabled:r}),A=[...await X({path:v,scope:"project",op:"reindex:manifest"}),...await X({path:S,scope:"project",op:"reindex:embeddings"}),...await Yr({mode:u,total_items:h.length})];return de(r,"done"),{ok:!0,mode:u,total_items:h.length,semantic:b,artifacts:{manifest:Fc,embeddings:Uc},warnings:[...f,...x,...N,...A],generated_at:_}}finally{await s?.()}}export{M as a,$e as b,Xe as c,gn as d,nu as e,iu as f,Bt as g,uo as h,ny as i,fo as j,ho as k,cu as l,wn as m,Zn as n,go as o,by as p,fu as q,Qn as r,yo as s,Ei as t,wo as u,_u as v,gu as w,yu as x,ip as y,qD as z,uv as A,mv as B,et as C,xP as D,Nv as E,Ey as F,o$ as G,bu as H,Iy as I,A$ as J,Sb as K,CN as L,ON as M,DN as N,ur as O,PN as P,NN as Q,LN as R,MN as S,jN as T,FN as U,UN as V,HN as W,zN as X,WN as Y,GN as Z,ws as _,Is as $,vD as aa,_m as ba,Ri as ca,iO as da,P as ea,oe as fa,aO as ga,ko as ha,oO as ia,sO as ja,Ou as ka,cO as la,dO as ma,lO as na,Gy as oa,uO as pa,mO as qa,So as ra,pO as sa,fO as ta,bo as ua,hO as va,_O as wa,Pu as xa,gO as ya,By as za,Mu as Aa,IO as Ba,rr as Ca,RO as Da,Qy as Ea,ew as Fa,CO as Ga,tw as Ha,S_ as Ia,PO as Ja,Gu as Ka,x_ as La,uz as Ma,mz as Na,ir as Oa,$i as Pa,Bu as Qa,Vu as Ra,Ju as Sa,Ku as Ta,Qu as Ua,tm as Va,nm as Wa,am as Xa,Mt as Ya,b1 as Za,k1 as _a,S1 as $a,E1 as ab,N1 as bb,mh as cb,pa as db,rF as eb,vt as fb,iF as gb,aF as hb,_x as ib,vx as jb,Ah as kb,bw as lb,sm as mb,qs as nb,ZF as ob,QF as pb,Di as qb,Pi as rb,Xh as sb,XU as tb,Zh as ub,e_ as vb,t_ as wb,i_ as xb,o_ as yb,WI as zb,GI as Ab,_z as Bb,gz as Cb,yz as Db,wz as Eb,BI as Fb,VI as Gb,JI as Hb,vz as Ib,R_ as Jb,YI as Kb,C_ as Lb,uc as Mb,$_ as Nb,XI as Ob,ZI as Pb,QI as Qb,hc as Rb,_c as Sb,Tz as Tb,$z as Ub,Oz as Vb,TR as Wb,WW as Xb,yg as Yb,Dr as Zb,bg as _b,kg as $b,Sg as ac,$c as bc,jC as cc,xG as dc,JG as ec,nq as fc,Ng as gc,Lg as hc,Mg as ic,Aq as jc,Fq as kc,Uq as lc,Hq as mc,Vq as nc};
|
|
76
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-IARAEFMA.js.map
|