rapidkit 0.33.1 → 0.34.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 +69 -8
- package/contracts/pipeline-last-run.v1.json +80 -0
- package/dist/analyze-SVYRQNLO.js +1 -0
- package/dist/autopilot-release-LBKCP73F.js +1 -0
- package/dist/{chunk-MSW2I3F3.js → chunk-2PGMJSO5.js} +64 -33
- package/dist/{workspace-4VGM2NPS.js → chunk-3TBSWOTY.js} +13 -13
- package/dist/chunk-GX7UU7LL.js +33 -0
- package/dist/{chunk-7OGOVP5U.js → chunk-IATULVMR.js} +1 -1
- package/dist/chunk-ILY6QARY.js +9 -0
- package/dist/chunk-JIECGCLV.js +4 -0
- package/dist/chunk-QUNCXYYK.js +1 -0
- package/dist/chunk-RGXFDBYB.js +7 -0
- package/dist/{doctor-T6F2I6VO.js → chunk-YV7IQDBM.js} +26 -26
- package/dist/{create-M7LT6WF6.js → create-BO2I3ESU.js} +1 -1
- package/dist/doctor-3SBEO7XU.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +122 -125
- package/dist/pipeline-VUQ6AXKF.js +5 -0
- package/dist/{pythonRapidkitExec-JXOKKTXZ.js → pythonRapidkitExec-MNWRC4F2.js} +1 -1
- package/dist/workspace-AG2MQFTY.js +1 -0
- package/dist/{workspace-foundation-4EYME5VM.js → workspace-foundation-G74V6K4U.js} +1 -1
- package/dist/workspace-run-EDM3SUPA.js +1 -0
- package/package.json +4 -3
- package/dist/analyze-Q2XAYVUQ.js +0 -9
- package/dist/autopilot-release-AOPUECK6.js +0 -7
- package/dist/chunk-W62Q2D3K.js +0 -33
- package/dist/workspace-run-SWN34LVQ.js +0 -1
- /package/dist/{chunk-BDJHZ3XW.js → chunk-SAIWD6VM.js} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-ILY6QARY.js';import {a as a$3}from'./chunk-RGXFDBYB.js';import {b}from'./chunk-YV7IQDBM.js';import {a as a$2}from'./chunk-JIECGCLV.js';import {a}from'./chunk-QUNCXYYK.js';import {b as b$1}from'./chunk-3TBSWOTY.js';import c from'chalk';import x from'fs-extra';import u from'path';function D(s){return s===0?"pass":s===2?"warn":"fail"}function M(s){return s.some(r=>r.status==="fail")?"blocked":s.some(r=>r.status==="warn")?"needs-attention":"ready"}function j(s,r){if(r)return 3;let t=s.some(i=>i.status==="fail"),a=s.some(i=>i.status==="warn");return t?1:a?2:0}async function A(s){let r=await b$1(s,true),t=false;try{let{syncWorkspaceContract:a}=await import('./workspace-contract-Z5VYUF3T.js');await a({workspacePath:s}),t=true;}catch{t=false;}return {sync:r,contractSynced:t}}async function C(s={}){let r=u.resolve(s.workspacePath??process.cwd()),t=a(r);if(!t)throw new Error("No RapidKit workspace found in current directory or parents");let a$4=[],i=[],l=false,p,f,d,g=Date.now();try{let{sync:e,contractSynced:o}=await A(t),n=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";a$4.push({name:"sync",status:n,durationMs:Date.now()-g,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${o?", contract synced":""}`:"workspace not registered in global registry; contract sync attempted"}),e.workspaceFound||i.push("workspace registry entry missing \u2014 run rapidkit create workspace or register manually");}catch(e){l=true,a$4.push({name:"sync",status:"fail",durationMs:Date.now()-g,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),i.push("workspace sync stage failed");}let y=Date.now();try{let e=await b({workspace:true,json:true,quiet:true,strict:s.strict===true,ci:s.strict!==true}),o=D(e),n=u.join(t,".rapidkit","reports","doctor-last-run.json");a$4.push({name:"doctor",status:o,durationMs:Date.now()-y,summary:o==="pass"?"doctor workspace passed":o==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors",exitCode:e,evidencePath:n}),o==="fail"?i.push("doctor workspace gate failed"):o==="warn"&&i.push("doctor workspace reported warnings");}catch(e){l=true,a$4.push({name:"doctor",status:"fail",durationMs:Date.now()-y,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),i.push("doctor workspace stage failed");}if(s.skipAnalyze)a$4.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let o=await a$1({workspacePath:t,json:true,strict:s.strict===true});p=u.join(t,".rapidkit","reports","analyze-last-run.json");let n=o.summary.verdict==="blocked"?"fail":o.summary.verdict==="needs-attention"?"warn":"pass";a$4.push({name:"analyze",status:n,durationMs:Date.now()-e,summary:`analyze verdict: ${o.summary.verdict} (score ${o.summary.score}/100)`,evidencePath:p}),n==="fail"?i.push("analyze reported blocked verdict"):n==="warn"&&i.push("analyze reported needs-attention verdict");}catch(o){l=true,a$4.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${o instanceof Error?o.message:String(o)}`}),i.push("analyze stage failed");}}let w=Date.now();try{let e=await a$2({startPath:t,writeReport:true,skipVerify:s.skipVerify===true});f=e.evidencePath;let o=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";a$4.push({name:"readiness",status:o,durationMs:Date.now()-w,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),o==="fail"?i.push(...e.blockingReasons.map(n=>`readiness: ${n}`)):o==="warn"&&i.push(...e.gates.filter(n=>n.status==="warn").map(n=>`readiness warn: ${n.gate}: ${n.summary}`));}catch(e){l=true,a$4.push({name:"readiness",status:"fail",durationMs:Date.now()-w,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),i.push("readiness stage failed");}if(s.skipAutopilot)a$4.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),o=s.autopilotMode??"audit";try{let n=await a$3({workspacePath:t,mode:o,json:true,skipPipelineStages:true});d=n.artifacts.reportPath;let k=n.summary.verdict==="approved"?"pass":n.summary.verdict==="partial"?"warn":"fail";a$4.push({name:"autopilot",status:k,durationMs:Date.now()-e,summary:`autopilot ${o}: ${n.summary.verdict}`,exitCode:n.summary.exitCode,evidencePath:d}),k!=="pass"&&i.push(...n.blockingReasons.slice(0,5));}catch(n){l=true,a$4.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${n instanceof Error?n.message:String(n)}`}),i.push("autopilot release stage failed");}}let E=M(a$4),z=j(a$4,l),m=u.join(t,".rapidkit","reports","pipeline-last-run.json"),h={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:t,summary:{verdict:E,exitCode:z,stagesPassed:a$4.filter(e=>e.status==="pass").length,stagesWarn:a$4.filter(e=>e.status==="warn").length,stagesFailed:a$4.filter(e=>e.status==="fail").length},stages:a$4,blockingReasons:[...new Set(i)],artifacts:{reportPath:m,analyzeEvidencePath:p,readinessEvidencePath:f,autopilotEvidencePath:d}};return s.writeReport!==false&&(await x.ensureDir(u.dirname(m)),await x.writeJSON(m,h,{spaces:2})),h}async function L(s){let r;try{r=await C(s);}catch(t){let a=t instanceof Error?t.message:String(t);s.json?console.log(JSON.stringify({schemaVersion:"rapidkit-pipeline-error-v1",ok:false,error:{message:a}},null,2)):console.log(c.red(`Pipeline failed: ${a}`)),process.exit(1);}if(s.json)console.log(JSON.stringify(r,null,2));else {console.log(c.bold.cyan(`
|
|
2
|
+
\u{1F517} RapidKit Governance Pipeline
|
|
3
|
+
`)),console.log(c.bold(`Workspace: ${c.cyan(u.basename(r.workspacePath))}`)),console.log(c.gray(`Path: ${r.workspacePath}`)),console.log(c.white(`Verdict: ${r.summary.verdict} Exit: ${r.summary.exitCode} (${r.summary.stagesPassed} pass / ${r.summary.stagesWarn} warn / ${r.summary.stagesFailed} fail)`));for(let t of r.stages){let a=t.status==="pass"?c.green("PASS"):t.status==="warn"?c.yellow("WARN"):t.status==="skipped"?c.gray("SKIP"):c.red("FAIL");console.log(` - ${t.name}: ${a} ${t.summary}`);}if(r.blockingReasons.length>0){console.log(c.bold(`
|
|
4
|
+
Blocking reasons:`));for(let t of r.blockingReasons.slice(0,8))console.log(c.gray(` \u2022 ${t}`));}console.log(c.gray(`
|
|
5
|
+
Evidence: ${r.artifacts.reportPath}`));}r.summary.exitCode!==0&&process.exit(r.summary.exitCode);}export{C as runPipeline,L as runPipelineCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{k as __test__,b as checkRapidkitCoreAvailable,c as checkRapidkitCoreVersionCompatible,i as getCachedCoreTopLevelCommands,h as getCoreTopLevelCommands,j as getModulesCatalog,d as resolveRapidkitPython,e as runCoreRapidkit,g as runCoreRapidkitCapture,f as runCoreRapidkitStreamed}from'./chunk-
|
|
1
|
+
export{k as __test__,b as checkRapidkitCoreAvailable,c as checkRapidkitCoreVersionCompatible,i as getCachedCoreTopLevelCommands,h as getCoreTopLevelCommands,j as getModulesCatalog,d as resolveRapidkitPython,e as runCoreRapidkit,g as runCoreRapidkitCapture,f as runCoreRapidkitStreamed}from'./chunk-GX7UU7LL.js';
|
|
@@ -0,0 +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-3TBSWOTY.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-2PGMJSO5.js';import {a}from'./chunk-RV6HBTFC.js';import c from'path';import d from'fs-extra';async function v(e,r){let o=await a(e),f=o?.name||c.basename(e),n,i=c.join(e,".python-version");if(await d.pathExists(i)){let a=(await d.readFile(i,"utf-8")).trim();a&&(n=a);}let t=r?.profile||"polyglot",u=t==="python-only"||t==="polyglot"||t==="enterprise",m=r?.installMethod||o?.metadata?.npm?.installMethod||(u?"poetry":"venv"),s=await a$1(e,{workspaceName:f,installMethod:m,pythonVersion:n,profile:t,writeMarker:true,writeGitignore:true,onlyIfMissing:!r?.force});return {workspacePath:e,created:s,status:s.length>0?"passed":"skipped"}}export{v as ensureWorkspaceFoundation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as runWorkspaceStage}from'./chunk-SAIWD6VM.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Official CLI for RapidKit, an open-source workspace platform that standardizes how teams build, scale, and deploy backend services.",
|
|
6
6
|
"keywords": [
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"lint-staged": "^15.5.2",
|
|
131
131
|
"prettier": "^3.6.2",
|
|
132
132
|
"size-limit": "^12.0.0",
|
|
133
|
-
"tsup": "^8.5.
|
|
133
|
+
"tsup": "^8.5.1",
|
|
134
134
|
"typescript": "^5.5.0",
|
|
135
135
|
"vite-bundle-visualizer": "^1.2.1",
|
|
136
136
|
"vitest": "^4.0.15"
|
|
@@ -148,7 +148,8 @@
|
|
|
148
148
|
]
|
|
149
149
|
},
|
|
150
150
|
"overrides": {
|
|
151
|
-
"minimatch": "^10.2.1"
|
|
151
|
+
"minimatch": "^10.2.1",
|
|
152
|
+
"esbuild": "^0.28.1"
|
|
152
153
|
},
|
|
153
154
|
"packageManager": "npm@10.8.2"
|
|
154
155
|
}
|
package/dist/analyze-Q2XAYVUQ.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {d,e}from'./chunk-KXTXQODI.js';import {a}from'./chunk-VKLL63TL.js';import g from'fs';import r from'path';import o from'chalk';var $=new Set([".git",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function y(e){try{return await g.promises.access(e,g.constants.F_OK),true}catch{return false}}async function v(e){try{let n=JSON.parse(await g.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function F(e){try{return await g.promises.readFile(e,"utf-8")}catch{return ""}}function I(e){let n=r.resolve(e);for(;;){if(g.existsSync(r.join(n,".rapidkit-workspace"))||g.existsSync(r.join(n,".rapidkit","workspace.json")))return n;let t=r.dirname(n);if(t===n)return null;n=t;}}async function G(e,n){return await y(r.join(e,".rapidkit","project.json"))||await y(r.join(e,".rapidkit","context.json"))?true:r.resolve(e)===r.resolve(n)?d(e).length>0:d(e).length>0}async function S(e){let n=await a(e,{skipDirs:$,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:G});return n.length>0?n:d(e).length>0?[e]:[]}function E(e,n){return r.relative(e,n).replace(/\\/g,"/")||"."}async function b(e,n){for(let t of n)if(await y(r.join(e,t)))return true;return false}async function T(e){return b(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function N(e){if(await b(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await v(r.join(e,"package.json")),i=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof i.test=="string"&&i.test.trim().length>0}async function K(e){let n=await v(r.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function h(e,n,t,i,s,c){return {id:e,severity:n,target:t,title:i,detail:s,remediation:c}}function O(e){let n=e.reduce((t,i)=>i.severity==="fail"?t+28:i.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function _(e$1,n){let t=await v(r.join(n,".rapidkit","project.json")),i=e(n,t),s=d(n),c=i.runtime==="unknown"?s[0]||"unknown":i.runtime,a=E(e$1,n),d$1=a,m=await K(n),f=await y(r.join(n,".rapidkit","project.json"))||await y(r.join(n,".rapidkit","context.json")),u=await N(n),k=await b(n,["Dockerfile","dockerfile"]),w=await b(n,[".env.example","env.example","config/env.example"]),A=await b(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),z=await T(n),l=[];return i.key==="unknown"&&l.push(h("project.stack.unknown","fail",d$1,"Project stack is unknown","RapidKit cannot confidently classify this backend project.","Add .rapidkit/project.json metadata or import the project with `rapidkit import`.")),f||l.push(h("project.marker.missing","warn",d$1,"RapidKit marker is missing","The project can be detected by files, but it is not registered with RapidKit metadata.","Run `rapidkit import <path>` from a workspace or create the project through RapidKit.")),u||l.push(h("project.tests.missing","warn",d$1,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `rapidkit workspace run test --affected` can gate changes.")),w||l.push(h("project.env.example.missing","info",d$1,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),A||l.push(h("project.ci.missing","warn",d$1,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),z||l.push(h("project.health.missing","info",d$1,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),k||l.push(h("project.container.missing","info",d$1,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:r.basename(n),path:n,relativePath:a,runtime:c,framework:i.key,confidence:i.confidence,supportTier:i.supportTier,hasRapidKitMarker:f,hasTests:u,hasDockerfile:k,hasEnvExample:w,hasCiConfig:A,hasHealthEndpoint:z,scripts:m,findings:l,score:O(l)}}function J(e){return e.name.toLowerCase()}async function M(e){let n=new Map(e.map(s=>[J(s),s])),t=[];for(let s of e){let c=await v(r.join(s.path,"package.json")),a={...c?.dependencies??{},...c?.devDependencies??{},...c?.peerDependencies??{}};for(let m of Object.keys(a)){let f=m.replace(/^@[^/]+\//,"").toLowerCase(),u=n.get(f);u&&u.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:u.relativePath,kind:"package"});}let d=await F(r.join(s.path,"pyproject.toml"));for(let m of e)m.relativePath!==s.relativePath&&d.includes(m.name)&&t.push({from:s.relativePath,to:m.relativePath,kind:"workspace-reference"});}let i=new Set;return t.filter(s=>{let c=`${s.from}\0${s.to}\0${s.kind}`;return i.has(c)?false:(i.add(c),true)})}function W(e,n){let t=new Map;for(let i of e)t.set(i.relativePath,{project:i.relativePath,directDependents:0,directDependencies:0});for(let i of n){let s=t.get(i.from),c=t.get(i.to);s&&(s.directDependencies+=1),c&&(c.directDependents+=1);}return Array.from(t.values()).sort((i,s)=>s.directDependents-i.directDependents||s.directDependencies-i.directDependencies)}async function H(e){let n=await v(r.join(e,".rapidkit","workspace.json"));return typeof n?.profile=="string"?n.profile:null}function B(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function V(e){if(e.projectCount===0)return ["Create a RapidKit workspace: npx rapidkit create workspace my-workspace --profile polyglot","Import an existing service: npx rapidkit import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `rapidkit bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `rapidkit import <path>` or recreate them via `rapidkit create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `rapidkit workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.rapidkit/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `rapidkit autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ee(e={}){let n=r.resolve(e.workspacePath||process.cwd());if(!await y(n))throw new Error(`Workspace path does not exist: ${n}`);let t=I(n)??n,i=await y(r.join(t,".rapidkit-workspace"))||await y(r.join(t,".rapidkit","workspace.json")),s=await H(t),c=await S(t),a=await Promise.all(c.map(p=>_(t,p))),d=await M(a),m=W(a,d),f=[];i||f.push(h("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered RapidKit workspace.","Run `rapidkit create workspace` or `rapidkit bootstrap --profile polyglot` in a workspace root.")),a.length===0&&f.push(h("workspace.projects.missing","fail",".","No backend projects detected","RapidKit did not find runtime markers or project metadata under this root.","Create a project with `rapidkit create project` or import one with `rapidkit import <path>`."));let u=[...f,...a.flatMap(p=>p.findings)],k=B(u),w={};for(let p of a)w[p.runtime]=(w[p.runtime]||0)+1;let A=a.length>0?Math.round(a.reduce((p,P)=>p+P.score,0)/a.length):0,z=f.reduce((p,P)=>p+(P.severity==="fail"?20:P.severity==="warn"?8:2),0),l=Math.max(0,A-z),R=k.fail>0||e.strict&&k.warn>0?"blocked":k.warn>0?"needs-attention":"ready",x={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:i,profile:s,summary:{score:l,verdict:R,projectCount:a.length,runtimeCount:Object.keys(w).length,findings:k},runtimes:w,projects:a,dependencyGraph:{status:d.length>0?"generated":"empty",edges:d,topImpactedProjects:m.slice(0,5)},findings:u,nextActions:V({findings:u,projectCount:a.length,hasGraph:d.length>0}),enterpriseControls:{jsonReady:true,ciGateCommand:"rapidkit analyze --json --strict",releaseGateCommand:"rapidkit autopilot release --mode enforce --json",evidencePath:".rapidkit/reports/analyze-last-run.json"}};if(e.output&&(await g.promises.mkdir(r.dirname(r.resolve(e.output)),{recursive:true}),await g.promises.writeFile(r.resolve(e.output),`${JSON.stringify(x,null,2)}
|
|
2
|
-
`)),!e.output&&i){let p=r.join(t,".rapidkit","reports","analyze-last-run.json");await g.promises.mkdir(r.dirname(p),{recursive:true}),await g.promises.writeFile(p,`${JSON.stringify(x,null,2)}
|
|
3
|
-
`);}return x}function ne(e){let n=e.summary.verdict==="ready"?o.green:e.summary.verdict==="needs-attention"?o.yellow:o.red;if(console.log(o.bold(`
|
|
4
|
-
RapidKit Workspace Analysis
|
|
5
|
-
`)),console.log(o.cyan("Workspace:"),e.workspacePath),console.log(o.cyan("Profile:"),e.profile||"not configured"),console.log(o.cyan("Score:"),`${e.summary.score}/100`),console.log(o.cyan("Verdict:"),n(e.summary.verdict)),console.log(o.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(o.bold(`
|
|
6
|
-
Projects`));for(let t of e.projects){let i=t.score>=85?o.green("pass"):t.score>=65?o.yellow("watch"):o.red("risk");console.log(` ${t.relativePath} ${o.gray(`${t.runtime}/${t.framework}`)} ${i} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(o.bold(`
|
|
7
|
-
Dependency Graph`)),console.log(o.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(o.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(o.bold(`
|
|
8
|
-
Top Findings`));for(let t of e.findings.slice(0,8)){let i=t.severity==="fail"?o.red:t.severity==="warn"?o.yellow:o.gray;console.log(` ${i(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(o.gray(` ${t.remediation}`));}}console.log(o.bold(`
|
|
9
|
-
Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(o.gray(` - ${t}`));console.log();}export{ne as printAnalyzeReport,ee as runAnalyze};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-BDJHZ3XW.js';import n from'chalk';import W from'fs';import g from'path';import {execa}from'execa';function b(s){try{return JSON.parse(s)}catch{return null}}function ie(s){let t=g.resolve(s);for(;;){if(W.existsSync(g.join(t,".rapidkit-workspace"))||W.existsSync(g.join(t,".rapidkit","workspace.json")))return t;let a=g.dirname(t);if(a===t)return null;t=a;}}function le(s){let t=g.resolve(s),a=ie(t);if(!a)throw new Error("No RapidKit workspace found in current directory or parents");return a}async function S(s,t){let a=process.argv[1];if(!a)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[a,...s],{cwd:t,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function H(s){let t=s.toLowerCase();return t==="pass"?"pass":t==="warn"?"warn":t==="fail"?"fail":"warn"}function U(s){return s.summary.failed>0?"fail":s.gates.results.some(t=>t.status==="warn")?"warn":"pass"}function ce(s){let t=s.filter(o=>o.status!=="skipped");if(t.length===0)return 100;let a=t.reduce((o,r)=>r.status==="pass"?o+1:r.status==="warn"?o+.6:o,0);return Math.round(a/t.length*100)}function ue(s){return s.executionError?["Re-run: npx rapidkit autopilot release --mode audit --json","Inspect .rapidkit/reports/autopilot-release-last-run.json for execution failure details"]:s.blockers.length>0?["Run: npx rapidkit doctor workspace --plan","Run: npx rapidkit readiness --json --strict","Run: npx rapidkit workspace run test --affected --strict"]:s.hasWarnings&&s.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx rapidkit autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function N(s,t){await W.promises.mkdir(g.dirname(s),{recursive:true}),await W.promises.writeFile(s,`${JSON.stringify(t,null,2)}
|
|
2
|
-
`,"utf-8");}async function ke(s){let t=le(s.workspacePath),a$1=s.mode,o=[],r=[],M,F,E,J=0,f=false,I=0,T=0,_=Date.now(),x=await S(["doctor","workspace","--json"],t),q=Date.now()-_,u="pass";if(x.crashed)u="fail",f=true,r.push(`doctor workspace execution error: ${x.stderr||"unknown error"}`);else if(x.exitCode!==0)u="fail",r.push("doctor workspace command failed");else {let e=b(x.stdout),i=e&&e.healthScore&&typeof e.healthScore=="object"?e.healthScore:{},l=Number(i.errors??0),c=Number(i.warnings??0);Number.isFinite(l)&&l>0?(u="fail",r.push(`doctor workspace reports ${l} error(s)`)):Number.isFinite(c)&&c>0&&(u="warn");}let L=o.push({name:"doctor-workspace",status:u,durationMs:q,summary:u==="pass"?"doctor workspace passed":u==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1;a$1==="enforce"&&u==="warn"&&r.push("doctor workspace reported warnings under enforce mode");let z=Date.now(),A=await S(["readiness","--json"],t),O=Date.now()-z,p="fail";if(A.crashed)p="fail",f=true,r.push(`readiness execution error: ${A.stderr||"unknown error"}`);else if(A.exitCode!==0)p="fail",r.push("readiness command failed");else {let e=b(A.stdout),i=String(e?.overallStatus??"fail");if(p=H(i),typeof e?.evidencePath=="string"&&e.evidencePath.trim().length>0&&(M=e.evidencePath),p==="fail"){let l=Array.isArray(e?.blockingReasons)?e?.blockingReasons.filter(c=>typeof c=="string"):[];l.length>0?r.push(...l.map(c=>`readiness: ${c}`)):r.push("readiness overall status is fail");}}let V=o.push({name:"readiness",status:p,durationMs:O,summary:`readiness overall status is ${p}`})-1;a$1==="enforce"&&p==="warn"&&r.push("readiness reported warnings under enforce mode");let Q=Date.now(),v=await S(["doctor","workspace","--plan","--json"],t),X=Date.now()-Q,w="warn";if(v.crashed)w="fail",f=true,r.push(`doctor remediation plan execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)w="fail",r.push("doctor remediation plan command failed");else {let e=b(v.stdout),i=e&&e.remediationPlan&&typeof e.remediationPlan=="object"?e.remediationPlan:null,l=Number(i?.totalSteps??0),c=Number(i?.executableSteps??0);Number.isFinite(l)&&l>0&&(I=l),Number.isFinite(c)&&c>0&&(T=c),Number.isFinite(l)&&l===0?w="pass":w="warn";}if(o.push({name:"remediation-plan",status:w,durationMs:X,summary:w==="pass"?"no remediation steps required":"remediation steps available"}),a$1==="enforce"&&w==="warn"&&r.push("remediation plan has pending steps under enforce mode"),a$1==="safe-fix"){let e=Date.now(),i=await S(["doctor","workspace","--apply"],t),l=Date.now()-e,c=i.crashed||i.exitCode!==0?"fail":"pass";if(i.crashed)f=true,r.push(`doctor remediation apply execution error: ${i.stderr||"unknown error"}`);else if(c==="fail")r.push("doctor remediation apply failed");else {J=T>0?T:I>0?I:1;let $=await S(["doctor","workspace","--json"],t);if($.crashed)u="fail",f=true,r.push(`post-apply doctor execution error: ${$.stderr||"unknown error"}`);else if($.exitCode!==0)u="fail",r.push("post-apply doctor workspace command failed");else {let m=b($.stdout),C=m&&m.healthScore&&typeof m.healthScore=="object"?m.healthScore:{},R=Number(C.errors??0),y=Number(C.warnings??0);Number.isFinite(R)&&R>0?(u="fail",r.push(`post-apply doctor reports ${R} error(s)`)):Number.isFinite(y)&&y>0?u="warn":u="pass";}o[L].status=u,o[L].summary=`doctor workspace post-apply status is ${u}`;let D=await S(["readiness","--json"],t);if(D.crashed)p="fail",f=true,r.push(`post-apply readiness execution error: ${D.stderr||"unknown error"}`);else if(D.exitCode!==0)p="fail",r.push("post-apply readiness command failed");else {let m=b(D.stdout),C=String(m?.overallStatus??"fail");if(p=H(C),typeof m?.evidencePath=="string"&&m.evidencePath.trim().length>0&&(M=m.evidencePath),p==="fail"){let R=Array.isArray(m?.blockingReasons)?m?.blockingReasons.filter(y=>typeof y=="string"):[];R.length>0?r.push(...R.map(y=>`post-apply readiness: ${y}`)):r.push("post-apply readiness overall status is fail");}}o[V].status=p,o[V].summary=`readiness post-apply overall status is ${p}`;}o.push({name:"remediation-apply",status:c,durationMs:l,summary:c==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let Y=Date.now(),h="pass",k="workspace test/build completed for selected projects";try{let e=await a({workspacePath:t,stage:"test",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});F=g.join(t,".rapidkit","reports","autopilot-workspace-run-test.json"),await N(F,e);let i=U(e);if(i==="fail")h="fail",k="workspace test stage failed for selected projects",r.push("workspace run test failed for selected projects");else {i==="warn"&&(h="warn",k="workspace test stage completed with warnings",a$1==="enforce"&&r.push("workspace run test reported warnings under enforce mode"));let l=await a({workspacePath:t,stage:"build",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});E=g.join(t,".rapidkit","reports","autopilot-workspace-run-build.json"),await N(E,l);let c=U(l);c==="fail"?(h="fail",k="workspace build stage failed for selected projects",r.push("workspace run build failed for selected projects")):c==="warn"&&(h="warn",k="workspace test/build completed with warnings",a$1==="enforce"&&r.push("workspace run test/build reported warnings under enforce mode"));}}catch(e){h="fail",k="workspace test/build orchestration failed",f=true,r.push(`workspace run orchestration error: ${e instanceof Error?e.message:String(e)}`);}let Z=Date.now()-Y;o.push({name:"workspace-run-test-build",status:h,durationMs:Z,summary:k});let P=o.filter(e=>e.status==="warn").length,ee=o.filter(e=>e.status==="fail").length,B=a$1==="enforce"?o.some(e=>e.status==="warn"||e.status==="fail"):ee>0,j=[...new Set(r)],te=f||B?Math.max(1,j.length):0,se=ce(o),re=f||B?"blocked":P>0?"partial":"approved",oe=f?3:B?1:P>0?2:0,ae=ue({mode:a$1,executionError:f,blockers:j,hasWarnings:P>0}),G=g.join(t,".rapidkit","reports","autopilot-release-last-run.json"),d={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:t,mode:a$1,summary:{releaseScore:se,verdict:re,blockers:te,warnings:P,safeFixesApplied:J,manualActions:j.length,exitCode:oe},stages:o,blockingReasons:j,nextActions:ae,artifacts:{reportPath:G,readinessEvidencePath:M,workspaceRunTestPath:F,workspaceRunBuildPath:E}};if(await N(G,d),s.output&&await N(g.resolve(s.output),d),!s.json){console.log(n.bold.cyan(`
|
|
3
|
-
\u{1F680} RapidKit Autopilot Release
|
|
4
|
-
`)),console.log(n.bold(`Workspace: ${n.cyan(g.basename(t))}`)),console.log(n.gray(`Path: ${t}`)),console.log(n.white(`Mode: ${a$1}`)),console.log(n.white(`Verdict: ${d.summary.verdict==="approved"?n.green("approved"):d.summary.verdict==="partial"?n.yellow("partial"):n.red("blocked")}`)),console.log(n.white(`Release score: ${d.summary.releaseScore}`));for(let e of d.stages){let i=e.status==="pass"?n.green("PASS"):e.status==="warn"?n.yellow("WARN"):e.status==="skipped"?n.gray("SKIP"):n.red("FAIL");console.log(` - ${e.name}: ${i} ${e.summary} (${e.durationMs}ms)`);}if(d.blockingReasons.length>0){console.log(n.bold.red(`
|
|
5
|
-
Blocking reasons:`));for(let e of d.blockingReasons)console.log(n.red(` - ${e}`));}if(d.nextActions.length>0){console.log(n.bold(`
|
|
6
|
-
Next actions:`));for(let e of d.nextActions)console.log(n.gray(` - ${e}`));}console.log(n.gray(`
|
|
7
|
-
Report: ${d.artifacts.reportPath}`));}return d}export{ke as runAutopilotRelease};
|
package/dist/chunk-W62Q2D3K.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {f,e,d,a as a$1,c,g as g$1}from'./chunk-Z5LKRG57.js';import {a}from'./chunk-2FIX2MDC.js';import ut from'crypto';import X from'os';import u from'path';import*as p from'fs-extra';import {execa}from'execa';var pt=["version","project","create","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],V=new Set(pt);var g=a();function S(){let t=[],e$1=i=>{let o=i?.trim();o&&t.push(o);};e$1(process.env.RAPIDKIT_BRIDGE_PYTHON),e$1(process.env.RAPIDKIT_PYTHON_CMD),e$1(process.env.POETRY_PYTHON);let r=_();(r.startsWith("/")||r.startsWith(".")||r.startsWith(".."))&&!r.startsWith("file:")&&e$1(f(u.join(u.resolve(r),".venv")));for(let i of e())i.args.length===1&&i.args[0]==="--version"&&e$1(i.command);for(let i of d())e$1(i);return [...new Set(t)]}function v(t,e){return t==="py"?["-3",...e]:e}function K(t){if(!t)return t;let e=["Installed Poetry version does not support '--no-update'. Falling back to 'poetry lock'."];return t.split(/\r?\n/).filter(i=>!e.some(o=>i.includes(o))).join(`
|
|
2
|
-
`)}var w=class extends Error{code;constructor(e,r){super(r),this.code=e;}};function D(t){if(t instanceof w)switch(t.code){case "PYTHON_NOT_FOUND":return `RapidKit (npm) could not find Python (python3/python/py) on your PATH.
|
|
3
|
-
Install Python 3.10+ and ensure \`${c()}\` is available, then retry.
|
|
4
|
-
Tip: if you are inside a RapidKit project, use the local ./rapidkit launcher.`;case "BRIDGE_VENV_CREATE_FAILED":return `RapidKit (npm) failed to create its bridge virtual environment.
|
|
5
|
-
`+(a$1()?`Ensure Python is installed with venv support.
|
|
6
|
-
`:`Ensure Python venv support is installed (e.g., python3-venv).
|
|
7
|
-
`)+`Details: ${t.message}`;case "BRIDGE_PIP_BOOTSTRAP_FAILED":return `RapidKit (npm) could not bootstrap pip inside the bridge virtual environment.
|
|
8
|
-
`+(a$1()?`Ensure pip is available for your Python installation and retry.
|
|
9
|
-
`:`Install python3-venv/python3-pip and retry.
|
|
10
|
-
`)+`Details: ${t.message}`;case "BRIDGE_PIP_UPGRADE_FAILED":return `RapidKit (npm) could not upgrade pip in the bridge virtual environment.
|
|
11
|
-
Check your network/proxy or disable RAPIDKIT_BRIDGE_UPGRADE_PIP.
|
|
12
|
-
Details: ${t.message}`;case "BRIDGE_PIP_INSTALL_FAILED":return `RapidKit (npm) could not install rapidkit-core in the bridge virtual environment.
|
|
13
|
-
Check your network/proxy, or install manually with: pipx install rapidkit-core.
|
|
14
|
-
Details: ${t.message}`;default:return `RapidKit (npm) bridge error: ${t.message}`}return `RapidKit (npm) failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function _(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function lt(){let t=_(),e=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,r=e&&e.trim()?`${t}|${e.trim()}`:t;return ut.createHash("sha256").update(r).digest("hex").slice(0,12)}function O(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:u.join(X.homedir(),".cache")}function mt(){return u.join(O(),"rapidkit","npm-bridge","venv")}function q(){let t=lt();return u.join(O(),"rapidkit","npm-bridge",`venv-${t}`)}function H(t){return f(t)}function Y(t){return g$1(t)}function Q(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function ft(t){return u.dirname(u.dirname(t))}function tt(){return u.join(O(),"rapidkit","npm-bridge","core-commands.json")}async function et(t){let e=!!process.env.RAPIDKIT_DEBUG,r=n=>{e&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${n}
|
|
15
|
-
`);};try{r("probing interpreter-specific rapidkit script");let i=((await execa(t,v(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"]),{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(r(`script path: ${i}`),i)try{if(await p.pathExists(i)){r(`found script at ${i}; invoking --version --json`);let o=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`script exitCode=${o.exitCode}`),o.exitCode===0){let s=(o.stdout??"").toString().trim();try{let a=JSON.parse(s),c=!!a&&typeof a=="object"&&a!==null&&"version"in a;if(r(`script JSON parse ok=${c}`),c)return true}catch{r("script output not valid JSON");}}}}catch(o){r(`interpreter-specific script probe failed: ${String(o)}`);}}catch(n){r(`interpreter-specific script probe error: ${String(n)}`);}try{r('probing importlib.find_spec("rapidkit")');let n=await execa(t,v(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"]),{reject:false,stdio:"pipe",timeout:2e3});if(r(`import probe exitCode=${n.exitCode} stdout=${(n.stdout??"").toString().trim()}`),n.exitCode===0&&(n.stdout??"").toString().trim()==="1")return true}catch(n){r(`import probe error: ${String(n)}`);}try{r("probing python -m rapidkit");let n=await execa(t,v(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(r(`-m probe exitCode=${n.exitCode}`),n.exitCode===0)return true}catch(n){r(`-m probe error: ${String(n)}`);}try{r("probing PATH for rapidkit executables");let n=(process.env.PATH??"").split(u.delimiter).filter(Boolean);for(let i of n){let o=u.join(i,a$1()?"rapidkit.exe":"rapidkit");try{if(await p.pathExists(o)){r(`found candidate on PATH: ${o}; invoking --version --json`);let s=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`candidate exitCode=${s.exitCode}`),s.exitCode===0){let a=(s.stdout??"").toString().trim();try{let c=JSON.parse(a);if(c&&typeof c=="object"&&c!==null&&"version"in c)return true}catch{r("candidate output not valid JSON, skipping");}}}}catch(s){r(`error probing candidate ${o}: ${String(s)}`);}}return r("no valid rapidkit found on PATH"),false}catch(n){return r(`PATH probe error: ${String(n)}`),false}}async function M(t){let e=(t??"").toString().trim();if(!e)return false;try{let r=JSON.parse(e);return !!r&&typeof r=="object"&&r!==null&&"version"in r}catch{return false}}async function ht(t){let e=u.relative(".",g$1(".venv")),r=u.relative(".",f(".venv")),n=t;for(let i=0;i<25;i+=1){let o=u.join(n,e);if(await p.pathExists(o)){let c=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:n});if(c.exitCode===0&&await M(c.stdout))return {cmd:o,baseArgs:[]}}let s=u.join(n,r);if(await p.pathExists(s)){let c=await execa(s,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:n});if(c.exitCode===0&&await M(c.stdout))return {cmd:s,baseArgs:["-m","rapidkit"]}}let a=u.dirname(n);if(a===n)break;n=a;}return null}async function gt(t){try{let e=u.join(t,".python-version");if(await p.pathExists(e)){let n=(await p.readFile(e,"utf-8")).trim();if(n)return n}}catch{}try{let e=u.join(t,".rapidkit-workspace");if(await p.pathExists(e)){let r=await p.readFile(e,"utf-8"),n=JSON.parse(r);if(n.pythonVersion)return n.pythonVersion}}catch{}return null}async function F(t){if(t&&t.trim())try{let o=await ht(t);if(o){let s=u.dirname(o.cmd).includes(".venv")?u.dirname(u.dirname(u.dirname(o.cmd))):u.dirname(o.cmd),a=await gt(s);return a&&(process.env.PYENV_VERSION=a),o}}catch{}let e=await Et();if(e.kind==="venv"){let o=ft(e.pythonPath),s=Y(o);return await p.pathExists(s)?{cmd:s,baseArgs:[]}:{cmd:e.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(e.cmd,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:e.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let s=((await execa(e.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(s&&await p.pathExists(s))try{let a=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(a.exitCode===0&&await M(a.stdout))return {cmd:s,baseArgs:[]}}catch{}}catch{}let r=q(),n=await j(e.cmd),i=Y(r);return await p.pathExists(i)?{cmd:i,baseArgs:[]}:{cmd:n,baseArgs:["-m","rapidkit"]}}async function nt(){for(let t of S())try{return await execa(t,v(t,["--version"]),{reject:false,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function B(){let t=null;for(let e of S()){try{await execa(e,v(e,["--version"]),{reject:false,stdio:"pipe",timeout:2e3});}catch(r){t=r;continue}try{return await j(e)}catch(r){t=r;continue}}throw t instanceof w?t:t instanceof Error?new w("BRIDGE_VENV_BOOTSTRAP_FAILED",t.message):new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).")}async function yt(){let t=!!process.env.RAPIDKIT_DEBUG,e$1=n=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${n}
|
|
16
|
-
`);},r=Array.from(new Set([...d(),...e(14,10).map(n=>n.command)]));for(let n of r)try{e$1(`Method 1: trying ${n} import`);let i=await execa(n,v(n,["-c","import rapidkit_core; print(1)"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.trim()==="1")return e$1(`\u2713 Found via ${n} import`),true}catch{continue}for(let n of r)try{e$1(`Method 2: trying ${n} -m pip show`);let i=await execa(n,v(n,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found via ${n} -m pip show`),true}catch{continue}for(let n of ["pip","pip3"])try{e$1(`Method 3: trying ${n} show`);let i=await execa(n,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found via ${n} show`),true}catch{continue}try{e$1("Method 4: checking pyenv versions");let n=await execa("pyenv",["versions","--bare"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout){let i=n.stdout.split(`
|
|
17
|
-
`).filter(o=>o.trim());e$1(`Found pyenv versions: ${i.join(", ")}`);for(let o of i){let s=process.env.PYENV_ROOT||u.join(X.homedir(),".pyenv"),a=u.join(s,"versions",o.trim(),"bin","pip");try{let c=await execa(a,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found in pyenv ${o}`),true}catch{try{let c=await execa("pyenv",["exec","pip","show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g,env:{...process.env,PYENV_VERSION:o.trim()}});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found in pyenv ${o} via PYENV_VERSION`),true}catch{continue}}}}}catch{e$1("pyenv not available");}for(let n of r)try{e$1(`Method 5: checking ${n} user site`);let i=await execa(n,v(n,["-m","site","--user-site"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout){let o=i.stdout.trim(),s=u.join(o,"rapidkit_core");if(await p.pathExists(s))return e$1("\u2713 Found in user site-packages"),true}}catch{continue}try{e$1("Method 6: checking pipx");let n=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout?.includes("rapidkit-core"))return e$1("\u2713 Found via pipx"),true}catch{e$1("pipx not available");}for(let n of r)try{e$1(`Method 6: checking ${n} -m pipx list`);let i=await execa(n,v(n,["-m","pipx","list"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("rapidkit-core"))return e$1(`\u2713 Found via ${n} -m pipx list`),true}catch{continue}try{if(e$1("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g})).exitCode===0)return e$1("\u2713 Found via poetry"),true}catch{e$1("poetry check failed");}for(let n of r)try{if(e$1(`Method 7: checking ${n} -m poetry show rapidkit-core`),(await execa(n,v(n,["-m","poetry","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g})).exitCode===0)return e$1(`\u2713 Found via ${n} -m poetry`),true}catch{continue}try{e$1("Method 8: checking conda");let n=await execa("conda",["list","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout?.includes("rapidkit-core"))return e$1("\u2713 Found via conda"),true}catch{e$1("conda not available");}return e$1("\u2717 Not found in any environment"),false}function wt(t){let e=t.trim();if(!e||!e.startsWith("rapidkit-core"))return null;let r=e.slice(13).trim();return !r||/[\/@]|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(r)?null:r}function J(t){let e=t.trim();if(!e)return null;let r=e.split("."),n=[];for(let i of r){let o=i.match(/^(\d+)/);if(!o){n.push(0);continue}n.push(Number.parseInt(o[1],10));}return n}function U(t,e){let r=Math.max(t.length,e.length);for(let n=0;n<r;n+=1){let i=n<t.length?t[n]:0,o=n<e.length?e[n]:0;if(i>o)return 1;if(i<o)return -1}return 0}function vt(t){return t.length<=1?[t[0]+1]:t.length===2?[t[0]+1,0]:[t[0],t[1]+1,0]}function Ct(t){let e=t.split(",").map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;let r=[];for(let n of e){let i=n.match(/^(==|>=|<=|>|<|~=)\s*([0-9][0-9A-Za-z+._-]*)$/);if(!i)return null;r.push({op:i[1],version:i[2]});}return r}function rt(t,e){let r=J(t);if(!r)return false;let n=Ct(e);if(!n)return false;for(let i of n){let o=J(i.version);if(!o)return false;let s=U(r,o);if(i.op==="=="&&s!==0||i.op===">="&&s<0||i.op==="<="&&s>0||i.op===">"&&s<=0||i.op==="<"&&s>=0)return false;if(i.op==="~="){if(s<0)return false;let a=vt(o);if(U(r,a)>=0)return false}}return true}async function Pt(){let t=Array.from(new Set([...d(),...e(14,10).map(r=>r.command)])),e$1=r=>{let n=r.match(/^Version:\s*(.+)$/m);return n?n[1].trim():null};for(let r of t)try{let n=await execa(r,v(r,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0){let i=e$1(n.stdout||"");if(i)return i}}catch{continue}for(let r of ["pip","pip3"])try{let n=await execa(r,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0){let i=e$1(n.stdout||"");if(i)return i}}catch{continue}try{let r=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:g});if(r.exitCode===0&&r.stdout){let n=r.stdout.match(/rapidkit-core\s+([0-9][0-9A-Za-z+._-]*)/i);if(n?.[1])return n[1]}}catch{}return null}async function _t(){let t=_(),e=wt(t);if(!e)return {isCompatible:false,installedVersion:null,expectedConstraint:null,reason:Q(t)?"constraint-unsupported":"constraint-missing"};let r=await Pt();if(!r)return {isCompatible:false,installedVersion:null,expectedConstraint:e,reason:"version-not-detected"};let n=rt(r,e);return {isCompatible:n,installedVersion:r,expectedConstraint:e,reason:n?"compatible":"incompatible-version"}}async function j(t){let e=q(),r=mt(),n=_(),i=[e];!Q(n)&&!await p.pathExists(e)&&await p.pathExists(r)&&i.push(r);for(let l of i){let h=H(l);if(await p.pathExists(h))try{let f=await execa(h,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:false,stdio:"pipe",timeout:2e3});if(f.exitCode===0&&(f.stdout??"").toString().trim()==="1")return h;await p.remove(l);}catch{await p.remove(l);}}let o=e,s={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},a=Math.max(0,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY??"2")),c=Math.max(200,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY_DELAY_MS??"800")),m=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),C=l=>new Promise(h=>setTimeout(h,l)),P=async(l,h,f)=>{let y=await execa(l,h,{reject:false,stdio:["ignore","pipe","inherit"],env:s,timeout:f});if(y.exitCode===0)return;let T=(y.stdout??"").toString(),N=(y.stderr??"").toString(),x=[T,N].filter(Boolean).join(`
|
|
18
|
-
`),at=x?`${l} ${h.join(" ")}
|
|
19
|
-
${x}`:`${l} ${h.join(" ")}`;throw new Error(at)},k=async(l,h,f)=>{let y=0;for(;;)try{await P(l,h,f);return}catch(T){if(y>=a)throw T;let N=Math.floor(Math.random()*200),x=c*Math.pow(2,y)+N;y+=1,await C(x);}};try{await p.ensureDir(u.dirname(o));try{await P(t,v(t,["-m","venv",o]),6e4);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_VENV_CREATE_FAILED",y)}let l=H(o);if((await execa(l,["-m","pip","--version"],{reject:false,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(l,["-m","ensurepip","--default-pip"],{reject:false,stdio:["ignore","pipe","inherit"],env:s,timeout:6e4})).exitCode!==0)throw new w("BRIDGE_PIP_BOOTSTRAP_FAILED","ensurepip failed; install python3-venv/python3-pip and retry.");if(process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1")try{await k(l,["-m","pip","install","-U","pip"],m);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_PIP_UPGRADE_FAILED",y)}try{await k(l,["-m","pip","install","-U",_()],m);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_PIP_INSTALL_FAILED",y)}return l}catch(l){if(l instanceof w)throw l;let h=l instanceof Error?l.message:String(l);throw new w("BRIDGE_VENV_BOOTSTRAP_FAILED",h)}}async function Et(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1")return {kind:"venv",pythonPath:await B()};for(let r of S())if(await et(r))return {kind:"system",cmd:r};let t=await nt();if(!t)throw new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");let e;try{e=await j(t);}catch{e=await B();}return {kind:"venv",pythonPath:e}}async function Vt(t,e){try{let r=await F(e?.cwd),n=r.cmd,i=[...r.baseArgs,...t];if(t[0]==="init"){let a=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"}),c=K((a.stdout??"").toString()),m=K((a.stderr??"").toString());return c&&process.stdout.write(c.endsWith(`
|
|
20
|
-
`)?c:`${c}
|
|
21
|
-
`),m&&process.stderr.write(m.endsWith(`
|
|
22
|
-
`)?m:`${m}
|
|
23
|
-
`),typeof a.exitCode=="number"?a.exitCode:1}let s=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"inherit"});return typeof s.exitCode=="number"?s.exitCode:1}catch(r){return process.stderr.write(`${D(r)}
|
|
24
|
-
`),1}}var kt=[{pattern:/RapidKitError:\s*Directory '([^']+)' exists and force is not set/,message:t=>`\u274C Directory "${u.basename(t[1])}" already exists.
|
|
25
|
-
\u{1F4A1} Choose a different name, or remove the existing directory first:
|
|
26
|
-
rm -rf ${t[1]}`},{pattern:/RapidKitError:\s*Project name '([^']+)' is (invalid|not allowed)/i,message:t=>`\u274C Invalid project name: "${t[1]}"
|
|
27
|
-
\u{1F4A1} Use lowercase letters, numbers, and hyphens only (e.g. my-api).`},{pattern:/RapidKitError:\s*Kit '([^']+)' not found/i,message:t=>`\u274C Unknown kit: "${t[1]}"
|
|
28
|
-
\u{1F4A1} Run "npx rapidkit list" to see available kits.`},{pattern:/RapidKitError:\s*(.+)/,message:t=>`\u274C ${t[1].trim()}`}];async function Mt(t,e){let{spawn:r}=await import('child_process');try{let n=await F(e?.cwd),i=n.cmd,o=[...n.baseArgs,...t];return await new Promise(s=>{let a=r(i,o,{cwd:e?.cwd,env:{...process.env,...e?.env},stdio:["inherit","inherit","pipe"]}),c=[];a.stderr?.on("data",m=>{c.push(m);}),a.on("close",m=>{let C=m??1;if(C!==0&&c.length>0){let P=Buffer.concat(c).toString("utf8");for(let{pattern:k,message:l}of kt){let h=P.match(k);if(h){process.stderr.write(l(h)+`
|
|
29
|
-
`),s(C);return}}process.stderr.write(P);}s(C);}),a.on("error",m=>{process.stderr.write(`${D(m)}
|
|
30
|
-
`),s(1);});})}catch(n){return process.stderr.write(`${D(n)}
|
|
31
|
-
`),1}}async function E(t,e){try{let r=await F(e?.cwd),n=r.cmd,i=[...r.baseArgs,...t],o=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"});return {exitCode:typeof o.exitCode=="number"?o.exitCode:1,stdout:(o.stdout??"").toString(),stderr:(o.stderr??"").toString()}}catch(r){return {exitCode:1,stdout:"",stderr:`${D(r)}
|
|
32
|
-
`}}}function it(t){let e=new Set,r=t.split(`
|
|
33
|
-
`),n=false;for(let i of r){let o=i.replace(/\r$/,"");if(!n){/^\s*Commands:\s*$/i.test(o)&&(n=true);let c=o.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let m=c[1].trim();m&&!m.startsWith("-")&&e.add(m);}continue}if(!o.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(o))continue;let s=o.match(/^\s*([a-z0-9][a-z0-9_-]*)\b/i);if(!s)continue;let a=s[1].trim();a&&!a.startsWith("-")&&e.add(a);}return e}async function ot(){let t=tt();if(!await p.pathExists(t))return null;try{let e=await p.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.commands))return e}catch{}return null}async function W(t){let e=tt();await p.ensureDir(u.dirname(e)),await p.writeJson(e,t,{spaces:2});}async function xt(){let t=await E(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let r=JSON.parse(t.stdout)?.version;return typeof r=="string"?r:void 0}catch{return}}async function Rt(){let t=await E(["commands","--json"],{cwd:process.cwd()});if(t.exitCode!==0)return null;try{let e=JSON.parse(t.stdout);if(e?.schema_version!==1||!Array.isArray(e.commands))return null;let r=e.commands.filter(n=>typeof n=="string");return r.length?r:null}catch{return null}}async function Bt(){let e=Date.now(),r=await ot(),n=await xt(),i=!!r?.commands?.length;if(i&&e-r.fetched_at<864e5&&(!n||!r.rapidkit_version||r.rapidkit_version===n))return new Set(r.commands);let o=await Rt();if(o?.length){let m=Array.from(new Set(o)).sort();return await W({schema_version:1,fetched_at:e,rapidkit_version:n,commands:m}),new Set(m)}let s=await E(["--help"],{cwd:process.cwd()});if(s.exitCode!==0)return i&&r?.commands?new Set(r.commands):new Set(V);let a=it(s.stdout);if(a.size===0)return new Set(V);let c=Array.from(a).sort();return await W({schema_version:1,fetched_at:e,rapidkit_version:n,commands:c}),a}async function Ft(){let e=Date.now(),r=await ot();return !r||e-r.fetched_at>=864e5||!r.commands?.length?null:new Set(r.commands)}function st(){return u.join(O(),"rapidkit","npm-bridge","modules-catalog.json")}async function bt(){let t=st();if(!await p.pathExists(t))return null;try{let e=await p.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.modules))return e}catch{}return null}async function z(t){let e=st();await p.ensureDir(u.dirname(e)),await p.writeJson(e,t,{spaces:2});}function Z(t){try{return JSON.parse(t)}catch{return null}}async function Gt(t={}){let e=typeof t.ttlMs=="number"?t.ttlMs:18e5,r=Date.now(),n=await bt();if(n?.fetched_at&&r-n.fetched_at<e)return n;let i=["modules","list","--json-schema","1"];t.category&&i.push("--category",t.category),t.tag&&i.push("--tag",t.tag),t.detailed&&i.push("--detailed");let o=await E(i,{cwd:t.cwd,env:t.env});if(o.exitCode===0){let a=Z(o.stdout);if(a&&a.schema_version===1&&Array.isArray(a.modules)){let c={...a,fetched_at:r};return await z(c),c}}let s=await E(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(s.exitCode===0){let a=Z(s.stdout);if(Array.isArray(a)){let c={schema_version:1,generated_at:new Date().toISOString(),filters:{category:t.category??null,tag:t.tag??null,detailed:!!t.detailed},stats:{total:a.length,returned:a.length,invalid:0},modules:a,source:"legacy-json",fetched_at:r};return await z(c),c}}return n||null}var Lt={pythonCommandCandidates:S,pickSystemPython:nt,ensureBridgeVenv:j,ensureBridgeVenvFromCandidates:B,parseCoreCommandsFromHelp:it,tryRapidkit:et,checkRapidkitCoreAvailable:yt,checkRapidkitCoreVersionCompatible:_t,isVersionSatisfyingConstraint:rt};export{V as a,yt as b,_t as c,Et as d,Vt as e,Mt as f,E as g,Bt as h,Ft as i,Gt as j,Lt as k};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as runWorkspaceStage}from'./chunk-BDJHZ3XW.js';
|
|
File without changes
|