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.
@@ -1,6 +1,6 @@
1
- import {a}from'./chunk-VKLL63TL.js';import {c}from'./chunk-NFUXULIF.js';import {j}from'./chunk-Z5LKRG57.js';import {b}from'./chunk-AC6KIKII.js';import {promises}from'fs';import o from'path';import i from'chalk';import S from'ora';import {execa}from'execa';function _(e){let t=o.resolve(e);return process.platform==="win32"?t.toLowerCase():t}function O(e){let t=_(e.path),r=Array.isArray(e.projects)?e.projects:[],a=[],c=new Set;for(let s of r){if(!s||typeof s.name!="string"||typeof s.path!="string")continue;let n=_(s.path);c.has(n)||(c.add(n),a.push({name:s.name,path:n}));}return {name:e.name,path:t,mode:e.mode,projects:a}}function P(e){let t=[],r=new Set;for(let a of e.workspaces||[]){if(!a||typeof a.name!="string"||typeof a.path!="string")continue;let c=O(a);r.has(c.path)||(r.add(c.path),t.push(c));}return {workspaces:t}}async function B(e,t){try{let r=_(e),a=j(),c=o.join(a,"workspaces.json");await promises.mkdir(a,{recursive:true});let s={workspaces:[]};try{let p=await promises.readFile(c,"utf8"),d=JSON.parse(p);d&&Array.isArray(d.workspaces)&&(s=P(d));}catch{}s.workspaces.some(p=>p.path===r)||(s.workspaces.push({name:t,path:r,mode:"full",projects:[]}),await promises.writeFile(c,JSON.stringify(s,null,2)));}catch{console.warn(i.gray("Note: Could not register workspace in shared registry"));}}async function ae(e,t=false){try{let r=_(e),a=j(),c=o.join(a,"workspaces.json"),s={workspaces:[]};try{let m=await promises.readFile(c,"utf8"),y=JSON.parse(m);y&&Array.isArray(y.workspaces)&&(s=P(y));}catch{t||console.log("\u26A0\uFE0F Workspace registry not found");return}let n=s.workspaces.find(m=>m.path===r);if(!n){t||console.log("\u26A0\uFE0F Workspace not registered in registry");return}Array.isArray(n.projects)||(n.projects=[]);let p=0,d=0,u=[e],g=new Set;for(;u.length>0;){let m=u.shift();if(!m||g.has(m))continue;g.add(m);let y=await promises.readdir(m,{withFileTypes:true});for(let w of y){if(!w.isDirectory()||w.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(w.name))continue;let h=o.join(m,w.name),f=_(h),R=o.join(f,".rapidkit","context.json"),k=o.join(f,".rapidkit","project.json");try{let $=false;try{await promises.access(R),$=true;}catch{await promises.access(k),$=true;}if($){let x=o.basename(f);n.projects.some(j=>j.path===f||j.name===x)?d++:(n.projects.push({name:x,path:f}),p++,t||console.log(`\u2714 Added: ${o.relative(e,f)}`));continue}}catch{}u.push(h);}}p>0?(await promises.writeFile(c,JSON.stringify(s,null,2)),t||console.log(`
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 oe(e,t,r){try{let a=_(e),c=_(r),s=j(),n=o.join(s,"workspaces.json"),p={workspaces:[]};try{let g=await promises.readFile(n,"utf8"),m=JSON.parse(g);m&&Array.isArray(m.workspaces)&&(p=P(m));}catch{return}let d=p.workspaces.find(g=>g.path===a);if(!d)return;Array.isArray(d.projects)||(d.projects=[]),d.projects.some(g=>g.path===c||g.name===t)||(d.projects.push({name:t,path:c}),await promises.writeFile(n,JSON.stringify(p,null,2)));}catch{}}async function ne(e,t){let r=S("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(o.join(e,".rapidkit"),{recursive:true});let a={workspace_name:t.name,author:t.author,rapidkit_version:b(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(o.join(e,".rapidkit","config.json"),JSON.stringify(a,null,2));let{syncWorkspaceFoundationFiles:c}=await import('./create-M7LT6WF6.js');await c(e,{workspaceName:t.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let s=T();await promises.writeFile(o.join(e,"rapidkit"),s),await promises.chmod(o.join(e,"rapidkit"),493);let n=z();await promises.writeFile(o.join(e,"rapidkit.cmd"),n);let p=U(t.name);if(await promises.writeFile(o.join(e,"README.md"),p),await promises.writeFile(o.join(e,".gitignore"),`# RapidKit workspace
1
+ import {a}from'./chunk-VKLL63TL.js';import {c}from'./chunk-NFUXULIF.js';import {j}from'./chunk-Z5LKRG57.js';import {b}from'./chunk-AC6KIKII.js';import {promises}from'fs';import o from'path';import i from'chalk';import E from'ora';import {execa}from'execa';function R(e){let t=o.resolve(e);return process.platform==="win32"?t.toLowerCase():t}function O(e){let t=R(e.path),r=Array.isArray(e.projects)?e.projects:[],a=[],p=new Set;for(let n of r){if(!n||typeof n.name!="string"||typeof n.path!="string")continue;let s=R(n.path);p.has(s)||(p.add(s),a.push({name:n.name,path:s}));}return {name:e.name,path:t,mode:e.mode,projects:a}}function P(e){let t=[],r=new Set;for(let a of e.workspaces||[]){if(!a||typeof a.name!="string"||typeof a.path!="string")continue;let p=O(a);r.has(p.path)||(r.add(p.path),t.push(p));}return {workspaces:t}}async function B(e,t){try{let r=R(e),a=j(),p=o.join(a,"workspaces.json");await promises.mkdir(a,{recursive:true});let n={workspaces:[]};try{let c=await promises.readFile(p,"utf8"),l=JSON.parse(c);l&&Array.isArray(l.workspaces)&&(n=P(l));}catch{}n.workspaces.some(c=>c.path===r)||(n.workspaces.push({name:t,path:r,mode:"full",projects:[]}),await promises.writeFile(p,JSON.stringify(n,null,2)));}catch{console.warn(i.gray("Note: Could not register workspace in shared registry"));}}async function ae(e,t=false){let r=R(e),a={workspacePath:r,workspaceFound:false,added:[],skipped:0};try{let p=j(),n=o.join(p,"workspaces.json"),s={workspaces:[]};try{let f=await promises.readFile(n,"utf8"),h=JSON.parse(f);h&&Array.isArray(h.workspaces)&&(s=P(h));}catch{return t||console.log("\u26A0\uFE0F Workspace registry not found"),a}let c=s.workspaces.find(f=>f.path===r);if(!c)return t||console.log("\u26A0\uFE0F Workspace not registered in registry"),a;Array.isArray(c.projects)||(c.projects=[]);let l=0,k=0,m=[],u=[e],$=new Set;for(;u.length>0;){let f=u.shift();if(!f||$.has(f))continue;$.add(f);let h=await promises.readdir(f,{withFileTypes:true});for(let y of h){if(!y.isDirectory()||y.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(y.name))continue;let b=o.join(f,y.name),g=R(b),w=o.join(g,".rapidkit","context.json"),D=o.join(g,".rapidkit","project.json");try{let C=false;try{await promises.access(w),C=true;}catch{await promises.access(D),C=true;}if(C){let j=o.basename(g);c.projects.some(v=>v.path===g||v.name===j)?k++:(c.projects.push({name:j,path:g}),l++,m.push(g),t||console.log(`\u2714 Added: ${o.relative(e,g)}`));continue}}catch{}u.push(b);}}return l>0?(await promises.writeFile(n,JSON.stringify(s,null,2)),t||console.log(`
2
+ \u2705 Synced ${l} project(s) to registry`)):t||console.log(`
3
+ \u2705 All projects already registered (${k} found)`),{workspacePath:r,workspaceFound:true,added:m,skipped:k}}catch(p){return t||console.error("\u274C Failed to sync projects:",p.message),a}}async function oe(e,t,r){try{let a=R(e),p=R(r),n=j(),s=o.join(n,"workspaces.json"),c={workspaces:[]};try{let m=await promises.readFile(s,"utf8"),u=JSON.parse(m);u&&Array.isArray(u.workspaces)&&(c=P(u));}catch{return}let l=c.workspaces.find(m=>m.path===a);if(!l)return;Array.isArray(l.projects)||(l.projects=[]),l.projects.some(m=>m.path===p||m.name===t)||(l.projects.push({name:t,path:p}),await promises.writeFile(s,JSON.stringify(c,null,2)));}catch{}}async function ne(e,t){let r=E("Creating RapidKit workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(o.join(e,".rapidkit"),{recursive:true});let a={workspace_name:t.name,author:t.author,rapidkit_version:b(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(o.join(e,".rapidkit","config.json"),JSON.stringify(a,null,2));let{syncWorkspaceFoundationFiles:p}=await import('./create-BO2I3ESU.js');await p(e,{workspaceName:t.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let n=T();await promises.writeFile(o.join(e,"rapidkit"),n),await promises.chmod(o.join(e,"rapidkit"),493);let s=z();await promises.writeFile(o.join(e,"rapidkit.cmd"),s);let c=U(t.name);if(await promises.writeFile(o.join(e,"README.md"),c),await promises.writeFile(o.join(e,".gitignore"),`# RapidKit workspace
4
4
  .env
5
5
  .env.*
6
6
  !.env.example
@@ -15,7 +15,7 @@ Thumbs.db
15
15
 
16
16
  # Logs
17
17
  *.log
18
- `),await promises.writeFile(o.join(e,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:b(),createdAt:new Date().toISOString(),name:t.name},null,2)),await J(e),r.succeed("Workspace created!"),!t.skipGit){let u=S("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 B(e,t.name),console.log(`
18
+ `),await promises.writeFile(o.join(e,".rapidkit-workspace"),JSON.stringify({signature:"RAPIDKIT_WORKSPACE",createdBy:"rapidkit-npm",version:b(),createdAt:new Date().toISOString(),name:t.name},null,2)),await J(e),r.succeed("Workspace created!"),!t.skipGit){let k=E("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}),k.succeed("Git repository initialized");}catch{k.warn("Could not initialize git repository");}}await B(e,t.name),console.log(`
19
19
  ${i.green("\u2728 RapidKit workspace created successfully!")}
20
20
 
21
21
  ${i.bold("\u{1F4C2} Workspace structure:")}
@@ -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 J(e){let{fileURLToPath:t}=await import('url'),r=t(import.meta.url),a=o.dirname(r),c=o.resolve(a,".."),s=o.join(c,"templates","kits"),n=o.join(e,".rapidkit","templates"),{default:p}=await import('fs-extra');await p.copy(s,n);let d=o.join(c,"templates","generator.js"),u=o.join(e,".rapidkit","generator.js");await p.copy(d,u);}async function se(e,t){let r=t.template==="fastapi",a=r?"FastAPI":"NestJS",c=S(`Creating ${a} project...`).start();try{let{fileURLToPath:s}=await import('url'),n=s(import.meta.url),p=o.dirname(n),d=o.resolve(p,".."),u=r?"fastapi-standard":"nestjs-standard",g=o.join(d,"templates","kits",u);await promises.mkdir(e,{recursive:true});let m={project_name:r?t.name.replace(/-/g,"_").toLowerCase():t.name.replace(/_/g,"-").toLowerCase(),author:t.author,description:t.description||`${a} 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()};await F(g,e,m);let y=r?`# Python
483
+ `}async function J(e){let{fileURLToPath:t}=await import('url'),r=t(import.meta.url),a=o.dirname(r),p=o.resolve(a,".."),n=o.join(p,"templates","kits"),s=o.join(e,".rapidkit","templates"),{default:c}=await import('fs-extra');await c.copy(n,s);let l=o.join(p,"templates","generator.js"),k=o.join(e,".rapidkit","generator.js");await c.copy(l,k);}async function se(e,t){let r=t.template==="fastapi",a=r?"FastAPI":"NestJS",p=E(`Creating ${a} project...`).start();try{let{fileURLToPath:n}=await import('url'),s=n(import.meta.url),c=o.dirname(s),l=o.resolve(c,".."),k=r?"fastapi-standard":"nestjs-standard",m=o.join(l,"templates","kits",k);await promises.mkdir(e,{recursive:true});let u={project_name:r?t.name.replace(/-/g,"_").toLowerCase():t.name.replace(/_/g,"-").toLowerCase(),author:t.author,description:t.description||`${a} 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()};await F(m,e,u);let $=r?`# Python
484
484
  __pycache__/
485
485
  *.py[cod]
486
486
  *$py.class
@@ -548,7 +548,7 @@ Thumbs.db
548
548
 
549
549
  # Coverage
550
550
  coverage/
551
- `;if(await promises.writeFile(o.join(e,".gitignore"),y),c.succeed(`${a} project created!`),!t.skipGit){let h=S("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${a} project via RapidKit`],{cwd:e}),h.succeed("Git repository initialized");}catch{h.warn("Could not initialize git repository");}}if(!t.skipInstall&&!r){let h=t.package_manager||"npm",f=S(`Installing dependencies with ${h}...`).start();try{await execa(h,["install"],{cwd:e}),f.succeed("Dependencies installed");}catch{f.warn(`Could not install dependencies. Run '${h} install' manually.`);}}let w=o.basename(e);console.log(r?`
551
+ `;if(await promises.writeFile(o.join(e,".gitignore"),$),p.succeed(`${a} project created!`),!t.skipGit){let h=E("Initializing git repository...").start();try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m",`Initial commit: ${a} project via RapidKit`],{cwd:e}),h.succeed("Git repository initialized");}catch{h.warn("Could not initialize git repository");}}if(!t.skipInstall&&!r){let h=t.package_manager||"npm",y=E(`Installing dependencies with ${h}...`).start();try{await execa(h,["install"],{cwd:e}),y.succeed("Dependencies installed");}catch{y.warn(`Could not install dependencies. Run '${h} install' manually.`);}}let f=o.basename(e);console.log(r?`
552
552
  ${i.green("\u2728 FastAPI project created successfully!")}
553
553
 
554
554
  ${i.bold("\u{1F4C2} Project structure:")}
@@ -564,7 +564,7 @@ ${e}/
564
564
  \u2514\u2500\u2500 README.md
565
565
 
566
566
  ${i.bold("\u{1F680} Get started:")}
567
- ${i.cyan(`cd ${w}`)}
567
+ ${i.cyan(`cd ${f}`)}
568
568
  ${i.cyan("npx rapidkit init")} ${i.gray("# Install dependencies")}
569
569
  ${i.cyan("npx rapidkit dev")} ${i.gray("# Start dev server")}
570
570
 
@@ -594,7 +594,7 @@ ${e}/
594
594
  \u2514\u2500\u2500 README.md
595
595
 
596
596
  ${i.bold("\u{1F680} Get started:")}
597
- ${i.cyan(`cd ${w}`)}
597
+ ${i.cyan(`cd ${f}`)}
598
598
  ${t.skipInstall?i.cyan("npx rapidkit init")+i.gray(" # npm install")+`
599
599
  `:""}${i.cyan("cp .env.example .env")}
600
600
  ${i.cyan("npx rapidkit dev")} ${i.gray("# Start dev server")}
@@ -614,16 +614,16 @@ ${i.bold("\u{1F310} API endpoints:")}
614
614
  http://localhost:8000/examples/notes # Example API
615
615
 
616
616
  ${i.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
617
- `);}catch(s){throw c.fail(`Failed to create ${a} project`),s}}async function F(e,t,r){let a=await promises.readdir(e,{withFileTypes:true});for(let c of a){let s=o.join(e,c.name),n=c.name.replace(/\.j2$/,""),p=o.join(t,n);if(c.isDirectory())await promises.mkdir(p,{recursive:true}),await F(s,p,r);else {let d=await promises.readFile(s,"utf-8");c.name.endsWith(".j2")&&(d=G(d,r)),await promises.writeFile(p,d),(n==="rapidkit"||n==="activate"||n.endsWith(".py")&&p.includes(".rapidkit"))&&await promises.chmod(p,493);}}}function G(e,t){let r=e;for(let[a,c]of Object.entries(t)){let s=new RegExp(`\\{\\{\\s*${a}\\s*\\}\\}`,"g");r=r.replace(s,String(c));let n=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");r=r.replace(n,(u,g,m)=>String(c).replace(new RegExp(g,"g"),m));let p=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(p,String(c).toLowerCase());let d=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(d,(u,g,m)=>String(c).replace(new RegExp(g,"g"),m).toLowerCase());}return r}async function ce(){let e=j(),t=o.join(e,"workspaces.json");if(!await promises.stat(t).catch(()=>null)){console.log(i.yellow(`
617
+ `);}catch(n){throw p.fail(`Failed to create ${a} project`),n}}async function F(e,t,r){let a=await promises.readdir(e,{withFileTypes:true});for(let p of a){let n=o.join(e,p.name),s=p.name.replace(/\.j2$/,""),c=o.join(t,s);if(p.isDirectory())await promises.mkdir(c,{recursive:true}),await F(n,c,r);else {let l=await promises.readFile(n,"utf-8");p.name.endsWith(".j2")&&(l=G(l,r)),await promises.writeFile(c,l),(s==="rapidkit"||s==="activate"||s.endsWith(".py")&&c.includes(".rapidkit"))&&await promises.chmod(c,493);}}}function G(e,t){let r=e;for(let[a,p]of Object.entries(t)){let n=new RegExp(`\\{\\{\\s*${a}\\s*\\}\\}`,"g");r=r.replace(n,String(p));let s=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");r=r.replace(s,(k,m,u)=>String(p).replace(new RegExp(m,"g"),u));let c=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(c,String(p).toLowerCase());let l=new RegExp(`\\{\\{\\s*${a}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");r=r.replace(l,(k,m,u)=>String(p).replace(new RegExp(m,"g"),u).toLowerCase());}return r}async function ce(){let e=j(),t=o.join(e,"workspaces.json");if(!await promises.stat(t).catch(()=>null)){console.log(i.yellow(`
618
618
  \u26A0\uFE0F No workspaces registered yet.
619
619
  `)),console.log(i.gray(`Create a workspace with: npx rapidkit <workspace-name>
620
620
  `));return}try{let r=await promises.readFile(t,"utf8"),a=JSON.parse(r);if(!a||typeof a!="object"||!Array.isArray(a.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 c=P(a),s=[],n=0;for(let g of c.workspaces)await promises.stat(g.path).catch(()=>null)?s.push(g):n+=1;let p={workspaces:s},d=JSON.stringify(a),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(`
622
+ `)),await promises.writeFile(t,JSON.stringify({workspaces:[]},null,2));return}let p=P(a),n=[],s=0;for(let m of p.workspaces)await promises.stat(m.path).catch(()=>null)?n.push(m):s+=1;let c={workspaces:n},l=JSON.stringify(a),k=JSON.stringify(c);if(l!==k&&await promises.writeFile(t,JSON.stringify(c,null,2)),!c.workspaces||c.workspaces.length===0){console.log(i.yellow(`
623
623
  \u26A0\uFE0F No workspaces registered yet.
624
- `)),n>0&&console.log(i.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.
624
+ `)),s>0&&console.log(i.gray(`Cleaned ${s} stale workspace entr${s===1?"y":"ies"}.
625
625
  `));return}console.log(i.bold(`
626
626
  \u{1F4E6} Registered RapidKit Workspaces:
627
- `));for(let g of p.workspaces)console.log(i.cyan(` ${g.name}`)),console.log(i.gray(` Path: ${g.path}`)),console.log(i.gray(` Projects: ${g.projects?.length||0}`)),console.log();n>0&&console.log(i.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.`)),console.log(i.gray(`Total: ${p.workspaces.length} workspace(s)
627
+ `));for(let m of c.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();s>0&&console.log(i.gray(`Cleaned ${s} stale workspace entr${s===1?"y":"ies"}.`)),console.log(i.gray(`Total: ${c.workspaces.length} workspace(s)
628
628
  `));}catch(r){console.error(i.red(`
629
- \u274C Failed to read workspace registry`)),console.error(i.gray(String(r)));}}async function N(e){try{let t=await promises.readFile(e,"utf8");return JSON.parse(t)}catch{return null}}function K(e){return c(e)}async function M(e){return a(e,{skipDirs:new Set(["node_modules","dist","build","target","coverage","htmlcov"]),includeHiddenDirs:false,descendIntoMatchedProjects:true})}async function A(e){try{return (await promises.readdir(e,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.toLowerCase().endsWith(".json")).map(r=>r.name).sort((r,a)=>r.localeCompare(a))}catch{return []}}async function pe(e,t){let r=t?.includePaths===true,a=t?.includeDoctorEvidence!==false,c=t?.includeBlueprint!==false,s=o.resolve(e),n=await N(o.join(s,".rapidkit","workspace.json")),p=typeof n?.workspace_name=="string"&&n.workspace_name.trim()||o.basename(s),d=typeof n?.profile=="string"?n.profile:void 0,u=typeof n?.rapidkit_version=="string"?n.rapidkit_version:void 0,g=await M(s),m=[];for(let k of g){let $=await N(o.join(k,".rapidkit","project.json")),x=o.relative(s,k)||".",D=o.join(k,".rapidkit","reports"),j={name:o.basename(k),relative_path:x,runtime:typeof $?.runtime=="string"?$.runtime:void 0,kit_name:typeof $?.kit_name=="string"?$.kit_name:void 0,modules:Array.isArray($?.modules)?$.modules.filter(E=>typeof E=="string"):void 0};if(r&&(j.absolute_path=k),a){let E=await N(o.join(D,"doctor-last-run.json"));K(E)&&(j.doctor_report=E);}let I=await A(D);I.length>0&&(j.reports=I),m.push(j);}let y=o.join(s,".rapidkit","reports"),w=await A(y),h=await N(o.join(s,".rapidkit","workspace.contract.json")),f={schema_version:"1.1",generated_at:new Date().toISOString(),generated_by:"rapidkit-npm",workspace:{name:p,relative_root:".",profile:d,rapidkit_version:u,...r?{absolute_root:s}:{}},summary:{project_count:m.length,doctor_evidence_included:a,contract_included:!!h},reports:{workspace:w},projects:m,...h?{contract:h}:{}};c&&(f.blueprint={schema_version:"rapidkit.workspace-blueprint.v1",purpose:"portable-reproducibility",workspace:{name:p,profile:d},projects:m.map(k=>({name:k.name,relative_path:k.relative_path,runtime:k.runtime,kit_name:k.kit_name,modules:k.modules??[],recreate_commands:[...k.kit_name?[`npx rapidkit create project ${k.kit_name} ${k.name} --yes --skip-install`]:[],`cd ${k.relative_path}`,"npx rapidkit init","npx rapidkit test"]})),recommended_commands:["npx rapidkit workspace contract verify --strict","npx rapidkit doctor workspace","npx rapidkit workspace run init --json","npx rapidkit workspace run test --strict --json","npx rapidkit readiness --strict --json"]});let R=t?.outputPath?o.resolve(t.outputPath):o.join(y,"share-bundle.json");return await promises.mkdir(o.dirname(R),{recursive:true}),await promises.writeFile(R,JSON.stringify(f,null,2),"utf8"),R}export{se as createProject,ne as createWorkspace,pe as createWorkspaceShareBundle,ce as listWorkspaces,oe as registerProjectInWorkspace,B as registerWorkspace,ae as syncWorkspaceProjects};
629
+ \u274C Failed to read workspace registry`)),console.error(i.gray(String(r)));}}async function N(e){try{let t=await promises.readFile(e,"utf8");return JSON.parse(t)}catch{return null}}function K(e){return c(e)}async function M(e){return a(e,{skipDirs:new Set(["node_modules","dist","build","target","coverage","htmlcov"]),includeHiddenDirs:false,descendIntoMatchedProjects:true})}async function A(e){try{return (await promises.readdir(e,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.toLowerCase().endsWith(".json")).map(r=>r.name).sort((r,a)=>r.localeCompare(a))}catch{return []}}async function pe(e,t){let r=t?.includePaths===true,a=t?.includeDoctorEvidence!==false,p=t?.includeBlueprint!==false,n=o.resolve(e),s=await N(o.join(n,".rapidkit","workspace.json")),c=typeof s?.workspace_name=="string"&&s.workspace_name.trim()||o.basename(n),l=typeof s?.profile=="string"?s.profile:void 0,k=typeof s?.rapidkit_version=="string"?s.rapidkit_version:void 0,m=await M(n),u=[];for(let g of m){let w=await N(o.join(g,".rapidkit","project.json")),D=o.relative(n,g)||".",C=o.join(g,".rapidkit","reports"),j={name:o.basename(g),relative_path:D,runtime:typeof w?.runtime=="string"?w.runtime:void 0,kit_name:typeof w?.kit_name=="string"?w.kit_name:void 0,modules:Array.isArray(w?.modules)?w.modules.filter(v=>typeof v=="string"):void 0};if(r&&(j.absolute_path=g),a){let v=await N(o.join(C,"doctor-last-run.json"));K(v)&&(j.doctor_report=v);}let W=await A(C);W.length>0&&(j.reports=W),u.push(j);}let $=o.join(n,".rapidkit","reports"),f=await A($),h=await N(o.join(n,".rapidkit","workspace.contract.json")),y={schema_version:"1.1",generated_at:new Date().toISOString(),generated_by:"rapidkit-npm",workspace:{name:c,relative_root:".",profile:l,rapidkit_version:k,...r?{absolute_root:n}:{}},summary:{project_count:u.length,doctor_evidence_included:a,contract_included:!!h},reports:{workspace:f},projects:u,...h?{contract:h}:{}};p&&(y.blueprint={schema_version:"rapidkit.workspace-blueprint.v1",purpose:"portable-reproducibility",workspace:{name:c,profile:l},projects:u.map(g=>({name:g.name,relative_path:g.relative_path,runtime:g.runtime,kit_name:g.kit_name,modules:g.modules??[],recreate_commands:[...g.kit_name?[`npx rapidkit create project ${g.kit_name} ${g.name} --yes --skip-install`]:[],`cd ${g.relative_path}`,"npx rapidkit init","npx rapidkit test"]})),recommended_commands:["npx rapidkit workspace contract verify --strict","npx rapidkit doctor workspace","npx rapidkit workspace run init --json","npx rapidkit workspace run test --strict --json","npx rapidkit readiness --strict --json"]});let b=t?.outputPath?o.resolve(t.outputPath):o.join($,"share-bundle.json");return await promises.mkdir(o.dirname(b),{recursive:true}),await promises.writeFile(b,JSON.stringify(y,null,2),"utf8"),b}export{B as a,ae as b,oe as c,ne as d,se as e,ce as f,pe as g};
@@ -0,0 +1,33 @@
1
+ import {f,e,d,a as a$1,k as k$1,g as g$1,c}from'./chunk-Z5LKRG57.js';import {a}from'./chunk-2FIX2MDC.js';import ft from'crypto';import q from'os';import u from'path';import*as p from'fs-extra';import {execa}from'execa';var mt=["version","project","create","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],M=new Set(mt);var g=a();function O(){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 J(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 S(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 ht(){let t=_(),e=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,r=e&&e.trim()?`${t}|${e.trim()}`:t;return ft.createHash("sha256").update(r).digest("hex").slice(0,12)}function j(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:u.join(q.homedir(),".cache")}function gt(){return u.join(j(),"rapidkit","npm-bridge","venv")}function Q(){let t=ht();return u.join(j(),"rapidkit","npm-bridge",`venv-${t}`)}function H(t){return f(t)}function U(t){return g$1(t)}async function tt(t=process.platform,e=process.env){let r=a$1(t)?["rapidkit.exe","rapidkit.cmd"]:["rapidkit"],n=k$1(e,t).flatMap(i=>r.map(o=>u.join(i,o)));for(let i of [...new Set(n)])try{if(!await p.pathExists(i))continue;let o=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(o.exitCode===0&&await D(o.stdout))return {cmd:i,baseArgs:[]}}catch{}return null}function et(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function yt(t){return u.dirname(u.dirname(t))}function nt(){return u.join(j(),"rapidkit","npm-bridge","core-commands.json")}async function rt(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 a=(o.stdout??"").toString().trim();try{let s=JSON.parse(a),c=!!s&&typeof s=="object"&&s!==null&&"version"in s;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 a=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`candidate exitCode=${a.exitCode}`),a.exitCode===0){let s=(a.stdout??"").toString().trim();try{let c=JSON.parse(s);if(c&&typeof c=="object"&&c!==null&&"version"in c)return true}catch{r("candidate output not valid JSON, skipping");}}}}catch(a){r(`error probing candidate ${o}: ${String(a)}`);}}return r("no valid rapidkit found on PATH"),false}catch(n){return r(`PATH probe error: ${String(n)}`),false}}async function D(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 it(t,e=process.platform){let r=async o=>{try{let a=u.join(o,".rapidkit-workspace");if(!await p.pathExists(a))return null;let c=(await p.readJson(a))?.metadata?.python?.venvPath;return typeof c!="string"||!c.trim()?null:u.isAbsolute(c)?c:u.join(o,c)}catch{return null}},n=async(o,a)=>{let s=g$1(a,e);if(await p.pathExists(s)){let l=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:o});if(l.exitCode===0&&await D(l.stdout))return {cmd:s,baseArgs:[],workspaceDir:o}}let c=f(a,e);if(await p.pathExists(c)){let l=await execa(c,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:o});if(l.exitCode===0&&await D(l.stdout))return {cmd:c,baseArgs:["-m","rapidkit"],workspaceDir:o}}return null},i=t;for(let o=0;o<25;o+=1){let a=await r(i),s=[u.join(i,".venv"),a].filter(l=>!!l);for(let l of [...new Set(s)]){let P=await n(i,l);if(P)return P}let c=u.dirname(i);if(c===i)break;i=c;}return null}async function wt(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.readJson(e);if(typeof r?.pythonVersion=="string"&&r.pythonVersion.trim())return r.pythonVersion.trim();let n=r?.metadata?.python?.pythonVersion;if(typeof n=="string"&&n.trim())return n.trim()}}catch{}return null}async function F(t){if(t&&t.trim())try{let a=await it(t);if(a){let s=a.workspaceDir??(u.dirname(a.cmd).includes(".venv")?u.dirname(u.dirname(u.dirname(a.cmd))):u.dirname(a.cmd)),c=await wt(s);return c&&(process.env.PYENV_VERSION=c),a}}catch{}let e=await xt();if(e.kind==="venv"){let a=yt(e.pythonPath),s=U(a);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 c=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(c.exitCode===0&&await D(c.stdout))return {cmd:s,baseArgs:[]}}catch{}}catch{}let r=await tt();if(r)return r;let n=Q(),i=await N(e.cmd),o=U(n);return await p.pathExists(o)?{cmd:o,baseArgs:[]}:{cmd:i,baseArgs:["-m","rapidkit"]}}async function ot(){for(let t of O())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 O()){try{await execa(e,v(e,["--version"]),{reject:false,stdio:"pipe",timeout:2e3});}catch(r){t=r;continue}try{return await N(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 vt(){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 a=process.env.PYENV_ROOT||u.join(q.homedir(),".pyenv"),s=u.join(a,"versions",o.trim(),"bin","pip");try{let c=await execa(s,["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(),a=u.join(o,"rapidkit_core");if(await p.pathExists(a))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 Pt(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 Y(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 W(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 Ct(t){return t.length<=1?[t[0]+1]:t.length===2?[t[0]+1,0]:[t[0],t[1]+1,0]}function Et(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 st(t,e){let r=Y(t);if(!r)return false;let n=Et(e);if(!n)return false;for(let i of n){let o=Y(i.version);if(!o)return false;let a=W(r,o);if(i.op==="=="&&a!==0||i.op===">="&&a<0||i.op==="<="&&a>0||i.op===">"&&a<=0||i.op==="<"&&a>=0)return false;if(i.op==="~="){if(a<0)return false;let s=Ct(o);if(W(r,s)>=0)return false}}return true}async function _t(){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 kt(){let t=_(),e=Pt(t);if(!e)return {isCompatible:false,installedVersion:null,expectedConstraint:null,reason:et(t)?"constraint-unsupported":"constraint-missing"};let r=await _t();if(!r)return {isCompatible:false,installedVersion:null,expectedConstraint:e,reason:"version-not-detected"};let n=st(r,e);return {isCompatible:n,installedVersion:r,expectedConstraint:e,reason:n?"compatible":"incompatible-version"}}async function N(t){let e=Q(),r=gt(),n=_(),i=[e];!et(n)&&!await p.pathExists(e)&&await p.pathExists(r)&&i.push(r);for(let m of i){let h=H(m);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(m);}catch{await p.remove(m);}}let o=e,a={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},s=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")),l=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),P=m=>new Promise(h=>setTimeout(h,m)),C=async(m,h,f)=>{let y=await execa(m,h,{reject:false,stdio:["ignore","pipe","inherit"],env:a,timeout:f});if(y.exitCode===0)return;let T=(y.stdout??"").toString(),$=(y.stderr??"").toString(),R=[T,$].filter(Boolean).join(`
18
+ `),pt=R?`${m} ${h.join(" ")}
19
+ ${R}`:`${m} ${h.join(" ")}`;throw new Error(pt)},x=async(m,h,f)=>{let y=0;for(;;)try{await C(m,h,f);return}catch(T){if(y>=s)throw T;let $=Math.floor(Math.random()*200),R=c*Math.pow(2,y)+$;y+=1,await P(R);}};try{await p.ensureDir(u.dirname(o));try{await C(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 m=H(o);if((await execa(m,["-m","pip","--version"],{reject:false,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(m,["-m","ensurepip","--default-pip"],{reject:false,stdio:["ignore","pipe","inherit"],env:a,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 x(m,["-m","pip","install","-U","pip"],l);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_PIP_UPGRADE_FAILED",y)}try{await x(m,["-m","pip","install","-U",_()],l);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_PIP_INSTALL_FAILED",y)}return m}catch(m){if(m instanceof w)throw m;let h=m instanceof Error?m.message:String(m);throw new w("BRIDGE_VENV_BOOTSTRAP_FAILED",h)}}async function xt(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1")return {kind:"venv",pythonPath:await B()};for(let r of O())if(await rt(r))return {kind:"system",cmd:r};let t=await ot();if(!t)throw new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");let e;try{e=await N(t);}catch{e=await B();}return {kind:"venv",pythonPath:e}}async function Bt(t,e){try{let r=await F(e?.cwd),n=r.cmd,i=[...r.baseArgs,...t];if(t[0]==="init"){let s=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"}),c=J((s.stdout??"").toString()),l=J((s.stderr??"").toString());return c&&process.stdout.write(c.endsWith(`
20
+ `)?c:`${c}
21
+ `),l&&process.stderr.write(l.endsWith(`
22
+ `)?l:`${l}
23
+ `),typeof s.exitCode=="number"?s.exitCode:1}let a=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"inherit"});return typeof a.exitCode=="number"?a.exitCode:1}catch(r){return process.stderr.write(`${S(r)}
24
+ `),1}}var Rt=[{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 Ft(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(a=>{let s=r(i,o,{cwd:e?.cwd,env:{...process.env,...e?.env},stdio:["inherit","inherit","pipe"]}),c=[];s.stderr?.on("data",l=>{c.push(l);}),s.on("close",l=>{let P=l??1;if(P!==0&&c.length>0){let C=Buffer.concat(c).toString("utf8");for(let{pattern:x,message:m}of Rt){let h=C.match(x);if(h){process.stderr.write(m(h)+`
29
+ `),a(P);return}}process.stderr.write(C);}a(P);}),s.on("error",l=>{process.stderr.write(`${S(l)}
30
+ `),a(1);});})}catch(n){return process.stderr.write(`${S(n)}
31
+ `),1}}async function k(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:`${S(r)}
32
+ `}}}function at(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 l=c[1].trim();l&&!l.startsWith("-")&&e.add(l);}continue}if(!o.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(o))continue;let a=o.match(/^\s*([a-z0-9][a-z0-9_-]*)\b/i);if(!a)continue;let s=a[1].trim();s&&!s.startsWith("-")&&e.add(s);}return e}async function ct(){let t=nt();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 z(t){let e=nt();await p.ensureDir(u.dirname(e)),await p.writeJson(e,t,{spaces:2});}async function bt(){let t=await k(["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 At(){let t=await k(["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 Gt(){let e=Date.now(),r=await ct(),n=await bt(),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 At();if(o?.length){let l=Array.from(new Set(o)).sort();return await z({schema_version:1,fetched_at:e,rapidkit_version:n,commands:l}),new Set(l)}let a=await k(["--help"],{cwd:process.cwd()});if(a.exitCode!==0)return i&&r?.commands?new Set(r.commands):new Set(M);let s=at(a.stdout);if(s.size===0)return new Set(M);let c=Array.from(s).sort();return await z({schema_version:1,fetched_at:e,rapidkit_version:n,commands:c}),s}async function Lt(){let e=Date.now(),r=await ct();return !r||e-r.fetched_at>=864e5||!r.commands?.length?null:new Set(r.commands)}function dt(){return u.join(j(),"rapidkit","npm-bridge","modules-catalog.json")}async function It(){let t=dt();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=dt();await p.ensureDir(u.dirname(e)),await p.writeJson(e,t,{spaces:2});}function X(t){try{return JSON.parse(t)}catch{return null}}async function Kt(t={}){let e=typeof t.ttlMs=="number"?t.ttlMs:18e5,r=Date.now(),n=await It();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 k(i,{cwd:t.cwd,env:t.env});if(o.exitCode===0){let s=X(o.stdout);if(s&&s.schema_version===1&&Array.isArray(s.modules)){let c={...s,fetched_at:r};return await Z(c),c}}let a=await k(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(a.exitCode===0){let s=X(a.stdout);if(Array.isArray(s)){let c={schema_version:1,generated_at:new Date().toISOString(),filters:{category:t.category??null,tag:t.tag??null,detailed:!!t.detailed},stats:{total:s.length,returned:s.length,invalid:0},modules:s,source:"legacy-json",fetched_at:r};return await Z(c),c}}return n||null}var Jt={pythonCommandCandidates:O,pickSystemPython:ot,ensureBridgeVenv:N,ensureBridgeVenvFromCandidates:B,parseCoreCommandsFromHelp:at,tryRapidkit:rt,findUserLocalRapidkitRunner:tt,findWorkspaceRunner:it,checkRapidkitCoreAvailable:vt,checkRapidkitCoreVersionCompatible:kt,isVersionSatisfyingConstraint:st};export{M as a,vt as b,kt as c,xt as d,Bt as e,Ft as f,k as g,Gt as h,Lt as i,Kt as j,Jt as k};
@@ -1,4 +1,4 @@
1
- import {a as a$1}from'./chunk-VM2TOHNX.js';import {promises}from'fs';import a from'path';import I from'os';import {pathToFileURL}from'url';var K=".rapidkitrc.json",k=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function $(){let e=a.join(I.homedir(),K);try{let t=await promises.readFile(e,"utf-8"),n=JSON.parse(t);return a$1.debug(`Loaded config from ${e}`),n}catch{return a$1.debug("No user config found, using defaults"),{}}}async function O(e=process.cwd()){let t=e,n=a.parse(t).root;for(;t!==n;){for(let s of k){let i=a.join(t,s);try{await promises.access(i),a$1.debug(`Found config file: ${i}`);let c=await import(pathToFileURL(i).href),x=c.default||c;return a$1.debug(`Loaded RapidKit config from ${s}`),x}catch{continue}}t=a.dirname(t);}return a$1.debug("No RapidKit config file found, using defaults"),{}}function N(e,t,n){return {author:n.author||t.workspace?.defaultAuthor||e.author,pythonVersion:n.pythonVersion||t.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:n.defaultInstallMethod||t.workspace?.installMethod||e.defaultInstallMethod,defaultKit:n.defaultKit||t.projects?.defaultKit||e.defaultKit,skipGit:n.skipGit??t.projects?.skipGit??e.skipGit,license:n.license||e.license,testRapidKitPath:n.testRapidKitPath||e.testRapidKitPath}}function v(e){return process.env.RAPIDKIT_DEV_PATH||e.testRapidKitPath||void 0}var o=class extends Error{constructor(n,s,i){super(n);this.code=s;this.details=i;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},p=class extends o{constructor(t,n){let s=n?`Python ${t}+ required, found ${n}`:`Python ${t}+ not found`;super(s,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},d=class extends o{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},f=class extends o{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},u=class extends o{constructor(t){super(`Directory "${t}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},g=class extends o{constructor(t,n){super(`Invalid project name: "${t}"`,"INVALID_PROJECT_NAME",n);}},h=class extends o{constructor(t,n){let s=`Installation failed at: ${t}`,i=`${n.message}
1
+ import {a as a$1}from'./chunk-VM2TOHNX.js';import {promises}from'fs';import a from'path';import I from'os';import {pathToFileURL}from'url';var K=".rapidkitrc.json",k=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function $(){let e=a.join(I.homedir(),K);try{let t=await promises.readFile(e,"utf-8"),n=JSON.parse(t);return a$1.debug(`Loaded config from ${e}`),n}catch{return a$1.debug("No user config found, using defaults"),{}}}async function O(e=process.cwd()){let t=e,n=a.parse(t).root;for(;t!==n;){for(let s of k){let i=a.join(t,s);try{await promises.access(i),a$1.debug(`Found config file: ${i}`);let c=await import(pathToFileURL(i).href),x=c.default||c;return a$1.debug(`Loaded RapidKit config from ${s}`),x}catch{continue}}t=a.dirname(t);}return a$1.debug("No RapidKit config file found, using defaults"),{}}function N(e,t,n){return {author:n.author||t.workspace?.defaultAuthor||e.author,pythonVersion:n.pythonVersion||t.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:n.defaultInstallMethod||t.workspace?.installMethod||e.defaultInstallMethod,defaultKit:n.defaultKit||t.projects?.defaultKit||e.defaultKit,skipGit:n.skipGit??t.projects?.skipGit??e.skipGit,license:n.license||e.license,testRapidKitPath:n.testRapidKitPath||e.testRapidKitPath}}function v(e){return process.env.RAPIDKIT_DEV_PATH||e.testRapidKitPath||void 0}var o=class extends Error{constructor(n,s,i){super(n);this.code=s;this.details=i;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}code;details},p=class extends o{constructor(t,n){let s=n?`Python ${t}+ required, found ${n}`:`Python ${t}+ not found`;super(s,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},d=class extends o{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},f=class extends o{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},u=class extends o{constructor(t){super(`Directory "${t}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},g=class extends o{constructor(t,n){super(`Invalid project name: "${t}"`,"INVALID_PROJECT_NAME",n);}},h=class extends o{constructor(t,n){let s=`Installation failed at: ${t}`,i=`${n.message}
2
2
 
3
3
  Troubleshooting:
4
4
  - Check your internet connection
@@ -0,0 +1,9 @@
1
+ import {a}from'./chunk-QUNCXYYK.js';import {d,e}from'./chunk-KXTXQODI.js';import {a as a$1}from'./chunk-VKLL63TL.js';import h from'fs';import o from'path';import s from'chalk';var F=new Set([".git",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function y(e){try{return await h.promises.access(e,h.constants.F_OK),true}catch{return false}}async function v(e){try{let n=JSON.parse(await h.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function I(e){try{return await h.promises.readFile(e,"utf-8")}catch{return ""}}function G(e){return a(e)}async function E(e,n){return await y(o.join(e,".rapidkit","project.json"))||await y(o.join(e,".rapidkit","context.json"))?true:o.resolve(e)===o.resolve(n)?d(e).length>0:d(e).length>0}async function S(e){let n=await a$1(e,{skipDirs:F,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:E});return n.length>0?n:d(e).length>0?[e]:[]}function T(e,n){return o.relative(e,n).replace(/\\/g,"/")||"."}async function b(e,n){for(let t of n)if(await y(o.join(e,t)))return true;return false}async function N(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 K(e){if(await b(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await v(o.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 O(e){let n=await v(o.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,i,r,c){return {id:e,severity:n,target:t,title:i,detail:r,remediation:c}}function _(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 J(e$1,n){let t=await v(o.join(n,".rapidkit","project.json")),i=e(n,t),r=d(n),c=i.runtime==="unknown"?r[0]||"unknown":i.runtime,a=T(e$1,n),d$1=a,m=await O(n),u=await y(o.join(n,".rapidkit","project.json"))||await y(o.join(n,".rapidkit","context.json")),g=await K(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 N(n),l=[];return i.key==="unknown"&&l.push(f("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`.")),u||l.push(f("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.")),g||l.push(f("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(f("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(f("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(f("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(f("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:o.basename(n),path:n,relativePath:a,runtime:c,framework:i.key,confidence:i.confidence,supportTier:i.supportTier,hasRapidKitMarker:u,hasTests:g,hasDockerfile:k,hasEnvExample:w,hasCiConfig:A,hasHealthEndpoint:z,scripts:m,findings:l,score:_(l)}}function M(e){return e.name.toLowerCase()}async function W(e){let n=new Map(e.map(r=>[M(r),r])),t=[];for(let r of e){let c=await v(o.join(r.path,"package.json")),a={...c?.dependencies??{},...c?.devDependencies??{},...c?.peerDependencies??{}};for(let m of Object.keys(a)){let u=m.replace(/^@[^/]+\//,"").toLowerCase(),g=n.get(u);g&&g.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:g.relativePath,kind:"package"});}let d=await I(o.join(r.path,"pyproject.toml"));for(let m of e)m.relativePath!==r.relativePath&&d.includes(m.name)&&t.push({from:r.relativePath,to:m.relativePath,kind:"workspace-reference"});}let i=new Set;return t.filter(r=>{let c=`${r.from}\0${r.to}\0${r.kind}`;return i.has(c)?false:(i.add(c),true)})}function H(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 r=t.get(i.from),c=t.get(i.to);r&&(r.directDependencies+=1),c&&(c.directDependents+=1);}return Array.from(t.values()).sort((i,r)=>r.directDependents-i.directDependents||r.directDependencies-i.directDependencies)}async function B(e){let n=await v(o.join(e,".rapidkit","workspace.json"));return typeof n?.profile=="string"?n.profile:null}function U(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 te(e={}){let n=o.resolve(e.workspacePath||process.cwd());if(!await y(n))throw new Error(`Workspace path does not exist: ${n}`);let t=G(n)??n,i=await y(o.join(t,".rapidkit-workspace"))||await y(o.join(t,".rapidkit","workspace.json")),r=await B(t),c=await S(t),a=await Promise.all(c.map(p=>J(t,p))),d=await W(a),m=H(a,d),u=[];i||u.push(f("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&&u.push(f("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 g=[...u,...a.flatMap(p=>p.findings)],k=U(g),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=u.reduce((p,P)=>p+(P.severity==="fail"?20:P.severity==="warn"?8:2),0),l=Math.max(0,A-z),$=k.fail>0||e.strict&&k.warn>0?"blocked":k.warn>0?"needs-attention":"ready",C={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:i,profile:r,summary:{score:l,verdict:$,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:g,nextActions:V({findings:g,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 h.promises.mkdir(o.dirname(o.resolve(e.output)),{recursive:true}),await h.promises.writeFile(o.resolve(e.output),`${JSON.stringify(C,null,2)}
2
+ `)),!e.output&&i){let p=o.join(t,".rapidkit","reports","analyze-last-run.json");await h.promises.mkdir(o.dirname(p),{recursive:true}),await h.promises.writeFile(p,`${JSON.stringify(C,null,2)}
3
+ `);}return C}function ie(e){let n=e.summary.verdict==="ready"?s.green:e.summary.verdict==="needs-attention"?s.yellow:s.red;if(console.log(s.bold(`
4
+ RapidKit Workspace Analysis
5
+ `)),console.log(s.cyan("Workspace:"),e.workspacePath),console.log(s.cyan("Profile:"),e.profile||"not configured"),console.log(s.cyan("Score:"),`${e.summary.score}/100`),console.log(s.cyan("Verdict:"),n(e.summary.verdict)),console.log(s.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(s.bold(`
6
+ Projects`));for(let t of e.projects){let i=t.score>=85?s.green("pass"):t.score>=65?s.yellow("watch"):s.red("risk");console.log(` ${t.relativePath} ${s.gray(`${t.runtime}/${t.framework}`)} ${i} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(s.bold(`
7
+ Dependency Graph`)),console.log(s.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(s.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(s.bold(`
8
+ Top Findings`));for(let t of e.findings.slice(0,8)){let i=t.severity==="fail"?s.red:t.severity==="warn"?s.yellow:s.gray;console.log(` ${i(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(s.gray(` ${t.remediation}`));}}console.log(s.bold(`
9
+ Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(s.gray(` - ${t}`));console.log();}export{te as a,ie as b};
@@ -0,0 +1,4 @@
1
+ import {a}from'./chunk-QUNCXYYK.js';import {a as a$1,b,d as d$1,c as c$1,f}from'./chunk-QCZGNOTH.js';import {c as c$2}from'./chunk-NFUXULIF.js';import c from'chalk';import l from'fs';import y from'fs-extra';import d from'path';function A(t){let e=a$1(t);return b(e,t)?"go":d$1(e,t)?"java":c$1(e,t)?"node":f(e,t)?"python":"unknown"}function j(t,e){if(!l.existsSync(t))return null;let a=l.readdirSync(t).filter(s=>s.endsWith(".json")&&e.some(r=>r.test(s))).map(s=>d.join(t,s));return a.length===0?null:(a.sort((s,r)=>l.statSync(r).mtimeMs-l.statSync(s).mtimeMs),a[0])}function p(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function O(t,e){let a=d.join(t,".rapidkit","toolchain.lock");if(!l.existsSync(a))return {gate:"env",status:"fail",summary:"toolchain.lock is missing",details:["Run rapidkit bootstrap to pin runtime versions and generate a reproducible toolchain."],evidencePath:a};try{let s=JSON.parse(l.readFileSync(a,"utf-8")),r=p(s.runtime),i=["python","node","go","java"].filter(n=>{let u=p(r[n]);return typeof u.version=="string"&&u.version.trim().length>0});if(i.length===0)return {gate:"env",status:"fail",summary:"No runtime versions are pinned in toolchain.lock",details:["Pin at least one runtime version via rapidkit setup <runtime> and re-run bootstrap."],evidencePath:a};if(e!=="unknown"){let n=p(r[e]);if(typeof n.version!="string"||n.version.trim().length===0)return {gate:"env",status:"fail",summary:`Project runtime (${e}) is not pinned in toolchain.lock`,details:[`Run rapidkit setup ${e} and rapidkit bootstrap to lock ${e} for this workspace.`],evidencePath:a}}return {gate:"env",status:"pass",summary:`Pinned runtimes: ${i.join(", ")}`,details:[],evidencePath:a}}catch{return {gate:"env",status:"fail",summary:"toolchain.lock is invalid JSON",details:["Regenerate lockfile with rapidkit bootstrap."],evidencePath:a}}}function C(t){let e=d.join(t,".rapidkit","reports","doctor-last-run.json");if(!l.existsSync(e))return {payload:null,path:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8"));return c$2(a,"workspace")?{payload:a,path:e}:{payload:null,path:e}}catch{return {payload:null,path:e}}}function G(t){let e=C(t);if(!e.payload)return {gate:{gate:"doctor",status:"fail",summary:"Doctor evidence is missing",details:["Run rapidkit doctor workspace --json before release readiness checks."],evidencePath:e.path},payload:null};let a=p(e.payload.summary),s=Number(a.totalIssues??0);return a.hasSystemErrors?{gate:{gate:"doctor",status:"fail",summary:"Doctor reported system errors",details:["Resolve system-level doctor errors before proceeding."],evidencePath:e.path},payload:e.payload}:s>0?{gate:{gate:"doctor",status:"warn",summary:`Doctor found ${s} issue(s)`,details:["Run rapidkit doctor workspace --fix and re-run readiness checks."],evidencePath:e.path},payload:e.payload}:{gate:{gate:"doctor",status:"pass",summary:"Doctor checks passed without issues",details:[],evidencePath:e.path},payload:e.payload}}function N(t){let e=d.join(t,".rapidkit","reports","analyze-last-run.json");if(!l.existsSync(e))return {gate:"analyze",status:"fail",summary:"Analyze evidence is missing",details:["Run rapidkit analyze --json before release readiness checks."],evidencePath:e};try{let a=JSON.parse(l.readFileSync(e,"utf-8")),s=p(a.summary),r=String(s.verdict??"").toLowerCase(),o=Number(s.score??0),i=p(s.findings),n=Number(i.fail??0);return r==="blocked"||n>0?{gate:"analyze",status:"fail",summary:`Analyze verdict is blocked (score ${o}/100)`,details:["Resolve analyze findings and regenerate analyze-last-run.json."],evidencePath:e}:r==="needs-attention"?{gate:"analyze",status:"warn",summary:`Analyze needs attention (score ${o}/100)`,details:["Review analyze warnings before release."],evidencePath:e}:{gate:"analyze",status:"pass",summary:`Analyze passed (score ${o}/100)`,details:[],evidencePath:e}}catch{return {gate:"analyze",status:"fail",summary:"Analyze evidence is invalid JSON",details:["Re-run rapidkit analyze --json to regenerate evidence."],evidencePath:e}}}function $(t){try{let e=JSON.parse(l.readFileSync(t,"utf-8")),a=String(e.status??"").toLowerCase(),s=p(e.summary),r=Number(s.failedChecks??0);return a==="fail"||r>0?{gate:"verify",status:"fail",summary:"Verify-pack contract reports failed checks",details:["Fix failed verify checks and regenerate verify-pack contract evidence."],evidencePath:t}:a==="pass"?{gate:"verify",status:"pass",summary:"Verify-pack contract passed",details:[],evidencePath:t}:{gate:"verify",status:"warn",summary:"Verify-pack contract status is not explicit",details:["Ensure contract status is pass/fail and keep schema aligned with v1 contract."],evidencePath:t}}catch{return {gate:"verify",status:"fail",summary:"Verify-pack contract is invalid JSON",details:["Regenerate verify-pack contract artifact."],evidencePath:t}}}async function x(t,e){if(e.skipVerify)return {gate:"verify",status:"pass",summary:"Verify gate skipped (--skip-verify)",details:["Verification was explicitly skipped for this readiness run."]};let a=d.join(t,".rapidkit","reports"),s=j(a,[/verify-pack-contract/i,/^verify.*\.json$/i]);if(s)return $(s);let r=d.join(a,"workspace-contract-verify-last-run.json"),o=j(a,[/workspace-contract-verify-last-run/i,/workspace-contract-verify/i]);if(o)try{let i=JSON.parse(l.readFileSync(o,"utf-8")),n=String(i.status??"").toLowerCase();if(n==="passed"||n==="pass")return {gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI cache)",details:[],evidencePath:o};if(n==="failed"||n==="fail")return {gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI cache)",details:(Array.isArray(i.violations)?i.violations:[]).slice(0,5),evidencePath:o}}catch{}try{let{verifyWorkspaceContract:i}=await import('./workspace-contract-Z5VYUF3T.js'),n=await i({workspacePath:t}),u={schemaVersion:"v1",source:"cli",generatedAt:new Date().toISOString(),status:n.status,contractPath:n.contractPath,projectCount:n.projectCount,checks:n.checks,violations:n.violations};return await y.ensureDir(a),await y.writeJSON(r,u,{spaces:2}),n.status==="failed"?{gate:"verify",status:"fail",summary:"Workspace contract verification failed (CLI)",details:n.violations.slice(0,5),evidencePath:r}:{gate:"verify",status:"pass",summary:"Workspace contract verification passed (CLI)",details:[],evidencePath:r}}catch(i){return {gate:"verify",status:"fail",summary:"No verify evidence and workspace contract verification unavailable",details:["Run rapidkit workspace contract verify --json or export verify-pack contract from CI.",i instanceof Error?i.message:String(i)],evidencePath:d.join(a,"*verify*.json")}}}function z(t,e){let a=d.join(e,".rapidkit","reports","doctor-last-run.json");if(!t)return {gate:"dependency",status:"warn",summary:"Dependency risk check skipped (doctor evidence missing)",details:["Run rapidkit doctor workspace --json to include dependency findings."],evidencePath:a};let s=Array.isArray(t.projects)?t.projects:[],r=s.reduce((i,n)=>{let u=Number(n.vulnerabilities??0);return Number.isFinite(u)?i+Math.max(0,u):i},0),o=s.filter(i=>i.depsInstalled===false).length;return r>0?{gate:"dependency",status:"fail",summary:`${r} dependency vulnerability(ies) reported`,details:["Resolve vulnerabilities (npm/pip/go audit pipelines) before release."],evidencePath:a}:o>0?{gate:"dependency",status:"warn",summary:`${o} project(s) report missing dependencies`,details:["Run project init/bootstrap and regenerate doctor evidence."],evidencePath:a}:{gate:"dependency",status:"pass",summary:"No dependency vulnerabilities reported",details:[],evidencePath:a}}function V(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}async function E(t,e){let a=d.join(t,".rapidkit","reports","release-readiness-last-run.json");return await y.ensureDir(d.dirname(a)),await y.writeJSON(a,e,{spaces:2}),a}async function I(t={}){let e=d.resolve(t.startPath??process.cwd()),a$1=a(e)??e,s=A(e),r=O(a$1,s),o=G(a$1),i=N(a$1),n=await x(a$1,{skipVerify:t.skipVerify}),u=z(o.payload,a$1),m=[r,o.gate,i,n,u],g=V(m),v={schemaVersion:"v1",generatedAt:new Date().toISOString(),workspacePath:a$1,projectPath:e,action:t.action,overallStatus:g,blocking:g==="fail",blockingReasons:m.filter(f=>f.status==="fail").map(f=>`${f.gate}: ${f.summary}`),gates:m};return t.writeReport!==false&&(v.evidencePath=await E(a$1,v)),v}function J(t){return t==="pass"?c.green("PASS"):t==="warn"?c.yellow("WARN"):c.red("FAIL")}function D(t){return t==="pass"?c.green("PASS"):t==="warn"?c.yellow("WARN"):c.red("FAIL")}async function Q(t){let e=await I({writeReport:true,skipVerify:t.skipVerify===true});if(t.json)console.log(JSON.stringify(e,null,2));else {console.log(c.bold.cyan(`
2
+ \u{1F6A6} RapidKit Release Readiness
3
+ `)),console.log(c.bold(`Workspace: ${c.cyan(d.basename(e.workspacePath))}`)),console.log(c.gray(`Path: ${e.workspacePath}`)),console.log(`Overall: ${D(e.overallStatus)}`);for(let a of e.gates){console.log(` - ${a.gate}: ${J(a.status)} ${a.summary}`);for(let s of a.details)console.log(c.gray(` ${s}`));a.evidencePath&&console.log(c.gray(` evidence: ${a.evidencePath}`));}e.evidencePath&&console.log(c.gray(`
4
+ Evidence saved: ${e.evidencePath}`));}t.strict&&e.overallStatus!=="pass"&&process.exit(1);}export{I as a,Q as b};
@@ -0,0 +1 @@
1
+ import n from'fs';import t from'path';function c(e){let r=t.resolve(e);for(;;){if(n.existsSync(t.join(r,".rapidkit-workspace"))||n.existsSync(t.join(r,".rapidkit","workspace.json")))return r;let i=t.dirname(r);if(i===r)return null;r=i;}}export{c as a};
@@ -0,0 +1,7 @@
1
+ import {a}from'./chunk-SAIWD6VM.js';import {a as a$1}from'./chunk-QUNCXYYK.js';import l from'chalk';import _ from'fs';import R from'path';import {execa}from'execa';function D(t){try{return JSON.parse(t)}catch{return null}}function le(t){let r=R.resolve(t),a=a$1(r);if(!a)throw new Error("No RapidKit workspace found in current directory or parents");return a}async function b(t,r){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,...t],{cwd:r,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 q(t){let r=t.toLowerCase();return r==="pass"?"pass":r==="warn"?"warn":r==="fail"?"fail":"warn"}function Q(t){return t.summary.failed>0?"fail":t.gates.results.some(r=>r.status==="warn")?"warn":"pass"}function ce(t){let r=t.filter(o=>o.status!=="skipped");if(r.length===0)return 100;let a=r.reduce((o,e)=>e.status==="pass"?o+1:e.status==="warn"?o+.6:o,0);return Math.round(a/r.length*100)}function ue(t){return t.executionError?["Re-run: npx rapidkit autopilot release --mode audit --json","Inspect .rapidkit/reports/autopilot-release-last-run.json for execution failure details"]:t.blockers.length>0?["Run: npx rapidkit doctor workspace --plan","Run: npx rapidkit readiness --json --strict","Run: npx rapidkit workspace run test --affected --strict"]:t.hasWarnings&&t.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 F(t,r){await _.promises.mkdir(R.dirname(t),{recursive:true}),await _.promises.writeFile(t,`${JSON.stringify(r,null,2)}
2
+ `,"utf-8");}async function ye(t){let r=le(t.workspacePath),a$1=t.mode,o=[],e=[],E,G,I,T,V=0,d=false,B=0,K=0,C=-1,z=-1,c="skipped",p="skipped",X=a$1==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(t.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let s=Date.now(),i=await b([...X],r),m=Date.now()-s;if(c="pass",i.crashed)c="fail",d=true,e.push(`doctor workspace execution error: ${i.stderr||"unknown error"}`);else if(i.exitCode===1)c="fail",e.push("doctor workspace command failed or reported errors");else if(i.exitCode===2)c="warn",e.push("doctor workspace reported warnings");else if(i.exitCode!==0)c="fail",e.push("doctor workspace command failed");else {let u=D(i.stdout),j=u&&u.healthScore&&typeof u.healthScore=="object"?u.healthScore:{},h=Number(j.errors??0),$=Number(j.warnings??0);Number.isFinite(h)&&h>0?(c="fail",e.push(`doctor workspace reports ${h} error(s)`)):Number.isFinite($)&&$>0&&(c="warn");}C=o.push({name:"doctor-workspace",status:c,durationMs:m,summary:c==="pass"?"doctor workspace passed":c==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,a$1==="enforce"&&c==="warn"&&e.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await b(["analyze","--json"],r),A=Date.now()-g;G=R.join(r,".rapidkit","reports","analyze-last-run.json");let n="pass";if(w.crashed)n="fail",d=true,e.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)n=w.exitCode===2?"warn":"fail",e.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let u=D(w.stdout),j=u&&u.summary&&typeof u.summary=="object"?u.summary:{},h=String(j.verdict??"ready");h==="blocked"?(n="fail",e.push("analyze reported blocked verdict")):h==="needs-attention"&&(n="warn");}o.push({name:"analyze",status:n,durationMs:A,summary:n==="pass"?"analyze passed":n==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),a$1==="enforce"&&n==="warn"&&e.push("analyze reported warnings under enforce mode");let P=Date.now(),k=await b(["readiness","--json"],r),y=Date.now()-P;if(p="fail",k.crashed)p="fail",d=true,e.push(`readiness execution error: ${k.stderr||"unknown error"}`);else if(k.exitCode!==0)p="fail",e.push("readiness command failed");else {let u=D(k.stdout),j=String(u?.overallStatus??"fail");if(p=q(j),typeof u?.evidencePath=="string"&&u.evidencePath.trim().length>0&&(E=u.evidencePath),p==="fail"){let h=Array.isArray(u?.blockingReasons)?u?.blockingReasons.filter($=>typeof $=="string"):[];h.length>0?e.push(...h.map($=>`readiness: ${$}`)):e.push("readiness overall status is fail");}}z=o.push({name:"readiness",status:p,durationMs:y,summary:`readiness overall status is ${p}`})-1,a$1==="enforce"&&p==="warn"&&e.push("readiness reported warnings under enforce mode");}let Y=Date.now(),N=await b(["doctor","workspace","--plan","--json"],r),Z=Date.now()-Y,S="warn";if(N.crashed)S="fail",d=true,e.push(`doctor remediation plan execution error: ${N.stderr||"unknown error"}`);else if(N.exitCode!==0)S="fail",e.push("doctor remediation plan command failed");else {let s=D(N.stdout),i=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(i?.totalSteps??0),g=Number(i?.executableSteps??0);Number.isFinite(m)&&m>0&&(B=m),Number.isFinite(g)&&g>0&&(K=g),Number.isFinite(m)&&m===0?S="pass":S="warn";}if(o.push({name:"remediation-plan",status:S,durationMs:Z,summary:S==="pass"?"no remediation steps required":"remediation steps available"}),a$1==="enforce"&&S==="warn"&&e.push("remediation plan has pending steps under enforce mode"),a$1==="safe-fix"){let s=Date.now(),i=await b(["doctor","workspace","--apply"],r),m=Date.now()-s,g=i.crashed||i.exitCode!==0?"fail":"pass";if(i.crashed)d=true,e.push(`doctor remediation apply execution error: ${i.stderr||"unknown error"}`);else if(g==="fail")e.push("doctor remediation apply failed");else {V=K>0?K:B>0?B:1;let w=await b(["doctor","workspace","--json"],r);if(w.crashed)c="fail",d=true,e.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",e.push("post-apply doctor workspace command failed");else {let n=D(w.stdout),P=n&&n.healthScore&&typeof n.healthScore=="object"?n.healthScore:{},k=Number(P.errors??0),y=Number(P.warnings??0);Number.isFinite(k)&&k>0?(c="fail",e.push(`post-apply doctor reports ${k} error(s)`)):Number.isFinite(y)&&y>0?c="warn":c="pass";}C>=0&&(o[C].status=c,o[C].summary=`doctor workspace post-apply status is ${c}`);let A=await b(["readiness","--json"],r);if(A.crashed)p="fail",d=true,e.push(`post-apply readiness execution error: ${A.stderr||"unknown error"}`);else if(A.exitCode!==0)p="fail",e.push("post-apply readiness command failed");else {let n=D(A.stdout),P=String(n?.overallStatus??"fail");if(p=q(P),typeof n?.evidencePath=="string"&&n.evidencePath.trim().length>0&&(E=n.evidencePath),p==="fail"){let k=Array.isArray(n?.blockingReasons)?n?.blockingReasons.filter(y=>typeof y=="string"):[];k.length>0?e.push(...k.map(y=>`post-apply readiness: ${y}`)):e.push("post-apply readiness overall status is fail");}}z>=0&&(o[z].status=p,o[z].summary=`readiness post-apply overall status is ${p}`);}o.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="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 O=Date.now(),x="pass",v="workspace test/build completed for selected projects";try{let s=await a({workspacePath:r,stage:"test",affected:true,since:t.since,parallel:t.parallel,maxWorkers:t.maxWorkers,strict:true,json:true,enforceGates:false});I=R.join(r,".rapidkit","reports","autopilot-workspace-run-test.json"),await F(I,s);let i=Q(s);if(i==="fail")x="fail",v="workspace test stage failed for selected projects",e.push("workspace run test failed for selected projects");else {i==="warn"&&(x="warn",v="workspace test stage completed with warnings",a$1==="enforce"&&e.push("workspace run test reported warnings under enforce mode"));let m=await a({workspacePath:r,stage:"build",affected:true,since:t.since,parallel:t.parallel,maxWorkers:t.maxWorkers,strict:true,json:true,enforceGates:false});T=R.join(r,".rapidkit","reports","autopilot-workspace-run-build.json"),await F(T,m);let g=Q(m);g==="fail"?(x="fail",v="workspace build stage failed for selected projects",e.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",v="workspace test/build completed with warnings",a$1==="enforce"&&e.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){x="fail",v="workspace test/build orchestration failed",d=true,e.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let ee=Date.now()-O;o.push({name:"workspace-run-test-build",status:x,durationMs:ee,summary:v});let M=o.filter(s=>s.status==="warn").length,te=o.filter(s=>s.status==="fail").length,J=a$1==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):te>0,W=[...new Set(e)],se=d||J?Math.max(1,W.length):0,re=ce(o),oe=d||J?"blocked":M>0?"partial":"approved",ae=d?3:J?1:M>0?2:0,ne=ue({mode:a$1,executionError:d,blockers:W,hasWarnings:M>0}),H=R.join(r,".rapidkit","reports","autopilot-release-last-run.json"),f={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:r,mode:a$1,summary:{releaseScore:re,verdict:oe,blockers:se,warnings:M,safeFixesApplied:V,manualActions:W.length,exitCode:ae},stages:o,blockingReasons:W,nextActions:ne,artifacts:{reportPath:H,analyzeEvidencePath:G,readinessEvidencePath:E,workspaceRunTestPath:I,workspaceRunBuildPath:T}};if(await F(H,f),t.output&&await F(R.resolve(t.output),f),!t.json){console.log(l.bold.cyan(`
3
+ \u{1F680} RapidKit Autopilot Release
4
+ `)),console.log(l.bold(`Workspace: ${l.cyan(R.basename(r))}`)),console.log(l.gray(`Path: ${r}`)),console.log(l.white(`Mode: ${a$1}`)),console.log(l.white(`Verdict: ${f.summary.verdict==="approved"?l.green("approved"):f.summary.verdict==="partial"?l.yellow("partial"):l.red("blocked")}`)),console.log(l.white(`Release score: ${f.summary.releaseScore}`));for(let s of f.stages){let i=s.status==="pass"?l.green("PASS"):s.status==="warn"?l.yellow("WARN"):s.status==="skipped"?l.gray("SKIP"):l.red("FAIL");console.log(` - ${s.name}: ${i} ${s.summary} (${s.durationMs}ms)`);}if(f.blockingReasons.length>0){console.log(l.bold.red(`
5
+ Blocking reasons:`));for(let s of f.blockingReasons)console.log(l.red(` - ${s}`));}if(f.nextActions.length>0){console.log(l.bold(`
6
+ Next actions:`));for(let s of f.nextActions)console.log(l.gray(` - ${s}`));}console.log(l.gray(`
7
+ Report: ${f.artifacts.reportPath}`));}return f}export{ye as a};