rapidkit 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +216 -24
- package/contracts/analyze-last-run.v1.json +106 -0
- package/contracts/cli-log-event.v1.json +51 -0
- package/contracts/doctor-project-evidence.v1.json +46 -0
- package/contracts/doctor-workspace-evidence.v1.json +57 -0
- package/contracts/release-readiness.v1.json +60 -0
- package/contracts/workspace-registry.v1.json +83 -0
- package/contracts/workspace-run-last.v1.json +112 -0
- package/dist/analyze-6RFG7C7Z.js +1 -0
- package/dist/autopilot-release-AUXP2ZIF.js +1 -0
- package/dist/chunk-6P5DCHBQ.js +4 -0
- package/dist/chunk-7VSYTOOG.js +7 -0
- package/dist/chunk-B2KOIORF.js +1 -0
- package/dist/{chunk-VPNHGQIV.js → chunk-C7OVQQXT.js} +1 -1
- package/dist/chunk-C7WILE56.js +1 -0
- package/dist/chunk-D23L2GFT.js +2 -0
- package/dist/{workspace-context-YFQQROOZ.js → chunk-EJGKBFV4.js} +2 -2
- package/dist/chunk-FV5A3N3I.js +2 -0
- package/dist/chunk-GDGATWR5.js +2 -0
- package/dist/chunk-HEG6DIGW.js +2 -0
- package/dist/{chunk-752X3YI3.js → chunk-IOIWVHRO.js} +81 -81
- package/dist/chunk-JBDQADHY.js +50 -0
- package/dist/{chunk-AC6KIKII.js → chunk-PPQYTYQG.js} +4 -4
- package/dist/chunk-RELR4O5E.js +2 -0
- package/dist/{chunk-FNL34DKD.js → chunk-RUUDLAKJ.js} +12 -12
- package/dist/chunk-T5LN7EO5.js +9 -0
- package/dist/chunk-U6QUN6V2.js +2 -0
- package/dist/chunk-UXKB4KGZ.js +13 -0
- package/dist/create-HN5HOGQ4.js +1 -0
- package/dist/{demo-kit-KTRITRWH.js → demo-kit-3VTLJBP7.js} +1 -1
- package/dist/{doctor-DG3TBPZN.js → doctor-QC662YLH.js} +1 -1
- package/dist/{dotnet-webapi-clean-TPQMNFSD.js → dotnet-webapi-clean-FX533F5U.js} +1 -1
- package/dist/{gofiber-standard-NDCBY6OM.js → gofiber-standard-35CJZ7S3.js} +1 -1
- package/dist/{gogin-standard-WUOMIHDR.js → gogin-standard-SAX6C4ZK.js} +1 -1
- package/dist/index.js +214 -213
- package/dist/managed-agent-markers-AXUM75OE.js +8 -0
- package/dist/pipeline-BOU4KETN.js +5 -0
- package/dist/{springboot-standard-WQWB5E24.js → springboot-standard-SFMSLTX4.js} +1 -1
- package/dist/{workspace-ZXWYIZOR.js → workspace-2AL5C3QZ.js} +1 -1
- package/dist/workspace-agent-sync-V2H6NTGD.js +17 -0
- package/dist/workspace-context-KCKNV5VQ.js +1 -0
- package/dist/{workspace-contract-A6QP7FPA.js → workspace-contract-D5O4OZD5.js} +1 -1
- package/dist/workspace-foundation-L6ZBGMVE.js +1 -0
- package/dist/{workspace-intelligence-NXIO55GJ.js → workspace-intelligence-3TWXJQ7Y.js} +1 -1
- package/dist/{workspace-model-OO4WOBJS.js → workspace-model-NQVZN5W4.js} +1 -1
- package/dist/workspace-registry-summary-MIPHVB56.js +1 -0
- package/dist/workspace-run-DEXI52KO.js +1 -0
- package/dist/workspace-verify-HBCQNNGU.js +1 -0
- package/package.json +2 -1
- package/dist/analyze-IIPDLLM2.js +0 -1
- package/dist/autopilot-release-EO7GQS4P.js +0 -1
- package/dist/chunk-5LLGW5TP.js +0 -9
- package/dist/chunk-B7NCBH5B.js +0 -2
- package/dist/chunk-DKVWFHZO.js +0 -4
- package/dist/chunk-IATULVMR.js +0 -11
- package/dist/chunk-KDUAZXEQ.js +0 -3
- package/dist/chunk-MCLLP6MW.js +0 -2
- package/dist/chunk-R4RPUW7I.js +0 -7
- package/dist/chunk-TC2PSHT6.js +0 -50
- package/dist/chunk-VM2TOHNX.js +0 -2
- package/dist/create-LUXJGSNL.js +0 -1
- package/dist/pipeline-7OTUIB6D.js +0 -5
- package/dist/workspace-foundation-TYLH5SAU.js +0 -1
- package/dist/workspace-run-AZ63D75J.js +0 -1
- package/dist/workspace-verify-K56NI3AI.js +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var c="<!-- RAPIDKIT:AGENT-GROUNDING:START -->",s="<!-- RAPIDKIT:AGENT-GROUNDING:END -->",i=new RegExp(`${u(c)}[\\s\\S]*?${u(s)}`,"m");function u(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g(n,t){let r=`${c}
|
|
2
|
+
${t.trim()}
|
|
3
|
+
${s}`,e=typeof n=="string"?n.trimEnd():"";return e?i.test(e)?`${e.replace(i,r).trimEnd()}
|
|
4
|
+
`:`${e}
|
|
5
|
+
|
|
6
|
+
${r}
|
|
7
|
+
`:`${r}
|
|
8
|
+
`}function l(n){if(!n)return null;let t=n.match(i);return t?t[0].replace(c,"").replace(s,"").trim():null}export{s as RAPIDKIT_AGENT_GROUNDING_END,c as RAPIDKIT_AGENT_GROUNDING_START,l as extractManagedAgentSection,g as upsertManagedAgentSection};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {c}from'./chunk-7VSYTOOG.js';import {b}from'./chunk-JBDQADHY.js';import {b as b$1}from'./chunk-RUUDLAKJ.js';import {a as a$1}from'./chunk-T5LN7EO5.js';import {a as a$2}from'./chunk-6P5DCHBQ.js';import {a}from'./chunk-KMUWWZRT.js';import {e,d}from'./chunk-B2KOIORF.js';import c$1 from'chalk';import D from'fs-extra';import u from'path';function C(t){return t===0?"pass":t===2?"warn":"fail"}function M(t){return t.some(s=>s.status==="fail")?"blocked":t.some(s=>s.status==="warn")?"needs-attention":"ready"}function F(t,s){if(s)return 3;let a=t.some(i=>i.status==="fail"),r=t.some(i=>i.status==="warn");return a?1:r?2:0}async function j(t){let s=await b$1(t,true),a=false;try{let{syncWorkspaceContract:r}=await import('./workspace-contract-D5O4OZD5.js');await r({workspacePath:t}),a=true;}catch{a=false;}return {sync:s,contractSynced:a}}async function G(t={}){let s=u.resolve(t.workspacePath??process.cwd()),a$3=a(s);if(!a$3)throw new Error("No RapidKit workspace found in current directory or parents");let r=[],i=[],l=false,p,y,m,f=Date.now();try{let{sync:e,contractSynced:n}=await j(a$3),o=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";r.push({name:"sync",status:o,durationMs:Date.now()-f,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${n?", 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,r.push({name:"sync",status:"fail",durationMs:Date.now()-f,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),i.push("workspace sync stage failed");}let w=Date.now();try{let e=await b({workspace:true,json:true,quiet:true,strict:t.strict===true,ci:t.strict!==true}),n=C(e),o=u.join(a$3,".rapidkit","reports","doctor-last-run.json");r.push({name:"doctor",status:n,durationMs:Date.now()-w,summary:n==="pass"?"doctor workspace passed":n==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors",exitCode:e,evidencePath:o}),n==="fail"?i.push("doctor workspace gate failed"):n==="warn"&&i.push("doctor workspace reported warnings");}catch(e){l=true,r.push({name:"doctor",status:"fail",durationMs:Date.now()-w,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),i.push("doctor workspace stage failed");}if(t.skipAnalyze)r.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let n=await a$1({workspacePath:a$3,json:true,strict:t.strict===true});p=u.join(a$3,".rapidkit","reports","analyze-last-run.json");let o=n.summary.verdict==="blocked"?"fail":n.summary.verdict==="needs-attention"?"warn":"pass";r.push({name:"analyze",status:o,durationMs:Date.now()-e,summary:`analyze verdict: ${n.summary.verdict} (score ${n.summary.score}/100)`,evidencePath:p}),o==="fail"?i.push("analyze reported blocked verdict"):o==="warn"&&i.push("analyze reported needs-attention verdict");}catch(n){l=true,r.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${n instanceof Error?n.message:String(n)}`}),i.push("analyze stage failed");}}let h=Date.now();try{let e=await a$2({startPath:a$3,writeReport:true,skipVerify:t.skipVerify===true});y=e.evidencePath;let n=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";r.push({name:"readiness",status:n,durationMs:Date.now()-h,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),n==="fail"?i.push(...e.blockingReasons.map(o=>`readiness: ${o}`)):n==="warn"&&i.push(...e.gates.filter(o=>o.status==="warn").map(o=>`readiness warn: ${o.gate}: ${o.summary}`));}catch(e){l=true,r.push({name:"readiness",status:"fail",durationMs:Date.now()-h,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),i.push("readiness stage failed");}if(t.skipAutopilot)r.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),n=t.autopilotMode??"audit";try{let o=await c({workspacePath:a$3,mode:n,json:true,skipPipelineStages:true});m=o.artifacts.reportPath;let P=o.summary.verdict==="approved"?"pass":o.summary.verdict==="partial"?"warn":"fail";r.push({name:"autopilot",status:P,durationMs:Date.now()-e,summary:`autopilot ${n}: ${o.summary.verdict}`,exitCode:o.summary.exitCode,evidencePath:m}),P!=="pass"&&i.push(...o.blockingReasons.slice(0,5));}catch(o){l=true,r.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${o instanceof Error?o.message:String(o)}`}),i.push("autopilot release stage failed");}}let z=M(r),k=F(r,l),g=u.join(a$3,".rapidkit","reports","pipeline-last-run.json"),d$1={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:a$3,summary:{verdict:z,exitCode:k,stagesPassed:r.filter(e=>e.status==="pass").length,stagesWarn:r.filter(e=>e.status==="warn").length,stagesFailed:r.filter(e=>e.status==="fail").length},stages:r,blockingReasons:[...new Set(i)],artifacts:{reportPath:g,analyzeEvidencePath:p,readinessEvidencePath:y,autopilotEvidencePath:m}};if(t.writeReport!==false){await D.ensureDir(u.dirname(g));let e$1=e(d$1,{commandId:"workspacePipeline",exitCode:k,generatedAt:d$1.generatedAt,blockers:d$1.blockingReasons,runId:d()});await D.writeJSON(g,e$1,{spaces:2});}if(t.writeReport!==false&&t.noAgentSync!==true&&process.env.RAPIDKIT_NO_AGENT_SYNC!=="1"&&t.agentSync!==false)try{let{syncWorkspaceAgentGrounding:e}=await import('./workspace-agent-sync-V2H6NTGD.js'),n=await e({workspacePath:a$3,write:true,refreshContext:true,strict:false});d$1.agentGrounding={indexPath:n.indexPath,writtenFiles:n.writtenFiles,blockers:n.blockers};}catch{}return d$1}async function X(t){let s;try{s=await G(t);}catch(a){let r=a instanceof Error?a.message:String(a);t.json?console.log(JSON.stringify({schemaVersion:"rapidkit-pipeline-error-v1",ok:false,error:{message:r}},null,2)):console.log(c$1.red(`Pipeline failed: ${r}`)),process.exit(1);}if(t.json)console.log(JSON.stringify(s,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(s.workspacePath))}`)),console.log(c$1.gray(`Path: ${s.workspacePath}`)),console.log(c$1.white(`Verdict: ${s.summary.verdict} Exit: ${s.summary.exitCode} (${s.summary.stagesPassed} pass / ${s.summary.stagesWarn} warn / ${s.summary.stagesFailed} fail)`));for(let a of s.stages){let r=a.status==="pass"?c$1.green("PASS"):a.status==="warn"?c$1.yellow("WARN"):a.status==="skipped"?c$1.gray("SKIP"):c$1.red("FAIL");console.log(` - ${a.name}: ${r} ${a.summary}`);}if(s.blockingReasons.length>0){console.log(c$1.bold(`
|
|
4
|
+
Blocking reasons:`));for(let a of s.blockingReasons.slice(0,8))console.log(c$1.gray(` \u2022 ${a}`));}console.log(c$1.gray(`
|
|
5
|
+
Evidence: ${s.artifacts.reportPath}`)),s.agentGrounding?.writtenFiles.length&&console.log(c$1.gray(`Agent grounding: ${s.agentGrounding.writtenFiles.length} file(s) synced (INDEX + AGENTS.md + Copilot/Cursor/Claude hooks)`));}s.summary.exitCode!==0&&process.exit(s.summary.exitCode);}export{G as runPipeline,X as runPipelineCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b as b$1,c}from'./chunk-3Q7264EJ.js';import {b}from'./chunk-
|
|
1
|
+
import {b as b$1,c}from'./chunk-3Q7264EJ.js';import {b}from'./chunk-PPQYTYQG.js';import {promises}from'fs';import g from'path';import r from'chalk';import R from'ora';import {execa}from'execa';var y="21",$="3.5.0",j="2.8.9";function u(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,".").replace(/^\.+|\.+$/g,"").replace(/\.{2,}/g,".").split(".").map(p=>p.replace(/^[^a-z]+/,"").replace(/[^a-z0-9]/g,"")).filter(Boolean).join(".")}function _(e,t){return e.replace(/[\r\n\t]+/g," ").trim()||t}function x(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-")}function M(e,t){let s=u(e)||"com.rapidkit.apps",p=u(t)||"service";return `${s}.${p}`}function E(e){return e.replace(/\./g,"/")}function T(){return JSON.stringify({engine:"npm",runtime:"java"},null,2)}function A(e,t){return JSON.stringify({kit_name:"springboot.standard",runtime:"java",module_support:false,project_name:e.project_name,artifact_id:e.artifact_id,group_id:e.group_id,package_name:e.package_name,app_version:e.app_version,created_by:"rapidkit-npm",rapidkit_version:t,created_at:new Date().toISOString()},null,2)}function P(e){return `<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
3
3
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4
4
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
@@ -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-
|
|
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-RUUDLAKJ.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {b,c,d}from'./chunk-EJGKBFV4.js';import i from'path';import c$1 from'fs-extra';var O="rapidkit-agent-reports-index.v1",E=".rapidkit/reports/INDEX.json",G=".rapidkit/AGENT-GROUNDING.md",S=[{relativePath:b,label:"Agent context pack",required:true},{relativePath:".rapidkit/reports/workspace-model.json",label:"Workspace model graph",required:false},{relativePath:".rapidkit/reports/doctor-last-run.json",label:"Workspace doctor",required:false},{relativePath:".rapidkit/reports/analyze-last-run.json",label:"Workspace analyze",required:false},{relativePath:".rapidkit/reports/pipeline-last-run.json",label:"Governance pipeline",required:false},{relativePath:".rapidkit/reports/release-readiness-last-run.json",label:"Release readiness",required:false},{relativePath:".rapidkit/reports/workspace-impact-last-run.json",label:"Workspace impact",required:false},{relativePath:".rapidkit/reports/workspace-verify-last-run.json",label:"Workspace verify",required:false}];function k(e){return `npx rapidkit ${e}`.trim()}function I(e){return e&&typeof e=="object"?e:null}function j(e,t=12){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0).slice(0,t):[]}function q(e){let t=j(e.blockers,12);if(t.length>0)return t;let r=j(e.blockingReasons,12);if(r.length>0)return r;let n=I(e.summary);return n&&Array.isArray(n.blockingReasons)?j(n.blockingReasons,12):[]}function _(e){for(let t of ["generatedAt","timestamp"]){let r=e[t];if(typeof r=="string"&&r.trim())return r.trim()}}function $(e,t,r){if(!e)return true;let n=Date.parse(e);return Number.isFinite(n)?r.getTime()-n>t*60*60*1e3:true}function K(e){let t=e&&e.length>0?e:["all"];return t.includes("all")?new Set(["all","agents","copilot","cursor","claude","codex","orca"]):new Set(t)}function u(e,t){return e.has("all")||e.has(t)}async function X(e){try{if(!await c$1.pathExists(e))return null;let t=await c$1.readJson(e);return I(t)}catch{return null}}async function F(e){let t=e.now??new Date,r=e.staleAfterHours??24,n=[],d=[];for(let l of S){let h=i.join(e.workspacePath,l.relativePath),a=await X(h),p=a!==null;p&&a&&d.push(...q(a)),n.push({path:l.relativePath,label:l.label,required:l.required,exists:p,generatedAt:a?_(a):void 0,commandId:typeof a?.commandId=="string"?a.commandId:void 0,exitCode:typeof a?.exitCode=="number"?a.exitCode:void 0});}let s=[...new Set(d.map(l=>l.trim()).filter(Boolean))].slice(0,16);return {schemaVersion:O,generatedAt:t.toISOString(),workspaceRoot:e.workspacePath,readOrder:S.map(l=>l.relativePath),blockers:s,staleAfterHours:r,reports:n,refreshCommand:k("workspace agent-sync --write --refresh-context")}}function N(e){let t=["# RapidKit agent grounding","","Cross-tool instructions for Copilot, Cursor, Claude Code, Codex, Grok, and other agents.","","## Read order (mandatory before workspace diagnosis)","","1. `.rapidkit/reports/INDEX.json` \u2014 latest blockers, timestamps, and report paths","2. `.rapidkit/reports/workspace-context-agent.json` \u2014 canonical agent context pack","3. Evidence artifacts listed in the index (doctor, analyze, pipeline, readiness, impact, verify)","","Do **not** full-repo scan until these reports are read or regenerated.","","## Regenerate intelligence","","```bash",k("workspace agent-sync --write --refresh-context"),k("workspace context --for-agent --json --write"),k("pipeline --json --write"),"```",""];if(e.index.blockers.length>0){t.push("## Current blockers","");for(let r of e.index.blockers.slice(0,12))t.push(`- ${r}`);t.push("");}if(e.context?.safeCommands?.length){t.push("## Safe commands (prefer these)","");for(let r of e.context.safeCommands.slice(0,10))t.push(`- \`${r.display}\` \u2014 ${r.description}`);t.push("");}return t.push("## Rules","","- Treat `.rapidkit/reports/*` as the source of truth for health, gates, and release posture.","- Prefer deterministic RapidKit CLI commands over heuristic framework guesses.","- If evidence is missing or stale, run the refresh commands above before proposing fixes.","- Keep project-scoped advice aligned with the active project named in the context pack.",""),t.join(`
|
|
2
|
+
`)}function B(e){return ["# RapidKit agent grounding","",`Generated: ${e.generatedAt}`,"","This file is tool-agnostic. Synced agents should read it together with `.rapidkit/reports/INDEX.json`.","","## Mandatory read order","",...e.readOrder.map((t,r)=>`${r+1}. \`${t}\``),"",e.blockers.length>0?"## Blockers":"",...e.blockers.length>0?e.blockers.map(t=>`- ${t}`):[],"","## Refresh","","```bash",e.refreshCommand,"```",""].filter(t=>t!=="").join(`
|
|
3
|
+
`)}function H(){return ["# RapidKit workspace grounding","","Before answering workspace, release, or architecture questions:","","1. Read `AGENTS.md` (managed RapidKit section).","2. Read `.rapidkit/reports/INDEX.json` and `.rapidkit/reports/workspace-context-agent.json`.","3. Use evidence reports before scanning the full repository.","","Regenerate stale intelligence:","","```bash",k("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
4
|
+
`)}function L(){return ["## Claude Code","","- Load `.rapidkit/reports/INDEX.json` before diagnosing blockers.","- Use `.claude/rules/rapidkit-evidence.md` when editing files under `.rapidkit/`.","- Refresh grounding with `npx rapidkit workspace agent-sync --write`.",""].join(`
|
|
5
|
+
`)}function M(){return ["---","description: RapidKit workspace evidence and intelligence grounding","globs: []","alwaysApply: true","---","","Before proposing fixes in this workspace:","","1. Read `AGENTS.md` and `.rapidkit/reports/INDEX.json`.","2. Read `.rapidkit/reports/workspace-context-agent.json`.","3. Prefer evidence in `.rapidkit/reports/*` over full-repo exploration.","","Refresh when stale:","","```bash",k("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
6
|
+
`)}function U(){return ["---",'applyTo: ".rapidkit/**,**/.rapidkit/**"',"description: RapidKit evidence and intelligence artifacts","---","","When working under `.rapidkit/`:","","- Treat JSON reports as canonical gate and health evidence.","- Start from `reports/INDEX.json` for read order and blockers.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.",""].join(`
|
|
7
|
+
`)}function z(){return ["# RapidKit evidence","","Applies when reading or editing `.rapidkit/reports/*`.","","- Start from `INDEX.json`, then `workspace-context-agent.json`.","- Use report blockers as the primary fix target.","- Regenerate with `npx rapidkit workspace agent-sync --write`.",""].join(`
|
|
8
|
+
`)}function J(){return ["---","description: Diagnose RapidKit workspace blockers from evidence reports","---","","Diagnose this workspace using RapidKit evidence only.","","Read:","","- `.rapidkit/reports/INDEX.json`","- `.rapidkit/reports/workspace-context-agent.json`","- Any fail/warn reports referenced in the index","","Return:","","1. Root cause grounded in report blockers","2. Smallest safe fix path (commands + file edits)","3. One verification command to prove recovery",""].join(`
|
|
9
|
+
`)}function V(){return ["---","name: rapidkit-grounding","description: Load RapidKit workspace intelligence reports before diagnosing or changing code","---","","# RapidKit grounding","","Use when the user asks about workspace health, release gates, doctor/pipeline failures, or project structure.","","## Workflow","","1. Read `.rapidkit/reports/INDEX.json`","2. Read `.rapidkit/reports/workspace-context-agent.json`","3. Read fail/warn evidence artifacts listed in the index","4. Propose the smallest safe fix with explicit verification commands","","## Refresh stale evidence","","```bash",k("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
10
|
+
`)}async function f(e,t,r){return r?(await c$1.ensureDir(i.dirname(e)),await c$1.writeFile(e,t,"utf8"),"written"):"skipped"}async function T(e){if(!e.write)return "skipped";let t=await c$1.pathExists(e.absolutePath)?await c$1.readFile(e.absolutePath,"utf8"):null,{upsertManagedAgentSection:r}=await import('./managed-agent-markers-AXUM75OE.js'),n=r(t,e.generatedBody),d=e.preamble?`${e.preamble.trimEnd()}
|
|
11
|
+
|
|
12
|
+
${n}`:n;return await c$1.ensureDir(i.dirname(e.absolutePath)),await c$1.writeFile(e.absolutePath,d,"utf8"),"written"}function re(e){if(!e?.trim())return;let t=new Set(["all","agents","copilot","cursor","claude","codex","orca"]),r=e.split(",").map(n=>n.trim().toLowerCase()).filter(n=>t.has(n));return r.length>0?r:void 0}async function ne(e){let t=i.resolve(e.workspacePath),r=new Date,n=e.staleAfterHours??24,d$1=K(e.targets),s=e.write===true,l=e.strict===true,h,a=null;e.refreshContext&&(a=await c({workspacePath:t,agent:e.agent??"generic",scope:e.scope,includeEvidence:true}),s&&(h=await d(a,t)));let p=await F({workspacePath:t,staleAfterHours:n,now:r}),w=p.reports.filter(o=>o.required&&!o.exists).map(o=>o.path),b=p.reports.filter(o=>o.exists&&$(o.generatedAt,n,r)).map(o=>o.path),A=[];l&&(w.length>0&&A.push(`Missing required reports: ${w.join(", ")}`),b.length>0&&A.push(`Stale reports (>${n}h): ${b.join(", ")}`));let x=[],R=[],g=(o,m)=>{o==="written"?x.push(m):R.push(m);};if(g(await f(i.join(t,E),`${JSON.stringify(p,null,2)}
|
|
13
|
+
`,s),E),g(await f(i.join(t,G),`${B(p)}
|
|
14
|
+
`,s),G),u(d$1,"agents")&&g(await T({absolutePath:i.join(t,"AGENTS.md"),generatedBody:N({index:p,context:a}),write:s}),"AGENTS.md"),u(d$1,"claude")){let o=i.join(t,"CLAUDE.md");if(s){let{upsertManagedAgentSection:m}=await import('./managed-agent-markers-AXUM75OE.js'),D=await c$1.pathExists(o)?await c$1.readFile(o,"utf8"):"",y=m(D,L()),W=y.includes("@AGENTS.md")?y:`@AGENTS.md
|
|
15
|
+
|
|
16
|
+
${y}`;await c$1.ensureDir(i.dirname(o)),await c$1.writeFile(o,W,"utf8"),x.push("CLAUDE.md");}else R.push("CLAUDE.md");g(await f(i.join(t,".claude/rules/rapidkit-evidence.md"),`${z()}
|
|
17
|
+
`,s),".claude/rules/rapidkit-evidence.md");}return u(d$1,"cursor")&&g(await f(i.join(t,".cursor/rules/rapidkit-grounding.mdc"),M(),s),".cursor/rules/rapidkit-grounding.mdc"),u(d$1,"copilot")&&(g(await T({absolutePath:i.join(t,".github/copilot-instructions.md"),generatedBody:H(),write:s}),".github/copilot-instructions.md"),g(await f(i.join(t,".github/instructions/rapidkit-evidence.instructions.md"),U(),s),".github/instructions/rapidkit-evidence.instructions.md"),g(await f(i.join(t,".github/prompts/rapidkit-diagnose.prompt.md"),J(),s),".github/prompts/rapidkit-diagnose.prompt.md"),g(await f(i.join(t,".github/skills/rapidkit-grounding/SKILL.md"),V(),s),".github/skills/rapidkit-grounding/SKILL.md")),(u(d$1,"codex")||u(d$1,"orca"))&&(u(d$1,"agents")||g(await T({absolutePath:i.join(t,"AGENTS.md"),generatedBody:N({index:p,context:a}),write:s}),"AGENTS.md")),{workspacePath:t,indexPath:i.join(t,E),contextPath:h,writtenFiles:x,skippedFiles:R,blockers:p.blockers,missingRequired:w,staleReports:b,strictViolations:A}}export{G as AGENT_GROUNDING_DOC_PATH,E as AGENT_REPORTS_INDEX_PATH,O as AGENT_REPORTS_INDEX_SCHEMA,S as AGENT_REPORT_CATALOG,F as buildWorkspaceAgentReportsIndex,re as parseAgentGroundingTargets,ne as syncWorkspaceAgentGrounding};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as WORKSPACE_CONTEXT_AGENT_REPORT_PATH,a as WORKSPACE_CONTEXT_SCHEMA_VERSION,c as buildWorkspaceAgentContext,d as writeWorkspaceAgentContext}from'./chunk-EJGKBFV4.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as WORKSPACE_CONTRACT_PATH,b as WORKSPACE_CONTRACT_SCHEMA_VERSION,d as buildWorkspaceContract,h as buildWorkspaceContractGraph,c as discoverProjectJsonFiles,g as readWorkspaceContract,f as syncWorkspaceContract,i as verifyWorkspaceContract,e as writeWorkspaceContract}from'./chunk-
|
|
1
|
+
export{a as WORKSPACE_CONTRACT_PATH,b as WORKSPACE_CONTRACT_SCHEMA_VERSION,d as buildWorkspaceContract,h as buildWorkspaceContractGraph,c as discoverProjectJsonFiles,g as readWorkspaceContract,f as syncWorkspaceContract,i as verifyWorkspaceContract,e as writeWorkspaceContract}from'./chunk-GDGATWR5.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b}from'./chunk-IOIWVHRO.js';import {a}from'./chunk-RV6HBTFC.js';import c from'path';import u from'fs-extra';async function W(t,r){let o=await a(t),d=o?.name||c.basename(t),n,i=c.join(t,".python-version");if(await u.pathExists(i)){let a=(await u.readFile(i,"utf-8")).trim();a&&(n=a);}let e=r?.profile||"polyglot",m=e==="python-only"||e==="polyglot"||e==="enterprise",f=r?.installMethod||o?.metadata?.npm?.installMethod||(m?"poetry":"venv"),s=await b(t,{workspaceName:d,installMethod:f,pythonVersion:n,profile:e,writeMarker:true,writeGitignore:true,onlyIfMissing:!r?.force}),{publishWorkspaceRegistrySummary:y}=await import('./workspace-registry-summary-MIPHVB56.js');return await y(t),{workspacePath:t,created:s,status:s.length>0?"passed":"skipped"}}export{W 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-
|
|
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-U6QUN6V2.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as WORKSPACE_MODEL_REPORT_PATH,a as WORKSPACE_MODEL_SCHEMA_VERSION,d as buildWorkspaceModel,c as validateWorkspaceModelStrict,e as writeWorkspaceModel}from'./chunk-
|
|
1
|
+
export{b as WORKSPACE_MODEL_REPORT_PATH,a as WORKSPACE_MODEL_SCHEMA_VERSION,d as buildWorkspaceModel,c as validateWorkspaceModelStrict,e as writeWorkspaceModel}from'./chunk-C7OVQQXT.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a,g}from'./chunk-GDGATWR5.js';import {a as a$1}from'./chunk-A5FBGRJA.js';import {j}from'./chunk-Z5LKRG57.js';import s from'path';import n from'fs-extra';var l=".rapidkit/workspace-registry.v1.json",h="workspace-registry.v1";function P(r){return {slug:r.slug,relativePath:r.relativePath,framework:r.framework,kit:r.kit,source:r.source}}async function f(r){let t=s.join(r,".rapidkit","workspace.json");if(!await n.pathExists(t))return {exists:false,legacyProjectCount:0};try{let e=await n.readJson(t),o=Array.isArray(e.projects)?e.projects.length:0;return {exists:true,workspaceName:typeof e.workspace_name=="string"&&e.workspace_name.trim()||typeof e.name=="string"&&e.name.trim()||s.basename(r),profile:typeof e.profile=="string"?e.profile:void 0,legacyProjectCount:o}}catch{return {exists:true,legacyProjectCount:0,workspaceName:s.basename(r)}}}async function W(r){let t=a$1(r),e=s.join(j(),"workspaces.json");if(!await n.pathExists(e))return 0;try{let a=((await n.readJson(e)).workspaces||[]).find(c=>a$1(c.path)===t);return Array.isArray(a?.projects)?a.projects.length:0}catch{return 0}}async function S(r){let t=s.resolve(r),e=s.join(t,a),o=await f(t),a$1=await W(t),c=await n.pathExists(e),i=[];if(c)try{let{contract:w}=await g({workspacePath:t});i=w.projects||[];}catch{i=[];}let R={contract:{exists:c,projectCount:i.length,path:a},globalRegistry:{exists:a$1>0,projectCount:a$1,path:s.join(j(),"workspaces.json")},legacyWorkspaceJson:{exists:o.exists,projectCount:o.legacyProjectCount,path:".rapidkit/workspace.json"}},p="none",u=[],y=0;return c?(p="workspace.contract.json",u=i.map(P),y=u.length):a$1>0?(p="global-registry",y=a$1):o.legacyProjectCount>0&&(p="legacy-workspace.json",y=o.legacyProjectCount),{contractExists:c,summary:{schemaVersion:h,kind:"rapidkit.workspace.registry",workspacePath:t,workspaceName:o.workspaceName||s.basename(t),profile:o.profile,projectCount:y,authority:p,contractPath:a,projects:u,sources:R}}}async function v(r){let t=s.join(s.resolve(r),l);if(!await n.pathExists(t))return null;try{let e=await n.readJson(t);return e?.schemaVersion!==h?null:e}catch{return null}}async function N(r,t){let e=await S(r),o=s.join(s.resolve(r),l),a={...e.summary,generatedAt:(t?.now??new Date).toISOString(),registrySummaryPath:l};return await n.ensureDir(s.dirname(o)),await n.writeJson(o,a,{spaces:2}),a}function M(r,t=""){return r.projectCount>0?r.authority==="workspace.contract.json"?`${r.projectCount} project(s) registered in workspace contract${t}.`:r.authority==="global-registry"?`${r.projectCount} project(s) registered in global workspace registry${t}.`:`${r.projectCount} project(s) registered in legacy workspace manifest${t}.`:`Workspace state exists, but no projects are registered yet${t}.`}export{l as WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH,h as WORKSPACE_REGISTRY_SUMMARY_SCHEMA_VERSION,M as formatWorkspaceRegistrySyncSummary,N as publishWorkspaceRegistrySummary,v as readWorkspaceRegistrySummary,S as resolveWorkspaceRegisteredProjects};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as runWorkspaceStage}from'./chunk-D23L2GFT.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-FV5A3N3I.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {m,f as f$1,c as c$1,n,e}from'./chunk-U6QUN6V2.js';import {d}from'./chunk-C7OVQQXT.js';import {c as c$2}from'./chunk-FV5A3N3I.js';import c from'path';import f from'fs-extra';var R="workspace-verify.v1",S=".rapidkit/reports/workspace-verify-last-run.json";function C(e,s){return c.isAbsolute(s)?s:c.join(e,s)}async function j(e$1){let s=await f.readJson(e$1);if(!s||typeof s!="object"||Array.isArray(s))throw new Error(`Workspace impact input is not a JSON object: ${e$1}`);let t=s;if(t.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(t.schemaVersion)}`);return t}function I(e){let s=new Set,t=[];for(let a of e){let n=`${a.scope}:${a.project??""}:${a.display}`;s.has(n)||(s.add(n),t.push(a));}return t}function V(e,s){if(!e||e==="workspace")return true;let t=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return s.scope==="workspace"?true:(s.project??"").trim().toLowerCase()===t}function A(e,s){if(e.id==="workspace.doctor")return c.join(s,".rapidkit","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return c.join(s,".rapidkit","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return c.join(s,".rapidkit","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return c.join(s,".rapidkit","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return c.join(s,".rapidkit","reports","pipeline-last-run.json");if(e.id.startsWith("project.")&&(e.id.endsWith(".test")||e.id.endsWith(".build")))return c.join(s,".rapidkit","reports","workspace-run-last.json")}function l(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function x(e){let s=l(e.healthScore),t=typeof s?.errors=="number"?s.errors:0,a=typeof s?.percent=="number"?s.percent:void 0;return t>0?{status:"fail",message:`Doctor evidence reports ${t} 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 O(e){let s=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return s==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:s==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:s==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${s}.`}}function $(e){let s=typeof e.status=="string"?e.status:"unknown";return s==="failed"||s==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:s==="passed"||s==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${s}.`}}function _(e){let s=l(e.summary);if(s?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let a=typeof s?.status=="string"?s.status:void 0;return a==="warn"||a==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function M(e){let s=l(e.summary),t=typeof s?.verdict=="string"?s.verdict:void 0;return t==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:t==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:t==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function D(e,s){let t=s.id.endsWith(".build")?"build":s.id.endsWith(".test")?"test":null,a=c$2(e,t);if(!a)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let n=a.stage;if(t&&n!==t)return {status:"missing",message:`Workspace run evidence is for stage "${n}", expected "${t}".`};let i=l(a.summary),o=typeof i?.failed=="number"?i.failed:0,m=typeof i?.exitCode=="number"?i.exitCode:0,d=Array.isArray(a.projects)?a.projects:[],p=s.project?.toLowerCase(),r=d.find(g=>{let u=l(g);if(!u||!p)return false;let E=typeof u.projectName=="string"?u.projectName.toLowerCase():"",w=typeof u.projectPath=="string"?u.projectPath.toLowerCase():"";return E===p||w.endsWith(`/${p}`)||w===p});if(r){let g=l(r),u=typeof g?.status=="string"?g.status:"unknown";if(u==="failed")return {status:"fail",message:`Workspace run evidence failed for ${s.project}.`};if(u==="passed")return {status:"pass",message:`Workspace run evidence passed for ${s.project}.`};if(u==="skipped")return {status:"warn",message:`Workspace run evidence skipped for ${s.project}.`}}return o>0||m!==0?{status:"fail",message:"Workspace run evidence reports failures."}:{status:"pass",message:"Workspace run evidence is present."}}async function q(e,s,t){let a=A(e,s),n=a?c.relative(s,a).split(c.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!t)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:n,message:n?`Missing evidence report: ${n}`:"No evidence mapping exists for this command."};let i=l(await f.readJson(a));if(!i)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:n,message:"Evidence report is not a JSON object."};let o;return e.id==="workspace.doctor"?o=x(i):e.id==="workspace.readiness"?o=O(i):e.id==="workspace.contract.verify"?o=$(i):e.id==="workspace.analyze"?o=_(i):e.id==="workspace.pipeline"?o=M(i):e.id.startsWith("project.")?o=D(i,e):o={status:"pass",message:"Evidence report is present."},{id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:o.status,required:e.required,evidencePath:n,message:o.message}}function F(e){let s=e.filter(r=>r.status==="pass").length,t=e.filter(r=>r.status==="warn").length,a=e.filter(r=>r.status==="fail").length,n=e.filter(r=>r.status==="missing").length,i=e.filter(r=>r.status==="skipped").length,o=e.filter(r=>r.required&&(r.status==="fail"||r.status==="missing")).map(r=>`${r.id}: ${r.message}`),m=e.filter(r=>r.required&&r.status==="missing").length,d="ready",p=0;return o.length>0?(d="blocked",p=2):(t>0||m>0)&&(d="needs-attention",p=1),{verdict:d,exitCode:p,stepsPassed:s,stepsWarn:t,stepsFailed:a,stepsMissing:n,stepsSkipped:i}}async function N(e$1){let s=c.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let i=C(s,e$1.fromImpactPath);return {impact:await j(i),fromImpactRef:c.relative(s,i).split(c.sep).join("/")}}let t=c.join(s,f$1);if(await f.pathExists(t))return {impact:await j(t),fromImpactRef:f$1};let a=c.join(s,c$1);if(await f.pathExists(a))return {impact:await n({workspacePath:s,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 n$1=await d({workspacePath:s,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:n$1.workspace.name,profile:n$1.workspace.profile,type:n$1.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:n$1}}}}async function Y(e){let s=c.resolve(e.workspacePath),{impact:t,fromImpactRef:a}=await N(e),n=t.diff.currentModel,i=I([...m(),...t.verificationPlan]).filter(r=>V(e.scope,r)),o=[];for(let r of i)o.push(await q(r,s,n.contracts.exists===true));let m$1=F(o),d=o.filter(r=>r.status==="missing"&&r.evidencePath).map(r=>r.evidencePath),p=o.filter(r=>r.required&&(r.status==="fail"||r.status==="missing")).map(r=>`${r.id}: ${r.message}`);return {schemaVersion:R,generatedAt:(e.now??new Date).toISOString(),workspacePath:s,mode:"evidence",fromImpactRef:a,scope:e.scope,impact:{changed:t.summary.changed,risk:t.summary.risk,affectedProjects:t.summary.affectedProjects,recommendedCommands:t.summary.recommendedCommands},summary:m$1,steps:o,missingEvidence:d,blockingReasons:p,verificationPlan:i}}async function U(e,s){let t=c.join(s,S);return await f.ensureDir(c.dirname(t)),await f.writeJson(t,e,{spaces:2}),t}function G(e,s){return e.summary.verdict==="blocked"?2:s?.strict&&e.summary.verdict!=="ready"?1:e.summary.exitCode}export{S as WORKSPACE_VERIFY_REPORT_PATH,R as WORKSPACE_VERIFY_SCHEMA_VERSION,Y as buildWorkspaceVerify,G as workspaceVerifyExitCode,U as writeWorkspaceVerify};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.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": [
|
|
@@ -111,6 +111,7 @@
|
|
|
111
111
|
"release:major": "bash scripts/release.sh major"
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
|
+
"@clack/prompts": "^0.9.1",
|
|
114
115
|
"chalk": "^5.3.0",
|
|
115
116
|
"cli-progress": "^3.12.0",
|
|
116
117
|
"commander": "^12.1.0",
|
package/dist/analyze-IIPDLLM2.js
DELETED
|
@@ -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';
|
package/dist/chunk-5LLGW5TP.js
DELETED
|
@@ -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};
|
package/dist/chunk-B7NCBH5B.js
DELETED
|
@@ -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};
|
package/dist/chunk-DKVWFHZO.js
DELETED
|
@@ -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};
|
package/dist/chunk-IATULVMR.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-VM2TOHNX.js';import {promises}from'fs';import a from'path';import I from'os';import {pathToFileURL}from'url';var K=".rapidkitrc.json",k=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function $(){let e=a.join(I.homedir(),K);try{let t=await promises.readFile(e,"utf-8"),n=JSON.parse(t);return a$1.debug(`Loaded config from ${e}`),n}catch{return a$1.debug("No user config found, using defaults"),{}}}async function O(e=process.cwd()){let t=e,n=a.parse(t).root;for(;t!==n;){for(let s of k){let i=a.join(t,s);try{await promises.access(i),a$1.debug(`Found config file: ${i}`);let c=await import(pathToFileURL(i).href),x=c.default||c;return a$1.debug(`Loaded RapidKit config from ${s}`),x}catch{continue}}t=a.dirname(t);}return a$1.debug("No RapidKit config file found, using defaults"),{}}function N(e,t,n){return {author:n.author||t.workspace?.defaultAuthor||e.author,pythonVersion:n.pythonVersion||t.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:n.defaultInstallMethod||t.workspace?.installMethod||e.defaultInstallMethod,defaultKit:n.defaultKit||t.projects?.defaultKit||e.defaultKit,skipGit:n.skipGit??t.projects?.skipGit??e.skipGit,license:n.license||e.license,testRapidKitPath:n.testRapidKitPath||e.testRapidKitPath}}function v(e){return process.env.RAPIDKIT_DEV_PATH||e.testRapidKitPath||void 0}var o=class extends Error{constructor(n,s,i){super(n);this.code=s;this.details=i;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}code;details},p=class extends o{constructor(t,n){let s=n?`Python ${t}+ required, found ${n}`:`Python ${t}+ not found`;super(s,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},d=class extends o{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},f=class extends o{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},u=class extends o{constructor(t){super(`Directory "${t}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},g=class extends o{constructor(t,n){super(`Invalid project name: "${t}"`,"INVALID_PROJECT_NAME",n);}},h=class extends o{constructor(t,n){let s=`Installation failed at: ${t}`,i=`${n.message}
|
|
2
|
-
|
|
3
|
-
Troubleshooting:
|
|
4
|
-
- Check your internet connection
|
|
5
|
-
- Verify Python/Poetry installation
|
|
6
|
-
- Try running with --debug flag for more details`;super(s,"INSTALLATION_ERROR",i);}},m=class extends o{constructor(){super("RapidKit Python package is not yet available on PyPI","RAPIDKIT_NOT_AVAILABLE",`Available options:
|
|
7
|
-
1. Install Python 3.10+ and retry the same command
|
|
8
|
-
2. Use the core workflow: npx rapidkit create workspace <name>
|
|
9
|
-
3. Offline fallback (limited): npx rapidkit create project fastapi.standard <name> --output .
|
|
10
|
-
|
|
11
|
-
Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};export{$ as a,O as b,N as c,v as d,o as e,p as f,d as g,f as h,u as i,g as j,h as k,m as l};
|
package/dist/chunk-KDUAZXEQ.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import {n,q as q$1,g}from'./chunk-YBS2HGO3.js';import {h,i,f,e}from'./chunk-UZW5QFRW.js';import {a}from'./chunk-VKLL63TL.js';import T from'fs';import w from'path';import S from'chalk';import {execa}from'execa';function ue(e){return T.existsSync(w.join(e,"bun.lock"))||T.existsSync(w.join(e,"bunfig.toml"))?"bun":T.existsSync(w.join(e,"pnpm-lock.yaml"))?"pnpm":T.existsSync(w.join(e,"yarn.lock"))?"yarn":(T.existsSync(w.join(e,"package-lock.json")),"npm")}function de(e,t,r=ue(e)){return r==="npm"?`npm run ${t}`:`${r} run ${t}`}function le(e,t=ue(e)){return `${t} install`}var Ee={"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:[]}}},Ce={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 pe(e$1,t,r){if(t){let o=t.trim().toLowerCase().replace(/[_.\s]+/g,"-"),a=e(t),f=`${e$1}-${a==="gofiber"?"fiber":a==="gogin"?"gin":a==="dotnet"?"aspnetcore":a!=="unknown"?a:o==="fiber"?"fiber":o==="aspnetcore"||o==="asp-net-core"?"aspnetcore":o}`,g=Ee[f];if(g&&g.commands[r])return g.commands[r]}let n=Ce[r]?.[e$1]??[];return n.length>0?n[0]:void 0}var Pe={test:"test",build:"build",start:"start"};function H(e){if(e.stage==="init")return e.runtime==="node"?le(e.projectPath):pe(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let t=Pe[e.stage];if(t){let r=g(e.projectPath,t,{framework:e.framework});if(r)return de(e.projectPath,r.scriptName)}}return pe(e.runtime,e.framework,e.stage)}function Fe(e){let t=h(e).map(r=>r==="python"?"python":r==="node"||r==="bun"?"node":r==="go"?"go":r==="java"?"java":r==="php"?"php":r==="rust"?"rust":r==="dotnet"?"dotnet":r==="elixir"?"elixir":r==="ruby"?"ruby":r==="clojure"||r==="scala"||r==="kotlin"?"jvm-generic":null).filter(r=>r!==null).filter((r,n,o)=>o.indexOf(r)===n);return {primary:t.length>0?t[0]:"unknown",secondary:t.slice(1)}}function me(e){return Fe(e).primary}function ge(e,t){if(!e)return "unknown";t||(t={setup:["ModuleNotFoundError","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[r,n]of Object.entries(t))for(let o of n)if(new RegExp(o,"i").test(e))return r;return "unknown"}async function z(e){let t=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(t))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[t],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${t}' not found or not executable`}}function fe(e,t,r){if(!t)return e;let n=typeof t=="object"&&!Array.isArray(t)&&("dev"in t||"staging"in t||"prod"in t||"default"in t)&&!Object.keys(t).some(o=>["init","test","build","start"].includes(o))?t:{};return r&&typeof n[r]=="string"?n[r]:typeof n.default=="string"?n.default:e}var ye={init:"init",test:"test",build:"build",start:"start"};function Ae(e){return e in ye?ye[e]:null}function he(e,t,r=q$1(e)){let n=Ae(t);if(!n)return {supported:false,reason:`Workspace stage "${t}" is not part of the RapidKit fleet contract.`};if(!r.projectRoot)return {supported:false,reason:"No RapidKit project metadata was detected for this target."};let o=r.commandMap[n];return !o||o.status!=="supported"?{supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`}:{supported:true}}var $e=new Set(["init","test","build","start"]),Ne=new Set([".git","node_modules",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function W(e){try{return await T.promises.access(e,T.constants.F_OK),true}catch{return false}}async function q(e){let t=await T.promises.readFile(e,"utf-8");return JSON.parse(t)}async function De(e,t){await T.promises.mkdir(w.dirname(e),{recursive:true}),await T.promises.writeFile(e,`${JSON.stringify(t,null,2)}
|
|
2
|
-
`,"utf-8");}function A(e){return e.replace(/\\/g,"/")}function Ie(e){let t=e?.trim();return t?t.startsWith("project:")?t.slice(8).trim()||null:t:null}async function Te(e){return a(e,{skipDirs:Ne,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(t,r)=>await W(w.join(t,".rapidkit","context.json"))||await W(w.join(t,".rapidkit","project.json"))?true:w.resolve(t)===w.resolve(r)?false:h(t).length>0})}async function We(e){for(let t of [w.join(".rapidkit","project.json"),w.join(".rapidkit","context.json")]){let r=w.join(e,t);if(await W(r))try{let n=await q(r),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function Me(e,t,r){let n=Ie(r);if(!n)return {projects:t,normalizedScope:null};let o=A(n).toLowerCase(),a=[];for(let d of t){let f=A(w.relative(e,d)),g=w.basename(d),p=await We(d);[f,g,p].filter(i=>typeof i=="string"&&i.length>0).map(i=>A(i).toLowerCase()).includes(o)&&a.push(d);}if(a.length===0)throw new Error(`Workspace run scope did not match any project: ${r}`);return {projects:a,normalizedScope:n}}async function Oe(e,t,r){let n=await execa("git",["diff","--name-only",`${r}...HEAD`],{cwd:e,reject:false});if(n.exitCode!==0)return new Set(t);let o=n.stdout.split(/\r?\n/).map(d=>d.trim()).filter(d=>d.length>0).map(d=>A(d));if(o.length===0)return new Set;let a=new Set;for(let d of t){let f=A(w.relative(e,d));if(!f||f===".")continue;let g=`${f}/`;o.some(p=>p===f||p.startsWith(g))&&a.add(d);}return a}async function Le(e,t,r){let n=w.join(e,".rapidkit","workspace.contract.json");if(await W(n))try{let s=await Ge(e,t,r,n);if(s.graphStatus!=="missing")return s}catch{return {expanded:r,graphStatus:"invalid",expansionDepth:0}}let o=w.join(e,".rapidkit","workspace-dependency-graph.json");if(!await W(o))return {expanded:r,graphStatus:"missing",expansionDepth:0};let a;try{a=await q(o);}catch{return {expanded:r,graphStatus:"invalid",expansionDepth:0}}let d=new Set(t.map(s=>w.resolve(s))),f=new Map;if(!a||typeof a!="object"||Array.isArray(a))return {expanded:r,graphStatus:"invalid",expansionDepth:0};let g=Array.isArray(a.projects)?a.projects:[];for(let s of g){if(!s||typeof s!="object"||Array.isArray(s))continue;let x=s,j=typeof x.path=="string"?x.path:"",y=w.resolve(e,j);if(!d.has(y))continue;let c=Array.isArray(x.dependsOn)?x.dependsOn.filter(l=>typeof l=="string"):[];for(let l of c){let v=w.resolve(e,l);d.has(v)&&(f.has(v)||f.set(v,new Set),f.get(v)?.add(y));}}let p=new Set(r),b=[...p],i=0;for(;b.length>0;){let s=b.shift();if(!s)continue;let x=f.get(s);if(x)for(let j of x)p.has(j)||(p.add(j),b.push(j),i+=1);}return {expanded:p,graphStatus:"loaded",expansionDepth:i}}async function Ge(e,t,r,n){let o=await q(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:r,graphStatus:"invalid",expansionDepth:0};let a=o,d=Array.isArray(a.projects)?a.projects:null;if(!d)return {expanded:r,graphStatus:"invalid",expansionDepth:0};let f=new Map,g=new Map;for(let y of t){let c=A(w.relative(e,y));g.set(c,w.resolve(y));}let p=new Map,b=new Map,i=new Map;for(let y of d){if(!y||typeof y!="object"||Array.isArray(y))continue;let c=y,l=typeof c.slug=="string"?c.slug:"",v=typeof c.relativePath=="string"?A(c.relativePath):l,R=g.get(v);!l||!R||f.set(l,R);}for(let y of d){if(!y||typeof y!="object"||Array.isArray(y))continue;let c=y,l=typeof c.slug=="string"?c.slug:"",v=f.get(l);if(!v)continue;let R=c.contracts&&typeof c.contracts=="object"&&!Array.isArray(c.contracts)?c.contracts:{},M=Array.isArray(R.dependsOn)?R.dependsOn.filter(h=>typeof h=="string"):[],$=Array.isArray(R.publishes)?R.publishes.filter(h=>typeof h=="string"):[],N=Array.isArray(R.consumes)?R.consumes.filter(h=>typeof h=="string"):[];for(let h of M){let C=f.get(h);C&&(i.has(C)||i.set(C,new Set),i.get(C)?.add(v));}for(let h of $)p.has(h)||p.set(h,new Set),p.get(h)?.add(v);for(let h of N)b.has(h)||b.set(h,new Set),b.get(h)?.add(v);}for(let[y,c]of p.entries()){let l=b.get(y);if(l)for(let v of c){i.has(v)||i.set(v,new Set);for(let R of l)R!==v&&i.get(v)?.add(R);}}let s=new Set(r),x=[...s],j=0;for(;x.length>0;){let y=x.shift();if(!y)continue;let c=i.get(y);if(c)for(let l of c)s.has(l)||(s.add(l),x.push(l),j+=1);}return {expanded:s,graphStatus:"loaded",expansionDepth:j}}async function _e(e,t){if(typeof t=="boolean")return t;let r=w.join(e,".rapidkit","policies.yml");if(!await W(r))return true;let n="";try{n=await T.promises.readFile(r,"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}async function J(e,t){let r=process.argv[1];if(!r)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};let n=await execa(process.execPath,[r,...e],{cwd:t,reject:false,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(n.exitCode??1),stdout:n.stdout,stderr:n.stderr}}function Be(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"}function Ve(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function Ke(e){let t=process.cwd();try{process.chdir(e);let{handleInitCommand:r}=await import('./index.js');return {exitCode:await r(["init"]),stdout:"",stderr:""}}finally{process.chdir(t);}}async function He(e$1){let t=i=>{let s=f(i);return s==="node"||s==="bun"?"node":s==="python"?"python":s==="go"?"go":s==="java"?"java":s==="php"?"php":s==="ruby"?"ruby":s==="rust"?"rust":s==="dotnet"?"dotnet":s==="elixir"?"elixir":s==="clojure"||s==="scala"||s==="kotlin"?"jvm-generic":me(e$1)},r=i=>{if(!i)return;let s=e(i);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(s))return s},n$1=n(e$1),o=n$1?.detection??i(e$1,n$1?.projectJson??null),a=n$1?.contextJson,d=t(o.runtime),f$1=r(o.key),g={},p=new Set(["init","test","build","start"]);if(a?.commands&&typeof a.commands=="object")for(let[i,s]of Object.entries(a.commands))typeof s=="string"&&p.has(i)&&(g[i]=s);let b;if(a?.commandEnvironments&&typeof a.commandEnvironments=="object"){let i=a.commandEnvironments;b={dev:typeof i.dev=="string"?i.dev:void 0,staging:typeof i.staging=="string"?i.staging:void 0,prod:typeof i.prod=="string"?i.prod:void 0,default:typeof i.default=="string"?i.default:void 0};}return {runtime:d,framework:f$1,commandOverrides:Object.keys(g).length>0?g:void 0,environmentCommandVariants:b,environment:typeof a?.environment=="string"?a.environment:void 0}}async function ze(e,t,r,n,o,a,d){let f=!o?.[t]&&Be(r),g;if(o&&o[t]?g=o[t]:f?g=`rapidkit ${t}`:g=H({projectPath:e,runtime:r,framework:n,stage:t}),!g)return {exitCode:127,command:`<stage not supported for ${r}>`,message:`No stage command found for runtime '${r}' and framework '${n||"unknown"}'`,errorCategory:"runtime"};let p=fe(g,a,d);if(!p)return {exitCode:127,command:g,message:"Failed to resolve stage command",errorCategory:"runtime"};let b=H({projectPath:e,runtime:r,framework:n,stage:t});if(f){if(b){let c=await z(b);if(!c.valid)return {exitCode:127,command:p,message:c.reason||"Command not available",errorCategory:"setup"}}}else {let c=await z(p);if(!c.valid)return {exitCode:127,command:p,message:c.reason||"Command not available",errorCategory:"setup"}}let i=0,s="",x="",j;try{let c=f?t==="init"&&Ve()?await Ke(e):await J([t],e):await execa(p,[],{cwd:e,reject:false,shell:true});if(i=Number(c.exitCode??0),s=c.stdout,x=c.stderr,i!==0){let l=`${s}
|
|
3
|
-
${x}`;j=ge(l);}}catch(c){return {exitCode:1,command:p,message:c instanceof Error?c.message:"Command execution failed",errorCategory:"runtime"}}return {exitCode:i,command:p,errorCategory:j,healthStatus:void 0,message:i!==0?`Stage failed with exit code ${i}`:void 0}}function ke(e){try{return JSON.parse(e)}catch{return null}}function Je(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx rapidkit setup dotnet` or `npx rapidkit init`.";case "go":return "Install Go 1.21+, then rerun `npx rapidkit setup go` or `npx rapidkit init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx rapidkit setup java` or `npx rapidkit init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx rapidkit setup node` or `npx rapidkit init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx rapidkit setup python` or `npx rapidkit init`.";default:return null}}async function Ue(e){let t=[],r=await J(["doctor","workspace","--json"],e);if(r.exitCode!==0)t.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let a=ke(r.stdout)?.healthScore,d=Number(a?.errors??0);Number.isFinite(d)&&d>0?t.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${d} error(s)`}):t.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let n=await J(["readiness","--json"],e);if(n.exitCode!==0)t.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let o=ke(n.stdout),a=String(o?.overallStatus??"").toLowerCase();a==="fail"?t.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):a==="warn"?t.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):t.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return t}function qe(e){return $e.has(e)}function Ye(e,t){let r=Math.max(1,Math.min(4,t)),n=Number(e??r);return Number.isFinite(n)?Math.max(1,Math.min(16,Math.trunc(n))):r}async function Rt(e){if(!qe(e.stage))throw new Error(`Unsupported workspace run stage: ${e.stage}`);let t=Date.now(),r=w.resolve(e.workspacePath),n=await Te(r),{projects:o,normalizedScope:a}=await Me(r,n,e.scope),d=e.affected===true,f=e.blastRadius===true,g=e.since?.trim()||"HEAD~1",p=d?await Oe(r,o,g):new Set(o),b,i="not-applicable",s=0,x="all";if(d&&f){let m=await Le(r,n,p);b=m.expanded,i=m.graphStatus,s=m.expansionDepth,x="affected+blast-radius";}else d?(b=p,x="affected"):(b=p,x="all");let j=e.stage==="init"?false:await _e(r,e.enforceGates),y=j?await Ue(r):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],c=y.find(m=>m.status==="fail"),l=o.filter(m=>b.has(m)),v=e.continueOnError===true||e.stage==="init",R=e.parallel===true,M=Ye(e.maxWorkers,l.length),$=l.length,N=0;e.json||console.log(S.gray(`Workspace run (${e.stage}) started: ${$} target(s), ${R?`parallel x${M}`:"sequential"}`));let h=new Map;for(let m of n){let k=o.includes(m),u=k&&b.has(m);h.set(m,{path:m,relativePath:A(w.relative(r,m)),selected:u,affected:u,status:"skipped",exitCode:null,durationMs:0,reason:u?void 0:k?"not affected":"outside scope",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});}if(c)for(let m of l){let k=h.get(m);k&&(k.status="skipped",k.reason=`blocked by ${c.gate}`);}else {let m=async k=>{let u=h.get(k);if(!u)return;let I=A(w.relative(r,k));e.json||console.log(S.gray(`\u23F3 [${N}/${$}] ${e.stage} ${I}`)),u.selected=true,u.affected=true;let P=Date.now(),{runtime:E,framework:F,commandOverrides:be,environmentCommandVariants:xe,environment:ve}=await He(k);u.runtimeDetected=E,u.framework=F;let te=he(k,e.stage);if(!te.supported){u.status="skipped",u.reason=te.reason??`stage "${e.stage}" unsupported for project`,u.durationMs=Date.now()-P,u.exitCode=null,N+=1;return}let D=await ze(k,e.stage,E,F,be,xe,ve);if(u.executionCommand=D.command,u.errorCategory=D.errorCategory,u.healthStatus=D.healthStatus,u.durationMs=Date.now()-P,u.exitCode=D.exitCode,D.exitCode===0?(u.status="passed",u.reason=void 0):(u.status="failed",u.reason=D.message||"stage command failed",u.errorMessage=D.message),N+=1,!e.json){let Re=$>0?Math.round(N/$*100):100,je=u.status==="passed"?S.green("\u2705"):S.red("\u274C");if(console.log(S.gray(`${je} [${N}/${$}] (${Re}%) ${I} ${u.durationMs}ms`)),u.status==="failed"){u.reason&&console.log(S.red(` Reason: ${u.reason}`)),u.executionCommand&&console.log(S.gray(` Command: ${u.executionCommand}`));let re=Je(u.runtimeDetected);re&&u.errorCategory==="setup"&&console.log(S.gray(` Hint: ${re}`));}}};if(R&&l.length>1){let k=0,u=false,I=new Array(M).fill(null).map(async()=>{for(;k<l.length;){if(u&&!v)return;let P=k;k+=1;let E=l[P];await m(E),h.get(E)?.status==="failed"&&(u=true);}});if(await Promise.all(I),!v&&u){let P=false;for(let E of l){let F=h.get(E);if(F){if(F.status==="failed"){P=true;continue}P&&F.status==="skipped"&&(F.reason=F.reason||"stopped after failure");}}}}else for(let k of l){await m(k);let u=h.get(k);if(!v&&u?.status==="failed"){let I=l.slice(l.indexOf(k)+1);for(let P of I){let E=h.get(P);E&&(E.status="skipped",E.reason="stopped after failure");}break}}}let C=[];for(let m of n){let k=h.get(m);k&&C.push(k);}let Y=C.filter(m=>m.status==="passed").length,B=C.filter(m=>m.status==="failed").length,Q=C.filter(m=>m.status==="skipped").length,X=e.strict===true,we=B>0||X&&y.some(m=>m.status!=="pass")?1:0,Z={schemaVersion:"1.0",workspacePath:r,stage:e.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-t,options:{affected:d,blastRadius:f,since:d?g:null,parallel:R,maxWorkers:M,continueOnError:v,strict:X,enforceGates:j,scope:a},selection:{mode:x,since:d?g:null,scope:a,graphStatus:i,expansionDepth:s},gates:{enforced:j,results:y,blocked:!!c,blockingGate:c?.gate},summary:{projectCount:n.length,selectedCount:l.length,passed:Y,failed:B,skipped:Q,exitCode:we},projects:C},ee=w.join(r,".rapidkit","reports","workspace-run-last.json");return await De(ee,Z),e.json||(c&&(console.log(S.red(`\u274C Workspace run blocked by ${c.gate}`)),console.log(S.gray(` ${c.summary}`))),console.log(S.cyan(`Workspace run (${e.stage}) => passed: ${Y}, failed: ${B}, skipped: ${Q}`)),console.log(S.gray(`Report: ${ee}`))),Z}export{Rt as a};
|
package/dist/chunk-MCLLP6MW.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-HHJAANUC.js';import {l}from'./chunk-OCGZNSOE.js';import c from'path';import h from'fs-extra';var j=".rapidkit/workspace.contract.json",P=1;function W(e){return e.replace(/\\/g,"/")}function y(e){let r=W(e).trim();return !r||r.startsWith("/")||r.startsWith("~")||/^[a-zA-Z]:\//.test(r)||r.includes("\0")?false:!r.split("/").filter(Boolean).some(o=>o===".."||o===".")}function S(e,r){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||r}function E(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}async function R(e){let r=c.join(e,".rapidkit","workspace.json");try{let o=await h.readJson(r);return {name:typeof o.workspace_name=="string"&&o.workspace_name.trim()||typeof o.name=="string"&&o.name.trim()||c.basename(e),profile:typeof o.profile=="string"?o.profile:void 0}}catch{return {name:c.basename(e)}}}async function O(e){let r=[],o=[e],n=new Set,i=new Set([".git","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;o.length>0;){let a=o.shift();if(!a||n.has(a))continue;n.add(a);let p=c.join(a,".rapidkit","project.json"),l=c.join(a,".rapidkit","context.json");if(await h.pathExists(p)||await h.pathExists(l)){r.push(await h.pathExists(p)?p:l);continue}let t;try{t=await h.readdir(a,{withFileTypes:true});}catch{continue}for(let s of t)!s.isDirectory()||i.has(s.name)||o.push(c.join(a,s.name));}return r.sort()}function J(e){let r=(e||"").toLowerCase();if(r.includes("fastapi"))return "fastapi";if(r.includes("nestjs"))return "nestjs";if(r.includes("springboot"))return "springboot";if(r.includes("gofiber"))return "fiber";if(r.includes("gogin"))return "gin"}function _(e,r){let o=(e||"").toLowerCase(),n=(r||"").toLowerCase();return o.includes("fastapi")?8e3:o.includes("nestjs")?3e3:o.includes("springboot")?8080:o.includes("gofiber")?3e3:o.includes("gogin")?8080:n==="node"?3e3:n==="python"?8e3:n==="java"||n==="go"?8080:null}function N(e,r){let o=e;for(;r.has(o)&&o<65535;)o+=1;return o}function w(e,r,o){let n=_(r.kit,r.runtime),i=e?.ports||[],a=i.length>0?i:n?[{name:"http",port:N(n,o),protocol:"http"}]:[];for(let t of a)o.add(t.port);let p={...r,...e,slug:e?.slug||r.slug,relativePath:e?.relativePath&&y(e.relativePath)?e.relativePath:r.relativePath,source:e?.source||r.source,relationship:e?.relationship||r.relationship,externalPath:e?.externalPath||r.externalPath,runtime:e?.runtime||r.runtime,framework:e?.framework||r.framework,kit:e?.kit||r.kit,modules:e?.modules?.length?e.modules:r.modules,ports:a,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:e?.contracts?.env||[]}},l=JSON.stringify(e||null)!==JSON.stringify(p);return {project:p,changed:l}}async function A(e){let r=c.resolve(e.workspacePath),o=await R(r),n=await O(r),i=await a(r),a$1=[];for(let t of i){let s=c.resolve(t.path),d=c.join(s,".rapidkit","project.json"),f=c.join(s,".rapidkit","context.json"),u=await h.pathExists(d)?d:await h.pathExists(f)?f:null;!u||n.some(g=>c.resolve(g)===c.resolve(u))||a$1.push({projectJsonPath:u,registryEntry:t});}let p=[],l=[...n.map(t=>({projectJsonPath:t})),...a$1];for(let{projectJsonPath:t,registryEntry:s}of l){let d=c.dirname(c.dirname(t)),f=W(c.relative(r,d)),u=s!==void 0&&!y(f),g=S(s?.name||c.basename(d),c.basename(d)),k=u?`external/${g}`:f||g,m=await h.readJson(t),C=typeof m.kit_name=="string"&&m.kit_name||typeof m.kit=="string"&&m.kit||void 0,$=typeof m.framework=="string"&&m.framework||J(C);p.push({slug:s?.name||k||c.basename(d),relativePath:k,source:s?.source??"workspace",relationship:s?.relationship,externalPath:u?d:void 0,runtime:typeof m.runtime=="string"?m.runtime:void 0,framework:$,kit:C,modules:E(m.modules),ports:[],contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}return {schemaVersion:P,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:o,projects:p}}async function F(e){let r=c.resolve(e.outputPath||c.join(e.workspacePath,j));if(await h.pathExists(r)&&e.force!==true)throw new Error(`Workspace contract already exists: ${r}. Use --force to overwrite.`);let o=await A({workspacePath:e.workspacePath,now:e.now}),n=new Set,i={...o,projects:o.projects.map(a=>w(void 0,a,n).project)};return await h.ensureDir(c.dirname(r)),await h.writeJson(r,i,{spaces:2}),{contractPath:r,contract:i}}async function K(e){let r=c.resolve(e.workspacePath),o=c.join(r,j),n=await A({workspacePath:r,now:e.now}),i=await h.pathExists(o)?await h.readJson(o):null,a=new Map((i?.projects||[]).map(u=>[u.slug,u])),p=new Set,l=[],t=[],s=[];for(let u of n.projects){let g=a.get(u.slug),k=w(g,u,p);g?k.changed&&t.push(u.slug):l.push(u.slug),s.push(k.project),a.delete(u.slug);}for(let u of a.values()){let g=w(u,u,p);s.push(g.project);}let d={schemaVersion:P,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...n.workspace,...i?.workspace||{},name:i?.workspace?.name||n.workspace.name},projects:s.sort((u,g)=>u.slug.localeCompare(g.slug))};await h.ensureDir(c.dirname(o)),await h.writeJson(o,d,{spaces:2});let f=await V({workspacePath:r});return {contractPath:o,contract:d,addedProjects:l,updatedProjects:t,verification:f}}async function x(e){let r=c.resolve(e.contractPath||c.join(e.workspacePath,j)),o=await h.readJson(r);return {contractPath:r,contract:o}}async function L(e){let{contractPath:r,contract:o}=await x(e),n=o.projects.map(t=>({id:t.slug,label:t.slug,relativePath:t.relativePath,source:t.source,relationship:t.relationship,externalPath:t.externalPath,runtime:t.runtime,framework:t.framework,kit:t.kit,modules:t.modules,ports:t.ports,apis:t.contracts.apis,owns:t.contracts.owns,env:t.contracts.env})),i=new Set(n.map(t=>t.id)),a=new Map,p=[];for(let t of o.projects){for(let s of t.contracts.dependsOn||[])i.has(s)&&p.push({from:s,to:t.slug,type:"dependency",label:"dependsOn"});for(let s of t.contracts.publishes||[])a.has(s)||a.set(s,new Set),a.get(s)?.add(t.slug);}for(let t of o.projects)for(let s of t.contracts.consumes||[]){let d=a.get(s);if(d)for(let f of d)f!==t.slug&&p.push({from:f,to:t.slug,type:"event",label:s});}let l={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:o.workspace,generatedAt:new Date().toISOString(),nodes:n.sort((t,s)=>t.id.localeCompare(s.id)),edges:p.sort((t,s)=>`${t.from}:${t.to}:${t.type}:${t.label}`.localeCompare(`${s.from}:${s.to}:${s.type}:${s.label}`)),summary:{projectCount:n.length,dependencyEdges:p.filter(t=>t.type==="dependency").length,eventEdges:p.filter(t=>t.type==="event").length,portCount:n.reduce((t,s)=>t+s.ports.length,0),apiCount:n.reduce((t,s)=>t+s.apis.length,0)}};return {contractPath:r,graph:l}}async function V(e){let{contractPath:r,contract:o}=await x(e),n=[],i=[];o.kind!=="rapidkit.workspace.contract"&&n.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==P&&n.push(`Contract schemaVersion must be ${P}.`),o.workspace?.name||n.push("Contract workspace.name is required."),Array.isArray(o.projects)||n.push("Contract projects must be an array.");let a=new Set,p=new Map;for(let t of o.projects||[]){if(!t.slug){n.push("Every project must declare slug.");continue}a.has(t.slug)&&n.push(`Duplicate project slug: ${t.slug}.`),a.add(t.slug),t.relativePath?y(t.relativePath)||n.push(`Project ${t.slug} declares unsafe relativePath: ${t.relativePath}.`):n.push(`Project ${t.slug} must declare relativePath.`),t.externalPath&&(t.relationship==="adopted"||t.source==="adopted-local"||t.source==="local-folder"||t.source==="git-url"||n.push(`Project ${t.slug} declares externalPath without imported/adopted provenance.`),c.isAbsolute(t.externalPath)||n.push(`Project ${t.slug} declares non-absolute externalPath.`));for(let s of t.ports||[]){(!Number.isInteger(s.port)||s.port<1||s.port>65535)&&n.push(`Project ${t.slug} declares invalid port: ${s.port}.`);let d=p.get(s.port);d&&n.push(`Port ${s.port} is claimed by both ${d} and ${t.slug}.`),p.set(s.port,t.slug);}for(let s of t.contracts?.apis||[])(!s.name?.trim()||!s.basePath?.startsWith("/"))&&n.push(`Project ${t.slug} declares invalid API contract.`);for(let s of [...t.contracts?.publishes||[],...t.contracts?.consumes||[]])s.trim()||n.push(`Project ${t.slug} declares an empty event contract.`);for(let s of t.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(s)||n.push(`Project ${t.slug} declares invalid env contract: ${s}.`);for(let s of t.contracts?.dependsOn||[])a.has(s);}for(let t of o.projects||[])for(let s of t.contracts?.dependsOn||[])a.has(s)||n.push(`Project ${t.slug} depends on unknown project: ${s}.`);i.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===P?"passed":"failed",message:"Contract schema and kind are valid."}),i.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),i.push({id:"ports",status:n.some(t=>t.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:n.some(t=>t.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:n.some(t=>t.includes("unsafe relativePath")||t.includes("invalid API contract")||t.includes("event contract")||t.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let l$1=await l(e.workspacePath);if(l$1.moduleCount>0){for(let t of l$1.issues)n.push(`${c.basename(t.projectRoot)}: ${t.message} (slug=${t.slug})`);i.push({id:"module-paths",status:l$1.status,message:l$1.status==="passed"?`All ${l$1.moduleCount} registered module(s) resolve under canonical paths.`:`${l$1.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&i.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:n.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:i,violations:n}}
|
|
2
|
-
export{j as a,P as b,O as c,A as d,F as e,K as f,x as g,L as h,V as i};
|
package/dist/chunk-R4RPUW7I.js
DELETED
|
@@ -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};
|