rapidkit 0.27.5 → 0.27.6

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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.27.5",
3
+ "version": "0.27.6",
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": [
@@ -33,6 +33,10 @@
33
33
  "dist",
34
34
  "scripts/enforce-package-manager.cjs"
35
35
  ],
36
+ "publishConfig": {
37
+ "registry": "https://registry.npmjs.org",
38
+ "access": "public"
39
+ },
36
40
  "scripts": {
37
41
  "preinstall": "node scripts/enforce-package-manager.cjs",
38
42
  "sync-kits": "bash scripts/sync-kits.sh",
@@ -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-RWV2GNJJ.js';
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-BFCIY2QK.js';
@@ -1,4 +1,4 @@
1
- import {b as b$1,c as c$1}from'./chunk-U7XJZHU6.js';import {b}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import c from'path';import n from'chalk';import R from'ora';import {execa}from'execa';var y="21",$="3.5.0",j="2.8.9";function u(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,".").replace(/^\.+|\.+$/g,"").replace(/\.{2,}/g,".").split(".").map(p=>p.replace(/^[^a-z]+/,"").replace(/[^a-z0-9]/g,"")).filter(Boolean).join(".")}function _(e,t){return e.replace(/[\r\n\t]+/g," ").trim()||t}function x(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-")}function M(e,t){let s=u(e)||"com.rapidkit.apps",p=u(t)||"service";return `${s}.${p}`}function E(e){return e.replace(/\./g,"/")}function T(){return JSON.stringify({engine:"npm",runtime:"java"},null,2)}function A(e,t){return JSON.stringify({kit_name:"springboot.standard",runtime:"java",module_support:false,project_name:e.project_name,artifact_id:e.artifact_id,group_id:e.group_id,package_name:e.package_name,app_version:e.app_version,created_by:"rapidkit-npm",rapidkit_version:t,created_at:new Date().toISOString()},null,2)}function P(e){return `<?xml version="1.0" encoding="UTF-8"?>
1
+ import {b as b$1,c as c$1}from'./chunk-U7XJZHU6.js';import {b}from'./chunk-AC6KIKII.js';import {promises}from'fs';import c from'path';import n from'chalk';import R from'ora';import {execa}from'execa';var y="21",$="3.5.0",j="2.8.9";function u(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,".").replace(/^\.+|\.+$/g,"").replace(/\.{2,}/g,".").split(".").map(p=>p.replace(/^[^a-z]+/,"").replace(/[^a-z0-9]/g,"")).filter(Boolean).join(".")}function _(e,t){return e.replace(/[\r\n\t]+/g," ").trim()||t}function x(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-")}function M(e,t){let s=u(e)||"com.rapidkit.apps",p=u(t)||"service";return `${s}.${p}`}function E(e){return e.replace(/\./g,"/")}function T(){return JSON.stringify({engine:"npm",runtime:"java"},null,2)}function A(e,t){return JSON.stringify({kit_name:"springboot.standard",runtime:"java",module_support:false,project_name:e.project_name,artifact_id:e.artifact_id,group_id:e.group_id,package_name:e.package_name,app_version:e.app_version,created_by:"rapidkit-npm",rapidkit_version:t,created_at:new Date().toISOString()},null,2)}function P(e){return `<?xml version="1.0" encoding="UTF-8"?>
2
2
  <project xmlns="http://maven.apache.org/POM/4.0.0"
3
3
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
4
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -1,6 +1,6 @@
1
- import {c}from'./chunk-NFUXULIF.js';import {j as j$1}from'./chunk-Z5LKRG57.js';import {b as b$1}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import n from'path';import a from'chalk';import b from'ora';import {execa}from'execa';function j(e){let t=n.resolve(e);return process.platform==="win32"?t.toLowerCase():t}function A(e){let t=j(e.path),r=Array.isArray(e.projects)?e.projects:[],o=[],i=new Set;for(let s of r){if(!s||typeof s.name!="string"||typeof s.path!="string")continue;let c=j(s.path);i.has(c)||(i.add(c),o.push({name:s.name,path:c}));}return {name:e.name,path:t,mode:e.mode,projects:o}}function x(e){let t=[],r=new Set;for(let o of e.workspaces||[]){if(!o||typeof o.name!="string"||typeof o.path!="string")continue;let i=A(o);r.has(i.path)||(r.add(i.path),t.push(i));}return {workspaces:t}}async function F(e,t){try{let r=j(e),o=j$1(),i=n.join(o,"workspaces.json");await promises.mkdir(o,{recursive:true});let s={workspaces:[]};try{let p=await promises.readFile(i,"utf8"),d=JSON.parse(p);d&&Array.isArray(d.workspaces)&&(s=x(d));}catch{}s.workspaces.some(p=>p.path===r)||(s.workspaces.push({name:t,path:r,mode:"full",projects:[]}),await promises.writeFile(i,JSON.stringify(s,null,2)));}catch{console.warn(a.gray("Note: Could not register workspace in shared registry"));}}async function te(e,t=false){try{let r=j(e),o=j$1(),i=n.join(o,"workspaces.json"),s={workspaces:[]};try{let g=await promises.readFile(i,"utf8"),k=JSON.parse(g);k&&Array.isArray(k.workspaces)&&(s=x(k));}catch{t||console.log("\u26A0\uFE0F Workspace registry not found");return}let c=s.workspaces.find(g=>g.path===r);if(!c){t||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(c.projects)||(c.projects=[]);let p=0,d=0,u=[e],m=new Set;for(;u.length>0;){let g=u.shift();if(!g||m.has(g))continue;m.add(g);let k=await promises.readdir(g,{withFileTypes:true});for(let y of k){if(!y.isDirectory()||y.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(y.name))continue;let f=n.join(g,y.name),h=j(f),v=n.join(h,".rapidkit","context.json"),E=n.join(h,".rapidkit","project.json");try{let _=false;try{await promises.access(v),_=true;}catch{await promises.access(E),_=true;}if(_){let $=n.basename(h);c.projects.some(R=>R.path===h||R.name===$)?d++:(c.projects.push({name:$,path:h}),p++,t||console.log(`\u2714 Added: ${n.relative(e,h)}`));continue}}catch{}u.push(f);}}p>0?(await promises.writeFile(i,JSON.stringify(s,null,2)),t||console.log(`
1
+ import {a as a$1}from'./chunk-VKLL63TL.js';import {c}from'./chunk-NFUXULIF.js';import {j as j$1}from'./chunk-Z5LKRG57.js';import {b as b$1}from'./chunk-AC6KIKII.js';import {promises}from'fs';import a from'path';import i from'chalk';import b from'ora';import {execa}from'execa';function j(e){let t=a.resolve(e);return process.platform==="win32"?t.toLowerCase():t}function A(e){let t=j(e.path),r=Array.isArray(e.projects)?e.projects:[],o=[],n=new Set;for(let s of r){if(!s||typeof s.name!="string"||typeof s.path!="string")continue;let c=j(s.path);n.has(c)||(n.add(c),o.push({name:s.name,path:c}));}return {name:e.name,path:t,mode:e.mode,projects:o}}function x(e){let t=[],r=new Set;for(let o of e.workspaces||[]){if(!o||typeof o.name!="string"||typeof o.path!="string")continue;let n=A(o);r.has(n.path)||(r.add(n.path),t.push(n));}return {workspaces:t}}async function F(e,t){try{let r=j(e),o=j$1(),n=a.join(o,"workspaces.json");await promises.mkdir(o,{recursive:true});let s={workspaces:[]};try{let p=await promises.readFile(n,"utf8"),d=JSON.parse(p);d&&Array.isArray(d.workspaces)&&(s=x(d));}catch{}s.workspaces.some(p=>p.path===r)||(s.workspaces.push({name:t,path:r,mode:"full",projects:[]}),await promises.writeFile(n,JSON.stringify(s,null,2)));}catch{console.warn(i.gray("Note: Could not register workspace in shared registry"));}}async function re(e,t=false){try{let r=j(e),o=j$1(),n=a.join(o,"workspaces.json"),s={workspaces:[]};try{let g=await promises.readFile(n,"utf8"),f=JSON.parse(g);f&&Array.isArray(f.workspaces)&&(s=x(f));}catch{t||console.log("\u26A0\uFE0F Workspace registry not found");return}let c=s.workspaces.find(g=>g.path===r);if(!c){t||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(c.projects)||(c.projects=[]);let p=0,d=0,u=[e],m=new Set;for(;u.length>0;){let g=u.shift();if(!g||m.has(g))continue;m.add(g);let f=await promises.readdir(g,{withFileTypes:true});for(let y of f){if(!y.isDirectory()||y.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(y.name))continue;let k=a.join(g,y.name),h=j(k),v=a.join(h,".rapidkit","context.json"),E=a.join(h,".rapidkit","project.json");try{let _=false;try{await promises.access(v),_=true;}catch{await promises.access(E),_=true;}if(_){let $=a.basename(h);c.projects.some(R=>R.path===h||R.name===$)?d++:(c.projects.push({name:$,path:h}),p++,t||console.log(`\u2714 Added: ${a.relative(e,h)}`));continue}}catch{}u.push(k);}}p>0?(await promises.writeFile(n,JSON.stringify(s,null,2)),t||console.log(`
2
2
  \u2705 Synced ${p} project(s) to registry`)):t||console.log(`
3
- \u2705 All projects already registered (${d} found)`);}catch(r){t||console.error("\u274C Failed to sync projects:",r.message);}}async function re(e,t,r){try{let o=j(e),i=j(r),s=j$1(),c=n.join(s,"workspaces.json"),p={workspaces:[]};try{let m=await promises.readFile(c,"utf8"),g=JSON.parse(m);g&&Array.isArray(g.workspaces)&&(p=x(g));}catch{return}let d=p.workspaces.find(m=>m.path===o);if(!d)return;Array.isArray(d.projects)||(d.projects=[]),d.projects.some(m=>m.path===i||m.name===t)||(d.projects.push({name:t,path:i}),await promises.writeFile(c,JSON.stringify(p,null,2)));}catch{}}async function ie(e,t){let r=b("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(n.join(e,".rapidkit"),{recursive:true});let o={workspace_name:t.name,author:t.author,rapidkit_version:b$1(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(n.join(e,".rapidkit","config.json"),JSON.stringify(o,null,2));let{syncWorkspaceFoundationFiles:i}=await import('./create-4NQKTQ3C.js');await i(e,{workspaceName:t.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let s=O();await promises.writeFile(n.join(e,"rapidkit"),s),await promises.chmod(n.join(e,"rapidkit"),493);let c=B();await promises.writeFile(n.join(e,"rapidkit.cmd"),c);let p=T(t.name);if(await promises.writeFile(n.join(e,"README.md"),p),await promises.writeFile(n.join(e,".gitignore"),`# RapidKit workspace
3
+ \u2705 All projects already registered (${d} found)`);}catch(r){t||console.error("\u274C Failed to sync projects:",r.message);}}async function ie(e,t,r){try{let o=j(e),n=j(r),s=j$1(),c=a.join(s,"workspaces.json"),p={workspaces:[]};try{let m=await promises.readFile(c,"utf8"),g=JSON.parse(m);g&&Array.isArray(g.workspaces)&&(p=x(g));}catch{return}let d=p.workspaces.find(m=>m.path===o);if(!d)return;Array.isArray(d.projects)||(d.projects=[]),d.projects.some(m=>m.path===n||m.name===t)||(d.projects.push({name:t,path:n}),await promises.writeFile(c,JSON.stringify(p,null,2)));}catch{}}async function oe(e,t){let r=b("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(a.join(e,".rapidkit"),{recursive:true});let o={workspace_name:t.name,author:t.author,rapidkit_version:b$1(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(a.join(e,".rapidkit","config.json"),JSON.stringify(o,null,2));let{syncWorkspaceFoundationFiles:n}=await import('./create-TWGGH5XC.js');await n(e,{workspaceName:t.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let s=O();await promises.writeFile(a.join(e,"rapidkit"),s),await promises.chmod(a.join(e,"rapidkit"),493);let c=B();await promises.writeFile(a.join(e,"rapidkit.cmd"),c);let p=T(t.name);if(await promises.writeFile(a.join(e,"README.md"),p),await promises.writeFile(a.join(e,".gitignore"),`# RapidKit workspace
4
4
  .env
5
5
  .env.*
6
6
  !.env.example
@@ -15,10 +15,10 @@ Thumbs.db
15
15
 
16
16
  # Logs
17
17
  *.log
18
- `),await promises.writeFile(n.join(e,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:b$1(),createdAt:new Date().toISOString(),name:t.name},null,2)),await z(e),r.succeed("Workspace created!"),!t.skipGit){let u=b("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),u.succeed("Git repository initialized");}catch{u.warn("Could not initialize git repository");}}await F(e,t.name),console.log(`
19
- ${a.green("\u2728 RapidKit workspace created successfully!")}
18
+ `),await promises.writeFile(a.join(e,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:b$1(),createdAt:new Date().toISOString(),name:t.name},null,2)),await z(e),r.succeed("Workspace created!"),!t.skipGit){let u=b("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),u.succeed("Git repository initialized");}catch{u.warn("Could not initialize git repository");}}await F(e,t.name),console.log(`
19
+ ${i.green("\u2728 RapidKit workspace created successfully!")}
20
20
 
21
- ${a.bold("\u{1F4C2} Workspace structure:")}
21
+ ${i.bold("\u{1F4C2} Workspace structure:")}
22
22
  ${e}/
23
23
  \u251C\u2500\u2500 rapidkit # Local CLI wrapper
24
24
  \u251C\u2500\u2500 rapidkit.cmd # Windows local CLI wrapper
@@ -30,28 +30,28 @@ ${e}/
30
30
  \u2502 \u2514\u2500\u2500 config.json # Legacy compatibility metadata
31
31
  \u2514\u2500\u2500 README.md
32
32
 
33
- ${a.bold("\u{1F680} Get started:")}
34
- ${a.cyan(`cd ${t.name}`)}
35
- ${a.cyan("npx rapidkit my-api --template fastapi")}
36
- ${a.cyan("cd my-api")}
37
- ${a.cyan("npx rapidkit init")}
38
- ${a.cyan("npx rapidkit dev")}
33
+ ${i.bold("\u{1F680} Get started:")}
34
+ ${i.cyan(`cd ${t.name}`)}
35
+ ${i.cyan("npx rapidkit my-api --template fastapi")}
36
+ ${i.cyan("cd my-api")}
37
+ ${i.cyan("npx rapidkit init")}
38
+ ${i.cyan("npx rapidkit dev")}
39
39
 
40
- ${a.bold("\u{1F4E6} Available templates:")}
40
+ ${i.bold("\u{1F4E6} Available templates:")}
41
41
  fastapi - FastAPI + Python
42
42
  nestjs - NestJS + TypeScript
43
43
  springboot - Spring Boot + Java
44
44
  gofiber - Go Fiber
45
45
  gogin - Go Gin
46
46
 
47
- ${a.bold("\u{1F4DA} Commands:")}
47
+ ${i.bold("\u{1F4DA} Commands:")}
48
48
  npx rapidkit <name> --template <type> Create a new project
49
49
  npx rapidkit init Install dependencies
50
50
  npx rapidkit dev Start dev server
51
51
  npx rapidkit help Show all commands
52
52
 
53
- ${a.gray("Alternative: ./rapidkit dev (Windows: .\\rapidkit.cmd dev), make dev")}
54
- ${a.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
53
+ ${i.gray("Alternative: ./rapidkit dev (Windows: .\\rapidkit.cmd dev), make dev")}
54
+ ${i.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
55
55
  `);}catch(o){throw r.fail("Failed to create workspace"),o}}function O(){return `#!/usr/bin/env bash
56
56
  #
57
57
  # RapidKit CLI - Local workspace commands
@@ -480,7 +480,7 @@ npx rapidkit dev # Start dev server
480
480
 
481
481
  - [RapidKit Documentation](https://rapidkit.dev)
482
482
  - [GitHub Repository](https://github.com/Baziar/rapidkit)
483
- `}async function z(e){let{fileURLToPath:t}=await import('url'),r=t(import.meta.url),o=n.dirname(r),i=n.resolve(o,".."),s=n.join(i,"templates","kits"),c=n.join(e,".rapidkit","templates"),{default:p}=await import('fs-extra');await p.copy(s,c);let d=n.join(i,"templates","generator.js"),u=n.join(e,".rapidkit","generator.js");await p.copy(d,u);}async function ae(e,t){let r=t.template==="fastapi",o=r?"FastAPI":"NestJS",i=b(`Creating ${o} project...`).start();try{let{fileURLToPath:s}=await import('url'),c=s(import.meta.url),p=n.dirname(c),d=n.resolve(p,".."),u=r?"fastapi-standard":"nestjs-standard",m=n.join(d,"templates","kits",u);await promises.mkdir(e,{recursive:true});let g={project_name:r?t.name.replace(/-/g,"_").toLowerCase():t.name.replace(/_/g,"-").toLowerCase(),author:t.author,description:t.description||`${o} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:t.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:b$1()};await W(m,e,g);let k=r?`# Python
483
+ `}async function z(e){let{fileURLToPath:t}=await import('url'),r=t(import.meta.url),o=a.dirname(r),n=a.resolve(o,".."),s=a.join(n,"templates","kits"),c=a.join(e,".rapidkit","templates"),{default:p}=await import('fs-extra');await p.copy(s,c);let d=a.join(n,"templates","generator.js"),u=a.join(e,".rapidkit","generator.js");await p.copy(d,u);}async function ae(e,t){let r=t.template==="fastapi",o=r?"FastAPI":"NestJS",n=b(`Creating ${o} project...`).start();try{let{fileURLToPath:s}=await import('url'),c=s(import.meta.url),p=a.dirname(c),d=a.resolve(p,".."),u=r?"fastapi-standard":"nestjs-standard",m=a.join(d,"templates","kits",u);await promises.mkdir(e,{recursive:true});let g={project_name:r?t.name.replace(/-/g,"_").toLowerCase():t.name.replace(/_/g,"-").toLowerCase(),author:t.author,description:t.description||`${o} application generated with RapidKit`,app_version:"0.1.0",license:"MIT",package_manager:t.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:b$1()};await W(m,e,g);let f=r?`# Python
484
484
  __pycache__/
485
485
  *.py[cod]
486
486
  *$py.class
@@ -548,10 +548,10 @@ Thumbs.db
548
548
 
549
549
  # Coverage
550
550
  coverage/
551
- `;if(await promises.writeFile(n.join(e,".gitignore"),k),i.succeed(`${o} project created!`),!t.skipGit){let f=b("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${o} project via RapidKit`],{cwd:e}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}if(!t.skipInstall&&!r){let f=t.package_manager||"npm",h=b(`Installing dependencies with ${f}...`).start();try{await execa(f,["install"],{cwd:e}),h.succeed("Dependencies installed");}catch{h.warn(`Could not install dependencies. Run '${f} install' manually.`);}}let y=n.basename(e);console.log(r?`
552
- ${a.green("\u2728 FastAPI project created successfully!")}
551
+ `;if(await promises.writeFile(a.join(e,".gitignore"),f),n.succeed(`${o} project created!`),!t.skipGit){let k=b("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${o} project via RapidKit`],{cwd:e}),k.succeed("Git repository initialized");}catch{k.warn("Could not initialize git repository");}}if(!t.skipInstall&&!r){let k=t.package_manager||"npm",h=b(`Installing dependencies with ${k}...`).start();try{await execa(k,["install"],{cwd:e}),h.succeed("Dependencies installed");}catch{h.warn(`Could not install dependencies. Run '${k} install' manually.`);}}let y=a.basename(e);console.log(r?`
552
+ ${i.green("\u2728 FastAPI project created successfully!")}
553
553
 
554
- ${a.bold("\u{1F4C2} Project structure:")}
554
+ ${i.bold("\u{1F4C2} Project structure:")}
555
555
  ${e}/
556
556
  \u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
557
557
  \u251C\u2500\u2500 src/
@@ -563,12 +563,12 @@ ${e}/
563
563
  \u251C\u2500\u2500 pyproject.toml # Poetry configuration
564
564
  \u2514\u2500\u2500 README.md
565
565
 
566
- ${a.bold("\u{1F680} Get started:")}
567
- ${a.cyan(`cd ${y}`)}
568
- ${a.cyan("npx rapidkit init")} ${a.gray("# Install dependencies")}
569
- ${a.cyan("npx rapidkit dev")} ${a.gray("# Start dev server")}
566
+ ${i.bold("\u{1F680} Get started:")}
567
+ ${i.cyan(`cd ${y}`)}
568
+ ${i.cyan("npx rapidkit init")} ${i.gray("# Install dependencies")}
569
+ ${i.cyan("npx rapidkit dev")} ${i.gray("# Start dev server")}
570
570
 
571
- ${a.bold("\u{1F4DA} Available commands:")}
571
+ ${i.bold("\u{1F4DA} Available commands:")}
572
572
  npx rapidkit init # Install dependencies (poetry install)
573
573
  npx rapidkit dev # Start dev server with hot reload
574
574
  npx rapidkit start # Start production server
@@ -576,12 +576,12 @@ ${a.bold("\u{1F4DA} Available commands:")}
576
576
  npx rapidkit lint # Lint code
577
577
  npx rapidkit format # Format code
578
578
 
579
- ${a.gray("Alternative: make dev, ./rapidkit dev, poetry run dev")}
580
- ${a.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
579
+ ${i.gray("Alternative: make dev, ./rapidkit dev, poetry run dev")}
580
+ ${i.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
581
581
  `:`
582
- ${a.green("\u2728 NestJS project created successfully!")}
582
+ ${i.green("\u2728 NestJS project created successfully!")}
583
583
 
584
- ${a.bold("\u{1F4C2} Project structure:")}
584
+ ${i.bold("\u{1F4C2} Project structure:")}
585
585
  ${e}/
586
586
  \u251C\u2500\u2500 .rapidkit/ # RapidKit CLI module
587
587
  \u251C\u2500\u2500 src/
@@ -593,13 +593,13 @@ ${e}/
593
593
  \u251C\u2500\u2500 package.json # Dependencies
594
594
  \u2514\u2500\u2500 README.md
595
595
 
596
- ${a.bold("\u{1F680} Get started:")}
597
- ${a.cyan(`cd ${y}`)}
598
- ${t.skipInstall?a.cyan("npx rapidkit init")+a.gray(" # npm install")+`
599
- `:""}${a.cyan("cp .env.example .env")}
600
- ${a.cyan("npx rapidkit dev")} ${a.gray("# Start dev server")}
596
+ ${i.bold("\u{1F680} Get started:")}
597
+ ${i.cyan(`cd ${y}`)}
598
+ ${t.skipInstall?i.cyan("npx rapidkit init")+i.gray(" # npm install")+`
599
+ `:""}${i.cyan("cp .env.example .env")}
600
+ ${i.cyan("npx rapidkit dev")} ${i.gray("# Start dev server")}
601
601
 
602
- ${a.bold("\u{1F4DA} Available commands:")}
602
+ ${i.bold("\u{1F4DA} Available commands:")}
603
603
  npx rapidkit init # Install dependencies
604
604
  npx rapidkit dev # Start dev server with hot reload
605
605
  npx rapidkit start # Start production server
@@ -608,22 +608,22 @@ ${a.bold("\u{1F4DA} Available commands:")}
608
608
  npx rapidkit lint # Lint code
609
609
  npx rapidkit format # Format code
610
610
 
611
- ${a.bold("\u{1F310} API endpoints:")}
611
+ ${i.bold("\u{1F310} API endpoints:")}
612
612
  http://localhost:8000/health # Health check
613
613
  http://localhost:8000/docs # Swagger docs
614
614
  http://localhost:8000/examples/notes # Example API
615
615
 
616
- ${a.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
617
- `);}catch(s){throw i.fail(`Failed to create ${o} project`),s}}async function W(e,t,r){let o=await promises.readdir(e,{withFileTypes:true});for(let i of o){let s=n.join(e,i.name),c=i.name.replace(/\.j2$/,""),p=n.join(t,c);if(i.isDirectory())await promises.mkdir(p,{recursive:true}),await W(s,p,r);else {let d=await promises.readFile(s,"utf-8");i.name.endsWith(".j2")&&(d=U(d,r)),await promises.writeFile(p,d),(c==="rapidkit"||c==="activate"||c.endsWith(".py")&&p.includes(".rapidkit"))&&await promises.chmod(p,493);}}}function U(e,t){let r=e;for(let[o,i]of Object.entries(t)){let s=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");r=r.replace(s,String(i));let c=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");r=r.replace(c,(u,m,g)=>String(i).replace(new RegExp(m,"g"),g));let p=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(p,String(i).toLowerCase());let d=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(d,(u,m,g)=>String(i).replace(new RegExp(m,"g"),g).toLowerCase());}return r}async function oe(){let e=j$1(),t=n.join(e,"workspaces.json");if(!await promises.stat(t).catch(()=>null)){console.log(a.yellow(`
616
+ ${i.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
617
+ `);}catch(s){throw n.fail(`Failed to create ${o} project`),s}}async function W(e,t,r){let o=await promises.readdir(e,{withFileTypes:true});for(let n of o){let s=a.join(e,n.name),c=n.name.replace(/\.j2$/,""),p=a.join(t,c);if(n.isDirectory())await promises.mkdir(p,{recursive:true}),await W(s,p,r);else {let d=await promises.readFile(s,"utf-8");n.name.endsWith(".j2")&&(d=U(d,r)),await promises.writeFile(p,d),(c==="rapidkit"||c==="activate"||c.endsWith(".py")&&p.includes(".rapidkit"))&&await promises.chmod(p,493);}}}function U(e,t){let r=e;for(let[o,n]of Object.entries(t)){let s=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");r=r.replace(s,String(n));let c=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");r=r.replace(c,(u,m,g)=>String(n).replace(new RegExp(m,"g"),g));let p=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(p,String(n).toLowerCase());let d=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(d,(u,m,g)=>String(n).replace(new RegExp(m,"g"),g).toLowerCase());}return r}async function ne(){let e=j$1(),t=a.join(e,"workspaces.json");if(!await promises.stat(t).catch(()=>null)){console.log(i.yellow(`
618
618
  \u26A0\uFE0F No workspaces registered yet.
619
- `)),console.log(a.gray(`Create a workspace with: npx rapidkit <workspace-name>
620
- `));return}try{let r=await promises.readFile(t,"utf8"),o=JSON.parse(r);if(!o||typeof o!="object"||!Array.isArray(o.workspaces)){console.log(a.yellow(`
619
+ `)),console.log(i.gray(`Create a workspace with: npx rapidkit <workspace-name>
620
+ `));return}try{let r=await promises.readFile(t,"utf8"),o=JSON.parse(r);if(!o||typeof o!="object"||!Array.isArray(o.workspaces)){console.log(i.yellow(`
621
621
  \u26A0\uFE0F Workspace registry is invalid; resetting to empty state.
622
- `)),await promises.writeFile(t,JSON.stringify({workspaces:[]},null,2));return}let i=x(o),s=[],c=0;for(let m of i.workspaces)await promises.stat(m.path).catch(()=>null)?s.push(m):c+=1;let p={workspaces:s},d=JSON.stringify(o),u=JSON.stringify(p);if(d!==u&&await promises.writeFile(t,JSON.stringify(p,null,2)),!p.workspaces||p.workspaces.length===0){console.log(a.yellow(`
622
+ `)),await promises.writeFile(t,JSON.stringify({workspaces:[]},null,2));return}let n=x(o),s=[],c=0;for(let m of n.workspaces)await promises.stat(m.path).catch(()=>null)?s.push(m):c+=1;let p={workspaces:s},d=JSON.stringify(o),u=JSON.stringify(p);if(d!==u&&await promises.writeFile(t,JSON.stringify(p,null,2)),!p.workspaces||p.workspaces.length===0){console.log(i.yellow(`
623
623
  \u26A0\uFE0F No workspaces registered yet.
624
- `)),c>0&&console.log(a.gray(`Cleaned ${c} stale workspace entr${c===1?"y":"ies"}.
625
- `));return}console.log(a.bold(`
624
+ `)),c>0&&console.log(i.gray(`Cleaned ${c} stale workspace entr${c===1?"y":"ies"}.
625
+ `));return}console.log(i.bold(`
626
626
  \u{1F4E6} Registered RapidKit Workspaces:
627
- `));for(let m of p.workspaces)console.log(a.cyan(` ${m.name}`)),console.log(a.gray(` Path: ${m.path}`)),console.log(a.gray(` Projects: ${m.projects?.length||0}`)),console.log();c>0&&console.log(a.gray(`Cleaned ${c} stale workspace entr${c===1?"y":"ies"}.`)),console.log(a.gray(`Total: ${p.workspaces.length} workspace(s)
628
- `));}catch(r){console.error(a.red(`
629
- \u274C Failed to read workspace registry`)),console.error(a.gray(String(r)));}}async function P(e){try{let t=await promises.readFile(e,"utf8");return JSON.parse(t)}catch{return null}}function J(e){return c(e)}async function L(e){try{return await promises.access(e),true}catch{return false}}async function G(e){let t=[],r=[e],o=new Set;for(;r.length>0;){let i=r.shift();if(!i||o.has(i))continue;o.add(i);let s=[];try{s=await promises.readdir(i,{withFileTypes:true});}catch{continue}for(let c of s){if(!c.isDirectory()||c.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(c.name))continue;let p=n.join(i,c.name),d=await L(n.join(p,".rapidkit","context.json")),u=await L(n.join(p,".rapidkit","project.json"));(d||u)&&t.push(p),r.push(p);}}return t.sort((i,s)=>i.localeCompare(s))}async function I(e){try{return (await promises.readdir(e,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.toLowerCase().endsWith(".json")).map(r=>r.name).sort((r,o)=>r.localeCompare(o))}catch{return []}}async function ne(e,t){let r=t?.includePaths===true,o=t?.includeDoctorEvidence!==false,i=n.resolve(e),s=await P(n.join(i,".rapidkit","workspace.json")),c=typeof s?.workspace_name=="string"&&s.workspace_name.trim()||n.basename(i),p=typeof s?.profile=="string"?s.profile:void 0,d=typeof s?.rapidkit_version=="string"?s.rapidkit_version:void 0,u=await G(i),m=[];for(let h of u){let v=await P(n.join(h,".rapidkit","project.json")),E=n.relative(i,h)||".",_=n.join(h,".rapidkit","reports"),$={name:n.basename(h),relative_path:E,runtime:typeof v?.runtime=="string"?v.runtime:void 0,kit_name:typeof v?.kit_name=="string"?v.kit_name:void 0};if(r&&($.absolute_path=h),o){let R=await P(n.join(_,"doctor-last-run.json"));J(R)&&($.doctor_report=R);}let N=await I(_);N.length>0&&($.reports=N),m.push($);}let g=n.join(i,".rapidkit","reports"),k=await I(g),y={schema_version:"1.0",generated_at:new Date().toISOString(),generated_by:"rapidkit-npm",workspace:{name:c,relative_root:".",profile:p,rapidkit_version:d,...r?{absolute_root:i}:{}},summary:{project_count:m.length,doctor_evidence_included:o},reports:{workspace:k},projects:m},f=t?.outputPath?n.resolve(t.outputPath):n.join(g,"share-bundle.json");return await promises.mkdir(n.dirname(f),{recursive:true}),await promises.writeFile(f,JSON.stringify(y,null,2),"utf8"),f}export{ae as createProject,ie as createWorkspace,ne as createWorkspaceShareBundle,oe as listWorkspaces,re as registerProjectInWorkspace,F as registerWorkspace,te as syncWorkspaceProjects};
627
+ `));for(let m of p.workspaces)console.log(i.cyan(` ${m.name}`)),console.log(i.gray(` Path: ${m.path}`)),console.log(i.gray(` Projects: ${m.projects?.length||0}`)),console.log();c>0&&console.log(i.gray(`Cleaned ${c} stale workspace entr${c===1?"y":"ies"}.`)),console.log(i.gray(`Total: ${p.workspaces.length} workspace(s)
628
+ `));}catch(r){console.error(i.red(`
629
+ \u274C Failed to read workspace registry`)),console.error(i.gray(String(r)));}}async function P(e){try{let t=await promises.readFile(e,"utf8");return JSON.parse(t)}catch{return null}}function J(e){return c(e)}async function G(e){return a$1(e,{skipDirs:new Set(["node_modules","dist","build","target","coverage","htmlcov"]),includeHiddenDirs:false,descendIntoMatchedProjects:true})}async function L(e){try{return (await promises.readdir(e,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.toLowerCase().endsWith(".json")).map(r=>r.name).sort((r,o)=>r.localeCompare(o))}catch{return []}}async function se(e,t){let r=t?.includePaths===true,o=t?.includeDoctorEvidence!==false,n=a.resolve(e),s=await P(a.join(n,".rapidkit","workspace.json")),c=typeof s?.workspace_name=="string"&&s.workspace_name.trim()||a.basename(n),p=typeof s?.profile=="string"?s.profile:void 0,d=typeof s?.rapidkit_version=="string"?s.rapidkit_version:void 0,u=await G(n),m=[];for(let h of u){let v=await P(a.join(h,".rapidkit","project.json")),E=a.relative(n,h)||".",_=a.join(h,".rapidkit","reports"),$={name:a.basename(h),relative_path:E,runtime:typeof v?.runtime=="string"?v.runtime:void 0,kit_name:typeof v?.kit_name=="string"?v.kit_name:void 0};if(r&&($.absolute_path=h),o){let R=await P(a.join(_,"doctor-last-run.json"));J(R)&&($.doctor_report=R);}let N=await L(_);N.length>0&&($.reports=N),m.push($);}let g=a.join(n,".rapidkit","reports"),f=await L(g),y={schema_version:"1.0",generated_at:new Date().toISOString(),generated_by:"rapidkit-npm",workspace:{name:c,relative_root:".",profile:p,rapidkit_version:d,...r?{absolute_root:n}:{}},summary:{project_count:m.length,doctor_evidence_included:o},reports:{workspace:f},projects:m},k=t?.outputPath?a.resolve(t.outputPath):a.join(g,"share-bundle.json");return await promises.mkdir(a.dirname(k),{recursive:true}),await promises.writeFile(k,JSON.stringify(y,null,2),"utf8"),k}export{ae as createProject,oe as createWorkspace,se as createWorkspaceShareBundle,ne as listWorkspaces,ie as registerProjectInWorkspace,F as registerWorkspace,re as syncWorkspaceProjects};
@@ -0,0 +1,3 @@
1
+ import {d,e,a as a$1,b}from'./chunk-TYC54P7X.js';import {a}from'./chunk-VKLL63TL.js';import j from'fs';import g from'path';import R from'chalk';import {execa}from'execa';var ce={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},de={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function q(e,r,t){if(r){let a=r.trim().toLowerCase().replace(/[_.\s]+/g,"-"),c=a$1(r),s=`${e}-${c==="gofiber"?"fiber":c==="gogin"?"gin":c==="dotnet"?"aspnetcore":c!=="unknown"?c:a==="fiber"?"fiber":a==="aspnetcore"||a==="asp-net-core"?"aspnetcore":a}`,n=ce[s];if(n&&n.commands[t])return n.commands[t]}let o=de[t]?.[e]??[];return o.length>0?o[0]:void 0}function le(e){let r=d(e).map(t=>t==="python"?"python":t==="node"||t==="bun"?"node":t==="go"?"go":t==="java"?"java":t==="php"?"php":t==="rust"?"rust":t==="dotnet"?"dotnet":t==="elixir"?"elixir":t==="ruby"?"ruby":t==="clojure"||t==="scala"||t==="kotlin"?"jvm-generic":null).filter(t=>t!==null).filter((t,o,a)=>a.indexOf(t)===o);return {primary:r.length>0?r[0]:"unknown",secondary:r.slice(1)}}function Y(e){return le(e).primary}function Q(e,r){if(!e)return "unknown";r||(r={setup:["ModuleNotFoundError","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[t,o]of Object.entries(r))for(let a of o)if(new RegExp(a,"i").test(e))return t;return "unknown"}async function X(e){let r=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(r))return {valid:true};try{let o=process.platform==="win32"?"where":"which";if((await execa(o,[r],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${r}' not found or not executable`}}function Z(e,r,t){return r?t&&typeof r[t]=="string"?r[t]:typeof r.default=="string"?r.default:e:e}var me=new Set(["init","test","build","start"]),pe=new Set([".git","node_modules",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function O(e){try{return await j.promises.access(e,j.constants.F_OK),true}catch{return false}}async function fe(e){let r=await j.promises.readFile(e,"utf-8");return JSON.parse(r)}async function ge(e,r){await j.promises.mkdir(g.dirname(e),{recursive:true}),await j.promises.writeFile(e,`${JSON.stringify(r,null,2)}
2
+ `,"utf-8");}function M(e){return e.replace(/\\/g,"/")}async function he(e){return a(e,{skipDirs:pe,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(r,t)=>await O(g.join(r,".rapidkit","context.json"))||await O(g.join(r,".rapidkit","project.json"))?true:g.resolve(r)===g.resolve(t)?false:d(r).length>0})}async function ye(e,r,t){let o=await execa("git",["diff","--name-only",`${t}...HEAD`],{cwd:e,reject:false});if(o.exitCode!==0)return new Set(r);let a=o.stdout.split(/\r?\n/).map(u=>u.trim()).filter(u=>u.length>0).map(u=>M(u));if(a.length===0)return new Set;let c=new Set;for(let u of r){let s=M(g.relative(e,u));if(!s||s===".")continue;let n=`${s}/`;a.some(m=>m===s||m.startsWith(n))&&c.add(u);}return c}async function ke(e,r,t){let o=g.join(e,".rapidkit","workspace-dependency-graph.json");if(!await O(o))return {expanded:t,graphStatus:"missing",expansionDepth:0};let a;try{a=await fe(o);}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let c=new Set(r.map(f=>g.resolve(f))),u=new Map;if(!a||typeof a!="object"||Array.isArray(a))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let s=Array.isArray(a.projects)?a.projects:[];for(let f of s){if(!f||typeof f!="object"||Array.isArray(f))continue;let y=f,b=typeof y.path=="string"?y.path:"",l=g.resolve(e,b);if(!c.has(l))continue;let h=Array.isArray(y.dependsOn)?y.dependsOn.filter(v=>typeof v=="string"):[];for(let v of h){let E=g.resolve(e,v);c.has(E)&&(u.has(E)||u.set(E,new Set),u.get(E)?.add(l));}}let n=new Set(t),m=[...n],k=0;for(;m.length>0;){let f=m.shift();if(!f)continue;let y=u.get(f);if(y)for(let b of y)n.has(b)||(n.add(b),m.push(b),k+=1);}return {expanded:n,graphStatus:"loaded",expansionDepth:k}}async function we(e,r){if(typeof r=="boolean")return r;let t=g.join(e,".rapidkit","policies.yml");if(!await O(t))return true;let o="";try{o=await j.promises.readFile(t,"utf-8");}catch{return true}let a=o.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return a?a[1]==="true":true}async function N(e,r){let t=process.argv[1];if(!t)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};let o=await execa(process.execPath,[t,...e],{cwd:r,reject:false,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr}}function be(e){return e==="node"||e==="go"||e==="java"||e==="python"}function xe(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function Re(e){let r=process.cwd();try{process.chdir(e);let{handleInitCommand:t}=await import('./index.js');return {exitCode:await t(["init"]),stdout:"",stderr:""}}finally{process.chdir(r);}}async function ve(e$1){let r=s=>{let n=b(s);return n==="node"||n==="bun"?"node":n==="python"?"python":n==="go"?"go":n==="java"?"java":n==="php"?"php":n==="ruby"?"ruby":n==="rust"?"rust":n==="dotnet"?"dotnet":n==="elixir"?"elixir":n==="clojure"||n==="scala"||n==="kotlin"?"jvm-generic":Y(e$1)},t=s=>{if(!s)return;let n=a$1(s);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(n))return n},o=g.join(e$1,".rapidkit","context.json");if(j.existsSync(o))try{let s=JSON.parse(j.readFileSync(o,"utf-8"));if(typeof s.runtime=="string"){let n={};if(s.commands&&typeof s.commands=="object")for(let[m,k]of Object.entries(s.commands))typeof k=="string"&&(n[m]=k);return {runtime:r(s.runtime),framework:t(typeof s.framework=="string"?s.framework:void 0),commandOverrides:Object.keys(n).length>0?n:void 0,environment:typeof s.environment=="string"?s.environment:void 0}}}catch{}let a=e(e$1),c=r(a.runtime),u=t(a.key);return {runtime:c,framework:u}}async function Ee(e,r,t,o,a,c){let u=!a?.[r]&&be(t),s;if(a&&a[r]?s=a[r]:u?s=`rapidkit ${r}`:s=q(t,o,r),!s)return {exitCode:127,command:`<stage not supported for ${t}>`,message:`No stage command found for runtime '${t}' and framework '${o||"unknown"}'`,errorCategory:"runtime"};let n=Z(s,a,c);if(!n)return {exitCode:127,command:s,message:"Failed to resolve stage command",errorCategory:"runtime"};if(!u){let l=await X(n);if(!l.valid)return {exitCode:127,command:n,message:l.reason||"Command not available",errorCategory:"setup"}}let m=0,k="",f="",y;try{let l=u?r==="init"&&xe()?await Re(e):await N([r],e):await execa(n,[],{cwd:e,reject:false,shell:true});if(m=Number(l.exitCode??0),k=l.stdout,f=l.stderr,m!==0){let h=`${k}
3
+ ${f}`;y=Q(h);}}catch(l){return {exitCode:1,command:n,message:l instanceof Error?l.message:"Command execution failed",errorCategory:"runtime"}}return {exitCode:m,command:n,errorCategory:y,healthStatus:void 0,message:m!==0?`Stage failed with exit code ${m}`:void 0}}function ee(e){try{return JSON.parse(e)}catch{return null}}async function Se(e){let r=[],t=await N(["doctor","workspace","--json"],e);if(t.exitCode!==0)r.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let c=ee(t.stdout)?.healthScore,u=Number(c?.errors??0);Number.isFinite(u)&&u>0?r.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${u} error(s)`}):r.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let o=await N(["readiness","--json"],e);if(o.exitCode!==0)r.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let a=ee(o.stdout),c=String(a?.overallStatus??"").toLowerCase();c==="fail"?r.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):c==="warn"?r.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):r.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return r}function Ce(e){return me.has(e)}function je(e,r){let t=Math.max(1,Math.min(4,r)),o=Number(e??t);return Number.isFinite(o)?Math.max(1,Math.min(16,Math.trunc(o))):t}async function He(e){if(!Ce(e.stage))throw new Error(`Unsupported workspace run stage: ${e.stage}`);let r=Date.now(),t=g.resolve(e.workspacePath),o=await he(t),a=e.affected===true,c=e.blastRadius===true,u=e.since?.trim()||"HEAD~1",s=a?await ye(t,o,u):new Set(o),n,m="not-applicable",k=0,f="all";if(a&&c){let i=await ke(t,o,s);n=i.expanded,m=i.graphStatus,k=i.expansionDepth,f="affected+blast-radius";}else a?(n=s,f="affected"):(n=s,f="all");let y=e.stage==="init"?false:await we(t,e.enforceGates),b=y?await Se(t):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],l=b.find(i=>i.status==="fail"),h=o.filter(i=>n.has(i)),v=e.continueOnError===true,E=e.parallel===true,W=je(e.maxWorkers,h.length),A=h.length,$=0;e.json||console.log(R.gray(`Workspace run (${e.stage}) started: ${A} target(s), ${E?`parallel x${W}`:"sequential"}`));let S=new Map;for(let i of o)S.set(i,{path:i,relativePath:M(g.relative(t,i)),selected:n.has(i),affected:n.has(i),status:(n.has(i),"skipped"),exitCode:null,durationMs:0,reason:n.has(i)?void 0:"not affected",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});if(l)for(let i of h){let p=S.get(i);p&&(p.status="skipped",p.reason=`blocked by ${l.gate}`);}else {let i=async p=>{let d=S.get(p);if(!d)return;let P=M(g.relative(t,p));e.json||console.log(R.gray(`\u23F3 [${$}/${A}] ${e.stage} ${P}`)),d.selected=true,d.affected=true;let C=Date.now(),{runtime:w,framework:x,commandOverrides:re,environment:ne}=await ve(p);d.runtimeDetected=w,d.framework=x;let F=await Ee(p,e.stage,w,x,re,ne);if(d.executionCommand=F.command,d.errorCategory=F.errorCategory,d.healthStatus=F.healthStatus,d.durationMs=Date.now()-C,d.exitCode=F.exitCode,F.exitCode===0?(d.status="passed",d.reason=void 0):(d.status="failed",d.reason=F.message||"stage command failed",d.errorMessage=F.message),$+=1,!e.json){let oe=A>0?Math.round($/A*100):100,ae=d.status==="passed"?R.green("\u2705"):R.red("\u274C");console.log(R.gray(`${ae} [${$}/${A}] (${oe}%) ${P} ${d.durationMs}ms`));}};if(E&&h.length>1){let p=0,d=false,P=new Array(W).fill(null).map(async()=>{for(;p<h.length;){if(d&&!v)return;let C=p;p+=1;let w=h[C];await i(w),S.get(w)?.status==="failed"&&(d=true);}});if(await Promise.all(P),!v&&d){let C=false;for(let w of h){let x=S.get(w);if(x){if(x.status==="failed"){C=true;continue}C&&x.status==="skipped"&&(x.reason=x.reason||"stopped after failure");}}}}else for(let p of h){await i(p);let d=S.get(p);if(!v&&d?.status==="failed"){let P=h.slice(h.indexOf(p)+1);for(let C of P){let w=S.get(C);w&&(w.status="skipped",w.reason="stopped after failure");}break}}}let T=[];for(let i of o){let p=S.get(i);p&&T.push(p);}let B=T.filter(i=>i.status==="passed").length,L=T.filter(i=>i.status==="failed").length,_=T.filter(i=>i.status==="skipped").length,H=e.strict===true,te=L>0||H&&b.some(i=>i.status!=="pass")?1:0,V={schemaVersion:"1.0",workspacePath:t,stage:e.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-r,options:{affected:a,blastRadius:c,since:a?u:null,parallel:E,maxWorkers:W,continueOnError:v,strict:H,enforceGates:y},selection:{mode:f,since:a?u:null,graphStatus:m,expansionDepth:k},gates:{enforced:y,results:b,blocked:!!l,blockingGate:l?.gate},summary:{projectCount:o.length,selectedCount:h.length,passed:B,failed:L,skipped:_,exitCode:te},projects:T},J=g.join(t,".rapidkit","reports","workspace-run-last.json");return await ge(J,V),e.json||(l&&(console.log(R.red(`\u274C Workspace run blocked by ${l.gate}`)),console.log(R.gray(` ${l.summary}`))),console.log(R.cyan(`Workspace run (${e.stage}) => passed: ${B}, failed: ${L}, skipped: ${_}`)),console.log(R.gray(`Report: ${J}`))),V}export{He as runWorkspaceStage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.27.5",
3
+ "version": "0.27.6",
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": [
@@ -33,6 +33,10 @@
33
33
  "dist",
34
34
  "scripts/enforce-package-manager.cjs"
35
35
  ],
36
+ "publishConfig": {
37
+ "registry": "https://registry.npmjs.org",
38
+ "access": "public"
39
+ },
36
40
  "scripts": {
37
41
  "preinstall": "node scripts/enforce-package-manager.cjs",
38
42
  "sync-kits": "bash scripts/sync-kits.sh",
@@ -1,5 +0,0 @@
1
- import {a}from'./chunk-VM2TOHNX.js';import {execa}from'execa';import l from'chalk';import {createRequire}from'module';import {promises}from'fs';import m from'path';import f from'os';var v="rapidkit",w=createRequire(import.meta.url),A=w("../package.json"),i=A?.version??"0.0.0";function g(r){let e=r.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!e)return null;let t=e[4]?e[4].split(".").map(o=>o.match(/^\d+$/)?Number(o):o):[];return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:t}}function b(r,n){let e=g(r),t=g(n);if(!e||!t)return 0;if(e.major!==t.major)return e.major>t.major?1:-1;if(e.minor!==t.minor)return e.minor>t.minor?1:-1;if(e.patch!==t.patch)return e.patch>t.patch?1:-1;if(e.prerelease.length===0&&t.prerelease.length===0)return 0;if(e.prerelease.length===0)return 1;if(t.prerelease.length===0)return -1;let o=Math.max(e.prerelease.length,t.prerelease.length);for(let u=0;u<o;u+=1){let a=e.prerelease[u],s=t.prerelease[u];if(a===void 0)return -1;if(s===void 0)return 1;if(a===s)continue;let d=typeof a=="number",h=typeof s=="number";return d&&h?a>s?1:-1:d?-1:h||String(a)>String(s)?1:-1}return 0}var C=14400*1e3;function k(){let r=process.env.RAPIDKIT_CACHE_DIR?.trim()||(process.env.VITEST_WORKER_ID?m.join(f.homedir(),".rapidkit","cache",`vitest-${process.env.VITEST_WORKER_ID}`):m.join(f.homedir(),".rapidkit","cache"));return m.join(r,"update-check.json")}async function _(){try{let r=await promises.readFile(k(),"utf-8"),n=JSON.parse(r);return typeof n.latestVersion=="string"&&typeof n.checkedAt=="number"&&n.currentVersion===i&&Date.now()-n.checkedAt<C?n:null}catch{return null}}async function U(r){try{let n=k();await promises.mkdir(m.dirname(n),{recursive:true}),await promises.writeFile(n,JSON.stringify({latestVersion:r,checkedAt:Date.now(),currentVersion:i}),"utf-8");}catch{}}async function S(){try{a.debug("Checking for updates...");let r=await _();if(r){let t=Math.round((Date.now()-r.checkedAt)/6e4);a.debug(`Update check: cache hit (${t}m old)`),b(r.latestVersion,i)>0&&(console.log(l.yellow(`
2
- \u26A0\uFE0F Update available: ${i} \u2192 ${r.latestVersion}`)),console.log(l.cyan(`Run: npm install -g rapidkit@latest
3
- `)));return}let{stdout:n}=await execa("npm",["view",v,"version"],{timeout:3e3}),e=n.trim();await U(e),e&&b(e,i)>0?(console.log(l.yellow(`
4
- \u26A0\uFE0F Update available: ${i} \u2192 ${e}`)),console.log(l.cyan(`Run: npm install -g rapidkit@latest
5
- `))):a.debug("You are using the latest version");}catch{a.debug("Could not check for updates");}}function x(){return i}export{S as a,x as b};
@@ -1,33 +0,0 @@
1
- import {a,d,e,f,c,g}from'./chunk-Z5LKRG57.js';import ct from'crypto';import z from'os';import u from'path';import*as p from'fs-extra';import {execa}from'execa';var at=["version","project","create","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],$=new Set(at);function W(){return d()}function w(t,n){return t==="py"?["-3",...n]:n}function F(t){if(!t)return t;let n=["Installed Poetry version does not support '--no-update'. Falling back to 'poetry lock'."];return t.split(/\r?\n/).filter(i=>!n.some(o=>i.includes(o))).join(`
2
- `)}var y=class extends Error{code;constructor(n,r){super(r),this.code=n;}};function R(t){if(t instanceof y)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()?`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()?`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 b(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function dt(){let t=b(),n=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,r=n&&n.trim()?`${t}|${n.trim()}`:t;return ct.createHash("sha256").update(r).digest("hex").slice(0,12)}function S(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:u.join(z.homedir(),".cache")}function pt(){return u.join(S(),"rapidkit","npm-bridge","venv")}function Z(){let t=dt();return u.join(S(),"rapidkit","npm-bridge",`venv-${t}`)}function G(t){return f(t)}function K(t){return g(t)}function X(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function ut(t){return u.dirname(u.dirname(t))}function q(){return u.join(S(),"rapidkit","npm-bridge","core-commands.json")}async function Q(t){let n=!!process.env.RAPIDKIT_DEBUG,r=e=>{n&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${e}
15
- `);};try{r("probing interpreter-specific rapidkit script");let i=((await execa(t,w(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(e){r(`interpreter-specific script probe error: ${String(e)}`);}try{r('probing importlib.find_spec("rapidkit")');let e=await execa(t,w(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=${e.exitCode} stdout=${(e.stdout??"").toString().trim()}`),e.exitCode===0&&(e.stdout??"").toString().trim()==="1")return true}catch(e){r(`import probe error: ${String(e)}`);}try{r("probing python -m rapidkit");let e=await execa(t,w(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(r(`-m probe exitCode=${e.exitCode}`),e.exitCode===0)return true}catch(e){r(`-m probe error: ${String(e)}`);}try{r("probing PATH for rapidkit executables");let e=(process.env.PATH??"").split(u.delimiter).filter(Boolean);for(let i of e){let o=u.join(i,a()?"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(e){return r(`PATH probe error: ${String(e)}`),false}}async function T(t){let n=(t??"").toString().trim();if(!n)return false;try{let r=JSON.parse(n);return !!r&&typeof r=="object"&&r!==null&&"version"in r}catch{return false}}async function lt(t){let n=u.relative(".",g(".venv")),r=u.relative(".",f(".venv")),e=t;for(let i=0;i<25;i+=1){let o=u.join(e,n);if(await p.pathExists(o)){let c=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:e});if(c.exitCode===0&&await T(c.stdout))return {cmd:o,baseArgs:[]}}let s=u.join(e,r);if(await p.pathExists(s)){let c=await execa(s,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:e});if(c.exitCode===0&&await T(c.stdout))return {cmd:s,baseArgs:["-m","rapidkit"]}}let a=u.dirname(e);if(a===e)break;e=a;}return null}async function mt(t){try{let n=u.join(t,".python-version");if(await p.pathExists(n)){let e=(await p.readFile(n,"utf-8")).trim();if(e)return e}}catch{}try{let n=u.join(t,".rapidkit-workspace");if(await p.pathExists(n)){let r=await p.readFile(n,"utf-8"),e=JSON.parse(r);if(e.pythonVersion)return e.pythonVersion}}catch{}return null}async function M(t){if(t&&t.trim())try{let o=await lt(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 mt(s);return a&&(process.env.PYENV_VERSION=a),o}}catch{}let n=await Ct();if(n.kind==="venv"){let o=ut(n.pythonPath),s=K(o);return await p.pathExists(s)?{cmd:s,baseArgs:[]}:{cmd:n.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(n.cmd,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:n.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let s=((await execa(n.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 T(a.stdout))return {cmd:s,baseArgs:[]}}catch{}}catch{}let r=Z(),e=await A(n.cmd),i=K(r);return await p.pathExists(i)?{cmd:i,baseArgs:[]}:{cmd:e,baseArgs:["-m","rapidkit"]}}async function V(){for(let t of W())try{return await execa(t,w(t,["--version"]),{reject:false,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function ft(){let t=!!process.env.RAPIDKIT_DEBUG,n=e=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${e}
16
- `);},r=Array.from(new Set([...d(),...e(14,10).map(e=>e.command)]));for(let e of r)try{n(`Method 1: trying ${e} import`);let i=await execa(e,w(e,["-c","import rapidkit_core; print(1)"]),{reject:false,stdio:"pipe",timeout:3e3});if(i.exitCode===0&&i.stdout?.trim()==="1")return n(`\u2713 Found via ${e} import`),true}catch{continue}for(let e of r)try{n(`Method 2: trying ${e} -m pip show`);let i=await execa(e,w(e,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:3e3});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found via ${e} -m pip show`),true}catch{continue}for(let e of ["pip","pip3"])try{n(`Method 3: trying ${e} show`);let i=await execa(e,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found via ${e} show`),true}catch{continue}try{n("Method 4: checking pyenv versions");let e=await execa("pyenv",["versions","--bare"],{reject:false,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout){let i=e.stdout.split(`
17
- `).filter(o=>o.trim());n(`Found pyenv versions: ${i.join(", ")}`);for(let o of i){let s=process.env.PYENV_ROOT||u.join(z.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:3e3});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found in pyenv ${o}`),true}catch{try{let c=await execa("pyenv",["exec","pip","show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3,env:{...process.env,PYENV_VERSION:o.trim()}});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found in pyenv ${o} via PYENV_VERSION`),true}catch{continue}}}}}catch{n("pyenv not available");}for(let e of r)try{n(`Method 5: checking ${e} user site`);let i=await execa(e,w(e,["-m","site","--user-site"]),{reject:false,stdio:"pipe",timeout:3e3});if(i.exitCode===0&&i.stdout){let o=i.stdout.trim(),s=u.join(o,"rapidkit_core");if(await p.pathExists(s))return n("\u2713 Found in user site-packages"),true}}catch{continue}try{n("Method 6: checking pipx");let e=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return n("\u2713 Found via pipx"),true}catch{n("pipx not available");}for(let e of r)try{n(`Method 6: checking ${e} -m pipx list`);let i=await execa(e,w(e,["-m","pipx","list"]),{reject:false,stdio:"pipe",timeout:3e3});if(i.exitCode===0&&i.stdout?.includes("rapidkit-core"))return n(`\u2713 Found via ${e} -m pipx list`),true}catch{continue}try{if(n("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3})).exitCode===0)return n("\u2713 Found via poetry"),true}catch{n("poetry check failed");}for(let e of r)try{if(n(`Method 7: checking ${e} -m poetry show rapidkit-core`),(await execa(e,w(e,["-m","poetry","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:3e3})).exitCode===0)return n(`\u2713 Found via ${e} -m poetry`),true}catch{continue}try{n("Method 8: checking conda");let e=await execa("conda",["list","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return n("\u2713 Found via conda"),true}catch{n("conda not available");}return n("\u2717 Not found in any environment"),false}function ht(t){let n=t.trim();if(!n||!n.startsWith("rapidkit-core"))return null;let r=n.slice(13).trim();return !r||/[\/@]|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(r)?null:r}function L(t){let n=t.trim();if(!n)return null;let r=n.split("."),e=[];for(let i of r){let o=i.match(/^(\d+)/);if(!o){e.push(0);continue}e.push(Number.parseInt(o[1],10));}return e}function J(t,n){let r=Math.max(t.length,n.length);for(let e=0;e<r;e+=1){let i=e<t.length?t[e]:0,o=e<n.length?n[e]:0;if(i>o)return 1;if(i<o)return -1}return 0}function gt(t){return t.length<=1?[t[0]+1]:t.length===2?[t[0]+1,0]:[t[0],t[1]+1,0]}function yt(t){let n=t.split(",").map(e=>e.trim()).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n){let i=e.match(/^(==|>=|<=|>|<|~=)\s*([0-9][0-9A-Za-z+._-]*)$/);if(!i)return null;r.push({op:i[1],version:i[2]});}return r}function tt(t,n){let r=L(t);if(!r)return false;let e=yt(n);if(!e)return false;for(let i of e){let o=L(i.version);if(!o)return false;let s=J(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=gt(o);if(J(r,a)>=0)return false}}return true}async function wt(){let t=Array.from(new Set([...d(),...e(14,10).map(r=>r.command)])),n=r=>{let e=r.match(/^Version:\s*(.+)$/m);return e?e[1].trim():null};for(let r of t)try{let e=await execa(r,w(r,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:3e3});if(e.exitCode===0){let i=n(e.stdout||"");if(i)return i}}catch{continue}for(let r of ["pip","pip3"])try{let e=await execa(r,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:3e3});if(e.exitCode===0){let i=n(e.stdout||"");if(i)return i}}catch{continue}try{let r=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:3e3});if(r.exitCode===0&&r.stdout){let e=r.stdout.match(/rapidkit-core\s+([0-9][0-9A-Za-z+._-]*)/i);if(e?.[1])return e[1]}}catch{}return null}async function vt(){let t=b(),n=ht(t);if(!n)return {isCompatible:false,installedVersion:null,expectedConstraint:null,reason:X(t)?"constraint-unsupported":"constraint-missing"};let r=await wt();if(!r)return {isCompatible:false,installedVersion:null,expectedConstraint:n,reason:"version-not-detected"};let e=tt(r,n);return {isCompatible:e,installedVersion:r,expectedConstraint:n,reason:e?"compatible":"incompatible-version"}}async function A(t){let n=Z(),r=pt(),e=b(),i=[n];!X(e)&&!await p.pathExists(n)&&await p.pathExists(r)&&i.push(r);for(let l of i){let h=G(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=n,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")),v=l=>new Promise(h=>setTimeout(h,l)),C=async(l,h,f)=>{let g=await execa(l,h,{reject:false,stdio:["ignore","pipe","inherit"],env:s,timeout:f});if(g.exitCode===0)return;let I=(g.stdout??"").toString(),D=(g.stderr??"").toString(),E=[I,D].filter(Boolean).join(`
18
- `),it=E?`${l} ${h.join(" ")}
19
- ${E}`:`${l} ${h.join(" ")}`;throw new Error(it)},_=async(l,h,f)=>{let g=0;for(;;)try{await C(l,h,f);return}catch(I){if(g>=a)throw I;let D=Math.floor(Math.random()*200),E=c*Math.pow(2,g)+D;g+=1,await v(E);}};try{await p.ensureDir(u.dirname(o));try{await C(t,w(t,["-m","venv",o]),6e4);}catch(f){let g=f instanceof Error?f.message:String(f);throw new y("BRIDGE_VENV_CREATE_FAILED",g)}let l=G(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 y("BRIDGE_PIP_BOOTSTRAP_FAILED","ensurepip failed; install python3-venv/python3-pip and retry.");if(process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1")try{await _(l,["-m","pip","install","-U","pip"],m);}catch(f){let g=f instanceof Error?f.message:String(f);throw new y("BRIDGE_PIP_UPGRADE_FAILED",g)}try{await _(l,["-m","pip","install","-U",b()],m);}catch(f){let g=f instanceof Error?f.message:String(f);throw new y("BRIDGE_PIP_INSTALL_FAILED",g)}return l}catch(l){if(l instanceof y)throw l;let h=l instanceof Error?l.message:String(l);throw new y("BRIDGE_VENV_BOOTSTRAP_FAILED",h)}}async function Ct(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let r=await V();if(!r)throw new y("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");return {kind:"venv",pythonPath:await A(r)}}for(let r of W())if(await Q(r))return {kind:"system",cmd:r};let t=await V();if(!t)throw new y("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");return {kind:"venv",pythonPath:await A(t)}}async function jt(t,n){try{let r=await M(n?.cwd),e=r.cmd,i=[...r.baseArgs,...t];if(t[0]==="init"){let a=await execa(e,i,{cwd:n?.cwd,env:{...process.env,...n?.env},reject:false,stdio:"pipe"}),c=F((a.stdout??"").toString()),m=F((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(e,i,{cwd:n?.cwd,env:{...process.env,...n?.env},reject:false,stdio:"inherit"});return typeof s.exitCode=="number"?s.exitCode:1}catch(r){return process.stderr.write(`${R(r)}
24
- `),1}}var Pt=[{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 Nt(t,n){let{spawn:r}=await import('child_process');try{let e=await M(n?.cwd),i=e.cmd,o=[...e.baseArgs,...t];return await new Promise(s=>{let a=r(i,o,{cwd:n?.cwd,env:{...process.env,...n?.env},stdio:["inherit","inherit","pipe"]}),c=[];a.stderr?.on("data",m=>{c.push(m);}),a.on("close",m=>{let v=m??1;if(v!==0&&c.length>0){let C=Buffer.concat(c).toString("utf8");for(let{pattern:_,message:l}of Pt){let h=C.match(_);if(h){process.stderr.write(l(h)+`
29
- `),s(v);return}}process.stderr.write(C);}s(v);}),a.on("error",m=>{process.stderr.write(`${R(m)}
30
- `),s(1);});})}catch(e){return process.stderr.write(`${R(e)}
31
- `),1}}async function P(t,n){try{let r=await M(n?.cwd),e=r.cmd,i=[...r.baseArgs,...t],o=await execa(e,i,{cwd:n?.cwd,env:{...process.env,...n?.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:`${R(r)}
32
- `}}}function et(t){let n=new Set,r=t.split(`
33
- `),e=false;for(let i of r){let o=i.replace(/\r$/,"");if(!e){/^\s*Commands:\s*$/i.test(o)&&(e=true);let c=o.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let m=c[1].trim();m&&!m.startsWith("-")&&n.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("-")&&n.add(a);}return n}async function nt(){let t=q();if(!await p.pathExists(t))return null;try{let n=await p.readJson(t);if(n&&n.schema_version===1&&Array.isArray(n.commands))return n}catch{}return null}async function U(t){let n=q();await p.ensureDir(u.dirname(n)),await p.writeJson(n,t,{spaces:2});}async function _t(){let t=await P(["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 Et(){let t=await P(["commands","--json"],{cwd:process.cwd()});if(t.exitCode!==0)return null;try{let n=JSON.parse(t.stdout);if(n?.schema_version!==1||!Array.isArray(n.commands))return null;let r=n.commands.filter(e=>typeof e=="string");return r.length?r:null}catch{return null}}async function $t(){let n=Date.now(),r=await nt(),e=await _t(),i=!!r?.commands?.length;if(i&&n-r.fetched_at<864e5&&(!e||!r.rapidkit_version||r.rapidkit_version===e))return new Set(r.commands);let o=await Et();if(o?.length){let m=Array.from(new Set(o)).sort();return await U({schema_version:1,fetched_at:n,rapidkit_version:e,commands:m}),new Set(m)}let s=await P(["--help"],{cwd:process.cwd()});if(s.exitCode!==0)return i&&r?.commands?new Set(r.commands):new Set($);let a=et(s.stdout);if(a.size===0)return new Set($);let c=Array.from(a).sort();return await U({schema_version:1,fetched_at:n,rapidkit_version:e,commands:c}),a}async function Tt(){let n=Date.now(),r=await nt();return !r||n-r.fetched_at>=864e5||!r.commands?.length?null:new Set(r.commands)}function rt(){return u.join(S(),"rapidkit","npm-bridge","modules-catalog.json")}async function xt(){let t=rt();if(!await p.pathExists(t))return null;try{let n=await p.readJson(t);if(n&&n.schema_version===1&&Array.isArray(n.modules))return n}catch{}return null}async function H(t){let n=rt();await p.ensureDir(u.dirname(n)),await p.writeJson(n,t,{spaces:2});}function Y(t){try{return JSON.parse(t)}catch{return null}}async function Vt(t={}){let n=typeof t.ttlMs=="number"?t.ttlMs:18e5,r=Date.now(),e=await xt();if(e?.fetched_at&&r-e.fetched_at<n)return e;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 P(i,{cwd:t.cwd,env:t.env});if(o.exitCode===0){let a=Y(o.stdout);if(a&&a.schema_version===1&&Array.isArray(a.modules)){let c={...a,fetched_at:r};return await H(c),c}}let s=await P(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(s.exitCode===0){let a=Y(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 H(c),c}}return e||null}var Mt={pickSystemPython:V,ensureBridgeVenv:A,parseCoreCommandsFromHelp:et,tryRapidkit:Q,checkRapidkitCoreAvailable:ft,checkRapidkitCoreVersionCompatible:vt,isVersionSatisfyingConstraint:tt};export{$ as a,ft as b,vt as c,Ct as d,jt as e,Nt as f,P as g,$t as h,Tt as i,Vt as j,Mt as k};