rapidkit 0.36.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.
Files changed (65) hide show
  1. package/README.md +216 -24
  2. package/contracts/analyze-last-run.v1.json +106 -0
  3. package/contracts/cli-log-event.v1.json +51 -0
  4. package/contracts/doctor-project-evidence.v1.json +46 -0
  5. package/contracts/doctor-workspace-evidence.v1.json +57 -0
  6. package/contracts/release-readiness.v1.json +60 -0
  7. package/contracts/workspace-registry.v1.json +83 -0
  8. package/contracts/workspace-run-last.v1.json +112 -0
  9. package/dist/analyze-6RFG7C7Z.js +1 -0
  10. package/dist/autopilot-release-AUXP2ZIF.js +1 -0
  11. package/dist/chunk-6P5DCHBQ.js +4 -0
  12. package/dist/chunk-7VSYTOOG.js +7 -0
  13. package/dist/chunk-B2KOIORF.js +1 -0
  14. package/dist/{chunk-VPNHGQIV.js → chunk-C7OVQQXT.js} +1 -1
  15. package/dist/chunk-C7WILE56.js +1 -0
  16. package/dist/chunk-D23L2GFT.js +2 -0
  17. package/dist/{workspace-context-YFQQROOZ.js → chunk-EJGKBFV4.js} +2 -2
  18. package/dist/chunk-FV5A3N3I.js +2 -0
  19. package/dist/chunk-GDGATWR5.js +2 -0
  20. package/dist/chunk-HEG6DIGW.js +2 -0
  21. package/dist/chunk-IOIWVHRO.js +883 -0
  22. package/dist/chunk-JBDQADHY.js +50 -0
  23. package/dist/{chunk-AC6KIKII.js → chunk-PPQYTYQG.js} +4 -4
  24. package/dist/chunk-RELR4O5E.js +2 -0
  25. package/dist/{chunk-DC44JPI3.js → chunk-RUUDLAKJ.js} +12 -12
  26. package/dist/chunk-T5LN7EO5.js +9 -0
  27. package/dist/chunk-U6QUN6V2.js +2 -0
  28. package/dist/chunk-UXKB4KGZ.js +13 -0
  29. package/dist/{create-7R4CGABE.js → create-HN5HOGQ4.js} +1 -1
  30. package/dist/{demo-kit-KTRITRWH.js → demo-kit-3VTLJBP7.js} +1 -1
  31. package/dist/{doctor-DG3TBPZN.js → doctor-QC662YLH.js} +1 -1
  32. package/dist/{dotnet-webapi-clean-TPQMNFSD.js → dotnet-webapi-clean-FX533F5U.js} +1 -1
  33. package/dist/{gofiber-standard-NDCBY6OM.js → gofiber-standard-35CJZ7S3.js} +1 -1
  34. package/dist/{gogin-standard-WUOMIHDR.js → gogin-standard-SAX6C4ZK.js} +1 -1
  35. package/dist/index.js +214 -213
  36. package/dist/managed-agent-markers-AXUM75OE.js +8 -0
  37. package/dist/pipeline-BOU4KETN.js +5 -0
  38. package/dist/{springboot-standard-WQWB5E24.js → springboot-standard-SFMSLTX4.js} +1 -1
  39. package/dist/{workspace-ZDL5IQU4.js → workspace-2AL5C3QZ.js} +1 -1
  40. package/dist/workspace-agent-sync-V2H6NTGD.js +17 -0
  41. package/dist/workspace-context-KCKNV5VQ.js +1 -0
  42. package/dist/{workspace-contract-A6QP7FPA.js → workspace-contract-D5O4OZD5.js} +1 -1
  43. package/dist/workspace-foundation-L6ZBGMVE.js +1 -0
  44. package/dist/{workspace-intelligence-VLA2RILM.js → workspace-intelligence-3TWXJQ7Y.js} +1 -1
  45. package/dist/{workspace-model-OO4WOBJS.js → workspace-model-NQVZN5W4.js} +1 -1
  46. package/dist/workspace-registry-summary-MIPHVB56.js +1 -0
  47. package/dist/workspace-run-DEXI52KO.js +1 -0
  48. package/dist/workspace-verify-HBCQNNGU.js +1 -0
  49. package/package.json +2 -1
  50. package/dist/analyze-HXO6R656.js +0 -1
  51. package/dist/autopilot-release-FMQ5KND5.js +0 -1
  52. package/dist/chunk-45KNNNAB.js +0 -2
  53. package/dist/chunk-7ZSURMR2.js +0 -4
  54. package/dist/chunk-HUQ5WRUF.js +0 -883
  55. package/dist/chunk-IATULVMR.js +0 -11
  56. package/dist/chunk-KIB4KHBF.js +0 -3
  57. package/dist/chunk-MCLLP6MW.js +0 -2
  58. package/dist/chunk-TC2PSHT6.js +0 -50
  59. package/dist/chunk-UY4LZEXK.js +0 -7
  60. package/dist/chunk-VM2TOHNX.js +0 -2
  61. package/dist/chunk-Y2ZPG7KN.js +0 -9
  62. package/dist/pipeline-23AEXNF2.js +0 -5
  63. package/dist/workspace-foundation-QVWALXMP.js +0 -1
  64. package/dist/workspace-run-NIKH2IKF.js +0 -1
  65. package/dist/workspace-verify-XEXRCET7.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-AC6KIKII.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"?>
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-DC44JPI3.js';
1
+ export{e as createProject,d as createWorkspace,g as createWorkspaceShareBundle,f as listWorkspaces,c as registerProjectInWorkspace,a as registerWorkspace,b as syncWorkspaceProjects}from'./chunk-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-MCLLP6MW.js';
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-45KNNNAB.js';
1
+ export{f as WORKSPACE_IMPACT_REPORT_PATH,e as WORKSPACE_IMPACT_SCHEMA_VERSION,d as WORKSPACE_MODEL_DIFF_REPORT_PATH,b as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,c as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,a as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,n as buildWorkspaceImpact,i as buildWorkspaceModelSnapshot,k as diffWorkspaceModel,g as isGitDiffSource,h as parseGitDiffRef,m as workspaceVerificationPlan,o as writeWorkspaceImpact,l as writeWorkspaceModelDiff,j as writeWorkspaceModelSnapshot}from'./chunk-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-VPNHGQIV.js';
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.36.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",
@@ -1 +0,0 @@
1
- export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-Y2ZPG7KN.js';
@@ -1 +0,0 @@
1
- export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-UY4LZEXK.js';
@@ -1,2 +0,0 @@
1
- import {d,b,a}from'./chunk-VPNHGQIV.js';import U from'crypto';import f from'path';import w 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 J(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 _(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=J(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 V="workspace-model-snapshot.v1",G="workspace-model-diff.v1",E=".rapidkit/reports/workspace-model-snapshot.json",N=".rapidkit/reports/workspace-model-diff-last-run.json",Q="workspace-impact.v1",X=".rapidkit/reports/workspace-impact-last-run.json";function B(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function Y(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function F(e){if(Array.isArray(e))return e.map(t=>F(t));if(e&&typeof e=="object"){let t={};for(let r of Object.keys(e).sort())t[r]=F(e[r]);return t}return e}function u(e){return JSON.stringify(F(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 U.createHash("sha256").update(u(t)).digest("hex")}function L(e,t){return f.isAbsolute(t)?t:f.join(e,t)}async function Z(e){let t=await w.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===V){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 ee(e){let t=await w.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!==G)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 Pe(e){let t=e.model??await d({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:V,generatedAt:(e.now??new Date).toISOString(),modelHash:S(t),modelRef:b,model:t}}async function Me(e,t){let r=f.join(t,E);return await w.ensureDir(f.dirname(r)),await w.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 h(e,t){e.push(t);}function te(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)&&h(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)&&h(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)&&h(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)&&h(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)&&h(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&&h(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 re(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 oe(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){h(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 g=i.runtime!==s.runtime||i.framework!==s.framework;h(r,{type:"project.changed",severity:g?"warning":"info",target:n,message:`Project changed: ${s.name}`,before:p,after:d});}}for(let[n,s]of o.entries())c.has(n)||h(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 ne(e){let t=f.resolve(e.workspacePath),r=B(e.fromPath),o=r?Y(e.fromPath):void 0,c=e.fromPath;if(r){let m=f.join(t,E);if(!await w.pathExists(m))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=E;}let n=L(t,c),s=await Z(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=[...te(s.model,i),...oe(s.model,i),...re(s.model,i)],g;e.includeGitObservation!==false&&(g=e.gitObservation??_(t,{ref:o}),g.available&&ie(d$1,g,i));let y=d$1.filter(m=>m.type.startsWith("git.")).length,v=s.hash!==p,O=r?`git:${o??"HEAD"}`:f.relative(t,n).split(f.sep).join("/");return {schemaVersion:G,generatedAt:(e.now??new Date).toISOString(),fromRef:O,toRef:b,fromHash:s.hash,toHash:p,summary:{changed:v||y>0,addedProjects:d$1.filter(m=>m.type==="project.added").length,removedProjects:d$1.filter(m=>m.type==="project.removed").length,changedProjects:d$1.filter(m=>m.type==="project.changed").length,workspaceChanges:d$1.filter(m=>m.type==="workspace.changed").length,validationChanges:d$1.filter(m=>m.type==="validation.changed").length,gitChangedFiles:y},git:g?.available?ce(g,o):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:d$1,currentModel:i}}async function je(e,t){let r=f.join(t,N);return await w.ensureDir(f.dirname(r)),await w.writeJson(r,e,{spaces:2}),r}function R(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function T(e){return e.reduce((t,r)=>R(r)>R(t)?r:t,"none")}function H(e){return e.join(" ")}function W(e,t,r,o){return {id:e,label:t,scope:o.scope,project:o.project,display:H(["npx","rapidkit",...r]),execute:H(["npx","--yes","--package","rapidkit","rapidkit",...r]),required:o.required!==false}}function ae(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 A(){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 se(e,t){let r=t.split(f.sep).join("/");return e.projects.filter(c=>{let n=c.path.split(f.sep).join("/");return r===n||r.startsWith(`${n}/`)}).sort((c,n)=>n.path.length-c.path.length)[0]}function ie(e,t,r){let o=new Set(e.map(n=>n.target)),c=(n,s)=>{let i=s.split(f.sep).join("/"),p=`git:${i}`;if(o.has(p))return;let d=se(r,i),g=d?`${d.name} (${d.path})`:"workspace";h(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:p,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${g}: ${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 ce(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 pe(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 de(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function le(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function fe(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(r=>r.severity==="critical"?false:r.type.startsWith("git.")||r.type==="validation.changed")?e.risk:R(e.risk)>=R("high")||e.risk==="medium"?"low":e.risk}function me(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,f.basename(t.path),t.absolutePath].filter(o=>typeof o=="string"&&o.trim().length>0).map(o=>o.trim().toLowerCase()).includes(r)}function ue(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 Ce(e){let t=f.resolve(e.workspacePath),r=B(e.fromPath),o=e.diff;if(!o&&!r){let a=L(t,e.fromPath);o=await ee(a)??void 0;}o||(o=await ne({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let 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,b=i.get(l)??[];b.push(a),i.set(l,b);}let p=[];for(let[a,k]of i.entries()){let l=c.get(a);if(l&&!me(e.scope,l))continue;let b=T(k.map(de)),x=l?.name??(typeof k[0]?.before?.name=="string"?String(k[0].before.name):a);p.push({id:`project:${x}`,scope:"project",target:a,title:`Project impact: ${x}`,summary:k.map(P=>P.message).join(" "),risk:b,reasons:k.map(P=>`${P.type}: ${P.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?ae(l):A()});}let d=o.changes.filter(a=>!a.type.startsWith("project.")),g=o.currentModel.summary?.projectCount??o.currentModel.projects.length,y=d.map(a=>({id:`workspace:${a.target}`,scope:"workspace",target:a.target,title:`Workspace impact: ${a.target}`,summary:a.message,risk:le(a,{projectCount:g}),reasons:[`${a.type}: ${a.message}`],verification:A()})),v=pe([...p.flatMap(a=>a.verification),...y.flatMap(a=>a.verification),...o.summary.changed?A():[]]).filter(a=>a.required),O=T([...p.map(a=>a.risk),...y.map(a=>a.risk)]),m=fe({risk:O,affectedProjects:p.length,projectCount:g,changes:o.changes}),$={changed:o.summary.changed,risk:m,affectedProjects:p.length,workspaceItems:y.length,recommendedCommands:v.length};return {schemaVersion:Q,generatedAt:(e.now??new Date).toISOString(),fromRef:o.fromRef,diffRef:N,workspace:{name:o.currentModel.workspace.name,profile:o.currentModel.workspace.profile,type:o.currentModel.workspace.type},summary:$,affectedProjects:p.sort((a,k)=>a.target.localeCompare(k.target)),workspaceImpact:y.sort((a,k)=>a.target.localeCompare(k.target)),verificationPlan:v,agentBrief:ue({changed:$.changed,risk:m,affectedProjects:p,workspaceImpact:y}),diff:o}}async function Se(e,t){let r=f.join(t,X);return await w.ensureDir(f.dirname(r)),await w.writeJson(r,e,{spaces:2}),r}export{V as a,G as b,E as c,N as d,Q as e,X as f,B as g,Y as h,Pe as i,Me as j,ne as k,je as l,A as m,Ce as n,Se as o};
@@ -1,4 +0,0 @@
1
- import {a as a$1,b as b$1,d as d$1,c,f}from'./chunk-YBS2HGO3.js';import {a,b}from'./chunk-KMUWWZRT.js';import {c as c$1}from'./chunk-NFUXULIF.js';import u from'chalk';import d from'fs';import m from'fs-extra';import l from'path';function C(t,e){let a=l.resolve(t);if(!b(a))return a;let s=l.join(e,".rapidkit","workspace.contract.json");if(d.existsSync(s))try{let i=JSON.parse(d.readFileSync(s,"utf-8")),n=Array.isArray(i.projects)?i.projects:[];for(let c of n){let y=p(c),f=typeof y.relativePath=="string"?y.relativePath.trim():"";if(f)return l.join(e,f)}}catch{}let r=k(e),o=Array.isArray(r.payload?.projects)?r.payload.projects:[];for(let i of o){let n=p(i),c=typeof n.path=="string"?n.path.trim():"";if(c)return l.resolve(c)}return a}function $(t){let e=a$1(t);return b$1(e,t)?"go":d$1(e,t)?"java":c(e,t)?"node":f(e,t)?"python":"unknown"}function x(t,e){if(!d.existsSync(t))return null;let a=d.readdirSync(t).filter(s=>s.endsWith(".json")&&e.some(r=>r.test(s))).map(s=>l.join(t,s));return a.length===0?null:(a.sort((s,r)=>d.statSync(r).mtimeMs-d.statSync(s).mtimeMs),a[0])}function p(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function G(t){let e=l.join(t,".rapidkit","workspace.contract.json");if(d.existsSync(e))try{let r=JSON.parse(d.readFileSync(e,"utf-8")),o=Array.isArray(r.projects)?r.projects:[];if(o.length>0)return o.length}catch{}let a=k(t);return (Array.isArray(a.payload?.projects)?a.payload.projects:[]).length}function z(t,e,a){let s=l.join(t,".rapidkit","toolchain.lock");if(!d.existsSync(s))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run rapidkit bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:s};try{let r=JSON.parse(d.readFileSync(s,"utf-8")),o=p(r.runtime),n=["python","node","go","java"].filter(c=>{let y=p(o[c]);return typeof y.version=="string"&&y.version.trim().length>0});if(n.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:s};if(e!=="unknown"){let c=p(o[e]);if(typeof c.version!="string"||c.version.trim().length===0)return {gate:"env",status:"fail",summary:`${a?.hasRegisteredProjects?"Project runtime":"Workspace"} (${e}) is not pinned in toolchain.lock`,details:[`Run rapidkit setup ${e} and rapidkit bootstrap to lock ${e} for this workspace.`],evidencePath:s}}return {gate:"env",status:"pass",summary:`Pinned runtimes: ${n.join(", ")}`,details:[],evidencePath:s}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with rapidkit bootstrap."],evidencePath:s}}}function k(t){let e=l.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$1(a,"workspace")?{payload:a,path:e}:{payload:null,path:e}}catch{return {payload:null,path:e}}}function V(t){let e=k(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 E(t){let e=l.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),r=String(s.verdict??"").toLowerCase(),o=Number(s.score??0),i=p(s.findings),n=Number(i.fail??0);return r==="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}:r==="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 J(t){try{let e=JSON.parse(d.readFileSync(t,"utf-8")),a=String(e.status??"").toLowerCase(),s=p(e.summary),r=Number(s.failedChecks??0);return a==="fail"||r>0?{gate:"verify",status:"fail",summary:"Verify-pack contract reports failed checks",details:["Fix failed verify checks and regenerate verify-pack contract evidence."],evidencePath:t}:a==="pass"?{gate:"verify",status:"pass",summary:"Verify-pack contract passed",details:[],evidencePath:t}:{gate:"verify",status:"warn",summary:"Verify-pack contract status is not explicit",details:["Ensure contract status is pass/fail and keep schema aligned with v1 contract."],evidencePath:t}}catch{return {gate:"verify",status:"fail",summary:"Verify-pack contract is invalid JSON",details:["Regenerate verify-pack contract artifact."],evidencePath:t}}}async function L(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=l.join(t,".rapidkit","reports"),s=x(a,[/verify-pack-contract/i,/^verify.*\.json$/i]);if(s)return J(s);let r=l.join(a,"workspace-contract-verify-last-run.json"),o=x(a,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i]);if(o)try{let i=JSON.parse(d.readFileSync(o,"utf-8")),n=String(i.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(i.violations)?i.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:i}=await import('./workspace-contract-A6QP7FPA.js'),n=await i({workspacePath:t}),c={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 m.ensureDir(a),await m.writeJSON(r,c,{spaces:2}),n.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:n.violations.slice(0,5),evidencePath:r}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:r}}catch(i){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.",i instanceof Error?i.message:String(i)],evidencePath:l.join(a,"*verify*.json")}}}function D(t,e){let a=l.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:[],r=s.reduce((i,n)=>{let c=Number(n.vulnerabilities??0);return Number.isFinite(c)?i+Math.max(0,c):i},0),o=s.filter(i=>i.depsInstalled===false).length;return r>0?{gate:"dependency",status:"fail",summary:`${r} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:a}: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 I(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}async function W(t,e){let a=l.join(t,".rapidkit","reports","release-readiness-last-run.json");return await m.ensureDir(l.dirname(a)),await m.writeJSON(a,e,{spaces:2}),a}async function F(t={}){let e=l.resolve(t.startPath??process.cwd()),a$1=a(e)??e,s=C(e,a$1),r=$(s),o=G(a$1)>0,i=z(a$1,r,{hasRegisteredProjects:o}),n=V(a$1),c=E(a$1),y=await L(a$1,{skipVerify:t.skipVerify}),f=D(n.payload,a$1),v=[i,n.gate,c,y,f],R=I(v),h={schemaVersion:"v1",generatedAt:new Date().toISOString(),workspacePath:a$1,projectPath:s,action:t.action,overallStatus:R,blocking:R==="fail",blockingReasons:v.filter(g=>g.status==="fail").map(g=>`${g.gate}: ${g.summary}`),gates:v};return t.writeReport!==false&&(h.evidencePath=await W(a$1,h)),h}function K(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}function M(t){return t==="pass"?u.green("PASS"):t==="warn"?u.yellow("WARN"):u.red("FAIL")}async function _(t){let e=await F({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(l.basename(e.workspacePath))}`)),console.log(u.gray(`Path: ${e.workspacePath}`)),console.log(`Overall: ${M(e.overallStatus)}`);for(let a of e.gates){console.log(` - ${a.gate}: ${K(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{F as a,_ as b};