rapidkit 0.35.0 → 0.36.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.
@@ -0,0 +1,5 @@
1
+ import {b}from'./chunk-TC2PSHT6.js';import {a as a$1}from'./chunk-Y2ZPG7KN.js';import {c}from'./chunk-UY4LZEXK.js';import {a as a$2}from'./chunk-7ZSURMR2.js';import {a}from'./chunk-KMUWWZRT.js';import {b as b$1}from'./chunk-DC44JPI3.js';import c$1 from'chalk';import x from'fs-extra';import u from'path';function D(s){return s===0?"pass":s===2?"warn":"fail"}function M(s){return s.some(r=>r.status==="fail")?"blocked":s.some(r=>r.status==="warn")?"needs-attention":"ready"}function j(s,r){if(r)return 3;let t=s.some(i=>i.status==="fail"),a=s.some(i=>i.status==="warn");return t?1:a?2:0}async function A(s){let r=await b$1(s,true),t=false;try{let{syncWorkspaceContract:a}=await import('./workspace-contract-A6QP7FPA.js');await a({workspacePath:s}),t=true;}catch{t=false;}return {sync:r,contractSynced:t}}async function C(s={}){let r=u.resolve(s.workspacePath??process.cwd()),t=a(r);if(!t)throw new Error("No RapidKit workspace found in current directory or parents");let a$3=[],i=[],l=false,p,f,d,g=Date.now();try{let{sync:e,contractSynced:o}=await A(t),n=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";a$3.push({name:"sync",status:n,durationMs:Date.now()-g,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${o?", contract synced":""}`:"workspace not registered in global registry; contract sync attempted"}),e.workspaceFound||i.push("workspace registry entry missing \u2014 run rapidkit create workspace or register manually");}catch(e){l=true,a$3.push({name:"sync",status:"fail",durationMs:Date.now()-g,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),i.push("workspace sync stage failed");}let y=Date.now();try{let e=await b({workspace:true,json:true,quiet:true,strict:s.strict===true,ci:s.strict!==true}),o=D(e),n=u.join(t,".rapidkit","reports","doctor-last-run.json");a$3.push({name:"doctor",status:o,durationMs:Date.now()-y,summary:o==="pass"?"doctor workspace passed":o==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors",exitCode:e,evidencePath:n}),o==="fail"?i.push("doctor workspace gate failed"):o==="warn"&&i.push("doctor workspace reported warnings");}catch(e){l=true,a$3.push({name:"doctor",status:"fail",durationMs:Date.now()-y,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),i.push("doctor workspace stage failed");}if(s.skipAnalyze)a$3.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let o=await a$1({workspacePath:t,json:true,strict:s.strict===true});p=u.join(t,".rapidkit","reports","analyze-last-run.json");let n=o.summary.verdict==="blocked"?"fail":o.summary.verdict==="needs-attention"?"warn":"pass";a$3.push({name:"analyze",status:n,durationMs:Date.now()-e,summary:`analyze verdict: ${o.summary.verdict} (score ${o.summary.score}/100)`,evidencePath:p}),n==="fail"?i.push("analyze reported blocked verdict"):n==="warn"&&i.push("analyze reported needs-attention verdict");}catch(o){l=true,a$3.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${o instanceof Error?o.message:String(o)}`}),i.push("analyze stage failed");}}let w=Date.now();try{let e=await a$2({startPath:t,writeReport:true,skipVerify:s.skipVerify===true});f=e.evidencePath;let o=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";a$3.push({name:"readiness",status:o,durationMs:Date.now()-w,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),o==="fail"?i.push(...e.blockingReasons.map(n=>`readiness: ${n}`)):o==="warn"&&i.push(...e.gates.filter(n=>n.status==="warn").map(n=>`readiness warn: ${n.gate}: ${n.summary}`));}catch(e){l=true,a$3.push({name:"readiness",status:"fail",durationMs:Date.now()-w,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),i.push("readiness stage failed");}if(s.skipAutopilot)a$3.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),o=s.autopilotMode??"audit";try{let n=await c({workspacePath:t,mode:o,json:true,skipPipelineStages:true});d=n.artifacts.reportPath;let k=n.summary.verdict==="approved"?"pass":n.summary.verdict==="partial"?"warn":"fail";a$3.push({name:"autopilot",status:k,durationMs:Date.now()-e,summary:`autopilot ${o}: ${n.summary.verdict}`,exitCode:n.summary.exitCode,evidencePath:d}),k!=="pass"&&i.push(...n.blockingReasons.slice(0,5));}catch(n){l=true,a$3.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${n instanceof Error?n.message:String(n)}`}),i.push("autopilot release stage failed");}}let E=M(a$3),z=j(a$3,l),m=u.join(t,".rapidkit","reports","pipeline-last-run.json"),h={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:t,summary:{verdict:E,exitCode:z,stagesPassed:a$3.filter(e=>e.status==="pass").length,stagesWarn:a$3.filter(e=>e.status==="warn").length,stagesFailed:a$3.filter(e=>e.status==="fail").length},stages:a$3,blockingReasons:[...new Set(i)],artifacts:{reportPath:m,analyzeEvidencePath:p,readinessEvidencePath:f,autopilotEvidencePath:d}};return s.writeReport!==false&&(await x.ensureDir(u.dirname(m)),await x.writeJSON(m,h,{spaces:2})),h}async function L(s){let r;try{r=await C(s);}catch(t){let a=t instanceof Error?t.message:String(t);s.json?console.log(JSON.stringify({schemaVersion:"rapidkit-pipeline-error-v1",ok:false,error:{message:a}},null,2)):console.log(c$1.red(`Pipeline failed: ${a}`)),process.exit(1);}if(s.json)console.log(JSON.stringify(r,null,2));else {console.log(c$1.bold.cyan(`
2
+ \u{1F517} RapidKit Governance Pipeline
3
+ `)),console.log(c$1.bold(`Workspace: ${c$1.cyan(u.basename(r.workspacePath))}`)),console.log(c$1.gray(`Path: ${r.workspacePath}`)),console.log(c$1.white(`Verdict: ${r.summary.verdict} Exit: ${r.summary.exitCode} (${r.summary.stagesPassed} pass / ${r.summary.stagesWarn} warn / ${r.summary.stagesFailed} fail)`));for(let t of r.stages){let a=t.status==="pass"?c$1.green("PASS"):t.status==="warn"?c$1.yellow("WARN"):t.status==="skipped"?c$1.gray("SKIP"):c$1.red("FAIL");console.log(` - ${t.name}: ${a} ${t.summary}`);}if(r.blockingReasons.length>0){console.log(c$1.bold(`
4
+ Blocking reasons:`));for(let t of r.blockingReasons.slice(0,8))console.log(c$1.gray(` \u2022 ${t}`));}console.log(c$1.gray(`
5
+ Evidence: ${r.artifacts.reportPath}`));}r.summary.exitCode!==0&&process.exit(r.summary.exitCode);}export{C as runPipeline,L as runPipelineCommand};
@@ -1 +1 @@
1
- export{e as createProject,d as createWorkspace,g as createWorkspaceShareBundle,f as listWorkspaces,c as registerProjectInWorkspace,a as registerWorkspace,b as syncWorkspaceProjects}from'./chunk-FNL34DKD.js';
1
+ export{e as createProject,d as createWorkspace,g as createWorkspaceShareBundle,f as listWorkspaces,c as registerProjectInWorkspace,a as registerWorkspace,b as syncWorkspaceProjects}from'./chunk-DC44JPI3.js';
@@ -0,0 +1 @@
1
+ import {b}from'./chunk-HUQ5WRUF.js';import {a}from'./chunk-RV6HBTFC.js';import c from'path';import d from'fs-extra';async function v(e,r){let o=await a(e),f=o?.name||c.basename(e),n,i=c.join(e,".python-version");if(await d.pathExists(i)){let a=(await d.readFile(i,"utf-8")).trim();a&&(n=a);}let t=r?.profile||"polyglot",u=t==="python-only"||t==="polyglot"||t==="enterprise",m=r?.installMethod||o?.metadata?.npm?.installMethod||(u?"poetry":"venv"),s=await b(e,{workspaceName:f,installMethod:m,pythonVersion:n,profile:t,writeMarker:true,writeGitignore:true,onlyIfMissing:!r?.force});return {workspacePath:e,created:s,status:s.length>0?"passed":"skipped"}}export{v as ensureWorkspaceFoundation};
@@ -1 +1 @@
1
- export{f as WORKSPACE_IMPACT_REPORT_PATH,e as WORKSPACE_IMPACT_SCHEMA_VERSION,d as WORKSPACE_MODEL_DIFF_REPORT_PATH,b as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,c as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,a as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,n as buildWorkspaceImpact,i as buildWorkspaceModelSnapshot,k as diffWorkspaceModel,g as isGitDiffSource,h as parseGitDiffRef,m as workspaceVerificationPlan,o as writeWorkspaceImpact,l as writeWorkspaceModelDiff,j as writeWorkspaceModelSnapshot}from'./chunk-B7NCBH5B.js';
1
+ export{f as WORKSPACE_IMPACT_REPORT_PATH,e as WORKSPACE_IMPACT_SCHEMA_VERSION,d as WORKSPACE_MODEL_DIFF_REPORT_PATH,b as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,c as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,a as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,n as buildWorkspaceImpact,i as buildWorkspaceModelSnapshot,k as diffWorkspaceModel,g as isGitDiffSource,h as parseGitDiffRef,m as workspaceVerificationPlan,o as writeWorkspaceImpact,l as writeWorkspaceModelDiff,j as writeWorkspaceModelSnapshot}from'./chunk-45KNNNAB.js';
@@ -0,0 +1 @@
1
+ export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME,b as runWorkspaceStage}from'./chunk-KIB4KHBF.js';
@@ -1 +1 @@
1
- import {m,f as f$1,c as c$1,n,e}from'./chunk-B7NCBH5B.js';import {d}from'./chunk-VPNHGQIV.js';import c from'path';import f from'fs-extra';var j="workspace-verify.v1",E=".rapidkit/reports/workspace-verify-last-run.json";function R(e,t){return c.isAbsolute(t)?t:c.join(e,t)}async function W(e$1){let t=await f.readJson(e$1);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e$1}`);let r=t;if(r.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);return r}function S(e){let t=new Set,r=[];for(let a of e){let i=`${a.scope}:${a.project??""}:${a.display}`;t.has(i)||(t.add(i),r.push(a));}return r}function C(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function I(e,t){if(e.id==="workspace.doctor")return c.join(t,".rapidkit","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return c.join(t,".rapidkit","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return c.join(t,".rapidkit","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return c.join(t,".rapidkit","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return c.join(t,".rapidkit","reports","pipeline-last-run.json");if(e.id.startsWith("project.")&&(e.id.endsWith(".test")||e.id.endsWith(".build")))return c.join(t,".rapidkit","reports","workspace-run-last.json")}function l(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function V(e){let t=l(e.healthScore),r=typeof t?.errors=="number"?t.errors:0,a=typeof t?.percent=="number"?t.percent:void 0;return r>0?{status:"fail",message:`Doctor evidence reports ${r} error(s).`}:typeof a=="number"&&a<70?{status:"warn",message:`Doctor health score is ${a}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function A(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function x(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function O(e){let t=l(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let a=typeof t?.status=="string"?t.status:void 0;return a==="warn"||a==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function $(e){let t=l(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function _(e,t){let r=t.id.endsWith(".build")?"build":t.id.endsWith(".test")?"test":null,a=typeof e.stage=="string"?e.stage:void 0;if(r&&a&&a!==r)return {status:"missing",message:`Workspace run evidence is for stage "${a}", expected "${r}".`};let i=l(e.summary),o=typeof i?.failed=="number"?i.failed:0,n=typeof i?.exitCode=="number"?i.exitCode:0,m=Array.isArray(e.projects)?e.projects:[],p=t.project?.toLowerCase(),d=m.find(s=>{let u=l(s);if(!u||!p)return false;let P=typeof u.projectName=="string"?u.projectName.toLowerCase():"",y=typeof u.projectPath=="string"?u.projectPath.toLowerCase():"";return P===p||y.endsWith(`/${p}`)||y===p});if(d){let s=l(d),u=typeof s?.status=="string"?s.status:"unknown";if(u==="failed")return {status:"fail",message:`Workspace run evidence failed for ${t.project}.`};if(u==="passed")return {status:"pass",message:`Workspace run evidence passed for ${t.project}.`};if(u==="skipped")return {status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}}return o>0||n!==0?{status:"fail",message:"Workspace run evidence reports failures."}:{status:"pass",message:"Workspace run evidence is present."}}async function M(e,t,r){let a=I(e,t),i=a?c.relative(t,a).split(c.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};if(!a||!await f.pathExists(a))return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:i,message:i?`Missing evidence report: ${i}`:"No evidence mapping exists for this command."};let o=l(await f.readJson(a));if(!o)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:i,message:"Evidence report is not a JSON object."};let n;return e.id==="workspace.doctor"?n=V(o):e.id==="workspace.readiness"?n=A(o):e.id==="workspace.contract.verify"?n=x(o):e.id==="workspace.analyze"?n=O(o):e.id==="workspace.pipeline"?n=$(o):e.id.startsWith("project.")?n=_(o,e):n={status:"pass",message:"Evidence report is present."},{id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:n.status,required:e.required,evidencePath:i,message:n.message}}function D(e){let t=e.filter(s=>s.status==="pass").length,r=e.filter(s=>s.status==="warn").length,a=e.filter(s=>s.status==="fail").length,i=e.filter(s=>s.status==="missing").length,o=e.filter(s=>s.status==="skipped").length,n=e.filter(s=>s.required&&(s.status==="fail"||s.status==="missing")).map(s=>`${s.id}: ${s.message}`),m=e.filter(s=>s.required&&s.status==="missing").length,p="ready",d=0;return n.length>0?(p="blocked",d=2):(r>0||m>0)&&(p="needs-attention",d=1),{verdict:p,exitCode:d,stepsPassed:t,stepsWarn:r,stepsFailed:a,stepsMissing:i,stepsSkipped:o}}async function q(e$1){let t=c.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let o=R(t,e$1.fromImpactPath);return {impact:await W(o),fromImpactRef:c.relative(t,o).split(c.sep).join("/")}}let r=c.join(t,f$1);if(await f.pathExists(r))return {impact:await W(r),fromImpactRef:f$1};let a=c.join(t,c$1);if(await f.pathExists(a))return {impact:await n({workspacePath:t,fromPath:c$1,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:c$1};let i=await d({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:e,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:".rapidkit/reports/workspace-model-diff-last-run.json",workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0},affectedProjects:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:"workspace-model-diff.v1",generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:".rapidkit/reports/workspace-model.json",fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}}}}async function K(e){let t=c.resolve(e.workspacePath),{impact:r,fromImpactRef:a}=await q(e),i=r.diff.currentModel,o=S([...m(),...r.verificationPlan]).filter(s=>C(e.scope,s)),n=[];for(let s of o)n.push(await M(s,t,i.contracts.exists===true));let m$1=D(n),p=n.filter(s=>s.status==="missing"&&s.evidencePath).map(s=>s.evidencePath),d=n.filter(s=>s.required&&(s.status==="fail"||s.status==="missing")).map(s=>`${s.id}: ${s.message}`);return {schemaVersion:j,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:a,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:m$1,steps:n,missingEvidence:p,blockingReasons:d,verificationPlan:o}}async function L(e,t){let r=c.join(t,E);return await f.ensureDir(c.dirname(r)),await f.writeJson(r,e,{spaces:2}),r}function J(e,t){return e.summary.verdict==="blocked"?2:t?.strict&&e.summary.verdict!=="ready"?1:e.summary.exitCode}export{E as WORKSPACE_VERIFY_REPORT_PATH,j as WORKSPACE_VERIFY_SCHEMA_VERSION,K as buildWorkspaceVerify,J as workspaceVerifyExitCode,L as writeWorkspaceVerify};
1
+ import {m,f as f$1,c as c$1,n,e}from'./chunk-45KNNNAB.js';import {d}from'./chunk-VPNHGQIV.js';import c from'path';import f from'fs-extra';var j="workspace-verify.v1",E=".rapidkit/reports/workspace-verify-last-run.json";function R(e,t){return c.isAbsolute(t)?t:c.join(e,t)}async function W(e$1){let t=await f.readJson(e$1);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e$1}`);let r=t;if(r.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);return r}function S(e){let t=new Set,r=[];for(let a of e){let i=`${a.scope}:${a.project??""}:${a.display}`;t.has(i)||(t.add(i),r.push(a));}return r}function C(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function I(e,t){if(e.id==="workspace.doctor")return c.join(t,".rapidkit","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return c.join(t,".rapidkit","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return c.join(t,".rapidkit","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return c.join(t,".rapidkit","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return c.join(t,".rapidkit","reports","pipeline-last-run.json");if(e.id.startsWith("project.")&&(e.id.endsWith(".test")||e.id.endsWith(".build")))return c.join(t,".rapidkit","reports","workspace-run-last.json")}function l(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function V(e){let t=l(e.healthScore),r=typeof t?.errors=="number"?t.errors:0,a=typeof t?.percent=="number"?t.percent:void 0;return r>0?{status:"fail",message:`Doctor evidence reports ${r} error(s).`}:typeof a=="number"&&a<70?{status:"warn",message:`Doctor health score is ${a}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function A(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function x(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function O(e){let t=l(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let a=typeof t?.status=="string"?t.status:void 0;return a==="warn"||a==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function $(e){let t=l(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function _(e,t){let r=t.id.endsWith(".build")?"build":t.id.endsWith(".test")?"test":null,a=typeof e.stage=="string"?e.stage:void 0;if(r&&a&&a!==r)return {status:"missing",message:`Workspace run evidence is for stage "${a}", expected "${r}".`};let i=l(e.summary),o=typeof i?.failed=="number"?i.failed:0,n=typeof i?.exitCode=="number"?i.exitCode:0,m=Array.isArray(e.projects)?e.projects:[],p=t.project?.toLowerCase(),d=m.find(s=>{let u=l(s);if(!u||!p)return false;let P=typeof u.projectName=="string"?u.projectName.toLowerCase():"",y=typeof u.projectPath=="string"?u.projectPath.toLowerCase():"";return P===p||y.endsWith(`/${p}`)||y===p});if(d){let s=l(d),u=typeof s?.status=="string"?s.status:"unknown";if(u==="failed")return {status:"fail",message:`Workspace run evidence failed for ${t.project}.`};if(u==="passed")return {status:"pass",message:`Workspace run evidence passed for ${t.project}.`};if(u==="skipped")return {status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}}return o>0||n!==0?{status:"fail",message:"Workspace run evidence reports failures."}:{status:"pass",message:"Workspace run evidence is present."}}async function M(e,t,r){let a=I(e,t),i=a?c.relative(t,a).split(c.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};if(!a||!await f.pathExists(a))return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:i,message:i?`Missing evidence report: ${i}`:"No evidence mapping exists for this command."};let o=l(await f.readJson(a));if(!o)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:i,message:"Evidence report is not a JSON object."};let n;return e.id==="workspace.doctor"?n=V(o):e.id==="workspace.readiness"?n=A(o):e.id==="workspace.contract.verify"?n=x(o):e.id==="workspace.analyze"?n=O(o):e.id==="workspace.pipeline"?n=$(o):e.id.startsWith("project.")?n=_(o,e):n={status:"pass",message:"Evidence report is present."},{id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:n.status,required:e.required,evidencePath:i,message:n.message}}function D(e){let t=e.filter(s=>s.status==="pass").length,r=e.filter(s=>s.status==="warn").length,a=e.filter(s=>s.status==="fail").length,i=e.filter(s=>s.status==="missing").length,o=e.filter(s=>s.status==="skipped").length,n=e.filter(s=>s.required&&(s.status==="fail"||s.status==="missing")).map(s=>`${s.id}: ${s.message}`),m=e.filter(s=>s.required&&s.status==="missing").length,p="ready",d=0;return n.length>0?(p="blocked",d=2):(r>0||m>0)&&(p="needs-attention",d=1),{verdict:p,exitCode:d,stepsPassed:t,stepsWarn:r,stepsFailed:a,stepsMissing:i,stepsSkipped:o}}async function q(e$1){let t=c.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let o=R(t,e$1.fromImpactPath);return {impact:await W(o),fromImpactRef:c.relative(t,o).split(c.sep).join("/")}}let r=c.join(t,f$1);if(await f.pathExists(r))return {impact:await W(r),fromImpactRef:f$1};let a=c.join(t,c$1);if(await f.pathExists(a))return {impact:await n({workspacePath:t,fromPath:c$1,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:c$1};let i=await d({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:e,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:".rapidkit/reports/workspace-model-diff-last-run.json",workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0},affectedProjects:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:"workspace-model-diff.v1",generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:".rapidkit/reports/workspace-model.json",fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}}}}async function K(e){let t=c.resolve(e.workspacePath),{impact:r,fromImpactRef:a}=await q(e),i=r.diff.currentModel,o=S([...m(),...r.verificationPlan]).filter(s=>C(e.scope,s)),n=[];for(let s of o)n.push(await M(s,t,i.contracts.exists===true));let m$1=D(n),p=n.filter(s=>s.status==="missing"&&s.evidencePath).map(s=>s.evidencePath),d=n.filter(s=>s.required&&(s.status==="fail"||s.status==="missing")).map(s=>`${s.id}: ${s.message}`);return {schemaVersion:j,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:a,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:m$1,steps:n,missingEvidence:p,blockingReasons:d,verificationPlan:o}}async function L(e,t){let r=c.join(t,E);return await f.ensureDir(c.dirname(r)),await f.writeJson(r,e,{spaces:2}),r}function J(e,t){return e.summary.verdict==="blocked"?2:t?.strict&&e.summary.verdict!=="ready"?1:e.summary.exitCode}export{E as WORKSPACE_VERIFY_REPORT_PATH,j as WORKSPACE_VERIFY_SCHEMA_VERSION,K as buildWorkspaceVerify,J as workspaceVerifyExitCode,L as writeWorkspaceVerify};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "type": "module",
5
5
  "description": "Official CLI for RapidKit — workspace-first platform to create, adopt, govern, and operate polyglot projects (Python, Node, Go, Java, .NET, frontend) with shared evidence for CI, Workspai, and AI agents.",
6
6
  "keywords": [
@@ -1 +0,0 @@
1
- export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-5LLGW5TP.js';
@@ -1 +0,0 @@
1
- export{a as runAutopilotRelease}from'./chunk-R4RPUW7I.js';
@@ -1,9 +0,0 @@
1
- import {a,b as b$1}from'./chunk-KMUWWZRT.js';import {h as h$1,i}from'./chunk-UZW5QFRW.js';import {a as a$1}from'./chunk-VKLL63TL.js';import h from'fs';import o from'path';import s from'chalk';var I=new Set([".git",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function y(e){try{return await h.promises.access(e,h.constants.F_OK),true}catch{return false}}async function v(e){try{let n=JSON.parse(await h.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function G(e){try{return await h.promises.readFile(e,"utf-8")}catch{return ""}}function E(e){return a(e)}async function S(e,n){return await y(o.join(e,".rapidkit","project.json"))||await y(o.join(e,".rapidkit","context.json"))?true:b$1(e)?false:o.resolve(e)===o.resolve(n)?h$1(e).length>0:h$1(e).length>0}async function T(e){let n=await a$1(e,{skipDirs:I,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:S});return n.length>0?n:b$1(e)?[]:h$1(e).length>0?[e]:[]}function N(e,n){return o.relative(e,n).replace(/\\/g,"/")||"."}async function b(e,n){for(let t of n)if(await y(o.join(e,t)))return true;return false}async function K(e){return b(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function O(e){if(await b(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await v(o.join(e,"package.json")),i=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof i.test=="string"&&i.test.trim().length>0}async function _(e){let n=await v(o.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,i,r,c){return {id:e,severity:n,target:t,title:i,detail:r,remediation:c}}function J(e){let n=e.reduce((t,i)=>i.severity==="fail"?t+28:i.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function M(e,n){let t=await v(o.join(n,".rapidkit","project.json")),i$1=i(n,t),r=h$1(n),c=i$1.runtime==="unknown"?r[0]||"unknown":i$1.runtime,a=N(e,n),d=a,u=await _(n),m=await y(o.join(n,".rapidkit","project.json"))||await y(o.join(n,".rapidkit","context.json")),g=await O(n),k=await b(n,["Dockerfile","dockerfile"]),w=await b(n,[".env.example","env.example","config/env.example"]),A=await b(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),z=await K(n),l=[];return i$1.key==="unknown"&&l.push(f("project.stack.unknown","fail",d,"Project stack is unknown","RapidKit cannot confidently classify this backend project.","Add .rapidkit/project.json metadata or import the project with `rapidkit import`.")),m||l.push(f("project.marker.missing","warn",d,"RapidKit marker is missing","The project can be detected by files, but it is not registered with RapidKit metadata.","Run `rapidkit import <path>` from a workspace or create the project through RapidKit.")),g||l.push(f("project.tests.missing","warn",d,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `rapidkit workspace run test --affected` can gate changes.")),w||l.push(f("project.env.example.missing","info",d,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),A||l.push(f("project.ci.missing","warn",d,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),z||l.push(f("project.health.missing","info",d,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),k||l.push(f("project.container.missing","info",d,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:o.basename(n),path:n,relativePath:a,runtime:c,framework:i$1.key,confidence:i$1.confidence,supportTier:i$1.supportTier,hasRapidKitMarker:m,hasTests:g,hasDockerfile:k,hasEnvExample:w,hasCiConfig:A,hasHealthEndpoint:z,scripts:u,findings:l,score:J(l)}}function W(e){return e.name.toLowerCase()}async function H(e){let n=new Map(e.map(r=>[W(r),r])),t=[];for(let r of e){let c=await v(o.join(r.path,"package.json")),a={...c?.dependencies??{},...c?.devDependencies??{},...c?.peerDependencies??{}};for(let u of Object.keys(a)){let m=u.replace(/^@[^/]+\//,"").toLowerCase(),g=n.get(m);g&&g.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:g.relativePath,kind:"package"});}let d=await G(o.join(r.path,"pyproject.toml"));for(let u of e)u.relativePath!==r.relativePath&&d.includes(u.name)&&t.push({from:r.relativePath,to:u.relativePath,kind:"workspace-reference"});}let i=new Set;return t.filter(r=>{let c=`${r.from}\0${r.to}\0${r.kind}`;return i.has(c)?false:(i.add(c),true)})}function B(e,n){let t=new Map;for(let i of e)t.set(i.relativePath,{project:i.relativePath,directDependents:0,directDependencies:0});for(let i of n){let r=t.get(i.from),c=t.get(i.to);r&&(r.directDependencies+=1),c&&(c.directDependents+=1);}return Array.from(t.values()).sort((i,r)=>r.directDependents-i.directDependents||r.directDependencies-i.directDependencies)}async function U(e){let n=await v(o.join(e,".rapidkit","workspace.json"));return typeof n?.profile=="string"?n.profile:null}function V(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function L(e){if(e.projectCount===0)return ["Create a RapidKit workspace: npx rapidkit create workspace my-workspace --profile polyglot","Import an existing service: npx rapidkit import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `rapidkit bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `rapidkit import <path>` or recreate them via `rapidkit create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `rapidkit workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.rapidkit/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `rapidkit autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ie(e={}){let n=o.resolve(e.workspacePath||process.cwd());if(!await y(n))throw new Error(`Workspace path does not exist: ${n}`);let t=E(n)??n,i=await y(o.join(t,".rapidkit-workspace"))||await y(o.join(t,".rapidkit","workspace.json")),r=await U(t),c=await T(t),a=await Promise.all(c.map(p=>M(t,p))),d=await H(a),u=B(a,d),m=[];i||m.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered RapidKit workspace.","Run `rapidkit create workspace` or `rapidkit bootstrap --profile polyglot` in a workspace root.")),a.length===0&&m.push(f("workspace.projects.missing","fail",".","No backend projects detected","RapidKit did not find runtime markers or project metadata under this root.","Create a project with `rapidkit create project` or import one with `rapidkit import <path>`."));let g=[...m,...a.flatMap(p=>p.findings)],k=V(g),w={};for(let p of a)w[p.runtime]=(w[p.runtime]||0)+1;let A=a.length>0?Math.round(a.reduce((p,P)=>p+P.score,0)/a.length):0,z=m.reduce((p,P)=>p+(P.severity==="fail"?20:P.severity==="warn"?8:2),0),l=Math.max(0,A-z),F=k.fail>0||e.strict&&k.warn>0?"blocked":k.warn>0?"needs-attention":"ready",C={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:i,profile:r,summary:{score:l,verdict:F,projectCount:a.length,runtimeCount:Object.keys(w).length,findings:k},runtimes:w,projects:a,dependencyGraph:{status:d.length>0?"generated":"empty",edges:d,topImpactedProjects:u.slice(0,5)},findings:g,nextActions:L({findings:g,projectCount:a.length,hasGraph:d.length>0}),enterpriseControls:{jsonReady:true,ciGateCommand:"rapidkit analyze --json --strict",releaseGateCommand:"rapidkit autopilot release --mode enforce --json",evidencePath:".rapidkit/reports/analyze-last-run.json"}};if(e.output&&(await h.promises.mkdir(o.dirname(o.resolve(e.output)),{recursive:true}),await h.promises.writeFile(o.resolve(e.output),`${JSON.stringify(C,null,2)}
2
- `)),!e.output&&i){let p=o.join(t,".rapidkit","reports","analyze-last-run.json");await h.promises.mkdir(o.dirname(p),{recursive:true}),await h.promises.writeFile(p,`${JSON.stringify(C,null,2)}
3
- `);}return C}function re(e){let n=e.summary.verdict==="ready"?s.green:e.summary.verdict==="needs-attention"?s.yellow:s.red;if(console.log(s.bold(`
4
- RapidKit Workspace Analysis
5
- `)),console.log(s.cyan("Workspace:"),e.workspacePath),console.log(s.cyan("Profile:"),e.profile||"not configured"),console.log(s.cyan("Score:"),`${e.summary.score}/100`),console.log(s.cyan("Verdict:"),n(e.summary.verdict)),console.log(s.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(s.bold(`
6
- Projects`));for(let t of e.projects){let i=t.score>=85?s.green("pass"):t.score>=65?s.yellow("watch"):s.red("risk");console.log(` ${t.relativePath} ${s.gray(`${t.runtime}/${t.framework}`)} ${i} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(s.bold(`
7
- Dependency Graph`)),console.log(s.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(s.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(s.bold(`
8
- Top Findings`));for(let t of e.findings.slice(0,8)){let i=t.severity==="fail"?s.red:t.severity==="warn"?s.yellow:s.gray;console.log(` ${i(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(s.gray(` ${t.remediation}`));}}console.log(s.bold(`
9
- Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(s.gray(` - ${t}`));console.log();}export{ie as a,re as b};
@@ -1,2 +0,0 @@
1
- import {d,b,a}from'./chunk-VPNHGQIV.js';import z from'crypto';import m from'path';import h from'fs-extra';import {spawnSync}from'child_process';function j(e,t){let r=spawnSync("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]});return r.status!==0?{ok:false,stdout:""}:{ok:true,stdout:(r.stdout??"").trim()}}function q(e){let t=[],r=[],o=[];for(let c of e.split(`
2
- `)){if(!c.trim())continue;let n=c.slice(0,2),s=c.slice(3).trim();if(s){if(n==="??"){r.push(s);continue}n.includes("D")&&o.push(s),t.push(s);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(r)].sort(),deletedFiles:[...new Set(o)].sort()}}function F(e,t){let r={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},o=j(e,["rev-parse","--is-inside-work-tree"]);if(!o.ok||o.stdout!=="true")return r;let c=j(e,["rev-parse","--abbrev-ref","HEAD"]),n=j(e,["rev-parse","HEAD"]),s=j(e,["status","--porcelain=v1","--untracked-files=all"]),i=q(s.stdout),p=i.changedFiles.length>0||i.untrackedFiles.length>0||i.deletedFiles.length>0;return {available:true,branch:c.ok?c.stdout:void 0,commit:n.ok?n.stdout:void 0,ref:t?.ref,dirty:p,changedFiles:i.changedFiles,untrackedFiles:i.untrackedFiles,deletedFiles:i.deletedFiles}}var T="workspace-model-snapshot.v1",H="workspace-model-diff.v1",D=".rapidkit/reports/workspace-model-snapshot.json",V=".rapidkit/reports/workspace-model-diff-last-run.json",K="workspace-impact.v1",J=".rapidkit/reports/workspace-impact-last-run.json";function U(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function Q(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function A(e){if(Array.isArray(e))return e.map(t=>A(t));if(e&&typeof e=="object"){let t={};for(let r of Object.keys(e).sort())t[r]=A(e[r]);return t}return e}function u(e){return JSON.stringify(A(e))}function S(e){let t={...e,generatedAt:"<ignored>",validation:e.validation?{...e.validation,issues:e.validation.issues.map(r=>({...r})).sort((r,o)=>{let c=`${r.severity}:${r.code}:${r.target}:${r.message}`,n=`${o.severity}:${o.code}:${o.target}:${o.message}`;return c.localeCompare(n)})}:void 0};return z.createHash("sha256").update(u(t)).digest("hex")}function G(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function X(e){let t=await h.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion===T){let o=r;if(!o.model||o.model.schemaVersion!==a)throw new Error(`Invalid workspace model snapshot: ${e}`);return {model:o.model,hash:o.modelHash||S(o.model)}}if(r.schemaVersion===a){let o=r;return {model:o,hash:S(o)}}throw new Error(`Unsupported workspace model input schema: ${String(r.schemaVersion)}`)}async function Y(e){let t=await h.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==H)return null;let o=r;if(!o.currentModel||o.currentModel.schemaVersion!==a||!o.summary||!Array.isArray(o.changes))throw new Error(`Invalid workspace model diff report: ${e}`);return o}async function We(e){let t=e.model??await d({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:T,generatedAt:(e.now??new Date).toISOString(),modelHash:S(t),modelRef:b,model:t}}async function ve(e,t){let r=m.join(t,D);return await h.ensureDir(m.dirname(r)),await h.writeJson(r,e,{spaces:2}),r}function C(e){return {name:e.name,path:e.path,kind:e.kind,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function k(e,t){e.push(t);}function Z(e,t){let r=[],o=["name","profile","type"],c=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let n of o){let s=e.workspace[n],i=t.workspace[n];u(s)!==u(i)&&k(r,{type:"workspace.changed",severity:"info",target:`workspace.${n}`,message:`Workspace metadata field changed: ${String(n)}`,before:s,after:i});}for(let n of c){let s=e.identity[n],i=t.identity[n];u(s)!==u(i)&&k(r,{type:"workspace.changed",severity:"info",target:`identity.${n}`,message:`Workspace identity field changed: ${String(n)}`,before:s,after:i});}return u(e.policies)!==u(t.policies)&&k(r,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),u(e.evidence)!==u(t.evidence)&&k(r,{type:"workspace.changed",severity:"info",target:"evidence",message:"Workspace evidence summary changed.",before:e.evidence,after:t.evidence}),u(e.discovery)!==u(t.discovery)&&k(r,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&k(r,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),r}function ee(e,t){let r=e.validation??null,o=t.validation??null;return u(r)===u(o)?[]:[{type:"validation.changed",severity:o?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:r,after:o}]}function te(e,t){let r=[],o=new Map(e.projects.map(n=>[n.path,n])),c=new Map(t.projects.map(n=>[n.path,n]));for(let[n,s]of c.entries()){let i=o.get(n);if(!i){k(r,{type:"project.added",severity:"info",target:n,message:`Project added: ${s.name}`,after:C(s)});continue}let p=C(i),d=C(s);if(u(p)!==u(d)){let f=i.runtime!==s.runtime||i.framework!==s.framework;k(r,{type:"project.changed",severity:f?"warning":"info",target:n,message:`Project changed: ${s.name}`,before:p,after:d});}}for(let[n,s]of o.entries())c.has(n)||k(r,{type:"project.removed",severity:"warning",target:n,message:`Project removed: ${s.name}`,before:C(s)});return r.sort((n,s)=>`${n.type}:${n.target}`.localeCompare(`${s.type}:${s.target}`))}async function re(e){let t=m.resolve(e.workspacePath),r=U(e.fromPath),o=r?Q(e.fromPath):void 0,c=e.fromPath;if(r){let a=m.join(t,D);if(!await h.pathExists(a))throw new Error("Git-aware workspace diff requires an existing snapshot at .rapidkit/reports/workspace-model-snapshot.json. Run: npx rapidkit workspace snapshot --json");c=D;}let n=G(t,c),s=await X(n),i=e.model??await d({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),p=S(i),d$1=[...Z(s.model,i),...te(s.model,i),...ee(s.model,i)],f;e.includeGitObservation!==false&&(f=e.gitObservation??F(t,{ref:o}),f.available&&ae(d$1,f,i));let y=d$1.filter(a=>a.type.startsWith("git.")).length,W=s.hash!==p,v=r?`git:${o??"HEAD"}`:m.relative(t,n).split(m.sep).join("/");return {schemaVersion:H,generatedAt:(e.now??new Date).toISOString(),fromRef:v,toRef:b,fromHash:s.hash,toHash:p,summary:{changed:W||y>0,addedProjects:d$1.filter(a=>a.type==="project.added").length,removedProjects:d$1.filter(a=>a.type==="project.removed").length,changedProjects:d$1.filter(a=>a.type==="project.changed").length,workspaceChanges:d$1.filter(a=>a.type==="workspace.changed").length,validationChanges:d$1.filter(a=>a.type==="validation.changed").length,gitChangedFiles:y},git:f?.available?se(f,o):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:d$1,currentModel:i}}async function Pe(e,t){let r=m.join(t,V);return await h.ensureDir(m.dirname(r)),await h.writeJson(r,e,{spaces:2}),r}function $(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function x(e){return e.reduce((t,r)=>$(r)>$(t)?r:t,"none")}function _(e){return e.join(" ")}function w(e,t,r,o){return {id:e,label:t,scope:o.scope,project:o.project,display:_(["npx","rapidkit",...r]),execute:_(["npx","--yes","--package","rapidkit","rapidkit",...r]),required:o.required!==false}}function oe(e){let t=`project:${e.name}`;return [w(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:e.commands.fleetStages.includes("test")}),w(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:e.commands.fleetStages.includes("build")})]}function O(){return [w("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),w("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),w("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),w("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),w("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false})]}function ne(e,t){let r=t.split(m.sep).join("/");return e.projects.filter(c=>{let n=c.path.split(m.sep).join("/");return r===n||r.startsWith(`${n}/`)}).sort((c,n)=>n.path.length-c.path.length)[0]}function ae(e,t,r){let o=new Set(e.map(n=>n.target)),c=(n,s)=>{let i=s.split(m.sep).join("/"),p=`git:${i}`;if(o.has(p))return;let d=ne(r,i),f=d?`${d.name} (${d.path})`:"workspace";k(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:p,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${f}: ${i}`,after:{path:i,project:d?.name,projectPath:d?.path}}),o.add(p);};for(let n of t.changedFiles)c("git.file.changed",n);for(let n of t.untrackedFiles)c("git.untracked",n);for(let n of t.deletedFiles)c("git.deleted",n);}function se(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function ie(e){let t=new Set,r=[];for(let o of e){let c=`${o.scope}:${o.project??""}:${o.display}`;t.has(c)||(t.add(c),r.push(o));}return r}function ce(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function pe(e){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")||e.type==="validation.changed"?"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function de(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,m.basename(t.path),t.absolutePath].filter(o=>typeof o=="string"&&o.trim().length>0).map(o=>o.trim().toLowerCase()).includes(r)}function le(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(r=>r.project?.name??r.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function be(e){let t=m.resolve(e.workspacePath),r=G(t,e.fromPath),o=e.diff??await Y(r)??await re({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,now:e.now,model:e.model}),c=new Map(o.currentModel.projects.map(a=>[a.path,a])),n=new Map(o.currentModel.projects.map(a=>[a.name,a])),s=o.changes.filter(a=>a.type.startsWith("project.")),i=new Map;for(let a of s){let l=(c.get(a.target)??(typeof a.before?.name=="string"?n.get(a.before.name):void 0))?.path??a.target,P=i.get(l)??[];P.push(a),i.set(l,P);}let p=[];for(let[a,g]of i.entries()){let l=c.get(a);if(l&&!de(e.scope,l))continue;let P=x(g.map(ce)),E=l?.name??(typeof g[0]?.before?.name=="string"?String(g[0].before.name):a);p.push({id:`project:${E}`,scope:"project",target:a,title:`Project impact: ${E}`,summary:g.map(b=>b.message).join(" "),risk:P,reasons:g.map(b=>`${b.type}: ${b.message}`),project:l?{name:l.name,path:l.path,kind:l.kind,runtime:l.runtime,framework:l.framework,supportTier:l.supportTier,...l.generator?{generator:l.generator}:{}}:void 0,verification:l?oe(l):O()});}let f=o.changes.filter(a=>!a.type.startsWith("project.")).map(a=>({id:`workspace:${a.target}`,scope:"workspace",target:a.target,title:`Workspace impact: ${a.target}`,summary:a.message,risk:pe(a),reasons:[`${a.type}: ${a.message}`],verification:O()})),y=ie([...p.flatMap(a=>a.verification),...f.flatMap(a=>a.verification),...o.summary.changed?O():[]]).filter(a=>a.required),W=x([...p.map(a=>a.risk),...f.map(a=>a.risk)]),v={changed:o.summary.changed,risk:W,affectedProjects:p.length,workspaceItems:f.length,recommendedCommands:y.length};return {schemaVersion:K,generatedAt:(e.now??new Date).toISOString(),fromRef:o.fromRef,diffRef:V,workspace:{name:o.currentModel.workspace.name,profile:o.currentModel.workspace.profile,type:o.currentModel.workspace.type},summary:v,affectedProjects:p.sort((a,g)=>a.target.localeCompare(g.target)),workspaceImpact:f.sort((a,g)=>a.target.localeCompare(g.target)),verificationPlan:y,agentBrief:le({changed:v.changed,risk:W,affectedProjects:p,workspaceImpact:f}),diff:o}}async function Me(e,t){let r=m.join(t,J);return await h.ensureDir(m.dirname(r)),await h.writeJson(r,e,{spaces:2}),r}export{T as a,H as b,D as c,V as d,K as e,J as f,U as g,Q as h,We as i,ve as j,re as k,Pe as l,O as m,be as n,Me as o};
@@ -1,4 +0,0 @@
1
- import {a as a$1,b as b$1,d as d$1,c as c$1,f}from'./chunk-YBS2HGO3.js';import {a,b}from'./chunk-KMUWWZRT.js';import {c as c$2}from'./chunk-NFUXULIF.js';import u from'chalk';import d from'fs';import v from'fs-extra';import c from'path';function N(t,e){let a=c.resolve(t);if(!b(a))return a;let s=c.join(e,".rapidkit","workspace.contract.json");if(d.existsSync(s))try{let r=JSON.parse(d.readFileSync(s,"utf-8")),n=Array.isArray(r.projects)?r.projects:[];for(let l of n){let y=p(l),f=typeof y.relativePath=="string"?y.relativePath.trim():"";if(f)return c.join(e,f)}}catch{}let i=C(e),o=Array.isArray(i.payload?.projects)?i.payload.projects:[];for(let r of o){let n=p(r),l=typeof n.path=="string"?n.path.trim():"";if(l)return c.resolve(l)}return a}function x(t){let e=a$1(t);return b$1(e,t)?"go":d$1(e,t)?"java":c$1(e,t)?"node":f(e,t)?"python":"unknown"}function O(t,e){if(!d.existsSync(t))return null;let a=d.readdirSync(t).filter(s=>s.endsWith(".json")&&e.some(i=>i.test(s))).map(s=>c.join(t,s));return a.length===0?null:(a.sort((s,i)=>d.statSync(i).mtimeMs-d.statSync(s).mtimeMs),a[0])}function p(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function G(t,e){let a=c.join(t,".rapidkit","toolchain.lock");if(!d.existsSync(a))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run rapidkit bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:a};try{let s=JSON.parse(d.readFileSync(a,"utf-8")),i=p(s.runtime),r=["python","node","go","java"].filter(n=>{let l=p(i[n]);return typeof l.version=="string"&&l.version.trim().length>0});if(r.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via rapidkit setup <runtime> and re-run bootstrap."],evidencePath:a};if(e!=="unknown"){let n=p(i[e]);if(typeof n.version!="string"||n.version.trim().length===0)return {gate:"env",status:"fail",summary:`Project runtime (${e}) is not pinned in toolchain.lock`,details:[`Run rapidkit setup ${e} and rapidkit bootstrap to lock ${e} for this workspace.`],evidencePath:a}}return {gate:"env",status:"pass",summary:`Pinned runtimes: ${r.join(", ")}`,details:[],evidencePath:a}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with rapidkit bootstrap."],evidencePath:a}}}function C(t){let e=c.join(t,".rapidkit","reports","doctor-last-run.json");if(!d.existsSync(e))return {payload:null,path:e};try{let a=JSON.parse(d.readFileSync(e,"utf-8"));return c$2(a,"workspace")?{payload:a,path:e}:{payload:null,path:e}}catch{return {payload:null,path:e}}}function $(t){let e=C(t);if(!e.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run rapidkit doctor workspace --json before release readiness checks."],evidencePath:e.path},payload:null};let a=p(e.payload.summary),s=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}:s>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${s} issue(s)`,details:["Run rapidkit 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 z(t){let e=c.join(t,".rapidkit","reports","analyze-last-run.json");if(!d.existsSync(e))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run rapidkit analyze --json before release readiness checks."],evidencePath:e};try{let a=JSON.parse(d.readFileSync(e,"utf-8")),s=p(a.summary),i=String(s.verdict??"").toLowerCase(),o=Number(s.score??0),r=p(s.findings),n=Number(r.fail??0);return i==="blocked"||n>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${o}/100)`,details:["Resolve analyze findings and regenerate analyze-last-run.json."],evidencePath:e}:i==="needs-attention"?{gate:"analyze",status:"warn",summary:`Analyze needs attention (score ${o}/100)`,details:["Review analyze warnings before release."],evidencePath:e}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${o}/100)`,details:[],evidencePath:e}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid JSON",details:["Re-run rapidkit analyze --json to regenerate evidence."],evidencePath:e}}}function V(t){try{let e=JSON.parse(d.readFileSync(t,"utf-8")),a=String(e.status??"").toLowerCase(),s=p(e.summary),i=Number(s.failedChecks??0);return a==="fail"||i>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 E(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=c.join(t,".rapidkit","reports"),s=O(a,[/verify-pack-contract/i,/^verify.*\.json$/i]);if(s)return V(s);let i=c.join(a,"workspace-contract-verify-last-run.json"),o=O(a,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i]);if(o)try{let r=JSON.parse(d.readFileSync(o,"utf-8")),n=String(r.status??"").toLowerCase();if(n==="passed"||n==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(n==="failed"||n==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(r.violations)?r.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:r}=await import('./workspace-contract-A6QP7FPA.js'),n=await r({workspacePath:t}),l={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:n.status,contractPath:n.contractPath,projectCount:n.projectCount,checks:n.checks,violations:n.violations};return await v.ensureDir(a),await v.writeJSON(i,l,{spaces:2}),n.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:n.violations.slice(0,5),evidencePath:i}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:i}}catch(r){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run rapidkit workspace contract verify --json or export verify-pack contract from CI.",r instanceof Error?r.message:String(r)],evidencePath:c.join(a,"*verify*.json")}}}function J(t,e){let a=c.join(e,".rapidkit","reports","doctor-last-run.json");if(!t)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run rapidkit doctor workspace --json to include dependency findings."],evidencePath:a};let s=Array.isArray(t.projects)?t.projects:[],i=s.reduce((r,n)=>{let l=Number(n.vulnerabilities??0);return Number.isFinite(l)?r+Math.max(0,l):r},0),o=s.filter(r=>r.depsInstalled===false).length;return i>0?{gate:"dependency",status:"fail",summary:`${i} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:a}:o>0?{gate:"dependency",status:"warn",summary:`${o} 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 D(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}async function I(t,e){let a=c.join(t,".rapidkit","reports","release-readiness-last-run.json");return await v.ensureDir(c.dirname(a)),await v.writeJSON(a,e,{spaces:2}),a}async function L(t={}){let e=c.resolve(t.startPath??process.cwd()),a$1=a(e)??e,s=N(e,a$1),i=x(s),o=G(a$1,i),r=$(a$1),n=z(a$1),l=await E(a$1,{skipVerify:t.skipVerify}),y=J(r.payload,a$1),f=[o,r.gate,n,l,y],h=D(f),g={schemaVersion:"v1",generatedAt:new Date().toISOString(),workspacePath:a$1,projectPath:s,action:t.action,overallStatus:h,blocking:h==="fail",blockingReasons:f.filter(m=>m.status==="fail").map(m=>`${m.gate}: ${m.summary}`),gates:f};return t.writeReport!==false&&(g.evidencePath=await I(a$1,g)),g}function W(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}function F(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}async function Y(t){let e=await L({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} RapidKit Release Readiness
3
- `)),console.log(u.bold(`Workspace: ${u.cyan(c.basename(e.workspacePath))}`)),console.log(u.gray(`Path: ${e.workspacePath}`)),console.log(`Overall: ${F(e.overallStatus)}`);for(let a of e.gates){console.log(` - ${a.gate}: ${W(a.status)} ${a.summary}`);for(let s of a.details)console.log(u.gray(` ${s}`));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{L as a,Y as b};
@@ -1,7 +0,0 @@
1
- import {a}from'./chunk-KDUAZXEQ.js';import {a as a$1}from'./chunk-KMUWWZRT.js';import l from'chalk';import _ from'fs';import R from'path';import {execa}from'execa';function D(t){try{return JSON.parse(t)}catch{return null}}function le(t){let r=R.resolve(t),a=a$1(r);if(!a)throw new Error("No RapidKit workspace found in current directory or parents");return a}async function b(t,r){let a=process.argv[1];if(!a)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[a,...t],{cwd:r,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 q(t){let r=t.toLowerCase();return r==="pass"?"pass":r==="warn"?"warn":r==="fail"?"fail":"warn"}function Q(t){return t.summary.failed>0?"fail":t.gates.results.some(r=>r.status==="warn")?"warn":"pass"}function ce(t){let r=t.filter(o=>o.status!=="skipped");if(r.length===0)return 100;let a=r.reduce((o,e)=>e.status==="pass"?o+1:e.status==="warn"?o+.6:o,0);return Math.round(a/r.length*100)}function ue(t){return t.executionError?["Re-run: npx rapidkit autopilot release --mode audit --json","Inspect .rapidkit/reports/autopilot-release-last-run.json for execution failure details"]:t.blockers.length>0?["Run: npx rapidkit doctor workspace --plan","Run: npx rapidkit readiness --json --strict","Run: npx rapidkit workspace run test --affected --strict"]:t.hasWarnings&&t.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx rapidkit autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function F(t,r){await _.promises.mkdir(R.dirname(t),{recursive:true}),await _.promises.writeFile(t,`${JSON.stringify(r,null,2)}
2
- `,"utf-8");}async function ye(t){let r=le(t.workspacePath),a$1=t.mode,o=[],e=[],E,G,I,T,V=0,d=false,B=0,K=0,C=-1,z=-1,c="skipped",p="skipped",X=a$1==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(t.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(),i=await b([...X],r),m=Date.now()-s;if(c="pass",i.crashed)c="fail",d=true,e.push(`doctor workspace execution error: ${i.stderr||"unknown error"}`);else if(i.exitCode===1)c="fail",e.push("doctor workspace command failed or reported errors");else if(i.exitCode===2)c="warn",e.push("doctor workspace reported warnings");else if(i.exitCode!==0)c="fail",e.push("doctor workspace command failed");else {let u=D(i.stdout),j=u&&u.healthScore&&typeof u.healthScore=="object"?u.healthScore:{},h=Number(j.errors??0),$=Number(j.warnings??0);Number.isFinite(h)&&h>0?(c="fail",e.push(`doctor workspace reports ${h} error(s)`)):Number.isFinite($)&&$>0&&(c="warn");}C=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,a$1==="enforce"&&c==="warn"&&e.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await b(["analyze","--json"],r),A=Date.now()-g;G=R.join(r,".rapidkit","reports","analyze-last-run.json");let n="pass";if(w.crashed)n="fail",d=true,e.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)n=w.exitCode===2?"warn":"fail",e.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let u=D(w.stdout),j=u&&u.summary&&typeof u.summary=="object"?u.summary:{},h=String(j.verdict??"ready");h==="blocked"?(n="fail",e.push("analyze reported blocked verdict")):h==="needs-attention"&&(n="warn");}o.push({name:"analyze",status:n,durationMs:A,summary:n==="pass"?"analyze passed":n==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),a$1==="enforce"&&n==="warn"&&e.push("analyze reported warnings under enforce mode");let P=Date.now(),k=await b(["readiness","--json"],r),y=Date.now()-P;if(p="fail",k.crashed)p="fail",d=true,e.push(`readiness execution error: ${k.stderr||"unknown error"}`);else if(k.exitCode!==0)p="fail",e.push("readiness command failed");else {let u=D(k.stdout),j=String(u?.overallStatus??"fail");if(p=q(j),typeof u?.evidencePath=="string"&&u.evidencePath.trim().length>0&&(E=u.evidencePath),p==="fail"){let h=Array.isArray(u?.blockingReasons)?u?.blockingReasons.filter($=>typeof $=="string"):[];h.length>0?e.push(...h.map($=>`readiness: ${$}`)):e.push("readiness overall status is fail");}}z=o.push({name:"readiness",status:p,durationMs:y,summary:`readiness overall status is ${p}`})-1,a$1==="enforce"&&p==="warn"&&e.push("readiness reported warnings under enforce mode");}let Y=Date.now(),N=await b(["doctor","workspace","--plan","--json"],r),Z=Date.now()-Y,S="warn";if(N.crashed)S="fail",d=true,e.push(`doctor remediation plan execution error: ${N.stderr||"unknown error"}`);else if(N.exitCode!==0)S="fail",e.push("doctor remediation plan command failed");else {let s=D(N.stdout),i=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(i?.totalSteps??0),g=Number(i?.executableSteps??0);Number.isFinite(m)&&m>0&&(B=m),Number.isFinite(g)&&g>0&&(K=g),Number.isFinite(m)&&m===0?S="pass":S="warn";}if(o.push({name:"remediation-plan",status:S,durationMs:Z,summary:S==="pass"?"no remediation steps required":"remediation steps available"}),a$1==="enforce"&&S==="warn"&&e.push("remediation plan has pending steps under enforce mode"),a$1==="safe-fix"){let s=Date.now(),i=await b(["doctor","workspace","--apply"],r),m=Date.now()-s,g=i.crashed||i.exitCode!==0?"fail":"pass";if(i.crashed)d=true,e.push(`doctor remediation apply execution error: ${i.stderr||"unknown error"}`);else if(g==="fail")e.push("doctor remediation apply failed");else {V=K>0?K:B>0?B:1;let w=await b(["doctor","workspace","--json"],r);if(w.crashed)c="fail",d=true,e.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",e.push("post-apply doctor workspace command failed");else {let n=D(w.stdout),P=n&&n.healthScore&&typeof n.healthScore=="object"?n.healthScore:{},k=Number(P.errors??0),y=Number(P.warnings??0);Number.isFinite(k)&&k>0?(c="fail",e.push(`post-apply doctor reports ${k} error(s)`)):Number.isFinite(y)&&y>0?c="warn":c="pass";}C>=0&&(o[C].status=c,o[C].summary=`doctor workspace post-apply status is ${c}`);let A=await b(["readiness","--json"],r);if(A.crashed)p="fail",d=true,e.push(`post-apply readiness execution error: ${A.stderr||"unknown error"}`);else if(A.exitCode!==0)p="fail",e.push("post-apply readiness command failed");else {let n=D(A.stdout),P=String(n?.overallStatus??"fail");if(p=q(P),typeof n?.evidencePath=="string"&&n.evidencePath.trim().length>0&&(E=n.evidencePath),p==="fail"){let k=Array.isArray(n?.blockingReasons)?n?.blockingReasons.filter(y=>typeof y=="string"):[];k.length>0?e.push(...k.map(y=>`post-apply readiness: ${y}`)):e.push("post-apply readiness overall status is fail");}}z>=0&&(o[z].status=p,o[z].summary=`readiness post-apply overall status is ${p}`);}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 O=Date.now(),x="pass",v="workspace test/build completed for selected projects";try{let s=await a({workspacePath:r,stage:"test",affected:true,since:t.since,parallel:t.parallel,maxWorkers:t.maxWorkers,strict:true,json:true,enforceGates:false});I=R.join(r,".rapidkit","reports","autopilot-workspace-run-test.json"),await F(I,s);let i=Q(s);if(i==="fail")x="fail",v="workspace test stage failed for selected projects",e.push("workspace run test failed for selected projects");else {i==="warn"&&(x="warn",v="workspace test stage completed with warnings",a$1==="enforce"&&e.push("workspace run test reported warnings under enforce mode"));let m=await a({workspacePath:r,stage:"build",affected:true,since:t.since,parallel:t.parallel,maxWorkers:t.maxWorkers,strict:true,json:true,enforceGates:false});T=R.join(r,".rapidkit","reports","autopilot-workspace-run-build.json"),await F(T,m);let g=Q(m);g==="fail"?(x="fail",v="workspace build stage failed for selected projects",e.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",v="workspace test/build completed with warnings",a$1==="enforce"&&e.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){x="fail",v="workspace test/build orchestration failed",d=true,e.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let ee=Date.now()-O;o.push({name:"workspace-run-test-build",status:x,durationMs:ee,summary:v});let M=o.filter(s=>s.status==="warn").length,te=o.filter(s=>s.status==="fail").length,J=a$1==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):te>0,W=[...new Set(e)],se=d||J?Math.max(1,W.length):0,re=ce(o),oe=d||J?"blocked":M>0?"partial":"approved",ae=d?3:J?1:M>0?2:0,ne=ue({mode:a$1,executionError:d,blockers:W,hasWarnings:M>0}),H=R.join(r,".rapidkit","reports","autopilot-release-last-run.json"),f={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:r,mode:a$1,summary:{releaseScore:re,verdict:oe,blockers:se,warnings:M,safeFixesApplied:V,manualActions:W.length,exitCode:ae},stages:o,blockingReasons:W,nextActions:ne,artifacts:{reportPath:H,analyzeEvidencePath:G,readinessEvidencePath:E,workspaceRunTestPath:I,workspaceRunBuildPath:T}};if(await F(H,f),t.output&&await F(R.resolve(t.output),f),!t.json){console.log(l.bold.cyan(`
3
- \u{1F680} RapidKit Autopilot Release
4
- `)),console.log(l.bold(`Workspace: ${l.cyan(R.basename(r))}`)),console.log(l.gray(`Path: ${r}`)),console.log(l.white(`Mode: ${a$1}`)),console.log(l.white(`Verdict: ${f.summary.verdict==="approved"?l.green("approved"):f.summary.verdict==="partial"?l.yellow("partial"):l.red("blocked")}`)),console.log(l.white(`Release score: ${f.summary.releaseScore}`));for(let s of f.stages){let i=s.status==="pass"?l.green("PASS"):s.status==="warn"?l.yellow("WARN"):s.status==="skipped"?l.gray("SKIP"):l.red("FAIL");console.log(` - ${s.name}: ${i} ${s.summary} (${s.durationMs}ms)`);}if(f.blockingReasons.length>0){console.log(l.bold.red(`
5
- Blocking reasons:`));for(let s of f.blockingReasons)console.log(l.red(` - ${s}`));}if(f.nextActions.length>0){console.log(l.bold(`
6
- Next actions:`));for(let s of f.nextActions)console.log(l.gray(` - ${s}`));}console.log(l.gray(`
7
- Report: ${f.artifacts.reportPath}`));}return f}export{ye as a};
@@ -1 +0,0 @@
1
- export{b as PYTHON_FREE_WORKSPACE_PROFILES,e as createProject,f as registerWorkspaceAtPath,c as resolvePythonFreeFallbackProfile,a as syncWorkspaceFoundationFiles,d as writeWorkspaceLauncher}from'./chunk-752X3YI3.js';
@@ -1,5 +0,0 @@
1
- import {b}from'./chunk-TC2PSHT6.js';import {a as a$1}from'./chunk-5LLGW5TP.js';import {a as a$3}from'./chunk-R4RPUW7I.js';import {a as a$2}from'./chunk-DKVWFHZO.js';import {a}from'./chunk-KMUWWZRT.js';import {b as b$1}from'./chunk-FNL34DKD.js';import c from'chalk';import x from'fs-extra';import u from'path';function D(s){return s===0?"pass":s===2?"warn":"fail"}function M(s){return s.some(r=>r.status==="fail")?"blocked":s.some(r=>r.status==="warn")?"needs-attention":"ready"}function j(s,r){if(r)return 3;let t=s.some(i=>i.status==="fail"),a=s.some(i=>i.status==="warn");return t?1:a?2:0}async function A(s){let r=await b$1(s,true),t=false;try{let{syncWorkspaceContract:a}=await import('./workspace-contract-A6QP7FPA.js');await a({workspacePath:s}),t=true;}catch{t=false;}return {sync:r,contractSynced:t}}async function C(s={}){let r=u.resolve(s.workspacePath??process.cwd()),t=a(r);if(!t)throw new Error("No RapidKit workspace found in current directory or parents");let a$4=[],i=[],l=false,p,f,d,g=Date.now();try{let{sync:e,contractSynced:o}=await A(t),n=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";a$4.push({name:"sync",status:n,durationMs:Date.now()-g,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${o?", contract synced":""}`:"workspace not registered in global registry; contract sync attempted"}),e.workspaceFound||i.push("workspace registry entry missing \u2014 run rapidkit create workspace or register manually");}catch(e){l=true,a$4.push({name:"sync",status:"fail",durationMs:Date.now()-g,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),i.push("workspace sync stage failed");}let y=Date.now();try{let e=await b({workspace:true,json:true,quiet:true,strict:s.strict===true,ci:s.strict!==true}),o=D(e),n=u.join(t,".rapidkit","reports","doctor-last-run.json");a$4.push({name:"doctor",status:o,durationMs:Date.now()-y,summary:o==="pass"?"doctor workspace passed":o==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors",exitCode:e,evidencePath:n}),o==="fail"?i.push("doctor workspace gate failed"):o==="warn"&&i.push("doctor workspace reported warnings");}catch(e){l=true,a$4.push({name:"doctor",status:"fail",durationMs:Date.now()-y,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),i.push("doctor workspace stage failed");}if(s.skipAnalyze)a$4.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let o=await a$1({workspacePath:t,json:true,strict:s.strict===true});p=u.join(t,".rapidkit","reports","analyze-last-run.json");let n=o.summary.verdict==="blocked"?"fail":o.summary.verdict==="needs-attention"?"warn":"pass";a$4.push({name:"analyze",status:n,durationMs:Date.now()-e,summary:`analyze verdict: ${o.summary.verdict} (score ${o.summary.score}/100)`,evidencePath:p}),n==="fail"?i.push("analyze reported blocked verdict"):n==="warn"&&i.push("analyze reported needs-attention verdict");}catch(o){l=true,a$4.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${o instanceof Error?o.message:String(o)}`}),i.push("analyze stage failed");}}let w=Date.now();try{let e=await a$2({startPath:t,writeReport:true,skipVerify:s.skipVerify===true});f=e.evidencePath;let o=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";a$4.push({name:"readiness",status:o,durationMs:Date.now()-w,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),o==="fail"?i.push(...e.blockingReasons.map(n=>`readiness: ${n}`)):o==="warn"&&i.push(...e.gates.filter(n=>n.status==="warn").map(n=>`readiness warn: ${n.gate}: ${n.summary}`));}catch(e){l=true,a$4.push({name:"readiness",status:"fail",durationMs:Date.now()-w,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),i.push("readiness stage failed");}if(s.skipAutopilot)a$4.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),o=s.autopilotMode??"audit";try{let n=await a$3({workspacePath:t,mode:o,json:true,skipPipelineStages:true});d=n.artifacts.reportPath;let k=n.summary.verdict==="approved"?"pass":n.summary.verdict==="partial"?"warn":"fail";a$4.push({name:"autopilot",status:k,durationMs:Date.now()-e,summary:`autopilot ${o}: ${n.summary.verdict}`,exitCode:n.summary.exitCode,evidencePath:d}),k!=="pass"&&i.push(...n.blockingReasons.slice(0,5));}catch(n){l=true,a$4.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${n instanceof Error?n.message:String(n)}`}),i.push("autopilot release stage failed");}}let E=M(a$4),z=j(a$4,l),m=u.join(t,".rapidkit","reports","pipeline-last-run.json"),h={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:t,summary:{verdict:E,exitCode:z,stagesPassed:a$4.filter(e=>e.status==="pass").length,stagesWarn:a$4.filter(e=>e.status==="warn").length,stagesFailed:a$4.filter(e=>e.status==="fail").length},stages:a$4,blockingReasons:[...new Set(i)],artifacts:{reportPath:m,analyzeEvidencePath:p,readinessEvidencePath:f,autopilotEvidencePath:d}};return s.writeReport!==false&&(await x.ensureDir(u.dirname(m)),await x.writeJSON(m,h,{spaces:2})),h}async function L(s){let r;try{r=await C(s);}catch(t){let a=t instanceof Error?t.message:String(t);s.json?console.log(JSON.stringify({schemaVersion:"rapidkit-pipeline-error-v1",ok:false,error:{message:a}},null,2)):console.log(c.red(`Pipeline failed: ${a}`)),process.exit(1);}if(s.json)console.log(JSON.stringify(r,null,2));else {console.log(c.bold.cyan(`
2
- \u{1F517} RapidKit Governance Pipeline
3
- `)),console.log(c.bold(`Workspace: ${c.cyan(u.basename(r.workspacePath))}`)),console.log(c.gray(`Path: ${r.workspacePath}`)),console.log(c.white(`Verdict: ${r.summary.verdict} Exit: ${r.summary.exitCode} (${r.summary.stagesPassed} pass / ${r.summary.stagesWarn} warn / ${r.summary.stagesFailed} fail)`));for(let t of r.stages){let a=t.status==="pass"?c.green("PASS"):t.status==="warn"?c.yellow("WARN"):t.status==="skipped"?c.gray("SKIP"):c.red("FAIL");console.log(` - ${t.name}: ${a} ${t.summary}`);}if(r.blockingReasons.length>0){console.log(c.bold(`
4
- Blocking reasons:`));for(let t of r.blockingReasons.slice(0,8))console.log(c.gray(` \u2022 ${t}`));}console.log(c.gray(`
5
- Evidence: ${r.artifacts.reportPath}`));}r.summary.exitCode!==0&&process.exit(r.summary.exitCode);}export{C as runPipeline,L as runPipelineCommand};
@@ -1 +0,0 @@
1
- import {a as a$1}from'./chunk-752X3YI3.js';import {a}from'./chunk-RV6HBTFC.js';import c from'path';import d from'fs-extra';async function v(e,r){let o=await a(e),f=o?.name||c.basename(e),n,i=c.join(e,".python-version");if(await d.pathExists(i)){let a=(await d.readFile(i,"utf-8")).trim();a&&(n=a);}let t=r?.profile||"polyglot",u=t==="python-only"||t==="polyglot"||t==="enterprise",m=r?.installMethod||o?.metadata?.npm?.installMethod||(u?"poetry":"venv"),s=await a$1(e,{workspaceName:f,installMethod:m,pythonVersion:n,profile:t,writeMarker:true,writeGitignore:true,onlyIfMissing:!r?.force});return {workspacePath:e,created:s,status:s.length>0?"passed":"skipped"}}export{v as ensureWorkspaceFoundation};
@@ -1 +0,0 @@
1
- export{a as runWorkspaceStage}from'./chunk-KDUAZXEQ.js';