rapidkit 0.32.1 → 0.32.2

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,4 +1,4 @@
1
- import {a}from'./chunk-LSFRHYMD.js';import n from'chalk';import W from'fs';import g from'path';import {execa}from'execa';function b(s){try{return JSON.parse(s)}catch{return null}}function ie(s){let t=g.resolve(s);for(;;){if(W.existsSync(g.join(t,".rapidkit-workspace"))||W.existsSync(g.join(t,".rapidkit","workspace.json")))return t;let a=g.dirname(t);if(a===t)return null;t=a;}}function le(s){let t=g.resolve(s),a=ie(t);if(!a)throw new Error("No RapidKit workspace found in current directory or parents");return a}async function S(s,t){let a=process.argv[1];if(!a)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[a,...s],{cwd:t,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function H(s){let t=s.toLowerCase();return t==="pass"?"pass":t==="warn"?"warn":t==="fail"?"fail":"warn"}function U(s){return s.summary.failed>0?"fail":s.gates.results.some(t=>t.status==="warn")?"warn":"pass"}function ce(s){let t=s.filter(o=>o.status!=="skipped");if(t.length===0)return 100;let a=t.reduce((o,r)=>r.status==="pass"?o+1:r.status==="warn"?o+.6:o,0);return Math.round(a/t.length*100)}function ue(s){return s.executionError?["Re-run: npx rapidkit autopilot release --mode audit --json","Inspect .rapidkit/reports/autopilot-release-last-run.json for execution failure details"]:s.blockers.length>0?["Run: npx rapidkit doctor workspace --plan","Run: npx rapidkit readiness --json --strict","Run: npx rapidkit workspace run test --affected --strict"]:s.hasWarnings&&s.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx rapidkit autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function N(s,t){await W.promises.mkdir(g.dirname(s),{recursive:true}),await W.promises.writeFile(s,`${JSON.stringify(t,null,2)}
1
+ import {a}from'./chunk-3V47U5UZ.js';import n from'chalk';import W from'fs';import g from'path';import {execa}from'execa';function b(s){try{return JSON.parse(s)}catch{return null}}function ie(s){let t=g.resolve(s);for(;;){if(W.existsSync(g.join(t,".rapidkit-workspace"))||W.existsSync(g.join(t,".rapidkit","workspace.json")))return t;let a=g.dirname(t);if(a===t)return null;t=a;}}function le(s){let t=g.resolve(s),a=ie(t);if(!a)throw new Error("No RapidKit workspace found in current directory or parents");return a}async function S(s,t){let a=process.argv[1];if(!a)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[a,...s],{cwd:t,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function H(s){let t=s.toLowerCase();return t==="pass"?"pass":t==="warn"?"warn":t==="fail"?"fail":"warn"}function U(s){return s.summary.failed>0?"fail":s.gates.results.some(t=>t.status==="warn")?"warn":"pass"}function ce(s){let t=s.filter(o=>o.status!=="skipped");if(t.length===0)return 100;let a=t.reduce((o,r)=>r.status==="pass"?o+1:r.status==="warn"?o+.6:o,0);return Math.round(a/t.length*100)}function ue(s){return s.executionError?["Re-run: npx rapidkit autopilot release --mode audit --json","Inspect .rapidkit/reports/autopilot-release-last-run.json for execution failure details"]:s.blockers.length>0?["Run: npx rapidkit doctor workspace --plan","Run: npx rapidkit readiness --json --strict","Run: npx rapidkit workspace run test --affected --strict"]:s.hasWarnings&&s.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx rapidkit autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function N(s,t){await W.promises.mkdir(g.dirname(s),{recursive:true}),await W.promises.writeFile(s,`${JSON.stringify(t,null,2)}
2
2
  `,"utf-8");}async function ke(s){let t=le(s.workspacePath),a$1=s.mode,o=[],r=[],M,F,E,J=0,f=false,I=0,T=0,_=Date.now(),x=await S(["doctor","workspace","--json"],t),q=Date.now()-_,u="pass";if(x.crashed)u="fail",f=true,r.push(`doctor workspace execution error: ${x.stderr||"unknown error"}`);else if(x.exitCode!==0)u="fail",r.push("doctor workspace command failed");else {let e=b(x.stdout),i=e&&e.healthScore&&typeof e.healthScore=="object"?e.healthScore:{},l=Number(i.errors??0),c=Number(i.warnings??0);Number.isFinite(l)&&l>0?(u="fail",r.push(`doctor workspace reports ${l} error(s)`)):Number.isFinite(c)&&c>0&&(u="warn");}let L=o.push({name:"doctor-workspace",status:u,durationMs:q,summary:u==="pass"?"doctor workspace passed":u==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1;a$1==="enforce"&&u==="warn"&&r.push("doctor workspace reported warnings under enforce mode");let z=Date.now(),A=await S(["readiness","--json"],t),O=Date.now()-z,p="fail";if(A.crashed)p="fail",f=true,r.push(`readiness execution error: ${A.stderr||"unknown error"}`);else if(A.exitCode!==0)p="fail",r.push("readiness command failed");else {let e=b(A.stdout),i=String(e?.overallStatus??"fail");if(p=H(i),typeof e?.evidencePath=="string"&&e.evidencePath.trim().length>0&&(M=e.evidencePath),p==="fail"){let l=Array.isArray(e?.blockingReasons)?e?.blockingReasons.filter(c=>typeof c=="string"):[];l.length>0?r.push(...l.map(c=>`readiness: ${c}`)):r.push("readiness overall status is fail");}}let V=o.push({name:"readiness",status:p,durationMs:O,summary:`readiness overall status is ${p}`})-1;a$1==="enforce"&&p==="warn"&&r.push("readiness reported warnings under enforce mode");let Q=Date.now(),v=await S(["doctor","workspace","--plan","--json"],t),X=Date.now()-Q,w="warn";if(v.crashed)w="fail",f=true,r.push(`doctor remediation plan execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)w="fail",r.push("doctor remediation plan command failed");else {let e=b(v.stdout),i=e&&e.remediationPlan&&typeof e.remediationPlan=="object"?e.remediationPlan:null,l=Number(i?.totalSteps??0),c=Number(i?.executableSteps??0);Number.isFinite(l)&&l>0&&(I=l),Number.isFinite(c)&&c>0&&(T=c),Number.isFinite(l)&&l===0?w="pass":w="warn";}if(o.push({name:"remediation-plan",status:w,durationMs:X,summary:w==="pass"?"no remediation steps required":"remediation steps available"}),a$1==="enforce"&&w==="warn"&&r.push("remediation plan has pending steps under enforce mode"),a$1==="safe-fix"){let e=Date.now(),i=await S(["doctor","workspace","--apply"],t),l=Date.now()-e,c=i.crashed||i.exitCode!==0?"fail":"pass";if(i.crashed)f=true,r.push(`doctor remediation apply execution error: ${i.stderr||"unknown error"}`);else if(c==="fail")r.push("doctor remediation apply failed");else {J=T>0?T:I>0?I:1;let $=await S(["doctor","workspace","--json"],t);if($.crashed)u="fail",f=true,r.push(`post-apply doctor execution error: ${$.stderr||"unknown error"}`);else if($.exitCode!==0)u="fail",r.push("post-apply doctor workspace command failed");else {let m=b($.stdout),C=m&&m.healthScore&&typeof m.healthScore=="object"?m.healthScore:{},R=Number(C.errors??0),y=Number(C.warnings??0);Number.isFinite(R)&&R>0?(u="fail",r.push(`post-apply doctor reports ${R} error(s)`)):Number.isFinite(y)&&y>0?u="warn":u="pass";}o[L].status=u,o[L].summary=`doctor workspace post-apply status is ${u}`;let D=await S(["readiness","--json"],t);if(D.crashed)p="fail",f=true,r.push(`post-apply readiness execution error: ${D.stderr||"unknown error"}`);else if(D.exitCode!==0)p="fail",r.push("post-apply readiness command failed");else {let m=b(D.stdout),C=String(m?.overallStatus??"fail");if(p=H(C),typeof m?.evidencePath=="string"&&m.evidencePath.trim().length>0&&(M=m.evidencePath),p==="fail"){let R=Array.isArray(m?.blockingReasons)?m?.blockingReasons.filter(y=>typeof y=="string"):[];R.length>0?r.push(...R.map(y=>`post-apply readiness: ${y}`)):r.push("post-apply readiness overall status is fail");}}o[V].status=p,o[V].summary=`readiness post-apply overall status is ${p}`;}o.push({name:"remediation-apply",status:c,durationMs:l,summary:c==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let Y=Date.now(),h="pass",k="workspace test/build completed for selected projects";try{let e=await a({workspacePath:t,stage:"test",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});F=g.join(t,".rapidkit","reports","autopilot-workspace-run-test.json"),await N(F,e);let i=U(e);if(i==="fail")h="fail",k="workspace test stage failed for selected projects",r.push("workspace run test failed for selected projects");else {i==="warn"&&(h="warn",k="workspace test stage completed with warnings",a$1==="enforce"&&r.push("workspace run test reported warnings under enforce mode"));let l=await a({workspacePath:t,stage:"build",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});E=g.join(t,".rapidkit","reports","autopilot-workspace-run-build.json"),await N(E,l);let c=U(l);c==="fail"?(h="fail",k="workspace build stage failed for selected projects",r.push("workspace run build failed for selected projects")):c==="warn"&&(h="warn",k="workspace test/build completed with warnings",a$1==="enforce"&&r.push("workspace run test/build reported warnings under enforce mode"));}}catch(e){h="fail",k="workspace test/build orchestration failed",f=true,r.push(`workspace run orchestration error: ${e instanceof Error?e.message:String(e)}`);}let Z=Date.now()-Y;o.push({name:"workspace-run-test-build",status:h,durationMs:Z,summary:k});let P=o.filter(e=>e.status==="warn").length,ee=o.filter(e=>e.status==="fail").length,B=a$1==="enforce"?o.some(e=>e.status==="warn"||e.status==="fail"):ee>0,j=[...new Set(r)],te=f||B?Math.max(1,j.length):0,se=ce(o),re=f||B?"blocked":P>0?"partial":"approved",oe=f?3:B?1:P>0?2:0,ae=ue({mode:a$1,executionError:f,blockers:j,hasWarnings:P>0}),G=g.join(t,".rapidkit","reports","autopilot-release-last-run.json"),d={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:t,mode:a$1,summary:{releaseScore:se,verdict:re,blockers:te,warnings:P,safeFixesApplied:J,manualActions:j.length,exitCode:oe},stages:o,blockingReasons:j,nextActions:ae,artifacts:{reportPath:G,readinessEvidencePath:M,workspaceRunTestPath:F,workspaceRunBuildPath:E}};if(await N(G,d),s.output&&await N(g.resolve(s.output),d),!s.json){console.log(n.bold.cyan(`
3
3
  \u{1F680} RapidKit Autopilot Release
4
4
  `)),console.log(n.bold(`Workspace: ${n.cyan(g.basename(t))}`)),console.log(n.gray(`Path: ${t}`)),console.log(n.white(`Mode: ${a$1}`)),console.log(n.white(`Verdict: ${d.summary.verdict==="approved"?n.green("approved"):d.summary.verdict==="partial"?n.yellow("partial"):n.red("blocked")}`)),console.log(n.white(`Release score: ${d.summary.releaseScore}`));for(let e of d.stages){let i=e.status==="pass"?n.green("PASS"):e.status==="warn"?n.yellow("WARN"):e.status==="skipped"?n.gray("SKIP"):n.red("FAIL");console.log(` - ${e.name}: ${i} ${e.summary} (${e.durationMs}ms)`);}if(d.blockingReasons.length>0){console.log(n.bold.red(`
@@ -1,3 +1,3 @@
1
1
  import {a}from'./chunk-VKLL63TL.js';import {d,e,a as a$1,b}from'./chunk-KXTXQODI.js';import D from'fs';import w from'path';import S from'chalk';import {execa}from'execa';var le={"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:[]}}},pe={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 Y(e,r,t){if(r){let s=r.trim().toLowerCase().replace(/[_.\s]+/g,"-"),u=a$1(r),a=`${e}-${u==="gofiber"?"fiber":u==="gogin"?"gin":u==="dotnet"?"aspnetcore":u!=="unknown"?u:s==="fiber"?"fiber":s==="aspnetcore"||s==="asp-net-core"?"aspnetcore":s}`,n=le[a];if(n&&n.commands[t])return n.commands[t]}let o=pe[t]?.[e]??[];return o.length>0?o[0]:void 0}function me(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,s)=>s.indexOf(t)===o);return {primary:r.length>0?r[0]:"unknown",secondary:r.slice(1)}}function Q(e){return me(e).primary}function X(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 s of o)if(new RegExp(s,"i").test(e))return t;return "unknown"}async function Z(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 ee(e,r,t){return r?t&&typeof r[t]=="string"?r[t]:typeof r.default=="string"?r.default:e:e}var ge=new Set(["init","test","build","start"]),fe=new Set([".git","node_modules",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function N(e){try{return await D.promises.access(e,D.constants.F_OK),true}catch{return false}}async function re(e){let r=await D.promises.readFile(e,"utf-8");return JSON.parse(r)}async function ye(e,r){await D.promises.mkdir(w.dirname(e),{recursive:true}),await D.promises.writeFile(e,`${JSON.stringify(r,null,2)}
2
2
  `,"utf-8");}function O(e){return e.replace(/\\/g,"/")}async function he(e){return a(e,{skipDirs:fe,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(r,t)=>await N(w.join(r,".rapidkit","context.json"))||await N(w.join(r,".rapidkit","project.json"))?true:w.resolve(r)===w.resolve(t)?false:d(r).length>0})}async function ke(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 s=o.stdout.split(/\r?\n/).map(c=>c.trim()).filter(c=>c.length>0).map(c=>O(c));if(s.length===0)return new Set;let u=new Set;for(let c of r){let a=O(w.relative(e,c));if(!a||a===".")continue;let n=`${a}/`;s.some(m=>m===a||m.startsWith(n))&&u.add(c);}return u}async function we(e,r,t){let o=w.join(e,".rapidkit","workspace.contract.json");if(await N(o))try{let f=await be(e,r,t,o);if(f.graphStatus!=="missing")return f}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let s=w.join(e,".rapidkit","workspace-dependency-graph.json");if(!await N(s))return {expanded:t,graphStatus:"missing",expansionDepth:0};let u;try{u=await re(s);}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let c=new Set(r.map(f=>w.resolve(f))),a=new Map;if(!u||typeof u!="object"||Array.isArray(u))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let n=Array.isArray(u.projects)?u.projects:[];for(let f of n){if(!f||typeof f!="object"||Array.isArray(f))continue;let E=f,p=typeof E.path=="string"?E.path:"",i=w.resolve(e,p);if(!c.has(i))continue;let g=Array.isArray(E.dependsOn)?E.dependsOn.filter(y=>typeof y=="string"):[];for(let y of g){let h=w.resolve(e,y);c.has(h)&&(a.has(h)||a.set(h,new Set),a.get(h)?.add(i));}}let m=new Set(t),v=[...m],b=0;for(;v.length>0;){let f=v.shift();if(!f)continue;let E=a.get(f);if(E)for(let p of E)m.has(p)||(m.add(p),v.push(p),b+=1);}return {expanded:m,graphStatus:"loaded",expansionDepth:b}}async function be(e,r,t,o){let s=await re(o);if(!s||typeof s!="object"||Array.isArray(s))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let u=s,c=Array.isArray(u.projects)?u.projects:null;if(!c)return {expanded:t,graphStatus:"invalid",expansionDepth:0};let a=new Map,n=new Map;for(let i of r){let g=O(w.relative(e,i));n.set(g,w.resolve(i));}let m=new Map,v=new Map,b=new Map;for(let i of c){if(!i||typeof i!="object"||Array.isArray(i))continue;let g=i,y=typeof g.slug=="string"?g.slug:"",h=typeof g.relativePath=="string"?O(g.relativePath):y,x=n.get(h);!y||!x||a.set(y,x);}for(let i of c){if(!i||typeof i!="object"||Array.isArray(i))continue;let g=i,y=typeof g.slug=="string"?g.slug:"",h=a.get(y);if(!h)continue;let x=g.contracts&&typeof g.contracts=="object"&&!Array.isArray(g.contracts)?g.contracts:{},$=Array.isArray(x.dependsOn)?x.dependsOn.filter(R=>typeof R=="string"):[],C=Array.isArray(x.publishes)?x.publishes.filter(R=>typeof R=="string"):[],I=Array.isArray(x.consumes)?x.consumes.filter(R=>typeof R=="string"):[];for(let R of $){let F=a.get(R);F&&(b.has(F)||b.set(F,new Set),b.get(F)?.add(h));}for(let R of C)m.has(R)||m.set(R,new Set),m.get(R)?.add(h);for(let R of I)v.has(R)||v.set(R,new Set),v.get(R)?.add(h);}for(let[i,g]of m.entries()){let y=v.get(i);if(y)for(let h of g){b.has(h)||b.set(h,new Set);for(let x of y)x!==h&&b.get(h)?.add(x);}}let f=new Set(t),E=[...f],p=0;for(;E.length>0;){let i=E.shift();if(!i)continue;let g=b.get(i);if(g)for(let y of g)f.has(y)||(f.add(y),E.push(y),p+=1);}return {expanded:f,graphStatus:"loaded",expansionDepth:p}}async function xe(e,r){if(typeof r=="boolean")return r;let t=w.join(e,".rapidkit","policies.yml");if(!await N(t))return true;let o="";try{o=await D.promises.readFile(t,"utf-8");}catch{return true}let s=o.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return s?s[1]==="true":true}async function G(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 Re(e){return e==="node"||e==="go"||e==="java"||e==="python"}function ve(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function Ee(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 Se(e$1){let r=a=>{let n=b(a);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":Q(e$1)},t=a=>{if(!a)return;let n=a$1(a);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=w.join(e$1,".rapidkit","context.json");if(D.existsSync(o))try{let a=JSON.parse(D.readFileSync(o,"utf-8"));if(typeof a.runtime=="string"){let n={};if(a.commands&&typeof a.commands=="object")for(let[m,v]of Object.entries(a.commands))typeof v=="string"&&(n[m]=v);return {runtime:r(a.runtime),framework:t(typeof a.framework=="string"?a.framework:void 0),commandOverrides:Object.keys(n).length>0?n:void 0,environment:typeof a.environment=="string"?a.environment:void 0}}}catch{}let s=e(e$1),u=r(s.runtime),c=t(s.key);return {runtime:u,framework:c}}async function je(e,r,t,o,s,u){let c=!s?.[r]&&Re(t),a;if(s&&s[r]?a=s[r]:c?a=`rapidkit ${r}`:a=Y(t,o,r),!a)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=ee(a,s,u);if(!n)return {exitCode:127,command:a,message:"Failed to resolve stage command",errorCategory:"runtime"};if(!c){let p=await Z(n);if(!p.valid)return {exitCode:127,command:n,message:p.reason||"Command not available",errorCategory:"setup"}}let m=0,v="",b="",f;try{let p=c?r==="init"&&ve()?await Ee(e):await G([r],e):await execa(n,[],{cwd:e,reject:false,shell:true});if(m=Number(p.exitCode??0),v=p.stdout,b=p.stderr,m!==0){let i=`${v}
3
- ${b}`;f=X(i);}}catch(p){return {exitCode:1,command:n,message:p instanceof Error?p.message:"Command execution failed",errorCategory:"runtime"}}return {exitCode:m,command:n,errorCategory:f,healthStatus:void 0,message:m!==0?`Stage failed with exit code ${m}`:void 0}}function te(e){try{return JSON.parse(e)}catch{return null}}function Ce(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx rapidkit setup dotnet` or `npx rapidkit init`.";case "go":return "Install Go 1.21+, then rerun `npx rapidkit setup go` or `npx rapidkit init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx rapidkit setup java` or `npx rapidkit init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx rapidkit setup node` or `npx rapidkit init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx rapidkit setup python` or `npx rapidkit init`.";default:return null}}async function Pe(e){let r=[],t=await G(["doctor","workspace","--json"],e);if(t.exitCode!==0)r.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let u=te(t.stdout)?.healthScore,c=Number(u?.errors??0);Number.isFinite(c)&&c>0?r.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${c} error(s)`}):r.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let o=await G(["readiness","--json"],e);if(o.exitCode!==0)r.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let s=te(o.stdout),u=String(s?.overallStatus??"").toLowerCase();u==="fail"?r.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):u==="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 Fe(e){return ge.has(e)}function Ae(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 Ke(e){if(!Fe(e.stage))throw new Error(`Unsupported workspace run stage: ${e.stage}`);let r=Date.now(),t=w.resolve(e.workspacePath),o=await he(t),s=e.affected===true,u=e.blastRadius===true,c=e.since?.trim()||"HEAD~1",a=s?await ke(t,o,c):new Set(o),n,m="not-applicable",v=0,b="all";if(s&&u){let d=await we(t,o,a);n=d.expanded,m=d.graphStatus,v=d.expansionDepth,b="affected+blast-radius";}else s?(n=a,b="affected"):(n=a,b="all");let f=e.stage==="init"?false:await xe(t,e.enforceGates),E=f?await Pe(t):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],p=E.find(d=>d.status==="fail"),i=o.filter(d=>n.has(d)),g=e.continueOnError===true,y=e.parallel===true,h=Ae(e.maxWorkers,i.length),x=i.length,$=0;e.json||console.log(S.gray(`Workspace run (${e.stage}) started: ${x} target(s), ${y?`parallel x${h}`:"sequential"}`));let C=new Map;for(let d of o)C.set(d,{path:d,relativePath:O(w.relative(t,d)),selected:n.has(d),affected:n.has(d),status:(n.has(d),"skipped"),exitCode:null,durationMs:0,reason:n.has(d)?void 0:"not affected",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});if(p)for(let d of i){let k=C.get(d);k&&(k.status="skipped",k.reason=`blocked by ${p.gate}`);}else {let d=async k=>{let l=C.get(k);if(!l)return;let M=O(w.relative(t,k));e.json||console.log(S.gray(`\u23F3 [${$}/${x}] ${e.stage} ${M}`)),l.selected=true,l.affected=true;let A=Date.now(),{runtime:j,framework:P,commandOverrides:oe,environment:se}=await Se(k);l.runtimeDetected=j,l.framework=P;let T=await je(k,e.stage,j,P,oe,se);if(l.executionCommand=T.command,l.errorCategory=T.errorCategory,l.healthStatus=T.healthStatus,l.durationMs=Date.now()-A,l.exitCode=T.exitCode,T.exitCode===0?(l.status="passed",l.reason=void 0):(l.status="failed",l.reason=T.message||"stage command failed",l.errorMessage=T.message),$+=1,!e.json){let ae=x>0?Math.round($/x*100):100,ie=l.status==="passed"?S.green("\u2705"):S.red("\u274C");if(console.log(S.gray(`${ie} [${$}/${x}] (${ae}%) ${M} ${l.durationMs}ms`)),l.status==="failed"){l.reason&&console.log(S.red(` Reason: ${l.reason}`)),l.executionCommand&&console.log(S.gray(` Command: ${l.executionCommand}`));let K=Ce(l.runtimeDetected);K&&l.errorCategory==="setup"&&console.log(S.gray(` Hint: ${K}`));}}};if(y&&i.length>1){let k=0,l=false,M=new Array(h).fill(null).map(async()=>{for(;k<i.length;){if(l&&!g)return;let A=k;k+=1;let j=i[A];await d(j),C.get(j)?.status==="failed"&&(l=true);}});if(await Promise.all(M),!g&&l){let A=false;for(let j of i){let P=C.get(j);if(P){if(P.status==="failed"){A=true;continue}A&&P.status==="skipped"&&(P.reason=P.reason||"stopped after failure");}}}}else for(let k of i){await d(k);let l=C.get(k);if(!g&&l?.status==="failed"){let M=i.slice(i.indexOf(k)+1);for(let A of M){let j=C.get(A);j&&(j.status="skipped",j.reason="stopped after failure");}break}}}let I=[];for(let d of o){let k=C.get(d);k&&I.push(k);}let R=I.filter(d=>d.status==="passed").length,F=I.filter(d=>d.status==="failed").length,_=I.filter(d=>d.status==="skipped").length,H=e.strict===true,ne=F>0||H&&E.some(d=>d.status!=="pass")?1:0,J={schemaVersion:"1.0",workspacePath:t,stage:e.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-r,options:{affected:s,blastRadius:u,since:s?c:null,parallel:y,maxWorkers:h,continueOnError:g,strict:H,enforceGates:f},selection:{mode:b,since:s?c:null,graphStatus:m,expansionDepth:v},gates:{enforced:f,results:E,blocked:!!p,blockingGate:p?.gate},summary:{projectCount:o.length,selectedCount:i.length,passed:R,failed:F,skipped:_,exitCode:ne},projects:I},V=w.join(t,".rapidkit","reports","workspace-run-last.json");return await ye(V,J),e.json||(p&&(console.log(S.red(`\u274C Workspace run blocked by ${p.gate}`)),console.log(S.gray(` ${p.summary}`))),console.log(S.cyan(`Workspace run (${e.stage}) => passed: ${R}, failed: ${F}, skipped: ${_}`)),console.log(S.gray(`Report: ${V}`))),J}export{Ke as a};
3
+ ${b}`;f=X(i);}}catch(p){return {exitCode:1,command:n,message:p instanceof Error?p.message:"Command execution failed",errorCategory:"runtime"}}return {exitCode:m,command:n,errorCategory:f,healthStatus:void 0,message:m!==0?`Stage failed with exit code ${m}`:void 0}}function te(e){try{return JSON.parse(e)}catch{return null}}function Ce(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx rapidkit setup dotnet` or `npx rapidkit init`.";case "go":return "Install Go 1.21+, then rerun `npx rapidkit setup go` or `npx rapidkit init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx rapidkit setup java` or `npx rapidkit init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx rapidkit setup node` or `npx rapidkit init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx rapidkit setup python` or `npx rapidkit init`.";default:return null}}async function Pe(e){let r=[],t=await G(["doctor","workspace","--json"],e);if(t.exitCode!==0)r.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let u=te(t.stdout)?.healthScore,c=Number(u?.errors??0);Number.isFinite(c)&&c>0?r.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${c} error(s)`}):r.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let o=await G(["readiness","--json"],e);if(o.exitCode!==0)r.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let s=te(o.stdout),u=String(s?.overallStatus??"").toLowerCase();u==="fail"?r.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):u==="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 Fe(e){return ge.has(e)}function Ae(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 Ke(e){if(!Fe(e.stage))throw new Error(`Unsupported workspace run stage: ${e.stage}`);let r=Date.now(),t=w.resolve(e.workspacePath),o=await he(t),s=e.affected===true,u=e.blastRadius===true,c=e.since?.trim()||"HEAD~1",a=s?await ke(t,o,c):new Set(o),n,m="not-applicable",v=0,b="all";if(s&&u){let d=await we(t,o,a);n=d.expanded,m=d.graphStatus,v=d.expansionDepth,b="affected+blast-radius";}else s?(n=a,b="affected"):(n=a,b="all");let f=e.stage==="init"?false:await xe(t,e.enforceGates),E=f?await Pe(t):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],p=E.find(d=>d.status==="fail"),i=o.filter(d=>n.has(d)),g=e.continueOnError===true||e.stage==="init",y=e.parallel===true,h=Ae(e.maxWorkers,i.length),x=i.length,$=0;e.json||console.log(S.gray(`Workspace run (${e.stage}) started: ${x} target(s), ${y?`parallel x${h}`:"sequential"}`));let C=new Map;for(let d of o)C.set(d,{path:d,relativePath:O(w.relative(t,d)),selected:n.has(d),affected:n.has(d),status:(n.has(d),"skipped"),exitCode:null,durationMs:0,reason:n.has(d)?void 0:"not affected",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});if(p)for(let d of i){let k=C.get(d);k&&(k.status="skipped",k.reason=`blocked by ${p.gate}`);}else {let d=async k=>{let l=C.get(k);if(!l)return;let M=O(w.relative(t,k));e.json||console.log(S.gray(`\u23F3 [${$}/${x}] ${e.stage} ${M}`)),l.selected=true,l.affected=true;let A=Date.now(),{runtime:j,framework:P,commandOverrides:oe,environment:se}=await Se(k);l.runtimeDetected=j,l.framework=P;let T=await je(k,e.stage,j,P,oe,se);if(l.executionCommand=T.command,l.errorCategory=T.errorCategory,l.healthStatus=T.healthStatus,l.durationMs=Date.now()-A,l.exitCode=T.exitCode,T.exitCode===0?(l.status="passed",l.reason=void 0):(l.status="failed",l.reason=T.message||"stage command failed",l.errorMessage=T.message),$+=1,!e.json){let ae=x>0?Math.round($/x*100):100,ie=l.status==="passed"?S.green("\u2705"):S.red("\u274C");if(console.log(S.gray(`${ie} [${$}/${x}] (${ae}%) ${M} ${l.durationMs}ms`)),l.status==="failed"){l.reason&&console.log(S.red(` Reason: ${l.reason}`)),l.executionCommand&&console.log(S.gray(` Command: ${l.executionCommand}`));let K=Ce(l.runtimeDetected);K&&l.errorCategory==="setup"&&console.log(S.gray(` Hint: ${K}`));}}};if(y&&i.length>1){let k=0,l=false,M=new Array(h).fill(null).map(async()=>{for(;k<i.length;){if(l&&!g)return;let A=k;k+=1;let j=i[A];await d(j),C.get(j)?.status==="failed"&&(l=true);}});if(await Promise.all(M),!g&&l){let A=false;for(let j of i){let P=C.get(j);if(P){if(P.status==="failed"){A=true;continue}A&&P.status==="skipped"&&(P.reason=P.reason||"stopped after failure");}}}}else for(let k of i){await d(k);let l=C.get(k);if(!g&&l?.status==="failed"){let M=i.slice(i.indexOf(k)+1);for(let A of M){let j=C.get(A);j&&(j.status="skipped",j.reason="stopped after failure");}break}}}let I=[];for(let d of o){let k=C.get(d);k&&I.push(k);}let R=I.filter(d=>d.status==="passed").length,F=I.filter(d=>d.status==="failed").length,_=I.filter(d=>d.status==="skipped").length,H=e.strict===true,ne=F>0||H&&E.some(d=>d.status!=="pass")?1:0,J={schemaVersion:"1.0",workspacePath:t,stage:e.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-r,options:{affected:s,blastRadius:u,since:s?c:null,parallel:y,maxWorkers:h,continueOnError:g,strict:H,enforceGates:f},selection:{mode:b,since:s?c:null,graphStatus:m,expansionDepth:v},gates:{enforced:f,results:E,blocked:!!p,blockingGate:p?.gate},summary:{projectCount:o.length,selectedCount:i.length,passed:R,failed:F,skipped:_,exitCode:ne},projects:I},V=w.join(t,".rapidkit","reports","workspace-run-last.json");return await ye(V,J),e.json||(p&&(console.log(S.red(`\u274C Workspace run blocked by ${p.gate}`)),console.log(S.gray(` ${p.summary}`))),console.log(S.cyan(`Workspace run (${e.stage}) => passed: ${R}, failed: ${F}, skipped: ${_}`)),console.log(S.gray(`Report: ${V}`))),J}export{Ke as a};
@@ -0,0 +1,33 @@
1
+ import {f,e,d,a as a$1,c,g as g$1}from'./chunk-Z5LKRG57.js';import {a}from'./chunk-2FIX2MDC.js';import ut from'crypto';import X from'os';import u from'path';import*as p from'fs-extra';import {execa}from'execa';var pt=["version","project","create","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],V=new Set(pt);var g=a();function S(){let t=[],e$1=i=>{let o=i?.trim();o&&t.push(o);};e$1(process.env.RAPIDKIT_BRIDGE_PYTHON),e$1(process.env.RAPIDKIT_PYTHON_CMD),e$1(process.env.POETRY_PYTHON);let r=_();(r.startsWith("/")||r.startsWith(".")||r.startsWith(".."))&&!r.startsWith("file:")&&e$1(f(u.join(u.resolve(r),".venv")));for(let i of e())i.args.length===1&&i.args[0]==="--version"&&e$1(i.command);for(let i of d())e$1(i);return [...new Set(t)]}function v(t,e){return t==="py"?["-3",...e]:e}function K(t){if(!t)return t;let e=["Installed Poetry version does not support '--no-update'. Falling back to 'poetry lock'."];return t.split(/\r?\n/).filter(i=>!e.some(o=>i.includes(o))).join(`
2
+ `)}var w=class extends Error{code;constructor(e,r){super(r),this.code=e;}};function D(t){if(t instanceof w)switch(t.code){case "PYTHON_NOT_FOUND":return `RapidKit (npm) could not find Python (python3/python/py) on your PATH.
3
+ Install Python 3.10+ and ensure \`${c()}\` is available, then retry.
4
+ Tip: if you are inside a RapidKit project, use the local ./rapidkit launcher.`;case "BRIDGE_VENV_CREATE_FAILED":return `RapidKit (npm) failed to create its bridge virtual environment.
5
+ `+(a$1()?`Ensure Python is installed with venv support.
6
+ `:`Ensure Python venv support is installed (e.g., python3-venv).
7
+ `)+`Details: ${t.message}`;case "BRIDGE_PIP_BOOTSTRAP_FAILED":return `RapidKit (npm) could not bootstrap pip inside the bridge virtual environment.
8
+ `+(a$1()?`Ensure pip is available for your Python installation and retry.
9
+ `:`Install python3-venv/python3-pip and retry.
10
+ `)+`Details: ${t.message}`;case "BRIDGE_PIP_UPGRADE_FAILED":return `RapidKit (npm) could not upgrade pip in the bridge virtual environment.
11
+ Check your network/proxy or disable RAPIDKIT_BRIDGE_UPGRADE_PIP.
12
+ Details: ${t.message}`;case "BRIDGE_PIP_INSTALL_FAILED":return `RapidKit (npm) could not install rapidkit-core in the bridge virtual environment.
13
+ Check your network/proxy, or install manually with: pipx install rapidkit-core.
14
+ Details: ${t.message}`;default:return `RapidKit (npm) bridge error: ${t.message}`}return `RapidKit (npm) failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function _(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function lt(){let t=_(),e=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,r=e&&e.trim()?`${t}|${e.trim()}`:t;return ut.createHash("sha256").update(r).digest("hex").slice(0,12)}function O(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:u.join(X.homedir(),".cache")}function mt(){return u.join(O(),"rapidkit","npm-bridge","venv")}function q(){let t=lt();return u.join(O(),"rapidkit","npm-bridge",`venv-${t}`)}function H(t){return f(t)}function Y(t){return g$1(t)}function Q(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function ft(t){return u.dirname(u.dirname(t))}function tt(){return u.join(O(),"rapidkit","npm-bridge","core-commands.json")}async function et(t){let e=!!process.env.RAPIDKIT_DEBUG,r=n=>{e&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${n}
15
+ `);};try{r("probing interpreter-specific rapidkit script");let i=((await execa(t,v(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"]),{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(r(`script path: ${i}`),i)try{if(await p.pathExists(i)){r(`found script at ${i}; invoking --version --json`);let o=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`script exitCode=${o.exitCode}`),o.exitCode===0){let s=(o.stdout??"").toString().trim();try{let a=JSON.parse(s),c=!!a&&typeof a=="object"&&a!==null&&"version"in a;if(r(`script JSON parse ok=${c}`),c)return true}catch{r("script output not valid JSON");}}}}catch(o){r(`interpreter-specific script probe failed: ${String(o)}`);}}catch(n){r(`interpreter-specific script probe error: ${String(n)}`);}try{r('probing importlib.find_spec("rapidkit")');let n=await execa(t,v(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"]),{reject:false,stdio:"pipe",timeout:2e3});if(r(`import probe exitCode=${n.exitCode} stdout=${(n.stdout??"").toString().trim()}`),n.exitCode===0&&(n.stdout??"").toString().trim()==="1")return true}catch(n){r(`import probe error: ${String(n)}`);}try{r("probing python -m rapidkit");let n=await execa(t,v(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(r(`-m probe exitCode=${n.exitCode}`),n.exitCode===0)return true}catch(n){r(`-m probe error: ${String(n)}`);}try{r("probing PATH for rapidkit executables");let n=(process.env.PATH??"").split(u.delimiter).filter(Boolean);for(let i of n){let o=u.join(i,a$1()?"rapidkit.exe":"rapidkit");try{if(await p.pathExists(o)){r(`found candidate on PATH: ${o}; invoking --version --json`);let s=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`candidate exitCode=${s.exitCode}`),s.exitCode===0){let a=(s.stdout??"").toString().trim();try{let c=JSON.parse(a);if(c&&typeof c=="object"&&c!==null&&"version"in c)return true}catch{r("candidate output not valid JSON, skipping");}}}}catch(s){r(`error probing candidate ${o}: ${String(s)}`);}}return r("no valid rapidkit found on PATH"),false}catch(n){return r(`PATH probe error: ${String(n)}`),false}}async function M(t){let e=(t??"").toString().trim();if(!e)return false;try{let r=JSON.parse(e);return !!r&&typeof r=="object"&&r!==null&&"version"in r}catch{return false}}async function ht(t){let e=u.relative(".",g$1(".venv")),r=u.relative(".",f(".venv")),n=t;for(let i=0;i<25;i+=1){let o=u.join(n,e);if(await p.pathExists(o)){let c=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:n});if(c.exitCode===0&&await M(c.stdout))return {cmd:o,baseArgs:[]}}let s=u.join(n,r);if(await p.pathExists(s)){let c=await execa(s,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:n});if(c.exitCode===0&&await M(c.stdout))return {cmd:s,baseArgs:["-m","rapidkit"]}}let a=u.dirname(n);if(a===n)break;n=a;}return null}async function gt(t){try{let e=u.join(t,".python-version");if(await p.pathExists(e)){let n=(await p.readFile(e,"utf-8")).trim();if(n)return n}}catch{}try{let e=u.join(t,".rapidkit-workspace");if(await p.pathExists(e)){let r=await p.readFile(e,"utf-8"),n=JSON.parse(r);if(n.pythonVersion)return n.pythonVersion}}catch{}return null}async function F(t){if(t&&t.trim())try{let o=await ht(t);if(o){let s=u.dirname(o.cmd).includes(".venv")?u.dirname(u.dirname(u.dirname(o.cmd))):u.dirname(o.cmd),a=await gt(s);return a&&(process.env.PYENV_VERSION=a),o}}catch{}let e=await Et();if(e.kind==="venv"){let o=ft(e.pythonPath),s=Y(o);return await p.pathExists(s)?{cmd:s,baseArgs:[]}:{cmd:e.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(e.cmd,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:e.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let s=((await execa(e.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(s&&await p.pathExists(s))try{let a=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(a.exitCode===0&&await M(a.stdout))return {cmd:s,baseArgs:[]}}catch{}}catch{}let r=q(),n=await j(e.cmd),i=Y(r);return await p.pathExists(i)?{cmd:i,baseArgs:[]}:{cmd:n,baseArgs:["-m","rapidkit"]}}async function nt(){for(let t of S())try{return await execa(t,v(t,["--version"]),{reject:false,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function B(){let t=null;for(let e of S()){try{await execa(e,v(e,["--version"]),{reject:false,stdio:"pipe",timeout:2e3});}catch(r){t=r;continue}try{return await j(e)}catch(r){t=r;continue}}throw t instanceof w?t:t instanceof Error?new w("BRIDGE_VENV_BOOTSTRAP_FAILED",t.message):new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).")}async function yt(){let t=!!process.env.RAPIDKIT_DEBUG,e$1=n=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${n}
16
+ `);},r=Array.from(new Set([...d(),...e(14,10).map(n=>n.command)]));for(let n of r)try{e$1(`Method 1: trying ${n} import`);let i=await execa(n,v(n,["-c","import rapidkit_core; print(1)"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.trim()==="1")return e$1(`\u2713 Found via ${n} import`),true}catch{continue}for(let n of r)try{e$1(`Method 2: trying ${n} -m pip show`);let i=await execa(n,v(n,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found via ${n} -m pip show`),true}catch{continue}for(let n of ["pip","pip3"])try{e$1(`Method 3: trying ${n} show`);let i=await execa(n,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found via ${n} show`),true}catch{continue}try{e$1("Method 4: checking pyenv versions");let n=await execa("pyenv",["versions","--bare"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout){let i=n.stdout.split(`
17
+ `).filter(o=>o.trim());e$1(`Found pyenv versions: ${i.join(", ")}`);for(let o of i){let s=process.env.PYENV_ROOT||u.join(X.homedir(),".pyenv"),a=u.join(s,"versions",o.trim(),"bin","pip");try{let c=await execa(a,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found in pyenv ${o}`),true}catch{try{let c=await execa("pyenv",["exec","pip","show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g,env:{...process.env,PYENV_VERSION:o.trim()}});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return e$1(`\u2713 Found in pyenv ${o} via PYENV_VERSION`),true}catch{continue}}}}}catch{e$1("pyenv not available");}for(let n of r)try{e$1(`Method 5: checking ${n} user site`);let i=await execa(n,v(n,["-m","site","--user-site"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout){let o=i.stdout.trim(),s=u.join(o,"rapidkit_core");if(await p.pathExists(s))return e$1("\u2713 Found in user site-packages"),true}}catch{continue}try{e$1("Method 6: checking pipx");let n=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout?.includes("rapidkit-core"))return e$1("\u2713 Found via pipx"),true}catch{e$1("pipx not available");}for(let n of r)try{e$1(`Method 6: checking ${n} -m pipx list`);let i=await execa(n,v(n,["-m","pipx","list"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("rapidkit-core"))return e$1(`\u2713 Found via ${n} -m pipx list`),true}catch{continue}try{if(e$1("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g})).exitCode===0)return e$1("\u2713 Found via poetry"),true}catch{e$1("poetry check failed");}for(let n of r)try{if(e$1(`Method 7: checking ${n} -m poetry show rapidkit-core`),(await execa(n,v(n,["-m","poetry","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g})).exitCode===0)return e$1(`\u2713 Found via ${n} -m poetry`),true}catch{continue}try{e$1("Method 8: checking conda");let n=await execa("conda",["list","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout?.includes("rapidkit-core"))return e$1("\u2713 Found via conda"),true}catch{e$1("conda not available");}return e$1("\u2717 Not found in any environment"),false}function wt(t){let e=t.trim();if(!e||!e.startsWith("rapidkit-core"))return null;let r=e.slice(13).trim();return !r||/[\/@]|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(r)?null:r}function J(t){let e=t.trim();if(!e)return null;let r=e.split("."),n=[];for(let i of r){let o=i.match(/^(\d+)/);if(!o){n.push(0);continue}n.push(Number.parseInt(o[1],10));}return n}function U(t,e){let r=Math.max(t.length,e.length);for(let n=0;n<r;n+=1){let i=n<t.length?t[n]:0,o=n<e.length?e[n]:0;if(i>o)return 1;if(i<o)return -1}return 0}function vt(t){return t.length<=1?[t[0]+1]:t.length===2?[t[0]+1,0]:[t[0],t[1]+1,0]}function Ct(t){let e=t.split(",").map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;let r=[];for(let n of e){let i=n.match(/^(==|>=|<=|>|<|~=)\s*([0-9][0-9A-Za-z+._-]*)$/);if(!i)return null;r.push({op:i[1],version:i[2]});}return r}function rt(t,e){let r=J(t);if(!r)return false;let n=Ct(e);if(!n)return false;for(let i of n){let o=J(i.version);if(!o)return false;let s=U(r,o);if(i.op==="=="&&s!==0||i.op===">="&&s<0||i.op==="<="&&s>0||i.op===">"&&s<=0||i.op==="<"&&s>=0)return false;if(i.op==="~="){if(s<0)return false;let a=vt(o);if(U(r,a)>=0)return false}}return true}async function Pt(){let t=Array.from(new Set([...d(),...e(14,10).map(r=>r.command)])),e$1=r=>{let n=r.match(/^Version:\s*(.+)$/m);return n?n[1].trim():null};for(let r of t)try{let n=await execa(r,v(r,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0){let i=e$1(n.stdout||"");if(i)return i}}catch{continue}for(let r of ["pip","pip3"])try{let n=await execa(r,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0){let i=e$1(n.stdout||"");if(i)return i}}catch{continue}try{let r=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:g});if(r.exitCode===0&&r.stdout){let n=r.stdout.match(/rapidkit-core\s+([0-9][0-9A-Za-z+._-]*)/i);if(n?.[1])return n[1]}}catch{}return null}async function _t(){let t=_(),e=wt(t);if(!e)return {isCompatible:false,installedVersion:null,expectedConstraint:null,reason:Q(t)?"constraint-unsupported":"constraint-missing"};let r=await Pt();if(!r)return {isCompatible:false,installedVersion:null,expectedConstraint:e,reason:"version-not-detected"};let n=rt(r,e);return {isCompatible:n,installedVersion:r,expectedConstraint:e,reason:n?"compatible":"incompatible-version"}}async function j(t){let e=q(),r=mt(),n=_(),i=[e];!Q(n)&&!await p.pathExists(e)&&await p.pathExists(r)&&i.push(r);for(let l of i){let h=H(l);if(await p.pathExists(h))try{let f=await execa(h,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:false,stdio:"pipe",timeout:2e3});if(f.exitCode===0&&(f.stdout??"").toString().trim()==="1")return h;await p.remove(l);}catch{await p.remove(l);}}let o=e,s={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},a=Math.max(0,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY??"2")),c=Math.max(200,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY_DELAY_MS??"800")),m=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),C=l=>new Promise(h=>setTimeout(h,l)),P=async(l,h,f)=>{let y=await execa(l,h,{reject:false,stdio:["ignore","pipe","inherit"],env:s,timeout:f});if(y.exitCode===0)return;let T=(y.stdout??"").toString(),N=(y.stderr??"").toString(),x=[T,N].filter(Boolean).join(`
18
+ `),at=x?`${l} ${h.join(" ")}
19
+ ${x}`:`${l} ${h.join(" ")}`;throw new Error(at)},k=async(l,h,f)=>{let y=0;for(;;)try{await P(l,h,f);return}catch(T){if(y>=a)throw T;let N=Math.floor(Math.random()*200),x=c*Math.pow(2,y)+N;y+=1,await C(x);}};try{await p.ensureDir(u.dirname(o));try{await P(t,v(t,["-m","venv",o]),6e4);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_VENV_CREATE_FAILED",y)}let l=H(o);if((await execa(l,["-m","pip","--version"],{reject:false,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(l,["-m","ensurepip","--default-pip"],{reject:false,stdio:["ignore","pipe","inherit"],env:s,timeout:6e4})).exitCode!==0)throw new w("BRIDGE_PIP_BOOTSTRAP_FAILED","ensurepip failed; install python3-venv/python3-pip and retry.");if(process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1")try{await k(l,["-m","pip","install","-U","pip"],m);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_PIP_UPGRADE_FAILED",y)}try{await k(l,["-m","pip","install","-U",_()],m);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_PIP_INSTALL_FAILED",y)}return l}catch(l){if(l instanceof w)throw l;let h=l instanceof Error?l.message:String(l);throw new w("BRIDGE_VENV_BOOTSTRAP_FAILED",h)}}async function Et(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1")return {kind:"venv",pythonPath:await B()};for(let r of S())if(await et(r))return {kind:"system",cmd:r};let t=await nt();if(!t)throw new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");let e;try{e=await j(t);}catch{e=await B();}return {kind:"venv",pythonPath:e}}async function Vt(t,e){try{let r=await F(e?.cwd),n=r.cmd,i=[...r.baseArgs,...t];if(t[0]==="init"){let a=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"}),c=K((a.stdout??"").toString()),m=K((a.stderr??"").toString());return c&&process.stdout.write(c.endsWith(`
20
+ `)?c:`${c}
21
+ `),m&&process.stderr.write(m.endsWith(`
22
+ `)?m:`${m}
23
+ `),typeof a.exitCode=="number"?a.exitCode:1}let s=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"inherit"});return typeof s.exitCode=="number"?s.exitCode:1}catch(r){return process.stderr.write(`${D(r)}
24
+ `),1}}var kt=[{pattern:/RapidKitError:\s*Directory '([^']+)' exists and force is not set/,message:t=>`\u274C Directory "${u.basename(t[1])}" already exists.
25
+ \u{1F4A1} Choose a different name, or remove the existing directory first:
26
+ rm -rf ${t[1]}`},{pattern:/RapidKitError:\s*Project name '([^']+)' is (invalid|not allowed)/i,message:t=>`\u274C Invalid project name: "${t[1]}"
27
+ \u{1F4A1} Use lowercase letters, numbers, and hyphens only (e.g. my-api).`},{pattern:/RapidKitError:\s*Kit '([^']+)' not found/i,message:t=>`\u274C Unknown kit: "${t[1]}"
28
+ \u{1F4A1} Run "npx rapidkit list" to see available kits.`},{pattern:/RapidKitError:\s*(.+)/,message:t=>`\u274C ${t[1].trim()}`}];async function Mt(t,e){let{spawn:r}=await import('child_process');try{let n=await F(e?.cwd),i=n.cmd,o=[...n.baseArgs,...t];return await new Promise(s=>{let a=r(i,o,{cwd:e?.cwd,env:{...process.env,...e?.env},stdio:["inherit","inherit","pipe"]}),c=[];a.stderr?.on("data",m=>{c.push(m);}),a.on("close",m=>{let C=m??1;if(C!==0&&c.length>0){let P=Buffer.concat(c).toString("utf8");for(let{pattern:k,message:l}of kt){let h=P.match(k);if(h){process.stderr.write(l(h)+`
29
+ `),s(C);return}}process.stderr.write(P);}s(C);}),a.on("error",m=>{process.stderr.write(`${D(m)}
30
+ `),s(1);});})}catch(n){return process.stderr.write(`${D(n)}
31
+ `),1}}async function E(t,e){try{let r=await F(e?.cwd),n=r.cmd,i=[...r.baseArgs,...t],o=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"});return {exitCode:typeof o.exitCode=="number"?o.exitCode:1,stdout:(o.stdout??"").toString(),stderr:(o.stderr??"").toString()}}catch(r){return {exitCode:1,stdout:"",stderr:`${D(r)}
32
+ `}}}function it(t){let e=new Set,r=t.split(`
33
+ `),n=false;for(let i of r){let o=i.replace(/\r$/,"");if(!n){/^\s*Commands:\s*$/i.test(o)&&(n=true);let c=o.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let m=c[1].trim();m&&!m.startsWith("-")&&e.add(m);}continue}if(!o.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(o))continue;let s=o.match(/^\s*([a-z0-9][a-z0-9_-]*)\b/i);if(!s)continue;let a=s[1].trim();a&&!a.startsWith("-")&&e.add(a);}return e}async function ot(){let t=tt();if(!await p.pathExists(t))return null;try{let e=await p.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.commands))return e}catch{}return null}async function W(t){let e=tt();await p.ensureDir(u.dirname(e)),await p.writeJson(e,t,{spaces:2});}async function xt(){let t=await E(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let r=JSON.parse(t.stdout)?.version;return typeof r=="string"?r:void 0}catch{return}}async function Rt(){let t=await E(["commands","--json"],{cwd:process.cwd()});if(t.exitCode!==0)return null;try{let e=JSON.parse(t.stdout);if(e?.schema_version!==1||!Array.isArray(e.commands))return null;let r=e.commands.filter(n=>typeof n=="string");return r.length?r:null}catch{return null}}async function Bt(){let e=Date.now(),r=await ot(),n=await xt(),i=!!r?.commands?.length;if(i&&e-r.fetched_at<864e5&&(!n||!r.rapidkit_version||r.rapidkit_version===n))return new Set(r.commands);let o=await Rt();if(o?.length){let m=Array.from(new Set(o)).sort();return await W({schema_version:1,fetched_at:e,rapidkit_version:n,commands:m}),new Set(m)}let s=await E(["--help"],{cwd:process.cwd()});if(s.exitCode!==0)return i&&r?.commands?new Set(r.commands):new Set(V);let a=it(s.stdout);if(a.size===0)return new Set(V);let c=Array.from(a).sort();return await W({schema_version:1,fetched_at:e,rapidkit_version:n,commands:c}),a}async function Ft(){let e=Date.now(),r=await ot();return !r||e-r.fetched_at>=864e5||!r.commands?.length?null:new Set(r.commands)}function st(){return u.join(O(),"rapidkit","npm-bridge","modules-catalog.json")}async function bt(){let t=st();if(!await p.pathExists(t))return null;try{let e=await p.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.modules))return e}catch{}return null}async function z(t){let e=st();await p.ensureDir(u.dirname(e)),await p.writeJson(e,t,{spaces:2});}function Z(t){try{return JSON.parse(t)}catch{return null}}async function Gt(t={}){let e=typeof t.ttlMs=="number"?t.ttlMs:18e5,r=Date.now(),n=await bt();if(n?.fetched_at&&r-n.fetched_at<e)return n;let i=["modules","list","--json-schema","1"];t.category&&i.push("--category",t.category),t.tag&&i.push("--tag",t.tag),t.detailed&&i.push("--detailed");let o=await E(i,{cwd:t.cwd,env:t.env});if(o.exitCode===0){let a=Z(o.stdout);if(a&&a.schema_version===1&&Array.isArray(a.modules)){let c={...a,fetched_at:r};return await z(c),c}}let s=await E(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(s.exitCode===0){let a=Z(s.stdout);if(Array.isArray(a)){let c={schema_version:1,generated_at:new Date().toISOString(),filters:{category:t.category??null,tag:t.tag??null,detailed:!!t.detailed},stats:{total:a.length,returned:a.length,invalid:0},modules:a,source:"legacy-json",fetched_at:r};return await z(c),c}}return n||null}var Lt={pythonCommandCandidates:S,pickSystemPython:nt,ensureBridgeVenv:j,ensureBridgeVenvFromCandidates:B,parseCoreCommandsFromHelp:it,tryRapidkit:et,checkRapidkitCoreAvailable:yt,checkRapidkitCoreVersionCompatible:_t,isVersionSatisfyingConstraint:rt};export{V as a,yt as b,_t as c,Et as d,Vt as e,Mt as f,E as g,Bt as h,Ft as i,Gt as j,Lt as k};
@@ -108,7 +108,7 @@ npx rapidkit dev
108
108
  cd <project-name>
109
109
  npx rapidkit init
110
110
  npx rapidkit dev
111
- `)+"```\n","utf-8"),!n){f.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:i$1}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}try{let{registerWorkspace:b}=await import('./workspace-EHYCBFXL.js');await b(i$1,a);}catch{}if(console.log(t.green(`
111
+ `)+"```\n","utf-8"),!n){f.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:i$1}),f.succeed("Git repository initialized");}catch{f.warn("Could not initialize git repository");}}try{let{registerWorkspace:b}=await import('./workspace-QCU3VBCD.js');await b(i$1,a);}catch{}if(console.log(t.green(`
112
112
  \u2728 Workspace created!
113
113
  `)),console.log(t.cyan("\u{1F4C2} Location:"),t.white(i$1)),console.log(t.cyan(`
114
114
  \u{1F680} Get started:
@@ -164,7 +164,7 @@ npx rapidkit dev
164
164
  cd <project-name>
165
165
  npx rapidkit init
166
166
  npx rapidkit dev
167
- `)+"```\n","utf-8"),!n){C.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m",`Initial commit: RapidKit workspace (${w} profile)`],{cwd:i$1}),C.succeed("Git repository initialized");}catch{C.warn("Could not initialize git repository");}}try{let{registerWorkspace:$t}=await import('./workspace-EHYCBFXL.js');await $t(i$1,a);}catch{}console.log(t.green(`
167
+ `)+"```\n","utf-8"),!n){C.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m",`Initial commit: RapidKit workspace (${w} profile)`],{cwd:i$1}),C.succeed("Git repository initialized");}catch{C.warn("Could not initialize git repository");}}try{let{registerWorkspace:$t}=await import('./workspace-QCU3VBCD.js');await $t(i$1,a);}catch{}console.log(t.green(`
168
168
  \u2728 Workspace created with fallback profile!
169
169
  `)),console.log(t.cyan("\u{1F4C2} Location:"),t.white(i$1)),console.log(t.cyan(`
170
170
  \u{1F680} Get started:
@@ -174,7 +174,7 @@ npx rapidkit dev
174
174
  `)),console.log("");return}catch(B){throw C.fail("Failed to create workspace"),console.error(t.red(`
175
175
  \u274C Error:`),B),B}}}else if(console.log(t.yellow(`
176
176
  \u26A0\uFE0F Python not detected. Auto-switching to "${w}" profile (no Python required).
177
- `)),d=w,new Set(["go-only","java-only","dotnet-only","node-only","minimal"]).has(w)){let j=O("Creating workspace").start();try{if(await k.ensureDir(i$1),j.succeed("Directory created"),await z(i$1,a,"venv",void 0),await Y(i$1,a,"venv",void 0,w),await V(i$1),await U(i$1,a),!n){j.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m",`Initial commit: RapidKit workspace (${w})`],{cwd:i$1}),j.succeed("Git repository initialized");}catch{j.warn("Could not initialize git repository");}}try{let{registerWorkspace:C}=await import('./workspace-EHYCBFXL.js');await C(i$1,a);}catch{}console.log(t.green(`
177
+ `)),d=w,new Set(["go-only","java-only","dotnet-only","node-only","minimal"]).has(w)){let j=O("Creating workspace").start();try{if(await k.ensureDir(i$1),j.succeed("Directory created"),await z(i$1,a,"venv",void 0),await Y(i$1,a,"venv",void 0,w),await V(i$1),await U(i$1,a),!n){j.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m",`Initial commit: RapidKit workspace (${w})`],{cwd:i$1}),j.succeed("Git repository initialized");}catch{j.warn("Could not initialize git repository");}}try{let{registerWorkspace:C}=await import('./workspace-QCU3VBCD.js');await C(i$1,a);}catch{}console.log(t.green(`
178
178
  \u2728 Workspace created (auto-fallback profile)!
179
179
  `)),console.log(t.cyan("\u{1F4C2} Location:"),t.white(i$1)),console.log(t.cyan("\u{1F4E6} Profile:"),t.yellow(w)),console.log(t.cyan("\u{1F4A1} Reason:"),t.gray("Python not detected; switched from "+d)),console.log(t.cyan(`
180
180
  \u{1F680} Get started:
@@ -182,7 +182,7 @@ npx rapidkit dev
182
182
  `)),console.log(t.cyan(`\u{1F4A1} Add Python later:
183
183
  `)),console.log(t.gray(" 1. Install Python 3.10+")),console.log(t.gray(` 2. Run: cd ${a} && rapidkit bootstrap --profile ${d}
184
184
  `)),console.log("");return}catch(C){throw j.fail("Failed to create workspace"),console.error(t.red(`
185
- \u274C Error:`),C),C}}}}a$1.step(1,3,"Setting up RapidKit environment");let I=O("Creating directory").start();try{await k.ensureDir(i$1),I.succeed("Directory created"),I.start("Detecting Python version");let f=null,R=await Rt(x.pythonVersion);if(R)f=await gt(R),f?(a$1.info(` Detected Python ${f}`),I.succeed(`Python ${f} detected`)):I.warn("Could not detect exact Python version");else {let b=S();f=await gt(b),f?I.succeed(`Python ${f} detected`):I.warn("Could not detect Python version, proceeding with defaults");}if(x.installMethod==="poetry"&&!await xt()&&(I.warn("Poetry not found \u2014 auto-fallback to pip + venv"),x.installMethod="venv"),await z(i$1,a,x.installMethod,f||void 0),f&&await Mt(i$1,f),await Y(i$1,a,x.installMethod,f||x.pythonVersion,d||h),await V(i$1),await U(i$1,a),x.installMethod==="poetry")try{await _t(i$1,x.pythonVersion,I,r,u,c);}catch(b){let w=b?.details||b?.message||String(b);if(w.includes("pyenv")||w.includes("exit status 127")||w.includes("returned non-zero exit status 127")){I.warn("Poetry encountered Python discovery issues, trying venv method"),a$1.debug(`Poetry error (attempting venv fallback): ${w}`);try{await ct(i$1,x.pythonVersion,I,r,u),x.installMethod="venv";}catch(D){throw D}}else throw b}else x.installMethod==="venv"?await ct(i$1,x.pythonVersion,I,r,u):await Et(i$1,I,r,u,c);if(await It(i$1,x.installMethod),await jt(i$1,x.installMethod),I.succeed("RapidKit environment ready!"),!o.skipGit){I.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:i$1}),I.succeed("Git repository initialized");}catch{I.warn("Could not initialize git repository");}}try{let{registerWorkspace:b}=await import('./workspace-EHYCBFXL.js');await b(i$1,a);}catch{console.warn(t.gray("Note: Could not register workspace in shared registry"));}if(console.log(t.green(`
185
+ \u274C Error:`),C),C}}}}a$1.step(1,3,"Setting up RapidKit environment");let I=O("Creating directory").start();try{await k.ensureDir(i$1),I.succeed("Directory created"),I.start("Detecting Python version");let f=null,R=await Rt(x.pythonVersion);if(R)f=await gt(R),f?(a$1.info(` Detected Python ${f}`),I.succeed(`Python ${f} detected`)):I.warn("Could not detect exact Python version");else {let b=S();f=await gt(b),f?I.succeed(`Python ${f} detected`):I.warn("Could not detect Python version, proceeding with defaults");}if(x.installMethod==="poetry"&&!await xt()&&(I.warn("Poetry not found \u2014 auto-fallback to pip + venv"),x.installMethod="venv"),await z(i$1,a,x.installMethod,f||void 0),f&&await Mt(i$1,f),await Y(i$1,a,x.installMethod,f||x.pythonVersion,d||h),await V(i$1),await U(i$1,a),x.installMethod==="poetry")try{await _t(i$1,x.pythonVersion,I,r,u,c);}catch(b){let w=b?.details||b?.message||String(b);if(w.includes("pyenv")||w.includes("exit status 127")||w.includes("returned non-zero exit status 127")){I.warn("Poetry encountered Python discovery issues, trying venv method"),a$1.debug(`Poetry error (attempting venv fallback): ${w}`);try{await ct(i$1,x.pythonVersion,I,r,u),x.installMethod="venv";}catch(D){throw D}}else throw b}else x.installMethod==="venv"?await ct(i$1,x.pythonVersion,I,r,u):await Et(i$1,I,r,u,c);if(await It(i$1,x.installMethod),await jt(i$1,x.installMethod),I.succeed("RapidKit environment ready!"),!o.skipGit){I.start("Initializing git repository");try{await execa("git",["init"],{cwd:i$1}),await execa("git",["add","."],{cwd:i$1}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:i$1}),I.succeed("Git repository initialized");}catch{I.warn("Could not initialize git repository");}}try{let{registerWorkspace:b}=await import('./workspace-QCU3VBCD.js');await b(i$1,a);}catch{console.warn(t.gray("Note: Could not register workspace in shared registry"));}if(console.log(t.green(`
186
186
  \u2728 RapidKit environment created successfully!
187
187
  `)),console.log(t.cyan("\u{1F4C2} Location:"),t.white(i$1)),console.log(t.cyan("\u2699\uFE0F Configuration:")),console.log(t.gray(` \u2022 Profile: ${d}`)),console.log(t.gray(` \u2022 Python: ${x.pythonVersion}`)),console.log(t.gray(` \u2022 Install method: ${x.installMethod}`)),console.log(t.cyan(`
188
188
  \u{1F680} Get started:
@@ -215,7 +215,7 @@ Error: ${P}
215
215
  Possible solutions:
216
216
  1. Check your internet connection
217
217
  2. Try installing manually: cd ${m.basename(e)} && poetry add rapidkit-core
218
- 3. Use venv method instead: npx rapidkit ${m.basename(e)} --install-method=venv`))}}}n.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:y}=await import('./pythonRapidkitExec-4MP62M5R.js');if(!await y()&&!r){n.start("Checking optional global pipx installation");let P=await tt(n,true);try{n.start("Installing RapidKit globally with pipx for CLI access"),await N(P,["install","rapidkit-core"]),n.succeed("RapidKit installed globally");}catch($){n.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${$}`);}}}catch(y){n.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${y}`);}}async function ct(e,o,n,r,l$1,p=false){n.start(`Checking Python ${o}`);let c=S();try{let{stdout:g}=await execa(c,["--version"]),h=g.match(/Python (\d+\.\d+)/)?.[1];if(h&&!G(h,o))throw new f$1(o,h);n.succeed(`Python ${h} found`);}catch(g){throw g instanceof f$1?g:new f$1(o)}n.start("Creating virtual environment");try{await execa(c,["-m","venv",".venv"],{cwd:e}),n.succeed("Virtual environment created");}catch(g){if(n.fail("Failed to create virtual environment"),(a=>typeof a=="object"&&a!==null&&"stdout"in a&&typeof a.stdout=="string")(g)&&g.stdout.includes("ensurepip is not")){let a=g.stdout.match(/apt install (python[\d.]+-venv)/),i=a?a[1]:"python3-venv";throw new k$1("Python venv module not available",new Error(`Virtual environment creation failed.
218
+ 3. Use venv method instead: npx rapidkit ${m.basename(e)} --install-method=venv`))}}}n.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:y}=await import('./pythonRapidkitExec-JXOKKTXZ.js');if(!await y()&&!r){n.start("Checking optional global pipx installation");let P=await tt(n,true);try{n.start("Installing RapidKit globally with pipx for CLI access"),await N(P,["install","rapidkit-core"]),n.succeed("RapidKit installed globally");}catch($){n.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${$}`);}}}catch(y){n.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${y}`);}}async function ct(e,o,n,r,l$1,p=false){n.start(`Checking Python ${o}`);let c=S();try{let{stdout:g}=await execa(c,["--version"]),h=g.match(/Python (\d+\.\d+)/)?.[1];if(h&&!G(h,o))throw new f$1(o,h);n.succeed(`Python ${h} found`);}catch(g){throw g instanceof f$1?g:new f$1(o)}n.start("Creating virtual environment");try{await execa(c,["-m","venv",".venv"],{cwd:e}),n.succeed("Virtual environment created");}catch(g){if(n.fail("Failed to create virtual environment"),(a=>typeof a=="object"&&a!==null&&"stdout"in a&&typeof a.stdout=="string")(g)&&g.stdout.includes("ensurepip is not")){let a=g.stdout.match(/apt install (python[\d.]+-venv)/),i=a?a[1]:"python3-venv";throw new k$1("Python venv module not available",new Error(`Virtual environment creation failed.
219
219
 
220
220
  On Debian/Ubuntu systems, install the venv package:
221
221
  sudo apt install ${i}
@@ -227,9 +227,9 @@ Error: ${a}
227
227
  Possible solutions:
228
228
  1. Check your internet connection
229
229
  2. Try installing manually: cd ${m.basename(e)} && ${f(".venv")} -m pip install rapidkit-core
230
- 3. Use Poetry instead: npx rapidkit ${m.basename(e)} --install-method=poetry`))}}n.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:g}=await import('./pythonRapidkitExec-4MP62M5R.js');if(!await g()&&!r){n.start("Checking optional global pipx installation");let a=await tt(n,true);try{n.start("Installing RapidKit globally with pipx for CLI access"),await N(a,["install","rapidkit-core"]),n.succeed("RapidKit installed globally");}catch(i){n.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${i}`);}}}catch(g){n.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${g}`);}}async function Et(e,o,n,r,l$1=false){if(!n)try{let{checkRapidkitCoreVersionCompatible:c}=await import('./pythonRapidkitExec-4MP62M5R.js'),u=await c();if(u.isCompatible){o.succeed(`RapidKit ${u.installedVersion??""} already compatible globally; skipping pipx installation`),await k.outputFile(m.join(e,".rapidkit-global"),`RapidKit already available globally (version ${u.installedVersion??"unknown"}) and satisfies expected constraint ${u.expectedConstraint??"n/a"}; workspace will reuse the existing installation
230
+ 3. Use Poetry instead: npx rapidkit ${m.basename(e)} --install-method=poetry`))}}n.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:g}=await import('./pythonRapidkitExec-JXOKKTXZ.js');if(!await g()&&!r){n.start("Checking optional global pipx installation");let a=await tt(n,true);try{n.start("Installing RapidKit globally with pipx for CLI access"),await N(a,["install","rapidkit-core"]),n.succeed("RapidKit installed globally");}catch(i){n.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${i}`);}}}catch(g){n.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${g}`);}}async function Et(e,o,n,r,l$1=false){if(!n)try{let{checkRapidkitCoreVersionCompatible:c}=await import('./pythonRapidkitExec-JXOKKTXZ.js'),u=await c();if(u.isCompatible){o.succeed(`RapidKit ${u.installedVersion??""} already compatible globally; skipping pipx installation`),await k.outputFile(m.join(e,".rapidkit-global"),`RapidKit already available globally (version ${u.installedVersion??"unknown"}) and satisfies expected constraint ${u.expectedConstraint??"n/a"}; workspace will reuse the existing installation
231
231
  `,"utf-8");return}u.reason==="constraint-missing"?o.warn('Version-aware global reuse skipped: no explicit rapidkit-core version constraint found. Set RAPIDKIT_CORE_PYTHON_PACKAGE (example: RAPIDKIT_CORE_PYTHON_PACKAGE="rapidkit-core>=0.4.0,<0.9.0") to enable version-aware reuse. Proceeding with pipx install/upgrade.'):u.reason==="constraint-unsupported"&&o.warn('Version-aware global reuse skipped: RAPIDKIT_CORE_PYTHON_PACKAGE uses an unsupported spec (path/url/git). Use a version range instead (example: RAPIDKIT_CORE_PYTHON_PACKAGE="rapidkit-core==0.4.0" or "rapidkit-core>=0.4.0,<0.9.0"). Proceeding with pipx install/upgrade.'),a$1.debug(`Global RapidKit install is not reusable via version-aware policy (reason=${u.reason}, installed=${u.installedVersion??"unknown"}, expected=${u.expectedConstraint??"none"}). Proceeding with pipx install/upgrade.`);}catch(c){a$1.debug(`Global RapidKit version-aware check failed before pipx install: ${c}`);}let p=await tt(o,l$1);if(o.start("Installing RapidKit globally with pipx"),n){let c=d$2(r||{});if(!c)throw new k$1("Test mode installation",new Error("No local RapidKit path configured. Set RAPIDKIT_DEV_PATH environment variable."));a$1.debug(`Installing from local path: ${c}`),o.text="Installing RapidKit from local path (test mode)",await N(p,["install","-e",c]);}else {o.text="Installing RapidKit from PyPI";try{await N(p,["install","rapidkit-core"]);}catch(c){try{o.text="RapidKit already installed globally, upgrading to match expected version",await N(p,["upgrade","rapidkit-core"]);}catch(u){throw a$1.debug(`pipx install/upgrade failed: install=${c}, upgrade=${u}`),new l}}}o.succeed("RapidKit installed globally"),await k.outputFile(m.join(e,".rapidkit-global"),`RapidKit installed globally with pipx
232
- `,"utf-8");}async function ce(e,o){let{skipGit:n=false,testMode:r=false,userConfig:l={},yes:p=false,installMethod:c,pythonVersion:u="3.10"}=o||{},g=c||l.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return a$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})(),h=g==="poetry"&&!await xt()?"venv":g;await z(e,m.basename(e),h),await V(e),await Y(e,m.basename(e),h,u,o?.profile);let a=O("Registering workspace").start();try{h==="poetry"?(await U(e,m.basename(e)),await _t(e,u,a,r,l,p)):h==="venv"?await ct(e,u,a,r,l):await Et(e,a,r,l,p),await It(e,h),await jt(e,h),a.succeed("Workspace registered");try{let{registerWorkspace:i}=await import('./workspace-EHYCBFXL.js');await i(e,m.basename(e));}catch{}if(!n){a.start("Initializing git repository");try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),a.succeed("Git repository initialized");}catch{a.warn("Could not initialize git repository");}}}catch(i){throw a.fail("Failed to register workspace"),i}}async function jt(e,o){let n=o==="poetry"?`source $(poetry env info --path)/bin/activate
232
+ `,"utf-8");}async function ce(e,o){let{skipGit:n=false,testMode:r=false,userConfig:l={},yes:p=false,installMethod:c,pythonVersion:u="3.10"}=o||{},g=c||l.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return a$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})(),h=g==="poetry"&&!await xt()?"venv":g;await z(e,m.basename(e),h),await V(e),await Y(e,m.basename(e),h,u,o?.profile);let a=O("Registering workspace").start();try{h==="poetry"?(await U(e,m.basename(e)),await _t(e,u,a,r,l,p)):h==="venv"?await ct(e,u,a,r,l):await Et(e,a,r,l,p),await It(e,h),await jt(e,h),a.succeed("Workspace registered");try{let{registerWorkspace:i}=await import('./workspace-QCU3VBCD.js');await i(e,m.basename(e));}catch{}if(!n){a.start("Initializing git repository");try{await execa("git",["init"],{cwd:e}),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: RapidKit workspace"],{cwd:e}),a.succeed("Git repository initialized");}catch{a.warn("Could not initialize git repository");}}}catch(i){throw a.fail("Failed to register workspace"),i}}async function jt(e,o){let n=o==="poetry"?`source $(poetry env info --path)/bin/activate
233
233
  # Or simply use: poetry run rapidkit <command>`:o==="venv"?"source .venv/bin/activate # On Windows: .venv\\Scripts\\activate":"N/A (globally installed)",r=o==="poetry"?`# No activation needed (recommended):
234
234
  ./rapidkit --help
235
235
  # or: