workspai 0.52.1 → 0.52.3

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.
@@ -1 +1 @@
1
- import {b as b$1,c as c$1}from'./chunk-QURMI7ID.js';import {a as a$2}from'./chunk-HPWLSLMC.js';import {q as q$1}from'./chunk-JXSRYQAR.js';import {a as a$3}from'./chunk-KHEJO3JU.js';import {g}from'./chunk-MZFSINY7.js';import {j,e as e$1}from'./chunk-ZVOEPWQM.js';import {l as l$1}from'./chunk-5XJRCP3D.js';import {c,d}from'./chunk-WJY7ZXVJ.js';import {a as a$1}from'./chunk-LPCL4U4L.js';import {f,g as g$1,h as h$3}from'./chunk-XHRHNVCZ.js';import {k,l,h as h$2,m as m$1,n,p as p$1,q}from'./chunk-PTTZPDLX.js';import {m,p,s}from'./chunk-FUPHQOJB.js';import {o,r as r$1,s as s$1}from'./chunk-B4CPDK6J.js';import {e}from'./chunk-MBRU3VWJ.js';import {b as b$2}from'./chunk-ULR66OJR.js';import {a,b,h as h$1,i,g as g$2,f as f$1}from'./chunk-62K2H72S.js';import {d as d$1}from'./chunk-VRW6KXNK.js';import oe from'path';import ce from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function ie(t,s){return t.length===s.length&&t.every((u,d)=>u===s[d])}function ne(t){b$2(a.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a$1,`chainSchemaVersion must be ${a$1}`),r(t.artifactPath===a.intelligenceRun,`artifactPath must be ${a.intelligenceRun}`),r(t.preflight.length===g$2.length,`preflight must contain exactly ${g$2.length} entries`);for(let[o,i]of g$2.entries()){let a=t.preflight[o];r(a?.id===i,`preflight[${o}].id must be ${i}`),r(ie(a.artifacts,h$1[i]),`${i} preflight artifacts must match the runtime registry`),i==="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===f$1.length,`stages must contain exactly ${f$1.length} canonical steps`);let u=t.preflight[0],d=u?.status==="failed";for(let[o,i$1]of f$1.entries()){let a=t.stages[o];r(a?.id===i$1,`stages[${o}].id must be ${i$1}`),r(ie(a.artifacts,i[i$1].produces),`${i$1} artifacts must match the runtime registry`),d&&r(a.status==="skipped",`${i$1} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${i$1} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${i$1} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${i$1} failed stage must have exitCode 1`),d=true):(r(a.exitCode===0,`${i$1} skipped stage must have exitCode 0`),r(a.durationMs===0,`${i$1} skipped stage must have durationMs 0`)),o===0&&((u?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(u?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(d=true));}let m=t.preflight.some(o=>o.status==="failed")||t.stages.some(o=>o.status==="failed"),y=t.stages.some(o=>o.status==="blocked"),n=m?"failed":y?"blocked":"passed",f=n==="failed"?1:n==="blocked"?2:0;r(t.status===n,`status must be ${n}`),r(t.exitCode===f,`exitCode must be ${f}`);}var me=a.intelligenceRun,fe=b.intelligenceRun,le=me;function h(t){d$1({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 He(t){let s$2=oe.resolve(t.workspacePath),u=[],d$1=[],m$2=false,y=async(e,l)=>{let g=[...h$1[e]];if(m$2){h({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),u.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:g,message:"skipped because a required upstream operation failed"});return}let I=Date.now();h({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let c=await l();h({id:e,kind:"preflight",status:"passed",message:c.message}),u.push({id:e,status:"passed",result:c.result,durationMs:Date.now()-I,artifacts:g,message:c.message});}catch(c){m$2=true;let k=c instanceof Error?c.message:String(c);h({id:e,kind:"preflight",status:"failed",message:k}),u.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-I,artifacts:g,message:k});}},n$1=async(e,l)=>{let g=[...i[e].produces];if(m$2){h({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),d$1.push({id:e,status:"skipped",durationMs:0,artifacts:g,exitCode:0,message:"skipped because a required upstream stage failed"});return}let I=Date.now();h({id:e,kind:"stage",status:"started",message:`${e} started`});try{let c=await l(),k=c.exitCode??0,x=c.blocked||k!==0?"blocked":"passed";h({id:e,kind:"stage",status:x,message:c.message}),d$1.push({id:e,status:x,durationMs:Date.now()-I,artifacts:g,exitCode:k,message:c.message});}catch(c){m$2=true;let k=c instanceof Error?c.message:String(c);h({id:e,kind:"stage",status:"failed",message:k}),d$1.push({id:e,status:"failed",durationMs:Date.now()-I,artifacts:g,exitCode:1,message:k});}};await y("sync",async()=>{let e=await g(s$2,true),l=await o({workspacePath:s$2});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${l.contract.projects.length} projects`}});let f$1,o$1=()=>{if(!f$1)throw new Error("canonical workspace model is unavailable");return f$1};await n$1("model",async()=>(f$1={...await p({workspacePath:s$2,includeEvidence:true}),build:m({mode:"full",engineStatus:"disabled"})},await s(f$1,s$2),{message:`${f$1.summary.projectCount} projects modeled`}));let i$1=oe.join(s$2,a.snapshot),a$4=false;await y("baseline",async()=>{if(!await ce.pathExists(i$1)){let g=await k({workspacePath:s$2,model:o$1()});return await l(g,s$2),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await ce.readJson(i$1),l$1=h$2(e);return l$1?(await l(l$1,s$2),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await n$1("diff",async()=>{let e=await m$1({workspacePath:s$2,fromPath:a.snapshot,model:o$1()});return await n(e,s$2),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await n$1("impact",async()=>{let e=await p$1({workspacePath:s$2,fromPath:a.diff});return await q(e,s$2),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await n$1("doctor-evidence",async()=>{let e=await q$1({workspace:s$2,json:true,quiet:true});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await n$1("contract-evidence",async()=>{let e=await r$1({workspacePath:s$2,strict:true});return await s$1({workspacePath:s$2,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await n$1("analyze-evidence",async()=>{let e=await a$2({workspacePath:s$2,json:true,strict:false});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 n$1("readiness-evidence",async()=>{let e=await a$3({startPath:s$2,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 n$1("verify",async()=>{let e=await f({workspacePath:s$2,fromImpactPath:a.impact});await g$1(e,s$2);let l=h$3(e,{strict:t.strict===true});return await j(s$2,e$1(e,l.passed)),{blocked:!l.passed,exitCode:l.exitCode,message:`${e.summary.verdict}; gate ${l.passed?"passed":"blocked"}`}}),await n$1("context",async()=>{let e=await c({workspacePath:s$2,model:o$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$2),{message:`context grounded for ${e.agent}`}}),await n$1("agent-sync",async()=>({message:`${(await l$1({workspacePath:s$2,agent:t.agent??"generic",write:true,refreshContext:false,strict:false,preset:"enterprise"})).writtenFiles.length} grounding files written`})),await n$1("explain",async()=>{let e=await b$1({workspacePath:s$2,target:{kind:"release-blocked"}});return await c$1(e,s$2),{message:e.summary}});let de=d$1.some(e=>e.status==="blocked"),P=m$2?"failed":de?"blocked":"passed",ue=m$2?1:P==="blocked"?2:0,R={schemaVersion:fe,chainSchemaVersion:a$1,generatedAt:new Date().toISOString(),workspacePath:s$2,baselineCreated:a$4,preflight:u,status:P,exitCode:ue,stages:d$1,artifactPath:le};return ne(R),await e(s$2,le,R),R}export{me as a,fe as b,He as c};
1
+ import {b as b$1,c as c$1}from'./chunk-QURMI7ID.js';import {a as a$2}from'./chunk-HPWLSLMC.js';import {q as q$1}from'./chunk-23JDMHSD.js';import {a as a$3}from'./chunk-3PTIIBRY.js';import {g}from'./chunk-MZFSINY7.js';import {j,e as e$1}from'./chunk-ZVOEPWQM.js';import {l as l$1}from'./chunk-5XJRCP3D.js';import {c,d}from'./chunk-WJY7ZXVJ.js';import {a as a$1}from'./chunk-LPCL4U4L.js';import {f,g as g$1,h as h$3}from'./chunk-XHRHNVCZ.js';import {k,l,h as h$2,m as m$1,n,p as p$1,q}from'./chunk-PTTZPDLX.js';import {m,p,s}from'./chunk-FUPHQOJB.js';import {o,r as r$1,s as s$1}from'./chunk-B4CPDK6J.js';import {e}from'./chunk-MBRU3VWJ.js';import {b as b$2}from'./chunk-ULR66OJR.js';import {a,b,h as h$1,i,g as g$2,f as f$1}from'./chunk-62K2H72S.js';import {d as d$1}from'./chunk-VRW6KXNK.js';import oe from'path';import ce from'fs-extra';function r(t,s){if(!t)throw new Error(`Workspace Intelligence run semantic violation: ${s}`)}function ie(t,s){return t.length===s.length&&t.every((u,d)=>u===s[d])}function ne(t){b$2(a.intelligenceRun,t,"Workspace Intelligence run report"),r(t.chainSchemaVersion===a$1,`chainSchemaVersion must be ${a$1}`),r(t.artifactPath===a.intelligenceRun,`artifactPath must be ${a.intelligenceRun}`),r(t.preflight.length===g$2.length,`preflight must contain exactly ${g$2.length} entries`);for(let[o,i]of g$2.entries()){let a=t.preflight[o];r(a?.id===i,`preflight[${o}].id must be ${i}`),r(ie(a.artifacts,h$1[i]),`${i} preflight artifacts must match the runtime registry`),i==="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===f$1.length,`stages must contain exactly ${f$1.length} canonical steps`);let u=t.preflight[0],d=u?.status==="failed";for(let[o,i$1]of f$1.entries()){let a=t.stages[o];r(a?.id===i$1,`stages[${o}].id must be ${i$1}`),r(ie(a.artifacts,i[i$1].produces),`${i$1} artifacts must match the runtime registry`),d&&r(a.status==="skipped",`${i$1} must be skipped after a hard failure`),a.status==="passed"?r(a.exitCode===0,`${i$1} passed stage must have exitCode 0`):a.status==="blocked"?r(a.exitCode!==0,`${i$1} blocked stage must have a non-zero exitCode`):a.status==="failed"?(r(a.exitCode===1,`${i$1} failed stage must have exitCode 1`),d=true):(r(a.exitCode===0,`${i$1} skipped stage must have exitCode 0`),r(a.durationMs===0,`${i$1} skipped stage must have durationMs 0`)),o===0&&((u?.status==="failed"||a.status==="failed")&&r(s?.status==="skipped","baseline must be skipped when sync or model fails"),s?.status==="skipped"&&r(u?.status==="failed"||a.status==="failed"||a.status==="skipped","baseline may be skipped only after an upstream failure"),s?.status!=="passed"&&(d=true));}let m=t.preflight.some(o=>o.status==="failed")||t.stages.some(o=>o.status==="failed"),y=t.stages.some(o=>o.status==="blocked"),n=m?"failed":y?"blocked":"passed",f=n==="failed"?1:n==="blocked"?2:0;r(t.status===n,`status must be ${n}`),r(t.exitCode===f,`exitCode must be ${f}`);}var me=a.intelligenceRun,fe=b.intelligenceRun,le=me;function h(t){d$1({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 He(t){let s$2=oe.resolve(t.workspacePath),u=[],d$1=[],m$2=false,y=async(e,l)=>{let g=[...h$1[e]];if(m$2){h({id:e,kind:"preflight",status:"skipped",message:`${e} prerequisite skipped after an upstream failure`}),u.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:g,message:"skipped because a required upstream operation failed"});return}let I=Date.now();h({id:e,kind:"preflight",status:"started",message:`${e} prerequisite started`});try{let c=await l();h({id:e,kind:"preflight",status:"passed",message:c.message}),u.push({id:e,status:"passed",result:c.result,durationMs:Date.now()-I,artifacts:g,message:c.message});}catch(c){m$2=true;let k=c instanceof Error?c.message:String(c);h({id:e,kind:"preflight",status:"failed",message:k}),u.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-I,artifacts:g,message:k});}},n$1=async(e,l)=>{let g=[...i[e].produces];if(m$2){h({id:e,kind:"stage",status:"skipped",message:`${e} skipped after an upstream failure`}),d$1.push({id:e,status:"skipped",durationMs:0,artifacts:g,exitCode:0,message:"skipped because a required upstream stage failed"});return}let I=Date.now();h({id:e,kind:"stage",status:"started",message:`${e} started`});try{let c=await l(),k=c.exitCode??0,x=c.blocked||k!==0?"blocked":"passed";h({id:e,kind:"stage",status:x,message:c.message}),d$1.push({id:e,status:x,durationMs:Date.now()-I,artifacts:g,exitCode:k,message:c.message});}catch(c){m$2=true;let k=c instanceof Error?c.message:String(c);h({id:e,kind:"stage",status:"failed",message:k}),d$1.push({id:e,status:"failed",durationMs:Date.now()-I,artifacts:g,exitCode:1,message:k});}};await y("sync",async()=>{let e=await g(s$2,true),l=await o({workspacePath:s$2});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${l.contract.projects.length} projects`}});let f$1,o$1=()=>{if(!f$1)throw new Error("canonical workspace model is unavailable");return f$1};await n$1("model",async()=>(f$1={...await p({workspacePath:s$2,includeEvidence:true}),build:m({mode:"full",engineStatus:"disabled"})},await s(f$1,s$2),{message:`${f$1.summary.projectCount} projects modeled`}));let i$1=oe.join(s$2,a.snapshot),a$4=false;await y("baseline",async()=>{if(!await ce.pathExists(i$1)){let g=await k({workspacePath:s$2,model:o$1()});return await l(g,s$2),a$4=true,{result:"created",message:"initial structural baseline created"}}let e=await ce.readJson(i$1),l$1=h$2(e);return l$1?(await l(l$1,s$2),{result:"reused",message:"legacy structural baseline migrated and reused"}):{result:"reused",message:"existing structural baseline reused"}}),await n$1("diff",async()=>{let e=await m$1({workspacePath:s$2,fromPath:a.snapshot,model:o$1()});return await n(e,s$2),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await n$1("impact",async()=>{let e=await p$1({workspacePath:s$2,fromPath:a.diff});return await q(e,s$2),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await n$1("doctor-evidence",async()=>{let e=await q$1({workspace:s$2,json:true,quiet:true});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await n$1("contract-evidence",async()=>{let e=await r$1({workspacePath:s$2,strict:true});return await s$1({workspacePath:s$2,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await n$1("analyze-evidence",async()=>{let e=await a$2({workspacePath:s$2,json:true,strict:false});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 n$1("readiness-evidence",async()=>{let e=await a$3({startPath:s$2,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 n$1("verify",async()=>{let e=await f({workspacePath:s$2,fromImpactPath:a.impact});await g$1(e,s$2);let l=h$3(e,{strict:t.strict===true});return await j(s$2,e$1(e,l.passed)),{blocked:!l.passed,exitCode:l.exitCode,message:`${e.summary.verdict}; gate ${l.passed?"passed":"blocked"}`}}),await n$1("context",async()=>{let e=await c({workspacePath:s$2,model:o$1(),agent:t.agent??"generic",includeEvidence:true});return await d(e,s$2),{message:`context grounded for ${e.agent}`}}),await n$1("agent-sync",async()=>({message:`${(await l$1({workspacePath:s$2,agent:t.agent??"generic",write:true,refreshContext:false,strict:false,preset:"enterprise"})).writtenFiles.length} grounding files written`})),await n$1("explain",async()=>{let e=await b$1({workspacePath:s$2,target:{kind:"release-blocked"}});return await c$1(e,s$2),{message:e.summary}});let de=d$1.some(e=>e.status==="blocked"),P=m$2?"failed":de?"blocked":"passed",ue=m$2?1:P==="blocked"?2:0,R={schemaVersion:fe,chainSchemaVersion:a$1,generatedAt:new Date().toISOString(),workspacePath:s$2,baselineCreated:a$4,preflight:u,status:P,exitCode:ue,stages:d$1,artifactPath:le};return ne(R),await e(s$2,le,R),R}export{me as a,fe as b,He as c};
@@ -0,0 +1,4 @@
1
+ import {f,e}from'./chunk-T3GJ7YVG.js';import {a,b}from'./chunk-2OIBHUVH.js';import {c}from'./chunk-7MQZQ4UU.js';import {i,j as j$1,l as l$1,k,n}from'./chunk-6HJJHEL6.js';import {a as a$2,e as e$1}from'./chunk-MBRU3VWJ.js';import {b as b$2}from'./chunk-ULR66OJR.js';import {b as b$1,a as a$1}from'./chunk-62K2H72S.js';import {s}from'./chunk-MOSXTVPU.js';import u from'chalk';import l from'fs';import y from'path';var M=a$1.readiness,T=b$1.readiness;function H(t,e){let a=y.resolve(t);if(!b(a))return a;let n=_(e,"workspace.contract.json");if(l.existsSync(n))try{let o=JSON.parse(l.readFileSync(n,"utf-8")),s=Array.isArray(o.projects)?o.projects:[];for(let i of s){let d=g(i),p=typeof d.relativePath=="string"?d.relativePath.trim():"";if(p)return y.join(e,p)}}catch{}let r=J(e),c=Array.isArray(r.payload?.projects)?r.payload.projects:[];for(let o of c){let s=g(o),i=typeof s.path=="string"?s.path.trim():"";if(i)return y.resolve(i)}return a}function L(t){let e=i(t);return j$1(e,t)?"go":l$1(e,t)?"java":k(e,t)?"node":n(e,t)?"python":"unknown"}function z(t,e){if(!l.existsSync(t))return null;let a=l.readdirSync(t).filter(n=>n.endsWith(".json")&&e.some(r=>r.test(n))).map(n=>y.join(t,n));return a.length===0?null:(a.sort((n,r)=>l.statSync(r).mtimeMs-l.statSync(n).mtimeMs),a[0])}function g(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function D(t){for(let e of t)if(l.existsSync(e))return e;return null}function _(t,...e){let a=s(t,...e);return D(a)??a[0]}function j(t,e){let a=a$2(t,`.workspai/reports/${e}`);return D([a,y.join(t,".rapidkit","reports",e)])??a}async function K(t){let{readWorkspaceRegistrySummary:e,resolveWorkspaceRegisteredProjects:a}=await import('./workspace-registry-summary-HOQ3OBNT.js'),n=await e(t);return n?n.projectCount:(await a(t)).summary.projectCount}function q(t,e,a){let n=_(t,"toolchain.lock");if(!l.existsSync(n))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run workspai bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:n};try{let r=JSON.parse(l.readFileSync(n,"utf-8")),c=g(r.runtime),s=["python","node","go","java"].filter(p=>{let f=g(c[p]);return typeof f.version=="string"&&f.version.trim().length>0});if(s.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via workspai setup <runtime> and re-run bootstrap."],evidencePath:n};let d=[...new Set((Array.isArray(e)?e:[e]).filter(p=>p!=="unknown"))].filter(p=>{let f=g(c[p]);return typeof f.version!="string"||f.version.trim().length===0});return d.length>0?{gate:"env",status:"fail",summary:`${a?.hasRegisteredProjects?"Project runtime":"Workspace"}${d.length===1?"":"s"} (${d.join(", ")}) ${d.length===1?"is":"are"} not pinned in toolchain.lock`,details:d.map(f=>`Run workspai setup ${f} and workspai bootstrap to lock ${f} for this workspace.`),evidencePath:n}:{gate:"env",status:"pass",summary:`Pinned runtimes: ${s.join(", ")}`,details:[],evidencePath:n}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with workspai bootstrap."],evidencePath:n}}}function J(t){let e=j(t,"doctor-last-run.json");if(!l.existsSync(e))return {payload:null,path:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));return c(a,"workspace")?{payload:a,path:e}:{payload:null,path:e}}catch{return {payload:null,path:e}}}function B(t){let e=J(t);if(!e.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run workspai doctor workspace --json before release readiness checks."],evidencePath:e.path},payload:null};let a=g(e.payload.summary),n=Number(a.totalIssues??0);return a.hasSystemErrors?{gate:{gate:"doctor",status:"fail",summary:"Doctor reported system errors",details:["Resolve system-level doctor errors before proceeding."],evidencePath:e.path},payload:e.payload}:n>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${n} issue(s)`,details:["Run workspai doctor workspace --fix and re-run readiness checks."],evidencePath:e.path},payload:e.payload}:{gate:{gate:"doctor",status:"pass",summary:"Doctor checks passed without issues",details:[],evidencePath:e.path},payload:e.payload}}function U(t){let e=j(t,"analyze-last-run.json");if(!l.existsSync(e))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run workspai analyze --json before release readiness checks."],evidencePath:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));b$2(a$1.analyze,a,e);let n=g(a.summary),r=String(n.verdict??"").toLowerCase(),c=Number(n.score??0),o=g(n.findings),s=Number(o.fail??0);return r==="blocked"||s>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${c}/100)`,details:["Resolve analyze findings and regenerate analyze-last-run.json."],evidencePath:e}:r==="needs-attention"?{gate:"analyze",status:"warn",summary:`Analyze needs attention (score ${c}/100)`,details:["Review analyze warnings before release."],evidencePath:e}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${c}/100)`,details:[],evidencePath:e}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid or violates its contract",details:["Re-run workspai analyze --json to regenerate evidence."],evidencePath:e}}}function Q(t){try{let e=JSON.parse(l.readFileSync(t,"utf-8")),a=String(e.status??"").toLowerCase(),n=g(e.summary),r=Number(n.failedChecks??0);return a==="fail"||r>0?{gate:"verify",status:"fail",summary:"Verify-pack contract reports failed checks",details:["Fix failed verify checks and regenerate verify-pack contract evidence."],evidencePath:t}:a==="pass"?{gate:"verify",status:"pass",summary:"Verify-pack contract passed",details:[],evidencePath:t}:{gate:"verify",status:"warn",summary:"Verify-pack contract status is not explicit",details:["Ensure contract status is pass/fail and keep schema aligned with v1 contract."],evidencePath:t}}catch{return {gate:"verify",status:"fail",summary:"Verify-pack contract is invalid JSON",details:["Regenerate verify-pack contract artifact."],evidencePath:t}}}async function X(t,e){if(e.skipVerify)return {gate:"verify",status:"pass",summary:"Verify gate skipped (--skip-verify)",details:["Verification was explicitly skipped for this readiness run."]};let a=[a$2(t,".workspai/reports"),y.join(t,".rapidkit","reports")],n=a[0],r=a.map(s=>z(s,[/verify-pack-contract/i,/^verify.*\.json$/i])).find(s=>typeof s=="string")??null;if(r)return Q(r);let c=a$2(t,a$1.contractVerify),o=a.map(s=>z(s,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i])).find(s=>typeof s=="string")??null;if(o)try{let s=JSON.parse(l.readFileSync(o,"utf-8")),i=String(s.status??"").toLowerCase();if(i==="passed"||i==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(i==="failed"||i==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(s.violations)?s.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:s}=await import('./workspace-contract-AZFISDLS.js'),i=await s({workspacePath:t}),d={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:i.status,contractPath:i.contractPath,projectCount:i.projectCount,checks:i.checks,violations:i.violations};return await e$1(t,a$1.contractVerify,d),i.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:i.violations.slice(0,5),evidencePath:c}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:c}}catch(s){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run workspai workspace contract verify --json or export verify-pack contract from CI.",s instanceof Error?s.message:String(s)],evidencePath:y.join(n,"*verify*.json")}}}function Y(t,e){let a=j(e,"doctor-last-run.json");if(!t)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run workspai doctor workspace --json to include dependency findings."],evidencePath:a};let n=Array.isArray(t.projects)?t.projects:[],r=n.reduce((o,s)=>{let i=Number(s.vulnerabilities??0);return Number.isFinite(i)?o+Math.max(0,i):o},0),c=n.filter(o=>o.depsInstalled===false).length;return r>0?{gate:"dependency",status:"fail",summary:`${r} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:a}:c>0?{gate:"dependency",status:"warn",summary:`${c} project(s) report missing dependencies`,details:["Run project init/bootstrap and regenerate doctor evidence."],evidencePath:a}:{gate:"dependency",status:"pass",summary:"No dependency vulnerabilities reported",details:[],evidencePath:a}}function Z(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}async function ee(t,e){return e$1(t,M,e)}async function te(t={}){let e$1=y.resolve(t.startPath??process.cwd()),a$1=a(e$1)??e$1,n=await K(a$1)>0,r=n&&b(e$1)?a$1:H(e$1,a$1),c=r===a$1?"unknown":L(r),o=n?c:"unknown";if(n&&r===a$1){let{resolveWorkspaceRegisteredProjects:m}=await import('./workspace-registry-summary-HOQ3OBNT.js');o=(await m(a$1)).summary.projects.map(F=>L(y.resolve(a$1,F.relativePath)));}let s=q(a$1,o,{hasRegisteredProjects:n}),i=B(a$1),d=U(a$1),p=await X(a$1,{skipVerify:t.skipVerify}),f$1=Y(i.payload,a$1),w=[s,i.gate,d,p,f$1],k=Z(w),v={schemaVersion:T,generatedAt:new Date().toISOString(),workspacePath:a$1,projectPath:r,action:t.action,overallStatus:k,blocking:k==="fail",blockingReasons:w.filter(m=>m.status==="fail").map(m=>`${m.gate}: ${m.summary}`),gates:w};if(t.writeReport!==false){let m=f(v,{commandId:"workspaceReadiness",exitCode:k==="fail"?2:k==="warn"?1:0,generatedAt:v.generatedAt,blockers:v.blockingReasons,runId:e()});v.evidencePath=await ee(a$1,m);}return v}function ae(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}function ne(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}async function he(t){let e=await te({startPath:t.workspace,writeReport:true,skipVerify:t.skipVerify===true});if(t.json)console.log(JSON.stringify(e,null,2));else {console.log(u.bold.cyan(`
2
+ \u{1F6A6} Workspai Release Readiness
3
+ `)),console.log(u.bold(`Workspace: ${u.cyan(y.basename(e.workspacePath))}`)),console.log(u.gray(`Path: ${e.workspacePath}`)),console.log(`Overall: ${ne(e.overallStatus)}`);for(let a of e.gates){console.log(` - ${a.gate}: ${ae(a.status)} ${a.summary}`);for(let n of a.details)console.log(u.gray(` ${n}`));a.evidencePath&&console.log(u.gray(` evidence: ${a.evidencePath}`));}e.evidencePath&&console.log(u.gray(`
4
+ Evidence saved: ${e.evidencePath}`));}t.strict&&e.overallStatus!=="pass"&&process.exit(1);}export{te as a,he as b};
@@ -0,0 +1,4 @@
1
+ import {d,b as b$1,e}from'./chunk-GHB6QMQH.js';import {d as d$2}from'./chunk-S5KTATOU.js';import {a}from'./chunk-27UR373Z.js';import {p as p$1,w,t as t$1}from'./chunk-6HJJHEL6.js';import {h,j,f,e as e$1}from'./chunk-2PY65U6X.js';import {d as d$1}from'./chunk-MBRU3VWJ.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {t,p,s}from'./chunk-MOSXTVPU.js';import {e as e$2,g}from'./chunk-RJIYCDVC.js';import G from'fs';import b from'path';import E from'chalk';import {execa}from'execa';function Ee(e){return G.existsSync(b.join(e,"bun.lock"))||G.existsSync(b.join(e,"bunfig.toml"))?"bun":G.existsSync(b.join(e,"pnpm-lock.yaml"))?"pnpm":G.existsSync(b.join(e,"yarn.lock"))?"yarn":(G.existsSync(b.join(e,"package-lock.json")),"npm")}function Ce(e,r,t=Ee(e)){return t==="npm"?`npm run ${r}`:`${t} run ${r}`}function Pe(e,r=Ee(e)){return `${r} install`}var ze={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},Ve={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function Y(e,r){if(r){let t=r.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=e$1(r),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:t==="fiber"?"fiber":t==="aspnetcore"||t==="asp-net-core"?"aspnetcore":t}`;return ze[s]}}function Te(e,r,t){if(r){let n=Y(e,r);if(n&&n.commands[t])return n.commands[t]}if(["init","test","build","start"].includes(t)){let n=Ve[t]?.[e]??[];return n.length>0?n[0]:void 0}}var Je={test:"test",build:"build",start:"start"};function ae(e){if(e.stage==="init")return e.runtime==="node"?Pe(e.projectPath):Te(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let r=Je[e.stage];if(r){let t=t$1(e.projectPath,r,{framework:e.framework});if(t)return Ce(e.projectPath,t.scriptName)}}return Te(e.runtime,e.framework,e.stage)}function qe(e){let r=h(e).map(t=>t==="python"?"python":t==="node"||t==="bun"?"node":t==="go"?"go":t==="java"?"java":t==="php"?"php":t==="rust"?"rust":t==="dotnet"?"dotnet":t==="elixir"?"elixir":t==="ruby"?"ruby":t==="clojure"||t==="scala"||t==="kotlin"?"jvm-generic":null).filter(t=>t!==null).filter((t,n,o)=>o.indexOf(t)===n);return {primary:r.length>0?r[0]:"unknown",secondary:r.slice(1)}}function Ne(e){return qe(e).primary}function ie(e,r){if(!e)return "unknown";r||(r={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[t,n]of Object.entries(r))for(let o of n)if(new RegExp(o,"i").test(e))return t;return "unknown"}async function Q(e){let r=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(r))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[r],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${r}' not found or not executable`}}function We(e,r,t){if(!r)return e;let n=typeof r=="object"&&!Array.isArray(r)&&("dev"in r||"staging"in r||"prod"in r||"default"in r)&&!Object.keys(r).some(o=>["init","test","build","start"].includes(o))?r:{};return t&&typeof n[t]=="string"?n[t]:typeof n.default=="string"?n.default:e}async function De(e,r){if(!e)return {healthy:true};switch(e.type){case "port":{let t=e.value;try{let n=await import('net');return new Promise(o=>{let s=new n.Socket,c=5e3;s.setTimeout(c),s.on("connect",()=>{s.destroy(),o({healthy:true,reason:`Port ${t} is listening`});}),s.on("timeout",()=>{s.destroy(),o({healthy:false,reason:`Port ${t} timeout after ${c}ms`});}),s.on("error",u=>{s.destroy(),o({healthy:false,reason:`Port ${t} error: ${String(u)}`});}),s.connect(t,"localhost");})}catch(n){return {healthy:false,reason:`Port check error: ${n instanceof Error?n.message:String(n)}`}}}case "http":{let t=e.value,n;try{let o=new AbortController;n=setTimeout(()=>o.abort(),5e3);let s=await fetch(t,{method:"GET",signal:o.signal});return {healthy:s.status===200,reason:`HTTP ${s.status}`,metadata:{status:s.status}}}catch(o){return {healthy:false,reason:`HTTP check error: ${o instanceof Error?o.message:String(o)}`}}finally{n&&clearTimeout(n);}}case "log":{let t=e.value;if(!r)return {healthy:true};try{let n=[b.join(r,".workspai","last-run.log"),b.join(r,".rapidkit","last-run.log")].find(o=>G.existsSync(o));if(n){let o=G.readFileSync(n,"utf-8"),s=new RegExp(t,"i");return {healthy:s.test(o),reason:s.test(o)?"Log pattern found":"Log pattern not found"}}return {healthy:true,reason:"No log file to check"}}catch(n){return {healthy:false,reason:`Log check error: ${n instanceof Error?n.message:String(n)}`}}}case "command":{let t=e.value;try{let n=await execa(t,[],{cwd:r,reject:false,shell:true});return {healthy:n.exitCode===0,reason:n.exitCode===0?"Health check passed":"Health check failed",metadata:{exitCode:n.exitCode}}}catch(n){return {healthy:false,reason:`Command check error: ${n instanceof Error?n.message:String(n)}`}}}default:return {healthy:true}}}var Me={init:"init",test:"test",build:"build",start:"start"};function Ye(e){return e in Me?Me[e]:null}function Qe(e,r){let n=p$1(e)?.contextJson?.commands;if(!n||typeof n!="object"||Array.isArray(n))return;let o=n[r];if(typeof o=="string"&&o.trim().length>0)return o.trim();if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o,c=s.default??s.dev;if(typeof c=="string"&&c.trim().length>0)return c.trim()}}function Ie(e,r,t=w(e)){let n=Ye(r);if(!n)return Qe(e,r)?{supported:true}:{supported:false,reason:`Workspace stage "${r}" is not part of the Workspai fleet contract.`};if(!t.projectRoot)return {supported:false,reason:"No Workspai project metadata was detected for this target."};let o=t.commandMap[n];if(!o||o.status!=="supported"){let s=t.runtimeSupportTier==="observed"||t.frameworkSupportTier==="observed";return {supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`,shouldFail:!s}}return {supported:true}}var Xe=new Set(["init","test","build","start"]),Ze=new Set([".git","node_modules",".workspai",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function _(e){try{return await G.promises.access(e,G.constants.F_OK),true}catch{return false}}async function et(e){for(let r of e)if(await _(r))return true;return false}async function tt(e,r,t){if(r==="python"){let o=[b.join(e,".workspai","cli.py"),b.join(e,".rapidkit","cli.py")];for(let s of o)if(await _(s))return {valid:true};return {valid:false,reason:"Project-local .workspai/cli.py is missing. Run `workspai init` in this project first."}}let n=t.trim().split(/\s+/)[0];if(n&&["npm","npx","pnpm","yarn"].includes(n)){let o=e$2(n);if((await execa(o.command,[...o.prefixArgs,"--version"],{reject:false,env:g()})).exitCode===0)return {valid:true}}return Q(t)}async function de(e){let r=await G.promises.readFile(e,"utf-8");return JSON.parse(r)}function T(e){return e.replace(/\\/g,"/")}function rt(e){let r=e?.trim();return r?r.startsWith("project:")?r.slice(8).trim()||null:r:null}async function nt(e){return a(e,{skipDirs:Ze,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(r,t$1)=>await et([...t(r,"context.json"),...t(r,"project.json")])?true:b.resolve(r)===b.resolve(t$1)?false:h(r).length>0})}async function ot(e){for(let r of [b.join(".workspai","project.json"),b.join(".workspai","context.json"),b.join(".rapidkit","project.json"),b.join(".rapidkit","context.json")]){let t=b.join(e,r);if(await _(t))try{let n=await de(t),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function st(e,r,t){let n=rt(t);if(!n)return {projects:r,normalizedScope:null};let o=T(n).toLowerCase(),s=[];for(let c of r){let u=T(b.relative(e,c)),p=b.basename(c),m=await ot(c);[u,p,m].filter(a=>typeof a=="string"&&a.length>0).map(a=>T(a).toLowerCase()).includes(o)&&s.push(c);}if(s.length===0)throw new Error(`Workspace run scope did not match any project: ${t}`);return {projects:s,normalizedScope:n}}async function at(e,r,t){let n=await execa("git",["diff","--name-only",`${t}...HEAD`],{cwd:e,reject:false,env:a$1()});if(n.exitCode!==0)return new Set(r);let o=n.stdout.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0).map(c=>T(c));if(o.length===0)return new Set;let s=new Set;for(let c of r){let u=T(b.relative(e,c));if(!u||u===".")continue;let p=`${u}/`;o.some(m=>m===u||m.startsWith(p))&&s.add(c);}return s}async function it(e,r,t){let n=await d$1(e,".workspai/workspace.contract.json")??p(e,"workspace.contract.json");if(await _(n))try{let d=await ct(e,r,t,n);if(d.graphStatus!=="missing")return d}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let o=await d$1(e,".workspai/workspace-dependency-graph.json")??p(e,"workspace-dependency-graph.json");if(!await _(o))return {expanded:t,graphStatus:"missing",expansionDepth:0};let s;try{s=await de(o);}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let c=new Set(r.map(d=>b.resolve(d))),u=new Map;if(!s||typeof s!="object"||Array.isArray(s))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let p$1=Array.isArray(s.projects)?s.projects:[];for(let d of p$1){if(!d||typeof d!="object"||Array.isArray(d))continue;let a=d,l=typeof a.path=="string"?a.path:"",h=b.resolve(e,l);if(!c.has(h))continue;let k=Array.isArray(a.dependsOn)?a.dependsOn.filter(R=>typeof R=="string"):[];for(let R of k){let g=b.resolve(e,R);c.has(g)&&(u.has(g)||u.set(g,new Set),u.get(g)?.add(h));}}let m=d$2(u,t);return {expanded:m.reached,graphStatus:"loaded",expansionDepth:m.added}}async function ct(e,r,t,n){let o=await de(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let s=o,c=Array.isArray(s.projects)?s.projects:null;if(!c)return {expanded:t,graphStatus:"invalid",expansionDepth:0};let u=new Map,p=new Map;for(let h of r){let k=T(b.relative(e,h));p.set(k,b.resolve(h));}let m=new Map,d=new Map,a=new Map;for(let h of c){if(!h||typeof h!="object"||Array.isArray(h))continue;let k=h,R=typeof k.slug=="string"?k.slug:"",g=typeof k.relativePath=="string"?T(k.relativePath):R,x=p.get(g);!R||!x||u.set(R,x);}for(let h of c){if(!h||typeof h!="object"||Array.isArray(h))continue;let k=h,R=typeof k.slug=="string"?k.slug:"",g=u.get(R);if(!g)continue;let x=k.contracts&&typeof k.contracts=="object"&&!Array.isArray(k.contracts)?k.contracts:{},S=Array.isArray(x.dependsOn)?x.dependsOn.filter(v=>typeof v=="string"):[],O=Array.isArray(x.publishes)?x.publishes.filter(v=>typeof v=="string"):[],I=Array.isArray(x.consumes)?x.consumes.filter(v=>typeof v=="string"):[];for(let v of S){let j=u.get(v);j&&(a.has(j)||a.set(j,new Set),a.get(j)?.add(g));}for(let v of O)m.has(v)||m.set(v,new Set),m.get(v)?.add(g);for(let v of I)d.has(v)||d.set(v,new Set),d.get(v)?.add(g);}for(let[h,k]of m.entries()){let R=d.get(h);if(R)for(let g of k){a.has(g)||a.set(g,new Set);for(let x of R)x!==g&&a.get(g)?.add(x);}}let l=d$2(a,t);return {expanded:l.reached,graphStatus:"loaded",expansionDepth:l.added}}async function ut(e,r){if(typeof r=="boolean")return r;let t=s(e,"policies.yml").find(s=>G.existsSync(s))??p(e,"policies.yml");if(!await _(t))return true;let n="";try{n=await G.promises.readFile(t,"utf-8");}catch{return true}let o=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o?o[1]==="true":true}function dt(e){let r=process.env.RAPIDKIT_WORKSPACE_RUN_STAGE_TIMEOUT_MS;if(r){let t=Number.parseInt(r,10);if(Number.isFinite(t)&&t>0)return t}return e==="init"?12e4:9e4}function $e(e,r){let t=Number.parseInt(process.env[e]??"",10);return Number.isFinite(t)&&t>0?t:r}function ce(e){return new Promise(r=>setTimeout(r,e))}async function lt(e){let r=process.argv[1];if(e.useRapidkitWrapper&&!r)return {exitCode:1,stdout:"",stderr:"Workspai entrypoint is unavailable for startup verification.",healthStatus:{healthy:false,reason:"Workspai entrypoint is unavailable."}};let t=e.useRapidkitWrapper?execa(process.execPath,[r,"start"],{cwd:e.projectPath,reject:false,timeout:e.timeoutMs,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}}):execa(e.finalCommand,[],{cwd:e.projectPath,reject:false,shell:true,timeout:e.timeoutMs}),n=Promise.resolve(t).then(d=>({kind:"exit",result:d}),d=>({kind:"error",error:d})),o=$e("WORKSPAI_WORKSPACE_RUN_STARTUP_GRACE_MS",2e3),s=await Promise.race([n,ce(o).then(()=>({kind:"alive"}))]);if(s.kind==="error"){let d=typeof s.error=="object"&&s.error!==null&&"timedOut"in s.error&&!!s.error.timedOut;return {exitCode:d?124:1,stdout:"",stderr:s.error instanceof Error?s.error.message:String(s.error),timedOut:d,healthStatus:{healthy:false,reason:"The start command failed before readiness."}}}if(s.kind==="exit"){let d=Number(s.result.exitCode??0);return {exitCode:d,stdout:String(s.result.stdout??""),stderr:String(s.result.stderr??""),healthStatus:{healthy:d===0,reason:d===0?"The start command completed successfully.":`The start command exited with code ${d} before readiness.`}}}let c=Y(e.runtime,e.framework)?.healthCheck,u=c?{healthy:false,reason:"The configured health check has not passed yet."}:{healthy:true,reason:`The service remained alive for ${o}ms (bounded startup smoke).`};if(c){let d=$e("WORKSPAI_WORKSPACE_RUN_STARTUP_HEALTH_TIMEOUT_MS",15e3),a=Date.now()+d;for(;Date.now()<a;){let l=await De(c,e.projectPath);if(u={healthy:l.healthy,reason:l.reason},l.healthy)break;if((await Promise.race([n,ce(350).then(()=>({kind:"alive"}))])).kind!=="alive"){u={healthy:false,reason:"The service exited before its configured health check passed."};break}}}try{t.kill?.("SIGTERM",{forceKillAfterDelay:1e3});}catch{try{t.kill?.();}catch{}}let p=await Promise.race([n,ce(2e3).then(()=>({kind:"alive"}))]),m=p.kind==="exit"?p.result:void 0;return {exitCode:u.healthy?0:1,stdout:String(m?.stdout??""),stderr:String(m?.stderr??""),healthStatus:u}}async function ue(e,r,t){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};try{let o=await execa(process.execPath,[n,...e],{cwd:r,reject:false,timeout:t,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr}}catch(o){return {exitCode:typeof o=="object"&&o!==null&&"timedOut"in o&&!!o.timedOut?124:1,stdout:typeof o=="object"&&o!==null&&"stdout"in o?String(o.stdout??""):"",stderr:typeof o=="object"&&o!==null&&"stderr"in o?String(o.stderr??""):o instanceof Error?o.message:String(o)}}}function pt(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"||e==="rust"||e==="php"}function mt(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function ft(e){let r=process.cwd();try{process.chdir(e);let{handleInitCommand:t}=await import('./index.js');return {exitCode:await t(["init"]),stdout:"",stderr:""}}finally{process.chdir(r);}}async function gt(e){let r=a=>{let l=f(a);return l==="node"||l==="bun"?"node":l==="python"?"python":l==="go"?"go":l==="java"?"java":l==="php"?"php":l==="ruby"?"ruby":l==="rust"?"rust":l==="dotnet"?"dotnet":l==="elixir"?"elixir":l==="clojure"||l==="scala"||l==="kotlin"?"jvm-generic":Ne(e)},t=a=>{if(!a)return;let l=e$1(a);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(l))return l},n=p$1(e),o=n?.detection??j(e,n?.projectJson??null),s=n?.contextJson,c=r(o.runtime),u=t(o.key),p={},m=new Set(["init","test","build","start"]);if(s?.commands&&typeof s.commands=="object")for(let[a,l]of Object.entries(s.commands))typeof l=="string"&&m.has(a)&&(p[a]=l);let d;if(s?.commandEnvironments&&typeof s.commandEnvironments=="object"){let a=s.commandEnvironments;d={dev:typeof a.dev=="string"?a.dev:void 0,staging:typeof a.staging=="string"?a.staging:void 0,prod:typeof a.prod=="string"?a.prod:void 0,default:typeof a.default=="string"?a.default:void 0};}return {runtime:c,framework:u,commandOverrides:Object.keys(p).length>0?p:void 0,environmentCommandVariants:d,environment:typeof s?.environment=="string"?s.environment:void 0}}async function yt(e,r,t,n,o,s,c){let u=!o?.[r]&&pt(t),p;if(o&&o[r]?p=o[r]:u?p=`rapidkit ${r}`:p=ae({projectPath:e,runtime:t,framework:n,stage:r}),!p)return {exitCode:127,command:`<stage not supported for ${t}>`,message:`No stage command found for runtime '${t}' and framework '${n||"unknown"}'`,errorCategory:"runtime"};let m=We(p,s,c);if(!m)return {exitCode:127,command:p,message:"Failed to resolve stage command",errorCategory:"runtime"};let d=ae({projectPath:e,runtime:t,framework:n,stage:r});if(u){if(d){let y=u?await tt(e,t,d):await Q(d);if(!y.valid)return {exitCode:127,command:m,message:y.reason||"Command not available",errorCategory:"setup"}}}else {let y=await Q(m);if(!y.valid)return {exitCode:127,command:m,message:y.reason||"Command not available",errorCategory:"setup"}}let a=0,l="",h="",k,R,g=dt(r),x=Date.now();try{let y=r==="start"?await lt({projectPath:e,finalCommand:m,useRapidkitWrapper:u,runtime:t,framework:n,timeoutMs:g}):u?r==="init"&&mt()?await ft(e):await ue([r],e,g):await execa(m,[],{cwd:e,reject:false,shell:true,timeout:g});if(a=Number(y.exitCode??0),l=y.stdout,h=y.stderr,R=r==="start"?y.healthStatus:void 0,a!==0){let C=`${l}
2
+ ${h}`,U=Date.now()-x;k=a===124||ie(C)==="timeout"||a===143&&U>=Math.floor(g*.8)?"timeout":ie(C);}}catch(y){let C=typeof y=="object"&&y!==null&&"timedOut"in y&&!!y.timedOut;return {exitCode:C?124:1,command:m,message:C?`Stage timed out after ${g}ms`:y instanceof Error?y.message:"Command execution failed",errorCategory:C?"timeout":"runtime"}}let S=`${l}
3
+ ${h}`.split(/\r?\n/).map(y=>y.trim()).filter(Boolean),O=S.slice(0,6).join(`
4
+ `),I=Date.now()-x,v=a===124||k==="timeout"||a===143&&I>=Math.floor(g*.8),j=a===0?void 0:v?"timeout":k,W=a===0||!j?void 0:{category:j,exitCode:a,command:m,timedOut:v,timeoutMs:g,...O?{outputExcerpt:O}:{}};return {exitCode:a,command:m,errorCategory:j,healthStatus:R,failureDiagnostic:W,message:v?`Stage timed out after ${g}ms`:a!==0?O?`Stage failed with exit code ${a}: ${S[0]}`:`Stage failed with exit code ${a}`:void 0}}function _e(e){try{return JSON.parse(e)}catch{return null}}function ht(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx workspai setup dotnet` or `npx workspai init`.";case "go":return "Install Go 1.21+, then rerun `npx workspai setup go` or `npx workspai init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx workspai setup java` or `npx workspai init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx workspai setup node` or `npx workspai init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx workspai setup python` or `npx workspai init`.";default:return null}}async function kt(e){let r=[],t=await ue(["doctor","workspace","--json"],e);if(t.exitCode!==0)r.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let s=_e(t.stdout)?.healthScore,c=Number(s?.errors??0);Number.isFinite(c)&&c>0?r.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${c} error(s)`}):r.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let n=await ue(["readiness","--json"],e);if(n.exitCode!==0)r.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let o=_e(n.stdout),s=String(o?.overallStatus??"").toLowerCase();s==="fail"?r.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):s==="warn"?r.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):r.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return r}var wt=new Set(["dev","stop"]);function bt(e){let r=e.trim();return !r||wt.has(r.toLowerCase())?false:Xe.has(r)?true:/^[a-z][a-z0-9_-]*$/i.test(r)}function Le(e,r,t){let n=T(b.relative(t,r));return (Array.isArray(e.projects)?e.projects:[]).some(s=>{if(!s||typeof s!="object")return false;let c=s,u=[c.relativePath,c.path].filter(p=>typeof p=="string"&&p.length>0).map(p=>T(p));return c.status==="passed"&&(u.includes(n)||u.some(p=>p.endsWith(`/${n}`)))})}function xt(e,r){return Y(e,r)?.dependencies??[]}function vt(e,r){let t=Math.max(1,Math.min(4,r)),n=Number(e??t);return Number.isFinite(n)?Math.max(1,Math.min(16,Math.trunc(n))):t}async function rr(e$1){if(!bt(e$1.stage))throw new Error(`Unsupported workspace run stage: ${e$1.stage}`);let r=Date.now(),t=b.resolve(e$1.workspacePath),n=await d(t),o=await nt(t),{projects:s,normalizedScope:c}=await st(t,o,e$1.scope),u=e$1.affected===true,p=e$1.blastRadius===true,m=e$1.since?.trim()||"HEAD~1",d$1=u?await at(t,s,m):new Set(s),a,l="not-applicable",h=0,k="all";if(u&&p){let f=await it(t,o,d$1);a=f.expanded,l=f.graphStatus,h=f.expansionDepth,k="affected+blast-radius";}else u?(a=d$1,k="affected"):(a=d$1,k="all");let R=e$1.stage==="init"?false:await ut(t,e$1.enforceGates),g=R?await kt(t):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],x=g.find(f=>f.status==="fail"),S=s.filter(f=>a.has(f)),O=e$1.continueOnError===true||e$1.stage==="init",I=e$1.parallel===true,v=vt(e$1.maxWorkers,S.length),j=S.length,W=0;e$1.json||console.log(E.gray(`Workspace run (${e$1.stage}) started: ${j} target(s), ${I?`parallel x${v}`:"sequential"}`));let y=new Map;for(let f of o){let w=T(b.relative(t,f)),i=s.includes(f),A=i&&a.has(f);y.set(f,{path:f,relativePath:w,projectName:b.basename(w)||b.basename(f),selected:A,affected:A,status:"skipped",exitCode:null,durationMs:0,reason:A?void 0:i?"not affected":"outside scope",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});}if(x)for(let f of S){let w=y.get(f);w&&(w.status="skipped",w.reason=`blocked by ${x.gate}`);}else {let f=async w=>{let i=y.get(w);if(!i)return;let A=T(b.relative(t,w));e$1.json||console.log(E.gray(`\u23F3 [${W}/${j}] ${e$1.stage} ${A}`)),i.selected=true,i.affected=true;let F=Date.now(),{runtime:P,framework:N,commandOverrides:Ke,environmentCommandVariants:Ue,environment:He}=await gt(w);i.runtimeDetected=P,i.framework=N;let X=Ie(w,e$1.stage);if(!X.supported){i.status=X.shouldFail===false?"skipped":"failed",i.reason=X.reason??`stage "${e$1.stage}" unsupported for project`,i.durationMs=Date.now()-F,i.exitCode=i.status==="failed"?127:null,i.status==="failed"&&(i.errorCategory="setup",i.errorMessage=i.reason),W+=1;return}if(e$1.reusePassed&&n){let D=n.stages[e$1.stage]??n.stages[e$1.stage];if(D&&Le(D,w,t)){i.status="passed",i.reason="reused passed result from workspace-run-last.json",i.durationMs=Date.now()-F,i.exitCode=0,W+=1,e$1.json||console.log(E.gray(`\u21BA reused passed cache for ${A}`));return}}let fe=xt(P,N).filter(D=>D!==e$1.stage);if(fe.length>0&&n){let D=fe.find(Z=>{let L=n.stages[Z];return !L||!Le(L,w,t)});if(D){i.status="skipped",i.reason=`dependency stage "${D}" not satisfied in workspace-run-last.json`,i.durationMs=Date.now()-F,i.exitCode=null,W+=1;return}}let M=await yt(w,e$1.stage,P,N,Ke,Ue,He);if(i.executionCommand=M.command,i.errorCategory=M.errorCategory,i.healthStatus=M.healthStatus,i.failureDiagnostic=M.failureDiagnostic,i.durationMs=Date.now()-F,i.exitCode=M.exitCode,M.exitCode===0?(i.status="passed",i.reason=void 0):(i.status="failed",i.reason=M.message||"stage command failed",i.errorMessage=M.message),W+=1,!e$1.json){let D=j>0?Math.round(W/j*100):100,Z=i.status==="passed"?E.green("\u2705"):E.red("\u274C");if(console.log(E.gray(`${Z} [${W}/${j}] (${D}%) ${A} ${i.durationMs}ms`)),i.status==="failed"){i.reason&&console.log(E.red(` Reason: ${i.reason}`)),i.executionCommand&&console.log(E.gray(` Command: ${i.executionCommand}`));let L=ht(i.runtimeDetected);L&&i.errorCategory==="setup"&&console.log(E.gray(` Hint: ${L}`));}}};if(I&&S.length>1){let w=0,i=false,A=new Array(v).fill(null).map(async()=>{for(;w<S.length;){if(i&&!O)return;let F=w;w+=1;let P=S[F];await f(P),y.get(P)?.status==="failed"&&(i=true);}});if(await Promise.all(A),!O&&i){let F=false;for(let P of S){let N=y.get(P);if(N){if(N.status==="failed"){F=true;continue}F&&N.status==="skipped"&&(N.reason=N.reason||"stopped after failure");}}}}else for(let w of S){await f(w);let i=y.get(w);if(!O&&i?.status==="failed"){let A=S.slice(S.indexOf(w)+1);for(let F of A){let P=y.get(F);P&&(P.status="skipped",P.reason="stopped after failure");}break}}}let C=[];for(let f of o){let w=y.get(f);w&&C.push(w);}let U=C.filter(f=>f.status==="passed").length,H=C.filter(f=>f.status==="failed").length,le=C.filter(f=>f.status==="skipped").length,pe=e$1.strict===true,Ge=H>0||pe&&g.some(f=>f.status==="fail"||f.status==="warn")?1:0,me={schemaVersion:"1.0",workspacePath:t,stage:e$1.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-r,options:{affected:u,blastRadius:p,since:u?m:null,parallel:I,maxWorkers:v,continueOnError:O,strict:pe,enforceGates:R,scope:c,reusePassed:e$1.reusePassed===true},selection:{mode:k,since:u?m:null,scope:c,graphStatus:l,expansionDepth:h},gates:{enforced:R,results:g,blocked:!!x,blockingGate:x?.gate},summary:{projectCount:o.length,selectedCount:S.length,passed:U,failed:H,skipped:le,exitCode:Ge},projects:C,enterpriseControls:{jsonReady:true,evidencePath:b$1}},Be=b.join(t,b$1);return await e(t,me),e$1.json||(x&&(console.log(E.red(`\u274C Workspace run blocked by ${x.gate}`)),console.log(E.gray(` ${x.summary}`))),console.log(E.cyan(`Workspace run (${e$1.stage}) => passed: ${U}, failed: ${H}, skipped: ${le}`)),console.log(E.gray(`Report: ${Be}`))),me}export{rr as a};
@@ -1,4 +1,4 @@
1
- import {a as a$2}from'./chunk-WHHK2DF5.js';import {a as a$5}from'./chunk-2OIBHUVH.js';import {a as a$3,e}from'./chunk-GHB6QMQH.js';import {d,a as a$1,e as e$1}from'./chunk-MBRU3VWJ.js';import {a}from'./chunk-62K2H72S.js';import a$4 from'chalk';import se from'fs';import b from'path';import {execa}from'execa';var G="autopilot-release-last-run.json",V="autopilot-release.json";function j(r){try{return JSON.parse(r)}catch{return null}}function Re(r){let e=b.resolve(r),n=a$5(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function re(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function oe(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function Se(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function be(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await se.promises.mkdir(b.dirname(r),{recursive:true}),await se.promises.writeFile(r,`${JSON.stringify(e,null,2)}
1
+ import {a as a$2}from'./chunk-NHVHRBBV.js';import {a as a$5}from'./chunk-2OIBHUVH.js';import {a as a$3,e}from'./chunk-GHB6QMQH.js';import {d,a as a$1,e as e$1}from'./chunk-MBRU3VWJ.js';import {a}from'./chunk-62K2H72S.js';import a$4 from'chalk';import se from'fs';import b from'path';import {execa}from'execa';var G="autopilot-release-last-run.json",V="autopilot-release.json";function j(r){try{return JSON.parse(r)}catch{return null}}function Re(r){let e=b.resolve(r),n=a$5(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function re(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function oe(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function Se(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function be(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await se.promises.mkdir(b.dirname(r),{recursive:true}),await se.promises.writeFile(r,`${JSON.stringify(e,null,2)}
2
2
  `,"utf-8");}async function Me(r){let e$2=Re(r.workspacePath),n=r.mode,o=[],t=[],F,H,D,q,Q,X=0,f=false,T=0,L=0,N=-1,W=-1,c="skipped",d$1="skipped",ae=n==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(r.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let s=Date.now(),l=await S([...ae],e$2),m=Date.now()-s;if(c="pass",l.crashed)c="fail",f=true,t.push(`doctor workspace execution error: ${l.stderr||"unknown error"}`);else if(l.exitCode===1)c="fail",t.push("doctor workspace command failed or reported errors");else if(l.exitCode===2)c="warn",t.push("doctor workspace reported warnings");else if(l.exitCode!==0)c="fail",t.push("doctor workspace command failed");else {let p=j(l.stdout),E=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},k=Number(E.errors??0),$=Number(E.warnings??0);Number.isFinite(k)&&k>0?(c="fail",t.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite($)&&$>0&&(c="warn");}N=o.push({name:"doctor-workspace",status:c,durationMs:m,summary:c==="pass"?"doctor workspace passed":c==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,n==="enforce"&&c==="warn"&&t.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await S(["analyze","--json"],e$2),v=Date.now()-g;H=await d(e$2,a.analyze)??a$1(e$2,a.analyze);let i="pass";if(w.crashed)i="fail",f=true,t.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)i=w.exitCode===2?"warn":"fail",t.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let p=j(w.stdout),E=p&&p.summary&&typeof p.summary=="object"?p.summary:{},k=String(E.verdict??"ready");k==="blocked"?(i="fail",t.push("analyze reported blocked verdict")):k==="needs-attention"&&(i="warn");}o.push({name:"analyze",status:i,durationMs:v,summary:i==="pass"?"analyze passed":i==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),n==="enforce"&&i==="warn"&&t.push("analyze reported warnings under enforce mode");let P=Date.now(),h=await S(["readiness","--json"],e$2),y=Date.now()-P;if(d$1="fail",h.crashed)d$1="fail",f=true,t.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)d$1="fail",t.push("readiness command failed");else {let p=j(h.stdout),E=String(p?.overallStatus??"fail");if(d$1=re(E),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(F=p.evidencePath),d$1==="fail"){let k=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter($=>typeof $=="string"):[];k.length>0?t.push(...k.map($=>`readiness: ${$}`)):t.push("readiness overall status is fail");}}W=o.push({name:"readiness",status:d$1,durationMs:y,summary:`readiness overall status is ${d$1}`})-1,n==="enforce"&&d$1==="warn"&&t.push("readiness reported warnings under enforce mode");}let ne=Date.now(),z=await S(["doctor","workspace","--plan","--json"],e$2),ie=Date.now()-ne,R="warn";if(z.crashed)R="fail",f=true,t.push(`doctor remediation plan execution error: ${z.stderr||"unknown error"}`);else if(z.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let s=j(z.stdout),l=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(l?.totalSteps??0),g=Number(l?.executableSteps??0);Number.isFinite(m)&&m>0&&(T=m),Number.isFinite(g)&&g>0&&(L=g),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:ie,summary:R==="pass"?"no remediation steps required":"remediation steps available"}),n==="enforce"&&R==="warn"&&t.push("remediation plan has pending steps under enforce mode"),n==="safe-fix"){let s=Date.now(),l=await S(["doctor","workspace","--apply"],e$2),m=Date.now()-s,g=l.crashed||l.exitCode!==0?"fail":"pass";if(l.crashed)f=true,t.push(`doctor remediation apply execution error: ${l.stderr||"unknown error"}`);else if(g==="fail")t.push("doctor remediation apply failed");else {X=L>0?L:T>0?T:1;let w=await S(["doctor","workspace","--json"],e$2);if(w.crashed)c="fail",f=true,t.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",t.push("post-apply doctor workspace command failed");else {let i=j(w.stdout),P=i&&i.healthScore&&typeof i.healthScore=="object"?i.healthScore:{},h=Number(P.errors??0),y=Number(P.warnings??0);Number.isFinite(h)&&h>0?(c="fail",t.push(`post-apply doctor reports ${h} error(s)`)):Number.isFinite(y)&&y>0?c="warn":c="pass";}N>=0&&(o[N].status=c,o[N].summary=`doctor workspace post-apply status is ${c}`);let v=await S(["readiness","--json"],e$2);if(v.crashed)d$1="fail",f=true,t.push(`post-apply readiness execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)d$1="fail",t.push("post-apply readiness command failed");else {let i=j(v.stdout),P=String(i?.overallStatus??"fail");if(d$1=re(P),typeof i?.evidencePath=="string"&&i.evidencePath.trim().length>0&&(F=i.evidencePath),d$1==="fail"){let h=Array.isArray(i?.blockingReasons)?i?.blockingReasons.filter(y=>typeof y=="string"):[];h.length>0?t.push(...h.map(y=>`post-apply readiness: ${y}`)):t.push("post-apply readiness overall status is fail");}}W>=0&&(o[W].status=d$1,o[W].summary=`readiness post-apply overall status is ${d$1}`);}o.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let le=Date.now(),x="pass",A="workspace test/build completed for selected projects";try{let s=await a$2({workspacePath:e$2,stage:"test",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});D=a$1(e$2,b.join(".workspai","reports",a$3)),await e(e$2,s),q=D;let l=oe(s);if(l==="fail")x="fail",A="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {l==="warn"&&(x="warn",A="workspace test stage completed with warnings",n==="enforce"&&t.push("workspace run test reported warnings under enforce mode"));let m=await a$2({workspacePath:e$2,stage:"build",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});await e(e$2,m),Q=D;let g=oe(m);g==="fail"?(x="fail",A="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",A="workspace test/build completed with warnings",n==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){x="fail",A="workspace test/build orchestration failed",f=true,t.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let ce=Date.now()-le;o.push({name:"workspace-run-test-build",status:x,durationMs:ce,summary:A});let M=o.filter(s=>s.status==="warn").length,pe=o.filter(s=>s.status==="fail").length,_=n==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):pe>0,C=[...new Set(t)],O=f||_?Math.max(1,C.length):0,ue=O>0?C:[],de=O===0?C:[],fe=Se(o),me=f||_?"blocked":M>0?"partial":"approved",ge=f?3:_?1:M>0?2:0,we=be({mode:n,executionError:f,blockers:C,hasWarnings:M>0}),Y=a$1(e$2,".workspai/reports"),he=b.join(Y,G),ke=b.join(Y,V),u={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:e$2,mode:n,summary:{releaseScore:fe,verdict:me,blockers:O,warnings:M,safeFixesApplied:X,manualActions:C.length,exitCode:ge},stages:o,blockingReasons:ue,warningReasons:de,nextActions:we,artifacts:{reportPath:he,aliasEvidencePath:ke,analyzeEvidencePath:H,readinessEvidencePath:F,workspaceRunEvidencePath:D,workspaceRunTestPath:q,workspaceRunBuildPath:Q},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${G}`,aliasEvidencePath:`.workspai/reports/${V}`}};if(await e$1(e$2,`.workspai/reports/${G}`,u),await e$1(e$2,`.workspai/reports/${V}`,u),r.output&&await xe(b.resolve(r.output),u),!r.json){console.log(a$4.bold.cyan(`
3
3
  \u{1F680} Workspai Autopilot Release
4
4
  `)),console.log(a$4.bold(`Workspace: ${a$4.cyan(b.basename(e$2))}`)),console.log(a$4.gray(`Path: ${e$2}`)),console.log(a$4.white(`Mode: ${n}`)),console.log(a$4.white(`Verdict: ${u.summary.verdict==="approved"?a$4.green("approved"):u.summary.verdict==="partial"?a$4.yellow("partial"):a$4.red("blocked")}`)),console.log(a$4.white(`Release score: ${u.summary.releaseScore}`));for(let s of u.stages){let l=s.status==="pass"?a$4.green("PASS"):s.status==="warn"?a$4.yellow("WARN"):s.status==="skipped"?a$4.gray("SKIP"):a$4.red("FAIL");console.log(` - ${s.name}: ${l} ${s.summary} (${s.durationMs}ms)`);}if(u.blockingReasons.length>0){console.log(a$4.bold.red(`
@@ -1 +1 @@
1
- export{a as DOCTOR_WORKSPACE_REPORT_PATH,m as applyEnvKeyAddFix,i as applyFileAppendFix,j as applyFileCopyFix,h as applyFileCreateFix,l as applyJsonEditFix,n as applyMakefileTargetFix,g as applyPackageScriptFix,f as assertOperationPathInsideProject,e as buildRepairOperationIdentity,p as computeDoctorFixAwareExitCode,o as computeDoctorGateExitCode,k as decodeJsonPointerSegment,d as parseInternalRepairCommand,c as parsePackageScriptFix,b as resolveDoctorPolicyProfile,q as runDoctor}from'./chunk-JXSRYQAR.js';
1
+ export{a as DOCTOR_WORKSPACE_REPORT_PATH,m as applyEnvKeyAddFix,i as applyFileAppendFix,j as applyFileCopyFix,h as applyFileCreateFix,l as applyJsonEditFix,n as applyMakefileTargetFix,g as applyPackageScriptFix,f as assertOperationPathInsideProject,e as buildRepairOperationIdentity,p as computeDoctorFixAwareExitCode,o as computeDoctorGateExitCode,k as decodeJsonPointerSegment,d as parseInternalRepairCommand,c as parsePackageScriptFix,b as resolveDoctorPolicyProfile,q as runDoctor}from'./chunk-23JDMHSD.js';