@unbrained/pm-cli 2026.11.8 → 2026.11.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 +1 -1
- package/CHANGELOG.md +15 -0
- package/dist/cli/main.js +1 -1
- package/dist/cli/runtime/projection-retry.js +1 -1
- package/dist/cli/runtime/read-output-mutation-retry.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-NH7QX2M2.js → chunk-3BMIAI4P.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RC6SSFOF.js → chunk-5VRJPPUC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XBUZENP4.js → chunk-6V4PGJBZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YUTFMHSG.js → chunk-ASJZMYKM.js} +33 -33
- package/dist/cli-bundle/chunks/chunk-BLUCQ4T4.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-4BMPGUTG.js → chunk-ELNWRSGZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7GC6WIDR.js → chunk-EZRLW4R6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NKO42JMT.js → chunk-G6Q4VQSI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3A5DJZCC.js → chunk-GCPP37N6.js} +48 -48
- package/dist/cli-bundle/chunks/{chunk-C4MQFWCM.js → chunk-GDQ2T2OR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-L5BU5FYN.js → chunk-GZVOOHTO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LI2HP5OX.js → chunk-IGT252ES.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CP43BHX3.js → chunk-JK7O7MFO.js} +29 -29
- package/dist/cli-bundle/chunks/{chunk-AFZS6WFV.js → chunk-JYQXIC6C.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PE6CZ3PE.js → chunk-LVDFPGD7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Z3LWNF7C.js → chunk-MSJ7IHMJ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MKW5LGVQ.js → chunk-O2M3TNFY.js} +6 -6
- package/dist/cli-bundle/chunks/chunk-UFIM5ZC5.js +6 -0
- package/dist/cli-bundle/chunks/{chunk-YGUUJHSR.js → chunk-VATZTJE3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DOHZKPPC.js → chunk-XKY4LUXN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7V6I6X4G.js → chunk-YK5GAWOT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-S4IZIMAO.js → chunk-YV5ALMG2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HESIRIVX.js → chunk-Z3QEEOAM.js} +2 -2
- package/dist/cli-bundle/chunks/item-revision-Y5CE3EIN.js +2 -0
- package/dist/cli-bundle/chunks/item-transaction-XBIN4KYM.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-admission-FJ3D66PV.js → mutation-admission-TAQN2AKK.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-GXP77CX7.js → register-list-query-XMQYFUFI.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-XJ2DROUM.js → register-mutation-OBVCFLDK.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-O5LERXM7.js → register-operations-CGNFZ6DR.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-4VOTYLL2.js → register-setup-LFB5ERXH.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-ZDJL3FGL.js → stage-NQHF6JPC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-Z2QWZRSL.js → chunk-2SQUWQP3.js} +18 -18
- package/dist/cli-bundle/focused-chunks/chunk-4FWMXQN3.js +12 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4UOXVFJZ.js → chunk-AH5IST3V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6U5HP6L3.js → chunk-ALLOWZSH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KNF2QTEZ.js → chunk-C3DO4ZGZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LTPT5TE7.js → chunk-CUGJ2DY2.js} +20 -20
- package/dist/cli-bundle/focused-chunks/{chunk-2A3QZELL.js → chunk-HLQOGAWG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-P4EHEH4C.js → chunk-HNFY3XLC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-IB6TCE7N.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-5YPX3QKU.js → chunk-IS5FLEZW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ULTSMJYF.js → chunk-J7PWHKZK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-P6TG33FV.js → chunk-JU62TKJP.js} +26 -26
- package/dist/cli-bundle/focused-chunks/{chunk-TSHRBPTI.js → chunk-LDMBNTOG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UUVRYIKA.js → chunk-LWMPQRJT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MYBKRV5R.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KBRSA4OK.js → chunk-NUFO3OR6.js} +25 -25
- package/dist/cli-bundle/focused-chunks/{chunk-DIEBSC76.js → chunk-NZQYHPUN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3HFENALW.js → chunk-Q45LDP7P.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-O7K3X4LH.js → chunk-QWUWNFQO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SZ2BKK3M.js → chunk-RNZUORGI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WPXMPGTY.js → chunk-UIKLNSW3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-I4YUZW3J.js → chunk-XLSTFUXM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-revision-M6FOLME2.js +2 -0
- package/dist/cli-bundle/focused-chunks/{item-transaction-Q2Z7DDCR.js → item-transaction-H6VA5JGB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-QWC6MLTZ.js → mutation-admission-PRTQWQK6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-NKH5SKSZ.js → stage-7T77PSJD.js} +2 -2
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +4 -4
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +57 -57
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +9 -9
- package/dist/core/item/item-format.d.ts +9 -1
- package/dist/core/item/item-format.js +1 -1
- package/dist/core/output/output.d.ts +9 -2
- package/dist/core/output/output.js +4 -4
- package/dist/core/search/corpus.js +1 -1
- package/dist/mcp/tool-definitions.js +1 -1
- package/dist/sdk/annotations.js +1 -1
- package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/lifecycle/item-revision.d.ts +6 -0
- package/dist/sdk/lifecycle/item-revision.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/get-facet-roots.js +2 -0
- package/dist/sdk/query/get.js +1 -1
- package/dist/sdk/read-output/positional-rows.js +2 -0
- package/dist/sdk/read-output-contracts.d.ts +4 -0
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/docs/AGENT_OUTPUT_ENCODINGS.md +16 -0
- package/docs/README.md +1 -1
- package/docs/READ_OUTPUT_CONTRACTS.md +21 -0
- package/docs/RELEASING.md +27 -5
- package/marketplace.json +1 -1
- package/package.json +2 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-JAE5MWLX.js +0 -2
- package/dist/cli-bundle/chunks/chunk-LLTRUVKK.js +0 -6
- package/dist/cli-bundle/chunks/item-revision-TUGZYYXX.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-2RRBAQN3.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-PL6EO4GJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-PSLDGAEY.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-UNNLBJRI.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-revision-XNSRDTFB.js +0 -2
- package/docs/ECOSYSTEM_PLANNING_REVIEW.md +0 -274
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{r as q,s as V}from"./chunk-
|
|
1
|
+
import{r as q,s as V}from"./chunk-AH5IST3V.js";import{d as m,j as M,l as k}from"./chunk-RNZUORGI.js";import{Ga as O,Gd as N,Jd as D,Md as j,S as x,X as g,ce as z}from"./chunk-2SQUWQP3.js";import{A as C,E as _,I as L,z as S}from"./chunk-G6ERMFJ5.js";import{constants as p}from"node:fs";import{lstat as A,mkdir as I,open as P}from"node:fs/promises";import h from"node:path";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="5434ff6f-95af-5983-88cb-fd360d95cb9e")}catch{}})();function E(i,e){if(typeof i!="string"||i.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return i.trim()}function $(i,e){let t=e.require(i.kind),n=t.direction==="undirected"?[i.source,i.target].sort().join("\0"):`${i.source}\0${i.target}`;return`${t.kind}\0${n}`}function Q(i){return Object.freeze({...i,...i.payload===void 0?{}:{payload:Object.freeze(structuredClone(i.payload))}})}function U(i,e,t,n){let r=t.require(i.kind),o=n.outgoingOne.get(`${r.kind}\0${i.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=n.incomingOne.get(`${r.kind}\0${i.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let c=$(i,t),a=n.identities.get(c);if(a!==void 0&&a!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function Y(i){let e=new Map;for(let t of i)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function X(i,e,t){if(i.expectedVersion!==void 0&&i.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${i.expectedVersion}, current ${e}`);let n=E(i.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(i.action!=="add"&&i.action!=="remove"&&i.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${i.action}`);if(!Number.isFinite(Date.parse(i.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(i.relationshipId,"relationshipId"),author:E(i.author,"author"),timestamp:new Date(i.timestamp).toISOString()}}function Z(i,e,t,n,r,o){let s=t.has(e);if(i.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(i.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(i.action==="remove")return;if(!i.edge)throw new TypeError(`Relationship ${i.action} event requires an edge`);let c=typeof i.edge.source=="string"?i.edge.source.trim():"",a=typeof i.edge.target=="string"?i.edge.target.trim():"";if(!n.has(c)||!n.has(a))throw new TypeError(`Relationship endpoint not found: ${c} -> ${a}`);let d=new g([c,a],[i.edge],r).edges()[0];return U(d,e,r,o),Q(d)}var T=class{#t;#i;#n=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#i=t.registry??x()}get version(){return this.#n.length}events(){return Object.freeze([...this.#n])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,r=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=r)yield Object.freeze(this.#n.slice(o,Math.min(o+r,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let r=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let a of c)r=t(r,a),o+=1,s=a;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#i.require(t.kind);this.#r.identities.set($(t,this.#i),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#i.require(e.kind);this.#r.identities.delete($(e,this.#i)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=X(e,this.version,this.#o),n=this.#e.get(t.relationshipId),r=Z(e,t.relationshipId,this.#e,this.#t,this.#i,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...r===void 0?{}:{edge:r},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#n.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,r),this.#s(t.relationshipId,r)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#n.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#n.slice(0,o)}let n=Y(t),r=new g(this.#t,n.values(),this.#i);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=N("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(D(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=j(this.#n.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},ee="relationship-event-store",W=p.O_NOFOLLOW;function w(i){return z(i,ee,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function f(i,e="relationships/events.jsonl"){let t=h.resolve(i),n=h.resolve(t,e),r=h.relative(t,n);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${h.sep}`)||h.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await I(t,{recursive:!0}),(await A(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let o=t;for(let s of r.split(h.sep)){o=h.join(o,s);try{if((await A(o)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(c){if(_(c))break;throw c}}return n}async function y(i,e,t){let n=new T(e,{registry:t}),r,o;try{o=await P(i,p.O_RDONLY|W),r=await o.readFile("utf8")}catch(c){if(_(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=r.split(`
|
|
2
2
|
`);for(let c=0;c<s.length;c+=1){let a=s[c].trim();if(!a)continue;let d;try{d=JSON.parse(a)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${c+1}`)}if(d.sequence!==n.version+1)throw new TypeError(`Invalid relationship event sequence at line ${c+1}`);n.append({eventId:d.eventId,relationshipId:d.relationshipId,action:d.action,...d.edge===void 0?{}:{edge:d.edge},author:d.author,timestamp:d.timestamp,...d.reason===void 0?{}:{reason:d.reason},expectedVersion:n.version})}return{log:n,raw:r}}function te(i,e,t,n){let r=Date.parse(e.timestamp),o;return e.action!=="remove"&&e.edge!==void 0&&(o=new g(t,[e.edge],n).edges()[0]),i.eventId===e.eventId.trim()&&i.relationshipId===e.relationshipId.trim()&&i.action===e.action&&i.author===e.author.trim()&&Number.isFinite(r)&&i.timestamp===new Date(r).toISOString()&&i.reason===(e.reason?.trim()||void 0)&&O(i.edge)===O(o)}var F=class i{#t;#i;#n;#o;#e;constructor(e,t,n,r){this.#t=e.pmRoot,this.#i=t,this.#n=e.registry,this.#o=n,this.#e=r}static async open(e){let t=Object.freeze([...e.nodes]),n=await f(e.pmRoot,e.relativePath),r=await w(e.pmRoot);try{await f(e.pmRoot,n);let{log:o}=await y(n,t,e.registry);return new i(e,t,n,o)}finally{await r()}}get path(){return this.#o}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(e){let t=await w(this.#t);try{let n=await f(this.#t,this.#o),{log:r}=await y(n,this.#i,this.#n),o=r.append(e);await I(h.dirname(n),{recursive:!0}),await f(this.#t,n);let s=await P(n,p.O_APPEND|p.O_CREAT|p.O_WRONLY|W);try{await s.appendFile(`${JSON.stringify(o)}
|
|
3
3
|
`,"utf8")}finally{await s.close()}return this.#e=r,o}finally{await t()}}async appendBatch(e,t={}){let n=await w(this.#t);try{let r=await f(this.#t,this.#o),{log:o,raw:s}=await y(r,this.#i,this.#n),c=o.version,a=new Map(o.events().map(l=>[l.eventId,l])),d=[],R=[];for(let l of e){let u=l.eventId.trim(),v=a.get(u);if(v!==void 0){if(t.existingEventPolicy==="skip_identical"&&te(v,l,this.#i,this.#n)){R.push(v.eventId);continue}if(t.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${u}`)}let b=o.append(l);a.set(b.eventId,b),d.push(b)}if(d.length>0){let l=s.length===0||s.endsWith(`
|
|
4
4
|
`)?s:`${s}
|
|
5
5
|
`;await I(h.dirname(r),{recursive:!0}),await f(this.#t,r),await L(r,`${l}${d.map(u=>JSON.stringify(u)).join(`
|
|
6
6
|
`)}
|
|
7
7
|
`)}return this.#e=o,Object.freeze({version_before:c,version_after:o.version,appended:Object.freeze(d),skipped_event_ids:Object.freeze(R)})}finally{await n()}}async snapshot(e={}){return this.#e=await this.#r(),this.#e.snapshot(e)}async page(e){return this.#e=await this.#r(),this.#e.page(e)}async*stream(e={}){this.#e=await this.#r(),yield*this.#e.stream(e)}async project(e,t,n={}){return this.#e=await this.#r(),this.#e.project(e,t,n)}async#r(){let e=await w(this.#t);try{let t=await f(this.#t,this.#o);return(await y(t,this.#i,this.#n)).log}finally{await e()}}};(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="73852fdf-f072-51ab-9449-d7922712eeb4")}catch{}})();function K(i){return[...i].sort().join("\0")}function ie(i,e,t){let n=i.successors.get(e);n?n.push(t):i.successors.set(e,[t]);let r=i.predecessors.get(t);r?r.push(e):i.predecessors.set(t,[e])}function G(i,e,t,n,r){let o=e.resolve(r);if(o?.ordering!==!0)return;let s=M(n),c=s===void 0?void 0:i.canonicalIds.get(s.toLowerCase());if(c===void 0)return;let a=(o.precedence??"source_before_target")==="source_before_target";ie(i,a?t:c,a?c:t)}function ne(i,e){let t={successors:new Map,predecessors:new Map,canonicalIds:new Map},n=i.filter(r=>typeof r?.id=="string"&&r.id.trim().length>0);for(let r of n){let o=r.id.trim();t.canonicalIds.set(o.toLowerCase(),o)}for(let r of n){let o=r.id.trim();G(t,e,o,r.blocked_by,"blocked_by");for(let s of r.dependencies??[])typeof s!="object"||s===null||G(t,e,o,s.id,typeof s.kind=="string"?s.kind:"related")}for(let r of[t.successors,t.predecessors])for(let o of r.values())o.sort();return t}function re(i,e){let t=new Set([e]),n=[e];for(;n.length>0;){let r=n.pop();for(let o of[i.successors,i.predecessors])for(let s of o.get(r)??[])t.has(s)||(t.add(s),n.push(s))}return t}function oe(i,e){let t=new Map;for(let n of e){let r=(i.successors.get(n)??[]).filter(o=>e.has(o));r.length>0&&t.set(n,r)}return t}function H(i,e,t){let n=ne(i,e),r=n.canonicalIds.get(t.trim().toLowerCase());if(r===void 0)return{cycles:[],successors:new Map,canonical:t};let o=oe(n,re(n,r));return{cycles:q(o).filter(s=>s.includes(r)),successors:o,canonical:r}}function se(i,e,t){let n=new Set(e),r=n.has(t)?t:e[0];if(i.get(r)?.includes(r))return[r,r];for(let o of i.get(r)??[]){if(!n.has(o))continue;let s=ae(i,n,r,o);if(s)return s}return[...e,e[0]]}function ae(i,e,t,n){let r=[[n]],o=new Set([t,n]);for(;r.length>0;){let s=r.shift(),c=s.at(-1);for(let a of i.get(c)??[]){if(a===t)return[t,...s,t];!e.has(a)||o.has(a)||(o.add(a),r.push([...s,a]))}}}function ve(i,e,t){let n=m(),r=H(i,n,t),o=H(e,n,t),s=new Set(r.cycles.map(K)),c=new Set(k(i,void 0,n).map(a=>`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`));return[...k(e,void 0,n).filter(a=>a.holder_id.toLowerCase()===t.trim().toLowerCase()&&!c.has(`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`)).map(a=>`ordering_storage_contradiction_created:${V(a)}:remove_contradicting_dependency_row:run_pm_graph_audit`),...o.cycles.filter(a=>!s.has(K(a))).map(a=>`ordering_cycle_created:${se(o.successors,a,o.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)]}(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="5f2ca18e-450d-5b6e-9e07-7bbf080764f9")}catch{}})();function Ee(i,e){let t=e.resolve(i);return t?.hierarchy===!0||t?.outgoing==="one"||t?.incoming==="one"}function J(i,e,t,n,r){let o=JSON.stringify([e,t,n]),s=i.get(o);s===void 0&&(s={kind:e,direction:t,node_id:n,endpoints:new Set},i.set(o,s)),s.endpoints.add(r)}function B(i,e){let t=new Map;for(let n of i)for(let r of n.dependencies??[]){let o=e.resolve(r.kind);o===void 0||o.hierarchy||(o.outgoing==="one"&&J(t,o.kind,"outgoing",n.id,r.id),o.incoming==="one"&&J(t,o.kind,"incoming",r.id,n.id))}return t}function Ie(i,e,t=m()){let n=B(i,t),r=B(e,t);for(let o of[...r.keys()].sort()){let s=r.get(o);if(s.endpoints.size<=1)continue;let c=n.get(o);if(![...s.endpoints].every(a=>c?.endpoints.has(a)))throw new C(`Relationship ${s.kind} permits only one ${s.direction} endpoint for ${s.node_id}.`,S.USAGE,{code:"dependency_cardinality_created",field:"dependencies",value:s.kind,relationship_cardinality:{kind:s.kind,direction:s.direction,node_id:s.node_id,endpoint_ids:[...s.endpoints].sort()},required:"The final dependency set must satisfy the active relationship kind's one-edge cardinality.",nextSteps:["Drop extra --dep seeds, or remove conflicting rows with update --dep-remove before adding another edge.","Choose another kind only when its declared semantics match the intended relationship."]})}}export{T as a,F as b,ve as c,Ee as d,Ie as e};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-Q45LDP7P.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as T,f as L}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as T,f as L}from"./chunk-IS5FLEZW.js";import{Y as f,Z as D,i as y,j as v,ma as R}from"./chunk-J7PWHKZK.js";import{Ab as x,j as I,vb as E}from"./chunk-JU62TKJP.js";import{a as k,b as C}from"./chunk-C3O6JJPO.js";import{Da as l,U as m,qc as _,ra as g,xa as h}from"./chunk-2SQUWQP3.js";import{A as s,C as w,z as a}from"./chunk-G6ERMFJ5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="59842825-3a81-53f4-845d-db2257ec6286")}catch{}})();async function X(e){let o=h(process.cwd(),e);await x(o);let i=await E(o),r=g(i,_());return{pmRoot:o,settings:i,typeRegistry:r}}async function j(e,o,i,r){l(e,y(o));let t=await f(e,o,i.id_prefix,i.item_format,r);if(t)return{id:t.id,historyPath:l(e,t.id),located:t};let n=v(o,i.id_prefix),d=y(o),c=n===d?[n]:[n,d];for(let p of c){let b=l(e,p);if(await w(b))return{id:p,historyPath:b,located:null}}throw new s(`Item ${o} not found`,a.NOT_FOUND)}import{readdir as P}from"node:fs/promises";import u from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="e9b7731d-e6f5-51a8-970b-462c0b728a9c")}catch{}})();function B(e,o){let i=new Map;for(let r of e){let t=r.external?r.id:o.get(r.id.toLowerCase())?.id??r.id;i.set(r.external?`external:${t}`:`local:${t.toLowerCase()}`,{...r,id:t})}return[...i.values()]}async function $(e,o){let i=u.basename(e),r=(await P(u.dirname(e)).catch(t=>{throw R("Cannot verify the blocker's physical file identity",{exitCode:a.GENERIC_FAILURE,context:{code:"blocker_identity_read_failed",required:"Restore access to the blocker item directory, then retry the item read."},cause:t})})).filter(t=>t.toLowerCase()===i.toLowerCase()).sort((t,n)=>+(n===i)-+(t===i)||t.localeCompare(n)).map(t=>u.parse(t).name)[0];if(r===void 0)throw new s(`Blocker canonical file disappeared during identity verification: ${o}`,a.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker file and validate storage integrity before retrying the item read."});return r}async function te(e){let o=T(e.metadata);if(o.length===0)return[];let i=new Map([e.metadata.blocked_by,...(e.metadata.dependencies??[]).filter(t=>m(t.kind)==="blocked_by").map(t=>t.id)].filter(t=>typeof t=="string").map(t=>[t.trim().toLowerCase(),t.trim()])),r=new Map;for(let t of o){if(k(t)||!/^(?!\.{1,2}$)[^/\\:\0]+$/u.test(t)||e.metadata.dependencies?.some(c=>c.id.trim()===t&&m(c.kind)==="blocked_by"&&C(c.source_kind)))continue;let n=await f(e.pmRoot,i.get(t),e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(n===null)continue;let d=await D(n,{schema:e.settings.schema});if(n.id=await $(n.itemPath,n.id),d.document.metadata.id!==n.id)throw new s(`Blocker identity differs from its canonical file: ${n.id}`,a.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker identity and validate storage integrity before retrying the item read."});r.set(t.toLowerCase(),d.document.metadata)}return B(L({blocked_by:e.metadata.blocked_by,dependencies:e.metadata.dependencies,updated_at:e.metadata.updated_at},r,I(e.settings.schema)),r)}export{X as a,j as b,$ as c,te as d};
|
|
2
|
+
//# sourceMappingURL=chunk-QWUWNFQO.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Y as Ie,Z as Te,aa as De,j as Ce,ma as Se}from"./chunk-ULTSMJYF.js";import{Ab as Re,L as G,j as pe,vb as xe}from"./chunk-P6TG33FV.js";import{a as A,b as R}from"./chunk-C3O6JJPO.js";import{Ce as Ee,Dc as Y,Ed as _e,Fd as ke,Ga as ue,Jc as F,Jd as ve,S as C,Wc as O,X as ce,id as me,nd as ge,qc as K,ra as ae,rc as fe,sd as he,xa as le,xd as ye,xe as be,ye as we}from"./chunk-Z2QWZRSL.js";import{A as v,z as b}from"./chunk-G6ERMFJ5.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]="283dfa35-9a8e-524c-b6e2-d433d51215ca")}catch{}})();function w(){let e=C();for(let t of K()?.relationship_kinds??[])for(let o of t.definitions)e.register(o);return 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]="8b57e560-4ac4-53b6-9fb1-eebb1f30562a")}catch{}})();function N(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return t.length>0?t:void 0}function z(e){return[e.parent_id,e.child_id,e.source,e.kind,e.holder_id,e.target_id??""].join("\0")}function Qe(e,t){let o=new Set,n=[];for(let r of[...e].sort()){if(o.has(r))continue;o.add(r);let i=[{nodeId:r,children:[...t.get(r)??[]].sort(),nextChild:0}];for(;i.length>0;){let s=i.at(-1),d=s.children[s.nextChild];d===void 0?(n.push(s.nodeId),i.pop()):(s.nextChild+=1,o.has(d)||(o.add(d),i.push({nodeId:d,children:[...t.get(d)??[]].sort(),nextChild:0})))}}return n}function Ze(e,t){let o=[...e].sort(),n=Qe(o,t),r=new Set,i=et(o,t),s=[];for(let d of n.reverse()){if(r.has(d))continue;let c=tt(d,i,r);(c.length>1||t.get(c[0])?.has(c[0]))&&s.push(c)}return s.sort((d,c)=>d.join("\0").localeCompare(c.join("\0")))}function et(e,t){let o=new Map(e.map(n=>[n,new Set]));for(let[n,r]of t)for(let i of r)o.get(i)?.add(n);return o}function tt(e,t,o){let n=[],r=[e];for(o.add(e);r.length>0;){let i=r.pop();n.push(i);for(let s of[...t.get(i)].sort())o.has(s)||(o.add(s),r.push(s))}return n.sort()}function Le(e){let t=new Map;for(let o of e){let n=N(o?.id);n&&!t.has(n)&&t.set(n,o)}return t}function nt(e,t,o){let n=N(t.parent);if(!(!n||!o.has(n)))return{parent_id:n,child_id:e,source:"scalar_parent",kind:"parent",holder_id:e,child_cardinality:"one"}}function ot(e,t,o,n){let r=N(t?.id),i=n.resolve(t?.kind);if(!r||!o.has(r)||!i?.hierarchy)return;let s=i.hierarchyDirection==="source_parent";return{parent_id:s?e:r,child_id:s?r:e,source:"dependency",kind:i.kind,holder_id:e,target_id:r,child_cardinality:s?i.incoming:i.outgoing}}function Oe(e,t){let o=new Map;for(let[n,r]of e){let i=nt(n,r,e);i&&o.set(z(i),i);for(let s of r.dependencies??[]){let d=ot(n,s,e,t);d&&o.set(z(d),d)}}return[...o.values()].sort((n,r)=>z(n).localeCompare(z(r)))}function ln(e,t=w()){return Oe(Le(e),t)}function rt(e,t,o){let n=new Set(e.filter(r=>r.child_cardinality==="one").map(r=>r.child_id));return[...t].filter(([r,i])=>i.length>1&&n.has(r)).map(([r,i])=>({child_id:r,parent_ids:[...i],legacy_terminal:o.has(r)&&i.every(s=>o.has(s))})).sort((r,i)=>r.child_id.localeCompare(i.child_id))}function it(e,t,o){let n=new Map;for(let i of t){if(i.source!=="dependency")continue;let s=n.get(i.child_id)??new Set;s.add(i.parent_id),n.set(i.child_id,s)}let r=[];for(let[i,s]of e){let d=N(s.parent);if(!d||!e.has(d))continue;let c=[...n.get(i)??[]].filter(l=>l!==d).sort();c.length!==0&&r.push({child_id:i,scalar_parent_id:d,dependency_parent_ids:c,legacy_terminal:o.has(i)&&o.has(d)&&c.every(l=>o.has(l))})}return r.sort((i,s)=>i.child_id.localeCompare(s.child_id))}function H(e,t=n=>n==="closed"||n==="canceled",o=w()){let n=Le(e),r=Oe(n,o),i=st(r),s=new Set([...n].filter(([,c])=>t(c.status)).map(([c])=>c)),d=Ze([...n.keys()],new Map([...i.children_by_parent].map(([c,l])=>[c,new Set(l)]))).map(c=>({item_ids:c,legacy_terminal:c.every(l=>s.has(l))}));return{relations:r,cycles:d,cardinality_violations:rt(r,i.parents_by_child,s),divergences:it(n,r,s)}}function un(e){return e.source==="scalar_parent"?`${e.parent_id} -> ${e.child_id} (scalar parent on ${e.holder_id})`:`${e.parent_id} -> ${e.child_id} (${e.kind} dependency on ${e.holder_id})`}function st(e){let t=new Map,o=new Map;for(let n of e){let r=t.get(n.child_id)??new Set;r.add(n.parent_id),t.set(n.child_id,r);let i=o.get(n.parent_id)??new Set;i.add(n.child_id),o.set(n.parent_id,i)}return{parents_by_child:new Map([...t].map(([n,r])=>[n,[...r].sort()])),children_by_parent:new Map([...o].map(([n,r])=>[n,[...r].sort()]))}}function J(e,t){let o=new Set(t);return e.every(n=>o.has(n))}function pn(e,t,o,n,r){let i=N(o);if(!i)return;let s=H(e,n,r),d=H(t,n,r),c=d.divergences.find(a=>!s.divergences.some(p=>p.child_id===a.child_id&&p.scalar_parent_id===a.scalar_parent_id&&J(a.dependency_parent_ids,p.dependency_parent_ids)));if(c){let a=[c.scalar_parent_id,...c.dependency_parent_ids].sort();throw new v(`Hierarchy mutation would assign ${c.child_id} to multiple parents: ${a.join(", ")}.`,b.CONFLICT,{code:"hierarchy_parent_divergence_created",source_id:i,target_id:c.child_id,verification_errors:a})}let l=d.cardinality_violations.find(a=>(a.child_id===i||a.parent_ids.includes(i))&&!s.cardinality_violations.some(p=>p.child_id===a.child_id&&J(a.parent_ids,p.parent_ids)));if(l)throw new v(`Hierarchy mutation would assign ${l.child_id} to multiple parents: ${l.parent_ids.join(", ")}.`,b.CONFLICT,{code:"hierarchy_cardinality_created",source_id:i,target_id:l.child_id,verification_errors:l.parent_ids});let u=d.cycles.find(a=>a.item_ids.includes(i)&&!s.cycles.some(p=>J(a.item_ids,p.item_ids)));if(u)throw new v(`Hierarchy mutation would create a cycle: ${u.item_ids.join(" -> ")}.`,b.CONFLICT,{code:"hierarchy_cycle_created",source_id:i,verification_errors:u.item_ids})}(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]="6c580b70-76eb-51db-8587-99b73dd20875")}catch{}})();var dt="global";function yn(e){let t=e?.trim();if(t)return R(t)?dt:t}function _n(e,t,o){return ct(e,t,o)}function ct(e,t,o){let n=e.trim();return R(o)||A(n)?n:Ce(n,t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="41f814be-ee87-5cae-b674-69c2e7f42655")}catch{}})();function D(e){if(typeof e!="string")return;let t=e.trim();if(!(!t||["none","null","n/a","na"].includes(t.toLowerCase())))return t}function M(e){let t=D(e);return t?.toLowerCase()==="no-active-blocker"?void 0:t}function $(e,t,o=!0){let n=D(e);return o&&(R(t)||n!==void 0&&A(n))}function Q(e,t){return $(e,t)?`external\0${e}`:`local\0${e.toLowerCase()}`}function Ae(e,t,o,n){return $(e,t)?n.get(e):o.get(e.toLowerCase())}function T(e,t){let o=e.toLowerCase(),n=t.toLowerCase();return o!==n?o<n?-1:1:e!==t?e<t?-1:1:0}function at(e){let t=new Map;for(let o of e.dependencies??[]){if(typeof o!="object"||o===null)continue;let n=o,r=D(n.id);if(!r)continue;let i=typeof n.kind=="string"?n.kind:"related",s=`${i}\0${Q(r,n.source_kind)}`,d=t.get(s);d?d.count+=1:t.set(s,{target_id:r,kind:i,count:1})}return t}function lt(e,t=o=>o==="closed"||o==="canceled"){let o=[];for(let n of e)if(!(typeof n?.id!="string"||n.id.trim().length===0))for(let r of at(n).values())r.count<2||o.push({holder_id:n.id.trim(),target_id:r.target_id,kind:r.kind,occurrences:r.count,holder_status:n.status,legacy_terminal:t(n.status)});return o.sort((n,r)=>{let i=T(n.holder_id,r.holder_id);if(i!==0)return i;let s=T(n.target_id,r.target_id);return s!==0?s:T(n.kind,r.kind)})}function ut(e,t,o,n,r){if(typeof o!="object"||o===null)return;let i=D(o.id);if(!i||Q(i,o.source_kind)!==Q(t))return;let s=r.resolve(typeof o.kind=="string"?o.kind:"related");if(!(s?.ordering!==!0||(s.precedence??"source_before_target")!=="source_before_target"))return{holder_id:e.id.trim(),target_id:i,dependency_kind:s.kind,holder_status:e.status,legacy_terminal:n(e.status)}}function pt(e,t=n=>n==="closed"||n==="canceled",o=w()){let n=new Map;for(let r of e){if(typeof r?.id!="string"||r.id.trim().length===0)continue;let i=D(r.blocked_by);if(i)for(let s of r.dependencies??[]){let d=ut(r,i,s,t,o);d&&n.set(`${d.holder_id.toLowerCase()}\0${d.target_id.toLowerCase()}\0${d.dependency_kind}`,d)}}return[...n.values()].sort((r,i)=>{let s=T(r.holder_id,i.holder_id);if(s!==0)return s;let d=T(r.target_id,i.target_id);return d!==0?d:T(r.dependency_kind,i.dependency_kind)})}function Z(e,t=o=>o==="closed"||o==="canceled"){let o=e.filter(c=>typeof c?.id=="string"&&c.id.trim().length>0),n=new Set(o.map(c=>c.id.trim().toLowerCase())),r=new Map,i=(c,l,u,a,p)=>{let m=D(l);if(!m||n.has(m.toLowerCase())||$(m,void 0,p))return;let f={holder_id:c.id.trim(),target_id:m,kind:u,source:a,holder_status:c.status,legacy_terminal:t(c.status),no_active_blocker_sentinel:m.toLowerCase()==="no-active-blocker"};r.set(`${f.holder_id}::${f.target_id}::${f.kind}::${f.source}`,f)};for(let c of o){i(c,c.parent,"parent","parent",!1),i(c,c.blocked_by,"blocked_by","blocked_by",!0);for(let l of c.dependencies??[]){if(typeof l!="object"||l===null)continue;let u=l;R(u.source_kind)||i(c,u.id,typeof u.kind=="string"?u.kind:"related","dependency",!0)}}let s=[...r.values()].sort((c,l)=>c.holder_id.localeCompare(l.holder_id)||c.target_id.localeCompare(l.target_id)||c.kind.localeCompare(l.kind)||c.source.localeCompare(l.source)),d=s.filter(c=>c.legacy_terminal);return{active:s.filter(c=>!c.legacy_terminal),legacy_terminal:d,no_active_blocker_sentinels:s.filter(c=>c.no_active_blocker_sentinel)}}function ft(e){let t=new Map;for(let o of[...e.active,...e.legacy_terminal]){if(o.no_active_blocker_sentinel)continue;let n=o.target_id.trim(),r=n.toLowerCase();t.has(r)||t.set(r,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function mt(e){let t=new Map;for(let o of e){let n=M(o.blocked_by);n&&$(n)&&!t.has(n)&&t.set(n,n);for(let r of o.dependencies??[]){if(typeof r!="object"||r===null||!$(r.id,r.source_kind))continue;let i=M(r.id);i&&!t.has(i)&&t.set(i,i)}}return[...t.values()].sort((o,n)=>o.localeCompare(n))}var Ne=new WeakMap;function xn(e){return e.hierarchyIntegrity??Ne.get(e)}function gt(e,t=w()){let o={};for(let n of e)for(let r of n.dependencies??[]){if(typeof r!="object"||r===null)continue;let i=r.kind;if(typeof i!="string")continue;let s=i.trim().toLowerCase().replaceAll("-","_"),d=t.resolve(i);d&&s!==d.kind&&(o[s]=(o[s]??0)+1)}return Object.fromEntries(Object.entries(o).sort(([n],[r])=>n.localeCompare(r)))}function ee(e,t,o){let n=o??w(),r=e.filter(f=>typeof f?.id=="string"&&f.id.trim().length>0),i=new Map(r.map(f=>[f.id.trim().toLowerCase(),f.id.trim()])),s=Z(r,t),d=ft(s);for(let f of d)i.set(f.toLowerCase(),f);let c=mt(r),l=new Set(i.keys()),u=new Map;for(let f of c){let y=f;for(;l.has(y.toLowerCase());)y=`external:${y}`;u.set(f,y),l.add(y.toLowerCase())}let a=r.map(f=>{let y=M(f.parent),g=M(f.blocked_by),h=(f.dependencies??[]).flatMap(_=>{if(typeof _!="object"||_===null)return[];let k=_,E=M(k.id);return E?[{id:Ae(E,k.source_kind,i,u),kind:typeof k.kind=="string"?k.kind:"related"}]:[]});return{id:f.id.trim(),...y?{parent:i.get(y.toLowerCase())}:{},...g?{blocked_by:Ae(g,void 0,i,u)}:{},dependencies:h}}),p=H(r,t,n),m={graph:ce.fromItems([...a,...d.map(f=>({id:f})),...c.map(f=>({id:u.get(f)}))],n),details:[...r.map(f=>({id:f.id.trim(),title:f.title,status:f.status,...typeof f.type=="string"&&f.type.trim().length>0?{type:f.type.trim()}:{}})),...d.map(f=>({id:f,title:`[missing] ${f}`,status:"missing"})),...c.map(f=>({id:u.get(f),title:`[external] ${f}`,status:"external"}))],missingIdSet:new Set(d.map(f=>f.toLowerCase())),dangling:s,duplicateRows:lt(r,t),orderingContradictions:pt(r,t,n),legacyAliasCounts:gt(r,n),hierarchyIntegrity:p};return Ne.set(m,p),m}import{createHash as ht}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]="e31ef0fb-e803-500b-b1e5-db9edfc880c4")}catch{}})();var yt=64,_t=8;function kt(e,t){let o=(e.dependencies??[]).map(n=>{if(typeof n!="object"||n===null)return"";let r=n;return`${typeof r.kind=="string"?r.kind:"related"}:${typeof r.id=="string"?r.id:""}`}).sort().join(",");return[e.id,e.title,e.status,t(e.status)?"1":"0",typeof e.type=="string"?e.type.trim():"",e.parent??"",e.blocked_by??"",o].join("\0")}function $e(e,t=n=>n==="closed"||n==="canceled",o=C()){let n=e.filter(i=>typeof i?.id=="string"&&i.id.trim().length>0).map(i=>kt(i,t)).sort(),r=o.list().map(i=>ue(i)).sort();return ht("sha256").update(n.join("")).update("").update(r.join("")).digest("hex")}function Me(e,t,o){let n=t??o;if(!Number.isInteger(n)||n<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`);return n}var te=class{#e=new Map;#t;#n;constructor(t={}){this.#t=Me("maxResultsPerWorkspace",t.maxResultsPerWorkspace,yt),this.#n=Me("maxWorkspaces",t.maxWorkspaces,_t)}lookup(t,o,n){let r=this.#e.get(t),i=!0;(r===void 0||r.fingerprint!==o)&&(r={fingerprint:o,assembly:n(),results:new Map},i=!1,!this.#e.has(t)&&this.#e.size>=this.#n&&this.#e.delete(this.#e.keys().next().value)),this.#e.delete(t),this.#e.set(t,r);let s=r,d=this.#t;return{assembly:s.assembly,assemblyReused:i,fingerprint:o,memoize(c,l){let u=s.results.get(c);if(u!==void 0||s.results.has(c))return s.results.delete(c),s.results.set(c,u),{value:structuredClone(u),reused:!0};let a=l();return s.results.size>=d&&s.results.delete(s.results.keys().next().value),s.results.set(c,structuredClone(a)),{value:a,reused:!1}}}}clear(){this.#e.clear()}},Be=new te;function Pe(){return Be}function Sn(){Be.clear()}(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]="3b494263-6359-57e9-8f34-b0bdcdeda93f")}catch{}})();var P=1200,vt=["prerequisite","dependent","ancestor","descendant","provenance","related"],bt=new TextEncoder;function ne(e,t,o){let n=e??t;if(!Number.isInteger(n)||n<1)throw new TypeError(`Relationship context ${o} must be positive`);return n}function B(e){return Math.max(1,Math.ceil(bt.encode(JSON.stringify(e)).byteLength/4))}function W(e,t,o){let n=o.resolve(e.kind);if(n?.ordering){let r=(n.precedence??"source_before_target")==="source_before_target"?e.source:e.target;return t===r?"prerequisite":"dependent"}if(n?.hierarchy){let r=n.hierarchyDirection==="source_parent"?e.source:e.target;return t===r?"ancestor":"descendant"}return e.kind==="discovered_from"||e.kind==="incident_from"?"provenance":"related"}function wt(e,t,o,n){let r=e.filter(i=>i.source===t&&i.target===o||i.target===t&&i.source===o).map(i=>W(i,o,n));return[...new Set(r)].sort()}function Et(e){return vt.find(t=>e.includes(t))}function Ct(e,t,o,n){let r=n.direction??"both",i=n.maxDepth??3;if(!Number.isInteger(i)||i<0)throw new TypeError("Relationship context maxDepth must be non-negative");let s=new Set([t]),d=[{id:t,distance:0}],c=[],l=0,u=!1;for(let a=0;a<d.length;a+=1){n.signal?.throwIfAborted();let p=d[a];if(p.distance>=i&&u)continue;let m=e.neighborEdges(p.id,{direction:r,kinds:n.kinds,signal:n.signal});if(l+=m.meta.inspectedEdges,p.distance>=i){m.value.some(f=>!s.has(f.id))&&(u=!0);continue}for(let{id:f,edge:y}of m.value){if(s.has(f))continue;s.add(f);let g={id:f,distance:p.distance+1,via:p.id,role:W(y,f,o)};c.push(g),d.push(g)}}return{rows:c,visitedNodes:d.length,inspectedEdges:l,depthTruncated:u}}function xt(e,t,o,n){let r={prerequisite:0,dependent:0,ancestor:0,descendant:0,provenance:0,related:0},i=e.neighborEdges(t,{direction:n.direction??"both",kinds:n.kinds,signal:n.signal}).value;for(let{id:s,edge:d}of i)r[W(d,s,o)]+=1;return{directEdges:r,directTotal:i.length,rootEdges:i.map(({edge:s})=>s)}}function Rt(e,t,o,n){let r=new Set;for(let i of t){let s=i.source===o?i.target:i.source,d=W(i,s,n);(d==="prerequisite"||d==="ancestor")&&r.add(s)}return[...e].sort((i,s)=>Number(r.has(s.id))-Number(r.has(i.id))||i.distance-s.distance||i.id.localeCompare(s.id))}function It(e,t){let o=e.distance===1?wt(t.rootEdges,t.rootId,e.id,t.registry):[];return{...t.details.get(e.id)??{id:e.id},distance:e.distance,role:o.length>0?Et(o):e.role,via:e.via,reasons:o.length>0?o:[`${e.role} via ${e.via} (depth ${e.distance})`]}}function Tt(e){let t=[],o=e.initialTokens,n=0;for(let r of e.candidates){if(t.length>=e.nodeLimit)break;let i=It(r,e),s=B(i);if(o+s>e.tokenBudget)break;let d=e.rootEdges.filter(c=>c.source===r.id||c.target===r.id).reduce((c,l)=>c+B(l),0);if(o+n+s+d>e.tokenBudget){if(t.length>0)break}else n+=d;t.push(i),o+=s}if(e.candidates.length>0&&t.length===0)throw new TypeError("Relationship context tokenBudget cannot fit one node");return{nodes:t,usedTokens:o}}function Dt(e){let t=e.options.kinds?new Set(e.options.kinds.map(i=>e.registry.require(i).kind)):void 0,o=e.graph.edges().filter(i=>{if(!e.included.has(i.source)||!e.included.has(i.target))return!1;if(t===void 0||t.has(i.kind))return!0;let s=e.registry.resolve(i.kind)?.inverse;return s!==void 0&&t.has(s)}).sort((i,s)=>+(s.source===e.rootId||s.target===e.rootId)-+(i.source===e.rootId||i.target===e.rootId)),n=[],r=e.initialTokens;for(let i of o){if(n.length>=e.edgeLimit)break;let s=B(i);r+s>e.tokenBudget||(n.push(i),r+=s)}return{edges:n,usedTokens:r,candidateCount:o.length}}function Ue(e,t,o,n={}){if(!e.nodes().includes(t))throw new TypeError(`Relationship node not found: ${t}`);let r=ne(n.nodeLimit,20,"nodeLimit"),i=ne(n.edgeLimit,40,"edgeLimit"),s=ne(n.tokenBudget,P,"tokenBudget"),d=n.registry??C(),c=new Map(o.map(I=>[I.id,I])),l=c.get(t)??{id:t},{evidence:u=[],...a}=l,p=[...u],m=Ct(e,t,d,n),{rootEdges:f,...y}=xt(e,t,d,n),g=Rt(m.rows,f,t,d),h=_e("relationship-context",{rootId:t,direction:n.direction??"both",kinds:[...n.kinds??[]].sort(),maxDepth:n.maxDepth??3,ordering:"required-root-evidence-first-v1"}),_=ve(g,n.cursor,h,({id:I})=>I,"--cursor"),k=g.slice(_),E=B(a)+B(p);if(E>s)throw new TypeError("Relationship context tokenBudget cannot fit root and evidence");let U=Tt({candidates:k,details:c,rootEdges:f,rootId:t,registry:d,nodeLimit:r,tokenBudget:s,initialTokens:E}),{nodes:L}=U,Ve=new Set([t,...L.map(({id:I})=>I)]),ie=Dt({graph:e,rootId:t,included:Ve,options:n,registry:d,edgeLimit:i,tokenBudget:s,initialTokens:U.usedTokens}),{edges:X,usedTokens:Ye}=ie,j=_+L.length,q=j<g.length,se=L.at(-1),V=ie.candidateCount-X.length,de=m.depthTruncated||q||V>0,Je={rootId:t,...a.status===void 0?{}:{rootStatus:a.status},...y,discoveredNodes:g.length,returnedNodes:L.length,returnedEdges:X.length,omittedNodes:g.length-j,omittedEdges:V,evidenceCount:p.length,hasMore:q};return{root:a,summary:Je,nodes:L,edges:X,evidence:p,meta:{exact:!0,truncated:de,completeness:de?"truncated":"complete",nodeLimit:r,edgeLimit:i,tokenBudget:s,usedTokens:Ye,visitedNodes:m.visitedNodes,inspectedEdges:m.inspectedEdges,omittedNodes:g.length-j,omittedEdges:V,...q&&se?{nextCursor:ke(h,se.id,j-1)}:{}}}}(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]="196b7f2d-b09b-5432-b4ef-9cdf82e92731")}catch{}})();var St=["tree","graph","context"],Lt=["none","repeated"],Ot=["outgoing","incoming","both"],At=32,Nt=200,Mt=400,$t=16e3;function Bt(e){let t=e?.trim().toLowerCase()??"tree";if(St.includes(t))return t;throw new v(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,b.USAGE)}function S(e,t){if(e===void 0)return;let o=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(o)||o<1)throw new v(`Invalid --${t} value "${e}". Use a positive integer.`,b.USAGE);return o}function Ke(e){if(e===void 0)return;let t=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(t)||t<0)throw new v(`Invalid --max-depth value "${e}". Use a non-negative integer.`,b.USAGE);return t}function Pt(e){let t=e?.trim().toLowerCase()??"none";if(Lt.includes(t))return t;throw new v(`Invalid --collapse value "${e}". Use "none" or "repeated".`,b.USAGE)}function Ut(e){let t=e?.trim().toLowerCase()??"both";if(Ot.includes(t))return t;throw new v(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,b.USAGE)}function jt(e,t=C()){if(e===void 0)return;let o=(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0);if(o.length===0)return;let n=new Set;for(let r of o){let i=t.resolve(r);if(!i){let s=t.list().map(d=>d.kind).join(", ");throw new v(`Invalid --kind value "${r}". Registered kinds: ${s}.`,b.USAGE)}n.add(i.kind)}return[...n].sort()}function Kt(e){if(!e||e.length===0)return[];let t=e.map(({id:n,kind:r})=>({id:n.trim(),kind:r.trim().toLowerCase()})).sort((n,r)=>{let i=n.kind.localeCompare(r.kind);return i!==0?i:n.id.localeCompare(r.id)}),o=new Map;for(let n of t){let r=`${n.kind.toLowerCase()}::${n.id.toLowerCase()}`;o.has(r)||o.set(r,{id:n.id,kind:n.kind})}return[...o.values()]}function Ft(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:Kt(e.dependencies)}}function Gt(e){return O(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function zt(e,t,o,n,r,i,s,d,c){for(let l of t.dependencies){let u=Math.max(1,Math.ceil(JSON.stringify({from:e.id,to:l.id,kind:l.kind}).length/3));if(d.nodes>=d.nodeLimit){e.truncated=!0,d.reasons.add("node_limit");break}if(d.edges>=d.edgeLimit){e.truncated=!0,d.reasons.add("edge_limit");break}if(d.estimatedTokens+u>=d.tokenBudget){e.truncated=!0,d.reasons.add("token_budget");break}d.edges+=1,d.estimatedTokens+=u,e.dependencies.push(Fe(l.id,o,n,r,i,s,d,c+1,l.kind))}}function Ht(e,t,o,n,r,i,s,d){return s.estimatedTokens>=s.tokenBudget&&t?.dependencies.length?(e.truncated=!0,s.reasons.add("token_budget"),!0):!t||e.cycle?!0:n!==void 0&&d>=n?(t.dependencies.length>0&&(e.truncated=!0,s.reasons.add("max_depth")),!0):r==="repeated"&&i.has(o)?(e.collapsed=!0,!0):!1}function Fe(e,t,o,n,r,i,s,d=0,c){let l=e.trim().toLowerCase(),u=t.get(l),a={id:u?.id??e,title:u?.title,type:u?.type,status:u?.status,via:c,missing:!u,cycle:o.has(l),dependencies:[]};if(s.nodes+=1,s.estimatedTokens+=Gt(a),Ht(a,u,l,n,r,i,s,d))return a;r==="repeated"&&i.add(l);let p=new Set(o);return p.add(l),zt(a,u,t,p,n,r,i,s,d),a}function je(e,t){return!e||e.missing&&!t.missing?t:{...e,title:e.title??t.title,type:e.type??t.type,status:e.status??t.status}}function Wt(e){let t=new Map,o=new Map,n=[e];for(;n.length>0;){let d=n.pop();t.set(d.id,je(t.get(d.id),{id:d.id,title:d.title,type:d.type,status:d.status,missing:d.missing}));for(let c of d.dependencies){t.set(c.id,je(t.get(c.id),{id:c.id,title:c.title,type:c.type,status:c.status,missing:c.missing}));let l=c.via??"related",u=`${d.id}::${c.id}::${l}`;o.has(u)||o.set(u,{from:d.id,to:c.id,kind:l}),c.cycle||n.push(c)}}let r=[...t.values()].sort((d,c)=>d.id.localeCompare(c.id)),i=[...o.values()].sort((d,c)=>{let l=d.from.localeCompare(c.from);if(l!==0)return l;let u=d.to.localeCompare(c.to);return u!==0?u:d.kind.localeCompare(c.kind)}),s=r.filter(d=>d.missing).map(d=>d.id);return{root_id:e.id,nodes:r,edges:i,missing_ids:s}}function Ge(e,t,o){let n=new Set,r=new Set,i=new Set,s=new Set,d=[{id:e,depth:0}],c=0;for(;c<d.length;){let l=d[c++],u=l.id.trim().toLowerCase();n.add(u);let a=t.get(u);if(!a){i.add(u);continue}if(!(o!==void 0&&l.depth>=o)&&!s.has(u)){s.add(u);for(let p of a.dependencies)r.add(`${u}::${p.id.trim().toLowerCase()}::${p.kind}`),d.push({id:p.id,depth:l.depth+1})}}return{node_count:n.size,edge_count:r.size,edge_basis:"deduplicated_directed",missing_count:i.size}}function Xt(e,t=C()){let o=Ke(e.maxDepth),n=S(e.nodeLimit,"node-limit"),r=S(e.edgeLimit,"edge-limit"),i=S(e.tokenBudget,"token-budget"),s=jt(e.kind,t);return{direction:Ut(e.direction),...s===void 0?{}:{kinds:s},...o===void 0?{}:{maxDepth:o},...n===void 0?{}:{nodeLimit:n},...r===void 0?{}:{edgeLimit:r},...i===void 0?{}:{tokenBudget:i},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function qt(e,t,o,n){return Ue(e.graph,t,e.details.map(r=>r.id===t&&n.length>0?{...r,evidence:n}:r),o)}function oe(e,t,o,n){for(let r of o.slice(0,n)){let i=r?.trim();i&&e.push(`${t}:${i}`)}}async function Vt(e,t,o,n){let r=await Ie(e,t,o.id_prefix,o.item_format,n);if(!r)return[];let{document:i}=await Te(r,{schema:o.schema}),s=i.metadata,d=s.files??[],c=s.tests??[],l=s.docs??[],u=[["files",d.length],["tests",c.length],["docs",l.length],["comments",(s.comments??[]).length],["notes",(s.notes??[]).length],["learnings",(s.learnings??[]).length]];if(u.every(([,p])=>p===0))return[];let a=[`linked:${u.map(([p,m])=>`${p}=${m}`).join(",")}`];return oe(a,"file",d.map(p=>p.path),3),oe(a,"test",c.map(p=>p.command??p.path),2),oe(a,"doc",l.map(p=>p.path),2),a}function Yt(e){let{canonicalId:t,context:o,missingCount:n,missingReferences:r,referenceLimit:i,summaryOnly:s}=e;return{id:t,format:"context",node_count:o.nodes.length+1,edge_count:o.edges.length,edge_basis:"deduplicated_directed",missing_count:n,missing_scope:"traversal",missing_reference_count:r.length,...s?{}:{missing_references:r.slice(0,i),context:o}}}function Jt(e){let{row:t,missingReachableSet:o,packetIds:n,filteredKinds:r,registry:i}=e;if(t.no_active_blocker_sentinel||!o.has(t.target_id.trim().toLowerCase())||!n.has(t.holder_id))return!1;if(r===void 0)return!0;let s=i.resolve(t.kind);return s!==void 0&&(r.has(s.kind)||s.inverse!==void 0&&r.has(s.inverse))}function ze(e,t){let o=fe(),n=t.commandOptionsOverride??(o?.command==="deps"?o.options:t.commandOptions);return be("deps",{...n,...t.global,resolvedOutputFormat:t.format},e)}function re(e,t){let o=ze(e,t),n=r=>Ee(r,t.format,t.global.lean===!0);return n(t.global.tokenAccounting===!0?we(o,n):o)}function He(e,t,o){let n;for(;;){let r=O(new TextEncoder().encode(re(e,t)).byteLength);if(r===n)return r;o(r),n=r}}function We(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function Xe(e){let{assembly:t,canonicalId:o,contextOptions:n,rootEvidence:r,summaryOnly:i,rendering:s,missingCount:d,missingReferences:c}=e,l=n.edgeLimit??40,u=Math.min(l,c.length),a=n.tokenBudget,p;for(;;){let m=qt(t,o,{...n,...a===void 0?{}:{tokenBudget:a}},r);p??=m.meta.tokenBudget,a??=p;let f=Yt({canonicalId:o,context:m,missingCount:d,missingReferences:c,referenceLimit:u,summaryOnly:i});if(i){if(O(new TextEncoder().encode(re(x(f,!0,s.legacyAliasCounts),s)).byteLength)>p)throw new TypeError("Relationship context tokenBudget cannot fit the rendered summary");return f}if(m.meta.tokenBudget=p,m.meta.usedTokens=He(x(f,!1,s.legacyAliasCounts),s,h=>{m.meta.usedTokens=h}),m.meta.usedTokens<=p)return f;if(u>0){u-=1;continue}let y=a,g=y*p/m.meta.usedTokens;a=Math.min(y-1,Math.max(1,Math.floor(g*.9)))}}function qe(e,t){let o=e.contextOptions,n={...e.rendering.global,outputFormat:e.rendering.format},r=["--pm-path",e.pmRoot,"item","deps",e.canonicalId,"--format","context","--output-format",e.rendering.format,"--token-budget"],i=r.length;r.push(String(t));let s=new Set(["--pm-path","--format","--output-format","--token-budget"]),d={format:"context",tokenBudget:t,kind:o.kinds},c=[["--max-depth","maxDepth",o.maxDepth],["--node-limit","nodeLimit",o.nodeLimit],["--edge-limit","edgeLimit",o.edgeLimit],["--direction","direction",o.direction],["--cursor","cursor",o.cursor],["--output-include","outputInclude",n.outputInclude],["--output-limit","outputLimit",n.outputLimit],["--output-budget","outputBudget",n.outputBudget],["--output-session","outputSession",n.outputSession],["--output-cursor","outputCursor",n.outputCursor]];for(let[a,p,m]of c)m!==void 0&&(r.push(a,String(m)),s.add(a),d[p]=m);for(let a of o.kinds??[])r.push("--kind",a),s.add("--kind");let l=[["--summary","summary",e.summaryOnly],["--full","full",e.rendering.commandOptions.full],["--json","json",n.json],["--lean","lean",n.lean],["--output-row-contract","outputRowContract",n.outputRowContract],["--token-accounting","tokenAccounting",n.tokenAccounting],["--no-extensions","noExtensions",n.noExtensions],["--no-pager","noPager",n.noPager]];for(let[a,p,m]of l)m===!0&&(r.push(a),s.add(a),d[p]=!0);let u=ge.find(a=>a.command==="deps");return Reflect.set(d,me,{canonical_include_modes:[],cli_invocation_observed:!0,explicit_legacy_aliases:Object.values(u.dimensions).flatMap(a=>a.legacy_aliases.flatMap(p=>s.has(p.flag)?[p.flag]:[]))}),he("deps",d),Y(d.summary===!0,d.full===!0,"--summary"),n.outputInclude=d.outputInclude,{args:r,budgetIndex:i,summaryOnly:d.summary===!0,rendering:{...e.rendering,global:n,commandOptionsOverride:d}}}function Qt(e,t,o){let n={...t.rendering,commandOptionsOverride:{...t.rendering.commandOptionsOverride,tokenBudget:o}},r;try{r=Xe({...e,contextOptions:{...e.contextOptions,tokenBudget:o},summaryOnly:t.summaryOnly,rootEvidence:t.summaryOnly?[]:e.rootEvidence,rendering:n})}catch(s){if(!We(s))throw s;return"native_floor"}let i=ze(x(r,t.summaryOnly,n.legacyAliasCounts),n);return ye(i)?"output_constraints":"fits"}async function Zt(e,t){let o=e.contextOptions.tokenBudget??P,n=qe(e,o),r=(n.summaryOnly?1:1+Math.min(e.contextOptions.edgeLimit??40,e.missingReferences.length))*(e.assembly.details.reduce((a,p)=>a+p.id.length+p.title.length+p.status.length+(p.type?.length??0),e.assembly.graph.edges().length+e.missingReferences.length)+(n.summaryOnly?[]:e.rootEvidence).reduce((a,p)=>a+p.length,0)),{findContextBudgetRecovery:i}=await import("./context-budget-recovery-5MKOCGY5.js"),s=i({requested:o,initialBudget:P,workUnits:r,probe:a=>Qt(e,n,a)}),d=["--pm-path",e.pmRoot,"item","deps",e.canonicalId,"--format","tree","--summary"],c=F(d),l=s.feasible_tokens===null?d:[...n.args];s.feasible_tokens!==null&&(l[n.budgetIndex]=String(s.feasible_tokens));let u=F(l);return Se("Relationship context tokenBudget cannot fit the required rendered packet",{exitCode:b.USAGE,cause:t,context:{code:"invalid_argument_value",field:"tokenBudget",value:String(o),required:s.feasible_tokens===null?"Inspect the compact summary and review the output constraints.":"Retry the preserved context query with --token-budget "+s.feasible_tokens+".",why:"Budget advice is verified against the current query. A minimum is reported only after every smaller positive budget is checked.",examples:[u,c],nextSteps:[u],recovery:{recovery_mode:"compact",suggested_flags:["--token-budget"],token_budget:s,suggested_retry_args:l,suggested_retry:u,next_best_command:c,fallback_candidates:[{source:"relationship_summary",command:c,reason:"Inspect bounded counts separately from context rows."}]}}})}async function en(e){let{pmRoot:t,assembly:o,canonicalId:n,options:r,rootEvidence:i,summaryOnly:s,rendering:d}=e,c=Xt(r,o.graph.registry()),l=o.graph.closure(n,{direction:c.direction,...c.kinds===void 0?{}:{kinds:c.kinds},maxDepth:c.maxDepth??3}),u=l.value.filter(h=>o.missingIdSet.has(h.toLowerCase())),a=new Set(u.map(h=>h.toLowerCase())),p=o.graph.registry(),m=c.kinds?new Set(c.kinds.map(h=>p.require(h).kind)):void 0,f=new Set([n,...l.value]),y=[...o.dangling.active,...o.dangling.legacy_terminal].filter(h=>Jt({row:h,missingReachableSet:a,packetIds:f,filteredKinds:m,registry:p})),g={pmRoot:t,assembly:o,canonicalId:n,contextOptions:c,rootEvidence:i,summaryOnly:s,rendering:d,missingCount:u.length,missingReferences:y};try{return Xe(g)}catch(h){if(h instanceof v&&h.code==="invalid_query_cursor"){let _=qe({...g,contextOptions:{...c,cursor:void 0},rendering:{...d,global:{...d.global,outputCursor:void 0}}},c.tokenBudget??P),k=F(_.args);throw new v(h.message,h.exitCode,{...h.context,nextSteps:[...h.context.nextSteps,k],recovery:{suggested_retry:k,suggested_retry_args:_.args}})}throw We(h)?await Zt(g,h):h}}function tn(e){let t=[e],o;for(;t.length>0;){let n=t.pop();n.dependencies.length>0&&(o=n,t.push(...n.dependencies))}return o?(o.dependencies.pop(),o.truncated=!0,!0):!1}function nn(e,t,o,n,r,i,s){let d=r??At,c=S(o.nodeLimit,"node-limit")??Nt,l=S(o.edgeLimit,"edge-limit")??Mt,u=S(o.tokenBudget,"token-budget")??$t,a={nodeLimit:c,edgeLimit:l,tokenBudget:u,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},p=Fe(e,n,new Set,d,t==="graph"?"repeated":i,new Set,a),m=Ge(e,n,void 0),f;for(;;){let y=Wt(p),g=a.reasons.size===0?void 0:{reasons:[...a.reasons].sort(),limits:{max_depth:d,node_limit:c,edge_limit:l,token_budget:u},estimated_tokens:0,total_node_count:m.node_count,total_edge_count:m.edge_count,omitted_node_count:Math.max(0,m.node_count-y.nodes.length),omitted_edge_count:Math.max(0,m.edge_count-y.edges.length)},h={id:e,format:t,node_count:y.nodes.length,edge_count:y.edges.length,edge_basis:"deduplicated_directed",missing_count:y.missing_ids.length,...g?{truncation:g}:{}};if(f=t==="tree"?{...h,tree:p}:{...h,graph:y},(f.truncation===void 0?O(new TextEncoder().encode(re(x(f,!1,s.legacyAliasCounts),s)).byteLength):He(x(f,!1,s.legacyAliasCounts),s,_=>{f.truncation.estimated_tokens=_}))<=u)return f;if(!tn(p))return a.reasons.add("token_budget"),f;a.reasons.add("token_budget")}}function x(e,t,o={}){let n={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"},r=e.context?.meta.truncated?[{name:"relationship_context_bounds",restore_with:"--token-budget <n> --node-limit <n> --edge-limit <n> --max-depth <n>"}]:[];return{...e,legacy_alias_counts:o,projection:{mode:t?"summary":"full",declared_field_groups:[n,...r],included_field_groups:t?[]:[n.name]}}}async function ro(e,t,o){let n=le(process.cwd(),o.path);await Re(n);let r=Bt(t.format),i=Ke(t.maxDepth),s=Pt(t.collapse);Y(t.summary===!0,t.full===!0,"--summary");let d=t.summary===!0,c=await xe(n),l=ae(c,K()),u=await De(n,c.item_format,l.type_to_folder,void 0,c.schema),a=pe(c.schema),p=new Map(u.map(g=>[g.id.trim().toLowerCase(),Ft(g)])),m=Z(u,g=>G(g,a));for(let g of[...m.active,...m.legacy_terminal]){let h=p.get(g.holder_id.trim().toLowerCase()),_=g.kind.trim().toLowerCase();h&&!h.dependencies.some(k=>k.id.trim().toLowerCase()===g.target_id.trim().toLowerCase()&&k.kind===_)&&h.dependencies.push({id:g.target_id,kind:_})}if(!p.has(e.trim().toLowerCase()))throw new v(`Item ${e} not found`,b.NOT_FOUND);let f=o.outputFormat??(o.json===!0||o.json===void 0&&o.defaultOutputFormat==="json"?"json":"toon");if(r==="context"){let g=p.get(e.trim().toLowerCase()).id,h=d?[]:await Vt(n,g,c,l.type_to_folder),_=U=>G(U,a),k=w(),E=Pe().lookup(n,$e(u,_,k),()=>ee(u,_,k));return x(await en({pmRoot:n,assembly:E.assembly,canonicalId:g,options:t,rootEvidence:h,summaryOnly:d,rendering:{format:f,global:o,commandOptions:t,legacyAliasCounts:E.assembly.legacyAliasCounts}}),d,E.assembly.legacyAliasCounts)}let y=Object.fromEntries(Object.entries(ee(u,g=>G(g,a)).legacyAliasCounts));return d?x({id:e,format:r,...Ge(e,p,i)},!0,y):x(nn(e,r,t,p,i,s,{format:f,global:o,commandOptions:t,legacyAliasCounts:y}),!1,y)}export{yn as a,_n as b,ct as c,w as d,ln as e,H as f,un as g,st as h,pn as i,M as j,lt as k,pt as l,Z as m,ft as n,xn as o,ee as p,$e as q,te as r,Pe as s,Sn as t,P as u,Ue as v,S as w,Ke as x,Ut as y,jt as z,ro as A};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{Y as Ie,Z as Te,aa as De,j as Ce,ma as Se}from"./chunk-J7PWHKZK.js";import{Ab as Re,L as G,j as pe,vb as xe}from"./chunk-JU62TKJP.js";import{a as A,b as R}from"./chunk-C3O6JJPO.js";import{Ae as we,Dc as Y,Ga as ue,Gd as _e,Ge as Ee,Hd as ke,Jc as F,Ld as ve,S as C,Wc as O,X as ce,id as me,nd as ge,qc as K,ra as ae,rc as fe,ud as he,xa as le,zd as ye,ze as be}from"./chunk-2SQUWQP3.js";import{A as v,z as b}from"./chunk-G6ERMFJ5.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]="283dfa35-9a8e-524c-b6e2-d433d51215ca")}catch{}})();function w(){let e=C();for(let t of K()?.relationship_kinds??[])for(let o of t.definitions)e.register(o);return 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]="8b57e560-4ac4-53b6-9fb1-eebb1f30562a")}catch{}})();function N(e){if(typeof e!="string")return;let t=e.trim().toLowerCase();return t.length>0?t:void 0}function z(e){return[e.parent_id,e.child_id,e.source,e.kind,e.holder_id,e.target_id??""].join("\0")}function Qe(e,t){let o=new Set,n=[];for(let r of[...e].sort()){if(o.has(r))continue;o.add(r);let i=[{nodeId:r,children:[...t.get(r)??[]].sort(),nextChild:0}];for(;i.length>0;){let s=i.at(-1),d=s.children[s.nextChild];d===void 0?(n.push(s.nodeId),i.pop()):(s.nextChild+=1,o.has(d)||(o.add(d),i.push({nodeId:d,children:[...t.get(d)??[]].sort(),nextChild:0})))}}return n}function Ze(e,t){let o=[...e].sort(),n=Qe(o,t),r=new Set,i=et(o,t),s=[];for(let d of n.reverse()){if(r.has(d))continue;let c=tt(d,i,r);(c.length>1||t.get(c[0])?.has(c[0]))&&s.push(c)}return s.sort((d,c)=>d.join("\0").localeCompare(c.join("\0")))}function et(e,t){let o=new Map(e.map(n=>[n,new Set]));for(let[n,r]of t)for(let i of r)o.get(i)?.add(n);return o}function tt(e,t,o){let n=[],r=[e];for(o.add(e);r.length>0;){let i=r.pop();n.push(i);for(let s of[...t.get(i)].sort())o.has(s)||(o.add(s),r.push(s))}return n.sort()}function Le(e){let t=new Map;for(let o of e){let n=N(o?.id);n&&!t.has(n)&&t.set(n,o)}return t}function nt(e,t,o){let n=N(t.parent);if(!(!n||!o.has(n)))return{parent_id:n,child_id:e,source:"scalar_parent",kind:"parent",holder_id:e,child_cardinality:"one"}}function ot(e,t,o,n){let r=N(t?.id),i=n.resolve(t?.kind);if(!r||!o.has(r)||!i?.hierarchy)return;let s=i.hierarchyDirection==="source_parent";return{parent_id:s?e:r,child_id:s?r:e,source:"dependency",kind:i.kind,holder_id:e,target_id:r,child_cardinality:s?i.incoming:i.outgoing}}function Oe(e,t){let o=new Map;for(let[n,r]of e){let i=nt(n,r,e);i&&o.set(z(i),i);for(let s of r.dependencies??[]){let d=ot(n,s,e,t);d&&o.set(z(d),d)}}return[...o.values()].sort((n,r)=>z(n).localeCompare(z(r)))}function ln(e,t=w()){return Oe(Le(e),t)}function rt(e,t,o){let n=new Set(e.filter(r=>r.child_cardinality==="one").map(r=>r.child_id));return[...t].filter(([r,i])=>i.length>1&&n.has(r)).map(([r,i])=>({child_id:r,parent_ids:[...i],legacy_terminal:o.has(r)&&i.every(s=>o.has(s))})).sort((r,i)=>r.child_id.localeCompare(i.child_id))}function it(e,t,o){let n=new Map;for(let i of t){if(i.source!=="dependency")continue;let s=n.get(i.child_id)??new Set;s.add(i.parent_id),n.set(i.child_id,s)}let r=[];for(let[i,s]of e){let d=N(s.parent);if(!d||!e.has(d))continue;let c=[...n.get(i)??[]].filter(l=>l!==d).sort();c.length!==0&&r.push({child_id:i,scalar_parent_id:d,dependency_parent_ids:c,legacy_terminal:o.has(i)&&o.has(d)&&c.every(l=>o.has(l))})}return r.sort((i,s)=>i.child_id.localeCompare(s.child_id))}function H(e,t=n=>n==="closed"||n==="canceled",o=w()){let n=Le(e),r=Oe(n,o),i=st(r),s=new Set([...n].filter(([,c])=>t(c.status)).map(([c])=>c)),d=Ze([...n.keys()],new Map([...i.children_by_parent].map(([c,l])=>[c,new Set(l)]))).map(c=>({item_ids:c,legacy_terminal:c.every(l=>s.has(l))}));return{relations:r,cycles:d,cardinality_violations:rt(r,i.parents_by_child,s),divergences:it(n,r,s)}}function un(e){return e.source==="scalar_parent"?`${e.parent_id} -> ${e.child_id} (scalar parent on ${e.holder_id})`:`${e.parent_id} -> ${e.child_id} (${e.kind} dependency on ${e.holder_id})`}function st(e){let t=new Map,o=new Map;for(let n of e){let r=t.get(n.child_id)??new Set;r.add(n.parent_id),t.set(n.child_id,r);let i=o.get(n.parent_id)??new Set;i.add(n.child_id),o.set(n.parent_id,i)}return{parents_by_child:new Map([...t].map(([n,r])=>[n,[...r].sort()])),children_by_parent:new Map([...o].map(([n,r])=>[n,[...r].sort()]))}}function J(e,t){let o=new Set(t);return e.every(n=>o.has(n))}function pn(e,t,o,n,r){let i=N(o);if(!i)return;let s=H(e,n,r),d=H(t,n,r),c=d.divergences.find(a=>!s.divergences.some(p=>p.child_id===a.child_id&&p.scalar_parent_id===a.scalar_parent_id&&J(a.dependency_parent_ids,p.dependency_parent_ids)));if(c){let a=[c.scalar_parent_id,...c.dependency_parent_ids].sort();throw new v(`Hierarchy mutation would assign ${c.child_id} to multiple parents: ${a.join(", ")}.`,b.CONFLICT,{code:"hierarchy_parent_divergence_created",source_id:i,target_id:c.child_id,verification_errors:a})}let l=d.cardinality_violations.find(a=>(a.child_id===i||a.parent_ids.includes(i))&&!s.cardinality_violations.some(p=>p.child_id===a.child_id&&J(a.parent_ids,p.parent_ids)));if(l)throw new v(`Hierarchy mutation would assign ${l.child_id} to multiple parents: ${l.parent_ids.join(", ")}.`,b.CONFLICT,{code:"hierarchy_cardinality_created",source_id:i,target_id:l.child_id,verification_errors:l.parent_ids});let u=d.cycles.find(a=>a.item_ids.includes(i)&&!s.cycles.some(p=>J(a.item_ids,p.item_ids)));if(u)throw new v(`Hierarchy mutation would create a cycle: ${u.item_ids.join(" -> ")}.`,b.CONFLICT,{code:"hierarchy_cycle_created",source_id:i,verification_errors:u.item_ids})}(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]="6c580b70-76eb-51db-8587-99b73dd20875")}catch{}})();var dt="global";function yn(e){let t=e?.trim();if(t)return R(t)?dt:t}function _n(e,t,o){return ct(e,t,o)}function ct(e,t,o){let n=e.trim();return R(o)||A(n)?n:Ce(n,t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="41f814be-ee87-5cae-b674-69c2e7f42655")}catch{}})();function D(e){if(typeof e!="string")return;let t=e.trim();if(!(!t||["none","null","n/a","na"].includes(t.toLowerCase())))return t}function M(e){let t=D(e);return t?.toLowerCase()==="no-active-blocker"?void 0:t}function $(e,t,o=!0){let n=D(e);return o&&(R(t)||n!==void 0&&A(n))}function Q(e,t){return $(e,t)?`external\0${e}`:`local\0${e.toLowerCase()}`}function Ae(e,t,o,n){return $(e,t)?n.get(e):o.get(e.toLowerCase())}function T(e,t){let o=e.toLowerCase(),n=t.toLowerCase();return o!==n?o<n?-1:1:e!==t?e<t?-1:1:0}function at(e){let t=new Map;for(let o of e.dependencies??[]){if(typeof o!="object"||o===null)continue;let n=o,r=D(n.id);if(!r)continue;let i=typeof n.kind=="string"?n.kind:"related",s=`${i}\0${Q(r,n.source_kind)}`,d=t.get(s);d?d.count+=1:t.set(s,{target_id:r,kind:i,count:1})}return t}function lt(e,t=o=>o==="closed"||o==="canceled"){let o=[];for(let n of e)if(!(typeof n?.id!="string"||n.id.trim().length===0))for(let r of at(n).values())r.count<2||o.push({holder_id:n.id.trim(),target_id:r.target_id,kind:r.kind,occurrences:r.count,holder_status:n.status,legacy_terminal:t(n.status)});return o.sort((n,r)=>{let i=T(n.holder_id,r.holder_id);if(i!==0)return i;let s=T(n.target_id,r.target_id);return s!==0?s:T(n.kind,r.kind)})}function ut(e,t,o,n,r){if(typeof o!="object"||o===null)return;let i=D(o.id);if(!i||Q(i,o.source_kind)!==Q(t))return;let s=r.resolve(typeof o.kind=="string"?o.kind:"related");if(!(s?.ordering!==!0||(s.precedence??"source_before_target")!=="source_before_target"))return{holder_id:e.id.trim(),target_id:i,dependency_kind:s.kind,holder_status:e.status,legacy_terminal:n(e.status)}}function pt(e,t=n=>n==="closed"||n==="canceled",o=w()){let n=new Map;for(let r of e){if(typeof r?.id!="string"||r.id.trim().length===0)continue;let i=D(r.blocked_by);if(i)for(let s of r.dependencies??[]){let d=ut(r,i,s,t,o);d&&n.set(`${d.holder_id.toLowerCase()}\0${d.target_id.toLowerCase()}\0${d.dependency_kind}`,d)}}return[...n.values()].sort((r,i)=>{let s=T(r.holder_id,i.holder_id);if(s!==0)return s;let d=T(r.target_id,i.target_id);return d!==0?d:T(r.dependency_kind,i.dependency_kind)})}function Z(e,t=o=>o==="closed"||o==="canceled"){let o=e.filter(c=>typeof c?.id=="string"&&c.id.trim().length>0),n=new Set(o.map(c=>c.id.trim().toLowerCase())),r=new Map,i=(c,l,u,a,p)=>{let m=D(l);if(!m||n.has(m.toLowerCase())||$(m,void 0,p))return;let f={holder_id:c.id.trim(),target_id:m,kind:u,source:a,holder_status:c.status,legacy_terminal:t(c.status),no_active_blocker_sentinel:m.toLowerCase()==="no-active-blocker"};r.set(`${f.holder_id}::${f.target_id}::${f.kind}::${f.source}`,f)};for(let c of o){i(c,c.parent,"parent","parent",!1),i(c,c.blocked_by,"blocked_by","blocked_by",!0);for(let l of c.dependencies??[]){if(typeof l!="object"||l===null)continue;let u=l;R(u.source_kind)||i(c,u.id,typeof u.kind=="string"?u.kind:"related","dependency",!0)}}let s=[...r.values()].sort((c,l)=>c.holder_id.localeCompare(l.holder_id)||c.target_id.localeCompare(l.target_id)||c.kind.localeCompare(l.kind)||c.source.localeCompare(l.source)),d=s.filter(c=>c.legacy_terminal);return{active:s.filter(c=>!c.legacy_terminal),legacy_terminal:d,no_active_blocker_sentinels:s.filter(c=>c.no_active_blocker_sentinel)}}function ft(e){let t=new Map;for(let o of[...e.active,...e.legacy_terminal]){if(o.no_active_blocker_sentinel)continue;let n=o.target_id.trim(),r=n.toLowerCase();t.has(r)||t.set(r,n)}return[...t.values()].sort((o,n)=>o.localeCompare(n))}function mt(e){let t=new Map;for(let o of e){let n=M(o.blocked_by);n&&$(n)&&!t.has(n)&&t.set(n,n);for(let r of o.dependencies??[]){if(typeof r!="object"||r===null||!$(r.id,r.source_kind))continue;let i=M(r.id);i&&!t.has(i)&&t.set(i,i)}}return[...t.values()].sort((o,n)=>o.localeCompare(n))}var Ne=new WeakMap;function xn(e){return e.hierarchyIntegrity??Ne.get(e)}function gt(e,t=w()){let o={};for(let n of e)for(let r of n.dependencies??[]){if(typeof r!="object"||r===null)continue;let i=r.kind;if(typeof i!="string")continue;let s=i.trim().toLowerCase().replaceAll("-","_"),d=t.resolve(i);d&&s!==d.kind&&(o[s]=(o[s]??0)+1)}return Object.fromEntries(Object.entries(o).sort(([n],[r])=>n.localeCompare(r)))}function ee(e,t,o){let n=o??w(),r=e.filter(f=>typeof f?.id=="string"&&f.id.trim().length>0),i=new Map(r.map(f=>[f.id.trim().toLowerCase(),f.id.trim()])),s=Z(r,t),d=ft(s);for(let f of d)i.set(f.toLowerCase(),f);let c=mt(r),l=new Set(i.keys()),u=new Map;for(let f of c){let y=f;for(;l.has(y.toLowerCase());)y=`external:${y}`;u.set(f,y),l.add(y.toLowerCase())}let a=r.map(f=>{let y=M(f.parent),g=M(f.blocked_by),h=(f.dependencies??[]).flatMap(_=>{if(typeof _!="object"||_===null)return[];let k=_,E=M(k.id);return E?[{id:Ae(E,k.source_kind,i,u),kind:typeof k.kind=="string"?k.kind:"related"}]:[]});return{id:f.id.trim(),...y?{parent:i.get(y.toLowerCase())}:{},...g?{blocked_by:Ae(g,void 0,i,u)}:{},dependencies:h}}),p=H(r,t,n),m={graph:ce.fromItems([...a,...d.map(f=>({id:f})),...c.map(f=>({id:u.get(f)}))],n),details:[...r.map(f=>({id:f.id.trim(),title:f.title,status:f.status,...typeof f.type=="string"&&f.type.trim().length>0?{type:f.type.trim()}:{}})),...d.map(f=>({id:f,title:`[missing] ${f}`,status:"missing"})),...c.map(f=>({id:u.get(f),title:`[external] ${f}`,status:"external"}))],missingIdSet:new Set(d.map(f=>f.toLowerCase())),dangling:s,duplicateRows:lt(r,t),orderingContradictions:pt(r,t,n),legacyAliasCounts:gt(r,n),hierarchyIntegrity:p};return Ne.set(m,p),m}import{createHash as ht}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]="e31ef0fb-e803-500b-b1e5-db9edfc880c4")}catch{}})();var yt=64,_t=8;function kt(e,t){let o=(e.dependencies??[]).map(n=>{if(typeof n!="object"||n===null)return"";let r=n;return`${typeof r.kind=="string"?r.kind:"related"}:${typeof r.id=="string"?r.id:""}`}).sort().join(",");return[e.id,e.title,e.status,t(e.status)?"1":"0",typeof e.type=="string"?e.type.trim():"",e.parent??"",e.blocked_by??"",o].join("\0")}function $e(e,t=n=>n==="closed"||n==="canceled",o=C()){let n=e.filter(i=>typeof i?.id=="string"&&i.id.trim().length>0).map(i=>kt(i,t)).sort(),r=o.list().map(i=>ue(i)).sort();return ht("sha256").update(n.join("")).update("").update(r.join("")).digest("hex")}function Me(e,t,o){let n=t??o;if(!Number.isInteger(n)||n<1)throw new TypeError(`Invalid ${e} bound: ${String(t)}`);return n}var te=class{#e=new Map;#t;#n;constructor(t={}){this.#t=Me("maxResultsPerWorkspace",t.maxResultsPerWorkspace,yt),this.#n=Me("maxWorkspaces",t.maxWorkspaces,_t)}lookup(t,o,n){let r=this.#e.get(t),i=!0;(r===void 0||r.fingerprint!==o)&&(r={fingerprint:o,assembly:n(),results:new Map},i=!1,!this.#e.has(t)&&this.#e.size>=this.#n&&this.#e.delete(this.#e.keys().next().value)),this.#e.delete(t),this.#e.set(t,r);let s=r,d=this.#t;return{assembly:s.assembly,assemblyReused:i,fingerprint:o,memoize(c,l){let u=s.results.get(c);if(u!==void 0||s.results.has(c))return s.results.delete(c),s.results.set(c,u),{value:structuredClone(u),reused:!0};let a=l();return s.results.size>=d&&s.results.delete(s.results.keys().next().value),s.results.set(c,structuredClone(a)),{value:a,reused:!1}}}}clear(){this.#e.clear()}},Be=new te;function Pe(){return Be}function Sn(){Be.clear()}(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]="3b494263-6359-57e9-8f34-b0bdcdeda93f")}catch{}})();var P=1200,vt=["prerequisite","dependent","ancestor","descendant","provenance","related"],bt=new TextEncoder;function ne(e,t,o){let n=e??t;if(!Number.isInteger(n)||n<1)throw new TypeError(`Relationship context ${o} must be positive`);return n}function B(e){return Math.max(1,Math.ceil(bt.encode(JSON.stringify(e)).byteLength/4))}function W(e,t,o){let n=o.resolve(e.kind);if(n?.ordering){let r=(n.precedence??"source_before_target")==="source_before_target"?e.source:e.target;return t===r?"prerequisite":"dependent"}if(n?.hierarchy){let r=n.hierarchyDirection==="source_parent"?e.source:e.target;return t===r?"ancestor":"descendant"}return e.kind==="discovered_from"||e.kind==="incident_from"?"provenance":"related"}function wt(e,t,o,n){let r=e.filter(i=>i.source===t&&i.target===o||i.target===t&&i.source===o).map(i=>W(i,o,n));return[...new Set(r)].sort()}function Et(e){return vt.find(t=>e.includes(t))}function Ct(e,t,o,n){let r=n.direction??"both",i=n.maxDepth??3;if(!Number.isInteger(i)||i<0)throw new TypeError("Relationship context maxDepth must be non-negative");let s=new Set([t]),d=[{id:t,distance:0}],c=[],l=0,u=!1;for(let a=0;a<d.length;a+=1){n.signal?.throwIfAborted();let p=d[a];if(p.distance>=i&&u)continue;let m=e.neighborEdges(p.id,{direction:r,kinds:n.kinds,signal:n.signal});if(l+=m.meta.inspectedEdges,p.distance>=i){m.value.some(f=>!s.has(f.id))&&(u=!0);continue}for(let{id:f,edge:y}of m.value){if(s.has(f))continue;s.add(f);let g={id:f,distance:p.distance+1,via:p.id,role:W(y,f,o)};c.push(g),d.push(g)}}return{rows:c,visitedNodes:d.length,inspectedEdges:l,depthTruncated:u}}function xt(e,t,o,n){let r={prerequisite:0,dependent:0,ancestor:0,descendant:0,provenance:0,related:0},i=e.neighborEdges(t,{direction:n.direction??"both",kinds:n.kinds,signal:n.signal}).value;for(let{id:s,edge:d}of i)r[W(d,s,o)]+=1;return{directEdges:r,directTotal:i.length,rootEdges:i.map(({edge:s})=>s)}}function Rt(e,t,o,n){let r=new Set;for(let i of t){let s=i.source===o?i.target:i.source,d=W(i,s,n);(d==="prerequisite"||d==="ancestor")&&r.add(s)}return[...e].sort((i,s)=>Number(r.has(s.id))-Number(r.has(i.id))||i.distance-s.distance||i.id.localeCompare(s.id))}function It(e,t){let o=e.distance===1?wt(t.rootEdges,t.rootId,e.id,t.registry):[];return{...t.details.get(e.id)??{id:e.id},distance:e.distance,role:o.length>0?Et(o):e.role,via:e.via,reasons:o.length>0?o:[`${e.role} via ${e.via} (depth ${e.distance})`]}}function Tt(e){let t=[],o=e.initialTokens,n=0;for(let r of e.candidates){if(t.length>=e.nodeLimit)break;let i=It(r,e),s=B(i);if(o+s>e.tokenBudget)break;let d=e.rootEdges.filter(c=>c.source===r.id||c.target===r.id).reduce((c,l)=>c+B(l),0);if(o+n+s+d>e.tokenBudget){if(t.length>0)break}else n+=d;t.push(i),o+=s}if(e.candidates.length>0&&t.length===0)throw new TypeError("Relationship context tokenBudget cannot fit one node");return{nodes:t,usedTokens:o}}function Dt(e){let t=e.options.kinds?new Set(e.options.kinds.map(i=>e.registry.require(i).kind)):void 0,o=e.graph.edges().filter(i=>{if(!e.included.has(i.source)||!e.included.has(i.target))return!1;if(t===void 0||t.has(i.kind))return!0;let s=e.registry.resolve(i.kind)?.inverse;return s!==void 0&&t.has(s)}).sort((i,s)=>+(s.source===e.rootId||s.target===e.rootId)-+(i.source===e.rootId||i.target===e.rootId)),n=[],r=e.initialTokens;for(let i of o){if(n.length>=e.edgeLimit)break;let s=B(i);r+s>e.tokenBudget||(n.push(i),r+=s)}return{edges:n,usedTokens:r,candidateCount:o.length}}function Ue(e,t,o,n={}){if(!e.nodes().includes(t))throw new TypeError(`Relationship node not found: ${t}`);let r=ne(n.nodeLimit,20,"nodeLimit"),i=ne(n.edgeLimit,40,"edgeLimit"),s=ne(n.tokenBudget,P,"tokenBudget"),d=n.registry??C(),c=new Map(o.map(I=>[I.id,I])),l=c.get(t)??{id:t},{evidence:u=[],...a}=l,p=[...u],m=Ct(e,t,d,n),{rootEdges:f,...y}=xt(e,t,d,n),g=Rt(m.rows,f,t,d),h=_e("relationship-context",{rootId:t,direction:n.direction??"both",kinds:[...n.kinds??[]].sort(),maxDepth:n.maxDepth??3,ordering:"required-root-evidence-first-v1"}),_=ve(g,n.cursor,h,({id:I})=>I,"--cursor"),k=g.slice(_),E=B(a)+B(p);if(E>s)throw new TypeError("Relationship context tokenBudget cannot fit root and evidence");let U=Tt({candidates:k,details:c,rootEdges:f,rootId:t,registry:d,nodeLimit:r,tokenBudget:s,initialTokens:E}),{nodes:L}=U,Ve=new Set([t,...L.map(({id:I})=>I)]),ie=Dt({graph:e,rootId:t,included:Ve,options:n,registry:d,edgeLimit:i,tokenBudget:s,initialTokens:U.usedTokens}),{edges:X,usedTokens:Ye}=ie,j=_+L.length,q=j<g.length,se=L.at(-1),V=ie.candidateCount-X.length,de=m.depthTruncated||q||V>0,Je={rootId:t,...a.status===void 0?{}:{rootStatus:a.status},...y,discoveredNodes:g.length,returnedNodes:L.length,returnedEdges:X.length,omittedNodes:g.length-j,omittedEdges:V,evidenceCount:p.length,hasMore:q};return{root:a,summary:Je,nodes:L,edges:X,evidence:p,meta:{exact:!0,truncated:de,completeness:de?"truncated":"complete",nodeLimit:r,edgeLimit:i,tokenBudget:s,usedTokens:Ye,visitedNodes:m.visitedNodes,inspectedEdges:m.inspectedEdges,omittedNodes:g.length-j,omittedEdges:V,...q&&se?{nextCursor:ke(h,se.id,j-1)}:{}}}}(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]="196b7f2d-b09b-5432-b4ef-9cdf82e92731")}catch{}})();var St=["tree","graph","context"],Lt=["none","repeated"],Ot=["outgoing","incoming","both"],At=32,Nt=200,Mt=400,$t=16e3;function Bt(e){let t=e?.trim().toLowerCase()??"tree";if(St.includes(t))return t;throw new v(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,b.USAGE)}function S(e,t){if(e===void 0)return;let o=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(o)||o<1)throw new v(`Invalid --${t} value "${e}". Use a positive integer.`,b.USAGE);return o}function Ke(e){if(e===void 0)return;let t=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(t)||t<0)throw new v(`Invalid --max-depth value "${e}". Use a non-negative integer.`,b.USAGE);return t}function Pt(e){let t=e?.trim().toLowerCase()??"none";if(Lt.includes(t))return t;throw new v(`Invalid --collapse value "${e}". Use "none" or "repeated".`,b.USAGE)}function Ut(e){let t=e?.trim().toLowerCase()??"both";if(Ot.includes(t))return t;throw new v(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,b.USAGE)}function jt(e,t=C()){if(e===void 0)return;let o=(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0);if(o.length===0)return;let n=new Set;for(let r of o){let i=t.resolve(r);if(!i){let s=t.list().map(d=>d.kind).join(", ");throw new v(`Invalid --kind value "${r}". Registered kinds: ${s}.`,b.USAGE)}n.add(i.kind)}return[...n].sort()}function Kt(e){if(!e||e.length===0)return[];let t=e.map(({id:n,kind:r})=>({id:n.trim(),kind:r.trim().toLowerCase()})).sort((n,r)=>{let i=n.kind.localeCompare(r.kind);return i!==0?i:n.id.localeCompare(r.id)}),o=new Map;for(let n of t){let r=`${n.kind.toLowerCase()}::${n.id.toLowerCase()}`;o.has(r)||o.set(r,{id:n.id,kind:n.kind})}return[...o.values()]}function Ft(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:Kt(e.dependencies)}}function Gt(e){return O(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function zt(e,t,o,n,r,i,s,d,c){for(let l of t.dependencies){let u=Math.max(1,Math.ceil(JSON.stringify({from:e.id,to:l.id,kind:l.kind}).length/3));if(d.nodes>=d.nodeLimit){e.truncated=!0,d.reasons.add("node_limit");break}if(d.edges>=d.edgeLimit){e.truncated=!0,d.reasons.add("edge_limit");break}if(d.estimatedTokens+u>=d.tokenBudget){e.truncated=!0,d.reasons.add("token_budget");break}d.edges+=1,d.estimatedTokens+=u,e.dependencies.push(Fe(l.id,o,n,r,i,s,d,c+1,l.kind))}}function Ht(e,t,o,n,r,i,s,d){return s.estimatedTokens>=s.tokenBudget&&t?.dependencies.length?(e.truncated=!0,s.reasons.add("token_budget"),!0):!t||e.cycle?!0:n!==void 0&&d>=n?(t.dependencies.length>0&&(e.truncated=!0,s.reasons.add("max_depth")),!0):r==="repeated"&&i.has(o)?(e.collapsed=!0,!0):!1}function Fe(e,t,o,n,r,i,s,d=0,c){let l=e.trim().toLowerCase(),u=t.get(l),a={id:u?.id??e,title:u?.title,type:u?.type,status:u?.status,via:c,missing:!u,cycle:o.has(l),dependencies:[]};if(s.nodes+=1,s.estimatedTokens+=Gt(a),Ht(a,u,l,n,r,i,s,d))return a;r==="repeated"&&i.add(l);let p=new Set(o);return p.add(l),zt(a,u,t,p,n,r,i,s,d),a}function je(e,t){return!e||e.missing&&!t.missing?t:{...e,title:e.title??t.title,type:e.type??t.type,status:e.status??t.status}}function Wt(e){let t=new Map,o=new Map,n=[e];for(;n.length>0;){let d=n.pop();t.set(d.id,je(t.get(d.id),{id:d.id,title:d.title,type:d.type,status:d.status,missing:d.missing}));for(let c of d.dependencies){t.set(c.id,je(t.get(c.id),{id:c.id,title:c.title,type:c.type,status:c.status,missing:c.missing}));let l=c.via??"related",u=`${d.id}::${c.id}::${l}`;o.has(u)||o.set(u,{from:d.id,to:c.id,kind:l}),c.cycle||n.push(c)}}let r=[...t.values()].sort((d,c)=>d.id.localeCompare(c.id)),i=[...o.values()].sort((d,c)=>{let l=d.from.localeCompare(c.from);if(l!==0)return l;let u=d.to.localeCompare(c.to);return u!==0?u:d.kind.localeCompare(c.kind)}),s=r.filter(d=>d.missing).map(d=>d.id);return{root_id:e.id,nodes:r,edges:i,missing_ids:s}}function Ge(e,t,o){let n=new Set,r=new Set,i=new Set,s=new Set,d=[{id:e,depth:0}],c=0;for(;c<d.length;){let l=d[c++],u=l.id.trim().toLowerCase();n.add(u);let a=t.get(u);if(!a){i.add(u);continue}if(!(o!==void 0&&l.depth>=o)&&!s.has(u)){s.add(u);for(let p of a.dependencies)r.add(`${u}::${p.id.trim().toLowerCase()}::${p.kind}`),d.push({id:p.id,depth:l.depth+1})}}return{node_count:n.size,edge_count:r.size,edge_basis:"deduplicated_directed",missing_count:i.size}}function Xt(e,t=C()){let o=Ke(e.maxDepth),n=S(e.nodeLimit,"node-limit"),r=S(e.edgeLimit,"edge-limit"),i=S(e.tokenBudget,"token-budget"),s=jt(e.kind,t);return{direction:Ut(e.direction),...s===void 0?{}:{kinds:s},...o===void 0?{}:{maxDepth:o},...n===void 0?{}:{nodeLimit:n},...r===void 0?{}:{edgeLimit:r},...i===void 0?{}:{tokenBudget:i},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function qt(e,t,o,n){return Ue(e.graph,t,e.details.map(r=>r.id===t&&n.length>0?{...r,evidence:n}:r),o)}function oe(e,t,o,n){for(let r of o.slice(0,n)){let i=r?.trim();i&&e.push(`${t}:${i}`)}}async function Vt(e,t,o,n){let r=await Ie(e,t,o.id_prefix,o.item_format,n);if(!r)return[];let{document:i}=await Te(r,{schema:o.schema}),s=i.metadata,d=s.files??[],c=s.tests??[],l=s.docs??[],u=[["files",d.length],["tests",c.length],["docs",l.length],["comments",(s.comments??[]).length],["notes",(s.notes??[]).length],["learnings",(s.learnings??[]).length]];if(u.every(([,p])=>p===0))return[];let a=[`linked:${u.map(([p,m])=>`${p}=${m}`).join(",")}`];return oe(a,"file",d.map(p=>p.path),3),oe(a,"test",c.map(p=>p.command??p.path),2),oe(a,"doc",l.map(p=>p.path),2),a}function Yt(e){let{canonicalId:t,context:o,missingCount:n,missingReferences:r,referenceLimit:i,summaryOnly:s}=e;return{id:t,format:"context",node_count:o.nodes.length+1,edge_count:o.edges.length,edge_basis:"deduplicated_directed",missing_count:n,missing_scope:"traversal",missing_reference_count:r.length,...s?{}:{missing_references:r.slice(0,i),context:o}}}function Jt(e){let{row:t,missingReachableSet:o,packetIds:n,filteredKinds:r,registry:i}=e;if(t.no_active_blocker_sentinel||!o.has(t.target_id.trim().toLowerCase())||!n.has(t.holder_id))return!1;if(r===void 0)return!0;let s=i.resolve(t.kind);return s!==void 0&&(r.has(s.kind)||s.inverse!==void 0&&r.has(s.inverse))}function ze(e,t){let o=fe(),n=t.commandOptionsOverride??(o?.command==="deps"?o.options:t.commandOptions);return be("deps",{...n,...t.global,resolvedOutputFormat:t.format},e)}function re(e,t){let o=ze(e,t),n=r=>Ee(r,t.format,t.global.lean===!0);return n(t.global.tokenAccounting===!0?we(o,n):o)}function He(e,t,o){let n;for(;;){let r=O(new TextEncoder().encode(re(e,t)).byteLength);if(r===n)return r;o(r),n=r}}function We(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function Xe(e){let{assembly:t,canonicalId:o,contextOptions:n,rootEvidence:r,summaryOnly:i,rendering:s,missingCount:d,missingReferences:c}=e,l=n.edgeLimit??40,u=Math.min(l,c.length),a=n.tokenBudget,p;for(;;){let m=qt(t,o,{...n,...a===void 0?{}:{tokenBudget:a}},r);p??=m.meta.tokenBudget,a??=p;let f=Yt({canonicalId:o,context:m,missingCount:d,missingReferences:c,referenceLimit:u,summaryOnly:i});if(i){if(O(new TextEncoder().encode(re(x(f,!0,s.legacyAliasCounts),s)).byteLength)>p)throw new TypeError("Relationship context tokenBudget cannot fit the rendered summary");return f}if(m.meta.tokenBudget=p,m.meta.usedTokens=He(x(f,!1,s.legacyAliasCounts),s,h=>{m.meta.usedTokens=h}),m.meta.usedTokens<=p)return f;if(u>0){u-=1;continue}let y=a,g=y*p/m.meta.usedTokens;a=Math.min(y-1,Math.max(1,Math.floor(g*.9)))}}function qe(e,t){let o=e.contextOptions,n={...e.rendering.global,outputFormat:e.rendering.format},r=["--pm-path",e.pmRoot,"item","deps",e.canonicalId,"--format","context","--output-format",e.rendering.format,"--token-budget"],i=r.length;r.push(String(t));let s=new Set(["--pm-path","--format","--output-format","--token-budget"]),d={format:"context",tokenBudget:t,kind:o.kinds},c=[["--max-depth","maxDepth",o.maxDepth],["--node-limit","nodeLimit",o.nodeLimit],["--edge-limit","edgeLimit",o.edgeLimit],["--direction","direction",o.direction],["--cursor","cursor",o.cursor],["--output-include","outputInclude",n.outputInclude],["--output-limit","outputLimit",n.outputLimit],["--output-budget","outputBudget",n.outputBudget],["--output-session","outputSession",n.outputSession],["--output-cursor","outputCursor",n.outputCursor]];for(let[a,p,m]of c)m!==void 0&&(r.push(a,String(m)),s.add(a),d[p]=m);for(let a of o.kinds??[])r.push("--kind",a),s.add("--kind");let l=[["--summary","summary",e.summaryOnly],["--full","full",e.rendering.commandOptions.full],["--json","json",n.json],["--lean","lean",n.lean],["--output-row-contract","outputRowContract",n.outputRowContract],["--token-accounting","tokenAccounting",n.tokenAccounting],["--no-extensions","noExtensions",n.noExtensions],["--no-pager","noPager",n.noPager]];for(let[a,p,m]of l)m===!0&&(r.push(a),s.add(a),d[p]=!0);let u=ge.find(a=>a.command==="deps");return Reflect.set(d,me,{canonical_include_modes:[],cli_invocation_observed:!0,explicit_legacy_aliases:Object.values(u.dimensions).flatMap(a=>a.legacy_aliases.flatMap(p=>s.has(p.flag)?[p.flag]:[]))}),he("deps",d),Y(d.summary===!0,d.full===!0,"--summary"),n.outputInclude=d.outputInclude,{args:r,budgetIndex:i,summaryOnly:d.summary===!0,rendering:{...e.rendering,global:n,commandOptionsOverride:d}}}function Qt(e,t,o){let n={...t.rendering,commandOptionsOverride:{...t.rendering.commandOptionsOverride,tokenBudget:o}},r;try{r=Xe({...e,contextOptions:{...e.contextOptions,tokenBudget:o},summaryOnly:t.summaryOnly,rootEvidence:t.summaryOnly?[]:e.rootEvidence,rendering:n})}catch(s){if(!We(s))throw s;return"native_floor"}let i=ze(x(r,t.summaryOnly,n.legacyAliasCounts),n);return ye(i)?"output_constraints":"fits"}async function Zt(e,t){let o=e.contextOptions.tokenBudget??P,n=qe(e,o),r=(n.summaryOnly?1:1+Math.min(e.contextOptions.edgeLimit??40,e.missingReferences.length))*(e.assembly.details.reduce((a,p)=>a+p.id.length+p.title.length+p.status.length+(p.type?.length??0),e.assembly.graph.edges().length+e.missingReferences.length)+(n.summaryOnly?[]:e.rootEvidence).reduce((a,p)=>a+p.length,0)),{findContextBudgetRecovery:i}=await import("./context-budget-recovery-5MKOCGY5.js"),s=i({requested:o,initialBudget:P,workUnits:r,probe:a=>Qt(e,n,a)}),d=["--pm-path",e.pmRoot,"item","deps",e.canonicalId,"--format","tree","--summary"],c=F(d),l=s.feasible_tokens===null?d:[...n.args];s.feasible_tokens!==null&&(l[n.budgetIndex]=String(s.feasible_tokens));let u=F(l);return Se("Relationship context tokenBudget cannot fit the required rendered packet",{exitCode:b.USAGE,cause:t,context:{code:"invalid_argument_value",field:"tokenBudget",value:String(o),required:s.feasible_tokens===null?"Inspect the compact summary and review the output constraints.":"Retry the preserved context query with --token-budget "+s.feasible_tokens+".",why:"Budget advice is verified against the current query. A minimum is reported only after every smaller positive budget is checked.",examples:[u,c],nextSteps:[u],recovery:{recovery_mode:"compact",suggested_flags:["--token-budget"],token_budget:s,suggested_retry_args:l,suggested_retry:u,next_best_command:c,fallback_candidates:[{source:"relationship_summary",command:c,reason:"Inspect bounded counts separately from context rows."}]}}})}async function en(e){let{pmRoot:t,assembly:o,canonicalId:n,options:r,rootEvidence:i,summaryOnly:s,rendering:d}=e,c=Xt(r,o.graph.registry()),l=o.graph.closure(n,{direction:c.direction,...c.kinds===void 0?{}:{kinds:c.kinds},maxDepth:c.maxDepth??3}),u=l.value.filter(h=>o.missingIdSet.has(h.toLowerCase())),a=new Set(u.map(h=>h.toLowerCase())),p=o.graph.registry(),m=c.kinds?new Set(c.kinds.map(h=>p.require(h).kind)):void 0,f=new Set([n,...l.value]),y=[...o.dangling.active,...o.dangling.legacy_terminal].filter(h=>Jt({row:h,missingReachableSet:a,packetIds:f,filteredKinds:m,registry:p})),g={pmRoot:t,assembly:o,canonicalId:n,contextOptions:c,rootEvidence:i,summaryOnly:s,rendering:d,missingCount:u.length,missingReferences:y};try{return Xe(g)}catch(h){if(h instanceof v&&h.code==="invalid_query_cursor"){let _=qe({...g,contextOptions:{...c,cursor:void 0},rendering:{...d,global:{...d.global,outputCursor:void 0}}},c.tokenBudget??P),k=F(_.args);throw new v(h.message,h.exitCode,{...h.context,nextSteps:[...h.context.nextSteps,k],recovery:{suggested_retry:k,suggested_retry_args:_.args}})}throw We(h)?await Zt(g,h):h}}function tn(e){let t=[e],o;for(;t.length>0;){let n=t.pop();n.dependencies.length>0&&(o=n,t.push(...n.dependencies))}return o?(o.dependencies.pop(),o.truncated=!0,!0):!1}function nn(e,t,o,n,r,i,s){let d=r??At,c=S(o.nodeLimit,"node-limit")??Nt,l=S(o.edgeLimit,"edge-limit")??Mt,u=S(o.tokenBudget,"token-budget")??$t,a={nodeLimit:c,edgeLimit:l,tokenBudget:u,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},p=Fe(e,n,new Set,d,t==="graph"?"repeated":i,new Set,a),m=Ge(e,n,void 0),f;for(;;){let y=Wt(p),g=a.reasons.size===0?void 0:{reasons:[...a.reasons].sort(),limits:{max_depth:d,node_limit:c,edge_limit:l,token_budget:u},estimated_tokens:0,total_node_count:m.node_count,total_edge_count:m.edge_count,omitted_node_count:Math.max(0,m.node_count-y.nodes.length),omitted_edge_count:Math.max(0,m.edge_count-y.edges.length)},h={id:e,format:t,node_count:y.nodes.length,edge_count:y.edges.length,edge_basis:"deduplicated_directed",missing_count:y.missing_ids.length,...g?{truncation:g}:{}};if(f=t==="tree"?{...h,tree:p}:{...h,graph:y},(f.truncation===void 0?O(new TextEncoder().encode(re(x(f,!1,s.legacyAliasCounts),s)).byteLength):He(x(f,!1,s.legacyAliasCounts),s,_=>{f.truncation.estimated_tokens=_}))<=u)return f;if(!tn(p))return a.reasons.add("token_budget"),f;a.reasons.add("token_budget")}}function x(e,t,o={}){let n={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"},r=e.context?.meta.truncated?[{name:"relationship_context_bounds",restore_with:"--token-budget <n> --node-limit <n> --edge-limit <n> --max-depth <n>"}]:[];return{...e,legacy_alias_counts:o,projection:{mode:t?"summary":"full",declared_field_groups:[n,...r],included_field_groups:t?[]:[n.name]}}}async function ro(e,t,o){let n=le(process.cwd(),o.path);await Re(n);let r=Bt(t.format),i=Ke(t.maxDepth),s=Pt(t.collapse);Y(t.summary===!0,t.full===!0,"--summary");let d=t.summary===!0,c=await xe(n),l=ae(c,K()),u=await De(n,c.item_format,l.type_to_folder,void 0,c.schema),a=pe(c.schema),p=new Map(u.map(g=>[g.id.trim().toLowerCase(),Ft(g)])),m=Z(u,g=>G(g,a));for(let g of[...m.active,...m.legacy_terminal]){let h=p.get(g.holder_id.trim().toLowerCase()),_=g.kind.trim().toLowerCase();h&&!h.dependencies.some(k=>k.id.trim().toLowerCase()===g.target_id.trim().toLowerCase()&&k.kind===_)&&h.dependencies.push({id:g.target_id,kind:_})}if(!p.has(e.trim().toLowerCase()))throw new v(`Item ${e} not found`,b.NOT_FOUND);let f=o.outputFormat??(o.json===!0||o.json===void 0&&o.defaultOutputFormat==="json"?"json":"toon");if(r==="context"){let g=p.get(e.trim().toLowerCase()).id,h=d?[]:await Vt(n,g,c,l.type_to_folder),_=U=>G(U,a),k=w(),E=Pe().lookup(n,$e(u,_,k),()=>ee(u,_,k));return x(await en({pmRoot:n,assembly:E.assembly,canonicalId:g,options:t,rootEvidence:h,summaryOnly:d,rendering:{format:f,global:o,commandOptions:t,legacyAliasCounts:E.assembly.legacyAliasCounts}}),d,E.assembly.legacyAliasCounts)}let y=Object.fromEntries(Object.entries(ee(u,g=>G(g,a)).legacyAliasCounts));return d?x({id:e,format:r,...Ge(e,p,i)},!0,y):x(nn(e,r,t,p,i,s,{format:f,global:o,commandOptions:t,legacyAliasCounts:y}),!1,y)}export{yn as a,_n as b,ct as c,w as d,ln as e,H as f,un as g,st as h,pn as i,M as j,lt as k,pt as l,Z as m,ft as n,xn as o,ee as p,$e as q,te as r,Pe as s,Sn as t,P as u,Ue as v,S as w,Ke as x,Ut as y,jt as z,ro as A};
|
|
2
|
+
//# sourceMappingURL=chunk-RNZUORGI.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as T}from"./chunk-
|
|
1
|
+
import{c as T}from"./chunk-CUGJ2DY2.js";import{a,d as I}from"./chunk-JU62TKJP.js";import{Z as w,j as g,k as v,l as E}from"./chunk-2SQUWQP3.js";import{A as u,C as m,m as k,z as f}from"./chunk-G6ERMFJ5.js";import C from"node:fs/promises";import p from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="74b72dd8-0877-55a4-9c80-d043f19e1f96")}catch{}})();var P=["extensions","docs","examples","assets","prompts"],U=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function R(e){return P.includes(e)}function q(e,t){if(t==null)return[];let n=Array.isArray(t)?t:[t],r=[];for(let o of n){if(typeof o!="string"||o.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,f.USAGE);r.push(o.trim())}return[...new Set(r)].sort((o,i)=>o.localeCompare(i))}function G(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",f.USAGE);let t={},n=e;for(let[r,o]of Object.entries(n)){if(!R(r))continue;let i=q(r,o);i.length>0&&(t[r]=i)}return t}function c(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n.trim():void 0}function S(e){if(!Array.isArray(e))return;let t=e.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0);return t.length>0?[...new Set(t)].sort((n,r)=>n.localeCompare(r)):void 0}function x(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function J(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={docs:c(t,"docs"),npm:c(t,"npm"),repository:c(t,"repository"),report:c(t,"report")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={image:c(t,"image"),video:c(t,"video")};return Object.values(n).some(r=>typeof r=="string")?n:void 0}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,n={display_name:c(t,"display_name")??c(t,"displayName"),category:c(t,"category"),summary:c(t,"summary"),links:J(t.links),media:K(t.media),tags:S(t.tags)};return Object.values(n).some(r=>r!==void 0)?n:void 0}async function Y(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let n;try{n=JSON.parse(await C.readFile(t,"utf8"))}catch(l){throw new u(`Failed to parse package manifest at "${t}": ${String(l)}`,f.USAGE)}if(typeof n!="object"||n===null||Array.isArray(n))throw new u(`Package manifest at "${t}" must be a JSON object.`,f.USAGE);let r=n,o=r.pm,i=o!=null,s=typeof o=="object"&&o!==null&&!Array.isArray(o)?o:{};return{source:i?"pm":"convention",package_json_path:t,package_name:typeof r.name=="string"?r.name:void 0,package_version:typeof r.version=="string"?r.version:void 0,package_private:r.private===!0,package_description:typeof r.description=="string"?r.description:void 0,package_keywords:S(r.keywords),package_homepage:typeof r.homepage=="string"?r.homepage:void 0,package_repository_url:x(r.repository),package_bugs_url:x(r.bugs),aliases:S(s.aliases),resources:G(o),catalog:V(s.catalog)}}async function j(e){if(!await m(e))return[];let t=await C.readdir(e,{withFileTypes:!0}),n=[];for(let r of t){if(!r.isDirectory())continue;let o=p.join(e,r.name);await m(p.join(o,"manifest.json"))&&n.push(o)}return n.sort((r,o)=>r.localeCompare(o))}async function he(e){if(await m(p.join(e,"manifest.json")))return[e];let t=(await Y(e)).resources.extensions??[],n=new Set;for(let r of t){if(r.includes("*")||r.startsWith("!"))throw new u(`Package extension entry "${r}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,f.USAGE);let o=p.resolve(e,r);if(!w(e,o))throw new u(`Package extension entry "${r}" resolves outside package root.`,f.USAGE);if(await m(p.join(o,"manifest.json"))){n.add(o);continue}for(let i of await j(o))n.add(i)}if(t.length===0)for(let r of U.extensions)for(let o of await j(p.join(e,r)))n.add(o);return[...n].sort((r,o)=>r.localeCompare(o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3984f1ef-1703-5a83-a4fa-ec1cdc738572")}catch{}})();var D=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function A(e){return"#".repeat(e)}function $(e){if(!e.includes("`"))return`\`${e}\``;let t=0,n=0;for(let i of e)n=i==="`"?n+1:0,t=Math.max(t,n);let r="`".repeat(t+1),o=e.startsWith("`")||e.endsWith("`")?" ":"";return`${r}${o}${e}${o}${r}`}function B(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map($).join(", ")}`}function W(e,t,n){let r=[`${A(t)} ${e}`,""];return n.length===0?(r.push("_None._",""),r):(r.push(...n.map(o=>`- ${$(o)}`),""),r)}function H(e,t,n){return e===0&&!n?[]:[`${A(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function be(e,t={}){let n=t.headingLevel??2;if(!Number.isInteger(n)||n<1||n>6)throw new RangeError(`headingLevel must be an integer in [1, 6], received ${String(t.headingLevel)}`);let r=Math.min(n+1,6),o=t.includeEmpty===!0,i=t.title??"Extension surfaces",s=[`${A(n)} ${i}`,""];(o||e.capabilities.length>0)&&s.push(B(e.capabilities),"");for(let[l,d]of D){let y=e[l]??[];y.length===0&&!o||s.push(...W(d,r,y))}return s.push(...H(e.preflight_overrides,r,o)),!(e.preflight_overrides>0||D.some(([l])=>(e[l]?.length??0)>0))&&!o&&s.push("_This extension registers no surfaces._",""),`${s.join(`
|
|
2
2
|
`).trimEnd()}
|
|
3
3
|
`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="abb182c9-6d6c-5be4-a2ad-c91b00a098d0")}catch{}})();var X=["agile","ops","research"],Q={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function Se(e){if(e===void 0)return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length===0)throw new Error("Type preset name must not be empty.");if(t==="agile"||t==="ops"||t==="research")return t;throw new Error(`Invalid type preset "${e}". Allowed: ${X.join(", ")}.`)}function Ae(e){return Q[e].map(t=>T(t))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1abceae0-299e-5fff-aa8c-46c015115571")}catch{}})();var Z=new Set(v),ee=new Set(E),F=new Set([...k.filter(e=>e!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),te=["create","update"];function z(e){if(typeof e!="string")return"";let t=e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return t.startsWith("--")?t.slice(2):t}function N(e){return e.replaceAll("_","-")}function re(e,t){let n=new Set;for(let r of e){let o=z(r);o.length>0&&o!==t&&n.add(o)}return[...n].sort((r,o)=>r.localeCompare(o))}function ne(e){let t=new Set;for(let n of e??[]){let r=n.trim();r.length>0&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function oe(e){let t=new Set,n=[];for(let r of e??[]){let o=r.trim().toLowerCase();if(o.length!==0){if(!ee.has(o))throw new Error(`Invalid field command "${r}". Allowed: ${E.join(", ")}.`);t.has(o)||(t.add(o),n.push(o))}}return e===void 0||n.length===0?[...te]:n}function je(e){let t=a(e.key);if(t.length===0)throw new Error("Field key must not be empty.");if(t.includes(","))throw new Error(`Field key "${t}" must not contain commas: commas separate field names in list flags such as --unset and --fields.`);if(F.has(t))throw new Error(`Cannot define custom field "${t}": custom schema field "${t}" collides with built-in item metadata "${t}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...F].sort((b,M)=>b.localeCompare(M)).join(", ")}.`);let n=typeof e.type=="string"&&e.type.trim().length>0?e.type.trim().toLowerCase():"string";if(!Z.has(n))throw new Error(`Invalid field type "${e.type}". Allowed: ${v.join(", ")}.`);let r=n,o=oe(e.commands),i=z(e.cliFlag),s=i.length>0&&i!==N(t)?i:void 0,l=s??N(t),d=re(e.aliases??[],l),y=[l,...d].find(b=>b.includes(","));if(y!==void 0)throw new Error(`Field flag "${y}" must not contain commas.`);let _=e.description?.trim();return{key:t,type:r,commands:o,description:_&&_.length>0?_:void 0,cliFlag:s,cliAliases:d,required:e.required===!0,requiredOnCreate:e.requiredOnCreate===!0,allowUnset:e.allowUnset!==!1,requiredTypes:ne(e.requiredTypes)}}function ie(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function se(e){let t=ie(e);if(!t)return[];let n=[];for(let r of t){if(typeof r!="object"||r===null||Array.isArray(r))continue;let o=r;typeof o.key!="string"||o.key.trim().length===0||n.push(o)}return n}function Ce(e){if(e==null||e.trim().length===0)return{fields:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:se(t)}}function De(e){return`${JSON.stringify({fields:e.fields},null,2)}
|
|
4
4
|
`}function $e(e,t){let n=e.fields.find(s=>a(s.key)===t.key),r=n!==void 0,o=e.fields.filter(s=>a(s.key)!==t.key),i={...n,key:t.key,type:t.type,commands:[...t.commands]};return O(i,"description",t.description),O(i,"cli_flag",t.cliFlag),t.cliAliases.length>0?i.cli_aliases=[...t.cliAliases]:delete i.cli_aliases,L(i,"required",t.required),L(i,"required_on_create",t.requiredOnCreate),t.allowUnset===!1?i.allow_unset=!1:delete i.allow_unset,t.requiredTypes.length>0?i.required_types=[...t.requiredTypes]:delete i.required_types,o.push(i),o.sort((s,l)=>a(s.key).localeCompare(a(l.key))),{file:{fields:o},definition:i,replaced:r}}function Fe(e,t){let n=a(t);if(n.length===0)throw new Error("Field key must not be empty.");let r=[],o=e.fields.filter(i=>a(i.key)===n?(r.push(i),!1):!0);return r.length===0?{file:{fields:o},removed:!1}:{file:{fields:o},removed:!0,definition:r[0]}}function O(e,t,n){let r=e;n!==void 0&&n.length>0?r[t]=n:delete r[t]}function L(e,t,n){let r=e;n?r[t]=!0:delete r[t]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b1e4c04e-0ade-5d24-95e3-b8dca3832c5a")}catch{}})();var ae=new Set(g),h=new Set(I.map(e=>a(e.id)).filter(e=>e.length>0));function le(e){let t=new Set;for(let n of e){let r=a(n);r.length>0&&t.add(r)}return[...t].sort((n,r)=>n.localeCompare(r))}function Pe(e){let t=a(e.id);if(t.length===0)throw new Error("Status id must not be empty.");if(h.has(t))throw new Error(`Cannot add-status the built-in status "${t}". Built-in statuses are reserved: ${[...h].join(", ")}.`);let n;if(e.roles!==void 0){n=[];let s=new Set;for(let l of e.roles){let d=typeof l=="string"?l.trim().toLowerCase():"";if(d.length!==0){if(!ae.has(d))throw new Error(`Invalid status role "${l}". Allowed roles: ${g.join(", ")}.`);s.has(d)||(s.add(d),n.push(d))}}if(n.length===0)throw new Error(`Status role must include at least one lifecycle role. Allowed roles: ${g.join(", ")}.`)}let r=e.aliases===void 0?void 0:le(e.aliases).filter(s=>s!==t),o=e.description?.trim(),i=typeof e.order=="number"&&Number.isFinite(e.order)?Math.trunc(e.order):void 0;return{id:t,roles:n,aliases:r,description:o&&o.length>0?o:void 0,order:i}}function de(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function ce(e){let t=de(e);if(!t)return[];let n=[];for(let r of t){if(typeof r!="object"||r===null||Array.isArray(r))continue;let o=r;typeof o.id!="string"||o.id.trim().length===0||n.push(o)}return n}function Ue(e){if(e==null||e.trim().length===0)return{statuses:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:ce(t)}}function Re(e){return`${JSON.stringify({statuses:e.statuses},null,2)}
|
|
5
5
|
`}function qe(e,t,n){let r=e.statuses.slice(),o=r.findIndex(l=>a(l.id)===t.id),i=o>=0?r[o]:n,s={...i,id:t.id};return t.roles!==void 0&&(t.roles.length>0?s.roles=[...t.roles]:s.roles!==void 0&&delete s.roles),t.aliases!==void 0&&(t.aliases.length>0?s.aliases=[...t.aliases]:s.aliases!==void 0&&delete s.aliases),t.description!==void 0&&(s.description=t.description),t.order!==void 0&&(s.order=t.order),o>=0?r[o]=s:r.push(s),{file:{statuses:r},definition:s,replaced:i!==void 0}}function Ge(e,t){let n=a(t);if(n.length===0)throw new Error("Status id must not be empty.");if(h.has(n))throw new Error(`Cannot remove built-in status "${n}". Built-in statuses are reserved: ${[...h].join(", ")}.`);let r=e.statuses.slice(),o=r.findIndex(s=>a(s.id)===n);if(o<0)return{file:{statuses:r},removed:!1};let[i]=r.splice(o,1);return{file:{statuses:r},removed:!0,definition:i}}function Je(e,t){let n=[e.id,...e.aliases??[]];for(let r of n){let o=a(r);if(o.length===0)continue;let i=t.get(o);if(i!==void 0&&i!==e.id)throw new Error(`Status token "${o}" already belongs to status "${i}". Choose a different id/alias to avoid shadowing it.`)}}export{P as a,U as b,Y as c,he as d,X as e,Q as f,Se as g,Ae as h,je as i,Ce as j,De as k,$e as l,Fe as m,h as n,Pe as o,Ue as p,Re as q,qe as r,Ge as s,Je as t,be as u};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-UIKLNSW3.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as Zl,j as Ql}from"./chunk-PL6EO4GJ.js";import{c as St,d as ln,e as un,f as mn,g as Kl,j as Xl}from"./chunk-KNF2QTEZ.js";import{a as Vl}from"./chunk-IDAYTYNN.js";import{J as zl,u as Q,y as so}from"./chunk-TSHRBPTI.js";import{a as qa,c as Bi,d as Ji,e as ld,g as ud,h as Ba,i as md,j as Kt,k as Yt,l as pd,m as fd,n as Ja,o as gd,p as Xt,q as Zt,r as yd,s as wd,t as Va}from"./chunk-WPXMPGTY.js";import{a as oo}from"./chunk-SVOOGGAK.js";import{B as Dd,C as Zi,D as Od,E as Ka,G as Pd,H as Ld,J as Nd,K as Md,L as Qi,U as er}from"./chunk-DIEBSC76.js";import{K as Yl}from"./chunk-4UOXVFJZ.js";import{G as lo,w as Gl,y as Jl}from"./chunk-P4EHEH4C.js";import{a as co,b as Bl}from"./chunk-O7K3X4LH.js";import{$a as ao,A as jd,B as Fd,Ba as to,C as qn,Fa as xl,Ga as Il,Ha as Rl,Ia as Al,Ja as wr,L as Ud,La as Cl,Ma as Tl,Na as $l,Oa as Mt,Pa as Dl,Q as Hd,Qa as sn,Ra as Ol,Sa as no,Ta as cn,Ua as Pl,Va as Ll,Wa as Nl,Xa as io,Ya as Ml,Za as dn,_a as ro,a as od,aa as zd,b as Vt,ba as Wd,c as Ga,ca as qd,d as sd,e as cd,f as it,fa as pr,g as Vi,h as dd,i as wt,ob as jl,pb as Fl,v as tr,vb as Ul,wa as hr,wb as Hl,xa as ml,ya as eo,z as Wn,za as Kn}from"./chunk-LTPT5TE7.js";import{d as Yn,f as vr,m as Wl,p as ql}from"./chunk-SZ2BKK3M.js";import{$ as yr,D as Qa,E as wl,M as Vn,N as _r,P as vl,Q as bl,V as gr,X as kl,Y as fe,Z as he,_ as El,aa as rt,b as Gt,ba as at,e as nr,fa as Sl,g as sl,ga as ot,n as pl,o as fl,q as hl,r as _l,s as Et,t as gl,u as yl}from"./chunk-ULTSMJYF.js";import{$a as Jn,Ab as ne,C as ir,D as Gn,E as Jd,Ea as el,F as rr,Fa as Xa,G as Vd,Ga as sr,Ha as en,I as ar,J as or,Ja as cr,Ka as tl,L as Kd,La as nl,M as $e,Na as il,Pa as rl,R as bt,S as Yd,Sa as dr,T as Xd,Ua as tn,Va as al,Xa as lr,Ya as ur,Za as Bn,_a as kt,a as se,ab as ol,bb as mr,c as Te,cb as Nt,db as te,e as Ie,eb as nn,f as Ke,fb as cl,gb as Za,hb as rn,ib as an,j as ge,jb as on,k as hd,l as Ki,mb as dl,n as _d,nb as ll,o as Gd,qb as je,r as Re,s as Ya,t as Bd,ub as ul,va as z,vb as C,wa as Zd,wb as fr,xa as Me,ya as Qd}from"./chunk-P6TG33FV.js";import{$ as Wc,$b as Ve,$d,Aa as Bt,Ca as Jc,Da as Ot,Db as nd,Dc as xd,Eb as id,Fa as Vc,Ga as A,Ha as Kc,Ia as xe,Ic as Id,Jc as ue,Ka as Gi,La as Yc,Ma as Ua,Mb as rd,Na as Ha,Nb as Pt,Nd as $,Oa as za,Od as Rd,P as Hc,Pd as Qt,Qa as Xc,Qd as vt,Ra as Zc,Rd as Lt,S as zc,U as Fa,Ua as Qc,Ud as Ad,Vb as Wa,Wb as ad,Xb as Jt,Xd as Cd,Z as pe,Zb as Je,_ as Ge,_d as Td,a as Oc,ae as re,ba as Y,cb as ed,cc as vd,d as Pc,e as Lc,ea as qc,ec as Yi,fc as bd,gc as kd,ic as Ed,lb as td,o as ja,pa as Gc,qa as Bc,qc as F,ra as H,uc as K,wa as zn,wc as Ne,xa as M,xc as Sd,ya as Be,yc as Xi,za as qi}from"./chunk-Z2QWZRSL.js";import{a as br,b as Xn}from"./chunk-EGN2HFRU.js";import{A as g,B as Hn,C as D,D as yt,E as j,F as B,I as Z,a as Hi,d as zi,p as Nc,r as Mc,t as jc,v as Fc,w as Wi,x as Uc,y as Un,z as y}from"./chunk-G6ERMFJ5.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 L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},ve=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Ye=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 pn(e){try{return await e()}catch(t){throw t instanceof L?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function uo(e){try{return await e()}catch(t){throw t instanceof ve?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Hg}from"node:crypto";import zg 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 fn=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]="eaede7d4-43ae-5551-915e-19befefc29d0")}catch{}})();var tu=1,jt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],mo=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],Wg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],qg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,kr=30,Er=5e3,nu=4,Gg=50;function st(e,t){if(!qg.test(e))throw new L(`${t} must be a stable lowercase id`)}function Bg(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function Zn(e){let t=Wg.filter(r=>e[r]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],i=e[n];return{polarity:n,value:n==="zero"?0:i}}function fo(e,t){return A(e)===A(t)}function iu(e,t){if(t.polarity==="equals")return fo(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let i=t.value;return e.every(r=>i.includes(r))}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 ru(e){let t=Zn(e),n=e.negative_control.cases;return n.some(i=>i.expected==="pass")&&n.some(i=>i.expected==="fail")&&n.every(i=>iu(i.observed,t)===(i.expected==="pass"))}function Jg(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,i=t.value;return!Array.isArray(n)||!Array.isArray(i)||i.some(r=>!n.includes(r))}return!fo(e.value,t.value)}function Vg(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||A(e.scope)!==A(t.scope))return!0;let n={observe:0,warn:1,block:2},i=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return Jg(Zn(e),Zn(t))||n[t.enforcement]<n[e.enforcement]||i}function Kg(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new L("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,i=Number(t)+Number(n);if(e.field!==void 0&&i!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&i!==0)throw new L("items source equals/state requires field")}function Yg(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new L("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(t=>t!==void 0).length>1)throw new L("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new L("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new L("dependency_kind source source_kind_state must be present or missing")}function Xg(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new L("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new L("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new L("prose_edge_gap exemption selectors must not be empty")}}function ho(e){st(e.id,"measurement.id"),e.max_cost!==void 0&&Bg(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new L(`measurement.source.kind must be one of ${mo.join(", ")}`);let n=Reflect.get(t,"kind");if(!mo.includes(n))throw new L(`measurement.source.kind must be one of ${mo.join(", ")}`);let i=t;if(i.kind==="items"&&Kg(i),i.kind==="dependency_kind"&&Yg(i),i.kind==="prose_edge_gap"&&Xg(i),(i.kind==="graph"||i.kind==="validate"||i.kind==="health")&&(typeof i.field!="string"||i.field.trim().length===0))throw new L(`${i.kind} source requires field`);return i.kind==="provider"&&(st(i.provider,"provider source provider"),st(i.key,"provider source key")),e}function _o(e){if(st(e.id,"assertion.id"),st(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new L("assertion.owner_item_id is required");let t=Zn(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new L(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new L("retired assertion requires retire_reason");e.scope.kind==="filter"&&st(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(i=>i.expected==="pass")||!n.some(i=>i.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!ru(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function Zg(e){if(!Array.isArray(e.allowed_providers))throw new L("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)st(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new L("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!jt.includes(t))throw new L(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new L(`gate provider policy trigger ${t} is invalid`)}}function au(e){if(st(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new L("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new L("gate requires at least one assertion");for(let t of e.assertion_ids)st(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${jt.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!jt.includes(t))throw new L(`gate trigger must be one of ${jt.join(", ")}`);return e.provider_policy&&Zg(e.provider_policy),e}function hn(e){if(e.version!==tu)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let i of e.measurements){if(ho(i),t.has(`measurement:${i.id}`))throw new L(`duplicate measurement ${i.id}`);t.add(`measurement:${i.id}`)}for(let i of e.assertions){if(_o(i),t.has(`assertion:${i.id}`))throw new L(`duplicate assertion ${i.id}`);t.add(`assertion:${i.id}`)}for(let i of e.gates){au(i);let r=i.assertion_ids.filter(a=>!e.assertions.some(o=>o.id===a));if(r.length>0)throw new L(`gate ${i.id} references missing assertions: ${r.join(", ")}`);if(t.has(`gate:${i.id}`))throw new L(`duplicate gate ${i.id}`);t.add(`gate:${i.id}`)}let n=new Set(e.measurements.map(i=>i.id));for(let[i,r]of ou(e))if(!n.has(i))throw new L(`${r.join(", ")} references missing measurement ${i}`);return e}function go(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)go(n,t)}function ou(e){let t=new Map,n=(i,r)=>{let a=t.get(i)??[];a.push(r),t.set(i,a)};for(let i of e.assertions)n(i.measurement_id,`assertion ${i.id}`),i.scope.kind==="filter"&&n(i.scope.measurement_id,`assertion ${i.id} scope`);for(let i of e.measurements){if(i.source.kind!=="derived")continue;let r=[];go(i.source.expression,r);for(let a of r)n(a,`derived measurement ${i.id}`)}return t}function Qg(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]:[]]}),i=new Set,r=new Set;for(;n.length>0;){let a=n.pop();if(i.has(a))continue;i.add(a);let o=t.measurements.find(s=>s.id===a);o.source.kind==="provider"?r.add(o.source.provider):o.source.kind==="derived"&&go(o.source.expression,n)}return r}function Qn(){return{version:tu,measurements:[],assertions:[],gates:[]}}function ey(e,t){let n=t.items.filter(i=>(e.statuses===void 0||e.statuses.includes(i.status))&&(e.types===void 0||e.types.includes(i.type))&&(e.tags===void 0||e.tags.every(r=>i.tags?.includes(r)))&&(e.field===void 0||(()=>{let r=i[e.field];if(e.state!==void 0){let a=r==null||r===""||Array.isArray(r)&&r.length===0;return e.state==="missing"?a:!a}return fo(r,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(i=>i.id)}}function ty(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 ny(e,t){let n=[],i=Fa(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let r of t.items)for(let a of r.dependencies??[]){let o=Fa(a.kind)??a.kind.trim().toLowerCase(),s=a.source_kind?.trim();o===i&&ty(e,s)&&n.push(`${r.id}->${a.id}${s?`@${s}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function iy(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 i=e[n];if(Array.isArray(i)){for(let r of i)if(typeof r=="string")t.push(r);else if(typeof r=="object"&&r!==null){let a=Reflect.get(r,"text");typeof a=="string"&&t.push(a)}}}return t}function ry(e,t,n,i){return e.some(r=>r.holder_id.trim().toLowerCase()===t.toLowerCase()&&(r.target_id===void 0||r.target_id.trim().toLowerCase()===n.toLowerCase())&&(r.text_contains===void 0||i.toLowerCase().includes(r.text_contains.trim().toLowerCase())))}function po(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function ay(e){let t=new Map,n=new Set,i=[],r=/(?<![\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(po(o.id,s.id));for(let s of[o.parent,o.blocked_by])typeof s=="string"&&n.add(po(o.id,s));for(let s of iy(o)){let c=[...s.matchAll(r)].map(d=>d[0]);a+=c.length,i.push({holder_id:o.id,segment:s,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:i,mention_count:a}}function oy(e,t){let n=ay(t.items),i=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=po(o.holder_id,d);if(n.linked_pairs.has(l)||ry(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);i.get(l)?.explicit===!0&&!u||i.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let r=[...i.values()],a=r.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:r.filter(o=>o.explicit).length,implicit_subject:r.filter(o=>!o.explicit).length}}}function sy(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 cy(e,t){let n=t.items.filter(i=>{let r=i[e.link],a=Array.isArray(r)&&r.length>0;return e.state==="present"?a:!a});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(i=>i.id)}}function dy(e,t){let n=e.source;return n.kind==="items"?ey(n,t):n.kind==="dependency_kind"?ny(n,t):n.kind==="prose_edge_gap"?oy(n,t):n.kind==="history"?sy(n,t):n.kind==="links"?cy(n,t):null}function su(e,t){return e.reduce((n,i)=>({units:n.units+i.units,items_scanned:n.items_scanned+i.items_scanned,history_entries:n.history_entries+i.history_entries,provider_calls:n.provider_calls+i.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function ly(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,i)=>n+i,0);if(e==="subtract")return t.slice(1).reduce((n,i)=>n-i,t[0]);if(e==="multiply")return t.reduce((n,i)=>n*i,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,i)=>n/i,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function cu(e,t,n){let i=new Array(e.length),r=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;r<e.length;){let o=r;r+=1,i[o]=await n(e[o],o)}});return await Promise.all(a),i}async function du(e,t,n,i,r){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 lu(o,t,n,i,r);if(typeof s.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=r.charged.has(o.id)?[]:[s.cost];return r.charged.add(o.id),{value:s.value,costs:c,population_size:s.population_size,contributors:s.contributors}}let a=await cu(e.operands,nu,o=>du(o,t,n,i,r));return{value:ly(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 uy(e,t,n,i,r){ho(e);let a=Date.now(),o,s=[],c=0;if(e.source.kind==="derived"){let u=await du(e.source.expression,t,n,[...i,e.id],r);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},s=u.costs}else{let u=dy(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=su([...s,d],Date.now()-a);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new ve(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${Hg("sha256").update(A(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function lu(e,t,n,i,r){if(i.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...i,e.id].join(" -> ")}`);let a=r.cache.get(e.id);if(a)return a;let o=uy(e,t,n,i,r).catch(s=>{if(s instanceof Ye&&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 Ye(s.message,c);throw d.cause=s,d}throw s});return r.cache.set(e.id,o),o}async function yo(e,t,n=[e]){return lu(e,t,n,[],{cache:new Map,charged:new Set})}function my(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 py(e,t,n={}){_o(e);let i=Zn(e),r=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:i,distance:my(t.value,i),verdict:r?"retired":iu(t.value,i)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:ru(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function fy(e,t,n,i){let r=Qg(e,t);if(r.size===0)return;let a=e.provider_policy,o=a?.triggers[i];if(!a||!o)throw new ve(`assurance gate ${e.id} refuses provider execution at trigger ${i} without an explicit provider policy`);let s=new Set(a.allowed_providers),c={low:0,medium:1,high:2};for(let d of r){if(!s.has(d))throw new ve(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new ve(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new ve(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${i}`);if(l.network&&!o.allow_network)throw new ve(`assurance gate ${e.id} refuses network provider ${d} at trigger ${i}`)}}async function eu(e,t,n,i,r){try{return await yo(n,i,r)}catch(a){if(a instanceof Ye){let o=a.check?` check ${a.check}`:"",s=a.measurement_id??n.id,c=new ve(`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 uu(e,t,n,i){hn(t);let r=t.gates.find(c=>c.id===e);if(!r)throw new ve(`assurance gate ${e} not found`);if(!r.triggers.includes(i.trigger))throw new ve(`assurance gate ${e} does not declare trigger ${i.trigger}`);fy(r,t,n,i.trigger);let a=await cu(r.assertion_ids,nu,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 eu(r.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 py(d,await eu(r.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:r.id,tree_id:n.tree_id,trigger:i.trigger,dry_run:i.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:su(a.map(c=>c.cost),Math.max(0,...a.map(c=>c.cost.duration_ms)))}}function Sr(e){return zg.join(e,"assurance.json")}async function mu(e){let t=await B(Sr(e));return t===null?Qn():xr(t)}function xr(e){try{return hn(JSON.parse(e))}catch(t){throw new g("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",y.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 Ir(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function hy(e,t){e==="measurement"?ho(t):e==="assertion"?_o(t):au(t)}async function ei(e,t){let n=structuredClone(Ir(await mu(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function pu(e,t,n){let i=Ir(await mu(e),t).find(r=>r.id===n);if(!i)throw new ve(`assurance ${t} ${n} not found`);return structuredClone(i)}async function Rr(e,t,n,i={}){hy(t,n);let r=await C(e),a=z(i.author,r.author_default),o=await an({pmRoot:e,filePath:Sr(e),op:`assurance:${t}:put`,author:a,message:i.message,lockTtlSeconds:kr,lockWaitMs:Er,mutate:s=>{let c=s===null?Qn():xr(s),d=Ir(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&Vg(d[l],n)){let m=n.authorization_decision;if(!m||!i.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),hn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
1
|
+
import{h as Zl,j as Ql}from"./chunk-MYBKRV5R.js";import{c as St,d as ln,e as un,f as mn,g as Kl,j as Xl}from"./chunk-C3DO4ZGZ.js";import{a as Vl}from"./chunk-IDAYTYNN.js";import{J as zl,u as Q,y as so}from"./chunk-LDMBNTOG.js";import{a as qa,c as Bi,d as Ji,e as ld,g as ud,h as Ba,i as md,j as Kt,k as Yt,l as pd,m as fd,n as Ja,o as gd,p as Xt,q as Zt,r as yd,s as wd,t as Va}from"./chunk-UIKLNSW3.js";import{a as oo}from"./chunk-SVOOGGAK.js";import{B as Dd,C as Zi,D as Od,E as Ka,G as Pd,H as Ld,J as Nd,K as Md,L as Qi,U as er}from"./chunk-NZQYHPUN.js";import{K as Yl}from"./chunk-AH5IST3V.js";import{G as lo,w as Gl,y as Jl}from"./chunk-HNFY3XLC.js";import{a as co,b as Bl}from"./chunk-QWUWNFQO.js";import{$a as ao,A as jd,B as Fd,Ba as to,C as qn,Fa as xl,Ga as Il,Ha as Rl,Ia as Al,Ja as wr,L as Ud,La as Cl,Ma as Tl,Na as $l,Oa as Mt,Pa as Dl,Q as Hd,Qa as sn,Ra as Ol,Sa as no,Ta as cn,Ua as Pl,Va as Ll,Wa as Nl,Xa as io,Ya as Ml,Za as dn,_a as ro,a as od,aa as zd,b as Vt,ba as Wd,c as Ga,ca as qd,d as sd,e as cd,f as it,fa as pr,g as Vi,h as dd,i as wt,ob as jl,pb as Fl,v as tr,vb as Ul,wa as hr,wb as Hl,xa as ml,ya as eo,z as Wn,za as Kn}from"./chunk-CUGJ2DY2.js";import{d as Yn,f as vr,m as Wl,p as ql}from"./chunk-RNZUORGI.js";import{$ as yr,D as Qa,E as wl,M as Vn,N as _r,P as vl,Q as bl,V as gr,X as kl,Y as fe,Z as he,_ as El,aa as rt,b as Gt,ba as at,e as nr,fa as Sl,g as sl,ga as ot,n as pl,o as fl,q as hl,r as _l,s as Et,t as gl,u as yl}from"./chunk-J7PWHKZK.js";import{$a as Jn,Ab as ne,C as ir,D as Gn,E as Jd,Ea as el,F as rr,Fa as Xa,G as Vd,Ga as sr,Ha as en,I as ar,J as or,Ja as cr,Ka as tl,L as Kd,La as nl,M as $e,Na as il,Pa as rl,R as bt,S as Yd,Sa as dr,T as Xd,Ua as tn,Va as al,Xa as lr,Ya as ur,Za as Bn,_a as kt,a as se,ab as ol,bb as mr,c as Te,cb as Nt,db as te,e as Ie,eb as nn,f as Ke,fb as cl,gb as Za,hb as rn,ib as an,j as ge,jb as on,k as hd,l as Ki,mb as dl,n as _d,nb as ll,o as Gd,qb as je,r as Re,s as Ya,t as Bd,ub as ul,va as z,vb as C,wa as Zd,wb as fr,xa as Me,ya as Qd}from"./chunk-JU62TKJP.js";import{$ as Wc,$b as Ve,Aa as Bt,Ca as Jc,Da as Ot,Db as nd,Dc as xd,Eb as id,Fa as Vc,Ga as A,Ha as Kc,Ia as xe,Ic as Id,Jc as ue,Ka as Gi,La as Yc,Ma as Ua,Mb as rd,Na as Ha,Nb as Pt,Oa as za,P as Hc,Pd as $,Qa as Xc,Qd as Rd,Ra as Zc,Rd as Qt,S as zc,Sd as vt,Td as Lt,U as Fa,Ua as Qc,Vb as Wa,Wb as ad,Wd as Ad,Xb as Jt,Z as pe,Zb as Je,Zd as Cd,_ as Ge,a as Oc,ae as Td,ba as Y,be as $d,cb as ed,cc as vd,ce as re,d as Pc,e as Lc,ea as qc,ec as Yi,fc as bd,gc as kd,ic as Ed,lb as td,o as ja,pa as Gc,qa as Bc,qc as F,ra as H,uc as K,wa as zn,wc as Ne,xa as M,xc as Sd,ya as Be,yc as Xi,za as qi}from"./chunk-2SQUWQP3.js";import{a as br,b as Xn}from"./chunk-EGN2HFRU.js";import{A as g,B as Hn,C as D,D as yt,E as j,F as B,I as Z,a as Hi,d as zi,p as Nc,r as Mc,t as jc,v as Fc,w as Wi,x as Uc,y as Un,z as y}from"./chunk-G6ERMFJ5.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 L=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},ve=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Ye=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 pn(e){try{return await e()}catch(t){throw t instanceof L?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function uo(e){try{return await e()}catch(t){throw t instanceof ve?new g(t.message,y.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as Hg}from"node:crypto";import zg 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 fn=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]="eaede7d4-43ae-5551-915e-19befefc29d0")}catch{}})();var tu=1,jt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],mo=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],Wg=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],qg=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,kr=30,Er=5e3,nu=4,Gg=50;function st(e,t){if(!qg.test(e))throw new L(`${t} must be a stable lowercase id`)}function Bg(e,t){if(!Number.isFinite(e)||e<0)throw new L(`${t} must be a finite non-negative number`)}function Zn(e){let t=Wg.filter(r=>e[r]!==void 0);if(t.length!==1)throw new L(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],i=e[n];return{polarity:n,value:n==="zero"?0:i}}function fo(e,t){return A(e)===A(t)}function iu(e,t){if(t.polarity==="equals")return fo(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let i=t.value;return e.every(r=>i.includes(r))}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 ru(e){let t=Zn(e),n=e.negative_control.cases;return n.some(i=>i.expected==="pass")&&n.some(i=>i.expected==="fail")&&n.every(i=>iu(i.observed,t)===(i.expected==="pass"))}function Jg(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,i=t.value;return!Array.isArray(n)||!Array.isArray(i)||i.some(r=>!n.includes(r))}return!fo(e.value,t.value)}function Vg(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||A(e.scope)!==A(t.scope))return!0;let n={observe:0,warn:1,block:2},i=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return Jg(Zn(e),Zn(t))||n[t.enforcement]<n[e.enforcement]||i}function Kg(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new L("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,i=Number(t)+Number(n);if(e.field!==void 0&&i!==1)throw new L("items source with field requires exactly one of equals or state");if(e.field===void 0&&i!==0)throw new L("items source equals/state requires field")}function Yg(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new L("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(t=>t!==void 0).length>1)throw new L("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new L("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new L("dependency_kind source source_kind_state must be present or missing")}function Xg(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new L("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new L("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new L("prose_edge_gap exemption selectors must not be empty")}}function ho(e){st(e.id,"measurement.id"),e.max_cost!==void 0&&Bg(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new L(`measurement.source.kind must be one of ${mo.join(", ")}`);let n=Reflect.get(t,"kind");if(!mo.includes(n))throw new L(`measurement.source.kind must be one of ${mo.join(", ")}`);let i=t;if(i.kind==="items"&&Kg(i),i.kind==="dependency_kind"&&Yg(i),i.kind==="prose_edge_gap"&&Xg(i),(i.kind==="graph"||i.kind==="validate"||i.kind==="health")&&(typeof i.field!="string"||i.field.trim().length===0))throw new L(`${i.kind} source requires field`);return i.kind==="provider"&&(st(i.provider,"provider source provider"),st(i.key,"provider source key")),e}function _o(e){if(st(e.id,"assertion.id"),st(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new L("assertion.owner_item_id is required");let t=Zn(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new L(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new L("retired assertion requires retire_reason");e.scope.kind==="filter"&&st(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(i=>i.expected==="pass")||!n.some(i=>i.expected==="fail"))throw new L("assertion negative control requires pass and fail cases");if(!ru(e))throw new L(`assertion ${e.id} negative control does not prove its bound`);return e}function Zg(e){if(!Array.isArray(e.allowed_providers))throw new L("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)st(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new L("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!jt.includes(t))throw new L(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new L(`gate provider policy trigger ${t} is invalid`)}}function au(e){if(st(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new L("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new L("gate requires at least one assertion");for(let t of e.assertion_ids)st(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new L(`gate.triggers is required and must be an array of ${jt.join(", ")}`);if(e.triggers.length===0)throw new L("gate requires at least one trigger");for(let t of e.triggers)if(!jt.includes(t))throw new L(`gate trigger must be one of ${jt.join(", ")}`);return e.provider_policy&&Zg(e.provider_policy),e}function hn(e){if(e.version!==tu)throw new L(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let i of e.measurements){if(ho(i),t.has(`measurement:${i.id}`))throw new L(`duplicate measurement ${i.id}`);t.add(`measurement:${i.id}`)}for(let i of e.assertions){if(_o(i),t.has(`assertion:${i.id}`))throw new L(`duplicate assertion ${i.id}`);t.add(`assertion:${i.id}`)}for(let i of e.gates){au(i);let r=i.assertion_ids.filter(a=>!e.assertions.some(o=>o.id===a));if(r.length>0)throw new L(`gate ${i.id} references missing assertions: ${r.join(", ")}`);if(t.has(`gate:${i.id}`))throw new L(`duplicate gate ${i.id}`);t.add(`gate:${i.id}`)}let n=new Set(e.measurements.map(i=>i.id));for(let[i,r]of ou(e))if(!n.has(i))throw new L(`${r.join(", ")} references missing measurement ${i}`);return e}function go(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)go(n,t)}function ou(e){let t=new Map,n=(i,r)=>{let a=t.get(i)??[];a.push(r),t.set(i,a)};for(let i of e.assertions)n(i.measurement_id,`assertion ${i.id}`),i.scope.kind==="filter"&&n(i.scope.measurement_id,`assertion ${i.id} scope`);for(let i of e.measurements){if(i.source.kind!=="derived")continue;let r=[];go(i.source.expression,r);for(let a of r)n(a,`derived measurement ${i.id}`)}return t}function Qg(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]:[]]}),i=new Set,r=new Set;for(;n.length>0;){let a=n.pop();if(i.has(a))continue;i.add(a);let o=t.measurements.find(s=>s.id===a);o.source.kind==="provider"?r.add(o.source.provider):o.source.kind==="derived"&&go(o.source.expression,n)}return r}function Qn(){return{version:tu,measurements:[],assertions:[],gates:[]}}function ey(e,t){let n=t.items.filter(i=>(e.statuses===void 0||e.statuses.includes(i.status))&&(e.types===void 0||e.types.includes(i.type))&&(e.tags===void 0||e.tags.every(r=>i.tags?.includes(r)))&&(e.field===void 0||(()=>{let r=i[e.field];if(e.state!==void 0){let a=r==null||r===""||Array.isArray(r)&&r.length===0;return e.state==="missing"?a:!a}return fo(r,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(i=>i.id)}}function ty(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 ny(e,t){let n=[],i=Fa(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let r of t.items)for(let a of r.dependencies??[]){let o=Fa(a.kind)??a.kind.trim().toLowerCase(),s=a.source_kind?.trim();o===i&&ty(e,s)&&n.push(`${r.id}->${a.id}${s?`@${s}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function iy(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 i=e[n];if(Array.isArray(i)){for(let r of i)if(typeof r=="string")t.push(r);else if(typeof r=="object"&&r!==null){let a=Reflect.get(r,"text");typeof a=="string"&&t.push(a)}}}return t}function ry(e,t,n,i){return e.some(r=>r.holder_id.trim().toLowerCase()===t.toLowerCase()&&(r.target_id===void 0||r.target_id.trim().toLowerCase()===n.toLowerCase())&&(r.text_contains===void 0||i.toLowerCase().includes(r.text_contains.trim().toLowerCase())))}function po(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function ay(e){let t=new Map,n=new Set,i=[],r=/(?<![\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(po(o.id,s.id));for(let s of[o.parent,o.blocked_by])typeof s=="string"&&n.add(po(o.id,s));for(let s of iy(o)){let c=[...s.matchAll(r)].map(d=>d[0]);a+=c.length,i.push({holder_id:o.id,segment:s,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:i,mention_count:a}}function oy(e,t){let n=ay(t.items),i=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=po(o.holder_id,d);if(n.linked_pairs.has(l)||ry(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);i.get(l)?.explicit===!0&&!u||i.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let r=[...i.values()],a=r.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:r.filter(o=>o.explicit).length,implicit_subject:r.filter(o=>!o.explicit).length}}}function sy(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 cy(e,t){let n=t.items.filter(i=>{let r=i[e.link],a=Array.isArray(r)&&r.length>0;return e.state==="present"?a:!a});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(i=>i.id)}}function dy(e,t){let n=e.source;return n.kind==="items"?ey(n,t):n.kind==="dependency_kind"?ny(n,t):n.kind==="prose_edge_gap"?oy(n,t):n.kind==="history"?sy(n,t):n.kind==="links"?cy(n,t):null}function su(e,t){return e.reduce((n,i)=>({units:n.units+i.units,items_scanned:n.items_scanned+i.items_scanned,history_entries:n.history_entries+i.history_entries,provider_calls:n.provider_calls+i.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function ly(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,i)=>n+i,0);if(e==="subtract")return t.slice(1).reduce((n,i)=>n-i,t[0]);if(e==="multiply")return t.reduce((n,i)=>n*i,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,i)=>n/i,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function cu(e,t,n){let i=new Array(e.length),r=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;r<e.length;){let o=r;r+=1,i[o]=await n(e[o],o)}});return await Promise.all(a),i}async function du(e,t,n,i,r){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 lu(o,t,n,i,r);if(typeof s.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=r.charged.has(o.id)?[]:[s.cost];return r.charged.add(o.id),{value:s.value,costs:c,population_size:s.population_size,contributors:s.contributors}}let a=await cu(e.operands,nu,o=>du(o,t,n,i,r));return{value:ly(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 uy(e,t,n,i,r){ho(e);let a=Date.now(),o,s=[],c=0;if(e.source.kind==="derived"){let u=await du(e.source.expression,t,n,[...i,e.id],r);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},s=u.costs}else{let u=dy(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=su([...s,d],Date.now()-a);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new ve(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${Hg("sha256").update(A(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function lu(e,t,n,i,r){if(i.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...i,e.id].join(" -> ")}`);let a=r.cache.get(e.id);if(a)return a;let o=uy(e,t,n,i,r).catch(s=>{if(s instanceof Ye&&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 Ye(s.message,c);throw d.cause=s,d}throw s});return r.cache.set(e.id,o),o}async function yo(e,t,n=[e]){return lu(e,t,n,[],{cache:new Map,charged:new Set})}function my(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 py(e,t,n={}){_o(e);let i=Zn(e),r=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:i,distance:my(t.value,i),verdict:r?"retired":iu(t.value,i)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:ru(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function fy(e,t,n,i){let r=Qg(e,t);if(r.size===0)return;let a=e.provider_policy,o=a?.triggers[i];if(!a||!o)throw new ve(`assurance gate ${e.id} refuses provider execution at trigger ${i} without an explicit provider policy`);let s=new Set(a.allowed_providers),c={low:0,medium:1,high:2};for(let d of r){if(!s.has(d))throw new ve(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new ve(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new ve(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${i}`);if(l.network&&!o.allow_network)throw new ve(`assurance gate ${e.id} refuses network provider ${d} at trigger ${i}`)}}async function eu(e,t,n,i,r){try{return await yo(n,i,r)}catch(a){if(a instanceof Ye){let o=a.check?` check ${a.check}`:"",s=a.measurement_id??n.id,c=new ve(`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 uu(e,t,n,i){hn(t);let r=t.gates.find(c=>c.id===e);if(!r)throw new ve(`assurance gate ${e} not found`);if(!r.triggers.includes(i.trigger))throw new ve(`assurance gate ${e} does not declare trigger ${i.trigger}`);fy(r,t,n,i.trigger);let a=await cu(r.assertion_ids,nu,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 eu(r.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 py(d,await eu(r.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:r.id,tree_id:n.tree_id,trigger:i.trigger,dry_run:i.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:su(a.map(c=>c.cost),Math.max(0,...a.map(c=>c.cost.duration_ms)))}}function Sr(e){return zg.join(e,"assurance.json")}async function mu(e){let t=await B(Sr(e));return t===null?Qn():xr(t)}function xr(e){try{return hn(JSON.parse(e))}catch(t){throw new g("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",y.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 Ir(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function hy(e,t){e==="measurement"?ho(t):e==="assertion"?_o(t):au(t)}async function ei(e,t){let n=structuredClone(Ir(await mu(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function pu(e,t,n){let i=Ir(await mu(e),t).find(r=>r.id===n);if(!i)throw new ve(`assurance ${t} ${n} not found`);return structuredClone(i)}async function Rr(e,t,n,i={}){hy(t,n);let r=await C(e),a=z(i.author,r.author_default),o=await an({pmRoot:e,filePath:Sr(e),op:`assurance:${t}:put`,author:a,message:i.message,lockTtlSeconds:kr,lockWaitMs:Er,mutate:s=>{let c=s===null?Qn():xr(s),d=Ir(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&Vg(d[l],n)){let m=n.authorization_decision;if(!m||!i.authorized_decision_ids?.includes(m))throw new L(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),hn(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 i=Qn();i.measurements=structuredClone(t.measurements),i.assertions=structuredClone(t.assertions),i.gates=structuredClone(t.gates),hn(i);let r=await C(e),a=z(n.author,r.author_default),o=await an({pmRoot:e,filePath:Sr(e),op:"assurance:bundle:apply",author:a,message:n.message,lockTtlSeconds:kr,lockWaitMs:Er,mutate:s=>{let c=s===null?Qn():xr(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(A(_)!==A(h))throw new L(`assurance bundle refuses to replace divergent ${p} ${h.id}`);l.push(`${p}:${h.id}`)}};return u(c.measurements,i.measurements,"measurement"),u(c.assertions,i.assertions,"assertion"),u(c.gates,i.gates,"gate"),hn(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 fu(e,t,n,i={}){let r=await C(e),a=z(i.author,r.author_default),o=await an({pmRoot:e,filePath:Sr(e),op:`assurance:${t}:remove`,author:a,message:i.message,lockTtlSeconds:kr,lockWaitMs:Er,mutate:s=>{let c=s===null?Qn():xr(s);if(t==="measurement"){let u=ou(c).get(n);if(u&&u.length>0)throw new L(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new L(`assurance assertion ${n} is referenced by gate`);let d=Ir(c,t),l=d.findIndex(u=>u.id===n);if(l<0)throw new L(`assurance ${t} ${n} not found`);return d.splice(l,1),hn(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 hu(e,t,n={}){if(t.dry_run)throw new TypeError("dry-run assurance verdicts are not persisted");let i=await C(e);await rn({pmRoot:e,op:"assurance:gate:verdict",author:z(n.author,i.author_default),context:{assurance_verdict:t},message:n.message??`Assurance gate ${t.gate_id} returned ${t.verdict}`,lockTtlSeconds:kr,lockWaitMs:Er})}async function _u(e,t={}){let n=t.limit??Gg;if(!Number.isInteger(n)||n<1||n>fn)throw new TypeError(`assurance verdict limit must be an integer from 1 through ${fn}`);return(await Me(nn(e),te)).reverse().filter(i=>i.op==="assurance:gate:verdict").map(i=>i.context?.assurance_verdict).filter(i=>typeof i=="object"&&i!==null&&"gate_id"in i).filter(i=>t.gate_id===void 0||i.gate_id===t.gate_id).slice(0,n)}import{mkdir as _y,readFile as gy}from"node:fs/promises";import yu from"node:path";import{createHash as yy}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]="24a18484-0b8b-55d7-aa23-08a23b8d78ce")}catch{}})();var vo=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},wu="sdk-workspace-transaction",vu=/^[a-zA-Z0-9._-]+$/,bu=30,ku=3e3;function xo(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!vu.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function bo(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function Io(e){return{pmRoot:bo(e.pmRoot,"Transaction pmRoot"),transactionId:xo(e.transactionId,"Transaction id"),author:bo(e.author,"Transaction author")}}function Cr(e,t,n){let i=e??t;if(!Number.isInteger(i)||i<=0)throw new TypeError(`${n} must be a positive integer`);return i}function Eu(e,t){return yu.join(e,"transactions","sdk",`${t}.json`)}async function Xe(e,t){t.updatedAt=$();let n=Eu(e,t.transactionId);await _y(yu.dirname(n),{recursive:!0}),await Z(n,`${JSON.stringify(t,null,2)}
|
|
@@ -62,4 +62,4 @@ ${a}`,y.GENERIC_FAILURE)}}function La(e){return typeof e.tag=="string"&&e.tag.tr
|
|
|
62
62
|
`);oe(e.progressEnabled,"writing keyword artifacts"),await Z(t,`${JSON.stringify(e.manifest,null,2)}
|
|
63
63
|
`),await Z(n,`${r}
|
|
64
64
|
`);let a=[];if(e.mode!=="keyword")try{oe(e.progressEnabled,"writing vectorization status ledger"),await Pl(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 cq(e,t){let n=AC(e.mode),i=RC(e),r=e.full===!0;oe(i,`start mode=${n}`);let a=M(process.cwd(),t.path);await ne(a);let o=hr(await C(a)).settings,s=null;try{s=await re(a,ml,o.locks.ttl_seconds,z(void 0,"pm-reindex"),!1,o.governance.force_required_for_stale_lock,o.locks.wait_ms)}catch(c){throw c instanceof g&&c.exitCode===y.CONFLICT?new g("Another pm reindex run is already active for this project. Wait for it to finish before starting a new keyword, semantic, or hybrid reindex.",y.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=$C(o),d=DC(o),l=jC({requestedMode:n,pmRoot:a,settings:o,extensionEmbedding:c,extensionVectorAdapter:d}),u=n;oe(i,"loading item corpus");let m=await FC({pmRoot:a,settings:o}),f=m.warnings,{documentCandidates:p,metadataDocuments:h}=m;oe(i,`loaded_items=${h.length}`);let _=$(),w=MC(u,_,h),v=Mi.join(a,Cc),k=Mi.join(a,Tc),E=u==="keyword"?await Dc(a,p,o.schema,f):h,I=[],T={},S=null,b=NC(u);if(u==="keyword"&&await UC({pmRoot:a,settings:o,forceFullSemantic:r,extensionEmbedding:c,reindexWarnings:f}),u!=="keyword"){let x=await JC({pmRoot:a,settings:o,requestedMode:n,activeEmbeddingProvider:l.activeEmbeddingProvider,activeVectorStore:l.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:d,documentCandidates:p,metadataDocuments:h,documentsForKeywordArtifacts:E,forceFullSemantic:r,reindexWarnings:f,semanticWarnings:I,semanticSummary:b,progressEnabled:i});E=x.documentsForKeywordArtifacts,T=x.vectorizationLedgerEntries,S=x.vectorizationEmbeddingMetadata}let O=await VC({pmRoot:a,mode:u,manifest:w,documentsForKeywordArtifacts:E,settings:o,vectorizationLedgerEntries:T,vectorizationEmbeddingMetadata:S,progressEnabled:i}),P=[...await K({path:v,scope:"project",op:"reindex:manifest"}),...await K({path:k,scope:"project",op:"reindex:embeddings"}),...await Xi({mode:u,total_items:h.length})];return oe(i,"done"),{ok:!0,mode:u,total_items:h.length,semantic:b,artifacts:{manifest:Cc,embeddings:Tc},warnings:[...f,...I,...O,...P],generated_at:_}}finally{await s?.()}}export{L as a,ve as b,Ye as c,pn as d,uo as e,tu as f,jt as g,mo as h,Vg as i,ho as j,_o as k,au as l,hn as m,Qn as n,yo as o,py as p,uu as q,ei as r,pu as s,Rr as t,wo as u,fu as v,hu as w,_u as x,Io as y,Iu as z,yT as A,Ry as B,wT as C,Cy as D,kT as E,Tu as F,Dy as G,zT as H,Ov as I,_O as J,wO as K,vO as L,mi as M,bO as N,kO as O,EO as P,SO as Q,xO as R,IO as S,RO as T,AO as U,CO as V,TO as W,$O as X,us as Y,ws as Z,K$ as _,vm as $,Ny as aa,Nu as ba,e$ as ca,ri as da,t$ as ea,Wy as fa,qy as ga,n$ as ha,Gy as ia,l_ as ja,s$ as ka,Wu as la,m_ as ma,bU as na,kU as oa,ai as pa,Or as qa,Gu as ra,Bu as sa,Ju as ta,Vu as ua,Zu as va,em as wa,tm as xa,rm as ya,At as za,AM as Aa,CM as Ba,TM as Ca,$M as Da,FM as Ea,Xf as Fa,ma as Ga,d1 as Ha,ft as Ia,oh as Ja,l1 as Ka,u1 as La,x0 as Ma,C0 as Na,uh as Oa,uw as Pa,sm as Qa,Ps as Ra,oj as Sa,sj as Ta,Lr as Ua,Nr as Va,jh as Wa,sF as Xa,Fh as Ya,Hh as Za,zh as _a,Gh as $a,Jh as ab,JI as bb,VI as cb,AU as db,CU as eb,TU as fb,$U as gb,h_ as hb,YI as ib,g_ as jb,ka as kb,w_ as lb,v_ as mb,b_ as nb,ZI as ob,eR as pb,nR as qb,DU as rb,iR as sb,ac as tb,oc as ub,WU as vb,qU as wb,GU as xb,OR as yb,iz as zb,dg as Ab,Pi as Bb,mg as Cb,pg as Db,fg as Eb,bc as Fb,HA as Gb,Uz as Hb,dW as Ib,gW as Jb,Rg as Kb,Ag as Lb,Cg as Mb,HW as Nb,eq as Ob,tq as Pb,nq as Qb,cq as Rb};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-XLSTFUXM.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-MYBKRV5R.js";import"./chunk-QWUWNFQO.js";import"./chunk-CUGJ2DY2.js";import"./chunk-IS5FLEZW.js";import"./chunk-GHQVM6K6.js";import{A as c,B as d,y as a,z as b}from"./chunk-J7PWHKZK.js";import"./chunk-JU62TKJP.js";import"./chunk-C3O6JJPO.js";import"./chunk-2SQUWQP3.js";import"./chunk-G6ERMFJ5.js";export{f as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,e as ITEM_REVISION_CONFLICT_CODE,w as assertExpectHashAdmissible,t as bindExpectedItemRevisions,c as bindItemRevisionScope,a as createItemRevisionScope,k as describeItemRevisionChanges,y as dispatchWithExpectedItemRevisions,q as enrichItemRevisionConflict,o as expectHashInvocationRewrittenError,x as expectHashRequiresMutationError,m as isItemRevisionConflict,u as isTrackerRevisionGuarded,l as itemRevisionConflictRowFields,d as itemRevisionScopeReceipt,v as itemRevisionUncheckedWarning,g as normalizeExpectedItemHash,h as parseExpectHashSpecs,i as readItemRevision,j as resolveExpectedItemRevisions,r as runWithBoundItemRevisionScope,b as runWithItemRevisionScope,p as scopeItemRevisionConflict,n as throwFirstItemRevisionConflict,s as withExpectedItemRevisions};
|
|
2
|
+
//# sourceMappingURL=item-revision-M6FOLME2.js.map
|