rapidkit 0.36.0 → 0.37.1

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 (97) hide show
  1. package/README.md +195 -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-QNZ2IL7K.js +1 -0
  11. package/dist/chunk-3SWQKRXH.js +2 -0
  12. package/dist/chunk-6P5DCHBQ.js +4 -0
  13. package/dist/chunk-7RBZGQ7T.js +7 -0
  14. package/dist/chunk-B2KOIORF.js +1 -0
  15. package/dist/{chunk-VPNHGQIV.js → chunk-C7OVQQXT.js} +1 -1
  16. package/dist/chunk-C7WILE56.js +1 -0
  17. package/dist/chunk-FV5A3N3I.js +2 -0
  18. package/dist/chunk-GDGATWR5.js +2 -0
  19. package/dist/chunk-HEG6DIGW.js +2 -0
  20. package/dist/chunk-IOIWVHRO.js +883 -0
  21. package/dist/chunk-JBDQADHY.js +50 -0
  22. package/dist/{chunk-AC6KIKII.js → chunk-PPQYTYQG.js} +4 -4
  23. package/dist/chunk-RELR4O5E.js +2 -0
  24. package/dist/{chunk-DC44JPI3.js → chunk-RUUDLAKJ.js} +12 -12
  25. package/dist/chunk-T5LN7EO5.js +9 -0
  26. package/dist/chunk-TRXYRHD7.js +2 -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-IMB3C3JY.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-4R7S3F6T.js +17 -0
  41. package/dist/workspace-context-CKACDTVE.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-PNMZJNDC.js +1 -0
  48. package/dist/workspace-verify-EO435PS4.js +1 -0
  49. package/docs/AI_DYNAMIC_INTEGRATION.md +440 -0
  50. package/docs/AI_EXAMPLES.md +419 -0
  51. package/docs/AI_FEATURES.md +460 -0
  52. package/docs/AI_QUICKSTART.md +245 -0
  53. package/docs/DEVELOPMENT.md +88 -0
  54. package/docs/From Code to Shared Understanding.png +0 -0
  55. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +170 -0
  56. package/docs/OPTIMIZATION_GUIDE.md +504 -0
  57. package/docs/PACKAGE_MANAGER_POLICY.md +25 -0
  58. package/docs/README.md +120 -0
  59. package/docs/SECURITY.md +63 -0
  60. package/docs/SETUP.md +107 -0
  61. package/docs/UTILITIES.md +221 -0
  62. package/docs/WORKSPACE_MARKER_SPEC.md +276 -0
  63. package/docs/ci-workflows.md +56 -0
  64. package/docs/commands-reference.md +136 -0
  65. package/docs/config-file-guide.md +295 -0
  66. package/docs/contracts/ARTIFACT_CATALOG.md +104 -0
  67. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +138 -0
  68. package/docs/contracts/README.md +70 -0
  69. package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +98 -0
  70. package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +74 -0
  71. package/docs/contracts/rapidkit-cli-contracts.json +239 -0
  72. package/docs/doctor-command.md +263 -0
  73. package/docs/examples/ci-agent-grounding.yml +62 -0
  74. package/docs/from-code-to-shared-understanding.md +46 -0
  75. package/docs/governance-policy.enterprise.example.json +40 -0
  76. package/docs/mirror-config.enterprise.example.json +60 -0
  77. package/docs/policies.workspace.example.yml +23 -0
  78. package/docs/workspace-operations.md +160 -0
  79. package/docs/workspace-run.md +80 -0
  80. package/package.json +4 -2
  81. package/dist/analyze-HXO6R656.js +0 -1
  82. package/dist/autopilot-release-FMQ5KND5.js +0 -1
  83. package/dist/chunk-45KNNNAB.js +0 -2
  84. package/dist/chunk-7ZSURMR2.js +0 -4
  85. package/dist/chunk-HUQ5WRUF.js +0 -883
  86. package/dist/chunk-IATULVMR.js +0 -11
  87. package/dist/chunk-KIB4KHBF.js +0 -3
  88. package/dist/chunk-MCLLP6MW.js +0 -2
  89. package/dist/chunk-TC2PSHT6.js +0 -50
  90. package/dist/chunk-UY4LZEXK.js +0 -7
  91. package/dist/chunk-VM2TOHNX.js +0 -2
  92. package/dist/chunk-Y2ZPG7KN.js +0 -9
  93. package/dist/pipeline-23AEXNF2.js +0 -5
  94. package/dist/workspace-context-YFQQROOZ.js +0 -2
  95. package/dist/workspace-foundation-QVWALXMP.js +0 -1
  96. package/dist/workspace-run-NIKH2IKF.js +0 -1
  97. 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-7RBZGQ7T.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-4R7S3F6T.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-3SWQKRXH.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-3SWQKRXH.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-TRXYRHD7.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-FV5A3N3I.js';
@@ -0,0 +1 @@
1
+ import {m,f as f$1,c,n,e}from'./chunk-U6QUN6V2.js';import {d}from'./chunk-C7OVQQXT.js';import {c as c$1}from'./chunk-FV5A3N3I.js';import p from'path';import g from'fs-extra';var R="workspace-verify.v1",S=".rapidkit/reports/workspace-verify-last-run.json";function C(e,s){return p.isAbsolute(s)?s:p.join(e,s)}async function P(e$1){let s=await g.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 r=s;if(r.schemaVersion!==e)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);return r}function I(e){let s=new Set,r=[];for(let a of e){let i=`${a.scope}:${a.project??""}:${a.display}`;s.has(i)||(s.add(i),r.push(a));}return r}function V(e,s){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return s.scope==="workspace"?true:(s.project??"").trim().toLowerCase()===r}function A(e,s){if(e.id==="workspace.doctor")return p.join(s,".rapidkit","reports","doctor-last-run.json");if(e.id==="workspace.contract.verify")return p.join(s,".rapidkit","reports","workspace-contract-verify-last-run.json");if(e.id==="workspace.readiness")return p.join(s,".rapidkit","reports","release-readiness-last-run.json");if(e.id==="workspace.analyze")return p.join(s,".rapidkit","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return p.join(s,".rapidkit","reports","pipeline-last-run.json");if(e.id.startsWith("project.")&&(e.id.endsWith(".test")||e.id.endsWith(".build")))return p.join(s,".rapidkit","reports","workspace-run-last.json")}function k(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function $(e){let s=k(e.healthScore),r=typeof s?.errors=="number"?s.errors:0,a=typeof s?.percent=="number"?s.percent:void 0;return r>0?{status:"fail",message:`Doctor evidence reports ${r} error(s).`}:typeof a=="number"&&a<70?{status:"warn",message:`Doctor health score is ${a}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function M(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 O(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 x(e){let s=k(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 _(e){let s=k(e.summary),r=typeof s?.verdict=="string"?s.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function D(e,s,r){let a=s.id.endsWith(".build")?"build":s.id.endsWith(".test")?"test":null,i=c$1(e,a);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let u=i.stage;if(a&&u!==a)return {status:"missing",message:`Workspace run evidence is for stage "${u}", expected "${a}".`};let c=Array.isArray(i.projects)?i.projects:[],o=s.project?.toLowerCase();if(!o)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let n=c.find(d=>{let t=k(d);if(!t)return false;let m=typeof t.projectName=="string"?t.projectName.toLowerCase():"",E=["projectPath","relativePath","path"].map(l=>t[l]).filter(l=>typeof l=="string"&&l.trim().length>0).map(l=>l.replace(/\\/g,"/").toLowerCase());return m===o||E.some(l=>l.endsWith(`/${o}`)||l===o)});if(n){let d=f(i.generatedAt,r,`Workspace run evidence for ${s.project??s.id}`);if(d)return {status:"fail",message:d};let t=k(n),m=typeof t?.status=="string"?t.status:"unknown";return m==="failed"?{status:"fail",message:`Workspace run evidence failed for ${s.project}.`}:m==="passed"?{status:"pass",message:`Workspace run evidence passed for ${s.project}.`}:m==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${s.project}.`}:{status:"warn",message:`Workspace run evidence status is ${m} for ${s.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${s.project}.`}}function f(e,s,r){if(typeof e!="string"||!s)return null;let a=Date.parse(e),i=Date.parse(s);return !Number.isFinite(a)||!Number.isFinite(i)?null:a<i?`${r} is stale: generated at ${e}, before impact ${s}.`:null}async function F(e,s,r,a){let i=A(e,s),u=i?p.relative(s,i).split(p.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};if(!i||!await g.pathExists(i))return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:u,message:u?`Missing evidence report: ${u}`:"No evidence mapping exists for this command."};let c=k(await g.readJson(i));if(!c)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:u,message:"Evidence report is not a JSON object."};let o;if(e.id==="workspace.doctor"){let n=f(c.generatedAt,a,"Doctor evidence");n?o={status:"fail",message:n}:o=$(c);}else if(e.id==="workspace.readiness"){let n=f(c.generatedAt,a,"Release readiness evidence");n?o={status:"fail",message:n}:o=M(c);}else if(e.id==="workspace.contract.verify"){let n=f(c.generatedAt,a,"Workspace contract verify evidence");n?o={status:"fail",message:n}:o=O(c);}else if(e.id==="workspace.analyze"){let n=f(c.generatedAt,a,"Analyze evidence");n?o={status:"fail",message:n}:o=x(c);}else if(e.id==="workspace.pipeline"){let n=f(c.generatedAt,a,"Pipeline evidence");n?o={status:"fail",message:n}:o=_(c);}else if(e.id.startsWith("project."))o=D(c,e,a);else {let n=f(c.generatedAt,a,"Evidence report");n?o={status:"fail",message:n}:o={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:o.status,required:e.required,evidencePath:u,message:o.message}}function q(e){let s=e.filter(t=>t.status==="pass").length,r=e.filter(t=>t.status==="warn").length,a=e.filter(t=>t.status==="fail").length,i=e.filter(t=>t.status==="missing").length,u=e.filter(t=>t.status==="skipped").length,c=e.filter(t=>t.required&&(t.status==="fail"||t.status==="missing")).map(t=>`${t.id}: ${t.message}`),o=e.filter(t=>t.required&&t.status==="missing").length,n="ready",d=0;return c.length>0?(n="blocked",d=2):(r>0||o>0)&&(n="needs-attention",d=1),{verdict:n,exitCode:d,stepsPassed:s,stepsWarn:r,stepsFailed:a,stepsMissing:i,stepsSkipped:u}}async function N(e$1){let s=p.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let u=C(s,e$1.fromImpactPath);return {impact:await P(u),fromImpactRef:p.relative(s,u).split(p.sep).join("/")}}let r=p.join(s,f$1);if(await g.pathExists(r))return {impact:await P(r),fromImpactRef:f$1};let a=p.join(s,c);if(await g.pathExists(a))return {impact:await n({workspacePath:s,fromPath:c,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:c};let i=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:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0},affectedProjects:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:"workspace-model-diff.v1",generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:".rapidkit/reports/workspace-model.json",fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}}}}async function Y(e){let s=p.resolve(e.workspacePath),{impact:r,fromImpactRef:a}=await N(e),i=r.diff.currentModel,u=I([...m(),...r.verificationPlan]).filter(t=>V(e.scope,t)),c=[];for(let t of u)c.push(await F(t,s,i.contracts.exists===true,r.generatedAt));let o=q(c),n=c.filter(t=>t.status==="missing"&&t.evidencePath).map(t=>t.evidencePath),d=c.filter(t=>t.required&&(t.status==="fail"||t.status==="missing")).map(t=>`${t.id}: ${t.message}`);return {schemaVersion:R,generatedAt:(e.now??new Date).toISOString(),workspacePath:s,mode:"evidence",fromImpactRef:a,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:o,steps:c,missingEvidence:n,blockingReasons:d,verificationPlan:u}}async function U(e,s){let r=p.join(s,S);return await g.ensureDir(p.dirname(r)),await g.writeJson(r,e,{spaces:2}),r}function Q(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,Q as workspaceVerifyExitCode,U as writeWorkspaceVerify};
@@ -0,0 +1,440 @@
1
+ # 🔄 Dynamic AI Integration with Python Core
2
+
3
+ > **Date:** January 1, 2026
4
+ > **Implementation:** Dynamic module catalog fetching from Python Core
5
+
6
+ ---
7
+
8
+ ## 🎯 Summary
9
+
10
+ AI system uses a **dynamic runtime catalog** and fetches module metadata from **RapidKit Python Core** instead of relying only on hardcoded entries.
11
+
12
+ ### Before (Static):
13
+
14
+ ```typescript
15
+ // ❌ Hardcoded fixed subset
16
+ export const MODULE_CATALOG = [
17
+ { id: 'authentication-core', ... },
18
+ // ... 10 more
19
+ ]
20
+ ```
21
+
22
+ ### After (Dynamic):
23
+
24
+ ```typescript
25
+ // ✅ Fetches from Python Core
26
+ export async function getModuleCatalog() {
27
+ const result = await exec('rapidkit modules list --json');
28
+ return parseModules(result);
29
+ }
30
+ ```
31
+
32
+ ---
33
+
34
+ ## 📊 Architecture
35
+
36
+ ### Data Flow
37
+
38
+ ```
39
+ User Query
40
+
41
+ AI Recommender
42
+
43
+ getModuleCatalog()
44
+
45
+ ├─ Try: rapidkit modules list --json
46
+ │ └─ Success: Return Python modules (runtime count)
47
+ │ └─ Fail: Return fallback catalog (baseline subset)
48
+
49
+ Generate Embeddings
50
+
51
+ Cosine Similarity
52
+
53
+ Return Top Recommendations
54
+ ```
55
+
56
+ ---
57
+
58
+ ## 🔧 Implementation Details
59
+
60
+ ### 1. Dynamic Module Fetching (`src/ai/module-catalog.ts`)
61
+
62
+ **Features:**
63
+
64
+ - ✅ Calls `rapidkit modules list --json`
65
+ - ✅ 5-minute cache (reduces Python calls)
66
+ - ✅ Fallback to hardcoded catalog if Python not available
67
+ - ✅ Automatic retry and error handling
68
+ - ✅ Category and framework mapping
69
+
70
+ **Code:**
71
+
72
+ ```typescript
73
+ export async function getModuleCatalog(): Promise<ModuleMetadata[]> {
74
+ // Check cache
75
+ if (cachedModules && Date.now() - lastFetchTime < CACHE_TTL) {
76
+ return cachedModules;
77
+ }
78
+
79
+ // Fetch from Python Core
80
+ try {
81
+ const { stdout } = await execAsync('rapidkit modules list --json');
82
+ const modules = parseModules(stdout);
83
+ cachedModules = modules;
84
+ return modules;
85
+ } catch (error) {
86
+ console.warn('⚠️ Using fallback catalog');
87
+ return FALLBACK_MODULE_CATALOG;
88
+ }
89
+ }
90
+ ```
91
+
92
+ ---
93
+
94
+ ### 2. Module Parsing
95
+
96
+ **Handles different Python CLI output formats:**
97
+
98
+ ```typescript
99
+ // Format 1: Array
100
+ ["module1", "module2"]
101
+
102
+ // Format 2: Object with modules key
103
+ { "modules": [...] }
104
+
105
+ // Format 3: Object with data key
106
+ { "data": [...] }
107
+ ```
108
+
109
+ **Category Mapping:**
110
+
111
+ ```typescript
112
+ Python Category → TypeScript Type
113
+ ├─ "auth" → "auth"
114
+ ├─ "authentication" → "auth"
115
+ ├─ "database" → "database"
116
+ ├─ "payment" → "payment"
117
+ ├─ "billing" → "payment"
118
+ └─ etc.
119
+ ```
120
+
121
+ ---
122
+
123
+ ### 3. Cache Strategy
124
+
125
+ **TTL: 5 minutes**
126
+
127
+ ```
128
+ First call:
129
+ ├─ Fetch from Python (10s)
130
+ ├─ Cache result
131
+ └─ Return
132
+
133
+ Subsequent calls (within 5 min):
134
+ ├─ Return cached
135
+ └─ Instant response
136
+
137
+ After 5 min:
138
+ ├─ Re-fetch from Python
139
+ └─ Update cache
140
+ ```
141
+
142
+ **Benefits:**
143
+
144
+ - ✅ Fast responses (cached)
145
+ - ✅ Always up-to-date (5min refresh)
146
+ - ✅ Reduces Python CLI calls
147
+
148
+ ---
149
+
150
+ ### 4. Fallback Mechanism
151
+
152
+ **Graceful degradation:**
153
+
154
+ ```
155
+ Try Python Core:
156
+ ├─ Success → Use runtime module catalog ✅
157
+ ├─ Python not in PATH → Use fallback subset ⚠️
158
+ ├─ Command timeout → Use fallback subset ⚠️
159
+ └─ Parse error → Use fallback subset ⚠️
160
+ ```
161
+
162
+ **Fallback catalog:**
163
+
164
+ - Baseline core modules (hardcoded subset)
165
+ - Authentication, database, payment, etc.
166
+ - Enough for basic recommendations
167
+
168
+ ---
169
+
170
+ ### 5. Embedding Generation
171
+
172
+ **Now dynamic:**
173
+
174
+ ```bash
175
+ # Old: Generated from fixed hardcoded subset
176
+ npx tsx src/ai/generate-embeddings.ts
177
+
178
+ # New: Fetches from Python Core first
179
+ # → Gets runtime module catalog
180
+ # → Generates embeddings for all discovered modules
181
+ # → Saves to data/modules-embeddings.json
182
+ ```
183
+
184
+ **Output:**
185
+
186
+ ```json
187
+ {
188
+ "model": "text-embedding-3-small",
189
+ "dimension": 1536,
190
+ "generated_at": "2026-01-01T...",
191
+ "modules": [
192
+ {
193
+ "id": "authentication-core",
194
+ "name": "Authentication Core",
195
+ "embedding": [0.123, -0.456, ...]
196
+ }
197
+ // ... runtime modules (from Python)
198
+ ]
199
+ }
200
+ ```
201
+
202
+ ---
203
+
204
+ ## 🚀 Usage Examples
205
+
206
+ ### Example 1: With Python Core Available
207
+
208
+ ```bash
209
+ $ rapidkit ai recommend "I need user authentication"
210
+
211
+ # Behind the scenes:
212
+ # 1. Calls: rapidkit modules list --json
213
+ # 2. Gets runtime module catalog from Python Core
214
+ # 3. Generates query embedding
215
+ # 4. Compares with catalog embeddings
216
+ # 5. Returns top 5 recommendations
217
+
218
+ 📦 Recommended Modules:
219
+ 1. authentication-core ⭐ (98% match)
220
+ 2. users-core ⭐ (92% match)
221
+ 3. session-management (88% match)
222
+ ...
223
+ ```
224
+
225
+ ---
226
+
227
+ ### Example 2: Without Python Core (Fallback)
228
+
229
+ ```bash
230
+ $ rapidkit ai recommend "payment processing"
231
+
232
+ # Console output:
233
+ ⚠️ RapidKit Python Core not found in PATH
234
+ Using fallback module catalog (baseline subset)
235
+
236
+ # Still works! Uses hardcoded fallback subset
237
+ 📦 Recommended Modules:
238
+ 1. stripe-payment ⭐ (95% match)
239
+ ...
240
+ ```
241
+
242
+ ---
243
+
244
+ ### Example 3: No Matching Modules
245
+
246
+ ```bash
247
+ $ rapidkit ai recommend "blockchain integration"
248
+
249
+ # Output:
250
+ ⚠️ No matching modules found in RapidKit registry.
251
+
252
+ 💡 Options:
253
+
254
+ 1. Create custom module:
255
+ rapidkit modules scaffold blockchain-integration --category integrations
256
+
257
+ 2. Search with different keywords
258
+ Try more general terms (e.g., "storage" instead of "blockchain")
259
+
260
+ 3. Request feature:
261
+ https://github.com/rapidkitlabs/rapidkit/issues
262
+ ```
263
+
264
+ ---
265
+
266
+ ## 📋 Benefits
267
+
268
+ ### ✅ Always Up-to-Date
269
+
270
+ ```
271
+ When Python Core adds new modules:
272
+ ├─ AI automatically picks them up
273
+ ├─ No code changes needed in npm
274
+ ├─ Just regenerate embeddings
275
+ └─ Users get latest recommendations
276
+ ```
277
+
278
+ ### ✅ Single Source of Truth
279
+
280
+ ```
281
+ Module Registry:
282
+ ├─ Python Core: runtime catalog (source of truth)
283
+ ├─ npm AI: Reads from Python (always synced)
284
+ └─ No duplicate data
285
+ ```
286
+
287
+ ### ✅ Graceful Fallback
288
+
289
+ ```
290
+ If Python unavailable:
291
+ ├─ Still works (fallback subset)
292
+ ├─ User informed (console warning)
293
+ ├─ No crashes or errors
294
+ └─ Can upgrade to Python later
295
+ ```
296
+
297
+ ### ✅ Performance
298
+
299
+ ```
300
+ Cache Strategy:
301
+ ├─ First call: 10s (Python fetch)
302
+ ├─ Cached calls: <100ms (instant)
303
+ ├─ Cache refresh: Every 5 minutes
304
+ └─ Optimal balance
305
+ ```
306
+
307
+ ---
308
+
309
+ ## 🔧 Configuration
310
+
311
+ ### Environment Variables
312
+
313
+ ```bash
314
+ # Optional: Force fallback mode (testing)
315
+ export RAPIDKIT_AI_FALLBACK=true
316
+
317
+ # Optional: Cache TTL (default: 5 minutes)
318
+ export RAPIDKIT_CACHE_TTL=600000 # milliseconds
319
+
320
+ # Optional: Python command/interpreter override (if python3/python is not the right one)
321
+ export RAPIDKIT_PYTHON_CMD=/path/to/python
322
+ ```
323
+
324
+ ---
325
+
326
+ ## 🧪 Testing
327
+
328
+ ### Test 1: With Python Core
329
+
330
+ ```bash
331
+ # Ensure Python Core in PATH
332
+ which rapidkit # Should return path
333
+
334
+ # Test recommendation
335
+ rapidkit ai recommend "authentication"
336
+
337
+ # Should show: using runtime catalog from Python Core
338
+ ```
339
+
340
+ ### Test 2: Without Python Core
341
+
342
+ ```bash
343
+ # Temporarily hide Python
344
+ export PATH=/tmp:$PATH
345
+
346
+ # Test recommendation
347
+ rapidkit ai recommend "authentication"
348
+
349
+ # Should show: ⚠️ Using fallback catalog (baseline subset)
350
+ ```
351
+
352
+ ### Test 3: Cache Behavior
353
+
354
+ ```bash
355
+ # First call (cold cache)
356
+ time rapidkit ai recommend "auth" # ~10 seconds
357
+
358
+ # Second call (warm cache)
359
+ time rapidkit ai recommend "database" # <1 second
360
+
361
+ # Wait 6 minutes, try again
362
+ sleep 360
363
+ time rapidkit ai recommend "payment" # ~10 seconds (cache expired)
364
+ ```
365
+
366
+ ---
367
+
368
+ ## 📊 Comparison
369
+
370
+ | Feature | Before (Static) | After (Dynamic) |
371
+ | ------------------- | ------------------ | ------------------ |
372
+ | **Module Count** | Fixed subset | Runtime catalog |
373
+ | **Updates** | Manual code change | Automatic |
374
+ | **Sync** | Manual | Automatic |
375
+ | **Fallback** | ❌ None | ✅ Baseline subset |
376
+ | **Cache** | ❌ None | ✅ 5-minute TTL |
377
+ | **Python Required** | ❌ No | ⚠️ Recommended |
378
+ | **Performance** | Fast (hardcoded) | Fast (cached) |
379
+
380
+ ---
381
+
382
+ ## 🚀 Next Steps
383
+
384
+ ### Current Stage: ✅ Dynamic Fetching
385
+
386
+ - ✅ Fetch from Python Core
387
+ - ✅ Cache with TTL
388
+ - ✅ Fallback to hardcoded
389
+ - ✅ Error handling
390
+
391
+ ### Next Stage: Module Installation
392
+
393
+ ```bash
394
+ rapidkit ai recommend "authentication"
395
+ # → Shows recommendations
396
+ # → [Install] button
397
+ # → Calls: rapidkit add module authentication-core
398
+ # → Python Core installs module
399
+ ```
400
+
401
+ ### Future Stage: Real-time Sync
402
+
403
+ ```bash
404
+ # Watch Python modules directory
405
+ # Auto-regenerate embeddings when modules change
406
+ # Push updates to users
407
+ ```
408
+
409
+ ---
410
+
411
+ ## 🎯 Summary
412
+
413
+ **What Changed:**
414
+
415
+ - ✅ AI now reads from Python Core dynamically
416
+ - ✅ Runtime catalog instead of a fixed hardcoded subset
417
+ - ✅ Always up-to-date
418
+ - ✅ Fallback if Python not available
419
+ - ✅ 5-minute cache for performance
420
+
421
+ **What Stayed Same:**
422
+
423
+ - ✅ Same API (getModuleCatalog)
424
+ - ✅ Same recommendation algorithm
425
+ - ✅ Same embedding model
426
+ - ✅ Same CLI commands
427
+ - ✅ Backward compatible
428
+
429
+ **Result:**
430
+
431
+ - 🎉 Runtime-driven catalog
432
+ - 🎉 Single source of truth
433
+ - 🎉 Production-ready
434
+ - 🎉 Zero breaking changes
435
+
436
+ ---
437
+
438
+ **Built with ❤️ by the RapidKit Team**
439
+
440
+ _Dynamic AI that grows with your framework._