rapidkit 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -147
- package/contracts/create-planner-capabilities.v1.json +251 -0
- package/contracts/runtime-command-surface.v1.json +52 -0
- package/dist/autopilot-release-SBPGNGAB.js +1 -0
- package/dist/chunk-2ED6SPXP.js +1 -0
- package/dist/chunk-3R7UJAX5.js +1 -0
- package/dist/{chunk-RUUDLAKJ.js → chunk-5NBYSXOZ.js} +1 -1
- package/dist/chunk-7XW2I6MP.js +13 -0
- package/dist/{chunk-U6QUN6V2.js → chunk-ABPDGFVD.js} +1 -1
- package/dist/chunk-IW3KLQXE.js +2 -0
- package/dist/{chunk-7VSYTOOG.js → chunk-NKNMGWAZ.js} +1 -1
- package/dist/{chunk-IOIWVHRO.js → chunk-TVIOAZ6E.js} +13 -13
- package/dist/chunk-XESEBTPE.js +1 -0
- package/dist/{create-HN5HOGQ4.js → create-Y3XJOKL5.js} +1 -1
- package/dist/index.js +150 -144
- package/dist/{pipeline-BOU4KETN.js → pipeline-C4UCLETO.js} +1 -1
- package/dist/{workspace-2AL5C3QZ.js → workspace-WBKFXH4Z.js} +1 -1
- package/dist/{workspace-agent-sync-V2H6NTGD.js → workspace-agent-sync-3FFFJYKF.js} +1 -1
- package/dist/{workspace-context-KCKNV5VQ.js → workspace-context-V4UGIHSC.js} +1 -1
- package/dist/{workspace-foundation-L6ZBGMVE.js → workspace-foundation-T45HAWKL.js} +1 -1
- package/dist/{workspace-intelligence-3TWXJQ7Y.js → workspace-intelligence-MGL3Z25K.js} +1 -1
- package/dist/{workspace-model-NQVZN5W4.js → workspace-model-IKMGY2BX.js} +1 -1
- package/dist/workspace-run-HOR56FON.js +1 -0
- package/dist/workspace-verify-A3J6D7T2.js +1 -0
- package/docs/AI_DYNAMIC_INTEGRATION.md +440 -0
- package/docs/AI_EXAMPLES.md +419 -0
- package/docs/AI_FEATURES.md +460 -0
- package/docs/AI_QUICKSTART.md +245 -0
- package/docs/DEVELOPMENT.md +88 -0
- package/docs/From Code to Shared Understanding.png +0 -0
- package/docs/OPEN_SOURCE_USER_SCENARIOS.md +170 -0
- package/docs/OPTIMIZATION_GUIDE.md +504 -0
- package/docs/PACKAGE_MANAGER_POLICY.md +25 -0
- package/docs/README.md +121 -0
- package/docs/SECURITY.md +63 -0
- package/docs/SETUP.md +107 -0
- package/docs/UTILITIES.md +221 -0
- package/docs/WORKSPACE_MARKER_SPEC.md +276 -0
- package/docs/ci-workflows.md +56 -0
- package/docs/commands-reference.md +136 -0
- package/docs/config-file-guide.md +295 -0
- package/docs/contracts/ARTIFACT_CATALOG.md +111 -0
- package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +138 -0
- package/docs/contracts/README.md +71 -0
- package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +98 -0
- package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +74 -0
- package/docs/contracts/rapidkit-cli-contracts.json +239 -0
- package/docs/create-planner-capabilities.md +81 -0
- package/docs/doctor-command.md +263 -0
- package/docs/examples/ci-agent-grounding.yml +62 -0
- package/docs/from-code-to-shared-understanding.md +46 -0
- package/docs/governance-policy.enterprise.example.json +40 -0
- package/docs/mirror-config.enterprise.example.json +60 -0
- package/docs/policies.workspace.example.yml +23 -0
- package/docs/workspace-operations.md +160 -0
- package/docs/workspace-run.md +80 -0
- package/package.json +3 -2
- package/dist/autopilot-release-AUXP2ZIF.js +0 -1
- package/dist/chunk-C7OVQQXT.js +0 -1
- package/dist/chunk-EJGKBFV4.js +0 -2
- package/dist/chunk-UXKB4KGZ.js +0 -13
- package/dist/chunk-YJ24EV3P.js +0 -1
- package/dist/workspace-run-DEXI52KO.js +0 -1
- package/dist/workspace-verify-HBCQNNGU.js +0 -1
- /package/dist/{chunk-D23L2GFT.js → chunk-6E5TBB2C.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c}from'./chunk-
|
|
1
|
+
import {c}from'./chunk-NKNMGWAZ.js';import {b}from'./chunk-JBDQADHY.js';import {b as b$1}from'./chunk-5NBYSXOZ.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-3FFFJYKF.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
2
|
\u{1F517} RapidKit Governance Pipeline
|
|
3
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
4
|
Blocking reasons:`));for(let a of s.blockingReasons.slice(0,8))console.log(c$1.gray(` \u2022 ${a}`));}console.log(c$1.gray(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{e as createProject,d as createWorkspace,g as createWorkspaceShareBundle,f as listWorkspaces,c as registerProjectInWorkspace,a as registerWorkspace,b as syncWorkspaceProjects}from'./chunk-
|
|
1
|
+
export{e as createProject,d as createWorkspace,g as createWorkspaceShareBundle,f as listWorkspaces,c as registerProjectInWorkspace,a as registerWorkspace,b as syncWorkspaceProjects}from'./chunk-5NBYSXOZ.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b,c,d}from'./chunk-
|
|
1
|
+
import {b,c,d}from'./chunk-IW3KLQXE.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
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
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
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(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as WORKSPACE_CONTEXT_AGENT_REPORT_PATH,a as WORKSPACE_CONTEXT_SCHEMA_VERSION,c as buildWorkspaceAgentContext,d as writeWorkspaceAgentContext}from'./chunk-
|
|
1
|
+
export{b as WORKSPACE_CONTEXT_AGENT_REPORT_PATH,a as WORKSPACE_CONTEXT_SCHEMA_VERSION,c as buildWorkspaceAgentContext,d as writeWorkspaceAgentContext}from'./chunk-IW3KLQXE.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-TVIOAZ6E.js';import {a}from'./chunk-RV6HBTFC.js';import c from'path';import u from'fs-extra';async function W(t,r){let o=await a(t),d=o?.name||c.basename(t),n,i=c.join(t,".python-version");if(await u.pathExists(i)){let a=(await u.readFile(i,"utf-8")).trim();a&&(n=a);}let e=r?.profile||"polyglot",m=e==="python-only"||e==="polyglot"||e==="enterprise",f=r?.installMethod||o?.metadata?.npm?.installMethod||(m?"poetry":"venv"),s=await b(t,{workspaceName:d,installMethod:f,pythonVersion:n,profile:e,writeMarker:true,writeGitignore:true,onlyIfMissing:!r?.force}),{publishWorkspaceRegistrySummary:y}=await import('./workspace-registry-summary-MIPHVB56.js');return await y(t),{workspacePath:t,created:s,status:s.length>0?"passed":"skipped"}}export{W as ensureWorkspaceFoundation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{f as WORKSPACE_IMPACT_REPORT_PATH,e as WORKSPACE_IMPACT_SCHEMA_VERSION,d as WORKSPACE_MODEL_DIFF_REPORT_PATH,b as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,c as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,a as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,n as buildWorkspaceImpact,i as buildWorkspaceModelSnapshot,k as diffWorkspaceModel,g as isGitDiffSource,h as parseGitDiffRef,m as workspaceVerificationPlan,o as writeWorkspaceImpact,l as writeWorkspaceModelDiff,j as writeWorkspaceModelSnapshot}from'./chunk-
|
|
1
|
+
export{f as WORKSPACE_IMPACT_REPORT_PATH,e as WORKSPACE_IMPACT_SCHEMA_VERSION,d as WORKSPACE_MODEL_DIFF_REPORT_PATH,b as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,c as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,a as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,n as buildWorkspaceImpact,i as buildWorkspaceModelSnapshot,k as diffWorkspaceModel,g as isGitDiffSource,h as parseGitDiffRef,m as workspaceVerificationPlan,o as writeWorkspaceImpact,l as writeWorkspaceModelDiff,j as writeWorkspaceModelSnapshot}from'./chunk-ABPDGFVD.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as WORKSPACE_MODEL_REPORT_PATH,a as WORKSPACE_MODEL_SCHEMA_VERSION,d as buildWorkspaceModel,c as validateWorkspaceModelStrict,e as writeWorkspaceModel}from'./chunk-
|
|
1
|
+
export{b as WORKSPACE_MODEL_REPORT_PATH,a as WORKSPACE_MODEL_SCHEMA_VERSION,d as buildWorkspaceModel,c as validateWorkspaceModelStrict,e as writeWorkspaceModel}from'./chunk-XESEBTPE.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as runWorkspaceStage}from'./chunk-6E5TBB2C.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-ABPDGFVD.js';import {d}from'./chunk-XESEBTPE.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._
|