rapidkit 0.27.5 → 0.27.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -122,8 +122,8 @@ npx rapidkit readiness [--json] [--strict]
122
122
  npx rapidkit workspace policy show
123
123
  npx rapidkit workspace policy set <key> <value>
124
124
  npx rapidkit doctor
125
- npx rapidkit doctor workspace [--fix]
126
- npx rapidkit doctor project [--fix]
125
+ npx rapidkit doctor workspace [--fix] [--plan] [--apply]
126
+ npx rapidkit doctor project [--fix] [--plan] [--apply]
127
127
  npx rapidkit workspace list # Display all workspaces created on this system
128
128
  npx rapidkit workspace share [--output <file>] [--include-paths] [--no-doctor]
129
129
  npx rapidkit import <path|git-url> [--workspace <path>] [--name <project-name>] [--git] [--json]
@@ -204,16 +204,21 @@ RapidKit keeps the wrapper boundary explicit so users know which layer owns each
204
204
  | `workspace run` | Workspace orchestrator | Stage execution across discovered projects with optional affected-only, blast-radius expansion, and policy-gated pre-checks |
205
205
 
206
206
  Use `npx rapidkit doctor` for a quick host pre-flight, `npx rapidkit doctor project` for a service-level check, and `npx rapidkit doctor workspace` for the full workspace picture.
207
+ Use `npx rapidkit doctor workspace --plan` or `npx rapidkit doctor project --plan` to preview remediation safely.
208
+ Use `npx rapidkit doctor workspace --apply` or `npx rapidkit doctor project --apply` for non-interactive remediation runs.
207
209
  Use `npx rapidkit readiness` when you need machine-readable release evidence or strict CI gating.
208
210
 
209
211
  ### Doctor workspace fix behavior
210
212
 
211
213
  - `npx rapidkit doctor workspace` reuses cached project scans when valid and refreshes evidence under `.rapidkit/reports/doctor-last-run.json`.
212
- - `npx rapidkit doctor workspace --fix` only executes actionable fix commands.
214
+ - `npx rapidkit doctor workspace --fix` runs interactive remediation (confirmation prompt).
215
+ - `npx rapidkit doctor workspace --plan` prints remediation plan only (no mutations).
216
+ - `npx rapidkit doctor workspace --apply` applies remediation plan non-interactively.
213
217
  - Advisory warnings (for example, detected vulnerabilities or optional env metadata gaps) are reported in workspace health, but they do not automatically become shell fix commands.
214
- - It is valid to see `No fixes needed` after `--fix` when only advisory warnings are present.
218
+ - It is valid to see `No fixes needed` after `--fix`/`--apply` when only advisory warnings are present.
215
219
  - URL-based fixes are recorded as manual guidance (for example, install pages) and are not executed as shell commands.
216
220
  - Go project fixes that require `go mod tidy` are skipped when the Go toolchain is not available, with a clear install-and-rerun hint.
221
+ - `--plan` cannot be combined with `--fix` or `--apply`.
217
222
 
218
223
  ### Doctor workspace JSON fields (AI/automation)
219
224
 
@@ -233,6 +238,9 @@ Use `npx rapidkit readiness` when you need machine-readable release evidence or
233
238
  - Project mode supports RapidKit and non-RapidKit backend projects (generic runtime diagnostics still run when `.rapidkit` is missing).
234
239
  - JSON evidence is written to `.rapidkit/reports/doctor-project-last-run.json` (workspace-level when available).
235
240
  - `--fix` in project mode applies only project-scoped actionable fixes, with the same safe/guarded handling used by doctor fix flows.
241
+ - `--plan` in project mode prints remediation plan only (no mutations).
242
+ - `--apply` in project mode applies project-scoped remediation non-interactively.
243
+ - `--plan` cannot be combined with `--fix` or `--apply`.
236
244
  - Project diagnostics include built-in probes (configuration surface, migration surface, runtime health surface) and optional custom probe/adapter contracts.
237
245
 
238
246
  ### Doctor project JSON fields (AI/automation)
@@ -0,0 +1 @@
1
+ function e(t){let n=process.env[t];if(!n)return null;let r=Number(n);return !Number.isFinite(r)||r<=0?null:Math.trunc(r)}function i(){return e("RAPIDKIT_TIMEOUT_PROBE_MS")??3e3}function T(){return e("RAPIDKIT_TIMEOUT_NETWORK_MS")??3e3}function s(){return e("RAPIDKIT_TIMEOUT_BRIDGE_MS")??8e3}export{i as a,T as b,s as c};
@@ -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 A(){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);}},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
@@ -8,4 +8,4 @@ Troubleshooting:
8
8
  2. Use the core workflow: npx rapidkit create workspace <name>
9
9
  3. Offline fallback (limited): npx rapidkit create project fastapi.standard <name> --output .
10
10
 
11
- Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};export{A as a,O as b,N as c,v as d,o as e,p as f,d as g,f as h,u as i,g as j,h as k,m as l};
11
+ Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};export{$ as a,O as b,N as c,v as d,o as e,p as f,d as g,f as h,u as i,g as j,h as k,m as l};
@@ -0,0 +1,5 @@
1
+ import {a}from'./chunk-VM2TOHNX.js';import {b as b$1}from'./chunk-2FIX2MDC.js';import {execa}from'execa';import m from'chalk';import {createRequire}from'module';import {promises}from'fs';import l from'path';import g from'os';var v="rapidkit",A=createRequire(import.meta.url),C=A("../package.json"),i=C?.version??"0.0.0";function b(r){let e=r.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!e)return null;let t=e[4]?e[4].split(".").map(o=>o.match(/^\d+$/)?Number(o):o):[];return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:t}}function k(r,n){let e=b(r),t=b(n);if(!e||!t)return 0;if(e.major!==t.major)return e.major>t.major?1:-1;if(e.minor!==t.minor)return e.minor>t.minor?1:-1;if(e.patch!==t.patch)return e.patch>t.patch?1:-1;if(e.prerelease.length===0&&t.prerelease.length===0)return 0;if(e.prerelease.length===0)return 1;if(t.prerelease.length===0)return -1;let o=Math.max(e.prerelease.length,t.prerelease.length);for(let u=0;u<o;u+=1){let a=e.prerelease[u],s=t.prerelease[u];if(a===void 0)return -1;if(s===void 0)return 1;if(a===s)continue;let d=typeof a=="number",h=typeof s=="number";return d&&h?a>s?1:-1:d?-1:h||String(a)>String(s)?1:-1}return 0}var _=14400*1e3;function y(){let r=process.env.RAPIDKIT_CACHE_DIR?.trim()||(process.env.VITEST_WORKER_ID?l.join(g.homedir(),".rapidkit","cache",`vitest-${process.env.VITEST_WORKER_ID}`):l.join(g.homedir(),".rapidkit","cache"));return l.join(r,"update-check.json")}async function U(){try{let r=await promises.readFile(y(),"utf-8"),n=JSON.parse(r);return typeof n.latestVersion=="string"&&typeof n.checkedAt=="number"&&n.currentVersion===i&&Date.now()-n.checkedAt<_?n:null}catch{return null}}async function N(r){try{let n=y();await promises.mkdir(l.dirname(n),{recursive:true}),await promises.writeFile(n,JSON.stringify({latestVersion:r,checkedAt:Date.now(),currentVersion:i}),"utf-8");}catch{}}async function F(){try{a.debug("Checking for updates...");let r=await U();if(r){let t=Math.round((Date.now()-r.checkedAt)/6e4);a.debug(`Update check: cache hit (${t}m old)`),k(r.latestVersion,i)>0&&(console.log(m.yellow(`
2
+ \u26A0\uFE0F Update available: ${i} \u2192 ${r.latestVersion}`)),console.log(m.cyan(`Run: npm install -g rapidkit@latest
3
+ `)));return}let{stdout:n}=await execa("npm",["view",v,"version"],{timeout:b$1()}),e=n.trim();await N(e),e&&k(e,i)>0?(console.log(m.yellow(`
4
+ \u26A0\uFE0F Update available: ${i} \u2192 ${e}`)),console.log(m.cyan(`Run: npm install -g rapidkit@latest
5
+ `))):a.debug("You are using the latest version");}catch{a.debug("Could not check for updates");}}function M(){return i}export{F as a,M as b};
@@ -0,0 +1,33 @@
1
+ import {a as a$1,d,e,f,c,g as g$1}from'./chunk-Z5LKRG57.js';import {a}from'./chunk-2FIX2MDC.js';import pt from'crypto';import Z from'os';import u from'path';import*as p from'fs-extra';import {execa}from'execa';var dt=["version","project","create","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],$=new Set(dt);var g=a();function X(){return d()}function v(t,n){return t==="py"?["-3",...n]:n}function K(t){if(!t)return t;let n=["Installed Poetry version does not support '--no-update'. Falling back to 'poetry lock'."];return t.split(/\r?\n/).filter(i=>!n.some(o=>i.includes(o))).join(`
2
+ `)}var w=class extends Error{code;constructor(n,r){super(r),this.code=n;}};function b(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 A(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function ut(){let t=A(),n=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,r=n&&n.trim()?`${t}|${n.trim()}`:t;return pt.createHash("sha256").update(r).digest("hex").slice(0,12)}function I(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:u.join(Z.homedir(),".cache")}function lt(){return u.join(I(),"rapidkit","npm-bridge","venv")}function q(){let t=ut();return u.join(I(),"rapidkit","npm-bridge",`venv-${t}`)}function L(t){return f(t)}function J(t){return g$1(t)}function Q(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function mt(t){return u.dirname(u.dirname(t))}function tt(){return u.join(I(),"rapidkit","npm-bridge","core-commands.json")}async function et(t){let n=!!process.env.RAPIDKIT_DEBUG,r=e=>{n&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${e}
15
+ `);};try{r("probing interpreter-specific rapidkit script");let i=((await execa(t,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(e){r(`interpreter-specific script probe error: ${String(e)}`);}try{r('probing importlib.find_spec("rapidkit")');let e=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=${e.exitCode} stdout=${(e.stdout??"").toString().trim()}`),e.exitCode===0&&(e.stdout??"").toString().trim()==="1")return true}catch(e){r(`import probe error: ${String(e)}`);}try{r("probing python -m rapidkit");let e=await execa(t,v(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(r(`-m probe exitCode=${e.exitCode}`),e.exitCode===0)return true}catch(e){r(`-m probe error: ${String(e)}`);}try{r("probing PATH for rapidkit executables");let e=(process.env.PATH??"").split(u.delimiter).filter(Boolean);for(let i of e){let o=u.join(i,a$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(e){return r(`PATH probe error: ${String(e)}`),false}}async function M(t){let n=(t??"").toString().trim();if(!n)return false;try{let r=JSON.parse(n);return !!r&&typeof r=="object"&&r!==null&&"version"in r}catch{return false}}async function ft(t){let n=u.relative(".",g$1(".venv")),r=u.relative(".",f(".venv")),e=t;for(let i=0;i<25;i+=1){let o=u.join(e,n);if(await p.pathExists(o)){let c=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:e});if(c.exitCode===0&&await M(c.stdout))return {cmd:o,baseArgs:[]}}let s=u.join(e,r);if(await p.pathExists(s)){let c=await execa(s,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:e});if(c.exitCode===0&&await M(c.stdout))return {cmd:s,baseArgs:["-m","rapidkit"]}}let a=u.dirname(e);if(a===e)break;e=a;}return null}async function ht(t){try{let n=u.join(t,".python-version");if(await p.pathExists(n)){let e=(await p.readFile(n,"utf-8")).trim();if(e)return e}}catch{}try{let n=u.join(t,".rapidkit-workspace");if(await p.pathExists(n)){let r=await p.readFile(n,"utf-8"),e=JSON.parse(r);if(e.pythonVersion)return e.pythonVersion}}catch{}return null}async function B(t){if(t&&t.trim())try{let o=await ft(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 ht(s);return a&&(process.env.PYENV_VERSION=a),o}}catch{}let n=await _t();if(n.kind==="venv"){let o=mt(n.pythonPath),s=J(o);return await p.pathExists(s)?{cmd:s,baseArgs:[]}:{cmd:n.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(n.cmd,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:n.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let s=((await execa(n.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(s&&await p.pathExists(s))try{let a=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(a.exitCode===0&&await M(a.stdout))return {cmd:s,baseArgs:[]}}catch{}}catch{}let r=q(),e=await S(n.cmd),i=J(r);return await p.pathExists(i)?{cmd:i,baseArgs:[]}:{cmd:e,baseArgs:["-m","rapidkit"]}}async function V(){for(let t of X())try{return await execa(t,v(t,["--version"]),{reject:false,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function gt(){let t=!!process.env.RAPIDKIT_DEBUG,n=e=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${e}
16
+ `);},r=Array.from(new Set([...d(),...e(14,10).map(e=>e.command)]));for(let e of r)try{n(`Method 1: trying ${e} import`);let i=await execa(e,v(e,["-c","import rapidkit_core; print(1)"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.trim()==="1")return n(`\u2713 Found via ${e} import`),true}catch{continue}for(let e of r)try{n(`Method 2: trying ${e} -m pip show`);let i=await execa(e,v(e,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found via ${e} -m pip show`),true}catch{continue}for(let e of ["pip","pip3"])try{n(`Method 3: trying ${e} show`);let i=await execa(e,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found via ${e} show`),true}catch{continue}try{n("Method 4: checking pyenv versions");let e=await execa("pyenv",["versions","--bare"],{reject:false,stdio:"pipe",timeout:g});if(e.exitCode===0&&e.stdout){let i=e.stdout.split(`
17
+ `).filter(o=>o.trim());n(`Found pyenv versions: ${i.join(", ")}`);for(let o of i){let s=process.env.PYENV_ROOT||u.join(Z.homedir(),".pyenv"),a=u.join(s,"versions",o.trim(),"bin","pip");try{let c=await execa(a,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found in pyenv ${o}`),true}catch{try{let c=await execa("pyenv",["exec","pip","show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g,env:{...process.env,PYENV_VERSION:o.trim()}});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return n(`\u2713 Found in pyenv ${o} via PYENV_VERSION`),true}catch{continue}}}}}catch{n("pyenv not available");}for(let e of r)try{n(`Method 5: checking ${e} user site`);let i=await execa(e,v(e,["-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 n("\u2713 Found in user site-packages"),true}}catch{continue}try{n("Method 6: checking pipx");let e=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:g});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return n("\u2713 Found via pipx"),true}catch{n("pipx not available");}for(let e of r)try{n(`Method 6: checking ${e} -m pipx list`);let i=await execa(e,v(e,["-m","pipx","list"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("rapidkit-core"))return n(`\u2713 Found via ${e} -m pipx list`),true}catch{continue}try{if(n("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g})).exitCode===0)return n("\u2713 Found via poetry"),true}catch{n("poetry check failed");}for(let e of r)try{if(n(`Method 7: checking ${e} -m poetry show rapidkit-core`),(await execa(e,v(e,["-m","poetry","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g})).exitCode===0)return n(`\u2713 Found via ${e} -m poetry`),true}catch{continue}try{n("Method 8: checking conda");let e=await execa("conda",["list","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(e.exitCode===0&&e.stdout?.includes("rapidkit-core"))return n("\u2713 Found via conda"),true}catch{n("conda not available");}return n("\u2717 Not found in any environment"),false}function yt(t){let n=t.trim();if(!n||!n.startsWith("rapidkit-core"))return null;let r=n.slice(13).trim();return !r||/[\/@]|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(r)?null:r}function U(t){let n=t.trim();if(!n)return null;let r=n.split("."),e=[];for(let i of r){let o=i.match(/^(\d+)/);if(!o){e.push(0);continue}e.push(Number.parseInt(o[1],10));}return e}function H(t,n){let r=Math.max(t.length,n.length);for(let e=0;e<r;e+=1){let i=e<t.length?t[e]:0,o=e<n.length?n[e]:0;if(i>o)return 1;if(i<o)return -1}return 0}function wt(t){return t.length<=1?[t[0]+1]:t.length===2?[t[0]+1,0]:[t[0],t[1]+1,0]}function vt(t){let n=t.split(",").map(e=>e.trim()).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n){let i=e.match(/^(==|>=|<=|>|<|~=)\s*([0-9][0-9A-Za-z+._-]*)$/);if(!i)return null;r.push({op:i[1],version:i[2]});}return r}function nt(t,n){let r=U(t);if(!r)return false;let e=vt(n);if(!e)return false;for(let i of e){let o=U(i.version);if(!o)return false;let s=H(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=wt(o);if(H(r,a)>=0)return false}}return true}async function Ct(){let t=Array.from(new Set([...d(),...e(14,10).map(r=>r.command)])),n=r=>{let e=r.match(/^Version:\s*(.+)$/m);return e?e[1].trim():null};for(let r of t)try{let e=await execa(r,v(r,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g});if(e.exitCode===0){let i=n(e.stdout||"");if(i)return i}}catch{continue}for(let r of ["pip","pip3"])try{let e=await execa(r,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(e.exitCode===0){let i=n(e.stdout||"");if(i)return i}}catch{continue}try{let r=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:g});if(r.exitCode===0&&r.stdout){let e=r.stdout.match(/rapidkit-core\s+([0-9][0-9A-Za-z+._-]*)/i);if(e?.[1])return e[1]}}catch{}return null}async function Pt(){let t=A(),n=yt(t);if(!n)return {isCompatible:false,installedVersion:null,expectedConstraint:null,reason:Q(t)?"constraint-unsupported":"constraint-missing"};let r=await Ct();if(!r)return {isCompatible:false,installedVersion:null,expectedConstraint:n,reason:"version-not-detected"};let e=nt(r,n);return {isCompatible:e,installedVersion:r,expectedConstraint:n,reason:e?"compatible":"incompatible-version"}}async function S(t){let n=q(),r=lt(),e=A(),i=[n];!Q(e)&&!await p.pathExists(n)&&await p.pathExists(r)&&i.push(r);for(let l of i){let h=L(l);if(await p.pathExists(h))try{let f=await execa(h,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:false,stdio:"pipe",timeout:2e3});if(f.exitCode===0&&(f.stdout??"").toString().trim()==="1")return h;await p.remove(l);}catch{await p.remove(l);}}let o=n,s={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},a=Math.max(0,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY??"2")),c=Math.max(200,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY_DELAY_MS??"800")),m=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),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 D=(y.stdout??"").toString(),O=(y.stderr??"").toString(),x=[D,O].filter(Boolean).join(`
18
+ `),st=x?`${l} ${h.join(" ")}
19
+ ${x}`:`${l} ${h.join(" ")}`;throw new Error(st)},E=async(l,h,f)=>{let y=0;for(;;)try{await P(l,h,f);return}catch(D){if(y>=a)throw D;let O=Math.floor(Math.random()*200),x=c*Math.pow(2,y)+O;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=L(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 E(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 E(l,["-m","pip","install","-U",A()],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 _t(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1"){let r=await V();if(!r)throw new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");return {kind:"venv",pythonPath:await S(r)}}for(let r of X())if(await et(r))return {kind:"system",cmd:r};let t=await V();if(!t)throw new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");return {kind:"venv",pythonPath:await S(t)}}async function $t(t,n){try{let r=await B(n?.cwd),e=r.cmd,i=[...r.baseArgs,...t];if(t[0]==="init"){let a=await execa(e,i,{cwd:n?.cwd,env:{...process.env,...n?.env},reject:false,stdio:"pipe"}),c=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(e,i,{cwd:n?.cwd,env:{...process.env,...n?.env},reject:false,stdio:"inherit"});return typeof s.exitCode=="number"?s.exitCode:1}catch(r){return process.stderr.write(`${b(r)}
24
+ `),1}}var Et=[{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,n){let{spawn:r}=await import('child_process');try{let e=await B(n?.cwd),i=e.cmd,o=[...e.baseArgs,...t];return await new Promise(s=>{let a=r(i,o,{cwd:n?.cwd,env:{...process.env,...n?.env},stdio:["inherit","inherit","pipe"]}),c=[];a.stderr?.on("data",m=>{c.push(m);}),a.on("close",m=>{let C=m??1;if(C!==0&&c.length>0){let P=Buffer.concat(c).toString("utf8");for(let{pattern:E,message:l}of Et){let h=P.match(E);if(h){process.stderr.write(l(h)+`
29
+ `),s(C);return}}process.stderr.write(P);}s(C);}),a.on("error",m=>{process.stderr.write(`${b(m)}
30
+ `),s(1);});})}catch(e){return process.stderr.write(`${b(e)}
31
+ `),1}}async function _(t,n){try{let r=await B(n?.cwd),e=r.cmd,i=[...r.baseArgs,...t],o=await execa(e,i,{cwd:n?.cwd,env:{...process.env,...n?.env},reject:false,stdio:"pipe"});return {exitCode:typeof o.exitCode=="number"?o.exitCode:1,stdout:(o.stdout??"").toString(),stderr:(o.stderr??"").toString()}}catch(r){return {exitCode:1,stdout:"",stderr:`${b(r)}
32
+ `}}}function rt(t){let n=new Set,r=t.split(`
33
+ `),e=false;for(let i of r){let o=i.replace(/\r$/,"");if(!e){/^\s*Commands:\s*$/i.test(o)&&(e=true);let c=o.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let m=c[1].trim();m&&!m.startsWith("-")&&n.add(m);}continue}if(!o.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(o))continue;let s=o.match(/^\s*([a-z0-9][a-z0-9_-]*)\b/i);if(!s)continue;let a=s[1].trim();a&&!a.startsWith("-")&&n.add(a);}return n}async function it(){let t=tt();if(!await p.pathExists(t))return null;try{let n=await p.readJson(t);if(n&&n.schema_version===1&&Array.isArray(n.commands))return n}catch{}return null}async function Y(t){let n=tt();await p.ensureDir(u.dirname(n)),await p.writeJson(n,t,{spaces:2});}async function xt(){let t=await _(["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 kt(){let t=await _(["commands","--json"],{cwd:process.cwd()});if(t.exitCode!==0)return null;try{let n=JSON.parse(t.stdout);if(n?.schema_version!==1||!Array.isArray(n.commands))return null;let r=n.commands.filter(e=>typeof e=="string");return r.length?r:null}catch{return null}}async function Vt(){let n=Date.now(),r=await it(),e=await xt(),i=!!r?.commands?.length;if(i&&n-r.fetched_at<864e5&&(!e||!r.rapidkit_version||r.rapidkit_version===e))return new Set(r.commands);let o=await kt();if(o?.length){let m=Array.from(new Set(o)).sort();return await Y({schema_version:1,fetched_at:n,rapidkit_version:e,commands:m}),new Set(m)}let s=await _(["--help"],{cwd:process.cwd()});if(s.exitCode!==0)return i&&r?.commands?new Set(r.commands):new Set($);let a=rt(s.stdout);if(a.size===0)return new Set($);let c=Array.from(a).sort();return await Y({schema_version:1,fetched_at:n,rapidkit_version:e,commands:c}),a}async function Bt(){let n=Date.now(),r=await it();return !r||n-r.fetched_at>=864e5||!r.commands?.length?null:new Set(r.commands)}function ot(){return u.join(I(),"rapidkit","npm-bridge","modules-catalog.json")}async function Rt(){let t=ot();if(!await p.pathExists(t))return null;try{let n=await p.readJson(t);if(n&&n.schema_version===1&&Array.isArray(n.modules))return n}catch{}return null}async function z(t){let n=ot();await p.ensureDir(u.dirname(n)),await p.writeJson(n,t,{spaces:2});}function W(t){try{return JSON.parse(t)}catch{return null}}async function Ft(t={}){let n=typeof t.ttlMs=="number"?t.ttlMs:18e5,r=Date.now(),e=await Rt();if(e?.fetched_at&&r-e.fetched_at<n)return e;let i=["modules","list","--json-schema","1"];t.category&&i.push("--category",t.category),t.tag&&i.push("--tag",t.tag),t.detailed&&i.push("--detailed");let o=await _(i,{cwd:t.cwd,env:t.env});if(o.exitCode===0){let a=W(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 _(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(s.exitCode===0){let a=W(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 e||null}var Gt={pickSystemPython:V,ensureBridgeVenv:S,parseCoreCommandsFromHelp:rt,tryRapidkit:et,checkRapidkitCoreAvailable:gt,checkRapidkitCoreVersionCompatible:Pt,isVersionSatisfyingConstraint:nt};export{$ as a,gt as b,Pt as c,_t as d,$t as e,Mt as f,_ as g,Vt as h,Bt as i,Ft as j,Gt as k};
@@ -0,0 +1 @@
1
+ import {promises}from'fs';import r from'path';var D=new Set(["node_modules","dist","build","target","coverage","htmlcov",".rapidkit",".venv"]);async function d(e){try{return await promises.access(e),true}catch{return false}}async function P(e){return await d(r.join(e,".rapidkit","context.json"))?true:d(r.join(e,".rapidkit","project.json"))}async function k(e,i){let c=[],o=[r.resolve(e)],a=new Set,l=i?.skipDirs??D,h=i?.includeHiddenDirs===true,f=i?.descendIntoMatchedProjects!==false,p=i?.isProjectDir??P,m=r.resolve(e);for(;o.length>0;){let t=o.shift();if(!t||a.has(t)||(a.add(t),await p(t,m)&&(c.push(t),!f)))continue;let n=[];try{n=await promises.readdir(t,{withFileTypes:true});}catch{continue}for(let s of n)s.isDirectory()&&(!h&&s.name.startsWith(".")||l.has(s.name)||o.push(r.join(t,s.name)));}return c.sort((t,n)=>t.localeCompare(n))}export{k as a};
@@ -1,4 +1,4 @@
1
- import {i,d as d$2,l,k as k$1,f as f$1,g,h}from'./chunk-ZAZJEYYT.js';import {a,d,b as b$1}from'./chunk-RV6HBTFC.js';import {a as a$2,e,d as d$1,f,c,k as k$2}from'./chunk-Z5LKRG57.js';import {b}from'./chunk-Q7ULIFQA.js';import {a as a$1}from'./chunk-VM2TOHNX.js';import {promises}from'fs';import*as k from'fs-extra';import m from'path';import q from'inquirer';import t from'chalk';import O from'ora';import {execa}from'execa';function S(){return c()}async function z(e,n,o,r){let l=d(n,b(),o);r&&(l.metadata||(l.metadata={}),l.metadata.python={version:r}),await b$1(e,l);}async function V(e){await k.outputFile(m.join(e,".gitignore"),`.venv/
1
+ import {i,d as d$2,l,k as k$1,f as f$1,g,h}from'./chunk-7OGOVP5U.js';import {a,d,b as b$1}from'./chunk-RV6HBTFC.js';import {a as a$2,e,d as d$1,f,c,k as k$2}from'./chunk-Z5LKRG57.js';import {b}from'./chunk-AC6KIKII.js';import {a as a$1}from'./chunk-VM2TOHNX.js';import {promises}from'fs';import*as k from'fs-extra';import m from'path';import q from'inquirer';import t from'chalk';import O from'ora';import {execa}from'execa';function S(){return c()}async function z(e,n,o,r){let l=d(n,b(),o);r&&(l.metadata||(l.metadata={}),l.metadata.python={version:r}),await b$1(e,l);}async function V(e){await k.outputFile(m.join(e,".gitignore"),`.venv/
2
2
  __pycache__/
3
3
  *.pyc
4
4
  .env
@@ -104,7 +104,7 @@ npx rapidkit dev
104
104
  cd <project-name>
105
105
  npx rapidkit init
106
106
  npx rapidkit dev
107
- `)+"```\n","utf-8"),!o){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:P}=await import('./workspace-776YW7I6.js');await P(i$1,a);}catch{}if(console.log(t.green(`
107
+ `)+"```\n","utf-8"),!o){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:P}=await import('./workspace-YKWUI37R.js');await P(i$1,a);}catch{}if(console.log(t.green(`
108
108
  \u2728 Workspace created!
109
109
  `)),console.log(t.cyan("\u{1F4C2} Location:"),t.white(i$1)),console.log(t.cyan(`
110
110
  \u{1F680} Get started:
@@ -154,7 +154,7 @@ npx rapidkit dev
154
154
  cd <project-name>
155
155
  npx rapidkit init
156
156
  npx rapidkit dev
157
- `)+"```\n","utf-8"),!o){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:Et}=await import('./workspace-776YW7I6.js');await Et(i$1,a);}catch{}console.log(t.green(`
157
+ `)+"```\n","utf-8"),!o){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:Et}=await import('./workspace-YKWUI37R.js');await Et(i$1,a);}catch{}console.log(t.green(`
158
158
  \u2728 Workspace created with fallback profile!
159
159
  `)),console.log(t.cyan("\u{1F4C2} Location:"),t.white(i$1)),console.log(t.cyan(`
160
160
  \u{1F680} Get started:
@@ -164,7 +164,7 @@ npx rapidkit dev
164
164
  `)),console.log("");return}catch(B){throw C.fail("Failed to create workspace"),console.error(t.red(`
165
165
  \u274C Error:`),B),B}}}else if(console.log(t.yellow(`
166
166
  \u26A0\uFE0F Python not detected. Auto-switching to "${w}" profile (no Python required).
167
- `)),d=w,new Set(["go-only","java-only","node-only","minimal"]).has(w)){let E=O("Creating workspace").start();try{if(await k.ensureDir(i$1),E.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),!o){E.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}),E.succeed("Git repository initialized");}catch{E.warn("Could not initialize git repository");}}try{let{registerWorkspace:C}=await import('./workspace-776YW7I6.js');await C(i$1,a);}catch{}console.log(t.green(`
167
+ `)),d=w,new Set(["go-only","java-only","node-only","minimal"]).has(w)){let E=O("Creating workspace").start();try{if(await k.ensureDir(i$1),E.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),!o){E.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}),E.succeed("Git repository initialized");}catch{E.warn("Could not initialize git repository");}}try{let{registerWorkspace:C}=await import('./workspace-YKWUI37R.js');await C(i$1,a);}catch{}console.log(t.green(`
168
168
  \u2728 Workspace created (auto-fallback profile)!
169
169
  `)),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(`
170
170
  \u{1F680} Get started:
@@ -172,7 +172,7 @@ npx rapidkit dev
172
172
  `)),console.log(t.cyan(`\u{1F4A1} Add Python later:
173
173
  `)),console.log(t.gray(" 1. Install Python 3.10+")),console.log(t.gray(` 2. Run: cd ${a} && rapidkit bootstrap --profile ${d}
174
174
  `)),console.log("");return}catch(C){throw E.fail("Failed to create workspace"),console.error(t.red(`
175
- \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 xt(b.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 P=S();f=await gt(P),f?I.succeed(`Python ${f} detected`):I.warn("Could not detect Python version, proceeding with defaults");}if(b.installMethod==="poetry"&&!await bt()&&(I.warn("Poetry not found \u2014 auto-fallback to pip + venv"),b.installMethod="venv"),await z(i$1,a,b.installMethod,f||void 0),f&&await St(i$1,f),await Y(i$1,a,b.installMethod,f||b.pythonVersion,d||h),await V(i$1),await U(i$1,a),b.installMethod==="poetry")try{await It(i$1,b.pythonVersion,I,r,y,u);}catch(P){let w=P?.details||P?.message||String(P);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,b.pythonVersion,I,r,y),b.installMethod="venv";}catch(K){throw K}}else throw P}else b.installMethod==="venv"?await ct(i$1,b.pythonVersion,I,r,y):await Rt(i$1,I,r,y,u);if(await Pt(i$1,b.installMethod),await _t(i$1,b.installMethod),I.succeed("RapidKit environment ready!"),!n.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:P}=await import('./workspace-776YW7I6.js');await P(i$1,a);}catch{console.warn(t.gray("Note: Could not register workspace in shared registry"));}if(console.log(t.green(`
175
+ \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 xt(b.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 P=S();f=await gt(P),f?I.succeed(`Python ${f} detected`):I.warn("Could not detect Python version, proceeding with defaults");}if(b.installMethod==="poetry"&&!await bt()&&(I.warn("Poetry not found \u2014 auto-fallback to pip + venv"),b.installMethod="venv"),await z(i$1,a,b.installMethod,f||void 0),f&&await St(i$1,f),await Y(i$1,a,b.installMethod,f||b.pythonVersion,d||h),await V(i$1),await U(i$1,a),b.installMethod==="poetry")try{await It(i$1,b.pythonVersion,I,r,y,u);}catch(P){let w=P?.details||P?.message||String(P);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,b.pythonVersion,I,r,y),b.installMethod="venv";}catch(K){throw K}}else throw P}else b.installMethod==="venv"?await ct(i$1,b.pythonVersion,I,r,y):await Rt(i$1,I,r,y,u);if(await Pt(i$1,b.installMethod),await _t(i$1,b.installMethod),I.succeed("RapidKit environment ready!"),!n.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:P}=await import('./workspace-YKWUI37R.js');await P(i$1,a);}catch{console.warn(t.gray("Note: Could not register workspace in shared registry"));}if(console.log(t.green(`
176
176
  \u2728 RapidKit environment created successfully!
177
177
  `)),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: ${b.pythonVersion}`)),console.log(t.gray(` \u2022 Install method: ${b.installMethod}`)),console.log(t.cyan(`
178
178
  \u{1F680} Get started:
@@ -205,7 +205,7 @@ Error: ${x}
205
205
  Possible solutions:
206
206
  1. Check your internet connection
207
207
  2. Try installing manually: cd ${m.basename(e)} && poetry add rapidkit-core
208
- 3. Use venv method instead: npx rapidkit ${m.basename(e)} --install-method=venv`))}}}o.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await import('./pythonRapidkitExec-GPPHN3L4.js');if(!await c()&&!r){o.start("Checking optional global pipx installation");let x=await tt(o,true);try{o.start("Installing RapidKit globally with pipx for CLI access"),await T(x,["install","rapidkit-core"]),o.succeed("RapidKit installed globally");}catch($){o.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${$}`);}}}catch(c){o.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${c}`);}}async function ct(e,n,o,r,l$1,p=false){o.start(`Checking Python ${n}`);let u=S();try{let{stdout:g}=await execa(u,["--version"]),h=g.match(/Python (\d+\.\d+)/)?.[1];if(h&&!G(h,n))throw new f$1(n,h);o.succeed(`Python ${h} found`);}catch(g){throw g instanceof f$1?g:new f$1(n)}o.start("Creating virtual environment");try{await execa(u,["-m","venv",".venv"],{cwd:e}),o.succeed("Virtual environment created");}catch(g){if(o.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.
208
+ 3. Use venv method instead: npx rapidkit ${m.basename(e)} --install-method=venv`))}}}o.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await import('./pythonRapidkitExec-4MP62M5R.js');if(!await c()&&!r){o.start("Checking optional global pipx installation");let x=await tt(o,true);try{o.start("Installing RapidKit globally with pipx for CLI access"),await T(x,["install","rapidkit-core"]),o.succeed("RapidKit installed globally");}catch($){o.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${$}`);}}}catch(c){o.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${c}`);}}async function ct(e,n,o,r,l$1,p=false){o.start(`Checking Python ${n}`);let u=S();try{let{stdout:g}=await execa(u,["--version"]),h=g.match(/Python (\d+\.\d+)/)?.[1];if(h&&!G(h,n))throw new f$1(n,h);o.succeed(`Python ${h} found`);}catch(g){throw g instanceof f$1?g:new f$1(n)}o.start("Creating virtual environment");try{await execa(u,["-m","venv",".venv"],{cwd:e}),o.succeed("Virtual environment created");}catch(g){if(o.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.
209
209
 
210
210
  On Debian/Ubuntu systems, install the venv package:
211
211
  sudo apt install ${i}
@@ -217,9 +217,9 @@ Error: ${a}
217
217
  Possible solutions:
218
218
  1. Check your internet connection
219
219
  2. Try installing manually: cd ${m.basename(e)} && ${f(".venv")} -m pip install rapidkit-core
220
- 3. Use Poetry instead: npx rapidkit ${m.basename(e)} --install-method=poetry`))}}o.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:g}=await import('./pythonRapidkitExec-GPPHN3L4.js');if(!await g()&&!r){o.start("Checking optional global pipx installation");let a=await tt(o,true);try{o.start("Installing RapidKit globally with pipx for CLI access"),await T(a,["install","rapidkit-core"]),o.succeed("RapidKit installed globally");}catch(i){o.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${i}`);}}}catch(g){o.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${g}`);}}async function Rt(e,n,o,r,l$1=false){if(!o)try{let{checkRapidkitCoreVersionCompatible:u}=await import('./pythonRapidkitExec-GPPHN3L4.js'),y=await u();if(y.isCompatible){n.succeed(`RapidKit ${y.installedVersion??""} already compatible globally; skipping pipx installation`),await k.outputFile(m.join(e,".rapidkit-global"),`RapidKit already available globally (version ${y.installedVersion??"unknown"}) and satisfies expected constraint ${y.expectedConstraint??"n/a"}; workspace will reuse the existing installation
220
+ 3. Use Poetry instead: npx rapidkit ${m.basename(e)} --install-method=poetry`))}}o.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:g}=await import('./pythonRapidkitExec-4MP62M5R.js');if(!await g()&&!r){o.start("Checking optional global pipx installation");let a=await tt(o,true);try{o.start("Installing RapidKit globally with pipx for CLI access"),await T(a,["install","rapidkit-core"]),o.succeed("RapidKit installed globally");}catch(i){o.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),a$1.debug(`pipx install failed: ${i}`);}}}catch(g){o.succeed("Skipped optional global pipx installation"),a$1.debug(`Global install check skipped: ${g}`);}}async function Rt(e,n,o,r,l$1=false){if(!o)try{let{checkRapidkitCoreVersionCompatible:u}=await import('./pythonRapidkitExec-4MP62M5R.js'),y=await u();if(y.isCompatible){n.succeed(`RapidKit ${y.installedVersion??""} already compatible globally; skipping pipx installation`),await k.outputFile(m.join(e,".rapidkit-global"),`RapidKit already available globally (version ${y.installedVersion??"unknown"}) and satisfies expected constraint ${y.expectedConstraint??"n/a"}; workspace will reuse the existing installation
221
221
  `,"utf-8");return}y.reason==="constraint-missing"?n.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.'):y.reason==="constraint-unsupported"&&n.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=${y.reason}, installed=${y.installedVersion??"unknown"}, expected=${y.expectedConstraint??"none"}). Proceeding with pipx install/upgrade.`);}catch(u){a$1.debug(`Global RapidKit version-aware check failed before pipx install: ${u}`);}let p=await tt(n,l$1);if(n.start("Installing RapidKit globally with pipx"),o){let u=d$2(r||{});if(!u)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: ${u}`),n.text="Installing RapidKit from local path (test mode)",await T(p,["install","-e",u]);}else {n.text="Installing RapidKit from PyPI";try{await T(p,["install","rapidkit-core"]);}catch(u){try{n.text="RapidKit already installed globally, upgrading to match expected version",await T(p,["upgrade","rapidkit-core"]);}catch(y){throw a$1.debug(`pipx install/upgrade failed: install=${u}, upgrade=${y}`),new l}}}n.succeed("RapidKit installed globally"),await k.outputFile(m.join(e,".rapidkit-global"),`RapidKit installed globally with pipx
222
- `,"utf-8");}async function se(e,n){let{skipGit:o=false,testMode:r=false,userConfig:l={},yes:p=false,installMethod:u,pythonVersion:y="3.10"}=n||{},g=u||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 bt()?"venv":g;await z(e,m.basename(e),h),await V(e),await Y(e,m.basename(e),h,y,n?.profile);let a=O("Registering workspace").start();try{h==="poetry"?(await U(e,m.basename(e)),await It(e,y,a,r,l,p)):h==="venv"?await ct(e,y,a,r,l):await Rt(e,a,r,l,p),await Pt(e,h),await _t(e,h),a.succeed("Workspace registered");try{let{registerWorkspace:i}=await import('./workspace-776YW7I6.js');await i(e,m.basename(e));}catch{}if(!o){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 _t(e,n){let o=n==="poetry"?`source $(poetry env info --path)/bin/activate
222
+ `,"utf-8");}async function se(e,n){let{skipGit:o=false,testMode:r=false,userConfig:l={},yes:p=false,installMethod:u,pythonVersion:y="3.10"}=n||{},g=u||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 bt()?"venv":g;await z(e,m.basename(e),h),await V(e),await Y(e,m.basename(e),h,y,n?.profile);let a=O("Registering workspace").start();try{h==="poetry"?(await U(e,m.basename(e)),await It(e,y,a,r,l,p)):h==="venv"?await ct(e,y,a,r,l):await Rt(e,a,r,l,p),await Pt(e,h),await _t(e,h),a.succeed("Workspace registered");try{let{registerWorkspace:i}=await import('./workspace-YKWUI37R.js');await i(e,m.basename(e));}catch{}if(!o){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 _t(e,n){let o=n==="poetry"?`source $(poetry env info --path)/bin/activate
223
223
  # Or simply use: poetry run rapidkit <command>`:n==="venv"?"source .venv/bin/activate # On Windows: .venv\\Scripts\\activate":"N/A (globally installed)",r=n==="poetry"?`# No activation needed (recommended):
224
224
  ./rapidkit --help
225
225
  # or:
@@ -1,4 +1,4 @@
1
- import {b}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import a from'path';import E from'nunjucks';import t from'chalk';import _ from'ora';import {fileURLToPath}from'url';import {execa}from'execa';import N from'crypto';var P=fileURLToPath(import.meta.url),K=a.dirname(P);function T(i=32){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",v=N.randomBytes(i),r="";for(let p=0;p<i;p++)r+=e[v[p]%e.length];return r}async function U(i,e){let r=(e.template||"fastapi")==="fastapi",p=r?"FastAPI":"NestJS",d=e.kit_name||(r?"fastapi.standard":"nestjs.standard"),I=d.replace(".","/"),h=_(`Generating ${p} project...`).start();try{let u=a.resolve(K,".."),l;d==="fastapi.ddd"?l="fastapi-ddd":d.startsWith("fastapi")?l="fastapi-standard":l="nestjs-standard";let k=a.join(u,"templates","kits",l),w=E.configure(k,{autoescape:false,trimBlocks:true,lstripBlocks:true});w.addFilter("generate_secret",function(n,o=32){return T(o)});let S={project_name:e.project_name,author:e.author||"RapidKit User",description:e.description||(r?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:e.app_version||"0.1.0",license:e.license||"MIT",package_manager:e.package_manager||"npm",node_version:e.node_version||"20.0.0",database_type:e.database_type||"postgresql",include_caching:e.include_caching||false,created_at:new Date().toISOString(),rapidkit_version:b()},j;r?j=["src/main.py.j2","src/__init__.py.j2","src/cli.py.j2","src/routing/__init__.py.j2","src/routing/health.py.j2","src/modules/__init__.py.j2","tests/__init__.py.j2","README.md.j2","pyproject.toml.j2","Makefile.j2",".rapidkit/__init__.py.j2",".rapidkit/project.json.j2",".rapidkit/cli.py.j2",".rapidkit/rapidkit.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"]:j=["src/main.ts.j2","src/app.module.ts.j2","src/app.controller.ts.j2","src/app.service.ts.j2","src/config/configuration.ts.j2","src/config/validation.ts.j2","src/config/index.ts.j2","src/modules/index.ts.j2","src/examples/examples.module.ts.j2","src/examples/examples.controller.ts.j2","src/examples/examples.service.ts.j2","src/examples/dto/create-note.dto.ts.j2","test/app.controller.spec.ts.j2","test/examples.controller.spec.ts.j2","test/app.e2e-spec.ts.j2","test/jest-e2e.json.j2","package.json.j2","tsconfig.json.j2","tsconfig.build.json.j2","nest-cli.json.j2","jest.config.ts.j2","eslint.config.cjs.j2",".env.example.j2","docker-compose.yml.j2","Dockerfile.j2","README.md.j2",".rapidkit/project.json.j2",".rapidkit/rapidkit.j2",".rapidkit/rapidkit.cmd.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"];for(let n of j){let o=a.join(k,n);try{await promises.access(o);}catch{continue}let y=await promises.readFile(o,"utf-8"),m;try{m=w.renderString(y,S);}catch(R){throw console.error(`Failed to render template: ${n}`),R}let c=n.replace(/\.j2$/,""),f=a.join(i,c);await promises.mkdir(a.dirname(f),{recursive:true}),await promises.writeFile(f,m),(c.endsWith(".rapidkit/rapidkit")||c.endsWith(".rapidkit/cli.py")||c.endsWith(".rapidkit/activate")||c==="rapidkit")&&await promises.chmod(f,493);}if(r){let n=a.join(k,".rapidkit","context.json"),o=a.join(i,".rapidkit","context.json");try{await promises.mkdir(a.join(i,".rapidkit"),{recursive:true}),await promises.copyFile(n,o);}catch{await promises.mkdir(a.join(i,".rapidkit"),{recursive:true});let m=e.engine||"pip";await promises.writeFile(o,JSON.stringify({engine:m,created_by:"rapidkit-npm-fallback"},null,2));}}let x=a.join(i,".rapidkit");await promises.mkdir(x,{recursive:true});let F=a.join(x,"project.json"),A={kit_name:d,profile:I,created_at:new Date().toISOString(),created_by:"rapidkit-npm-fallback",runtime:r?"python":"node"};await promises.writeFile(F,JSON.stringify(A,null,2),"utf-8");let D=r?`# Python
1
+ import {b}from'./chunk-AC6KIKII.js';import {promises}from'fs';import a from'path';import E from'nunjucks';import t from'chalk';import _ from'ora';import {fileURLToPath}from'url';import {execa}from'execa';import N from'crypto';var P=fileURLToPath(import.meta.url),K=a.dirname(P);function T(i=32){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",v=N.randomBytes(i),r="";for(let p=0;p<i;p++)r+=e[v[p]%e.length];return r}async function U(i,e){let r=(e.template||"fastapi")==="fastapi",p=r?"FastAPI":"NestJS",d=e.kit_name||(r?"fastapi.standard":"nestjs.standard"),I=d.replace(".","/"),h=_(`Generating ${p} project...`).start();try{let u=a.resolve(K,".."),l;d==="fastapi.ddd"?l="fastapi-ddd":d.startsWith("fastapi")?l="fastapi-standard":l="nestjs-standard";let k=a.join(u,"templates","kits",l),w=E.configure(k,{autoescape:false,trimBlocks:true,lstripBlocks:true});w.addFilter("generate_secret",function(n,o=32){return T(o)});let S={project_name:e.project_name,author:e.author||"RapidKit User",description:e.description||(r?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:e.app_version||"0.1.0",license:e.license||"MIT",package_manager:e.package_manager||"npm",node_version:e.node_version||"20.0.0",database_type:e.database_type||"postgresql",include_caching:e.include_caching||false,created_at:new Date().toISOString(),rapidkit_version:b()},j;r?j=["src/main.py.j2","src/__init__.py.j2","src/cli.py.j2","src/routing/__init__.py.j2","src/routing/health.py.j2","src/modules/__init__.py.j2","tests/__init__.py.j2","README.md.j2","pyproject.toml.j2","Makefile.j2",".rapidkit/__init__.py.j2",".rapidkit/project.json.j2",".rapidkit/cli.py.j2",".rapidkit/rapidkit.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"]:j=["src/main.ts.j2","src/app.module.ts.j2","src/app.controller.ts.j2","src/app.service.ts.j2","src/config/configuration.ts.j2","src/config/validation.ts.j2","src/config/index.ts.j2","src/modules/index.ts.j2","src/examples/examples.module.ts.j2","src/examples/examples.controller.ts.j2","src/examples/examples.service.ts.j2","src/examples/dto/create-note.dto.ts.j2","test/app.controller.spec.ts.j2","test/examples.controller.spec.ts.j2","test/app.e2e-spec.ts.j2","test/jest-e2e.json.j2","package.json.j2","tsconfig.json.j2","tsconfig.build.json.j2","nest-cli.json.j2","jest.config.ts.j2","eslint.config.cjs.j2",".env.example.j2","docker-compose.yml.j2","Dockerfile.j2","README.md.j2",".rapidkit/project.json.j2",".rapidkit/rapidkit.j2",".rapidkit/rapidkit.cmd.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"];for(let n of j){let o=a.join(k,n);try{await promises.access(o);}catch{continue}let y=await promises.readFile(o,"utf-8"),m;try{m=w.renderString(y,S);}catch(R){throw console.error(`Failed to render template: ${n}`),R}let c=n.replace(/\.j2$/,""),f=a.join(i,c);await promises.mkdir(a.dirname(f),{recursive:true}),await promises.writeFile(f,m),(c.endsWith(".rapidkit/rapidkit")||c.endsWith(".rapidkit/cli.py")||c.endsWith(".rapidkit/activate")||c==="rapidkit")&&await promises.chmod(f,493);}if(r){let n=a.join(k,".rapidkit","context.json"),o=a.join(i,".rapidkit","context.json");try{await promises.mkdir(a.join(i,".rapidkit"),{recursive:true}),await promises.copyFile(n,o);}catch{await promises.mkdir(a.join(i,".rapidkit"),{recursive:true});let m=e.engine||"pip";await promises.writeFile(o,JSON.stringify({engine:m,created_by:"rapidkit-npm-fallback"},null,2));}}let x=a.join(i,".rapidkit");await promises.mkdir(x,{recursive:true});let F=a.join(x,"project.json"),A={kit_name:d,profile:I,created_at:new Date().toISOString(),created_by:"rapidkit-npm-fallback",runtime:r?"python":"node"};await promises.writeFile(F,JSON.stringify(A,null,2),"utf-8");let D=r?`# Python
2
2
  __pycache__/
3
3
  *.py[cod]
4
4
  *$py.class
@@ -0,0 +1,50 @@
1
+ import {e}from'./chunk-TYC54P7X.js';import {c as c$1,a as a$2,b as b$1}from'./chunk-NFUXULIF.js';import {b,f,d,a as a$4,k,g,i as i$1}from'./chunk-Z5LKRG57.js';import {a}from'./chunk-VM2TOHNX.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import c from'chalk';import {execa}from'execa';import a$1 from'fs-extra';import i from'path';import Ye from'inquirer';function Ze(e){return [...new Set(e.filter(s=>s&&s.trim().length>0))]}function et(){let e=k().map(t=>i.join(t,a$4()?"poetry.exe":"poetry")),s=a$4()?[i.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),i.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],r=a$4()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return Ze([...e,...s,...r])}function tt(e){let s=k().map(u=>({location:"Global (user-local)",path:i.join(u,a$4()?"rapidkit.exe":"rapidkit")})),r=[{location:"Global (pipx)",path:i.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:i.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:i.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],t=g(i.join(process.cwd(),".venv")),l=i$1(process.cwd()),o=[{location:"Workspace (.venv)",path:t},...l.map(u=>({location:"Workspace (launcher)",path:u}))],n=[...s,...r,...o],d=new Set;return n.filter(u=>d.has(u.path)?false:(d.add(u.path),true))}function st(e){let s=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((r,t)=>{let l=s.get(r.location)??Number.MAX_SAFE_INTEGER,o=s.get(t.location)??Number.MAX_SAFE_INTEGER;return l!==o?l-o:r.path.localeCompare(t.path)})}function Y(e){let s=0,r=e.issues.some(t=>t.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!r&&(s+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(s+=1),s}function ge(e){return e.filter(s=>Y(s)>0).length}function ke(e){return e.reduce((s,r)=>s+Y(r),0)}var nt="doctor-project-scan-v2",Ie="doctor-workspace-cache-v1",ot=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"});function ce(){return {...ot}}function le(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function He(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function Ne(e,s){try{if(!await a$1.pathExists(e))return null;let r=await a$1.readJSON(e);return c$1(r,s)?r:null}catch{return null}}function Me(e,s){if(!e?.system)return [];let r=[{id:"python",current:s.python},{id:"poetry",current:s.poetry},{id:"pipx",current:s.pipx},{id:"go",current:s.go},{id:"rapidkitCore",current:s.rapidkitCore}],t=[];for(let l of r){let o=e.system?.[l.id]?.status;!o||o===l.current.status||t.push({id:l.id,from:o,to:l.current.status});}return t}function it(e,s){let r=new Map;for(let p of s.projects)r.set(p.path||p.name,p.issues.length);if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let t=Array.isArray(e.projects)?e.projects:[],l=new Map;for(let p of t){let h=p.path||p.name;h&&l.set(h,He(p.issues));}let o=0,n=0,d=new Set,u=new Set,m=new Set([...Array.from(l.keys()),...Array.from(r.keys())]);for(let p of m){let h=l.get(p)??0,v=r.get(p)??0;v>h?(o+=v-h,d.add(p)):v<h&&(n+=h-v,u.add(p));}let f=le(e.healthScore),g=le(s.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:n,netIssueDelta:o-n,scoreDeltaPercent:f===null||g===null?null:g-f,systemStatusChanges:Me(e,{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore}),regressedProjects:Array.from(d).sort(),improvedProjects:Array.from(u).sort()}}function at(e,s){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let r=He(e.project?.issues),t=s.project.issues.length,l=Math.max(t-r,0),o=Math.max(r-t,0),n=le(e.healthScore),d=le(s.healthScore),u=s.project.path||s.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:l,resolvedIssueCount:o,netIssueDelta:l-o,scoreDeltaPercent:n===null||d===null?null:d-n,systemStatusChanges:Me(e,{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore}),regressedProjects:l>0?[u]:[],improvedProjects:o>0?[u]:[]}}function Ge(e){let s=e??[],r=0,t=0;for(let n of s){if(n.scope==="project-scoped"){r+=1;continue}(n.scope==="workspace-aggregate"||n.scope==="host-system")&&(t+=1);}let l=r>0&&t>0?1:0,o=l>0?"mixed":r>0?"scoped":t>0?"aggregated":"unknown";return {scopedCount:r,aggregatedCount:t,mixedCount:l,dominantScope:o}}function P(e,s){return a$4()?`cd "${e}"; ${s}`:`cd ${e} && ${s}`}function L(e){return a$4()?P(e,"Copy-Item .env.example .env"):P(e,"cp .env.example .env")}function rt(e){return e==="FastAPI"||e==="NestJS"||e==="Go/Fiber"||e==="Go/Gin"||e==="Spring Boot"||e==="Rust"||e==="Phoenix"?"first-class":e==="Django"||e==="Flask"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Elixir"||e==="Clojure"||e==="Scala"||e==="Kotlin"||e==="Deno"||e==="Bun"||e==="PHP"||e==="Laravel"||e==="Ruby"||e==="Ruby on Rails"||e==="ASP.NET"?"extended":"observed"}function ct(e){return e==="Next.js"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"?"frontend":e==="Unknown"||e==="Node.js"||e==="Python"?"generic":"backend"}function lt(e){return e==="NestJS"||e==="Next.js"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Bun"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Node.js"?"node":e==="FastAPI"||e==="Django"||e==="Flask"||e==="Python"?"python":e==="Go/Fiber"||e==="Go/Gin"?"go":e==="Spring Boot"?"java":e==="Rust"?"rust":e==="Elixir"||e==="Phoenix"?"elixir":e==="Clojure"?"clojure":e==="Deno"?"deno":e==="Laravel"||e==="PHP"?"php":e==="Ruby on Rails"||e==="Ruby"?"ruby":e==="ASP.NET"?"dotnet":"unknown"}function re(e,s,r){e.framework=s,e.frameworkConfidence=r,e.supportTier=rt(s),e.projectKind=ct(s),e.runtimeFamily=lt(s);}function dt(e){return e==="python"?"python":e==="node"||e==="bun"?"node":e==="go"?"go":e==="java"?"java":e==="rust"?"rust":e==="elixir"?"elixir":e==="clojure"?"clojure":e==="deno"?"deno":e==="php"?"php":e==="ruby"?"ruby":e==="dotnet"?"dotnet":"unknown"}function We(e){switch(e.key){case "fastapi":return "FastAPI";case "django":return "Django";case "flask":return "Flask";case "python":return "Python";case "nestjs":return "NestJS";case "express":return "Express";case "fastify":return "Fastify";case "koa":return "Koa";case "node":return "Node.js";case "gofiber":return "Go/Fiber";case "gogin":return "Go/Gin";case "echo":return "Echo";case "go":return "Go";case "springboot":return "Spring Boot";case "java":return "Java";case "laravel":return "Laravel";case "php":return "PHP";case "rails":return "Ruby on Rails";case "ruby":return "Ruby";case "dotnet":return "ASP.NET";case "phoenix":return "Phoenix";case "elixir":return "Elixir";case "clojure":return "Clojure";case "scala":return "Scala";case "kotlin":return "Kotlin";case "deno":return "Deno";case "bun":return "Bun";case "actix":case "axum":case "rocket":case "rust":return "Rust";case "sinatra":case "symfony":case "unknown":return "Unknown";default:return "Unknown"}}function ut(e){return e.key==="python"||e.key==="node"||e.key==="go"||e.key==="java"||e.key==="php"||e.key==="ruby"||e.key==="dotnet"||e.key==="rust"||e.key==="elixir"||e.key==="clojure"||e.key==="scala"||e.key==="kotlin"||e.key==="deno"||e.key==="bun"||e.key==="unknown"}function _(e,s){e.framework=We(s),e.frameworkKey=s.key,e.importStack=s.importStack,e.frameworkConfidence=s.confidence,e.supportTier=s.supportTier,e.projectKind=ut(s)?"generic":"backend",e.runtimeFamily=dt(s.runtime);}function pt(e){let s=e.dependencies,r=e.scripts??{},t=(e.kitName??"").toLowerCase(),l=n=>!!s[n],o=Object.values(r).filter(n=>typeof n=="string").join(" ").toLowerCase();return l("next")||o.includes("next ")?{framework:"Next.js",confidence:"high"}:l("nuxt")||o.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:l("@nestjs/core")||t.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:l("express")?{framework:"Express",confidence:"high"}:l("fastify")?{framework:"Fastify",confidence:"high"}:l("koa")?{framework:"Koa",confidence:"high"}:l("@angular/core")?{framework:"Angular",confidence:"high"}:l("@sveltejs/kit")||o.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:l("vue")?{framework:"Vue",confidence:"medium"}:l("react")&&l("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function mt(e$1){let s=e(e$1);return s.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:We(s),confidence:s.confidence}}async function Re(e){try{let s=await a$1.stat(e);return `${i.basename(e)}:${s.isDirectory()?"d":"f"}:${s.size}:${s.mtimeMs}`}catch{return `${i.basename(e)}:missing`}}async function ft(e){try{let s=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),r=new Set;await de(e)&&r.add(e);let t=async(l,o)=>{if(o<0)return;let n=await Be(l);for(let d of n){if(Ke(d,s))continue;let u=i.join(l,d);if(await de(u)){r.add(u);continue}o>0&&await t(u,o-1);}};return await t(e,1),r.size===0&&(await Pt(e,3,s)).forEach(o=>r.add(o)),Array.from(r).sort((l,o)=>l.localeCompare(o))}catch{return []}}async function gt(e,s){let r=[i.join(e,".rapidkit-workspace"),i.join(e,".rapidkit","workspace.json"),i.join(e,".rapidkit","policies.yml"),i.join(e,".rapidkit","toolchain.lock"),i.join(e,".rapidkit","cache-config.yml")],t=[".rapidkit/project.json",".rapidkit/context.json",".rapidkit/file-hashes.json","package.json","pyproject.toml","composer.json","Gemfile","Gemfile.lock","go.mod","go.sum","pom.xml","requirements.txt","Dockerfile","Makefile",".env",".env.example","src","modules","tests","test",".venv","node_modules"],l=await Promise.all(r.map(Re)),o=await Promise.all(s.map(async n=>{let d=await Promise.all(t.map(u=>Re(i.join(n,u))));return `${n}::${d.join("|")}`}));return [nt,...l,...o].join("||")}async function ht(e,s){try{if(!await a$1.pathExists(e))return null;let r=await a$1.readJSON(e);return !r||r.signature!==s||!Array.isArray(r.projects)||typeof r.schemaVersion=="string"&&r.schemaVersion!==Ie?null:r}catch{return null}}async function yt(e,s){try{await a$1.ensureDir(i.dirname(e)),await a$1.writeJSON(e,s,{spaces:2});}catch{}}async function kt(e,s,r){let t=i.join(e,".rapidkit","reports","doctor-last-run.json");try{return await a$1.ensureDir(i.dirname(t)),await a$1.writeJSON(t,{schemaVersion:a$2,evidenceType:"workspace",generatedAt:new Date().toISOString(),contract:ce(),workspacePath:e,workspaceName:s.workspaceName,projectScanCached:s.projectScanCached??false,projectScanSignature:s.projectScanSignature,cachePath:r,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore,versions:{core:s.coreVersion,npm:s.npmVersion}},projects:s.projects,summary:{totalProjects:s.projects.length,totalIssues:s.projects.reduce((l,o)=>l+o.issues.length,0),projectAdvisoryWarningProjects:ge(s.projects),projectAdvisoryWarnings:ke(s.projects),hasSystemErrors:[s.python,s.rapidkitCore].some(l=>l.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[]},{spaces:2}),t}catch{return}}async function we(){let[e,s,r,t,l]=await Promise.all([wt(),vt(),xt(),bt(),jt()]);return {python:e,poetry:s,pipx:r,go:t,rapidkitCore:l}}async function wt(){let e=d();for(let s of e)try{let{stdout:r}=await execa(s,["--version"],{timeout:3e3}),t=r.match(/Python (\d+\.\d+\.\d+)/);if(t){let l=t[1],[o,n]=l.split(".").map(Number);return o<3||o===3&&n<10?{status:"warn",message:`Python ${l} (requires 3.10+)`,details:`${s} found but version is below minimum requirement`}:{status:"ok",message:`Python ${l}`,details:`Using ${s}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function vt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),s=e.match(/Poetry .*version ([\d.]+)/);return s?{status:"ok",message:`Poetry ${s[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=d().map(s=>({cmd:s,args:s==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let s of e)try{let{stdout:r}=await execa(s.cmd,s.args,{timeout:3e3,shell:b()}),t=r.match(/Poetry .*version ([\d.]+)/)||r.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available via ${s.cmd} ${s.args.join(" ")}`}}catch{continue}for(let s of et())try{if(!await a$1.pathExists(s))continue;let{stdout:r}=await execa(s,["--version"],{timeout:3e3,shell:b()}),t=r.match(/Poetry .*version ([\d.]+)/)||r.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available at ${s}`}}catch{continue}return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function xt(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{let e=d();for(let s of e)try{let r=s==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:t}=await execa(s,r,{timeout:3e3,shell:b()});return {status:"ok",message:`pipx ${t.trim()}`,details:`Available via ${s} ${r.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function bt(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),s=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return s?{status:"ok",message:`Go ${s[1]}`,details:"Available for Go/Fiber and Go/Gin projects"}:{status:"ok",message:"Go (version unknown)",details:"go found in PATH"}}catch{return {status:"warn",message:"Go not installed",details:"Optional: Required only for gofiber.standard / gogin.standard projects \u2014 https://go.dev/dl/"}}}async function jt(){let e=process.env.HOME||process.env.USERPROFILE||"",s=[],r=tt(e);for(let{location:l,path:o}of r)try{if(await a$1.pathExists(o)){let{stdout:n,exitCode:d}=await execa(o,["--version"],{timeout:3e3,reject:false});if(d===0&&(n.includes("RapidKit Version")||n.includes("RapidKit"))){let u=n.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);u&&s.push({location:l,path:o,version:u[1]});}}}catch{continue}if(s.length>0){let l=s.filter(n=>n.location!=="Workspace (launcher)");if(l.length>0){let n=st(l),d=n[0].version,u=n.some(g=>g.location==="Workspace (.venv)"),m=n.some(g=>g.location.startsWith("Global (")),f=!u&&m?"Workspace (.venv): not installed (optional). For best project-level performance and isolation, run npx rapidkit workspace run init inside this workspace.":void 0;return {status:"ok",message:`RapidKit Core ${d}`,details:f,paths:n.map(g=>({location:g.location,path:g.path,version:g.version}))}}return {status:"ok",message:`RapidKit Core ${s[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:l,exitCode:o}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(o===0&&(l.includes("RapidKit Version")||l.includes("RapidKit"))){let n=l.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(n)return {status:"ok",message:`RapidKit Core ${n[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:l,exitCode:o}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(o===0&&(l.includes("RapidKit Version")||l.includes("RapidKit"))){let n=l.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(n)return {status:"ok",message:`RapidKit Core ${n[1]}`,details:"Available via Poetry"}}}catch{}let t=d();for(let l of t)try{let{stdout:o,exitCode:n}=await execa(l,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(n===0&&o&&!o.includes("Traceback")&&!o.includes("ModuleNotFoundError")){let d=o.trim();if(d)return {status:"ok",message:`RapidKit Core ${d}`,details:`Available in ${l} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function D(e,s){let r=i.join(e,"Dockerfile");s.hasDocker=await a$1.pathExists(r);let t=i.join(e,"tests"),l=i.join(e,"test"),o=i.join(e,"src","test"),n=await a$1.pathExists(t)||await a$1.pathExists(l)||await a$1.pathExists(o),d=false;if(s.framework==="Go/Fiber"||s.framework==="Go/Gin")try{let u=[{dir:e,depth:0}],m=4,f=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;u.length>0&&!d;){let g=u.shift();if(!g)break;let p=[];try{p=await a$1.readdir(g.dir);}catch{continue}for(let h of p){let v=i.join(g.dir,h),y;try{y=await a$1.stat(v);}catch{continue}if(y.isFile()&&h.endsWith("_test.go")){d=true;break}y.isDirectory()&&g.depth<m&&!f.has(h)&&!h.startsWith(".")&&u.push({dir:v,depth:g.depth+1});}}}catch{}if(s.hasTests=n||d,s.runtimeFamily==="node"){let u=i.join(e,".eslintrc.js"),m=i.join(e,".eslintrc.json");s.hasCodeQuality=await a$1.pathExists(u)||await a$1.pathExists(m);}else if(s.framework==="Go/Fiber"||s.framework==="Go/Gin"){let u=i.join(e,".golangci.yml"),m=i.join(e,".golangci.yaml"),f=i.join(e,"Makefile"),g=await a$1.pathExists(f)&&(await a$1.readFile(f,"utf8")).includes("golangci-lint");s.hasCodeQuality=await a$1.pathExists(u)||await a$1.pathExists(m)||g;}else if(s.runtimeFamily==="python"){let u=i.join(e,"ruff.toml"),m=i.join(e,"pyproject.toml");if(await a$1.pathExists(m))try{let f=await a$1.readFile(m,"utf8");s.hasCodeQuality=f.includes("[tool.ruff]")||await a$1.pathExists(u);}catch{s.hasCodeQuality=await a$1.pathExists(u);}}else if(s.framework==="Spring Boot"){let u=i.join(e,"pom.xml");if(await a$1.pathExists(u))try{let m=await a$1.readFile(u,"utf8");s.hasCodeQuality=m.includes("spotless")||m.includes("checkstyle")||m.includes("pmd")||m.includes("maven-enforcer-plugin");}catch{s.hasCodeQuality=false;}}try{if(s.runtimeFamily==="node"){let{stdout:u}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(u)try{let f=JSON.parse(u).metadata?.vulnerabilities;f&&(s.vulnerabilities=(f.high||0)+(f.critical||0)+(f.moderate||0));}catch{}}else if(s.runtimeFamily==="python"){let u=i.join(e,".venv"),m=f(u);if(await a$1.pathExists(m))try{let{stdout:f}=await execa(m,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(f){JSON.parse(f);s.vulnerabilities=0;}}catch{}}}catch{}}function A(e,s){e.probes||(e.probes=[]),e.probes.push(s);}async function Ct(e,s){let r=s.runtimeFamily||"unknown";if(s.projectKind==="backend"||s.projectKind==="generic"){if(r==="node"){let l=await a$1.pathExists(i.join(e,"package-lock.json"))||await a$1.pathExists(i.join(e,"pnpm-lock.yaml"))||await a$1.pathExists(i.join(e,"yarn.lock"));A(s,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:l?"pass":"warn",severity:"warn",scope:"project-scoped",reason:l?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:l?void 0:"Commit a lockfile for deterministic installs and CI parity."});let o=await a$1.pathExists(i.join(e,"src/main.ts"))||await a$1.pathExists(i.join(e,"src/main.js"))||await a$1.pathExists(i.join(e,"src/server.ts"))||await a$1.pathExists(i.join(e,"src/server.js"));A(s,{id:"adapter-node-boot-entrypoint",label:"Node adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Boot entrypoint markers detected for service startup path.":"No canonical Node boot entrypoint markers detected.",recommendation:o?void 0:"Define and document service bootstrap entrypoint (main/server)."});return}if(r==="python"){let l=await a$1.pathExists(i.join(e,"poetry.lock"))||await a$1.pathExists(i.join(e,"requirements.txt"))||await a$1.pathExists(i.join(e,"uv.lock"));A(s,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:l?"pass":"warn",severity:"warn",scope:"project-scoped",reason:l?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:l?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let o=await a$1.pathExists(i.join(e,"app/main.py"))||await a$1.pathExists(i.join(e,"main.py"))||await a$1.pathExists(i.join(e,"manage.py"));A(s,{id:"adapter-python-boot-entrypoint",label:"Python adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Python application entrypoint markers detected.":"No Python application entrypoint markers detected.",recommendation:o?void 0:"Expose explicit app/main entrypoint for deterministic boot probes."});return}if(r==="java"){let l=await a$1.pathExists(i.join(e,"mvnw"))||await a$1.pathExists(i.join(e,"gradlew"));A(s,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:l?"pass":"warn",severity:"warn",scope:"project-scoped",reason:l?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:l?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(r==="go"){let l=await a$1.pathExists(i.join(e,"go.sum"));A(s,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:l?"pass":"warn",severity:"warn",scope:"project-scoped",reason:l?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:l?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function Et(e,s){let r=[i.join(e,".rapidkit","doctor.adapters.json"),i.join(e,"doctor.adapters.json")];for(let t of r)if(await a$1.pathExists(t))try{let l=await a$1.readJSON(t),o=Array.isArray(l?.checks)?l.checks:[];for(let n=0;n<o.length;n+=1){let d=o[n]||{},u=Array.isArray(d.runtimes)?d.runtimes:[];if(u.length>0&&!u.includes(s.runtimeFamily||"unknown"))continue;let m=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`adapter-check-${n+1}`,f=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():m,g=d.severity||"warn",p=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],h=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],v=p.length===0;for(let T of p)if(await a$1.pathExists(i.join(e,T))){v=true;break}let y=true;for(let T of h)if(!await a$1.pathExists(i.join(e,T))){y=false;break}let x=v&&y;A(s,{id:m,label:f,status:x?"pass":g==="error"?"fail":"warn",severity:g,scope:"project-scoped",reason:x?d.passReason||"Custom adapter contract satisfied.":d.failReason||`Custom adapter check failed from ${i.basename(t)}.`,recommendation:d.recommendation});}}catch{A(s,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${i.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function M(e,s){if(!(s.projectKind==="backend"||s.projectKind==="generic"))return;let t=i.join(e,".env"),l=i.join(e,".env.example"),o=await a$1.pathExists(t)||await a$1.pathExists(l)||await a$1.pathExists(i.join(e,"config"));A(s,{id:"config-surface",label:"Configuration contract surface",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Configuration artifacts detected (.env/.env.example/config).":"No explicit configuration contract artifacts detected.",recommendation:o?void 0:"Add .env.example or explicit config contract documentation for deterministic setup."});let n={python:["alembic.ini","migrations","versions"],node:["prisma/schema.prisma","migrations","typeorm.config.ts","typeorm.config.js"],go:["migrations","db/migrations"],java:["src/main/resources/db/migration","src/main/resources/liquibase"],rust:["migrations","sqlx-data.json"],elixir:["priv/repo/migrations"],clojure:["resources/migrations","migrations"],deno:["migrations"],php:["database/migrations","migrations"],ruby:["db/migrate"],dotnet:["Migrations","Data/Migrations"],unknown:["migrations"]},d=s.runtimeFamily||"unknown",u=n[d]||n.unknown,m=false;for(let p of u)if(await a$1.pathExists(i.join(e,p))){m=true;break}A(s,{id:"migration-surface",label:"Migration/readiness surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:m?void 0:"Add migration tooling baseline (migrations dir or runtime-native migration config)."});let f=["src/health","src/healthcheck","src/main/resources/application.yml","src/main/resources/application.properties","app/health.py","routes/health.ts","routes/health.js"],g=false;for(let p of f)if(await a$1.pathExists(i.join(e,p))){g=true;break}A(s,{id:"runtime-health-surface",label:"Runtime health probe surface",status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:g?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await Ct(e,s);}async function G(e,s){let r=[i.join(e,".rapidkit","doctor.probes.json"),i.join(e,"doctor.probes.json")];for(let t of r)if(await a$1.pathExists(t))try{let l=await a$1.readJSON(t),o=Array.isArray(l?.probes)?l.probes:[];for(let n=0;n<o.length;n+=1){let d=o[n]||{},u=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`custom-probe-${n+1}`,m=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():u,f=d.severity||"warn",g=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],p=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],h=g.length===0;for(let x of g)if(await a$1.pathExists(i.join(e,x))){h=true;break}let v=true;for(let x of p)if(!await a$1.pathExists(i.join(e,x))){v=false;break}let y=h&&v;A(s,{id:u,label:m,status:y?"pass":f==="error"?"fail":"warn",severity:f,scope:"project-scoped",reason:y?"Custom probe contract satisfied.":`Custom probe failed from ${i.basename(t)}.`,recommendation:d.recommendation});}}catch{A(s,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${i.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await Et(e,s);}async function ve(e$1,s={}){let t={name:i.basename(e$1),path:e$1,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},l=s.allowNonRapidkit===true,o=i.join(e$1,".rapidkit");if(!await a$1.pathExists(o)){if(!l)return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;t.issues.push("Not a RapidKit-managed project (running generic backend diagnostics)");}try{let k=i.join(e$1,"registry.json");if(await a$1.pathExists(k)){let w=await a$1.readJson(k);w.installed_modules&&(t.stats={modules:w.installed_modules.length});}}catch{}let n=null;try{let k=i.join(o,"project.json");if(await a$1.pathExists(k)){n=await a$1.readJson(k);let w=n?.kit_name||n?.kit;w&&(t.kit=w);}}catch{}try{let k=i.join(e$1,".git");if(await a$1.pathExists(k)){let{stdout:w}=await execa("git",["log","-1","--format=%cr"],{cwd:e$1,reject:false});w&&(t.lastModified=w.trim());}else {let w=await a$1.stat(e$1),I=Date.now()-w.mtime.getTime(),H=Math.floor(I/(1e3*60*60*24));t.lastModified=H===0?"today":`${H} day${H>1?"s":""} ago`;}}catch{}let d=i.join(e$1,"package.json"),u=i.join(e$1,"pyproject.toml"),m=i.join(e$1,"requirements.txt"),f$1=i.join(e$1,"go.mod"),g=i.join(e$1,"pom.xml"),p=i.join(e$1,"build.sbt"),h=i.join(e$1,"Cargo.toml"),v=i.join(e$1,"mix.exs"),y=i.join(e$1,"deps.edn"),x=i.join(e$1,"project.clj"),T=i.join(e$1,"deno.json"),W=i.join(e$1,"deno.jsonc"),J=i.join(e$1,"bun.lockb"),q=i.join(e$1,"bun.lock"),O=i.join(e$1,"composer.json"),se=i.join(e$1,"Gemfile"),U=await a$1.pathExists(d),B=await a$1.pathExists(u)||await a$1.pathExists(m),R=await a$1.pathExists(O),ee=await a$1.pathExists(se),ne=await a$1.pathExists(h),Je=await a$1.pathExists(v),qe=await a$1.pathExists(y)||await a$1.pathExists(x),Ue=await a$1.pathExists(p),ze=await a$1.pathExists(T)||await a$1.pathExists(W),ue=false;try{ue=(await a$1.readdir(e$1)).some(w=>w.endsWith(".csproj")||w.endsWith(".sln"));}catch{ue=false;}let Qe=await a$1.pathExists(f$1)||n?.runtime==="go"||typeof n?.kit_name=="string"&&(n.kit_name.startsWith("gofiber")||n.kit_name.startsWith("gogin")),xe=U&&(await a$1.pathExists(J)||await a$1.pathExists(q)||typeof n?.packageManager=="string"&&(n?.packageManager).toLowerCase().startsWith("bun@"));if(Qe){_(t,e(e$1,n??null)),t.isGoProject=true,t.venvActive=true,t.coreInstalled=false;try{await execa("go",["version"],{timeout:3e3});}catch{t.issues.push("Go toolchain not found \u2014 install from https://go.dev/dl/"),t.fixCommands?.push("https://go.dev/dl/");}let k=i.join(e$1,"go.sum");return await a$1.pathExists(k)?t.depsInstalled=true:(t.depsInstalled=false,t.issues.push("Go dependencies not downloaded (go.sum missing)"),t.fixCommands?.push(P(e$1,"go mod tidy"))),await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(await a$1.pathExists(g)||n?.runtime==="java"||typeof n?.kit_name=="string"&&n.kit_name.startsWith("springboot")){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=await a$1.pathExists(g),w=await a$1.pathExists(i.join(e$1,"build.gradle"))||await a$1.pathExists(i.join(e$1,"build.gradle.kts")),j=await a$1.pathExists(i.join(e$1,"mvnw"))||await a$1.pathExists(i.join(e$1,"mvnw.cmd")),I=await a$1.pathExists(i.join(e$1,"gradlew"))||await a$1.pathExists(i.join(e$1,"gradlew.bat"));try{await execa("java",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Java runtime not found \u2014 install JDK 21+ and ensure java is on PATH"),t.fixCommands?.push("https://adoptium.net/");}if(k){if(!j)try{await execa("mvn",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Maven not found \u2014 install Maven 3.9+ or add Maven Wrapper"),t.fixCommands?.push("https://maven.apache.org/install.html");}}else if(w&&!I)try{await execa("gradle",["--version"],{timeout:3e3,reject:false});}catch{t.issues.push("Gradle not found \u2014 install Gradle 8+ or add Gradle Wrapper"),t.fixCommands?.push("https://gradle.org/install/");}let H=i.join(e$1,"target"),S=i.join(e$1,"build","libs"),$=i.join(e$1,".rapidkit","cache","java","m2"),C=i.join(e$1,".rapidkit","cache","java","gradle");t.depsInstalled=await a$1.pathExists(H)||await a$1.pathExists(S)||await a$1.pathExists($)||await a$1.pathExists(C),t.depsInstalled||(t.issues.push("Java dependencies are not warmed or built yet"),t.fixCommands?.push(P(e$1,"rapidkit init")));let N=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(N),!t.hasEnvFile){let z=i.join(e$1,".env.example");await a$1.pathExists(z)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}let V=i.join(e$1,"src","main","resources","application.yml");if(await a$1.pathExists(V))try{let z=await a$1.readFile(V,"utf-8");/include:\s*[^\n]*health/i.test(z)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(z)||(t.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),t.fixCommands?.push(P(e$1,"Ensure management.endpoints.web.exposure.include contains health in src/main/resources/application.yml")));}catch{t.issues.push("Unable to read application.yml for Spring Actuator health checks");}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(ne){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"Cargo.lock"),w=i.join(e$1,"target");t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w),t.depsInstalled||(t.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),t.fixCommands?.push(P(e$1,"cargo fetch")));let j=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(j),!t.hasEnvFile){let I=i.join(e$1,".env.example");await a$1.pathExists(I)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(Je){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"mix.lock"),w=i.join(e$1,"deps");t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w),t.depsInstalled||(t.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),t.fixCommands?.push(P(e$1,"mix deps.get")));let j=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(j),!t.hasEnvFile){let I=i.join(e$1,".env.example");await a$1.pathExists(I)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(qe){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,".cpcache"),w=i.join(e$1,"target"),j=await a$1.pathExists(y)||await a$1.pathExists(x);return t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w)||j,t.depsInstalled||(t.issues.push("Clojure dependency cache not initialized"),t.fixCommands?.push(P(e$1,"clojure -P"))),await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(Ue){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"target");t.depsInstalled=await a$1.pathExists(k),t.depsInstalled||(t.issues.push("Scala build artifacts missing (run dependency/build warmup)"),t.fixCommands?.push(P(e$1,"sbt compile")));let w=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(w),!t.hasEnvFile){let j=i.join(e$1,".env.example");await a$1.pathExists(j)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(ze){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false,t.depsInstalled=true;let k=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(k),!t.hasEnvFile){let w=i.join(e$1,".env.example");await a$1.pathExists(w)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(U){let k=null;try{k=await a$1.readJson(d);}catch{k=null;}let w={...k?.dependencies??{},...k?.devDependencies??{}},j=k?.scripts??{},I=typeof n?.kit_name=="string"?n.kit_name.toLowerCase():typeof n?.kit=="string"?n.kit.toLowerCase():"",H=pt({dependencies:w,scripts:j,kitName:I});if(xe)re(t,"Bun","high");else {let C=e(e$1,n??null);C.key==="nestjs"||C.key==="express"||C.key==="fastify"||C.key==="koa"?_(t,C):re(t,H.framework,H.confidence);}t.venvActive=true;let S=i.join(e$1,"node_modules");if(await a$1.pathExists(S))try{let N=(await a$1.readdir(S)).filter(V=>!V.startsWith(".")&&!V.startsWith("_"));t.depsInstalled=N.length>0;}catch{t.depsInstalled=false;}if(t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(P(e$1,xe?"bun install":"rapidkit init"))),t.coreInstalled=false,t.projectKind==="frontend"){let C=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all(C.map(V=>a$1.pathExists(i.join(e$1,V))))).some(Boolean))t.hasEnvFile=true;else {let V=i.join(e$1,".env.example");await a$1.pathExists(V)&&(t.hasEnvFile=false,t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}}else {let C=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(C),!t.hasEnvFile){let N=i.join(e$1,".env.example");await a$1.pathExists(N)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}}let $=i.join(e$1,"src");if(t.modulesHealthy=true,t.missingModules=[],await a$1.pathExists($))try{let C=await a$1.readdir($);t.modulesHealthy=C.length>0;}catch{t.modulesHealthy=false;}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(B){let k=await mt(e$1);re(t,k.framework,k.confidence);let w=i.join(e$1,".venv");if(await a$1.pathExists(w)){t.venvActive=true;let S=f(w);if(await a$1.pathExists(S)){try{let{stdout:N}=await execa(S,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=N.trim();}catch{t.coreInstalled=false;}let $="fastapi";t.framework==="Django"?$="django":t.framework==="Flask"?$="flask":t.framework==="Python"&&($="");let C=true;if($)try{await execa(S,["-c",`import ${$}`],{timeout:2e3}),t.depsInstalled=true,C=false;}catch{C=true;}if(C)try{let N=i.join(w,"lib");if(await a$1.pathExists(N)){let z=(await a$1.readdir(N)).find(oe=>oe.startsWith("python"));if(z){let oe=i.join(N,z,"site-packages");if(await a$1.pathExists(oe)){let Xe=(await a$1.readdir(oe)).filter(pe=>!pe.startsWith("_")&&!pe.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(pe));t.depsInstalled=Xe.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(P(e$1,"rapidkit init")));}catch{t.issues.push("Could not verify dependency installation");}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push(P(e$1,"rapidkit init"));let j=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(j),!t.hasEnvFile){let S=i.join(e$1,".env.example");await a$1.pathExists(S)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}let I=i.join(e$1,"src"),H=i.join(e$1,"modules");if(t.modulesHealthy=true,t.missingModules=[],await a$1.pathExists(I)){let S=i.join(I,"__init__.py");await a$1.pathExists(S)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await a$1.pathExists(H))try{let S=await Be(H);for(let $ of S){let C=i.join(H,$,"__init__.py");await a$1.pathExists(C)||(t.modulesHealthy=false,t.missingModules.push(`modules/${$}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(R){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"vendor");t.depsInstalled=await a$1.pathExists(k),t.depsInstalled||(t.issues.push("PHP dependencies not installed (vendor missing)"),t.fixCommands?.push(P(e$1,"composer install")));let w=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(w),!t.hasEnvFile){let j=i.join(e$1,".env.example");await a$1.pathExists(j)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(ee){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=await a$1.pathExists(i.join(e$1,"Gemfile.lock")),w=await a$1.pathExists(i.join(e$1,"vendor","bundle"));t.depsInstalled=k||w,t.depsInstalled||(t.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),t.fixCommands?.push(P(e$1,"bundle install")));let j=i.join(e$1,".env");return t.hasEnvFile=await a$1.pathExists(j),await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(ue){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"obj"),w=i.join(e$1,"packages.lock.json");t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w),t.depsInstalled||(t.issues.push(".NET restore/build artifacts not found"),t.fixCommands?.push(P(e$1,"dotnet restore")));let j=i.join(e$1,".env");return t.hasEnvFile=await a$1.pathExists(j),await D(e$1,t),t}return re(t,"Unknown","low"),t.issues.push("Unknown project type (no recognized runtime marker files)"),await D(e$1,t),await M(e$1,t),await G(e$1,t),t}async function Be(e){try{return (await a$1.readdir(e,{withFileTypes:true})).filter(r=>r.isDirectory()).map(r=>r.name)}catch{try{let s=await a$1.readdir(e),r=[];for(let t of s)try{(await a$1.stat(i.join(e,t))).isDirectory()&&r.push(t);}catch{continue}return r}catch{return []}}}async function de(e){let s=i.join(e,".rapidkit");if(!await a$1.pathExists(s))return false;let r=["project.json","context.json","file-hashes.json"];for(let t of r)if(await a$1.pathExists(i.join(s,t)))return true;return false}function Ke(e,s){if(s.has(e))return true;let r=e.toLowerCase();return !!(r==="dist"||r.startsWith("dist-")||r.startsWith("dist_")||r==="build"||r.startsWith("build-")||r.startsWith("build_"))}async function Pt(e,s,r){let t=new Set,l=[{dir:e,depth:0}];for(;l.length>0;){let o=l.shift();if(!o)break;try{let n=await a$1.readdir(o.dir);for(let d of n){if(Ke(d,r))continue;let u=i.join(o.dir,d),m;try{m=await a$1.stat(u);}catch{continue}if(m.isDirectory()){if(await de(u)){t.add(u);continue}o.depth<s&&l.push({dir:u,depth:o.depth+1});}}}catch{continue}}return Array.from(t)}async function ae(e){let s=i.resolve(e),r=i.parse(s).root;for(;;){if(await $t(s))return s;if(s===r)break;s=i.dirname(s);}return null}async function St(e){let s=i.resolve(e),r=await ae(s),t=r??i.parse(s).root;for(;;){if(await de(s)||await Rt(s)&&(!r||s!==r))return s;if(s===t)break;s=i.dirname(s);}return null}function $e(e){let s=i.resolve(e);return process.platform==="darwin"?s.replace(/^\/private(?=\/var\/)/,""):s}async function Rt(e){let s=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.sbt","Cargo.toml","mix.exs","deps.edn","project.clj","deno.json","deno.jsonc","composer.json","Gemfile"];for(let r of s)if(await a$1.pathExists(i.join(e,r)))return true;return false}async function $t(e){let s=[i.join(e,".rapidkit-workspace"),i.join(e,".rapidkit","workspace-marker.json"),i.join(e,".rapidkit","config.json")];return Promise.all(s.map(r=>a$1.pathExists(r))).then(r=>r.some(Boolean))}function _e(e,s){let r=0,t=0,l=0;return e.forEach(n=>{n.status==="ok"?r++:n.status==="warn"?t++:n.status==="error"&&l++;}),s.forEach(n=>{let d=Y(n),u=n.isGoProject?n.issues.length===0&&n.depsInstalled:n.issues.length===0&&n.venvActive&&n.depsInstalled;if(n.issues.length>0||d>0||!u){t++;return}r++;}),{total:r+t+l,passed:r,warnings:t,errors:l}}function Te(e,s,r={}){let t=[];for(let o of e)t.push({id:o.id,label:o.label,status:o.result.status,scope:"host-system",policyRuleId:"system-status-derived",reason:o.result.details||o.result.message});let l=[...s].sort((o,n)=>{let d=`${o.path||""}|${o.name||""}`.toLowerCase(),u=`${n.path||""}|${n.name||""}`.toLowerCase();return d.localeCompare(u)});for(let o of l){let n=o.issues.length>0,d=Y(o),u=n||d>0?"warn":"ok",m=n?`${o.issues.length} blocking issue(s)`:d>0?`${d} advisory warning(s)`:"Project checks passed";t.push({id:`project:${o.name}`,label:`Project ${o.name}`,status:u,scope:"project-scoped",policyRuleId:n?"project-blocking-issues":d>0?"project-advisory-warnings":"project-checks-passed",reason:m});}if(r.includeWorkspaceAggregateRules){let o=s.reduce((u,m)=>u+m.issues.length,0),n=ke(s),d=e.filter(u=>u.result.status==="error").length;t.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:s.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:s.length>0?`${s.length} project(s) discovered for workspace analysis.`:"No projects discovered for workspace analysis."}),t.push({id:"workspace:system-error-gate",label:"Workspace system error gate",status:d>0?"error":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-system-error-gate",reason:d>0?`${d} system requirement gate(s) failed.`:"All system requirement gates passed."}),t.push({id:"workspace:blocking-issues-gate",label:"Workspace blocking issues gate",status:o>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-blocking-issues-gate",reason:o>0?`${o} blocking project issue(s) detected.`:"No blocking project issues detected."}),t.push({id:"workspace:advisory-warnings-gate",label:"Workspace advisory warnings gate",status:n>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:n>0?`${n} advisory warning(s) detected.`:"No advisory warnings detected."});}return t}async function Fe(e,s=true){let r=i.basename(e);try{let p=i.join(e,".rapidkit-workspace");await a$1.pathExists(p)&&(r=(await a$1.readJSON(p)).name||r);}catch{try{let p=i.join(e,".rapidkit","config.json");r=(await a$1.readJSON(p)).workspace_name||r;}catch{}}let[t,l]=await Promise.all([we(),ft(e)]),o={workspacePath:e,workspaceName:r,python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,projects:[]};a.debug(`Workspace scan found ${l.length} project(s)`);let n=await gt(e,l),d=i.join(e,".rapidkit","reports","doctor-workspace-cache.json"),u=s?await ht(d,n):null;if(u)o.projects=u.projects,o.projectScanCached=true,a.debug(`Workspace project health cache hit: ${d}`);else try{let p=await Promise.all(l.map(h=>ve(h)));o.projects=p,o.projectScanCached=false,await yt(d,{schemaVersion:Ie,signature:n,generatedAt:new Date().toISOString(),projects:p}),a.debug(`Workspace project health cache refreshed: ${d}`);}catch(p){a.debug(`Failed to scan workspace projects: ${p}`);}o.projectScanSignature=n,o.projectScanCachePath=d;let m=[o.python,o.poetry,o.pipx,o.go,o.rapidkitCore];if(o.healthScore=_e(m,o.projects),o.scoreBreakdown=Te([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],o.projects,{includeWorkspaceAggregateRules:true}),o.scopeProvenance=Ge(o.scoreBreakdown),o.rapidkitCore.status==="ok"){let p=o.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);p&&(o.coreVersion=p[1]);}let f=i.join(e,".rapidkit","reports","doctor-last-run.json"),g=await Ne(f,"workspace");return o.driftDelta=it(g,o),o.evidencePath=await kt(e,o,u?d:null),o}async function Ft(e,s){let r=e||s.projectPath,t=i.join(r,".rapidkit","reports","doctor-project-last-run.json");try{return await a$1.ensureDir(i.dirname(t)),await a$1.writeJSON(t,{schemaVersion:b$1,evidenceType:"project",generatedAt:new Date().toISOString(),contract:ce(),workspacePath:e||null,projectPath:s.projectPath,projectName:s.projectName,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore},project:s.project,driftDelta:s.driftDelta,summary:{scopeProvenance:s.scopeProvenance},scoreBreakdown:s.scoreBreakdown??[]},{spaces:2}),t}catch{return}}async function Dt(e){let s=await ae(e),r=await we(),t=await ve(e,{allowNonRapidkit:true}),l=_e([r.python,r.poetry,r.pipx,r.go,r.rapidkitCore],[t]),o={workspacePath:s||void 0,projectPath:e,projectName:i.basename(e),python:r.python,poetry:r.poetry,pipx:r.pipx,go:r.go,rapidkitCore:r.rapidkitCore,project:t,healthScore:l};o.scoreBreakdown=Te([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],[o.project]),o.scopeProvenance=Ge(o.scoreBreakdown);let n=s||e,d=i.join(n,".rapidkit","reports","doctor-project-last-run.json"),u=await Ne(d,"project");return o.driftDelta=at(u,o),o.evidencePath=await Ft(s||void 0,o),o}function E(e,s){let r=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",t=e.status==="ok"?c.green:e.status==="warn"?c.yellow:c.red;console.log(`${r} ${c.bold(s)}: ${t(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(l=>{let o=l.version?c.cyan(` -> ${l.version}`):"";console.log(` ${c.cyan("\u2022")} ${c.gray(l.location)}: ${c.dim(l.path)}${o}`);}),e.details&&console.log(` ${c.gray(e.details)}`);}function De(e){let s=e.issues.length>0,r=s?"\u26A0\uFE0F":"\u2705",t=s?c.yellow:c.green;if(console.log(`
2
+ ${r} ${c.bold("Project")}: ${t(e.name)}`),e.framework){let n=e.framework==="FastAPI"||e.framework==="Django"||e.framework==="Flask"?"\u{1F40D}":e.framework==="NestJS"?"\u{1F985}":e.framework==="Next.js"||e.framework==="Nuxt"?"\u25B2":e.framework==="React"?"\u269B\uFE0F":e.framework==="Vue"?"\u{1F7E2}":e.framework==="Angular"?"\u{1F170}\uFE0F":e.framework==="SvelteKit"?"\u{1F9E1}":e.framework==="Spring Boot"?"\u2615":e.framework==="Rust"?"\u{1F980}":e.framework==="Elixir"||e.framework==="Phoenix"?"\u{1F9EA}":e.framework==="Clojure"?"\u2699\uFE0F":e.framework==="Scala"?"\u{1F53A}":e.framework==="Kotlin"?"\u{1F7E3}":e.framework==="Deno"?"\u{1F995}":e.framework==="Bun"?"\u{1F956}":e.framework==="Go/Fiber"||e.framework==="Go/Gin"?"\u{1F439}":e.framework==="Laravel"||e.framework==="PHP"?"\u{1F418}":e.framework==="Ruby on Rails"||e.framework==="Ruby"?"\u{1F48E}":e.framework==="ASP.NET"?"\u{1F537}":"\u{1F4E6}";console.log(` ${n} Framework: ${c.cyan(e.framework)}${e.kit?c.gray(` (${e.kit})`):""}`);let d=[];e.runtimeFamily&&d.push(`runtime: ${e.runtimeFamily}`),e.projectKind&&d.push(`kind: ${e.projectKind}`),e.supportTier&&d.push(`support: ${e.supportTier}`),e.frameworkConfidence&&d.push(`confidence: ${e.frameworkConfidence}`),d.length>0&&console.log(` ${c.dim("\u21B3")} ${c.gray(d.join(" \u2022 "))}`);}if(console.log(` ${c.gray(`Path: ${e.path}`)}`),e.runtimeFamily==="python"&&(e.venvActive?console.log(` \u2705 Virtual environment: ${c.green("Active")}`):console.log(` \u274C Virtual environment: ${c.red("Not found")}`),e.coreInstalled?console.log(` ${c.dim("\u2139")} RapidKit Core: ${c.gray(e.coreVersion||"In venv")} ${c.dim("(optional)")}`):console.log(` ${c.dim("\u2139")} RapidKit Core: ${c.gray("Using global installation")} ${c.dim("(recommended)")}`)),e.depsInstalled?console.log(` \u2705 Dependencies: ${c.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${c.yellow("Not installed")}`),e.hasEnvFile!==void 0&&(e.hasEnvFile?console.log(` \u2705 Environment: ${c.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${c.yellow(".env missing")}`)),e.modulesHealthy!==void 0&&(e.modulesHealthy?console.log(` \u2705 Modules: ${c.green("Healthy")}`):e.missingModules&&e.missingModules.length>0&&console.log(` \u26A0\uFE0F Modules: ${c.yellow(`Missing ${e.missingModules.length} init file(s)`)}`)),e.stats){let n=[];e.stats.modules!==void 0&&n.push(`${e.stats.modules} module${e.stats.modules!==1?"s":""}`),n.length>0&&console.log(` \u{1F4CA} Stats: ${c.cyan(n.join(" \u2022 "))}`);}e.lastModified&&console.log(` \u{1F552} Last Modified: ${c.gray(e.lastModified)}`);let o=[];if(e.hasTests!==void 0&&o.push(e.hasTests?"\u2705 Tests":c.dim("\u2298 No tests")),e.hasDocker!==void 0&&o.push(e.hasDocker?"\u2705 Docker":c.dim("\u2298 No Docker")),e.hasCodeQuality!==void 0){let n=e.runtimeFamily==="node"?"ESLint":e.runtimeFamily==="rust"?"clippy":e.runtimeFamily==="elixir"?"Credo":e.runtimeFamily==="clojure"?"clj-kondo":e.runtimeFamily==="deno"?"deno lint":e.framework==="Spring Boot"?"Static analysis":e.framework==="Go/Fiber"||e.framework==="Go/Gin"?"golangci-lint":e.runtimeFamily==="python"?"Ruff":"Lint";o.push(e.hasCodeQuality?`\u2705 ${n}`:c.dim(`\u2298 No ${n}`));}if(o.length>0&&console.log(` ${o.join(" \u2022 ")}`),e.vulnerabilities!==void 0&&e.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${c.yellow(`${e.vulnerabilities} vulnerability(ies) found`)}`),e.issues.length>0&&(console.log(` ${c.bold("Issues:")}`),e.issues.forEach(n=>{console.log(` \u2022 ${c.yellow(n)}`);}),e.fixCommands&&e.fixCommands.length>0&&(console.log(`
3
+ ${c.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(n=>{console.log(` ${c.cyan("$")} ${c.white(n)}`);}))),e.probes&&e.probes.length>0){console.log(` ${c.bold("Probe checks:")}`);for(let n of e.probes){let d=n.status==="pass"?"\u2705":n.status==="warn"?"\u26A0\uFE0F":"\u274C";console.log(` ${d} ${n.label}: ${c.gray(n.reason)}`),n.recommendation&&console.log(` ${c.dim("\u21B3")} ${c.gray(n.recommendation)}`);}}}async function Oe(){try{return (await execa("go",["version"],{timeout:a$3(),reject:false})).exitCode===0}catch{return false}}function Z(e,s){let r=[new RegExp(`^cd\\s+"([^"]+)"\\s*(?:&&|;)\\s*${s}\\s*$`,"i"),new RegExp(`^cd\\s+'([^']+)'\\s*(?:&&|;)\\s*${s}\\s*$`,"i"),new RegExp(`^cd\\s+(.+?)\\s*(?:&&|;)\\s*${s}\\s*$`,"i")];for(let t of r){let l=e.match(t);if(l?.[1])return {projectPath:l[1].trim()}}return null}function Ve(e){return Z(e,"cp\\s+\\.env\\.example\\s+\\.env")||Z(e,"copy-item\\s+\\.env\\.example\\s+\\.env")}function Le(e){let s=[{pattern:"npm\\s+install",command:"npm",args:["install"]},{pattern:"npm\\s+ci",command:"npm",args:["ci"]},{pattern:"pnpm\\s+install",command:"pnpm",args:["install"]},{pattern:"yarn\\s+install",command:"yarn",args:["install"]},{pattern:"poetry\\s+install",command:"poetry",args:["install"]},{pattern:"pip\\s+install\\s+-r\\s+requirements\\.txt",command:"pip",args:["install","-r","requirements.txt"]},{pattern:"composer\\s+install",command:"composer",args:["install"]},{pattern:"bundle\\s+install",command:"bundle",args:["install"]},{pattern:"dotnet\\s+restore",command:"dotnet",args:["restore"]},{pattern:"cargo\\s+fetch",command:"cargo",args:["fetch"]},{pattern:"mix\\s+deps\\.get",command:"mix",args:["deps.get"]},{pattern:"clojure\\s+-P",command:"clojure",args:["-P"]},{pattern:"sbt\\s+compile",command:"sbt",args:["compile"]}];for(let r of s){let t=Z(e,r.pattern);if(t)return {projectPath:t.projectPath,command:r.command,args:r.args}}return null}function he(e,s){return /^https?:\/\//i.test(s.trim())?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"manual-url",risk:"safe",executable:false,reason:"Manual guidance URL"}:Ve(s)?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"env-copy",risk:"safe",executable:true,reason:"Environment seed copy"}:Z(s,"rapidkit\\s+init")?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"rapidkit-init",risk:"guarded",executable:true,reason:"RapidKit initializer may mutate dependencies and configs"}:Z(s,"go\\s+mod\\s+tidy")?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"go-mod-tidy",risk:"guarded",executable:true,reason:"Go module graph reconciliation"}:Le(s)?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"dependency-sync",risk:"guarded",executable:true,reason:"Dependency synchronization command"}:{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"shell",risk:"invasive",executable:true,reason:"Generic shell command"}}async function ye(e){let s=e.filter(m=>m.fixCommands&&m.fixCommands.length>0),r=s.flatMap(m=>(m.fixCommands??[]).map(f=>he(m,f))),t=null,l=[],o=0,n=0,d=0,u=0;for(let m of r){let f=m.executable,g;m.kind==="go-mod-tidy"&&(t===null&&(t=await Oe()),t||(f=false,g="Go toolchain not available")),f&&(o+=1,m.risk==="safe"&&(n+=1),m.risk==="guarded"&&(d+=1),m.risk==="invasive"&&(u+=1)),l.push({...m,executableInCurrentEnvironment:f,blockedReason:g});}return {generatedAt:new Date().toISOString(),fixableProjects:s.length,totalSteps:l.length,executableSteps:o,risk:{safe:n,guarded:d,invasive:u},steps:l}}function Ae(e){let s=e instanceof Error?e.message:String(e),r=["ETIMEDOUT","ECONNRESET","ECONNREFUSED","EAI_AGAIN","ENOTFOUND","network","503","504"],t=s.toLowerCase();return r.some(l=>t.includes(l.toLowerCase()))}async function At(e,s){let r=e.get(s);if(r)return r;let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,l=i.basename(s).replace(/[^a-zA-Z0-9._-]/g,"_"),o=i.join(s,".rapidkit","reports","fix-snapshots",`${l}-${t}`);await a$1.ensureDir(o);let n=[".env","package-lock.json","pnpm-lock.yaml","yarn.lock","poetry.lock","requirements.txt","go.mod","go.sum","Cargo.lock","composer.lock","Gemfile.lock","pom.xml","build.gradle","build.gradle.kts","gradle.lockfile"],d=new Map;for(let m of n){let f=i.join(s,m);if(!await a$1.pathExists(f))continue;let g=i.join(o,m);await a$1.ensureDir(i.dirname(g)),await a$1.copy(f,g,{overwrite:true}),d.set(f,g);}let u={snapshotRoot:o,files:d};return e.set(s,u),u}async function It(e){for(let[s,r]of e.files.entries())await a$1.pathExists(r)&&(await a$1.ensureDir(i.dirname(s)),await a$1.copy(r,s,{overwrite:true}));}async function Ht(e){let s=await ve(e,{allowNonRapidkit:true});return {issues:s.issues.length,healthy:s.issues.length===0}}async function te(e,s=false,r={}){let t=await ye(e),l=e.filter(h=>h.fixCommands&&h.fixCommands.length>0),o=null,n=t.steps.some(h=>h.kind==="go-mod-tidy"&&!h.executableInCurrentEnvironment),d=new Map;if(l.length===0){console.log(c.green(`
4
+ \u2705 No fixes needed - all projects are healthy!`));return}console.log(c.bold.cyan(`
5
+ \u{1F527} Available Fixes:
6
+ `));for(let h of l){let v=h.fixCommands??[];console.log(c.bold(`Project: ${c.yellow(h.name)}`)),v.forEach((y,x)=>{console.log(` ${x+1}. ${c.cyan(y)}`);}),console.log();}if(r.planOnly){if(r.json){console.log(JSON.stringify(t,null,2));return}console.log(c.bold(`
7
+ \u{1F9ED} Remediation Plan
8
+ `)),console.log(c.gray(`Executable steps: ${t.executableSteps}/${t.totalSteps} | risk: safe=${t.risk.safe}, guarded=${t.risk.guarded}, invasive=${t.risk.invasive}`));for(let h of t.steps){let v=h.executableInCurrentEnvironment?c.green("ready"):c.yellow(`blocked${h.blockedReason?` (${h.blockedReason})`:""}`);console.log(` - ${c.cyan(h.projectName)} [${h.risk}] ${h.originalCommand} ${c.gray(`=> ${v}`)}`);}console.log(c.gray(`
9
+ Use --apply to execute this plan non-interactively, or --fix for interactive confirmation.`));return}let u=t.executableSteps,m=t.risk.safe,f=t.risk.guarded,g=t.risk.invasive;if(u===0){console.log(c.gray("\u{1F4A1} No automatic fixes can be applied right now.")),n&&console.log(c.gray(" Install Go to enable go mod tidy fixes, then rerun `rapidkit doctor workspace --fix`."));return}if(!s){console.log(c.gray('\u{1F4A1} Run "npx rapidkit doctor workspace --fix" to apply fixes automatically'));return}if(console.log(c.gray(`Risk policy: safe=${m}, guarded=${f}, invasive=${g}. Guarded/invasive fixes use snapshot + rollback.`)),!r.skipConfirmation){let{confirm:h}=await Ye.prompt([{type:"confirm",name:"confirm",message:`Apply ${l.reduce((v,y)=>v+(y.fixCommands?.length??0),0)} fix(es)?`,default:false}]);if(!h){console.log(c.yellow(`
10
+ \u26A0\uFE0F Fixes cancelled by user`));return}}console.log(c.bold.cyan(`
11
+ \u{1F680} Applying fixes...
12
+ `));let p=new Set;for(let h of l){let v=h.fixCommands??[];console.log(c.bold(`Fixing ${c.cyan(h.name)}...`));for(let y of v){let x=he(h,y),T=`${h.path}::${y}`;if(!p.has(T)){p.add(T);try{if(console.log(c.gray(` $ ${y}`)),x.kind==="manual-url"){console.log(c.yellow(` \u2139 Manual action required: open ${y}`)),console.log(c.green(` \u2705 Recorded as guidance
13
+ `));continue}if(!x.executable){console.log(c.yellow(" \u26A0 Step is non-executable by policy")),console.log(c.green(` \u2705 Recorded as guidance
14
+ `));continue}x.risk!=="safe"&&await At(d,x.projectPath);let W=Ve(y);if(W){let B=i.join(W.projectPath,".env.example"),R=i.join(W.projectPath,".env");if(!await a$1.pathExists(B))throw new Error(`.env.example not found at ${B}`);if(await a$1.pathExists(R)){console.log(c.green(` \u2705 .env already exists
15
+ `));continue}await a$1.copy(B,R,{overwrite:false,errorOnExist:false}),console.log(c.green(` \u2705 Success
16
+ `));continue}let J=Z(y,"rapidkit\\s+init");if(J){await execa("rapidkit",["init"],{cwd:J.projectPath,shell:b(),stdio:"inherit"}),console.log(c.green(` \u2705 Success
17
+ `));continue}let q=Z(y,"go\\s+mod\\s+tidy");if(q){if(o===null&&(o=await Oe()),!o){console.log(c.yellow(" \u26A0 Go toolchain is not installed \u2014 skipping go mod tidy; install Go to apply this fix.")),console.log(c.green(` \u2705 Recorded as guidance
18
+ `));continue}await execa("go",["mod","tidy"],{cwd:q.projectPath,shell:b(),stdio:"inherit"}),console.log(c.green(` \u2705 Success
19
+ `));continue}let O=Le(y);if(O){let R;for(let ee=1;ee<=2;ee+=1)try{await execa(O.command,O.args,{cwd:O.projectPath,shell:b(),stdio:"inherit"}),R=null;break}catch(ne){if(R=ne,ee<2&&Ae(ne)){console.log(c.yellow(` \u26A0 Retrying dependency sync (${ee}/1)...`));continue}throw ne}if(R)throw R;console.log(c.green(` \u2705 Success
20
+ `));continue}let se=x.kind==="shell"?2:1,U;for(let B=1;B<=se;B+=1)try{await execa(y,{shell:true,stdio:"inherit"}),U=null;break}catch(R){if(U=R,B<se&&Ae(R)){console.log(c.yellow(` \u26A0 Retrying command (${B}/${se-1})...`));continue}throw R}if(U)throw U;console.log(c.green(` \u2705 Success
21
+ `));}catch(W){let J=he(h,y);if(J.risk!=="safe"){let q=d.get(J.projectPath);if(q)try{await It(q),console.log(c.yellow(" \u21A9 Rolled back snapshot after failed fix"));}catch(O){console.log(c.red(` \u274C Rollback failed: ${O instanceof Error?O.message:String(O)}`));}}console.log(c.red(` \u274C Failed: ${W instanceof Error?W.message:String(W)}
22
+ `));}}}try{let y=await Ht(h.path);console.log(y.healthy?c.green(` \u2705 Post-fix verification passed for ${h.name}`):c.yellow(` \u26A0 Post-fix verification: ${y.issues} issue(s) remain for ${h.name}`));}catch(y){console.log(c.yellow(` \u26A0 Post-fix verification skipped: ${y instanceof Error?y.message:String(y)}`));}}console.log(c.bold.green(`
23
+ \u2705 Fix process completed!`));}async function zt(e={}){let s=!!(e.fix||e.plan||e.apply),r=!e.workspace&&!e.project&&s?await ae(process.cwd()):null,t=e.workspace||!!r,l=!!e.project&&!t;if(e.json||console.log(c.bold.cyan(`
24
+ \u{1FA7A} RapidKit Health Check
25
+ `)),t){let o=r??await ae(process.cwd());o||(a.error("No RapidKit workspace found in current directory or parents"),a.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e.json||(r&&console.log(c.gray("\u2139\uFE0F Detected workspace context; enabling workspace checks for --fix")),console.log(c.bold(`Workspace: ${c.cyan(i.basename(o))}`)),console.log(c.gray(`Path: ${o}`)));let n=await Fe(o);if(e.json||(n.projectScanCached&&console.log(c.gray(`\u2139\uFE0F Reused cached project scan${n.projectScanCachePath?` (${i.basename(n.projectScanCachePath)})`:""}`)),n.evidencePath&&console.log(c.gray(`\u2139\uFE0F Evidence saved: ${n.evidencePath}`))),e.json){let f=e.plan?await ye(n.projects):void 0,g={contract:ce(),workspace:{name:i.basename(o),path:o},cache:{projectScan:n.projectScanCached??false,projectScanPath:n.projectScanCachePath,evidencePath:n.evidencePath},healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,rapidkitCore:n.rapidkitCore,versions:{core:n.coreVersion,npm:n.npmVersion}},projects:n.projects.map(p=>({name:p.name,path:p.path,framework:p.framework,frameworkKey:p.frameworkKey,importStack:p.importStack,runtimeFamily:p.runtimeFamily,projectKind:p.projectKind,supportTier:p.supportTier,frameworkConfidence:p.frameworkConfidence,venvActive:p.venvActive,depsInstalled:p.depsInstalled,hasEnvFile:p.hasEnvFile,vulnerabilities:p.vulnerabilities,coreInstalled:p.coreInstalled,coreVersion:p.coreVersion,issues:p.issues,fixCommands:p.fixCommands,probes:p.probes})),summary:{totalProjects:n.projects.length,totalIssues:n.projects.reduce((p,h)=>p+h.issues.length,0),projectAdvisoryWarningProjects:ge(n.projects),projectAdvisoryWarnings:ke(n.projects),hasSystemErrors:[n.python,n.rapidkitCore].some(p=>p.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[],...f?{remediationPlan:f}:{}};console.log(JSON.stringify(g,null,2));return}if(n.healthScore){let f=n.healthScore,g=Math.round(f.passed/f.total*100),p=g>=80?c.green:g>=50?c.yellow:c.red,h="\u2588".repeat(Math.floor(g/5))+"\u2591".repeat(20-Math.floor(g/5));console.log(c.bold(`
26
+ \u{1F4CA} Health Score:`)),console.log(` ${p(`${g}%`)} ${c.gray(h)}`),console.log(` ${c.green(`\u2705 ${f.passed} passed`)} ${c.gray("|")} ${c.yellow(`\u26A0\uFE0F ${f.warnings} warnings`)} ${c.gray("|")} ${c.red(`\u274C ${f.errors} errors`)}`);}if(console.log(c.bold(`
27
+
28
+ System Tools:
29
+ `)),E(n.python,"Python"),E(n.poetry,"Poetry"),E(n.pipx,"pipx"),E(n.go,"Go"),E(n.rapidkitCore,"RapidKit Core"),n.coreVersion&&n.npmVersion){let f=n.coreVersion.split(".")[1],g=n.npmVersion.split(".")[1];f!==g&&(console.log(c.yellow(`
30
+ \u26A0\uFE0F Version mismatch: Core ${n.coreVersion} / CLI ${n.npmVersion}`)),console.log(c.gray(" Consider updating to matching versions for best compatibility")));}n.projects.length>0?(console.log(c.bold(`
31
+ \u{1F4E6} Projects (${n.projects.length}):`)),n.projects.forEach(f=>De(f))):(console.log(c.bold(`
32
+ \u{1F4E6} Projects:`)),console.log(c.gray(" No RapidKit projects found in workspace")));let d=n.projects.reduce((f,g)=>f+g.issues.length,0),u=ge(n.projects),m=[n.python,n.rapidkitCore].some(f=>f.status==="error");if(m||d>0||u>0){let f=u>0?` and ${u} advisory warning project(s)`:"";if(console.log(c.bold.yellow(`
33
+ \u26A0\uFE0F Found ${d} project issue(s)${f}`)),m&&console.log(c.bold.red("\u274C System requirements not met")),e.plan)await te(n.projects,false,{planOnly:true,json:e.json});else if(e.fix||e.apply){if(await te(n.projects,true,{skipConfirmation:e.apply===true}),!e.json){let g=await Fe(o,false),p=g.projects.reduce((v,y)=>v+y.issues.length,0),h=[g.python,g.rapidkitCore].some(v=>v.status==="error");h||p>0?(console.log(c.bold.yellow(`
34
+ \u26A0\uFE0F Post-fix verification found ${p} remaining issue(s)`)),h&&console.log(c.bold.red("\u274C System requirements still not met"))):console.log(c.bold.green(`
35
+ \u2705 Post-fix verification passed. Workspace is healthy.`)),g.projectScanCached&&console.log(c.gray(`\u2139\uFE0F Reused cached project scan${g.projectScanCachePath?` (${i.basename(g.projectScanCachePath)})`:""}`)),g.evidencePath&&console.log(c.gray(`\u2139\uFE0F Evidence refreshed: ${g.evidencePath}`));}}else d>0&&await te(n.projects,false);}else console.log(c.bold.green(`
36
+ \u2705 All checks passed! Workspace is healthy.`));}else if(l){let o=await St(process.cwd());o||(await ae(process.cwd())?(a.error("No backend project found in current directory within this workspace"),a.info("Run this command from inside a project directory in the workspace")):a.error("No RapidKit project found in current directory or parents"),a.info('Run this command from within a project, or use "rapidkit doctor workspace" for workspace checks'),process.exit(1));let n=await Dt(o),d=n.workspacePath?$e(n.workspacePath):null,u=$e(n.project.path);if(e.json){let x=e.plan?await ye([n.project]):void 0,T={contract:ce(),scope:"project",workspace:d?{name:i.basename(d),path:d}:null,project:{name:n.project.name,path:u,framework:n.project.framework,frameworkKey:n.project.frameworkKey,importStack:n.project.importStack,runtimeFamily:n.project.runtimeFamily,projectKind:n.project.projectKind,supportTier:n.project.supportTier,frameworkConfidence:n.project.frameworkConfidence,venvActive:n.project.venvActive,depsInstalled:n.project.depsInstalled,hasEnvFile:n.project.hasEnvFile,vulnerabilities:n.project.vulnerabilities,coreInstalled:n.project.coreInstalled,coreVersion:n.project.coreVersion,issues:n.project.issues,fixCommands:n.project.fixCommands,probes:n.project.probes},evidencePath:n.evidencePath,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore},summary:{totalProjects:1,totalIssues:n.project.issues.length,projectAdvisoryWarningProjects:Y(n.project)>0?1:0,projectAdvisoryWarnings:Y(n.project),hasSystemErrors:[n.python,n.rapidkitCore].some(W=>W.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[],...x?{remediationPlan:x}:{}};console.log(JSON.stringify(T,null,2));return}console.log(c.bold(`Project: ${c.cyan(i.basename(o))}`)),console.log(c.gray(`Path: ${o}`)),n.workspacePath&&console.log(c.gray(`Workspace: ${i.basename(n.workspacePath)}`)),n.evidencePath&&console.log(c.gray(`\u2139\uFE0F Evidence saved: ${n.evidencePath}`));let m=n.healthScore,f=m.total>0?Math.round(m.passed/m.total*100):0,g=f>=80?c.green:f>=50?c.yellow:c.red,p="\u2588".repeat(Math.floor(f/5))+"\u2591".repeat(20-Math.floor(f/5));console.log(c.bold(`
37
+ \u{1F4CA} Health Score:`)),console.log(` ${g(`${f}%`)} ${c.gray(p)}`),console.log(` ${c.green(`\u2705 ${m.passed} passed`)} ${c.gray("|")} ${c.yellow(`\u26A0\uFE0F ${m.warnings} warnings`)} ${c.gray("|")} ${c.red(`\u274C ${m.errors} errors`)}`),console.log(c.bold(`
38
+
39
+ System Tools:
40
+ `)),E(n.python,"Python"),E(n.poetry,"Poetry"),E(n.pipx,"pipx"),E(n.go,"Go"),E(n.rapidkitCore,"RapidKit Core"),console.log(c.bold(`
41
+ \u{1F4E6} Project (1):`)),De(n.project);let h=[n.python,n.rapidkitCore].some(x=>x.status==="error"),v=n.project.issues.length,y=Y(n.project);if(h||v>0||y>0){let x=y>0?` and ${y} advisory warning(s)`:"";console.log(c.bold.yellow(`
42
+ \u26A0\uFE0F Found ${v} project issue(s)${x}`)),h&&console.log(c.bold.red("\u274C System requirements not met")),e.plan?await te([n.project],false,{planOnly:true,json:e.json}):e.fix||e.apply?await te([n.project],true,{skipConfirmation:e.apply===true}):v>0&&await te([n.project],false);}else console.log(c.bold.green(`
43
+ \u2705 All checks passed! Project is healthy.`));}else {console.log(c.bold(`System Tools:
44
+ `));let o=await we(),n=o.python,d=o.poetry,u=o.pipx,m=o.go,f=o.rapidkitCore;E(n,"Python"),E(d,"Poetry"),E(u,"pipx"),E(m,"Go"),E(f,"RapidKit Core"),[n,f].some(p=>p.status==="error")?(console.log(c.bold.red(`
45
+ \u274C Some required tools are missing`)),(e.fix||e.apply)&&console.log(c.gray(`
46
+ Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(c.gray(`
47
+ Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))):(console.log(c.bold.green(`
48
+ \u2705 All required tools are installed!`)),(e.fix||e.apply)&&console.log(c.gray(`
49
+ Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(c.gray(`
50
+ Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`)));}console.log("");}export{zt as runDoctor};
@@ -1,4 +1,4 @@
1
- import {c,b as b$1,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import d from'path';import o from'chalk';import S from'ora';import {execa}from'execa';function _(e){return `package main
1
+ import {c,b as b$1,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b}from'./chunk-AC6KIKII.js';import {promises}from'fs';import d from'path';import o from'chalk';import S from'ora';import {execa}from'execa';function _(e){return `package main
2
2
 
3
3
  import (
4
4
  "fmt"
@@ -1,4 +1,4 @@
1
- import {c,b as b$2,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b as b$1}from'./chunk-Q7ULIFQA.js';import {promises}from'fs';import d from'path';import o from'chalk';import _ from'ora';import {execa}from'execa';function T(e){return `package main
1
+ import {c,b as b$2,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b as b$1}from'./chunk-AC6KIKII.js';import {promises}from'fs';import d from'path';import o from'chalk';import _ from'ora';import {execa}from'execa';function T(e){return `package main
2
2
 
3
3
  import (
4
4
  "context"