rapidkit 0.27.4 → 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 +12 -4
- package/dist/chunk-2FIX2MDC.js +1 -0
- package/dist/{chunk-ZAZJEYYT.js → chunk-7OGOVP5U.js} +2 -2
- package/dist/chunk-AC6KIKII.js +5 -0
- package/dist/chunk-BFCIY2QK.js +33 -0
- package/dist/chunk-VKLL63TL.js +1 -0
- package/dist/create-TWGGH5XC.js +842 -0
- package/dist/{demo-kit-HMJZ3A3M.js → demo-kit-KTRITRWH.js} +1 -1
- package/dist/doctor-DDIR7LBO.js +50 -0
- package/dist/{gofiber-standard-JDPREQCP.js → gofiber-standard-TFPNBIMS.js} +1 -1
- package/dist/{gogin-standard-DCERHHVB.js → gogin-standard-7UJ2OBYL.js} +1 -1
- package/dist/index.js +112 -112
- package/dist/package.json +5 -1
- package/dist/pythonRapidkitExec-4MP62M5R.js +1 -0
- package/dist/{springboot-standard-AGTOOTNT.js → springboot-standard-H6GYMH3P.js} +1 -1
- package/dist/{workspace-HEHMJ3QC.js → workspace-YKWUI37R.js} +45 -45
- package/dist/workspace-run-GVE4J6HT.js +3 -0
- package/package.json +5 -1
- package/dist/chunk-Q7ULIFQA.js +0 -5
- package/dist/chunk-UOGFCKQ5.js +0 -33
- package/dist/create-GHYIP4PM.js +0 -781
- package/dist/doctor-SZXHMRFR.js +0 -47
- package/dist/pythonRapidkitExec-K2SFGAYJ.js +0 -1
- package/dist/workspace-run-M7XJ3QH5.js +0 -3
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`
|
|
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
|
|
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{
|
|
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};
|