workspai 0.77.0 → 0.78.0
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/contracts/create-planner-capabilities.v1.json +26 -2
- package/contracts/runtime-command-surface.v1.json +2 -0
- package/contracts/workspace-intelligence-architecture.v1.json +2 -0
- package/dist/analyze-X76YV667.js +1 -0
- package/dist/autopilot-release-6OV2FLRS.js +1 -0
- package/dist/{chunk-3EMAC3MF.js → chunk-2CUT4GLE.js} +1 -1
- package/dist/chunk-3PGXGAHC.js +2 -0
- package/dist/{chunk-4CXV3PPV.js → chunk-4AAXIWYY.js} +1 -1
- package/dist/{chunk-47UR6ZH4.js → chunk-4KAYWMNE.js} +1 -1
- package/dist/{chunk-UP3UWAJV.js → chunk-5FVREPQC.js} +1 -1
- package/dist/{chunk-HRVHQBTA.js → chunk-5OKNWBAN.js} +1 -1
- package/dist/{chunk-DWKCFHHL.js → chunk-75WJOYWT.js} +1 -1
- package/dist/{chunk-LUPKDFQ3.js → chunk-7EMG3C3H.js} +2 -2
- package/dist/{chunk-O3TVVQ6X.js → chunk-7HV4U2OV.js} +1 -1
- package/dist/{chunk-TGNPMOM6.js → chunk-AMGIXK6Z.js} +1 -1
- package/dist/{chunk-IDETNYCF.js → chunk-FLAGHVSH.js} +1 -1
- package/dist/{chunk-UNEK3VVR.js → chunk-HB3ZYG2Z.js} +2144 -91
- package/dist/{chunk-UTIK3K3M.js → chunk-HMWZWT7B.js} +1 -1
- package/dist/{chunk-3SQIV3F4.js → chunk-IQJL3LBM.js} +1 -1
- package/dist/{chunk-475GQJ2D.js → chunk-KRTVIBPC.js} +1 -1
- package/dist/chunk-MD4CHXV3.js +2 -0
- package/dist/{chunk-QCX6BO2M.js → chunk-MN5S462C.js} +1 -1
- package/dist/{chunk-IAXRGH4Q.js → chunk-ONUFNCRN.js} +1 -1
- package/dist/chunk-QDM6TWFK.js +1 -0
- package/dist/{chunk-WC2K5QFI.js → chunk-QLHRGWUW.js} +1 -1
- package/dist/{chunk-223SWPTL.js → chunk-QMNJTI65.js} +1 -1
- package/dist/{chunk-ZIWWE4BQ.js → chunk-RHF2IZOW.js} +1 -1
- package/dist/{chunk-V6HVDVKJ.js → chunk-RJESUJQF.js} +5 -5
- package/dist/chunk-RQXZF7BZ.js +1 -0
- package/dist/{chunk-JVZA35OL.js → chunk-TJRVWVAZ.js} +1 -1
- package/dist/{chunk-GLBFY7AB.js → chunk-UVIBPWOG.js} +2 -2
- package/dist/{chunk-3EPR3D5Q.js → chunk-VEMGICT4.js} +1 -1
- package/dist/{chunk-SC43A6LH.js → chunk-VRZAN3WS.js} +50 -50
- package/dist/{chunk-E7WJ2QX7.js → chunk-YHQK4S3H.js} +1 -1
- package/dist/{chunk-X5XFT5UZ.js → chunk-YWC5MKIL.js} +1 -1
- package/dist/{chunk-J2MPBSQJ.js → chunk-ZQ36CTLF.js} +1 -1
- package/dist/{create-YPAZJYCE.js → create-WB5YQ7C6.js} +1 -1
- package/dist/{doctor-W5PXJ5FL.js → doctor-HOSHQ7II.js} +1 -1
- package/dist/{goal-lifecycle-5R55CA7H.js → goal-lifecycle-UEJMTUFV.js} +1 -1
- package/dist/{goal-pack-IS6GGJPH.js → goal-pack-YGZMG3RQ.js} +1 -1
- package/dist/index.js +92 -91
- package/dist/{pipeline-LW3SW2WT.js → pipeline-Z4JOJ4PX.js} +1 -1
- package/dist/{project-agent-entry-5TYKK5IV.js → project-agent-entry-ZMDQWJ6I.js} +1 -1
- package/dist/{project-intelligence-lens-TEOSTKNU.js → project-intelligence-lens-FSWQKY3E.js} +1 -1
- package/dist/{project-test-coverage-T4TIWGKN.js → project-test-coverage-EJ3MBSZ3.js} +1 -1
- package/dist/{proof-carrying-change-2TKRADCW.js → proof-carrying-change-M2RNYQ7E.js} +1 -1
- package/dist/{verified-goal-RN4TOV34.js → verified-goal-UAUCEDZZ.js} +1 -1
- package/dist/{workspace-A33YMF2N.js → workspace-J5QYWAE3.js} +1 -1
- package/dist/{workspace-agent-sync-VCA4G4DT.js → workspace-agent-sync-GLG36KQZ.js} +1 -1
- package/dist/{workspace-context-YBWLSKR6.js → workspace-context-BZV4ZFKZ.js} +1 -1
- package/dist/{workspace-contract-3QUZDBMM.js → workspace-contract-XDNIB5JX.js} +1 -1
- package/dist/{workspace-explain-NXYRAQFI.js → workspace-explain-V3XDMONQ.js} +1 -1
- package/dist/{workspace-foundation-DZ52PECX.js → workspace-foundation-EDTKW2RB.js} +1 -1
- package/dist/{workspace-graph-stream-4VT46HZ7.js → workspace-graph-stream-UPASFCAF.js} +1 -1
- package/dist/{workspace-intelligence-FKYQQDJ6.js → workspace-intelligence-24MZRG2S.js} +1 -1
- package/dist/{workspace-intelligence-runner-3K2JZH6Q.js → workspace-intelligence-runner-HISKHQLG.js} +1 -1
- package/dist/{workspace-knowledge-graph-CPBKNXQI.js → workspace-knowledge-graph-5EECTGXQ.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-T6ZJGWLC.js +1 -0
- package/dist/{workspace-mcp-serve-UXPKX7K6.js → workspace-mcp-serve-S3TWO4RI.js} +1 -1
- package/dist/{workspace-model-POCPMNRT.js → workspace-model-J757KSDE.js} +1 -1
- package/dist/{workspace-onboarding-KLG3GG7S.js → workspace-onboarding-3TLME4HP.js} +1 -1
- package/dist/{workspace-registry-summary-M4WMFDQ4.js → workspace-registry-summary-ZC5CFZXP.js} +1 -1
- package/dist/{workspace-repair-engine-2VGN42QD.js → workspace-repair-engine-C26C7OIB.js} +1 -1
- package/dist/workspace-run-2KBTMGG7.js +1 -0
- package/dist/{workspace-verify-PLAKTF3J.js → workspace-verify-KFBWQ37C.js} +1 -1
- package/dist/{workspace-watch-VNU4KVYN.js → workspace-watch-LNP5JPD4.js} +1 -1
- package/docs/agent-framework-adapters.md +68 -18
- package/docs/ci-workflows.md +9 -6
- package/docs/commands-reference.md +5 -2
- package/docs/creating-workspaces-and-projects.md +2 -0
- package/docs/doctor-command.md +5 -3
- package/docs/native-kit-baselines.md +2 -2
- package/package.json +4 -1
- package/scripts/enterprise-package-smoke.mjs +50 -0
- package/dist/analyze-TJM66CPF.js +0 -1
- package/dist/autopilot-release-C7Q4OTPY.js +0 -1
- package/dist/chunk-5KXOV7W4.js +0 -1
- package/dist/chunk-IHWS3ALP.js +0 -2
- package/dist/chunk-N7DOKE7V.js +0 -2
- package/dist/chunk-SEZTSMRR.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-67XDXUOT.js +0 -1
- package/dist/workspace-run-5YQR7GEZ.js +0 -1
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"plannerFramework": "microsoft-agent-framework",
|
|
119
119
|
"category": "agent",
|
|
120
120
|
"owner": "workspai",
|
|
121
|
-
"stability": "
|
|
121
|
+
"stability": "preview",
|
|
122
122
|
"versionPolicy": "tested-baseline",
|
|
123
123
|
"moduleSupport": false,
|
|
124
124
|
"workspacePythonEngine": "none"
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"plannerFramework": "microsoft-agent-framework",
|
|
131
131
|
"category": "agent",
|
|
132
132
|
"owner": "workspai",
|
|
133
|
-
"stability": "
|
|
133
|
+
"stability": "preview",
|
|
134
134
|
"versionPolicy": "tested-baseline",
|
|
135
135
|
"moduleSupport": false,
|
|
136
136
|
"workspacePythonEngine": "none"
|
|
@@ -159,6 +159,30 @@
|
|
|
159
159
|
"moduleSupport": false,
|
|
160
160
|
"workspacePythonEngine": "none"
|
|
161
161
|
},
|
|
162
|
+
{
|
|
163
|
+
"id": "agent.google-adk.python",
|
|
164
|
+
"runtime": "python",
|
|
165
|
+
"framework": "google-adk",
|
|
166
|
+
"plannerFramework": "google-adk",
|
|
167
|
+
"category": "agent",
|
|
168
|
+
"owner": "workspai",
|
|
169
|
+
"stability": "preview",
|
|
170
|
+
"versionPolicy": "tested-baseline",
|
|
171
|
+
"moduleSupport": false,
|
|
172
|
+
"workspacePythonEngine": "none"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"id": "agent.google-adk.typescript",
|
|
176
|
+
"runtime": "node",
|
|
177
|
+
"framework": "google-adk",
|
|
178
|
+
"plannerFramework": "google-adk",
|
|
179
|
+
"category": "agent",
|
|
180
|
+
"owner": "workspai",
|
|
181
|
+
"stability": "preview",
|
|
182
|
+
"versionPolicy": "tested-baseline",
|
|
183
|
+
"moduleSupport": false,
|
|
184
|
+
"workspacePythonEngine": "none"
|
|
185
|
+
},
|
|
162
186
|
{
|
|
163
187
|
"id": "gateway.openrouter.typescript",
|
|
164
188
|
"runtime": "node",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-QMNJTI65.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-YHQK4S3H.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-FIK343LI.js';import {c as c$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-FIK343LI.js';import {c as c$1}from'./chunk-75WJOYWT.js';import {l,q}from'./chunk-FLAGHVSH.js';import {f,h as h$2,g}from'./chunk-IQJL3LBM.js';import {a as a$3}from'./chunk-4AAXIWYY.js';import {i,h as h$1,d,b as b$1,a as a$2,c as c$2,k as k$1}from'./chunk-BLEIUQL6.js';import {b as b$3}from'./chunk-VN2MKTQO.js';import {a}from'./chunk-AFIFZTOY.js';import {a as a$4}from'./chunk-XWKGZRHN.js';import {c,d as d$1}from'./chunk-EWZZUQBR.js';import {b as b$2}from'./chunk-25AWHAB5.js';import {h,i as i$1,m,k,n,o,g as g$1,l as l$1,j as j$1,s,e,f as f$1}from'./chunk-ODK4LCEL.js';import {a as a$5}from'./chunk-FB7SCXAZ.js';import {randomUUID,createHash}from'crypto';import b from'path';import z from'fs-extra';var nt=new Set(["committed","rejected","aborted","superseded"]);function u(e,t){if(!e)throw new Error(`Decision protocol violation: ${t}`)}function st(e){return [...new Set(e)].sort()}function We(e,t){return t.digestCanonical(e.effects.map(a=>({id:a.id,status:a.status,key:a.idempotencyKey})))}function Me(e,t,a){u(!e.some(r=>r.id===t),`${a} receipt '${t}' already exists`);}function it(e,t){Me(e.effects,t.id,"effect");let a=e.effects.find(r=>r.idempotencyKey===t.idempotencyKey);return u(!a,`effect idempotency key '${t.idempotencyKey}' was already recorded by '${a?.id}'`),[...e.effects,t]}function ot(e,t,a){return Me(e.verifications,t.id,"verification"),u(t.target.effectHeadDigest===We(e,a),`verification '${t.id}' does not bind the current effect head`),[...e.verifications,t]}function ct(e){return e.requiredCriteria.every(t=>{let a=e.verifications.filter(r=>r.criterionId===t);return a.length>0&&a.at(-1)?.status==="passed"})}function dt(e$1,t,a){if(t.kind==="created"){u(e$1===null,"created must be the first event");let y=t.payload.references?.[0];u(y,"created must bind an intent artifact");let p=t.payload.references?.filter(k=>k.role==="success-criterion").map(k=>k.artifact)??[];return {schemaVersion:e,id:t.transactionId,purpose:"proof-carrying-change",createdAt:t.occurredAt,updatedAt:t.occurredAt,state:"draft",generation:1,eventCount:t.sequence,eventHeadDigest:t.digest,intent:y,requiredCriteria:st(p),scope:null,evidence:[],plans:[],authorization:null,effects:[],verifications:[],blockers:[]}}u(e$1,`${t.kind} cannot occur before created`),u(!nt.has(e$1.state),`${t.kind} cannot follow terminal state ${e$1.state}`);let r=e$1.state,n=e$1.scope,s=e$1.evidence,d=e$1.plans,f=e$1.authorization,l=e$1.effects,o=e$1.verifications,c=e$1.blockers,h=e$1.terminalReason;switch(t.kind){case "scope-bound":u(e$1.state==="draft"||e$1.state==="scoped","scope-bound requires draft or scoped state"),u(t.payload.scope,"scope-bound requires scope"),n=t.payload.scope,r="scoped";break;case "evidence-attached":u(e$1.state==="scoped"||e$1.state==="evidence-ready","evidence-attached requires scoped state"),u((t.payload.references?.length??0)>0,"evidence-attached requires references"),s=[...s,...t.payload.references??[]],r="evidence-ready";break;case "plan-attached":u(e$1.state==="evidence-ready","plan-attached requires evidence-ready state"),u((t.payload.references?.length??0)>0,"plan-attached requires references"),d=[...d,...t.payload.references??[]];break;case "authorized":u(e$1.state==="evidence-ready","authorization requires evidence-ready state"),u(t.payload.authorization,"authorized requires a bounded authorization grant"),f=t.payload.authorization,r="authorized";break;case "effect-requested":u(e$1.state==="authorized"||e$1.state==="executing","effect-requested requires authorization"),r="executing";break;case "effect-recorded":u(e$1.state==="authorized"||e$1.state==="executing","effect-recorded requires authorization"),u(t.payload.effect,"effect-recorded requires a receipt"),u(f?.effectClasses.includes(t.payload.effect.effectClass),`effect class '${t.payload.effect.effectClass}' is outside the authorization grant`),l=it(e$1,t.payload.effect),r=t.payload.effect.status==="succeeded"?"executing":"blocked",t.payload.effect.status!=="succeeded"&&(c=[...c,{code:t.payload.effect.status==="uncertain"?"decision.effect.uncertain":"decision.effect.failed",actionable:true,details:t.payload.effect.summary}]);break;case "effect-uncertain":u(e$1.state==="authorized"||e$1.state==="executing","effect-uncertain requires an active execution"),r="blocked",c=[...c,t.payload.blocker??{code:"decision.effect.uncertain",actionable:true}];break;case "verification-started":u(e$1.state==="authorized"||e$1.state==="executing","verification-started requires authorized or executing state"),r="verifying";break;case "verification-recorded":{u(e$1.state==="verifying","verification-recorded requires verifying state"),u(t.payload.verification,"verification-recorded requires a receipt"),o=ot(e$1,t.payload.verification,a),r=t.payload.verification.status==="failed"?"blocked":t.payload.verification.status==="inconclusive"?"awaiting-human":"verifying";break}case "human-required":r="awaiting-human";break;case "blocked":u(t.payload.blocker,"blocked requires a structured blocker"),c=[...c,t.payload.blocker],r="blocked";break;case "resumed":u(e$1.state==="blocked"||e$1.state==="awaiting-human","resumed requires a paused state"),u(t.payload.resumeTo,"resumed requires an explicit target state"),r=t.payload.resumeTo,c=[];break;case "committed":u(e$1.state==="verifying","commit requires verifying state"),u(ct(e$1),"every required criterion needs a latest passing receipt"),u(!e$1.effects.some(y=>y.status!=="succeeded"),"all effects must be certainly successful"),r="committed",h=t.payload.reason??t.payload.summary;break;case "rejected":case "aborted":case "superseded":r=t.kind,h=t.payload.reason??t.payload.summary;break;default:throw new Error(`Decision protocol violation: unsupported event ${t.kind}`)}return {...e$1,updatedAt:t.occurredAt,state:r,generation:e$1.generation+1,eventCount:t.sequence,eventHeadDigest:t.digest,scope:n,evidence:s,plans:d,authorization:f,effects:l,verifications:o,blockers:c,...h?{terminalReason:h}:{}}}function Be(e,t,a,r){let n=(t?.sequence??0)+1,s={schemaVersion:f$1,transactionId:e,sequence:n,kind:a.kind,occurredAt:a.occurredAt,actor:a.actor,previousEventDigest:t?.digest??null,payload:a.payload};return {...s,digest:r.digestCanonical(s)}}function ee(e,t){u(e.length>0,"at least one event is required");let a=null,r=null;for(let n of e){u(n.schemaVersion===f$1,`unsupported event schema ${n.schemaVersion}`),u(n.sequence===(r?.sequence??0)+1,`event sequence ${n.sequence} is not contiguous`),u(n.previousEventDigest===(r?.digest??null),`event ${n.sequence} has an invalid previous digest`);let{digest:s,...d}=n;u(n.digest===t.digestCanonical(d),`event ${n.sequence} digest is invalid`),u(!r||n.transactionId===r.transactionId,"events cross transaction boundaries"),a=dt(a,n,t),r=n;}return a}function he(e,t,a){return {schemaVersion:g$1,transactionId:e.id,generatedAt:t,generation:e.generation,eventCount:e.eventCount,eventHeadDigest:e.eventHeadDigest,state:e.state,transactionDigest:a.digestCanonical(e)}}function te(e,t){return We(e,t)}var M={digestCanonical:c};function ft(e){let t=e.trim();if(!/^change-[a-z0-9][a-z0-9-]{7,95}$/.test(t))throw new Error(`Invalid decision transaction id: ${e}`);return t}function L(e){let a=`.workspai/decisions/${ft(e)}`;return {directory:a,transaction:`${a}/transaction.json`,checkpoint:`${a}/checkpoint.json`,events:`${a}/events.jsonl`,lock:`${a}.lock`}}function gt(e,t){return e.split(/\r?\n/).filter(r=>r.trim().length>0).map((r,n)=>{try{return JSON.parse(r)}catch(s){throw new Error(`Decision event log is corrupt at ${t}:${n+1}: ${s.message}`)}})}async function Le(e,t){let a=L(t),r=await b$1(e,a.events);return r?gt(await z.readFile(r,"utf8"),r):[]}function Ue(e,t){let a=L(t);return {directory:a$2(e,a.directory),transaction:a$2(e,a.transaction),checkpoint:a$2(e,a.checkpoint),events:a$2(e,a.events)}}async function ht(e,t,a$1,r){let n=L(t.id),s=he(t,r,M);for(let[d,f]of a$1.entries())a(f,"contracts/workspace-intelligence/decision-event.v1.json",`Decision event ${d+1}`);return b$3(n.transaction,t),b$3(n.checkpoint,s),await k$1(e,n.events,`${a$1.map(d=>JSON.stringify(d)).join(`
|
|
2
2
|
`)}
|
|
3
3
|
`),await h$1(e,n.transaction,t),await h$1(e,n.checkpoint,s),{transaction:t,checkpoint:s,events:a$1,paths:Ue(e,t.id)}}async function Fe(e){let t=L(e.transactionId),a=a$2(e.workspacePath,t.lock);return a$4(a,async()=>{let r=await Le(e.workspacePath,e.transactionId),n=r.at(-1)??null;if((n?.digest??null)!==e.expectedHeadDigest)throw new Error(`Decision transaction head changed: expected ${e.expectedHeadDigest??"<empty>"}, observed ${n?.digest??"<empty>"}`);r.length>0&&ee(r,M);let s=Be(e.transactionId,n,e.event,M),d=[...r,s],f=ee(d,M);return ht(e.workspacePath,f,d,e.event.occurredAt)},{purpose:`decision:${e.transactionId}`,timeoutMs:3e4,staleMs:6e4})}async function Je(e,t){let a=await Le(e,t);if(a.length===0)throw new Error(`Decision transaction not found: ${t}`);let r=ee(a,M),n=he(r,r.updatedAt,M);return {transaction:r,checkpoint:n,events:a,paths:Ue(e,t)}}function U(e){return L(e).directory}var me={digestCanonical:c},ut="workspai.deleted-artifact-tombstone.v1";function mt(e){let t=e.trim();if(!/^change-[a-z0-9][a-z0-9-]{7,95}$/.test(t))throw new Error(`Invalid proof-carrying change id: ${e}`);return t}function V(e){let a=`.workspai/changes/${mt(e)}`;return {directory:a,lease:`${a}/lease.json`,prediction:`${a}/predicted-overlay.json`,actualOverlay:`${a}/actual-overlay.json`,surprises:`${a}/architecture-surprises.json`,workspaceVerification:`${a}/verification/workspace-verify.json`,capsule:`${a}/capsule.json`,privateBaselineGraph:`${a}/private/baseline-graph.json`}}function wt(e,t){return {kind:e,id:t}}function T(e){return {role:e.role,artifact:e.artifact,schemaVersion:e.schemaVersion,digest:{algorithm:"sha256",semantics:e.semantics??"canonical-json-v1",value:e.value}}}async function A(e,t){let a=await b$1(e,t);return a?await z.readJson(a):null}async function Qe(e,t){let a=await d(e,v(t));return !a||!(await z.stat(a).catch(()=>null))?.isFile()?null:createHash("sha256").update(await z.readFile(a)).digest("hex")}async function yt(e,t){let a=new Map;await Promise.all(t.proofs.map(async n=>{let s=v(n.artifact),d=a.get(s);d||(d=Qe(e,s),a.set(s,d)),await d;}));let r=Object.fromEntries((await Promise.all([...a.entries()].map(async([n,s])=>[n,await s]))).filter(n=>typeof n[1]=="string"));return {...t,pccArtifactContentHashes:r}}async function vt(e){let a=(await A(e,s.workspaceContract.artifactPath))?.workspace?.name;if(typeof a=="string"&&a.trim())return a.trim();let r=await A(e,".workspai/workspace.json"),n=r?.workspace_name??r?.name;return typeof n=="string"&&n.trim()?n.trim():b.basename(e)}async function F(e,t){let a=await c$2(e,t.artifact);if(!a)return false;if(t.digest.semantics==="raw-bytes-v1"){let s=await z.readFile(a);return createHash("sha256").update(s).digest("hex")===t.digest.value}let r=await z.readJson(a).catch(()=>null);return r?(t.digest.semantics==="workspace-model-structural-v1"?d$1(r):c(r))===t.digest.value:false}function Ze(e){return c({schemaVersion:ut,artifact:v(e),deleted:true})}function kt(e){let t=v(e.artifact);if(!t||t==="."||t===".."||t.startsWith("../"))throw new Error(`Deleted artifact identity must be a contained relative path: ${e.artifact}`);return {artifact:t,observedAt:e.observedAt??new Date().toISOString(),digest:{algorithm:"sha256",semantics:"deletion-tombstone-v1",value:Ze(t)}}}async function et(e,t){if(t.digest.algorithm!=="sha256"||t.digest.semantics!=="deletion-tombstone-v1"||t.digest.value!==Ze(t.artifact))return false;let a=await d(e,t.artifact);return a!==null&&!await z.pathExists(a)}async function Pt(e,t){let a=await A(e,V(t).lease);if(!a||a.schemaVersion!==h)throw new Error(`Architecture lease is missing or unsupported for ${t}.`);if(a.changeId!==t)throw new Error(`Architecture lease binding failed for ${t}.`);return a}async function J(e){let t=await a$3(e);if(t.status==="miss")throw new Error(`A current canonical Model and Graph are required (${t.reason}). Run workspai workspace intelligence run --for-agent generic --strict --json.`);return t}function Ct(e,t,a){return c({modelHash:e,graphHash:t,inputHash:a})}function Y(e){let t=d$1(e.model),a=c(e.graph),r=e.graph.source.inputs?.hash;if(!r)throw new Error("The canonical Graph has no live input fingerprint.");return {modelHash:t,graphHash:a,inputHash:r,generation:Ct(t,a,r)}}async function we(e,t){let a=await J(e),r=Y(a);if(r.generation!==t.generation)throw new Error(`Architecture lease ${t.changeId} is stale. Expected generation ${t.generation}, observed ${r.generation}. Abort or begin a new change from current evidence.`);return a}function C(e,t,a,r,n=new Date().toISOString()){return {kind:e,payload:t,occurredAt:n,actor:wt(a,r)}}async function I(e,t,a,r){return Fe({workspacePath:e,transactionId:a,expectedHeadDigest:t?.transaction.eventHeadDigest??null,event:r})}function D(e,t,a){return `${e}\0${t}\0${a}`}var tt="agent-framework-change-plan",It=new Set(["init","test","build"]);function At(e){if(!e.record.transaction.plans.some(n=>n.role===tt))return false;let a=new Set(e.lease.scope.projects),r=e.verify.steps.filter(n=>{if(n.scope!=="project"||!n.project||!a.has(n.project))return false;let s=n.id.split(".").at(-1);return s!==void 0&&It.has(s)});return r.some(n=>n.status==="fail")?false:r.length===0||r.some(n=>n.status==="missing")}function bt(e){let t=[];for(let[a,r]of [["entity",e.entities],["relation",e.relations],["proof",e.proofs]])t.push(...r.added.map(n=>({operation:"add",targetKind:a,targetId:n.id}))),t.push(...r.removed.map(n=>({operation:"remove",targetKind:a,targetId:n.id}))),t.push(...r.changed.map(n=>({operation:"change",targetKind:a,targetId:n.id})));return t.push(...e.changedArtifacts.map(a=>({operation:"change",targetKind:"artifact",targetId:a}))),t.sort((a,r)=>D(a.operation,a.targetKind,a.targetId).localeCompare(D(r.operation,r.targetKind,r.targetId)))}function Et(e,t){let a=new Set(t.filter(o=>o.targetKind==="artifact").map(o=>v(o.targetId)));if(a.size===0)return new Set;let r=new Set,n=new Set,s=(o,c)=>{a.has(v(c.artifact))&&(n.add(c.id),r.add(D(o,"proof",c.id)));};e.proofs.added.forEach(o=>s("add",o)),e.proofs.removed.forEach(o=>s("remove",o)),e.proofs.changed.forEach(o=>{let c=o.after??o.before;c&&s("change",c);});let d=new Set,f=(o,c)=>{c.proofIds.some(h=>n.has(h))&&(d.add(c.id),r.add(D(o,"entity",c.id)));};e.entities.added.forEach(o=>f("add",o)),e.entities.removed.forEach(o=>f("remove",o)),e.entities.changed.forEach(o=>{let c=o.after??o.before;c&&f("change",c);});let l=(o,c)=>{!c.proofIds.some(h=>n.has(h))&&!d.has(c.from)&&!d.has(c.to)||r.add(D(o,"relation",c.id));};return e.relations.added.forEach(o=>l("add",o)),e.relations.removed.forEach(o=>l("remove",o)),e.relations.changed.forEach(o=>{let c=o.after??o.before;c&&l("change",c);}),r}function Dt(e){let t=e.prediction?.operations.map(c=>({operation:c.operation,targetKind:c.targetKind,targetId:c.targetId}))??[],a=bt(e.actual),r=new Set(t.map(c=>D(c.operation,c.targetKind,c.targetId))),n=new Set(a.map(c=>D(c.operation,c.targetKind,c.targetId))),s=Et(e.actual,t),d=a.filter(c=>r.has(D(c.operation,c.targetKind,c.targetId))||s.has(D(c.operation,c.targetKind,c.targetId))),f=a.filter(c=>!r.has(D(c.operation,c.targetKind,c.targetId))&&!s.has(D(c.operation,c.targetKind,c.targetId))),l=t.filter(c=>!n.has(D(c.operation,c.targetKind,c.targetId))),o=e.prediction?f.length===0&&l.length===0&&s.size===0?"exact":f.length===0?"within-expectation":"surprising":"no-prediction";return {schemaVersion:j$1,changeId:e.changeId,generatedAt:e.generatedAt,prediction:e.predictionReference,actual:e.actualReference,matched:d,unpredicted:f,missing:l,summary:{predicted:t.length,actual:a.length,matched:d.length,unpredicted:f.length,missing:l.length,verdict:o}}}async function pe(e){let t=await A(e.workspacePath,e.relativePath);return t?T({role:e.role,artifact:e.relativePath,schemaVersion:e.schemaVersion,value:c(t)}):null}function Rt(e){let{integrity:t,...a}=e;return a}async function ye(e){let t=V(e.lease.changeId),[a,r,n]=await Promise.all([pe({workspacePath:e.workspacePath,relativePath:t.prediction,role:"prediction",schemaVersion:i$1}),pe({workspacePath:e.workspacePath,relativePath:t.actualOverlay,role:"actual-architecture-overlay",schemaVersion:a$5}),pe({workspacePath:e.workspacePath,relativePath:t.surprises,role:"architecture-surprises",schemaVersion:j$1})]),s=T({role:"decision-transaction",artifact:`${U(e.lease.changeId)}/transaction.json`,schemaVersion:e.record.transaction.schemaVersion,value:c(e.record.transaction)}),d=e.record.transaction.effects.flatMap(g=>g.artifacts),f=e.record.transaction.effects.flatMap(g=>g.deletedArtifacts??[]),l=e.record.transaction.verifications.flatMap(g=>g.artifacts),o=await A(e.workspacePath,t.actualOverlay),c$1=o?!ue(o):false,h=[{id:"intent-bound",status:"passed",summary:"The transaction is hash-bound to its immutable Goal Pack."},{id:"baseline-pinned",status:"passed",summary:"The architecture lease pins exact Model, Graph, and live-input identities."},{id:"effects-receipted",status:e.record.transaction.effects.length>0&&e.record.transaction.effects.every(g=>g.status==="succeeded")||e.record.transaction.effects.length===0&&c$1?"passed":e.record.transaction.effects.length===0?"pending":"failed",summary:e.record.transaction.effects.length===0&&c$1?"Fresh Graph observation proves this was a no-effect change.":`${e.record.transaction.effects.length} typed effect receipt(s) are bound to the transaction ledger.`},{id:"architecture-reobserved",status:r?"passed":"pending",summary:r?"The actual architecture delta was derived from a fresh canonical Graph.":"No post-effect architecture overlay has been observed yet."},{id:"independently-verified",status:e.record.transaction.state==="committed"?"passed":e.record.transaction.verifications.some(g=>g.status==="failed")?"failed":"pending",summary:`${e.record.transaction.verifications.length} independent verification receipt(s) are recorded.`}],y=await A(e.workspacePath,t.surprises),p=[...e.record.transaction.effects.length===0&&o&&ue(o)?["No typed effect receipt explains the observed architecture generation."]:[],...y?.summary.unpredicted?[`${y.summary.unpredicted} actual architecture operation(s) were not predicted.`]:[],...e.record.transaction.blockers.map(g=>g.details??g.code)],k$1=e.record.transaction.state==="committed"?"sealed":e.record.transaction.state==="aborted"?"aborted":e.record.transaction.state==="blocked"||e.record.transaction.state==="awaiting-human"?"blocked":e.record.transaction.state==="verifying"&&e.record.transaction.verifications.some(g=>g.status==="passed")?"verified":"open",i={schemaVersion:k,changeId:e.lease.changeId,goalId:e.lease.goalId,generatedAt:e.record.transaction.updatedAt,status:k$1,workspace:e.lease.workspace,scope:e.lease.scope,decision:{transaction:s,eventHeadDigest:e.record.transaction.eventHeadDigest,effectHeadDigest:te(e.record.transaction,me),state:e.record.transaction.state,generation:e.record.transaction.generation},intent:e.record.transaction.intent,baseline:e.lease.baseline,prediction:a,actualOverlay:r,surpriseReport:n,effects:d,deletedArtifacts:f,verification:l,assurances:h,remainingUncertainty:[...new Set(p)]};return {...i,integrity:{algorithm:"sha256",semantics:"canonical-json-v1",capsuleDigest:c(i)}}}async function O(e,t,a){let r=await ye({workspacePath:e,lease:t,record:a});return await h$1(e,V(t.changeId).capsule,r),r}function j(e){let t=V(e.lease.changeId),a$1={schemaVersion:l$1,operation:e.operation,changeId:e.lease.changeId,state:e.record.transaction.state,capsule:e.capsule,artifacts:{lease:t.lease,prediction:e.capsule.prediction?.artifact??null,actualOverlay:e.capsule.actualOverlay?.artifact??null,surpriseReport:e.capsule.surpriseReport?.artifact??null,transaction:`${U(e.lease.changeId)}/transaction.json`,events:`${U(e.lease.changeId)}/events.jsonl`,capsule:t.capsule},nextActions:e.nextActions};return a(a$1,"contracts/workspace-intelligence/change-operation-result.v1.json","Proof-Carrying Change operation result"),b$2({kind:"operation.completed",status:e.record.transaction.state==="blocked"||e.record.transaction.state==="awaiting-human"?"blocked":e.record.transaction.state==="aborted"?"cancelled":"succeeded",component:"proof-carrying-change",correlationId:e.lease.changeId,message:`${e.operation}: ${e.record.transaction.state}`,evidenceBindings:[{kind:"artifact",ref:t.capsule,role:"output",provenance:"authoritative"},{kind:"artifact",ref:`${U(e.lease.changeId)}/transaction.json`,role:"subject",provenance:"authoritative"}],attributes:{operation:e.operation,changeId:e.lease.changeId,goalId:e.lease.goalId,decisionState:e.record.transaction.state,assurancePassed:e.capsule.assurances.filter(r=>r.status==="passed").length,assuranceTotal:e.capsule.assurances.length}}),a$1}async function R(e,t){let a=await Pt(e,t),r=await Je(e,t);return {lease:a,record:r}}async function da(e){let t=b.resolve(e.workspacePath),a=await l({workspacePath:t,goalId:e.goalId,validateBindings:true}),r=a.goalPack;if(!r||!a.active)throw new Error("No active Goal Pack is available, or the named Goal is not active.");if(r.state!=="ready-to-plan")throw new Error(`Goal ${r.id} cannot begin a change while its state is ${r.state}.`);let n=await J(t),s=Y(n);if(s.modelHash!==r.sourceBinding.model.hash||(r.sourceBinding.graph.inputHash?s.inputHash!==r.sourceBinding.graph.inputHash:s.graphHash!==r.sourceBinding.graph.hash))throw new Error(`Goal ${r.id} is no longer bound to the current architecture generation.`);let d=`change-${r.intent.category}-${randomUUID().replace(/-/g,"").slice(0,16)}`,f=V(d),l$1=new Date().toISOString(),o=await yt(t,n.graph),c$1=c(o),h$1={schemaVersion:h,changeId:d,goalId:r.id,createdAt:l$1,workspace:r.workspace,scope:{kind:r.scope.kind,projects:[...r.scope.projects]},baseline:{model:T({role:"baseline-model",artifact:r.sourceBinding.model.artifact,schemaVersion:r.sourceBinding.model.schemaVersion,value:r.sourceBinding.model.hash,semantics:"workspace-model-structural-v1"}),graph:{...T({role:"baseline-graph",artifact:r.sourceBinding.graph.artifact,schemaVersion:r.sourceBinding.graph.schemaVersion,value:s.graphHash}),inputHash:s.inputHash}},generation:s.generation,semantics:"optimistic-generation-guard",privateMaterialization:{artifact:f.privateBaselineGraph,role:"hash-bound-baseline-cache",portable:false,authoritative:false,digest:{algorithm:"sha256",semantics:"canonical-json-v1",value:c$1}}};await i(t,f.lease,[{relativePath:f.privateBaselineGraph,payload:o},{relativePath:f.lease,payload:h$1}]);let y=e.actorKind??"cli",p=e.actorId??"workspai-change",k=T({role:"intent",artifact:a.active.goalPack,schemaVersion:r.schemaVersion,value:c(r)}),i$1=r.successCriteria.map(E=>T({role:"success-criterion",artifact:E.id,schemaVersion:"workspai.goal-success-criterion.v1",value:c(E)})),g=await I(t,null,d,C("created",{summary:`Begin proof-carrying change for ${r.id}.`,references:[k,...i$1]},y,p,l$1));g=await I(t,g,d,C("scope-bound",{summary:"Bind immutable Goal scope.",scope:h$1.scope},y,p)),g=await I(t,g,d,C("evidence-attached",{summary:"Attach exact architecture generation and lease.",references:[h$1.baseline.model,{role:h$1.baseline.graph.role,artifact:h$1.baseline.graph.artifact,schemaVersion:h$1.baseline.graph.schemaVersion,digest:h$1.baseline.graph.digest},T({role:"architecture-lease",artifact:f.lease,schemaVersion:h$1.schemaVersion,value:c(h$1)})]},y,p)),await q({workspacePath:t,goalId:r.id,changeId:d});let P=await O(t,h$1,g);return j({operation:"begin",lease:h$1,record:g,capsule:P,nextActions:[`workspai change predict --change ${d} --file <prediction.json> --json`,`workspai change authorize --change ${d} --effects filesystem,command --json`]})}async function la(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId);if(await we(e.workspacePath,t),a.transaction.state!=="evidence-ready")throw new Error(`Prediction requires evidence-ready state, observed ${a.transaction.state}.`);let r={...e.prediction,schemaVersion:i$1,changeId:e.changeId,goalId:t.goalId,baselineGeneration:t.generation,nonCanonical:true,proofEligible:false,operations:[...e.prediction.operations].sort((f,l)=>D(f.operation,f.targetKind,f.targetId).localeCompare(D(l.operation,l.targetKind,l.targetId)))};await h$1(e.workspacePath,V(e.changeId).prediction,r);let n=T({role:"noncanonical-prediction",artifact:V(e.changeId).prediction,schemaVersion:r.schemaVersion,value:c(r)}),s=await I(e.workspacePath,a,e.changeId,C("plan-attached",{summary:"Attach an explicitly noncanonical architecture prediction.",references:[n]},e.actorKind??"agent",e.actorId??"workspai-agent")),d=await O(e.workspacePath,t,s);return j({operation:"predict",lease:t,record:s,capsule:d,nextActions:[`workspai change authorize --change ${e.changeId} --effects filesystem,command --json`]})}async function fa(e){let{lease:t,record:a$1}=await R(e.workspacePath,e.changeId);if(await we(e.workspacePath,t),a$1.transaction.state!=="evidence-ready")throw new Error(`Plan attachment requires evidence-ready state, observed ${a$1.transaction.state}.`);let r=e.role.trim().toLowerCase();if(!/^[a-z0-9](?:[a-z0-9.-]{0,62}[a-z0-9])?$/.test(r))throw new Error(`Invalid proof-carrying plan role: ${e.role}`);if(!e.schemaVersion.trim())throw new Error("Plan schema version is required.");let n=e.contractPath.replace(/\\/g,"/");if(!n.startsWith("contracts/")||n.split("/").some(l=>l===".."||l==="."))throw new Error(`Plan contract path must resolve inside the published contract root: ${e.contractPath}`);if(!e.payload||typeof e.payload!="object"||e.payload.schemaVersion!==e.schemaVersion)throw new Error("Plan payload schema version does not match its PCC reference.");a(e.payload,n,`${r} plan`);let s=c(e.payload),d=`${V(e.changeId).directory}/plans/${r}-${s}.json`;await h$1(e.workspacePath,d,e.payload);let f=await I(e.workspacePath,a$1,e.changeId,C("plan-attached",{summary:`Attach ${r} execution plan.`,references:[T({role:r,artifact:d,schemaVersion:e.schemaVersion,value:s})]},e.actorKind??"cli",e.actorId??"workspai-plan"));return await O(e.workspacePath,t,f),{changeId:e.changeId,state:f.transaction.state,artifact:d,digest:s}}async function ga(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId);if(await we(e.workspacePath,t),e.effectClasses.length===0)throw new Error("Authorization requires at least one effect class.");let r=await I(e.workspacePath,a,e.changeId,C("authorized",{summary:`Authorize bounded effect classes: ${e.effectClasses.join(", ")}.`,authorization:{grantedBy:e.grantedBy,grant:"bounded-effects",effectClasses:[...new Set(e.effectClasses)].sort()}},e.actorKind??"human",e.grantedBy)),n=await O(e.workspacePath,t,r);return j({operation:"authorize",lease:t,record:r,capsule:n,nextActions:[`workspai change effect record --change ${e.changeId} --file <effect-receipt.json> --json`,`workspai change verify --change ${e.changeId} --json`]})}async function ha(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId);if(a.transaction.state!=="blocked"&&a.transaction.state!=="awaiting-human")throw new Error(`Resume requires blocked or awaiting-human state, observed ${a.transaction.state}.`);let r=await I(e.workspacePath,a,e.changeId,C("resumed",{summary:e.reason,reason:e.reason,resumeTo:e.resumeTo},"human",e.actorId)),n=await O(e.workspacePath,t,r);return j({operation:"resume",lease:t,record:r,capsule:n,nextActions:e.resumeTo==="verifying"?[`workspai change verification record --change ${e.changeId} --file <verification-receipt.json> --json`]:[`workspai change effect record --change ${e.changeId} --file <effect-receipt.json> --json`]})}async function pa(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId),r=new Set(e.receipt.artifacts.map(f=>v(f.artifact))),n=(e.receipt.deletedArtifacts??[]).map(f=>v(f.artifact));if(new Set(n).size!==n.length)throw new Error("Effect receipt contains duplicate deleted-artifact identities.");if(n.some(f=>r.has(f)))throw new Error("An effect artifact cannot be both present and deleted in one receipt.");if(n.length>0&&e.receipt.status!=="succeeded")throw new Error("Only a succeeded effect may carry deleted-artifact tombstones.");for(let f of e.receipt.artifacts)if(!await F(e.workspacePath,f))throw new Error(`Effect artifact is missing or corrupt: ${f.artifact}`);for(let f of e.receipt.deletedArtifacts??[])if(!await et(e.workspacePath,f))throw new Error(`Deleted effect artifact is present, outside the governed scope, or has an invalid tombstone: ${f.artifact}`);let s=await I(e.workspacePath,a,e.changeId,C("effect-recorded",{summary:e.receipt.summary,effect:e.receipt},e.actorKind??"agent",e.actorId??"workspai-agent")),d=await O(e.workspacePath,t,s);return j({operation:"effect-record",lease:t,record:s,capsule:d,nextActions:s.transaction.state==="blocked"?[`workspai change status --change ${e.changeId} --json`]:[`workspai change verify --change ${e.changeId} --json`]})}async function ua(e){let t=b.resolve(e.workspacePath),{lease:a,record:r}=await R(t,e.changeId);if(!r.transaction.requiredCriteria.includes(e.receipt.criterionId))throw new Error(`Verification criterion '${e.receipt.criterionId}' is outside the immutable Goal contract.`);let n=await J(t),s=V(e.changeId),[d,f]=await Promise.all([A(t,s.actualOverlay),A(t,s.surprises)]),l=r.transaction.verifications.some(i=>i.criterionId==="workspace-verify"&&i.status==="passed");if(!d||!f||!l)throw new Error("Domain verification can be admitted only after change verify re-observes the Graph and records a passing Workspace Verify receipt.");let o=Y(n),c=te(r.transaction,me);if(e.receipt.target.modelHash!==o.modelHash||e.receipt.target.graphHash!==o.graphHash||e.receipt.target.effectHeadDigest!==c)throw new Error("Verification receipt does not target the current Model, Graph, and effect head.");for(let i of e.receipt.artifacts)if(!await F(t,i))throw new Error(`Verification artifact is missing or corrupt: ${i.artifact}`);let h=e.actorKind??"ci",y=e.actorId??"workspai-verifier",p=r;if(p.transaction.state==="blocked"){if(!p.transaction.blockers.every(g=>g.code==="change.verification.criteria_missing"))throw new Error("The change is blocked by a condition that a verification receipt cannot resume.");p=await I(t,p,e.changeId,C("resumed",{summary:"Resume to admit a missing verification receipt.",resumeTo:"verifying"},h,y));}else if(p.transaction.state!=="verifying")throw new Error(`Verification receipt requires verifying or criteria-blocked state; observed ${p.transaction.state}.`);p=await I(t,p,e.changeId,C("verification-recorded",{summary:e.receipt.summary,verification:e.receipt},h,y)),p.transaction.state==="verifying"&&p.transaction.requiredCriteria.every(g=>p.transaction.verifications.filter(E=>E.criterionId===g).at(-1)?.status==="passed")&&(p=await I(t,p,e.changeId,C("committed",{summary:"Seal the independently verified proof-carrying change."},h,y)));let k=await O(t,a,p);return j({operation:"verification-record",lease:a,record:p,capsule:k,nextActions:p.transaction.state==="committed"?[`workspai change capsule validate --change ${e.changeId} --json`]:[`workspai change status --change ${e.changeId} --json`]})}function ae(e,t,a,r="verification"){return T({role:r,artifact:e,schemaVersion:t,value:c(a)})}function ue(e){return e.summary.entityAdds+e.summary.entityRemovals+e.summary.entityChanges+e.summary.relationAdds+e.summary.relationRemovals+e.summary.relationChanges+e.summary.proofAdds+e.summary.proofRemovals+e.summary.proofChanges>0}function v(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function $t(e){if(e.scope.kind==="workspace")return e.overlay;let t=new Set(e.scope.projects),a=i=>!!(i.projectId&&t.has(i.projectId)),r={added:e.overlay.entities.added.filter(a),removed:e.overlay.entities.removed.filter(a),changed:e.overlay.entities.changed.filter(i=>a(i.after??i.before??{}))},n=i=>e.scopedEntityIds.has(i.from)||e.scopedEntityIds.has(i.to),s={added:e.overlay.relations.added.filter(n),removed:e.overlay.relations.removed.filter(n),changed:e.overlay.relations.changed.filter(i=>{let g=i.after??i.before;return !!(g&&n(g))})},d=new Set([...r.added.flatMap(i=>i.proofIds),...r.removed.flatMap(i=>i.proofIds),...r.changed.flatMap(i=>[...i.before?.proofIds??[],...i.after?.proofIds??[]]),...s.added.flatMap(i=>i.proofIds),...s.removed.flatMap(i=>i.proofIds),...s.changed.flatMap(i=>[...i.before?.proofIds??[],...i.after?.proofIds??[]])]),f=i=>{let g=v(i);return e.projectPrefixes.includes(".")?true:e.projectPrefixes.some(P=>g===P||g.startsWith(`${P}/`))},l=i=>d.has(i.id)||f(i.artifact),o={added:e.overlay.proofs.added.filter(l),removed:e.overlay.proofs.removed.filter(l),changed:e.overlay.proofs.changed.filter(i=>{let g=i.after??i.before;return !!(g&&l(g))})},c=e.overlay.impactedEntityIds.filter(i=>e.scopedEntityIds.has(i)),h=e.overlay.changedArtifacts.filter(f),y=r.removed.length+s.removed.length+o.removed.length,p=y+r.added.length+r.changed.length+s.added.length+s.changed.length+o.added.length+o.changed.length,k=p===0?"none":y>0||c.length>=10?"high":c.length>=5||p>=5?"medium":"low";return {...e.overlay,entities:r,relations:s,proofs:o,impactedEntityIds:c,changedArtifacts:h,summary:{entityAdds:r.added.length,entityRemovals:r.removed.length,entityChanges:r.changed.length,relationAdds:s.added.length,relationRemovals:s.removed.length,relationChanges:s.changed.length,proofAdds:o.added.length,proofRemovals:o.removed.length,proofChanges:o.changed.length,impactedEntities:c.length,changedArtifacts:h.length,risk:k}}}function Ye(e){let t=b.normalize(b.resolve(e));return process.platform==="win32"?t.toLowerCase():t}async function St(e){let t=new Set(e.receiptedArtifacts.map(v)),a=new Set;for(let n of t){let s=await d(e.workspacePath,n);s&&a.add(Ye(s));}let r=[];for(let n of e.changedArtifacts){let s=v(n);if(t.has(s))continue;let d$1=await d(e.workspacePath,s);d$1&&a.has(Ye(d$1))||r.push(n);}return r}function Vt(e){let t=v(e.artifact);return e.receiptedArtifacts.has(t)||e.scope.kind==="workspace"||e.projectPrefixes.includes(".")?true:e.projectPrefixes.some(a=>t===a||t.startsWith(`${a}/`))}async function xt(e){let t=v(e.artifact),a=f=>{let l=f.proofs.filter(o=>v(o.artifact)===t);return l.length===0?[]:l.some(o=>!o.contentHash)?null:[...new Set(l.map(o=>o.contentHash))].sort()},r=a(e.baseline),n=a(e.head),s=await Qe(e.workspacePath,t),d=e.baseline.pccArtifactContentHashes?.[t];return d?s===null||s!==d:r&&r.length>0?s===null||!r.includes(s):r&&r.length===0?s!==null||!!n?.length:r===null||n===null?true:c(r)!==c(n)}async function ma(e){let t=b.resolve(e.workspacePath),{lease:a,record:r}=await R(t,e.changeId);if(r.transaction.state!=="authorized"&&r.transaction.state!=="executing")throw new Error(`Verification requires authorized or executing state, observed ${r.transaction.state}.`);e.refresh!==false&&await c$1({workspacePath:t,strict:false,agent:"generic"});let n=await J(t),s=await A(t,a.privateMaterialization.artifact);if(!s||c(s)!==a.privateMaterialization.digest.value)throw new Error(`The hash-bound baseline materialization is missing or corrupt for ${e.changeId}.`);let d=new Date().toISOString(),f$1=n.model.projects.filter(w=>a.scope.projects.includes(w.name)).map(w=>v(w.path).replace(/\/$/u,"")).filter(Boolean),l=$t({overlay:a$1(s,n.graph,new Date(d)),scope:a.scope,projectPrefixes:f$1,scopedEntityIds:new Set([...s.entities,...n.graph.entities].filter(w=>w.projectId&&a.scope.projects.includes(w.projectId)).map(w=>w.id))}),o=V(e.changeId);await h$1(t,o.actualOverlay,l);let c$2=ae(o.actualOverlay,l.schemaVersion,l,"actual-architecture-overlay"),h=await A(t,o.prediction),y=h?ae(o.prediction,h.schemaVersion,h,"noncanonical-prediction"):null,p=Dt({changeId:e.changeId,generatedAt:d,prediction:h,predictionReference:y,actual:l,actualReference:c$2});await h$1(t,o.surprises,p);let k=ae(o.surprises,p.schemaVersion,p,"architecture-surprises"),i=r,g$1=e.actorKind??"cli",P=e.actorId??"workspai-change-verify";if(ue(l)&&i.transaction.effects.length===0){i=await I(t,i,e.changeId,C("blocked",{summary:"Observed architecture change has no typed effect receipt.",blocker:{code:"change.effect_receipt.missing",actionable:true,details:"Record the actual mutation effect before verification can claim causality."}},g$1,P));let w=await O(t,a,i);return j({operation:"verify",lease:a,record:i,capsule:w,nextActions:[`workspai change resume --change ${e.changeId} --to authorized --reason "Record missing effect receipt" --json`]})}let E=i.transaction.effects.filter(w=>w.status==="succeeded").flatMap(w=>[...w.artifacts.map(x=>x.artifact),...(w.deletedArtifacts??[]).map(x=>x.artifact)]),G=new Set(E.map(v)),$=(await Promise.all(l.changedArtifacts.map(async w=>({artifact:w,contentChanged:await xt({workspacePath:t,artifact:w,baseline:s,head:n.graph})})))).filter(({artifact:w,contentChanged:x})=>x&&Vt({artifact:w,scope:a.scope,projectPrefixes:f$1,receiptedArtifacts:G})).map(({artifact:w})=>w),S=await St({workspacePath:t,changedArtifacts:$,receiptedArtifacts:E});if(S.length>0){i=await I(t,i,e.changeId,C("blocked",{summary:"Observed architecture artifacts are not covered by typed effect receipts.",blocker:{code:"change.effect_receipt.coverage_missing",actionable:true,details:`Uncovered artifacts: ${S.slice(0,20).join(", ")}`}},g$1,P));let w=await O(t,a,i);return j({operation:"verify",lease:a,record:i,capsule:w,nextActions:[`workspai change resume --change ${e.changeId} --to authorized --reason "Cover observed artifacts" --json`]})}let K=await f({workspacePath:t});if(!h$2(K,{strict:e.strict===true}).passed&&At({record:i,lease:a,verify:K})){await g(K,t);let w=await O(t,a,i),x=a.scope.projects[0];return j({operation:"verify",lease:a,record:i,capsule:w,nextActions:[...x?[`workspai workspace run init --workspace ${JSON.stringify(t)} --scope ${JSON.stringify(x)} --json`,`workspai workspace run test --workspace ${JSON.stringify(t)} --scope ${JSON.stringify(x)} --json`,`workspai workspace run build --workspace ${JSON.stringify(t)} --scope ${JSON.stringify(x)} --json`]:[],`workspai change verify --change ${e.changeId} --json`]})}i=await I(t,i,e.changeId,C("verification-started",{summary:"Begin independent post-effect verification."},g$1,P));let X=await g(K,t),ke=b.relative(t,X).split(b.sep).join("/"),re=await A(t,ke);if(!re)throw new Error(`Workspace Verify evidence was not persisted at ${ke}.`);await h$1(t,o.workspaceVerification,re);let Q=await A(t,o.workspaceVerification);if(!Q)throw new Error(`Change-scoped Workspace Verify evidence was not persisted at ${o.workspaceVerification}.`);let N=h$2(re,{strict:e.strict===true}),Pe=Y(n),Ce={id:`verify-workspace-${c({generatedAt:d,verify:Q,gate:N}).slice(0,16)}`,criterionId:"workspace-verify",status:N.passed?"passed":"failed",summary:N.passed?`Workspace Verify passed in ${N.mode} mode.`:`Workspace Verify blocked in ${N.mode} mode: ${N.reasons.join("; ")}`,target:{modelHash:Pe.modelHash,graphHash:Pe.graphHash,effectHeadDigest:te(i.transaction,me)},artifacts:[ae(o.workspaceVerification,Q.schemaVersion,Q),c$2,k],observedAt:d};if(i=await I(t,i,e.changeId,C("verification-recorded",{summary:Ce.summary,verification:Ce},g$1,P)),i.transaction.state==="verifying"){let w=i.transaction.requiredCriteria.filter(x=>i.transaction.verifications.filter(rt=>rt.criterionId===x).at(-1)?.status!=="passed");w.length>0?i=await I(t,i,e.changeId,C("blocked",{summary:"Required outcome verification is incomplete.",blocker:{code:"change.verification.criteria_missing",actionable:true,details:`Missing passing receipts: ${w.join(", ")}`}},g$1,P)):i=await I(t,i,e.changeId,C("committed",{summary:"Seal the independently verified proof-carrying change."},g$1,P));}let at=await O(t,a,i);return j({operation:"verify",lease:a,record:i,capsule:at,nextActions:i.transaction.state==="committed"?[`workspai change capsule validate --change ${e.changeId} --json`]:[`workspai change status --change ${e.changeId} --json`]})}async function wa(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId),r=await ye({workspacePath:e.workspacePath,lease:t,record:a});return j({operation:e.operation??"status",lease:t,record:a,capsule:r,nextActions:a.transaction.state==="evidence-ready"?[`workspai change authorize --change ${e.changeId} --effects filesystem,command --json`]:a.transaction.state==="authorized"||a.transaction.state==="executing"?[`workspai change verify --change ${e.changeId} --json`]:[]})}async function ya(e){let t=b.resolve(e.workspacePath),a$1=await b$1(t,".workspai/changes","directory"),n=(a$1?await z.readdir(a$1,{withFileTypes:true}):[]).filter(l=>l.isDirectory()&&/^change-[a-z0-9][a-z0-9-]{7,95}$/.test(l.name)).map(l=>l.name).sort(),s=[],d=null;for(let l of n)try{let{lease:o,record:c}=await R(t,l);d??=o.workspace.name;let h=await ye({workspacePath:t,lease:o,record:c}),y=await ve({workspacePath:t,changeId:l}),p=c.transaction.blockers.map(i=>i.details??i.code),k=h.status==="blocked"?h.assurances.filter(i=>i.status==="failed").map(i=>`${i.id}: ${i.summary}`):[];s.push({changeId:l,goalId:o.goalId,state:c.transaction.state,status:h.status,createdAt:c.transaction.createdAt,updatedAt:c.transaction.updatedAt,scope:o.scope,assurance:{passed:h.assurances.filter(i=>i.status==="passed").length,total:h.assurances.length},blockers:[...new Set([...p,...k])],capsuleArtifact:V(l).capsule,valid:y.valid,errors:y.errors});}catch(o){s.push({changeId:l,goalId:null,state:null,status:"invalid",createdAt:null,updatedAt:null,scope:null,assurance:{passed:0,total:5},blockers:[],capsuleArtifact:V(l).capsule,valid:false,errors:[o instanceof Error?o.message:String(o)]});}s.sort((l,o)=>(o.updatedAt??"").localeCompare(l.updatedAt??"")||l.changeId.localeCompare(o.changeId));let f={schemaVersion:m,generatedAt:new Date().toISOString(),workspace:{name:d??await vt(t)},changes:s,summary:{total:s.length,open:s.filter(l=>l.status==="open"||l.status==="verified").length,blocked:s.filter(l=>l.status==="blocked").length,sealed:s.filter(l=>l.status==="sealed").length,aborted:s.filter(l=>l.status==="aborted").length,invalid:s.filter(l=>!l.valid).length}};return a(f,"contracts/workspace-intelligence/proof-carrying-change-list.v1.json","Proof-Carrying Change list"),f}async function va(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId),r=await I(e.workspacePath,a,e.changeId,C("aborted",{summary:e.reason,reason:e.reason},"human",e.actorId)),n=await O(e.workspacePath,t,r);return j({operation:"abort",lease:t,record:r,capsule:n,nextActions:[]})}async function ve(e){let t=V(e.changeId),a$1=await A(e.workspacePath,t.capsule);if(!a$1)throw new Error(`Proof-carrying change capsule not found: ${e.changeId}`);let r=[];a$1.schemaVersion!==k&&r.push(`Unsupported capsule schema: ${a$1.schemaVersion}`),a$1.changeId!==e.changeId&&r.push("Capsule change binding does not match."),c(Rt(a$1))!==a$1.integrity.capsuleDigest&&r.push("Capsule integrity digest does not match its canonical content.");let{lease:n$1,record:s}=await R(e.workspacePath,e.changeId),d=s.transaction.evidence.find(o=>o.role==="architecture-lease");(!d||d.digest.value!==c(n$1))&&r.push("Architecture lease does not match the decision-ledger evidence binding."),(n$1.goalId!==a$1.goalId||n$1.generation!==c({modelHash:n$1.baseline.model.digest.value,graphHash:n$1.baseline.graph.digest.value,inputHash:n$1.baseline.graph.inputHash}))&&r.push("Architecture lease identity or generation binding is invalid."),s.transaction.eventHeadDigest!==a$1.decision.eventHeadDigest&&r.push("Capsule does not bind the current decision event head."),c(s.transaction)!==a$1.decision.transaction.digest.value&&r.push("Decision transaction projection digest does not match the capsule.");let f=await A(e.workspacePath,n$1.privateMaterialization.artifact);(!f||c(f)!==n$1.privateMaterialization.digest.value)&&r.push("Hash-bound baseline materialization is missing or corrupt.");for(let o of [a$1.intent,a$1.decision.transaction,a$1.prediction,a$1.actualOverlay,a$1.surpriseReport,...a$1.effects,...a$1.verification].filter(c=>!!c))await F(e.workspacePath,o)||r.push(`Referenced artifact is missing or corrupt: ${o.artifact}`);for(let o of a$1.deletedArtifacts??[])await et(e.workspacePath,o)||r.push(`Deleted artifact tombstone is invalid or the artifact exists again: ${o.artifact}`);let l={schemaVersion:n,changeId:e.changeId,validatedAt:new Date().toISOString(),valid:r.length===0,errors:r,capsule:a$1};return a(l,"contracts/workspace-intelligence/proof-carrying-change-capsule-validation.v1.json","Proof-Carrying Change capsule validation"),l}async function ka(e){let t=await ve(e);if(!t.valid)throw new Error(`Cannot export an invalid capsule: ${t.errors.join("; ")}`);let a$1=b.resolve(e.workspacePath),r=b.resolve(a$1,e.outputPath),n=b.relative(a$1,r);if(n===".."||n.startsWith(`..${b.sep}`)||b.isAbsolute(n))throw new Error("Capsule export path must remain inside the workspace.");let s=n.split(b.sep).join("/"),d=await h$1(a$1,s,t.capsule),f={schemaVersion:o,changeId:e.changeId,outputPath:d,validation:t};return a(f,"contracts/workspace-intelligence/proof-carrying-change-capsule-export.v1.json","Proof-Carrying Change capsule export"),f}function Pa(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Prediction input must be a JSON object.");let t=e;if(!Array.isArray(t.operations)||!Array.isArray(t.assumptions))throw new Error("Prediction input requires operations[] and assumptions[].");let a=new Set(["add","remove","change"]),r=new Set(["entity","relation","proof","artifact"]),n=new Set(["high","medium","low"]);for(let d of t.operations)if(!d||!a.has(d.operation)||!r.has(d.targetKind)||typeof d.targetId!="string"||d.targetId.trim().length===0||typeof d.rationale!="string"||!n.has(d.confidence))throw new Error("Prediction contains an invalid operation.");let s=t.predictedRisk;if(!s||!["none","low","medium","high"].includes(s))throw new Error("Prediction requires predictedRisk: none, low, medium, or high.");return {schemaVersion:i$1,changeId:t.changeId??"change-placeholder",goalId:t.goalId??"goal-placeholder",generatedAt:t.generatedAt??new Date().toISOString(),baselineGeneration:t.baselineGeneration??"pending-binding",nonCanonical:true,proofEligible:false,operations:t.operations,assumptions:t.assumptions.filter(d=>typeof d=="string"),predictedRisk:s}}function Ca(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Effect receipt input must be a JSON object.");let t=e;if(typeof t.id!="string"||!["filesystem","command","configuration","dependency","external"].includes(String(t.effectClass))||!["succeeded","failed","uncertain"].includes(String(t.status))||typeof t.summary!="string"||typeof t.observedAt!="string"||typeof t.idempotencyKey!="string"||!Array.isArray(t.artifacts))throw new Error("Effect receipt is missing required typed fields.");if(t.deletedArtifacts!==void 0&&(!Array.isArray(t.deletedArtifacts)||t.deletedArtifacts.some(r=>!r||typeof r.artifact!="string"||r.observedAt!==void 0&&typeof r.observedAt!="string"||r.digest!==void 0&&(r.digest.algorithm!=="sha256"||r.digest.semantics!=="deletion-tombstone-v1"||typeof r.digest.value!="string"))))throw new Error("Effect receipt contains an invalid deleted-artifact tombstone.");let a=t;return {...a,...a.deletedArtifacts?{deletedArtifacts:a.deletedArtifacts.map(r=>r.digest?r:kt({artifact:r.artifact,observedAt:r.observedAt??a.observedAt}))}:{}}}function Ia(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Verification receipt input must be a JSON object.");let t=e;if(typeof t.id!="string"||typeof t.criterionId!="string"||!["passed","failed","inconclusive"].includes(String(t.status))||typeof t.summary!="string"||typeof t.observedAt!="string"||!t.target||typeof t.target.modelHash!="string"||typeof t.target.graphHash!="string"||typeof t.target.effectHeadDigest!="string"||!Array.isArray(t.artifacts))throw new Error("Verification receipt is missing required typed fields.");return t}function Aa(e,t){return e.decision.eventHeadDigest===t.eventHeadDigest&&e.decision.transaction.digest.value===c(t)}async function ba(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId);if(t.goalId!==e.goalId)throw new Error(`Proof-carrying change ${e.changeId} is not bound to Goal ${e.goalId}.`);let r=new Set(["authorized","executing","verifying"]),n=a.transaction.state==="blocked"&&a.transaction.blockers.length>0&&a.transaction.blockers.every(i=>i.code==="change.verification.criteria_missing");if(!r.has(a.transaction.state)&&!n)throw new Error(`Proof-carrying change ${e.changeId} is not an applied scaffold pending verification.`);let s=a.transaction.effects.filter(i=>i.effectClass==="filesystem");if(s.length===0)throw new Error(`Proof-carrying change ${e.changeId} has no succeeded filesystem effect receipt.`);if(s.some(i=>i.status!=="succeeded"||i.artifacts.length===0))throw new Error(`Proof-carrying change ${e.changeId} has incomplete or unsuccessful filesystem effects.`);for(let i of s)for(let g of i.artifacts)if(!await F(e.workspacePath,g))throw new Error(`Proof-carrying change ${e.changeId} no longer matches effect artifact ${g.artifact}.`);let d=a.transaction.plans.find(i=>i.role===tt);if(d){let i=await A(e.workspacePath,d.artifact);if(!i||c(i)!==d.digest.value)throw new Error(`Proof-carrying change ${e.changeId} has a missing or corrupt agent framework plan.`);let g=i.target,P=typeof g?.artifactPrefix=="string"?v(g.artifactPrefix).replace(/\/$/u,""):"",E=Array.isArray(i.files)?i.files.flatMap(S=>{if(!S||typeof S!="object")return [];let K=S.path;if(typeof K!="string")return [];let X=v(K);return [P?`${P}/${X}`:X]}):[],G=new Set(s.flatMap(S=>S.artifacts.map(K=>v(K.artifact)))),$=E.filter(S=>!G.has(S));if(E.length===0||$.length>0)throw new Error(`Proof-carrying change ${e.changeId} has a partial filesystem effect receipt.`)}let f=await J(e.workspacePath),l=Y(f),o=await A(e.workspacePath,t.privateMaterialization.artifact);if(!o||c(o)!==t.privateMaterialization.digest.value)throw new Error(`Proof-carrying change ${e.changeId} has a missing or corrupt architecture baseline.`);let c$1=a$1(o,f.graph),h=new Set,y=await b$1(e.workspacePath,".workspai/changes","directory"),p=y?await z.readdir(y,{withFileTypes:true}):[];for(let i of p){if(!i.isDirectory()||!/^change-[a-z0-9][a-z0-9-]{7,95}$/.test(i.name))continue;let g=await R(e.workspacePath,i.name).catch(()=>null);if(!g||g.record.transaction.createdAt<t.createdAt)continue;let P=g.record.transaction.effects.filter($=>$.effectClass==="filesystem"&&$.status==="succeeded");if(P.length===0)continue;for(let $ of P)for(let S of $.artifacts)await F(e.workspacePath,S)&&h.add(v(S.artifact));let E=g.record.transaction.plans.find($=>$.role==="noncanonical-prediction");if(!E)continue;let G=await A(e.workspacePath,E.artifact);if(!(!G||c(G)!==E.digest.value))for(let $ of G.operations)$.targetKind==="artifact"&&h.add(v($.targetId));}let k=c$1.changedArtifacts.map(v).filter(i=>!h.has(i));if(k.length>0)throw new Error(`Proof-carrying change ${e.changeId} does not explain current architecture artifacts: ${k.slice(0,3).join(", ")}.`);return {modelHash:l.modelHash,graphHash:l.graphHash}}async function Ea(e){let t=await ve({workspacePath:e.workspacePath,changeId:e.changeId});if(!t.valid)throw new Error(`Proof-carrying change ${e.changeId} failed capsule validation.`);let{lease:a,record:r}=await R(e.workspacePath,e.changeId);if(a.goalId!==e.goalId||r.transaction.state!=="committed"||t.capsule.status!=="sealed")throw new Error(`Proof-carrying change ${e.changeId} is not a sealed change for ${e.goalId}.`);let n=[...r.transaction.verifications].reverse().find(s=>s.status==="passed");if(!n)throw new Error(`Proof-carrying change ${e.changeId} has no passing verification receipt.`);return {modelHash:n.target.modelHash,graphHash:n.target.graphHash}}
|
|
4
4
|
export{Je as a,kt as b,da as c,la as d,fa as e,ga as f,ha as g,pa as h,ua as i,St as j,ma as k,wa as l,ya as m,va as n,ve as o,ka as p,Pa as q,Ca as r,Ia as s,Aa as t,ba as u,Ea as v};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b as b$1}from'./chunk-B6FJ6RG6.js';import {N,M,k as k$1,q as q$1,G,I,O as O$1}from'./chunk-HB3ZYG2Z.js';import {c}from'./chunk-7HV4U2OV.js';import {e,f as f$1}from'./chunk-EFHSRPW7.js';import {b}from'./chunk-UJXE4UAX.js';import {m,l}from'./chunk-VQZ5PI5J.js';import {promises}from'fs';import c$1 from'path';import L,{homedir}from'os';import {pathToFileURL}from'url';import p from'process';import ie from'fs-extra';var y={schemaVersion:"workspai.model-gateway-qualification.v1",workspaiReleaseAuthority:"source-ready",attach:"unsupported",adapters:[{adapterId:"openrouter-typescript",status:"source-ready",platforms:[]},{adapterId:"openrouter-python",status:"source-ready",platforms:[]}]};var R=["ubuntu-latest","macos-latest","windows-latest"];function B(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Model gateway qualification document must be an object.");let t=e;if(!Array.isArray(t.adapters)||t.adapters.length===0)throw new Error("Model gateway qualification document contains no adapters.");let r=new Set;for(let a of t.adapters){if(!a||typeof a.adapterId!="string")throw new Error("Model gateway qualification adapter is missing adapterId.");if(r.has(a.adapterId))throw new Error(`Duplicate model gateway qualification adapter: ${a.adapterId}`);r.add(a.adapterId);let n=N(a.adapterId);if(!n)throw new Error(`Qualification adapter ${a.adapterId} is not in the version baseline.`);if(a.status!=="source-ready"&&a.status!=="qualified")throw new Error(`Invalid qualification status for ${a.adapterId}.`);if(!Array.isArray(a.platforms))throw new Error(`Qualification platforms missing for ${a.adapterId}.`);if(a.status==="source-ready"){if(a.platforms.length!==0)throw new Error(`Source-ready adapter ${a.adapterId} must not record platform qualification.`);continue}let s=new Set;for(let o of a.platforms){if(!o||!R.includes(o.os)||o.result!=="pass"||o.skippedRequiredStage!==false||o.sdkVersion!==n.sdkVersion)throw new Error(`Qualified adapter ${a.adapterId} is missing a valid platform record bound to ${n.sdkVersion}.`);if(s.has(o.os))throw new Error(`Duplicate platform ${o.os} for ${a.adapterId}.`);s.add(o.os);}for(let o of R)if(!s.has(o))throw new Error(`Qualified adapter ${a.adapterId} is missing ${o} evidence.`)}for(let a of M)if(!r.has(a.adapterId))throw new Error(`Baseline adapter ${a.adapterId} has no qualification record.`);let i=t.adapters.every(a=>a.status==="qualified");if(i)throw new Error("All adapters are qualified; release authority must match.")}B(y);var f=y,W=Object.freeze({schemaVersion:f.schemaVersion,workspaiReleaseAuthority:f.workspaiReleaseAuthority,attach:f.attach,adapters:Object.freeze(f.adapters.map(e=>Object.freeze({...e,platforms:Object.freeze(e.platforms.map(t=>Object.freeze(t)))})))}),z=W.workspaiReleaseAuthority;function K(e){return `${e} \xB7 ${z}`}var w=["backend","frontend","desktop","agent","gateway","extension","gaming"],J=[{id:"backend",label:"Backend",hint:"APIs and services"},{id:"frontend",label:"Frontend",hint:"Web applications"},{id:"desktop",label:"Desktop",hint:"Native desktop applications"},{id:"agent",label:"AI Agent",hint:"Governed agent runtimes"},{id:"gateway",label:"AI Gateway",hint:"Unified model access and routing"},{id:"extension",label:"Extension",hint:"Editor and platform extensions"},{id:"gaming",label:"Gaming",hint:"Game runtimes and tooling"}];function X(e){let r=e.label.indexOf(" \u2014 ");return r>=0?e.label.slice(r+3).trim():e.label.trim()}function Z(e){return w.includes(e.category)?e.category:null}function T(e){let t=c().flatMap(o=>{let l=Z(o);return l?[{value:o.id,label:`${D(l)} \xB7 ${X(o)}`,hint:`${o.runtime} \xB7 tested baseline`,name:o.label,category:l}]:[]}),r=k$1().map(o=>({value:o.kitId,label:`Frontend \xB7 ${o.displayName}`,hint:"official \xB7 latest stable",name:`${o.displayName} \u2014 ${o.framework}`,category:"frontend"})),i=q$1().map(o=>({value:o.kitId,label:`${D(o.category)} \xB7 ${o.displayName}`,hint:`${o.runtimeCandidates.join(" + ")} \xB7 official latest stable`,name:`${o.displayName} \u2014 ${o.category}`,category:o.category})),a=G().map(o=>({value:o.id,label:`AI Agent \xB7 ${o.label}`,hint:`${o.runtime} \xB7 ${I(o)?"release-admitted baseline":`${o.stability} \xB7 awaiting release admission`}`,name:o.label,category:"agent"})),n=O$1().map(o=>({value:o.id,label:`AI Gateway \xB7 ${o.label}`,hint:K(o.runtime),name:o.label,category:"gateway"})),s=[...t,...r,...i,...a,...n].filter(o=>!e||o.category===e).sort((o,l)=>{let Q=w.indexOf(o.category),V=w.indexOf(l.category);return Q-V||(o.label??"").localeCompare(l.label??"")});return O(s),s}function Ae(){let e=new Set(T().map(t=>t.category));return J.filter(t=>e.has(t.id)).map(t=>({value:t.id,label:t.label,hint:t.hint}))}function D(e){return e.charAt(0).toUpperCase()+e.slice(1)}function O(e){let t=new Set,r=new Set;for(let i of e){let a=i.label??i.name??String(i.value),n=String(i.value);if(t.has(a))throw new Error(`Duplicate kit picker label: ${a}`);if(r.has(n))throw new Error(`Duplicate kit picker value: ${n}`);t.add(a),r.add(n);}}var te=".workspairc.json",oe=".rapidkitrc.json",re=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"],ae=["workspai.config.json","rapidkit.config.json"];function F(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function k(e,t){let r=t instanceof Error?t.message:String(t),i=e.endsWith(".js")&&/module is not defined in ES module scope/i.test(r)?' CommonJS syntax in a .js config is not valid when the project package uses "type": "module"; rename the file to .cjs or use export default.':"";return `Failed to load Workspai config at ${e}.${i} Cause: ${r}`}async function et(){for(let e$1 of [c$1.join(L.homedir(),te),c$1.join(L.homedir(),oe)])try{let t=await promises.readFile(e$1,"utf-8"),r=JSON.parse(t);return e.debug(`Loaded config from ${e$1}`),r}catch{}return e.debug("No user config found, using defaults"),{}}async function tt(e$1=process.cwd(),t={}){let r=e$1,i=c$1.parse(r).root;for(;r!==i;){for(let a of ae){let n=c$1.join(r,a);try{let s=await promises.readFile(n,"utf-8"),o=JSON.parse(s);if(!o||typeof o!="object"||Array.isArray(o))throw new Error("configuration root must be a JSON object");return e.debug(`Loaded data-only Workspai config from ${a}`),o}catch(s){if(F(s))continue;throw new Error(k(n,s))}}for(let a of re){let n=c$1.join(r,a);try{await promises.access(n);}catch(s){if(F(s))continue;throw new Error(k(n,s))}if(e.debug(`Found config file: ${n}`),!t.trustExecutableConfig)throw new Error(`Refusing to execute Workspai config at ${n} without explicit trust. Use a data-only workspai.config.json file, pass --trust-config, or set WORKSPAI_TRUST_CONFIG=1.`);try{let o=await import(pathToFileURL(n).href),l=o.default||o;return e.debug(`Loaded Workspai config from ${a}`),l}catch(s){throw new Error(k(n,s))}}r=c$1.dirname(r);}return e.debug("No Workspai config file found, using defaults"),{}}function ot(e,t,r){return {author:r.author||t.workspace?.defaultAuthor||e.author,pythonVersion:r.pythonVersion||t.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:r.defaultInstallMethod||t.workspace?.installMethod||e.defaultInstallMethod,defaultKit:r.defaultKit||t.projects?.defaultKit||e.defaultKit,skipGit:r.skipGit??t.projects?.skipGit??e.skipGit,license:r.license||e.license,testRapidKitPath:r.testRapidKitPath||e.testRapidKitPath}}function rt(e){return f$1("DEV_PATH")||e.testRapidKitPath||void 0}var C=class extends Error{constructor(r,i){super(["Workspai workspaces cannot be nested.",`Target: ${r}`,`Containing workspace: ${i}`,"Choose Managed home or pass --output <path> with a location outside the current workspace."].join(`
|
|
2
|
+
`));this.targetPath=r;this.containingWorkspacePath=i;this.name="NestedWorkspaceCreationError";}targetPath;containingWorkspacePath;code="WORKSPACE_NESTING_NOT_SUPPORTED"};async function ne(e){try{return !!await ie.stat(e)}catch{return false}}function se(e,t){let r=e.indexOf(t);if(r>=0&&r+1<e.length)return e[r+1];let i=e.find(a=>a.startsWith(`${t}=`));if(i)return i.slice(t.length+1)}function ce(e){return e.includes("--here")}async function U(e){let t=c$1.resolve(e);for(;;){let r=[c$1.join(t,".workspai-workspace"),c$1.join(t,".rapidkit-workspace"),c$1.join(t,".workspai","workspace.json"),c$1.join(t,".rapidkit","workspace.json")];if((await Promise.all(r.map(ne))).some(Boolean))return t;let i=c$1.dirname(t);if(i===t)return;t=i;}}async function ft(e){let t=c$1.resolve(e),r=await U(c$1.dirname(t));if(r)throw new C(t,r)}async function le(e,t=homedir()){let i=[{value:"managed",label:"Managed home",hint:l(t)}];return await U(e)||i.push({value:"here",label:"Current directory",hint:e}),i}function q(e,t=p.cwd()){if(ce(e))return c$1.resolve(t);let r=se(e,"--output");if(r)return c$1.resolve(r)}function gt(e,t=p.cwd()){let r=c$1.resolve(e),i=c$1.resolve(t),a=c$1.relative(i,r);return a.length>0&&!a.startsWith("..")&&!c$1.isAbsolute(a)?`cd ${a}`:`cd ${r}`}function mt(e,t={}){let r=t.argv??[],i=t.outputParent??q(r,p.cwd());return m(e.trim(),{homeDir:t.homeDir,outputDir:i})}function ht(e,t,r={}){return e?c$1.resolve(e)===c$1.resolve(t)?true:r.outputParent===void 0:false}async function yt(e,t={}){let r=t.cwd??p.cwd(),i=t.homeDir??homedir(),a=q(e,r);if(a!==void 0)return a;let n=t.hasYes??(e.includes("--yes")||e.includes("-y"));if(!(t.interactive??(!n&&!!p.stdin.isTTY&&!b())))return;let o=await le(r,i);if(o.length===1)return;let{location:l}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:o,default:0}]);if(l==="here")return c$1.resolve(r)}export{T as a,Ae as b,et as c,tt as d,ot as e,rt as f,ft as g,gt as h,mt as i,ht as j,yt as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,d}from'./chunk-
|
|
1
|
+
import {b,d}from'./chunk-5OKNWBAN.js';import {g as g$1}from'./chunk-BLEIUQL6.js';import {p,q}from'./chunk-ODK4LCEL.js';import A from'fs-extra';function t(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function S(e){let s=t(e);return !!(s&&s.schemaVersion===q.model&&t(s.workspace)&&Array.isArray(s.projects)&&(t(s.projectTopology)||t(s.graph)))}function W(e){let s=t(e);return !!(s&&s.schemaVersion===q.knowledgeGraph&&t(s.source)&&t(s.workspace)&&Array.isArray(s.entities)&&Array.isArray(s.relations)&&Array.isArray(s.proofs)&&Array.isArray(s.providers)&&t(s.quality))}async function g(e){try{return await A.readJson(e)}catch{return null}}async function I(e){let[s,i]=await Promise.all([g$1(e,p.model),g$1(e,p.knowledgeGraph)]);if(!s)return {status:"miss",reason:"missing-model"};if(!i)return {status:"miss",reason:"missing-graph"};let[n,o]=await Promise.all([g(s),g(i)]);if(!S(n))return {status:"miss",reason:"invalid-model"};if(!W(o))return {status:"miss",reason:"invalid-graph"};if(o.proofs.some(r=>r.freshness==="stale"))return {status:"miss",reason:"stale-proof"};try{b(o,n);}catch{return {status:"miss",reason:"source-mismatch"}}let a=o.source.inputs;if(!a)return {status:"miss",reason:"missing-input-fingerprint"};let f=a.scopes.filter(r=>r.kind==="workspace"),m=a.scopes.filter(r=>r.kind==="project"),k=n.projects.map(r=>r.name).sort(),w=m.map(r=>r.id).sort(),y=new Set(m.map(r=>r.fileLimit));if(a.schemaVersion!=="workspace-knowledge-graph-inputs.v1"||a.strategy!=="hybrid-git-content-v2"||a.hashAlgorithm!=="sha256"||f.length!==1||y.size>1||JSON.stringify(k)!==JSON.stringify(w))return {status:"miss",reason:"invalid-input-fingerprint"};let u;try{u=await d({workspacePath:e,projects:n.projects.map(r=>({id:r.name,path:r.path,...r.absolutePath?{absolutePath:r.absolutePath}:{}})),expected:a});}catch{return {status:"miss",reason:"input-scan-failed"}}return u?{status:"hit",model:n,graph:o,modelPath:s,graphPath:i}:{status:"miss",reason:"live-input-mismatch"}}export{I as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-JEI6BTZI.js';import {a}from'./chunk-IVYPC36J.js';import {c,e,d}from'./chunk-QYEQVNBF.js';import {d as d$1,b}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-JEI6BTZI.js';import {a}from'./chunk-IVYPC36J.js';import {c,e,d}from'./chunk-QYEQVNBF.js';import {d as d$1,b}from'./chunk-IQJL3LBM.js';import {g}from'./chunk-VEMGICT4.js';import {r,n}from'./chunk-QDM6TWFK.js';import {p,d as d$2}from'./chunk-MD4CHXV3.js';import {h}from'./chunk-BLEIUQL6.js';import {b as b$1}from'./chunk-VN2MKTQO.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import j from'path';import P from'fs-extra';function Y(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Q(e$1){switch(e$1){case "why":return d;case "trace":return e;default:return c}}async function E(e,n,o){try{if(!await P.pathExists(e))return null;let r=await P.readJson(e);return n?b$1(n,r,e):o&&a$2(r,o,e),r}catch(r){if((n||o)&&await P.pathExists(e))throw r;return null}}function q(e,n){if(!e)return null;let o=n.trim().toLowerCase();return e.projects.find(r=>r.slug.toLowerCase()===o||r.relativePath.toLowerCase()===o)??null}function U(e,n$1,o){let r=o.trim().toLowerCase(),t=(n(e)?.nodes.map(a=>a.id)??e.projects.map(a=>a.name)).find(a=>a.toLowerCase()===r);if(t)return t;let m=e.projects.find(a=>[a.name,a.path,j.basename(a.path)].filter(u=>u.trim().length>0).some(u=>u.toLowerCase()===r));if(m)return m.name;let p=q(n$1,o);if(p){let a=e.projects.find(u=>u.path===p.relativePath||u.path.endsWith(`/${p.relativePath}`));if(a)return a.name}return o}function Z(e,n){if(!e)return [];let o=n.trim().toLowerCase(),r=new Set;for(let d of e.projects){d.contracts.dependsOn?.some(t=>t.toLowerCase()===o)&&r.add(d.slug);for(let t of d.contracts.consumes??[])for(let m of e.projects)m.contracts.publishes?.includes(t)&&m.slug===o&&r.add(d.slug);}return [...r].sort()}function ee(e,n){if(!e)return [];let o=n.trim().toLowerCase();return e.steps.filter(r=>r.scope==="project"&&r.project?.toLowerCase()===o&&r.command?.display).map(r=>r.command.display).slice(0,8)}function l(e,n,o){return {id:e,title:n,body:o.trim()}}async function he(e){let n$1=j.resolve(e.workspacePath),o=(e.now??new Date).toISOString(),r$1=e.model??await r({workspacePath:n$1,includeEvidence:true}),d=e.contract;if(d===void 0)try{d=(await p({workspacePath:n$1})).contract;}catch{d=null;}let t=e.verify;t===void 0&&(t=await E(j.join(n$1,d$1),d$1));let m=e.impact;if(m===void 0&&(m=await E(j.join(n$1,g),g)),e.target.kind==="release-blocked"){let s=t?.blockingReasons??[],c=(r$1.summary?.projectCount??r$1.projects.length)===0,g=[l("verdict",c?"Workspace scaffold posture":"Release verdict",t?c?`Scaffold posture: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Freshness: **${t.freshness.verdict}**. No registered projects yet \u2014 release gates apply after the first project is added.`:`Verdict: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Risk: **${t.impact.risk}**. Freshness: **${t.freshness.verdict}**.`:"No workspace verify report found. Run `npx workspai workspace verify --json --write` first."),l("blockers",c?"Pre-project signals":"Blocking reasons",s.length?s.map(h=>`- ${h}`).join(`
|
|
2
2
|
`):c?"No pre-project signals in the latest verify report.":"No blocking reasons in the latest verify report.")];return t?.resolutionHints?.length&&g.push(l("resolution","Resolution hints",t.resolutionHints.map(h=>`- **${h.blockerId}** (${h.resolutionClass}): ${h.commandRetryHint??h.fixHints[0]?.detail??"See fix hints"}`).join(`
|
|
3
3
|
`))),{schemaVersion:a,generatedAt:o,workspacePath:n$1,target:e.target,summary:t?c?b(s.length,t.summary.verdict):s.length>0||t.summary.verdict==="blocked"?`Release blocked: ${t.summary.verdict} with ${s.length} blocking reason(s).`:t.summary.verdict==="needs-attention"?"Release needs attention: advisory or incomplete verification evidence remains; no blocking reason was reported.":`Release posture: ${t.summary.verdict}; no blocking reason was reported.`:"Release posture unknown \u2014 verify report missing.",sections:g,releaseVerdict:t?.summary.verdict,evidenceFreshness:t?.freshness.verdict,blocking:!!(t&&(t.summary.verdict==="blocked"||s.length>0)),releaseRisk:t?.impact.risk,blockingReasons:s,resolutionHints:t?.resolutionHints}}if(e.target.kind==="blocker"){let s=e.target,f=t?.resolutionHints?.find(g=>g.blockerId===s.blockerId),c=t?.blockingReasons.find(g=>g.includes(s.blockerId))??t?.blockingReasons[0];return {schemaVersion:a,generatedAt:o,workspacePath:n$1,target:s,summary:f?`Blocker ${s.blockerId}: ${f.resolutionClass}`:`Blocker ${s.blockerId} (no structured hint)`,sections:[l("reason","Blocking signal",c??"No matching blocking reason in verify."),l("hint","Resolution class",f?`${f.resolutionClass}
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d,n}from'./chunk-
|
|
1
|
+
import {d,n}from'./chunk-QDM6TWFK.js';import {a,b}from'./chunk-S5KTATOU.js';function u(r){let s=new Map;for(let n of r.projects)s.has(n.name)||s.set(n.name,d(n));return s}function w(r){let s=u(r),n$1=n(r)??{nodes:r.projects.map(t=>({id:t.name,path:t.path})),edges:[]},a$1=a(n$1),o=new Map;for(let t of n$1.nodes){let e=s.get(t.id)??d({missing:t.id}),l=[...b(a$1,[t.id],{direction:"dependencies"}).keys()].filter(c=>c!==t.id).sort((c,f)=>c.localeCompare(f)).map(c=>({id:c,hash:s.get(c)??"<unknown>"}));o.set(t.id,{id:t.id,ownHash:e,transitiveInputsHash:d({own:e,dependencies:l})});}return o}function y(r,s){if(!s||Object.keys(s).length===0)return {verdict:"unknown",baseline:"none",changed:[],added:[],removed:[]};let n=[],a=[];for(let[e,i]of r.entries())e in s?s[e]!==i.transitiveInputsHash&&n.push(e):a.push(e);let o=[];for(let e of Object.keys(s))r.has(e)||o.push(e);return n.sort((e,i)=>e.localeCompare(i)),a.sort((e,i)=>e.localeCompare(i)),o.sort((e,i)=>e.localeCompare(i)),{verdict:n.length>0||a.length>0||o.length>0?"stale":"fresh",baseline:"recorded",changed:n,added:a,removed:o}}function M(r){let s={};for(let[n,a]of [...r.entries()].sort((o,t)=>o[0].localeCompare(t[0])))s[n]=a.transitiveInputsHash;return s}export{u as a,w as b,y as c,M as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a}from'./chunk-HCFOVANQ.js';import {n,h,i}from'./chunk-SEZTSMRR.js';import {B}from'./chunk-O3TVVQ6X.js';import {d as d$1}from'./chunk-ROOPODG6.js';import {a as a$1}from'./chunk-GR6442P7.js';import {d,c}from'./chunk-EWZZUQBR.js';import {p,t}from'./chunk-ODK4LCEL.js';import u from'path';import {createHash}from'crypto';import {createReadStream}from'fs';import {execFile}from'child_process';import {promisify}from'util';import _ from'fs-extra';import {parseAllDocuments}from'yaml';var Bs=p.knowledgeGraph;function Ls(e,t){if(e.source.kind!=="workspace-model")throw new Error(`Workspace knowledge graph is not bound to the canonical workspace model (source: ${e.source.kind}).`);if(e.source.artifact!==p.model)throw new Error(`Workspace knowledge graph source artifact is ${e.source.artifact}; expected ${p.model}.`);if(e.source.hashAlgorithm!=="sha256")throw new Error(`Workspace knowledge graph source hash algorithm is ${e.source.hashAlgorithm}; expected sha256.`);let s=d(t);if(e.source.hash!==s)throw new Error("Workspace knowledge graph is stale: its source hash does not match the canonical workspace model.");if(e.workspace.name!==t.workspace.name||(e.workspace.profile??void 0)!==(t.workspace.profile??void 0))throw new Error("Workspace knowledge graph identity does not match the canonical workspace model.");let o=n(t);if(!o)throw new Error("Canonical workspace model has no project topology for the workspace knowledge graph.");let i=n=>({...n,generatedAt:"<ignored>"});if(c(i(e.projectTopology))!==c(i(o)))throw new Error("Workspace knowledge graph project topology does not match the canonical workspace model.")}function jt(e){return {path:e.path,...e.runtime!==void 0?{runtime:e.runtime}:{},...e.runtimeCandidates!==void 0?{runtimeCandidates:e.runtimeCandidates}:{},...e.framework!==void 0?{framework:e.framework}:{},...e.kit!==void 0?{kit:e.kit}:{},...e.kind!==void 0?{kind:e.kind}:{},...e.category!==void 0?{category:e.category}:{},...e.governance?{governanceCiStatus:e.governance.ci.status,governanceReleaseStatus:e.governance.release.status,governanceOwnershipStatus:e.governance.ownership.status,governanceProviders:[e.governance.ci.provider,e.governance.release.provider,e.governance.ownership.provider].filter(t=>!!t)}:{}}}var Dt=5e5,qt=2e6;function ke(e,t){if(e!==void 0&&Number.isFinite(e)&&e>0)return Math.floor(e);let s=process.env[t];if(!s)return;let o=Number.parseInt(s,10);return Number.isFinite(o)&&o>0?o:void 0}var It=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","venv","vendor","node_modules","dist","build","target","coverage",".next",".turbo",".cache",".vscode-test","graphify-out",".pytest_cache",".mypy_cache",".ruff_cache",".tox",".gradle","fixture","fixtures","__fixtures__","testdata"]),Et=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","QWEN.md"]),Ct=new Set([".workspai-workspace"]),Zt=[/(?:^|\/)\.agents\/skills\/workspai-[^/]+\//u,/(?:^|\/)\.amazonq\/rules\/workspai-[^/]+\.md$/u,/(?:^|\/)\.claude\/(?:rules|skills)\/(?:workspai-|rapidkit-)[^/]+(?:\/|$)/u,/(?:^|\/)\.cursor\/(?:rules|skills)\/(?:workspai-|rapidkit-)[^/]+(?:\/|$)/u,/(?:^|\/)\.grok\/(?:rules|skills)\/workspai-[^/]+(?:\/|$)/u,/(?:^|\/)\.github\/agents\/workspai-[^/]+\.agent\.md$/u,/(?:^|\/)\.github\/(?:instructions|prompts|skills)\/(?:workspai-|rapidkit-)[^/]+(?:\/|$)/u,/(?:^|\/)\.github\/copilot-instructions\.md$/u,/(?:^|\/)\.windsurf\/rules\/workspai-[^/]+\.md$/u,/(?:^|\/)\.windsurfrules$/u,/(?:^|\/)\.vscode\/(?:workspai|rapidkit)-agent-hooks\.json$/u];function Ke(e,t){let s=D(u.relative(e,t));return Et.has(u.posix.basename(s))||Ct.has(u.posix.basename(s))||Zt.some(o=>o.test(s))}var Ht=new Set(["test","tests","spec","specs","e2e","integration","integration-tests","integration_tests","__tests__","fixture","fixtures","__fixtures__","testdata"]),Ut=new Set(["examples","samples","worked"]);function Ge(e,t){let s=u.relative(e,t).split(u.sep).map(i=>i.toLowerCase()),o=u.basename(t).toLowerCase();return s.some(i=>Ht.has(i))||/(?:\.test|\.spec|_test)\.[a-z0-9]+$/i.test(o)||/^test_.+\.[a-z0-9]+$/i.test(o)||/(?:tests?|specs?)\.(?:cs|fs|vb|java|kt|kts)$/i.test(o)}function De(e,t){return u.relative(e,t).split(u.sep).map(s=>s.toLowerCase()).some(s=>Ut.has(s))}function ee(e,t){return Ge(e,t)||De(e,t)}function he(e,t){return u.relative(e,t).split(u.sep).some(s=>s.toLowerCase()==="generated")}var Le=new Set(["package.json","pyproject.toml","requirements.txt","Pipfile","go.mod","Cargo.toml","pom.xml","build.gradle","build.gradle.kts","composer.json","Gemfile","mix.exs","pubspec.yaml","Package.swift","CMakeLists.txt","deno.json","deno.jsonc","project.clj","deps.edn","build.sbt","BUILD","BUILD.bazel","WORKSPACE.bazel"]),Jt=new Set([...Le,"go.work","go.work.sum"]),Vt=new Set(["get","put","post","delete","options","head","patch","trace"]),te=new Set([".c",".cc",".cpp",".cs",".dart",".ex",".exs",".go",".h",".hpp",".java",".cjs",".cts",".js",".jsx",".kt",".kts",".mjs",".mts",".php",".py",".r",".rb",".rs",".scala",".svelte",".swift",".ts",".tsx",".vue",".clj",".cljs",".fs",".fsx",".lua",".vb"]),nt=new Set([...te,".adb",".ads",".asm",".bash",".bat",".cl",".cob",".cu",".cuh",".erl",".f",".f03",".f08",".f77",".f90",".f95",".fish",".for",".gql",".graphql",".groovy",".hip",".hrl",".hs",".hlsl",".jl",".ll",".m",".metal",".mir",".mlir",".mm",".nim",".pas",".pl",".pm",".proto",".ps1",".s",".sh",".sol",".sql",".sv",".td",".thrift",".v",".vhd",".vhdl",".zig",".zsh"]);function J(e,t){let s=u.extname(e).toLowerCase();return s===".h"&&t==="cpp"?"cpp":{".c":"c",".adb":"ada",".ads":"ada",".asm":"assembly",".bash":"shell",".bat":"batch",".cc":"cpp",".cl":"opencl",".cob":"cobol",".cpp":"cpp",".cs":"csharp",".cu":"cuda",".cuh":"cuda",".dart":"dart",".erl":"erlang",".ex":"elixir",".exs":"elixir",".f":"fortran",".f03":"fortran",".f08":"fortran",".f77":"fortran",".f90":"fortran",".f95":"fortran",".fish":"shell",".for":"fortran",".gql":"graphql",".go":"go",".graphql":"graphql",".groovy":"groovy",".h":"c",".hip":"hip",".hpp":"cpp",".hrl":"erlang",".hs":"haskell",".hlsl":"hlsl",".java":"java",".jl":"julia",".cjs":"javascript",".cts":"typescript",".js":"javascript",".jsx":"javascript",".kt":"kotlin",".kts":"kotlin",".mjs":"javascript",".mts":"typescript",".php":"php",".py":"python",".r":"r",".rb":"ruby",".rs":"rust",".scala":"scala",".svelte":"svelte",".swift":"swift",".ts":"typescript",".tsx":"typescript",".vue":"vue",".clj":"clojure",".cljs":"clojure",".fs":"fsharp",".fsx":"fsharp",".lua":"lua",".ll":"llvm-ir",".m":"objective-c",".metal":"metal",".mir":"llvm-mir",".mlir":"mlir",".mm":"objective-cpp",".nim":"nim",".pas":"pascal",".pl":"perl",".pm":"perl",".proto":"protobuf",".ps1":"powershell",".s":"assembly",".sh":"shell",".sol":"solidity",".sql":"sql",".sv":"systemverilog",".td":"tablegen",".thrift":"thrift",".v":"verilog",".vb":"visual-basic",".vhd":"vhdl",".vhdl":"vhdl",".zig":"zig",".zsh":"shell"}[s]??s.slice(1)}var Yt=new Set(["external","third_party","third-party","vendor","vendors","vendored"]),Qt=new Set(["app","apps","cli","cmd","core","extensions","internal","lib","packages","services","src"]);function at(e,t){let o=D(u.relative(t,e)).split("/").filter(Boolean),i=o[0]?.toLowerCase()??"";return (o.some(l=>Yt.has(l.toLowerCase()))?1e3:0)+(Qt.has(i)?-100:0)+Math.min(o.length,20)}function Xt(e,t,s){if(e.length<=t)return [...e];let o=[...e].sort((c,r)=>at(c,s)-at(r,s)||c.localeCompare(r)),i=new Map;for(let c of o){let r=J(c),d=i.get(r)??[];d.push(c),i.set(r,d);}let n=new Set,l=Math.max(1,Math.min(25,Math.floor(t/Math.max(i.size,1))));for(let c of [...i.values()])for(let r of c.slice(0,l))n.add(r);for(let c of o){if(n.size>=t)break;n.add(c);}return [...n].sort((c,r)=>c.localeCompare(r))}function eo(e,t){let s=D(u.relative(t,e)).split("/").filter(Boolean);if(s.length===0)return "<root>";let o=s[0].toLowerCase();return ["app","apps","cmd","components","crates","modules","packages","plugins","services"].includes(o)&&s[1]?`${o}/${s[1].toLowerCase()}`:o}function $e(e,t,s){let o=[...new Set(e)].sort((d,a)=>d.localeCompare(a));if(o.length<=t)return o;let i=new Set,n=o.filter(d=>Jt.has(u.basename(d))).sort((d,a)=>D(u.relative(s,d)).split("/").length-D(u.relative(s,a)).split("/").length||d.localeCompare(a));for(let d of n){if(i.size>=t)break;i.add(d);}let l=new Map;for(let d of o){if(i.has(d))continue;let a=`${eo(d,s)}\0${J(d)}`,p=l.get(a)??[];p.push(d),l.set(a,p);}let c=[...l.entries()].sort(([d],[a])=>d.localeCompare(a)),r=0;for(;i.size<t;){let d=false;for(let[,a]of c){let p=a[r];if(p&&(i.add(p),d=true,i.size>=t))break}if(!d)break;r+=1;}return [...i].sort((d,a)=>d.localeCompare(a))}function to(e){let t=Math.max(0,e.eligibleFiles),s=Math.min(25e3,Math.max(5e3,Math.ceil(t*.2))),o=Math.max(100,Math.min(e.deepOverride??s,Math.max(t,100),1e5)),i=Math.min(1e5,Math.max(25e3,o*4,Math.ceil(t*.6))),n=Math.max(o,Math.min(e.semanticOverride??i,Math.max(t,o),25e4)),l=Math.min(2e4,Math.max(2e3,Math.ceil(Math.min(t,o)*.25))),c=Math.max(100,Math.min(e.sourceOverride??l,o,5e4));return {semanticFileBudget:n,deepFileBudget:o,sourceExtractionFileBudget:c}}function Oe(e,t,s){let o=[],i=e.split(/\r?\n/);for(let n=0;n<i.length&&o.length<s;n+=1)for(let l of t){let r=i[n].match(l.pattern)?.[1]?.trim();if(r){o.push({name:r,line:n+1,detail:l.detail});break}}return o}var oo=[{pattern:/^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/,detail:"function"},{pattern:/^\s*(?:export\s+)?(?:abstract\s+)?(?:class|interface|enum|type)\s+([A-Za-z_$][\w$]*)/,detail:"type"},{pattern:/^\s*(?:export\s+)?(?:declare\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)/,detail:"value"},{pattern:/^\s*(?:async\s+)?def\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*class\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*func\s+(?:\([^)]*\)\s*)?([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*type\s+([A-Za-z_]\w*)\s+/,detail:"type"},{pattern:/^\s*(?:public\s+|private\s+|protected\s+|internal\s+|abstract\s+|final\s+)*(?:class|interface|record|enum)\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*(?:public|protected|internal)\s+(?:(?:static|virtual|override|abstract|async|sealed|final|synchronized|native|unsafe|partial|extern|new)\s+)*(?:<[^>]+>\s*)?[A-Za-z_$][\w$<>,.?\[\]: ]*\s+([A-Za-z_$][\w$]*)\s*\(/,detail:"method"},{pattern:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:struct|trait|enum|type)\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*(?:public\s+|private\s+|protected\s+)?function\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*(?:class|module|struct|protocol|mixin)\s+([A-Za-z_]\w*)/,detail:"type"}],Rt=[{pattern:/^\s*import(?:.+?from\s*)?["']([^"']+)["']/,detail:"import"},{pattern:/require\(["']([^"']+)["']\)/,detail:"require"}],St=[{pattern:/^\s*from\s+([A-Za-z0-9_.]+)\s+import\s+/,detail:"import"},{pattern:/^\s*import\s+([A-Za-z0-9_.]+)(?:\s|$)/,detail:"import"}],so=[{pattern:/^\s*#\s*include\s*["<]([^">]+)[">]/,detail:"include"}],io=[{pattern:/^\s*use\s+([A-Za-z0-9_:*.-]+)/,detail:"use"}],ro=[{pattern:/^\s*import\s+(?:static\s+)?([A-Za-z0-9_.*]+)\s*;?/,detail:"import"}],no=[{pattern:/^\s*(?:global\s+)?using\s+([A-Za-z0-9_.]+)/,detail:"using"}],ao=[{pattern:/^\s*import\s+(?:[A-Za-z0-9_.]+\s+)?["']([^"']+)["']/,detail:"import"}],At=[{pattern:/^\s*require(?:_relative)?\s+["']([^"']+)["']/,detail:"require"}],co=[{pattern:/^\s*use\s+([A-Za-z0-9_\\]+)/,detail:"use"}],lo=[{pattern:/^\s*(?:alias|import|require|use)\s+([A-Za-z0-9_.]+)/,detail:"import"}],po=[{pattern:/^\s*import\s+["']([^"']+)["']/,detail:"import"}],uo=[{pattern:/\brequire\s*\(?\s*["']([^"']+)["']/,detail:"require"}],fo=[{pattern:/^\s*(?:library|require)\s*\(\s*["']?([^"')\s]+)["']?/,detail:"import"}],go=[...Rt,...St,{pattern:/^\s*(?:import|using|use)\s+([A-Za-z0-9_:.*\\/.-]+)/,detail:"import"},...At];function mo(e){let t=u.extname(e).toLowerCase();return [".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx",".vue",".svelte"].includes(t)?Rt:t===".py"?St:[".c",".cc",".cpp",".h",".hpp"].includes(t)?so:t===".rs"?io:[".java",".kt",".kts",".scala"].includes(t)?ro:[".cs",".fs",".fsx",".vb"].includes(t)?no:t===".go"?ao:t===".rb"?At:t===".php"?co:[".ex",".exs"].includes(t)?lo:t===".dart"?po:t===".lua"?uo:t===".r"?fo:go}function ho(e,t,s,o,i){let n=u.extname(e).toLowerCase()===".py",l=[];if(n){let r=t.match(/^\.+/)?.[0].length??0,d=r>0?u.dirname(e):u.resolve(o??"");for(let p=1;p<r;p+=1)d=u.dirname(d);let a=t.slice(r).replace(/\./g,u.sep);l.push(a?u.join(d,a):d);}else if(t.startsWith("."))l.push(u.resolve(u.dirname(e),t));else if(i==="include")l.push(u.resolve(u.dirname(e),t)),o&&l.push(u.resolve(o,t));else return null;let c=new Set;for(let r of l){c.add(r);let d=u.extname(r).toLowerCase(),a=te.has(d);if(n&&(c.add(`${r}.py`),c.add(u.join(r,"__init__.py"))),a){let p=r.slice(0,-d.length);if([".js",".jsx",".mjs"].includes(d))for(let f of [".ts",".tsx",".js",".jsx",".mjs"])c.add(`${p}${f}`);}else for(let p of te)c.add(`${r}${p}`),c.add(u.join(r,`index${p}`));}return [...c].find(r=>s.has(u.resolve(r)))??null}function vo(e,t){let s=t.trimStart(),o=u.extname(e).toLowerCase();return [".py",".rb",".sh",".bash",".zsh"].includes(o)?s.startsWith("#"):[".sql",".lua",".hs"].includes(o)?s.startsWith("--"):s.startsWith("//")||s.startsWith("/*")||s.startsWith("*")}function yo(e,t){if(u.extname(e).toLowerCase()!==".py")return t;let s=null;return t.split(/\r?\n/).map(o=>{let i=0,n="";for(;i<o.length;){if(s){let a=o.indexOf(s,i);if(a<0)return n;i=a+3,s=null;continue}let l=o.indexOf("'''",i),c=o.indexOf('"""',i),r=o.indexOf("#",i),d=l<0?c:c<0?l:Math.min(l,c);if(r>=0&&(d<0||r<d)){n+=o.slice(i,r);break}if(d<0){n+=o.slice(i);break}n+=o.slice(i,d),s=o.startsWith("'''",d)?"'''":'"""',i=d+3;}return n}).join(`
|
|
1
|
+
import {a}from'./chunk-HCFOVANQ.js';import {n,h,i}from'./chunk-QDM6TWFK.js';import {B}from'./chunk-7HV4U2OV.js';import {d as d$1}from'./chunk-ROOPODG6.js';import {a as a$1}from'./chunk-GR6442P7.js';import {d,c}from'./chunk-EWZZUQBR.js';import {p,t}from'./chunk-ODK4LCEL.js';import u from'path';import {createHash}from'crypto';import {createReadStream}from'fs';import {execFile}from'child_process';import {promisify}from'util';import _ from'fs-extra';import {parseAllDocuments}from'yaml';var Bs=p.knowledgeGraph;function Ls(e,t){if(e.source.kind!=="workspace-model")throw new Error(`Workspace knowledge graph is not bound to the canonical workspace model (source: ${e.source.kind}).`);if(e.source.artifact!==p.model)throw new Error(`Workspace knowledge graph source artifact is ${e.source.artifact}; expected ${p.model}.`);if(e.source.hashAlgorithm!=="sha256")throw new Error(`Workspace knowledge graph source hash algorithm is ${e.source.hashAlgorithm}; expected sha256.`);let s=d(t);if(e.source.hash!==s)throw new Error("Workspace knowledge graph is stale: its source hash does not match the canonical workspace model.");if(e.workspace.name!==t.workspace.name||(e.workspace.profile??void 0)!==(t.workspace.profile??void 0))throw new Error("Workspace knowledge graph identity does not match the canonical workspace model.");let o=n(t);if(!o)throw new Error("Canonical workspace model has no project topology for the workspace knowledge graph.");let i=n=>({...n,generatedAt:"<ignored>"});if(c(i(e.projectTopology))!==c(i(o)))throw new Error("Workspace knowledge graph project topology does not match the canonical workspace model.")}function jt(e){return {path:e.path,...e.runtime!==void 0?{runtime:e.runtime}:{},...e.runtimeCandidates!==void 0?{runtimeCandidates:e.runtimeCandidates}:{},...e.framework!==void 0?{framework:e.framework}:{},...e.kit!==void 0?{kit:e.kit}:{},...e.kind!==void 0?{kind:e.kind}:{},...e.category!==void 0?{category:e.category}:{},...e.governance?{governanceCiStatus:e.governance.ci.status,governanceReleaseStatus:e.governance.release.status,governanceOwnershipStatus:e.governance.ownership.status,governanceProviders:[e.governance.ci.provider,e.governance.release.provider,e.governance.ownership.provider].filter(t=>!!t)}:{}}}var Dt=5e5,qt=2e6;function ke(e,t){if(e!==void 0&&Number.isFinite(e)&&e>0)return Math.floor(e);let s=process.env[t];if(!s)return;let o=Number.parseInt(s,10);return Number.isFinite(o)&&o>0?o:void 0}var It=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","venv","vendor","node_modules","dist","build","target","coverage",".next",".turbo",".cache",".vscode-test","graphify-out",".pytest_cache",".mypy_cache",".ruff_cache",".tox",".gradle","fixture","fixtures","__fixtures__","testdata"]),Et=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","QWEN.md"]),Ct=new Set([".workspai-workspace"]),Zt=[/(?:^|\/)\.agents\/skills\/workspai-[^/]+\//u,/(?:^|\/)\.amazonq\/rules\/workspai-[^/]+\.md$/u,/(?:^|\/)\.claude\/(?:rules|skills)\/(?:workspai-|rapidkit-)[^/]+(?:\/|$)/u,/(?:^|\/)\.cursor\/(?:rules|skills)\/(?:workspai-|rapidkit-)[^/]+(?:\/|$)/u,/(?:^|\/)\.grok\/(?:rules|skills)\/workspai-[^/]+(?:\/|$)/u,/(?:^|\/)\.github\/agents\/workspai-[^/]+\.agent\.md$/u,/(?:^|\/)\.github\/(?:instructions|prompts|skills)\/(?:workspai-|rapidkit-)[^/]+(?:\/|$)/u,/(?:^|\/)\.github\/copilot-instructions\.md$/u,/(?:^|\/)\.windsurf\/rules\/workspai-[^/]+\.md$/u,/(?:^|\/)\.windsurfrules$/u,/(?:^|\/)\.vscode\/(?:workspai|rapidkit)-agent-hooks\.json$/u];function Ke(e,t){let s=D(u.relative(e,t));return Et.has(u.posix.basename(s))||Ct.has(u.posix.basename(s))||Zt.some(o=>o.test(s))}var Ht=new Set(["test","tests","spec","specs","e2e","integration","integration-tests","integration_tests","__tests__","fixture","fixtures","__fixtures__","testdata"]),Ut=new Set(["examples","samples","worked"]);function Ge(e,t){let s=u.relative(e,t).split(u.sep).map(i=>i.toLowerCase()),o=u.basename(t).toLowerCase();return s.some(i=>Ht.has(i))||/(?:\.test|\.spec|_test)\.[a-z0-9]+$/i.test(o)||/^test_.+\.[a-z0-9]+$/i.test(o)||/(?:tests?|specs?)\.(?:cs|fs|vb|java|kt|kts)$/i.test(o)}function De(e,t){return u.relative(e,t).split(u.sep).map(s=>s.toLowerCase()).some(s=>Ut.has(s))}function ee(e,t){return Ge(e,t)||De(e,t)}function he(e,t){return u.relative(e,t).split(u.sep).some(s=>s.toLowerCase()==="generated")}var Le=new Set(["package.json","pyproject.toml","requirements.txt","Pipfile","go.mod","Cargo.toml","pom.xml","build.gradle","build.gradle.kts","composer.json","Gemfile","mix.exs","pubspec.yaml","Package.swift","CMakeLists.txt","deno.json","deno.jsonc","project.clj","deps.edn","build.sbt","BUILD","BUILD.bazel","WORKSPACE.bazel"]),Jt=new Set([...Le,"go.work","go.work.sum"]),Vt=new Set(["get","put","post","delete","options","head","patch","trace"]),te=new Set([".c",".cc",".cpp",".cs",".dart",".ex",".exs",".go",".h",".hpp",".java",".cjs",".cts",".js",".jsx",".kt",".kts",".mjs",".mts",".php",".py",".r",".rb",".rs",".scala",".svelte",".swift",".ts",".tsx",".vue",".clj",".cljs",".fs",".fsx",".lua",".vb"]),nt=new Set([...te,".adb",".ads",".asm",".bash",".bat",".cl",".cob",".cu",".cuh",".erl",".f",".f03",".f08",".f77",".f90",".f95",".fish",".for",".gql",".graphql",".groovy",".hip",".hrl",".hs",".hlsl",".jl",".ll",".m",".metal",".mir",".mlir",".mm",".nim",".pas",".pl",".pm",".proto",".ps1",".s",".sh",".sol",".sql",".sv",".td",".thrift",".v",".vhd",".vhdl",".zig",".zsh"]);function J(e,t){let s=u.extname(e).toLowerCase();return s===".h"&&t==="cpp"?"cpp":{".c":"c",".adb":"ada",".ads":"ada",".asm":"assembly",".bash":"shell",".bat":"batch",".cc":"cpp",".cl":"opencl",".cob":"cobol",".cpp":"cpp",".cs":"csharp",".cu":"cuda",".cuh":"cuda",".dart":"dart",".erl":"erlang",".ex":"elixir",".exs":"elixir",".f":"fortran",".f03":"fortran",".f08":"fortran",".f77":"fortran",".f90":"fortran",".f95":"fortran",".fish":"shell",".for":"fortran",".gql":"graphql",".go":"go",".graphql":"graphql",".groovy":"groovy",".h":"c",".hip":"hip",".hpp":"cpp",".hrl":"erlang",".hs":"haskell",".hlsl":"hlsl",".java":"java",".jl":"julia",".cjs":"javascript",".cts":"typescript",".js":"javascript",".jsx":"javascript",".kt":"kotlin",".kts":"kotlin",".mjs":"javascript",".mts":"typescript",".php":"php",".py":"python",".r":"r",".rb":"ruby",".rs":"rust",".scala":"scala",".svelte":"svelte",".swift":"swift",".ts":"typescript",".tsx":"typescript",".vue":"vue",".clj":"clojure",".cljs":"clojure",".fs":"fsharp",".fsx":"fsharp",".lua":"lua",".ll":"llvm-ir",".m":"objective-c",".metal":"metal",".mir":"llvm-mir",".mlir":"mlir",".mm":"objective-cpp",".nim":"nim",".pas":"pascal",".pl":"perl",".pm":"perl",".proto":"protobuf",".ps1":"powershell",".s":"assembly",".sh":"shell",".sol":"solidity",".sql":"sql",".sv":"systemverilog",".td":"tablegen",".thrift":"thrift",".v":"verilog",".vb":"visual-basic",".vhd":"vhdl",".vhdl":"vhdl",".zig":"zig",".zsh":"shell"}[s]??s.slice(1)}var Yt=new Set(["external","third_party","third-party","vendor","vendors","vendored"]),Qt=new Set(["app","apps","cli","cmd","core","extensions","internal","lib","packages","services","src"]);function at(e,t){let o=D(u.relative(t,e)).split("/").filter(Boolean),i=o[0]?.toLowerCase()??"";return (o.some(l=>Yt.has(l.toLowerCase()))?1e3:0)+(Qt.has(i)?-100:0)+Math.min(o.length,20)}function Xt(e,t,s){if(e.length<=t)return [...e];let o=[...e].sort((c,r)=>at(c,s)-at(r,s)||c.localeCompare(r)),i=new Map;for(let c of o){let r=J(c),d=i.get(r)??[];d.push(c),i.set(r,d);}let n=new Set,l=Math.max(1,Math.min(25,Math.floor(t/Math.max(i.size,1))));for(let c of [...i.values()])for(let r of c.slice(0,l))n.add(r);for(let c of o){if(n.size>=t)break;n.add(c);}return [...n].sort((c,r)=>c.localeCompare(r))}function eo(e,t){let s=D(u.relative(t,e)).split("/").filter(Boolean);if(s.length===0)return "<root>";let o=s[0].toLowerCase();return ["app","apps","cmd","components","crates","modules","packages","plugins","services"].includes(o)&&s[1]?`${o}/${s[1].toLowerCase()}`:o}function $e(e,t,s){let o=[...new Set(e)].sort((d,a)=>d.localeCompare(a));if(o.length<=t)return o;let i=new Set,n=o.filter(d=>Jt.has(u.basename(d))).sort((d,a)=>D(u.relative(s,d)).split("/").length-D(u.relative(s,a)).split("/").length||d.localeCompare(a));for(let d of n){if(i.size>=t)break;i.add(d);}let l=new Map;for(let d of o){if(i.has(d))continue;let a=`${eo(d,s)}\0${J(d)}`,p=l.get(a)??[];p.push(d),l.set(a,p);}let c=[...l.entries()].sort(([d],[a])=>d.localeCompare(a)),r=0;for(;i.size<t;){let d=false;for(let[,a]of c){let p=a[r];if(p&&(i.add(p),d=true,i.size>=t))break}if(!d)break;r+=1;}return [...i].sort((d,a)=>d.localeCompare(a))}function to(e){let t=Math.max(0,e.eligibleFiles),s=Math.min(25e3,Math.max(5e3,Math.ceil(t*.2))),o=Math.max(100,Math.min(e.deepOverride??s,Math.max(t,100),1e5)),i=Math.min(1e5,Math.max(25e3,o*4,Math.ceil(t*.6))),n=Math.max(o,Math.min(e.semanticOverride??i,Math.max(t,o),25e4)),l=Math.min(2e4,Math.max(2e3,Math.ceil(Math.min(t,o)*.25))),c=Math.max(100,Math.min(e.sourceOverride??l,o,5e4));return {semanticFileBudget:n,deepFileBudget:o,sourceExtractionFileBudget:c}}function Oe(e,t,s){let o=[],i=e.split(/\r?\n/);for(let n=0;n<i.length&&o.length<s;n+=1)for(let l of t){let r=i[n].match(l.pattern)?.[1]?.trim();if(r){o.push({name:r,line:n+1,detail:l.detail});break}}return o}var oo=[{pattern:/^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/,detail:"function"},{pattern:/^\s*(?:export\s+)?(?:abstract\s+)?(?:class|interface|enum|type)\s+([A-Za-z_$][\w$]*)/,detail:"type"},{pattern:/^\s*(?:export\s+)?(?:declare\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)/,detail:"value"},{pattern:/^\s*(?:async\s+)?def\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*class\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*func\s+(?:\([^)]*\)\s*)?([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*type\s+([A-Za-z_]\w*)\s+/,detail:"type"},{pattern:/^\s*(?:public\s+|private\s+|protected\s+|internal\s+|abstract\s+|final\s+)*(?:class|interface|record|enum)\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*(?:public|protected|internal)\s+(?:(?:static|virtual|override|abstract|async|sealed|final|synchronized|native|unsafe|partial|extern|new)\s+)*(?:<[^>]+>\s*)?[A-Za-z_$][\w$<>,.?\[\]: ]*\s+([A-Za-z_$][\w$]*)\s*\(/,detail:"method"},{pattern:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*(?:pub(?:\([^)]*\))?\s+)?(?:struct|trait|enum|type)\s+([A-Za-z_]\w*)/,detail:"type"},{pattern:/^\s*(?:public\s+|private\s+|protected\s+)?function\s+([A-Za-z_]\w*)/,detail:"function"},{pattern:/^\s*(?:class|module|struct|protocol|mixin)\s+([A-Za-z_]\w*)/,detail:"type"}],Rt=[{pattern:/^\s*import(?:.+?from\s*)?["']([^"']+)["']/,detail:"import"},{pattern:/require\(["']([^"']+)["']\)/,detail:"require"}],St=[{pattern:/^\s*from\s+([A-Za-z0-9_.]+)\s+import\s+/,detail:"import"},{pattern:/^\s*import\s+([A-Za-z0-9_.]+)(?:\s|$)/,detail:"import"}],so=[{pattern:/^\s*#\s*include\s*["<]([^">]+)[">]/,detail:"include"}],io=[{pattern:/^\s*use\s+([A-Za-z0-9_:*.-]+)/,detail:"use"}],ro=[{pattern:/^\s*import\s+(?:static\s+)?([A-Za-z0-9_.*]+)\s*;?/,detail:"import"}],no=[{pattern:/^\s*(?:global\s+)?using\s+([A-Za-z0-9_.]+)/,detail:"using"}],ao=[{pattern:/^\s*import\s+(?:[A-Za-z0-9_.]+\s+)?["']([^"']+)["']/,detail:"import"}],At=[{pattern:/^\s*require(?:_relative)?\s+["']([^"']+)["']/,detail:"require"}],co=[{pattern:/^\s*use\s+([A-Za-z0-9_\\]+)/,detail:"use"}],lo=[{pattern:/^\s*(?:alias|import|require|use)\s+([A-Za-z0-9_.]+)/,detail:"import"}],po=[{pattern:/^\s*import\s+["']([^"']+)["']/,detail:"import"}],uo=[{pattern:/\brequire\s*\(?\s*["']([^"']+)["']/,detail:"require"}],fo=[{pattern:/^\s*(?:library|require)\s*\(\s*["']?([^"')\s]+)["']?/,detail:"import"}],go=[...Rt,...St,{pattern:/^\s*(?:import|using|use)\s+([A-Za-z0-9_:.*\\/.-]+)/,detail:"import"},...At];function mo(e){let t=u.extname(e).toLowerCase();return [".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx",".vue",".svelte"].includes(t)?Rt:t===".py"?St:[".c",".cc",".cpp",".h",".hpp"].includes(t)?so:t===".rs"?io:[".java",".kt",".kts",".scala"].includes(t)?ro:[".cs",".fs",".fsx",".vb"].includes(t)?no:t===".go"?ao:t===".rb"?At:t===".php"?co:[".ex",".exs"].includes(t)?lo:t===".dart"?po:t===".lua"?uo:t===".r"?fo:go}function ho(e,t,s,o,i){let n=u.extname(e).toLowerCase()===".py",l=[];if(n){let r=t.match(/^\.+/)?.[0].length??0,d=r>0?u.dirname(e):u.resolve(o??"");for(let p=1;p<r;p+=1)d=u.dirname(d);let a=t.slice(r).replace(/\./g,u.sep);l.push(a?u.join(d,a):d);}else if(t.startsWith("."))l.push(u.resolve(u.dirname(e),t));else if(i==="include")l.push(u.resolve(u.dirname(e),t)),o&&l.push(u.resolve(o,t));else return null;let c=new Set;for(let r of l){c.add(r);let d=u.extname(r).toLowerCase(),a=te.has(d);if(n&&(c.add(`${r}.py`),c.add(u.join(r,"__init__.py"))),a){let p=r.slice(0,-d.length);if([".js",".jsx",".mjs"].includes(d))for(let f of [".ts",".tsx",".js",".jsx",".mjs"])c.add(`${p}${f}`);}else for(let p of te)c.add(`${r}${p}`),c.add(u.join(r,`index${p}`));}return [...c].find(r=>s.has(u.resolve(r)))??null}function vo(e,t){let s=t.trimStart(),o=u.extname(e).toLowerCase();return [".py",".rb",".sh",".bash",".zsh"].includes(o)?s.startsWith("#"):[".sql",".lua",".hs"].includes(o)?s.startsWith("--"):s.startsWith("//")||s.startsWith("/*")||s.startsWith("*")}function yo(e,t){if(u.extname(e).toLowerCase()!==".py")return t;let s=null;return t.split(/\r?\n/).map(o=>{let i=0,n="";for(;i<o.length;){if(s){let a=o.indexOf(s,i);if(a<0)return n;i=a+3,s=null;continue}let l=o.indexOf("'''",i),c=o.indexOf('"""',i),r=o.indexOf("#",i),d=l<0?c:c<0?l:Math.min(l,c);if(r>=0&&(d<0||r<d)){n+=o.slice(i,r);break}if(d<0){n+=o.slice(i);break}n+=o.slice(i,d),s=o.startsWith("'''",d)?"'''":'"""',i=d+3;}return n}).join(`
|
|
2
2
|
`)}function bo(e,t){if(![".js",".jsx",".mjs",".ts",".tsx"].includes(u.extname(e).toLowerCase()))return t;let s=false,o=false;return t.split(/\r?\n/).map(i=>{let n="",l=null,c=false;for(let r=0;r<i.length;r+=1){let d=i[r],a=i[r+1];if(s){n+=" ",d==="*"&&a==="/"&&(n+=" ",r+=1,s=false);continue}if(o){n+=" ",d==="`"&&!c&&(o=false),c=d==="\\"&&!c,d!=="\\"&&(c=false);continue}if(l){n+=d,d===l&&!c&&(l=null),c=d==="\\"&&!c,d!=="\\"&&(c=false);continue}if(d==="/"&&a==="/")return n.padEnd(i.length," ");if(d==="/"&&a==="*"){n+=" ",r+=1,s=true;continue}if(d==="`"){n+=" ",o=true,c=false;continue}(d==="'"||d==='"')&&(l=d),n+=d;}return n}).join(`
|
|
3
3
|
`)}function Ft(e,t){return bo(e,yo(e,t))}var we=[{pattern:/@(?:Get|Post|Put|Delete|Patch|Options|Head)\s*\(\s*["']([^"']*)["']/i,detail:"decorated route"},{pattern:/\b(?:app|router|server|api|route|fastify|fiber)\.(?:get|post|put|delete|patch|options|head)\s*\(\s*["']([^"']+)["']/i,detail:"router route"},{pattern:/@(?:GetMapping|PostMapping|PutMapping|DeleteMapping|PatchMapping|RequestMapping)\s*\([^"']*["']([^"']*)["']/,detail:"mapped route"},{pattern:/\[Http(?:Get|Post|Put|Delete|Patch)\s*\(\s*["']([^"']*)["']/i,detail:"HTTP route"},{pattern:/^\s*(?:get|post|put|delete|patch)\s+["']([^"']+)["']/i,detail:"HTTP route"}],ko=[{pattern:/@Router\s+([^\s]+)\s+\[(?:get|post|put|delete|patch|options|head)\]/i,detail:"swagger route"},{pattern:/\b[A-Za-z_]\w*\.(?:GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD)\s*\(\s*["']([^"']+)["']/,detail:"go router route"}],wo=[{pattern:/\.route\s*\(\s*["']([^"']+)["']\s*,\s*(?:routing::)?(?:get|post|put|delete|patch|options|head)\s*\(/i,detail:"rust router route"}],Po=[{pattern:/\b[A-Za-z_]\w*\.Map(?:Get|Post|Put|Delete|Patch|Methods)\s*\(\s*["']([^"']+)["']/i,detail:"dotnet route"},{pattern:/\b[A-Za-z_]\w*\.MapHealthChecks\s*\(\s*["']([^"']+)["']/i,detail:"dotnet health route"}];function $o(e){let t=u.extname(e).toLowerCase();return t===".go"?[...we,...ko]:t===".rs"?[...we,...wo]:t===".cs"?[...we,...Po]:we}function jo(e,t){return t==="swagger route"?e.match(/\[(get|post|put|delete|patch|options|head)\]/i)?.[1]?.toUpperCase()??"HTTP":t==="rust router route"?e.match(/,\s*(?:routing::)?(get|post|put|delete|patch|options|head)\s*\(/i)?.[1]?.toUpperCase()??"HTTP":t==="dotnet health route"?"GET":t==="dotnet route"?e.match(/\.Map(Get|Post|Put|Delete|Patch|Methods)\s*\(/i)?.[1]?.toUpperCase()??"HTTP":e.match(/(?:@|\.|\[|^\s*)(get|post|put|delete|patch|options|head)/i)?.[1]?.toUpperCase()??"HTTP"}function je(e){return createHash("sha256").update(e).digest("hex")}function R(e,t){return `wkg:${e}:${je(`${e}\0${t}`).slice(0,20)}`}function D(e){return e.replace(/\\/g,"/")}function me(e){let t=D(e).replace(/^\.\//,"");return !t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")?"unknown":t}function C(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function P(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function H(e){if(Array.isArray(e))return e.filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean).sort();let t=C(e);return t?Object.keys(t).map(s=>s.trim()).filter(Boolean).sort():[]}function Io(e){if(Array.isArray(e))return e.map(s=>typeof s=="string"?s.split("=",1)[0]?.trim():"").filter(s=>!!s).sort();let t=C(e);return t?Object.keys(t).sort():[]}function Eo(e){return Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0).sort(([t],[s])=>t.localeCompare(s)))}async function Co(e,t,s=[]){let o=[],i=[e],n=s.map(r=>u.resolve(r)),l=r=>{let d=u.resolve(r);return n.some(a=>d===a||d.startsWith(`${a}${u.sep}`))},c=0;for(;c<i.length&&o.length<t;){let r=i[c++],d;try{d=await _.readdir(r,{withFileTypes:true});}catch{continue}d.sort((a,p)=>a.name.localeCompare(p.name));for(let a of d){if(o.length>=t)break;if(a.isSymbolicLink())continue;let p=u.join(r,a.name);l(p)||(a.isDirectory()?!It.has(a.name)&&!a$1(a.name)&&i.push(p):a.isFile()&&(Ke(e,p)||o.push(p)));}}return o.sort((r,d)=>r.localeCompare(d))}function ve(e,t,s){let o=s?.projects.find(i=>i.relativePath===t.path||t.id!==void 0&&(i.slug===t.id||i.relativePath===`external/${t.id}`));return d$1(e,t.path,{...t.absolutePath||o?.externalPath?{absolutePath:t.absolutePath??o?.externalPath}:{}})}async function qe(e){return new Promise(t=>{let s=createHash("sha256"),o=createReadStream(e);o.on("data",i=>s.update(i)),o.on("error",i=>{t(`unreadable:${i.code??"unknown"}`);}),o.on("end",()=>t(s.digest("hex")));})}var Ro=promisify(execFile);async function Z(e,t){let s=await Ro("git",t,{cwd:e,encoding:"buffer",maxBuffer:268435456,windowsHide:true});return Buffer.isBuffer(s.stdout)?s.stdout:Buffer.from(s.stdout)}function Ze(){return [".",...[...It].sort((e,t)=>e.localeCompare(t)).map(e=>`:(exclude,glob)**/${e}/**`),...[...Et].sort((e,t)=>e.localeCompare(t)).map(e=>`:(exclude,glob)**/${e}`),...[...Ct].sort((e,t)=>e.localeCompare(t)).map(e=>`:(exclude,glob)**/${e}`),":(exclude,glob)**/.agents/skills/workspai-*/**",":(exclude,glob)**/.amazonq/rules/workspai-*.md",":(exclude,glob)**/.claude/rules/workspai-*.md",":(exclude,glob)**/.claude/rules/rapidkit-*.md",":(exclude,glob)**/.claude/skills/workspai-*/**",":(exclude,glob)**/.cursor/rules/workspai-*.*",":(exclude,glob)**/.cursor/rules/rapidkit-*.*",":(exclude,glob)**/.cursor/skills/workspai-*/**",":(exclude,glob)**/.grok/rules/workspai-*.md",":(exclude,glob)**/.grok/skills/workspai-*/**",":(exclude,glob)**/.github/agents/workspai-*.agent.md",":(exclude,glob)**/.github/copilot-instructions.md",":(exclude,glob)**/.github/instructions/workspai-*.md",":(exclude,glob)**/.github/instructions/rapidkit-*.md",":(exclude,glob)**/.github/prompts/workspai-*.md",":(exclude,glob)**/.github/prompts/rapidkit-*.md",":(exclude,glob)**/.github/skills/workspai-*/**",":(exclude,glob)**/.github/skills/rapidkit-*/**",":(exclude,glob)**/.windsurf/rules/workspai-*.md",":(exclude,glob)**/.windsurfrules",":(exclude,glob)**/.vscode/workspai-agent-hooks.json",":(exclude,glob)**/.vscode/rapidkit-agent-hooks.json"]}function We(e){return e.toString("utf8").split("\0").filter(Boolean).map(t=>t.replace(/\\/gu,"/"))}async function So(e,t,s=[]){try{await Z(e,["rev-parse","--show-toplevel"]);let o=Ze(),[i,n,l]=await Promise.all([Z(e,["ls-files","--stage","-z","--",...o]),Z(e,["ls-files","--deleted","-z","--",...o]),Z(e,["ls-files","--others","--exclude-standard","-z","--",...o])]),c=new Set(We(n)),r=i.toString("utf8").split("\0").filter(Boolean).flatMap(v=>{let m=v.match(/^(\d{6}) [0-9a-f]+ \d\t([\s\S]+)$/u);if(!m)return [];let[,h,y]=m,b=y.replace(/\\/gu,"/");return h==="120000"||h==="160000"||c.has(b)?[]:[b]}),p=(await Ce([...new Set([...r,...We(l)])],64,async v=>{let m=u.normalize(v);if(u.isAbsolute(m)||m===".."||m.startsWith(`..${u.sep}`))return null;let h=u.resolve(e,m);try{let y=await _.lstat(h);return y.isFile()&&!y.isSymbolicLink()?v:null}catch{return null}})).filter(v=>v!==null).map(v=>u.resolve(e,...v.split("/").filter(Boolean))).filter(v=>!Ke(e,v)).filter(v=>!s.some(m=>v===u.resolve(m)||v.startsWith(`${u.resolve(m)}${u.sep}`))).sort((v,m)=>v.localeCompare(m)),f=p.length>t;return {files:f?$e(p,t,e):p,eligibleFileCount:p.length,eligibleFileCountExact:true,truncated:f,fileLimit:t,strategy:"git-index-worktree-v1"}}catch{return null}}async function ye(e,t,s=[]){let o=await So(e,t,s);if(o)return o;let i=await Co(e,t+1,s),n=i.length>t;return {files:n?$e(i,t,e):i,eligibleFileCount:i.length,eligibleFileCountExact:!n,truncated:n,fileLimit:t,strategy:"filesystem-bfs-v1"}}async function Ao(e){try{let t=(await Z(e.root,["rev-parse","--show-prefix"])).toString("utf8").trim().replace(/\\/gu,"/"),s=t?`${t.replace(/^\/+|\/+$/gu,"")}/`:"";if(u.posix.isAbsolute(s)||s==="../"||s.startsWith("../")||s.includes("/../"))return null;let o=Ze(),[i,n,l,c,r,d]=await Promise.all([Z(e.root,["ls-files","--full-name","-s","--",...o]),Z(e.root,["diff","--no-ext-diff","--no-textconv","--binary","HEAD","--",...o]),Z(e.root,["ls-files","--full-name","--others","--exclude-standard","-z","--",...o]),Z(e.root,["ls-files","--full-name","--others","--ignored","--exclude-standard","-z","--",...o]),Z(e.root,["ls-files","-v","--",...o]),Z(e.root,["ls-files","--full-name","-s","--",...o])]);if(r.toString("utf8").split(/\r?\n/u).some(y=>/^[a-z] /u.test(y)))return null;let a=e.files.map(y=>{let b=D(u.relative(e.root,y));return `${s}${b}`});if(d.toString("utf8").split(/\r?\n/u).filter(y=>y.startsWith("160000 ")).map(y=>y.split(" ",2)[1]).filter(y=>!!y).map(y=>y.replace(/\\/gu,"/").replace(/\/$/u,"")).some(y=>a.some(b=>b.startsWith(`${y}/`))))return null;let f=new Set(a),v=Buffer.concat([l,c]).toString("utf8").split("\0").filter(Boolean).map(y=>y.replace(/\\/gu,"/")).filter(y=>f.has(y)),m=await Ce([...new Set(v)].sort((y,b)=>y.localeCompare(b)),16,async y=>{let b=s?y.slice(s.length):y;return {path:b,hash:await qe(u.resolve(e.root,...b.split("/").filter(Boolean)))}}),h=createHash("sha256");h.update(`git-worktree-v2\0${e.kind}\0${e.id}\0${e.fileLimit}\0`),h.update(i),h.update(createHash("sha256").update(n).digest());for(let y of m)h.update(`${y.path}\0${y.hash}\0`);return {kind:e.kind,id:e.id,strategy:"git-worktree-v2",hash:h.digest("hex"),fileCount:e.files.length,fileLimit:e.fileLimit,truncated:e.files.length>=e.fileLimit}}catch{return null}}async function Fo(e){try{let t=(await Z(e.root,["rev-parse","--show-prefix"])).toString("utf8").trim().replace(/\\/gu,"/"),s=t?`${t.replace(/^\/+|\/+$/gu,"")}/`:"";if(u.posix.isAbsolute(s)||s==="../"||s.startsWith("../")||s.includes("/../"))return null;let o=Ze(),[i,n,l,c]=await Promise.all([Z(e.root,["ls-files","--full-name","-s","--",...o]),Z(e.root,["diff","--no-ext-diff","--no-textconv","--binary","HEAD","--",...o]),Z(e.root,["ls-files","--full-name","--others","--exclude-standard","-z","--",...o]),Z(e.root,["ls-files","-v","--",...o])]);if(c.toString("utf8").split(/\r?\n/u).some(p=>/^[a-z] /u.test(p)))return null;let r=(e.excludedRoots??[]).map(p=>u.resolve(p)),d=(await Ce([...new Set(We(l))].sort((p,f)=>p.localeCompare(f)),16,async p=>{if(s&&!p.startsWith(s))return null;let f=s?p.slice(s.length):p,v=u.normalize(f);if(!f||u.isAbsolute(v)||v===".."||v.startsWith(`..${u.sep}`))return null;let m=u.resolve(e.root,v);if(r.some(h=>m===h||m.startsWith(`${h}${u.sep}`))||Ke(e.root,m))return null;try{let h=await _.lstat(m);if(!h.isFile()||h.isSymbolicLink())return null}catch{return null}return {path:f,hash:await qe(m)}})).filter(p=>p!==null),a=createHash("sha256");a.update(`git-worktree-v2\0${e.kind}\0${e.id}\0${e.fileLimit}\0`),a.update(i),a.update(createHash("sha256").update(n).digest());for(let p of d)a.update(`${p.path}\0${p.hash}\0`);return a.digest("hex")===e.expectedHash}catch{return null}}async function Ce(e,t,s){let o=new Array(e.length),i=0,n=Array.from({length:Math.min(t,Math.max(e.length,1))},async()=>{for(;i<e.length;){let l=i++;o[l]=await s(e[l]);}});return await Promise.all(n),o}async function xe(e){let t=[...new Set(e.files)].sort((d,a)=>d.localeCompare(a)),s=e.eligibleFileCount??t.length,o=s>e.fileLimit||t.length>e.fileLimit,i=t.slice(0,e.fileLimit),n=await Ao({...e,files:i}),l={eligibleFileCount:s,eligibleFileCountExact:e.eligibleFileCountExact??!o,inventoryMode:o?"emergency-bounded":"complete",...e.inventoryStrategy?{inventoryStrategy:e.inventoryStrategy}:{},...e.selection?{selection:e.selection}:{}};if(n)return {...n,fileCount:i.length,truncated:o,...l};let c=await Ce(i,16,async d=>({path:D(u.relative(e.root,d)),hash:await qe(d)}));c.sort((d,a)=>d.path.localeCompare(a.path));let r=createHash("sha256");r.update(`content-merkle-v1\0${e.kind}\0${e.id}\0${e.fileLimit}\0`);for(let d of c)r.update(`${d.path}\0${d.hash}\0`);return {kind:e.kind,id:e.id,strategy:"content-merkle-v1",hash:r.digest("hex"),fileCount:c.length,fileLimit:e.fileLimit,truncated:o,...l}}async function _o(e){let t=u.resolve(e.workspacePath),s=[...e.projects].sort((r,d)=>r.id.localeCompare(d.id)),o=s.map(r=>ve(t,r)),i=e.inventories?.workspaceInventory??(e.inventories?.workspaceFiles?{files:[...e.inventories.workspaceFiles],eligibleFileCount:e.inventories.workspaceFiles.length,eligibleFileCountExact:e.inventories.workspaceFiles.length<=e.workspaceFileLimit,truncated:e.inventories.workspaceFiles.length>e.workspaceFileLimit,fileLimit:e.workspaceFileLimit,strategy:"filesystem-bfs-v1"}:await ye(t,e.workspaceFileLimit,o)),n=i.files.filter(r=>!o.some(d=>r===d||r.startsWith(`${d}${u.sep}`))),l={...i,files:n,eligibleFileCount:i.eligibleFileCountExact&&!i.truncated?n.length:i.eligibleFileCount},c=await Promise.all([xe({kind:"workspace",id:"workspace",root:t,files:l.files,fileLimit:e.workspaceFileLimit,eligibleFileCount:l.eligibleFileCount,eligibleFileCountExact:l.eligibleFileCountExact,inventoryStrategy:l.strategy}),...s.map(async r=>{let d=ve(t,r),a=e.inventories?.projectFiles?.get(r.id),p=e.inventories?.projectInventories?.get(r.id)??(a?{files:[...a],eligibleFileCount:a.length,eligibleFileCountExact:a.length<=e.projectFileLimit,strategy:"filesystem-bfs-v1"}:await ye(d,e.projectFileLimit)),f=e.inventories?.scanBudgetsByProject?.get(r.id);return xe({kind:"project",id:r.id,root:d,files:p.files,fileLimit:e.projectFileLimit,eligibleFileCount:p.eligibleFileCount,eligibleFileCountExact:p.eligibleFileCountExact,inventoryStrategy:p.strategy,...f?{selection:{strategy:"component-language-round-robin-v1",semanticFileCount:Math.min(p.files.length,f.semanticFileBudget),semanticFileBudget:f.semanticFileBudget,deepFileCount:Math.min(p.files.length,f.deepFileBudget),deepFileBudget:f.deepFileBudget,sourceExtractionFileBudget:f.sourceExtractionFileBudget}}:{}})})]);return c.sort((r,d)=>r.kind.localeCompare(d.kind)||r.id.localeCompare(d.id)),_t(c)}function _t(e){let t=[...e].sort((o,i)=>o.kind.localeCompare(i.kind)||o.id.localeCompare(i.id)),s=createHash("sha256");s.update("workspace-knowledge-graph-inputs.v1\0hybrid-git-content-v2\0");for(let o of t)s.update(`${o.kind}\0${o.id}\0${o.hash}\0${o.fileCount}\0${o.fileLimit}\0${o.truncated}\0${o.eligibleFileCount??o.fileCount}\0${o.eligibleFileCountExact??!o.truncated}\0${o.inventoryMode??(o.truncated?"emergency-bounded":"complete")}\0${o.inventoryStrategy??"unknown"}\0${o.selection?c(o.selection):""}\0`);return {schemaVersion:"workspace-knowledge-graph-inputs.v1",strategy:"hybrid-git-content-v2",hashAlgorithm:"sha256",hash:s.digest("hex"),scopes:t}}async function Ws(e){if(_t(e.expected.scopes).hash!==e.expected.hash)return false;let t=u.resolve(e.workspacePath),s=[...e.projects].sort((n,l)=>n.id.localeCompare(l.id)),o=s.map(n=>ve(t,n)),i=new Map(s.map(n=>[n.id,n]));for(let n of e.expected.scopes){let l=n.kind==="project"?i.get(n.id):void 0;if(n.kind==="project"&&!l)return false;let c$1=l?ve(t,l):t;if(n.strategy==="git-worktree-v2"){let v=await Fo({kind:n.kind,id:n.id,root:c$1,fileLimit:n.fileLimit,expectedHash:n.hash,...n.kind==="workspace"?{excludedRoots:o}:{}});if(v!==null){if(!v)return false;continue}}let r=await ye(c$1,n.fileLimit,n.kind==="workspace"?o:[]),d=n.kind==="workspace"?r.files.filter(v=>!o.some(m=>v===m||v.startsWith(`${m}${u.sep}`))):r.files,a={...r,files:d,eligibleFileCount:r.eligibleFileCountExact&&!r.truncated?d.length:r.eligibleFileCount},p=n.selection?{strategy:"component-language-round-robin-v1",semanticFileCount:Math.min(a.files.length,n.selection.semanticFileBudget),semanticFileBudget:n.selection.semanticFileBudget,deepFileCount:Math.min(a.files.length,n.selection.deepFileBudget),deepFileBudget:n.selection.deepFileBudget,sourceExtractionFileBudget:n.selection.sourceExtractionFileBudget}:void 0,f=await xe({kind:n.kind,id:n.id,root:c$1,files:a.files,fileLimit:n.fileLimit,eligibleFileCount:a.eligibleFileCount,eligibleFileCountExact:a.eligibleFileCountExact,inventoryStrategy:a.strategy,...p?{selection:p}:{}});if(c(f)!==c(n))return false}return true}async function ae(e){let t=await _.readFile(e,"utf8");if(e.toLowerCase().endsWith(".json")){let s=JSON.parse(t),o=C(s);return o?[o]:[]}return parseAllDocuments(t,{logLevel:"silent"}).map(s=>C(s.toJSON())).filter(s=>s!==null)}function ue(e){return [...new Set([...e.workspaceFiles,...e.projects.flatMap(t=>e.filesByProject.get(t.id)??[])])].sort((t,s)=>t.localeCompare(s))}function Ie(e){return /^(?:openapi|swagger)(?:\.[^.]+)?\.(?:json|ya?ml)$/i.test(u.basename(e))}function ct(e){let t=u.basename(e).toLowerCase();return /\.(?:graphql|gql|proto)$/.test(t)||/^asyncapi(?:\.[^.]+)?\.(?:json|ya?ml)$/.test(t)}function dt(e){let t=u.basename(e),s=D(e);return !/(?:^|\/)\.devcontainer(?:\/|$)/i.test(s)&&/^Dockerfile(?:\..+)?$/i.test(t)||/\.tf$/i.test(t)||t==="Chart.yaml"}function lt(e){return /(?:^|[\\/])(?:README|ARCHITECTURE|CONTRIBUTING|SECURITY)\.md$/i.test(e)}function To(e,t){let s=D(u.relative(e,t));return /^\.github\/workflows\/.+\.ya?ml$/i.test(s)||/^(?:\.gitlab-ci\.ya?ml|azure-pipelines\.ya?ml|Jenkinsfile|bitbucket-pipelines\.ya?ml|\.woodpecker\.ya?ml|\.drone\.ya?ml|\.travis\.ya?ml|appveyor\.ya?ml)$/i.test(s)||/^\.circleci\/config\.ya?ml$/i.test(s)||/^\.buildkite\/pipeline\.ya?ml$/i.test(s)||/^\.tekton\/.+\.ya?ml$/i.test(s)||/^prow\/[^/]+\.(?:sh|py)$/i.test(s)}function pt(e,t){let s=D(u.relative(e,t));return /(?:^|\/)(?:adr|adrs|decisions)(?:\/).+\.md$/i.test(s)||/(?:^|\/)ADR[-_0-9].+\.md$/i.test(s)}async function ut(e){let t=new Set;for(let s of [e.workspacePath,...e.projects.map(o=>o.root)])for(let o of ["compose.yml","compose.yaml","docker-compose.yml","docker-compose.yaml"]){let i=u.join(s,o);await _.pathExists(i)&&t.add(i);}for(let s of ue(e))/^(?:docker-)?compose(?:\.[a-z0-9_-]+)*\.ya?ml$/i.test(u.basename(s))&&t.add(s);return [...t].sort((s,o)=>s.localeCompare(o))}async function ft(e){let s=[e.workspacePath,...e.projects.map(i=>i.root)].flatMap(i=>[u.join(i,"CODEOWNERS"),u.join(i,".github","CODEOWNERS"),u.join(i,".gitlab","CODEOWNERS"),u.join(i,"docs","CODEOWNERS")]);for(let i of ue(e))u.basename(i)==="OWNERS"&&s.push(i);let o=await Promise.all(s.map(async i=>await _.pathExists(i)?i:null));return [...new Set(o.filter(i=>!!i))].sort((i,n)=>i.localeCompare(n))}function gt(e){let t=[{root:e.workspacePath,files:e.workspaceFiles},...e.projects.map(s=>({root:s.root,files:e.filesByProject.get(s.id)??[]}))];return [...new Set(t.flatMap(s=>s.files.filter(o=>To(s.root,o))))].sort((s,o)=>s.localeCompare(o))}async function mt(e){let t=[];for(let s of ue(e))if(/\.ya?ml$/i.test(s))try{(await ae(s)).some(i=>{let n=C(i.metadata);return !!(P(i.apiVersion)&&P(i.kind)&&P(n?.name))})&&t.push(s);}catch{}return t.sort((s,o)=>s.localeCompare(o))}function ie(e,t){let s=u.resolve(t);return e.filter(o=>s===o.root||s.startsWith(`${o.root}${u.sep}`)).sort((o,i)=>i.root.length-o.root.length)[0]??null}var ze=class{constructor(t,s,o){this.workspacePath=t;this.now=s;this.workspaceName=o;}workspacePath;now;workspaceName;entities=new Map;relations=new Map;proofs=new Map;providers=[];diagnostics=[];contentHashes=new Map;attributeConflicts=new Set;emptyLabelDiagnostics=new Set;artifactPath(t,s){if(s){let o=D(u.relative(s.root,t));return me(u.posix.join(s.artifactPrefix,o))}return me(u.relative(this.workspacePath,t))}async addProof(t){let s;if(t.absolutePath){if(!this.contentHashes.has(t.absolutePath))try{this.contentHashes.set(t.absolutePath,je(await _.readFile(t.absolutePath)));}catch{this.contentHashes.set(t.absolutePath,null);}s=this.contentHashes.get(t.absolutePath)??void 0;}let o=me(t.artifact),i=R("proof",[t.provider,o,t.pointer??"",t.line??"",t.detail??""].join("\0"));return this.proofs.has(i)||this.proofs.set(i,{id:i,provider:t.provider,artifact:o,...t.pointer?{pointer:t.pointer}:{},...t.line?{line:t.line}:{},...t.column?{column:t.column}:{},...s?{contentHash:s}:{},observedAt:this.now.toISOString(),derivation:t.derivation??"extracted",trust:t.trust??"observed",confidence:t.confidence??"high",freshness:"fresh",...t.detail?{detail:t.detail}:{}}),i}addEntity(t){let s=R(t.kind,t.key),o=Eo(t.attributes??{}),i=this.entities.get(s),n=t.label.trim(),l=n||i?.label||t.key.trim()||t.kind;!n&&!this.emptyLabelDiagnostics.has(s)&&(this.emptyLabelDiagnostics.add(s),this.diagnostics.push({code:"graph.knowledge.empty_label_normalized",severity:"warning",message:`An empty ${t.kind} label was normalized to ${l}.`,entityIds:[s],recommendation:"Inspect the provider proof and preserve a non-empty source identifier before publishing the entity."}));let c={...i?.attributes??{}};for(let[a,p]of Object.entries(o)){if(a in c&&JSON.stringify(c[a])!==JSON.stringify(p)){if(t.mergeArrayAttributes?.includes(a)&&Array.isArray(c[a])&&Array.isArray(p)){c[a]=p;continue}let f=`${s}\0${a}`;this.attributeConflicts.has(f)||(this.attributeConflicts.add(f),this.diagnostics.push({code:"graph.knowledge.attribute_conflict",severity:"warning",message:`Conflicting ${a} values were observed for ${t.kind} ${l}.`,entityIds:[s],recommendation:"Inspect the entity proof paths and make the authoritative source explicit."}));continue}c[a]=p;}let r=[...new Set([...i?.identity.aliases??[],...t.aliases??[]].map(a=>a.trim()).filter(Boolean))].sort(),d=[...new Set([...i?.proofIds??[],...t.proofIds??[]])].sort();return this.entities.set(s,{id:s,kind:t.kind,label:l,...t.projectId?{projectId:t.projectId}:{},identity:{key:t.key,scope:t.projectId?"project":"workspace",aliases:r,fingerprint:je(JSON.stringify({kind:t.kind,key:t.key,attributes:c}))},attributes:c,proofIds:d}),s}addRelation(t){let s=R("relation",`${t.from}\0${t.kind}\0${t.to}`),o=this.relations.get(s),i=[...new Set([...o?.proofIds??[],...t.proofIds])].sort(),n=new Set(i.map(r=>this.proofs.get(r)?.provider).filter(Boolean)).size,l=t.trust??o?.trust??"observed",c=n>=2&&l!=="ambiguous"?"corroborated":l;return this.relations.set(s,{id:s,from:t.from,to:t.to,kind:t.kind,derivation:t.derivation??o?.derivation??"extracted",trust:c,confidence:c==="corroborated"?"high":t.confidence??o?.confidence??"high",proofIds:i}),s}};function pe(e){let t=[],s=null;for(let o of e.split(/\r?\n/)){let i=o.match(/^\s*\[\[([^\]]+)\]\]\s*(?:#.*)?$/)?.[1]?.trim()??o.match(/^\s*\[([^\]]+)\]\s*(?:#.*)?$/)?.[1]?.trim();if(i){s&&t.push({name:s.name,body:s.lines.join(`
|
|
4
4
|
`)}),s={name:i,lines:[]};continue}s?.lines.push(o);}return s&&t.push({name:s.name,body:s.lines.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$2}from'./chunk-TGNPMOM6.js';import {j,l as l$1}from'./chunk-J2MPBSQJ.js';import {g}from'./chunk-GLBFY7AB.js';import {a as a$1}from'./chunk-223SWPTL.js';import {v}from'./chunk-SC43A6LH.js';import {j as j$1,e}from'./chunk-RU3UT7GJ.js';import {b,c as c$1}from'./chunk-47UR6ZH4.js';import {c,d}from'./chunk-JVZA35OL.js';import {a}from'./chunk-COICGD62.js';import {f as f$1,g as g$1,h as h$2}from'./chunk-3SQIV3F4.js';import {k,l,h as h$1,m,n,p as p$1,q as q$1}from'./chunk-3EPR3D5Q.js';import {a as a$3}from'./chunk-4CXV3PPV.js';import {o as o$1,r as r$1,u}from'./chunk-SEZTSMRR.js';import {o,r as r$2,s}from'./chunk-IHWS3ALP.js';import {f,h}from'./chunk-BLEIUQL6.js';import {b as b$1}from'./chunk-VN2MKTQO.js';import {c as c$2}from'./chunk-EFHSRPW7.js';import {p,q,z,A,y,x}from'./chunk-ODK4LCEL.js';import ge from'path';import pe from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function de(t,s){return t.length===s.length&&t.every((m,u)=>m===s[u])}function ue(t){b$1(p.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a,`chainSchemaVersion must be ${a}`),r(t.artifactPath===p.intelligenceRun,`artifactPath must be ${p.intelligenceRun}`),r(t.preflight.length===y.length,`preflight must contain exactly ${y.length} entries`);for(let[d,n]of y.entries()){let a=t.preflight[d];r(a?.id===n,`preflight[${d}].id must be ${n}`),r(de(a.artifacts,z[n]),`${n} preflight artifacts must match the runtime registry`),n==="sync"?r(a.status==="passed"&&a.result==="synchronized"||a.status==="failed"&&a.result==="failed","sync preflight status and result are incoherent"):r(a.status==="passed"&&(a.result==="created"||a.result==="reused")||a.status==="failed"&&a.result==="failed"||a.status==="skipped"&&a.result==="skipped","baseline preflight status and result are incoherent");}let s=t.preflight[1];r(t.baselineCreated===(s?.result==="created"),"baselineCreated must match the baseline preflight result"),r(t.stages.length===x.length,`stages must contain exactly ${x.length} canonical steps`);let m=t.preflight[0],u=m?.status==="failed";for(let[d,n]of x.entries()){let a=t.stages[d];r(a?.id===n,`stages[${d}].id must be ${n}`),r(de(a.artifacts,A[n].produces),`${n} artifacts must match the runtime registry`),u&&r(a.status==="skipped",`${n} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${n} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${n} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${n} failed stage must have exitCode 1`),u=true):(r(a.exitCode===0,`${n} skipped stage must have exitCode 0`),r(a.durationMs===0,`${n} skipped stage must have durationMs 0`)),d===0&&((m?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(m?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(u=true));}let h=t.preflight.some(d=>d.status==="failed")||t.stages.some(d=>d.status==="failed"),y$1=t.stages.some(d=>d.status==="blocked"),l=h?"failed":y$1?"blocked":"passed",p$1=l==="failed"?1:l==="blocked"?2:0;r(t.status===l,`status must be ${l}`),r(t.exitCode===p$1,`exitCode must be ${p$1}`);}var we=p.intelligenceRun,Ee=q.intelligenceRun,L=we;function I(t){c$2({action:"intelligence",status:t.status==="started"?"started":t.status==="passed"?"succeeded":t.status==="failed"?"failed":"warn",message:t.message,metadata:{phase:`workspace.intelligence.${t.kind}.${t.id}`,intelligenceMilestoneId:t.id,intelligenceMilestoneKind:t.kind,intelligenceMilestoneStatus:t.status}});}async function Ue(t){let s=ge.resolve(t.workspacePath);return f(s,L,()=>ye({...t,workspacePath:s}),{timeoutMs:15*6e4,staleAfterMs:3e4})}async function ye(t){let s$1=t.workspacePath,m$1=[],u$1=[],h$3=false,y=async(e,o)=>{let c=[...z[e]];if(h$3){I({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),m$1.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:c,message:"skipped because a required upstream operation failed"});return}let k=Date.now();I({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let i=await o();I({id:e,kind:"preflight",status:"passed",message:i.message}),m$1.push({id:e,status:"passed",result:i.result,durationMs:Date.now()-k,artifacts:c,message:i.message});}catch(i){h$3=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"preflight",status:"failed",message:f}),m$1.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:c,message:f});}},l$2=async(e,o)=>{let c=[...A[e].produces];if(h$3){I({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),u$1.push({id:e,status:"skipped",durationMs:0,artifacts:c,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();I({id:e,kind:"stage",status:"started",message:`${e} started`});try{let i=await o(),f=i.exitCode??0,w=i.blocked||f!==0?"blocked":"passed";I({id:e,kind:"stage",status:w,message:i.message}),u$1.push({id:e,status:w,durationMs:Date.now()-k,artifacts:c,exitCode:f,message:i.message});}catch(i){h$3=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"stage",status:"failed",message:f}),u$1.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:c,exitCode:1,message:f});}};await y("sync",async()=>{let e=await g(s$1,true),o$1=await o({workspacePath:s$1});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${o$1.contract.projects.length} projects`}});let p$2,d$1=()=>{if(!p$2)throw new Error("canonical workspace model is unavailable");return p$2};await l$2("model",async()=>(p$2={...await r$1({workspacePath:s$1,includeEvidence:true}),build:o$1({mode:"full",engineStatus:"disabled"})},await u(p$2,s$1),{message:`${p$2.summary.projectCount} projects modeled`}));let n$1=ge.join(s$1,p.snapshot),a$4=false;await y("baseline",async()=>{if(!await pe.pathExists(n$1)){let c=await k({workspacePath:s$1,model:d$1()});return await l(c,s$1),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await pe.readJson(n$1),o=h$1(e);return o?(await l(o,s$1),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await l$2("diff",async()=>{let e=await m({workspacePath:s$1,fromPath:p.snapshot,model:d$1()});return await n(e,s$1),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await l$2("impact",async()=>{let e=await p$1({workspacePath:s$1,fromPath:p.diff});return await q$1(e,s$1),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await l$2("doctor-evidence",async()=>{let e=await v({workspace:s$1,json:true,quiet:true,profile:t.strict===true?"enterprise-strict":"local"});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await l$2("contract-evidence",async()=>{let e=await r$2({workspacePath:s$1,strict:true});return await s({workspacePath:s$1,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await l$2("analyze-evidence",async()=>{let e=await a$1({workspacePath:s$1,json:true,strict:t.strict===true});return {blocked:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await l$2("readiness-evidence",async()=>{let e=await a$2({startPath:s$1,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await l$2("verify",async()=>{let e$1=await f$1({workspacePath:s$1,fromImpactPath:p.impact});await g$1(e$1,s$1);let o=h$2(e$1,{strict:t.strict===true});return await j$1(s$1,e(e$1,o.passed)),{blocked:!o.passed,exitCode:o.exitCode,message:`${e$1.summary.verdict}; gate ${o.passed?"passed":"blocked"}`}}),await l$2("context",async()=>{let e=await c({workspacePath:s$1,model:d$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$1),{message:`context grounded for ${e.agent}`}}),await l$2("agent-sync",async()=>{let e=await l$1({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"}),o=false,c$1=await a$3(s$1);if(c$1.status==="miss"){if(c$1.reason!=="live-input-mismatch")throw new Error(`Agent grounding left canonical evidence invalid (${c$1.reason}).`);p$2={...await r$1({workspacePath:s$1,includeEvidence:true}),build:o$1({mode:"full",engineStatus:"disabled"})},await u(p$2,s$1);let f=await c({workspacePath:s$1,model:p$2,agent:t.agent??"generic",includeEvidence:true});await d(f,s$1);let w=await l$1({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"});e={...w,writtenFiles:[...new Set([...e.writtenFiles,...w.writtenFiles])].sort(),strictViolations:[...new Set([...e.strictViolations??[],...w.strictViolations??[]])].sort()};let O=await a$3(s$1);if(O.status==="miss")throw new Error(`Agent grounding reconciliation did not produce fresh canonical evidence (${O.reason}).`);o=true;}let k=e.strictViolations??[],i=t.strict===true&&k.length>0;return {blocked:i,exitCode:i?2:0,message:i?`${e.writtenFiles.length} grounding files written; ${k.length} strict grounding violation(s): ${k.join("; ")}`:`${e.writtenFiles.length} grounding files written; portable entry surfaces prepared for all supported hosts${o?"; canonical Model/Graph freshness sealed":""}`}}),await l$2("explain",async()=>{let e=await b({workspacePath:s$1,target:{kind:"release-blocked"}});await c$1(e,s$1);let o=t.strict===true?u$1.filter(c=>c.status==="blocked").map(c=>c.id):[];return {message:o.length>0&&e.blocking!==true?`Strict policy blocked advisory or incomplete evidence in ${o.join(", ")}. ${e.summary}`:e.summary}});let me=u$1.some(e=>e.status==="blocked"),G=h$3?"failed":me?"blocked":"passed",fe=h$3?1:G==="blocked"?2:0,b$1={schemaVersion:Ee,chainSchemaVersion:a,generatedAt:new Date().toISOString(),workspacePath:s$1,baselineCreated:a$4,preflight:m$1,status:G,exitCode:fe,stages:u$1,artifactPath:L};ue(b$1),await h(s$1,L,b$1);let ke=await j({workspacePath:s$1});return await h(s$1,p.agentIndex,ke),b$1}export{we as a,Ee as b,Ue as c};
|
|
1
|
+
import {a as a$2}from'./chunk-AMGIXK6Z.js';import {j,l as l$1}from'./chunk-ZQ36CTLF.js';import {g}from'./chunk-UVIBPWOG.js';import {a as a$1}from'./chunk-QMNJTI65.js';import {v}from'./chunk-VRZAN3WS.js';import {j as j$1,e}from'./chunk-RU3UT7GJ.js';import {b,c as c$1}from'./chunk-4KAYWMNE.js';import {c,d}from'./chunk-TJRVWVAZ.js';import {a}from'./chunk-COICGD62.js';import {f as f$1,g as g$1,h as h$2}from'./chunk-IQJL3LBM.js';import {k,l,h as h$1,m,n,p as p$1,q as q$1}from'./chunk-VEMGICT4.js';import {a as a$3}from'./chunk-4AAXIWYY.js';import {o as o$1,r as r$1,u}from'./chunk-QDM6TWFK.js';import {o,r as r$2,s}from'./chunk-MD4CHXV3.js';import {f,h}from'./chunk-BLEIUQL6.js';import {b as b$1}from'./chunk-VN2MKTQO.js';import {c as c$2}from'./chunk-EFHSRPW7.js';import {p,q,z,A,y,x}from'./chunk-ODK4LCEL.js';import ge from'path';import pe from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function de(t,s){return t.length===s.length&&t.every((m,u)=>m===s[u])}function ue(t){b$1(p.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a,`chainSchemaVersion must be ${a}`),r(t.artifactPath===p.intelligenceRun,`artifactPath must be ${p.intelligenceRun}`),r(t.preflight.length===y.length,`preflight must contain exactly ${y.length} entries`);for(let[d,n]of y.entries()){let a=t.preflight[d];r(a?.id===n,`preflight[${d}].id must be ${n}`),r(de(a.artifacts,z[n]),`${n} preflight artifacts must match the runtime registry`),n==="sync"?r(a.status==="passed"&&a.result==="synchronized"||a.status==="failed"&&a.result==="failed","sync preflight status and result are incoherent"):r(a.status==="passed"&&(a.result==="created"||a.result==="reused")||a.status==="failed"&&a.result==="failed"||a.status==="skipped"&&a.result==="skipped","baseline preflight status and result are incoherent");}let s=t.preflight[1];r(t.baselineCreated===(s?.result==="created"),"baselineCreated must match the baseline preflight result"),r(t.stages.length===x.length,`stages must contain exactly ${x.length} canonical steps`);let m=t.preflight[0],u=m?.status==="failed";for(let[d,n]of x.entries()){let a=t.stages[d];r(a?.id===n,`stages[${d}].id must be ${n}`),r(de(a.artifacts,A[n].produces),`${n} artifacts must match the runtime registry`),u&&r(a.status==="skipped",`${n} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${n} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${n} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${n} failed stage must have exitCode 1`),u=true):(r(a.exitCode===0,`${n} skipped stage must have exitCode 0`),r(a.durationMs===0,`${n} skipped stage must have durationMs 0`)),d===0&&((m?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(m?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(u=true));}let h=t.preflight.some(d=>d.status==="failed")||t.stages.some(d=>d.status==="failed"),y$1=t.stages.some(d=>d.status==="blocked"),l=h?"failed":y$1?"blocked":"passed",p$1=l==="failed"?1:l==="blocked"?2:0;r(t.status===l,`status must be ${l}`),r(t.exitCode===p$1,`exitCode must be ${p$1}`);}var we=p.intelligenceRun,Ee=q.intelligenceRun,L=we;function I(t){c$2({action:"intelligence",status:t.status==="started"?"started":t.status==="passed"?"succeeded":t.status==="failed"?"failed":"warn",message:t.message,metadata:{phase:`workspace.intelligence.${t.kind}.${t.id}`,intelligenceMilestoneId:t.id,intelligenceMilestoneKind:t.kind,intelligenceMilestoneStatus:t.status}});}async function Ue(t){let s=ge.resolve(t.workspacePath);return f(s,L,()=>ye({...t,workspacePath:s}),{timeoutMs:15*6e4,staleAfterMs:3e4})}async function ye(t){let s$1=t.workspacePath,m$1=[],u$1=[],h$3=false,y=async(e,o)=>{let c=[...z[e]];if(h$3){I({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),m$1.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:c,message:"skipped because a required upstream operation failed"});return}let k=Date.now();I({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let i=await o();I({id:e,kind:"preflight",status:"passed",message:i.message}),m$1.push({id:e,status:"passed",result:i.result,durationMs:Date.now()-k,artifacts:c,message:i.message});}catch(i){h$3=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"preflight",status:"failed",message:f}),m$1.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:c,message:f});}},l$2=async(e,o)=>{let c=[...A[e].produces];if(h$3){I({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),u$1.push({id:e,status:"skipped",durationMs:0,artifacts:c,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();I({id:e,kind:"stage",status:"started",message:`${e} started`});try{let i=await o(),f=i.exitCode??0,w=i.blocked||f!==0?"blocked":"passed";I({id:e,kind:"stage",status:w,message:i.message}),u$1.push({id:e,status:w,durationMs:Date.now()-k,artifacts:c,exitCode:f,message:i.message});}catch(i){h$3=true;let f=i instanceof Error?i.message:String(i);I({id:e,kind:"stage",status:"failed",message:f}),u$1.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:c,exitCode:1,message:f});}};await y("sync",async()=>{let e=await g(s$1,true),o$1=await o({workspacePath:s$1});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${o$1.contract.projects.length} projects`}});let p$2,d$1=()=>{if(!p$2)throw new Error("canonical workspace model is unavailable");return p$2};await l$2("model",async()=>(p$2={...await r$1({workspacePath:s$1,includeEvidence:true}),build:o$1({mode:"full",engineStatus:"disabled"})},await u(p$2,s$1),{message:`${p$2.summary.projectCount} projects modeled`}));let n$1=ge.join(s$1,p.snapshot),a$4=false;await y("baseline",async()=>{if(!await pe.pathExists(n$1)){let c=await k({workspacePath:s$1,model:d$1()});return await l(c,s$1),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await pe.readJson(n$1),o=h$1(e);return o?(await l(o,s$1),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await l$2("diff",async()=>{let e=await m({workspacePath:s$1,fromPath:p.snapshot,model:d$1()});return await n(e,s$1),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await l$2("impact",async()=>{let e=await p$1({workspacePath:s$1,fromPath:p.diff});return await q$1(e,s$1),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await l$2("doctor-evidence",async()=>{let e=await v({workspace:s$1,json:true,quiet:true,profile:t.strict===true?"enterprise-strict":"local"});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await l$2("contract-evidence",async()=>{let e=await r$2({workspacePath:s$1,strict:true});return await s({workspacePath:s$1,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await l$2("analyze-evidence",async()=>{let e=await a$1({workspacePath:s$1,json:true,strict:t.strict===true});return {blocked:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||t.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await l$2("readiness-evidence",async()=>{let e=await a$2({startPath:s$1,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||t.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await l$2("verify",async()=>{let e$1=await f$1({workspacePath:s$1,fromImpactPath:p.impact});await g$1(e$1,s$1);let o=h$2(e$1,{strict:t.strict===true});return await j$1(s$1,e(e$1,o.passed)),{blocked:!o.passed,exitCode:o.exitCode,message:`${e$1.summary.verdict}; gate ${o.passed?"passed":"blocked"}`}}),await l$2("context",async()=>{let e=await c({workspacePath:s$1,model:d$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$1),{message:`context grounded for ${e.agent}`}}),await l$2("agent-sync",async()=>{let e=await l$1({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"}),o=false,c$1=await a$3(s$1);if(c$1.status==="miss"){if(c$1.reason!=="live-input-mismatch")throw new Error(`Agent grounding left canonical evidence invalid (${c$1.reason}).`);p$2={...await r$1({workspacePath:s$1,includeEvidence:true}),build:o$1({mode:"full",engineStatus:"disabled"})},await u(p$2,s$1);let f=await c({workspacePath:s$1,model:p$2,agent:t.agent??"generic",includeEvidence:true});await d(f,s$1);let w=await l$1({workspacePath:s$1,agent:t.agent??"generic",targets:["all"],write:true,refreshContext:false,strict:t.strict===true,preset:"enterprise"});e={...w,writtenFiles:[...new Set([...e.writtenFiles,...w.writtenFiles])].sort(),strictViolations:[...new Set([...e.strictViolations??[],...w.strictViolations??[]])].sort()};let O=await a$3(s$1);if(O.status==="miss")throw new Error(`Agent grounding reconciliation did not produce fresh canonical evidence (${O.reason}).`);o=true;}let k=e.strictViolations??[],i=t.strict===true&&k.length>0;return {blocked:i,exitCode:i?2:0,message:i?`${e.writtenFiles.length} grounding files written; ${k.length} strict grounding violation(s): ${k.join("; ")}`:`${e.writtenFiles.length} grounding files written; portable entry surfaces prepared for all supported hosts${o?"; canonical Model/Graph freshness sealed":""}`}}),await l$2("explain",async()=>{let e=await b({workspacePath:s$1,target:{kind:"release-blocked"}});await c$1(e,s$1);let o=t.strict===true?u$1.filter(c=>c.status==="blocked").map(c=>c.id):[];return {message:o.length>0&&e.blocking!==true?`Strict policy blocked advisory or incomplete evidence in ${o.join(", ")}. ${e.summary}`:e.summary}});let me=u$1.some(e=>e.status==="blocked"),G=h$3?"failed":me?"blocked":"passed",fe=h$3?1:G==="blocked"?2:0,b$1={schemaVersion:Ee,chainSchemaVersion:a,generatedAt:new Date().toISOString(),workspacePath:s$1,baselineCreated:a$4,preflight:m$1,status:G,exitCode:fe,stages:u$1,artifactPath:L};ue(b$1),await h(s$1,L,b$1);let ke=await j({workspacePath:s$1});return await h(s$1,p.agentIndex,ke),b$1}export{we as a,Ee as b,Ue as c};
|