workspai 0.50.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +126 -497
  2. package/contracts/create-planner-capabilities.v1.json +10 -1
  3. package/contracts/extension-cli-compatibility.v1.json +1 -1
  4. package/dist/analyze-4H33PAUB.js +1 -0
  5. package/dist/{artifact-remediation-plan-ICN3KOFG.js → artifact-remediation-plan-TQ6KTTXD.js} +1 -1
  6. package/dist/autopilot-release-BHZYM5KX.js +1 -0
  7. package/dist/chunk-3D2PAIRH.js +3 -0
  8. package/dist/{chunk-C35UXTDM.js → chunk-4WJC5QCD.js} +1 -1
  9. package/dist/{chunk-MV7KF75Q.js → chunk-6HLPTJZ3.js} +1 -1
  10. package/dist/{chunk-CV5HKU4P.js → chunk-7T4TSV5C.js} +1 -1
  11. package/dist/chunk-BBGNDMRU.js +2 -0
  12. package/dist/{chunk-VKTUWUS6.js → chunk-BG4FWJJ3.js} +1 -1
  13. package/dist/chunk-BYTFXQ6G.js +1 -0
  14. package/dist/chunk-DLM6C7FU.js +8 -0
  15. package/dist/chunk-E3CT7TYT.js +1 -0
  16. package/dist/chunk-EPVFKJF4.js +1 -0
  17. package/dist/{chunk-5EXZBCAZ.js → chunk-FKWB66NQ.js} +1 -1
  18. package/dist/{chunk-RTVRZFIJ.js → chunk-FZ76CF2W.js} +1 -1
  19. package/dist/{chunk-C3FLCDRN.js → chunk-GBAO4GSW.js} +1 -1
  20. package/dist/{chunk-AL2A7Q4X.js → chunk-GQRWRHSR.js} +31 -31
  21. package/dist/{chunk-BQGBU2Y3.js → chunk-HE4PUMU4.js} +1 -1
  22. package/dist/{chunk-KXG6E5VK.js → chunk-HMGPELXS.js} +1 -1
  23. package/dist/chunk-HSZCINFX.js +2 -0
  24. package/dist/chunk-L2E2Z4OE.js +5 -0
  25. package/dist/chunk-MAF3LLGK.js +691 -0
  26. package/dist/chunk-PS5F4DCT.js +1 -0
  27. package/dist/{chunk-LZQUZGXB.js → chunk-Q6TKQVKQ.js} +1 -1
  28. package/dist/chunk-TROHVI2V.js +2 -0
  29. package/dist/{chunk-IPJ5URDF.js → chunk-U2LR73E2.js} +1 -1
  30. package/dist/chunk-U2QL5733.js +36 -0
  31. package/dist/{chunk-DDQ3XK3H.js → chunk-VCW5HSPC.js} +2 -2
  32. package/dist/{chunk-6UTM5AJI.js → chunk-VU2BKKMB.js} +1 -1
  33. package/dist/chunk-WJVB6SSD.js +16 -0
  34. package/dist/{chunk-SS2VV3D5.js → chunk-XBM2P45G.js} +2 -2
  35. package/dist/{create-I23DC7SN.js → create-SBFBFXKN.js} +1 -1
  36. package/dist/{doctor-DOOMYLIH.js → doctor-OPCMTBJB.js} +1 -1
  37. package/dist/index.js +229 -229
  38. package/dist/{pipeline-U77HSINC.js → pipeline-7BUXAFS2.js} +1 -1
  39. package/dist/{project-test-coverage-4TEHZJFC.js → project-test-coverage-BALEHHTT.js} +1 -1
  40. package/dist/{workspace-ZEYUVR26.js → workspace-U6ZQLELX.js} +1 -1
  41. package/dist/{workspace-agent-sync-DKYJLUDP.js → workspace-agent-sync-L4SY7B4Q.js} +1 -1
  42. package/dist/workspace-context-KOBSLZTI.js +1 -0
  43. package/dist/{workspace-contract-PVLGPBBV.js → workspace-contract-SOD3OOVF.js} +1 -1
  44. package/dist/{workspace-explain-64HNKAHO.js → workspace-explain-2CTMW2YW.js} +1 -1
  45. package/dist/{workspace-feedback-RATRXFUC.js → workspace-feedback-ZZ4HPW2T.js} +1 -1
  46. package/dist/{workspace-foundation-D33LJLGT.js → workspace-foundation-PUIYBQUF.js} +1 -1
  47. package/dist/{workspace-graph-stream-THNG2T7R.js → workspace-graph-stream-BLKIC7VN.js} +1 -1
  48. package/dist/workspace-graph-token-efficiency-5FNH4JZ5.js +1 -0
  49. package/dist/{workspace-history-EWFPT74O.js → workspace-history-SPKNRHIX.js} +1 -1
  50. package/dist/{workspace-intelligence-MCNSWWDV.js → workspace-intelligence-I3ABOH2F.js} +1 -1
  51. package/dist/workspace-intelligence-runner-Q2XSR3ZL.js +1 -0
  52. package/dist/{workspace-knowledge-graph-2EYR7N56.js → workspace-knowledge-graph-5MKEI4Z5.js} +1 -1
  53. package/dist/{workspace-knowledge-graph-query-VOSPPH4W.js → workspace-knowledge-graph-query-EKHIE3E2.js} +1 -1
  54. package/dist/{workspace-mcp-serve-FLAVKWYW.js → workspace-mcp-serve-ETNUA72W.js} +1 -1
  55. package/dist/{workspace-model-FMFYLHE4.js → workspace-model-HHA37SNH.js} +1 -1
  56. package/dist/{workspace-onboarding-MYROZDI2.js → workspace-onboarding-ELHZABJE.js} +1 -1
  57. package/dist/workspace-readme-HGGZ4AZB.js +77 -0
  58. package/dist/{workspace-registry-summary-6VXIAQLX.js → workspace-registry-summary-D2QM5JF6.js} +1 -1
  59. package/dist/workspace-run-DAAZBCN7.js +1 -0
  60. package/dist/{workspace-verify-FKYI65UQ.js → workspace-verify-4WJTLXRA.js} +1 -1
  61. package/dist/{workspace-watch-RP5KMVP2.js → workspace-watch-2PIFTQ6B.js} +1 -1
  62. package/docs/README_CONTENT_CONTRACT.md +98 -124
  63. package/docs/ci-workflows.md +13 -4
  64. package/docs/commands-reference.md +4 -2
  65. package/docs/workspace-knowledge-graph.md +39 -0
  66. package/docs/workspace-operations.md +9 -6
  67. package/package.json +6 -3
  68. package/scripts/enterprise-package-smoke.mjs +11 -0
  69. package/templates/kits/fastapi-ddd/README.md.j2 +1 -1
  70. package/templates/kits/fastapi-standard/README.md.j2 +1 -1
  71. package/templates/kits/nestjs-standard/Dockerfile.j2 +1 -1
  72. package/templates/kits/nestjs-standard/README.md.j2 +1 -1
  73. package/templates/kits/nestjs-standard/package.json.j2 +11 -2
  74. package/dist/analyze-ZFQWTCJQ.js +0 -1
  75. package/dist/autopilot-release-VKXQ7BS7.js +0 -1
  76. package/dist/chunk-2AXEGYPL.js +0 -1
  77. package/dist/chunk-GNQRYISX.js +0 -5
  78. package/dist/chunk-I42F552T.js +0 -2
  79. package/dist/chunk-IDQKVJUF.js +0 -2
  80. package/dist/chunk-JFUD73OZ.js +0 -933
  81. package/dist/chunk-KKAOTTYO.js +0 -8
  82. package/dist/chunk-KMLPHFLD.js +0 -2
  83. package/dist/chunk-L2YK5RV2.js +0 -1
  84. package/dist/chunk-LAJM2SBP.js +0 -15
  85. package/dist/chunk-UETZ7USY.js +0 -36
  86. package/dist/chunk-WDKNMTJQ.js +0 -1
  87. package/dist/chunk-YPKNQCLK.js +0 -2
  88. package/dist/workspace-context-IHUFMZT3.js +0 -1
  89. package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +0 -1
  90. package/dist/workspace-intelligence-runner-TG2VLHNZ.js +0 -1
  91. package/dist/workspace-run-2ZI5UMJ2.js +0 -1
@@ -1,933 +0,0 @@
1
- import {f,g,e as e$2}from'./chunk-C35UXTDM.js';import {b as b$3}from'./chunk-KVSYBHUR.js';import {b as b$7,a as a$3}from'./chunk-THIOE2PB.js';import {b as b$4}from'./chunk-2AXEGYPL.js';import {a as a$2}from'./chunk-IPJ5URDF.js';import {e,g as g$1,f as f$2,b as b$6,c as c$2,d as d$2}from'./chunk-LAJM2SBP.js';import {d,b as b$2}from'./chunk-Y5YAP4F3.js';import {g as g$2}from'./chunk-KMLPHFLD.js';import {i,f as f$1,c as c$1,e as e$3}from'./chunk-VRW6KXNK.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {b as b$1,a,c,d as d$1}from'./chunk-MOSXTVPU.js';import {b as b$5,k,j,m,i as i$1,t,s,q as q$1}from'./chunk-RJIYCDVC.js';import {promises}from'fs';import*as b from'fs-extra';import p from'path';import e$1 from'chalk';import {execa}from'execa';function N(){return i$1()}var rt="transactions";function st(){return p.join(q$1(),rt)}async function We(){let t=st();return await b$7(t),a$3({journalDirectory:t})}async function Oe(t){for(let o of s())await t.captureFile(o);}async function ie(t){let o=await We();try{return await Oe(o),await o.captureOwnedTree(t),o}catch(n){return F(o,n)}}async function lt(t){let o=await We();try{await Oe(o),await o.captureOwnedTree(p.join(t,a)),await o.captureOwnedTree(p.join(t,".venv"));let n=[c,".gitignore",p.join(a,"workspace.json"),p.join(a,"toolchain.lock"),p.join(a,"policies.yml"),p.join(a,"cache-config.yml"),g$2,a$2,"pyproject.toml","poetry.toml","poetry.lock","rapidkit","rapidkit.cmd","README.md",".rapidkit-global"];for(let s of n)await o.captureFile(p.join(t,s));return o}catch(n){return F(o,n)}}async function B(t){await t.commit(),t.journalPath&&await promises.rm(p.dirname(t.journalPath),{recursive:true,force:true}).catch(o=>f$1.debug(`Could not remove committed lifecycle journal: ${o}`));}async function F(t,o){try{await t.rollback();}catch(n){throw new AggregateError([o,n],"Workspace lifecycle failed and rollback was incomplete.")}throw o}async function J(t,o,n,s,r){let l=d(o,i(),n,r?.pythonEngine?{coreStatus:r.pythonEngine,...r.pythonEngineReason?{coreReason:r.pythonEngineReason}:{},...s?{pythonVersion:s}:{}}:void 0);s&&!r?.pythonEngine&&(l.metadata||(l.metadata={}),l.metadata.python={pythonVersion:s}),await b$2(t,l);}async function U(t){await b.outputFile(p.join(t,".gitignore"),`.venv/
2
- __pycache__/
3
- *.pyc
4
- .env
5
- ${d$1}
6
- ${b$1}/
7
-
8
- `,"utf-8");}async function Fe(t){try{let o=await execa("git",["rev-parse","--show-toplevel"],{cwd:t,env:a$1()});return o.stdout.trim()?p.resolve(t,o.stdout.trim()):null}catch{return null}}async function Q(t,o,n){if(await Fe(t)){o.warn("Git initialization skipped because target is already inside a git worktree");return}o.start("Initializing git repository");try{await execa("git",["init"],{cwd:t,env:a$1()}),await execa("git",["add","."],{cwd:t,env:a$1()}),await execa("git",["-c","user.name=Workspai","-c","user.email=workspai@localhost","commit","-m",n],{cwd:t,env:a$1()}),o.succeed("Git repository initialized");}catch{o.warn("Could not initialize git repository");}}async function Le(t,o){let n=o.replace(/[^a-z0-9-]/gi,"-").toLowerCase();await b.outputFile(p.join(t,"poetry.toml"),`[virtualenvs]
9
- in-project = true
10
- `,"utf-8"),await b.outputFile(p.join(t,"pyproject.toml"),`[tool.poetry]
11
- name = "${n}"
12
- version = "0.1.0"
13
- description = "Workspai workspace"
14
- authors = []
15
- package-mode = false
16
-
17
- [tool.poetry.dependencies]
18
- python = "^3.10"
19
- rapidkit-core = "*"
20
-
21
- [build-system]
22
- requires = ["poetry-core"]
23
- build-backend = "poetry.core.masonry.api"
24
- `,"utf-8");}function Ve(t,o,n,s,r){return JSON.stringify({schema_version:"1.0",workspace_name:t,workspai_version:i(),rapidkit_version:i(),created_at:new Date().toISOString(),created_by:"workspai",profile:s||"minimal",...r?.profileRequested?{profile_requested:r.profileRequested}:{},...r?.bootstrapNote?{bootstrap_note:r.bootstrapNote}:{},engine:{install_method:o,python_version:n||null,...r?.pythonEngine?{python_core:{status:r.pythonEngine,...r.pythonEngineReason?{reason:r.pythonEngineReason}:{}}}:{}}},null,2)}function Ge(t,o,n,s,r,l){return JSON.stringify({schema_version:"1.0",generated_by:"workspai",generated_at:new Date().toISOString(),runtime:{python:{version:o||null,install_method:t,...l?.pythonEngine?{core:{status:l.pythonEngine,...l.pythonEngineReason?{reason:l.pythonEngineReason}:{}}}:{}},node:{version:n||process.version},go:{version:s||null},java:{version:null,build_tool:null,build_tool_version:null},dotnet:{version:r||null,sdk:r||null}}},null,2)}function He(){return `version: "1.0"
25
- mode: warn # "warn" or "strict"
26
- dependency_sharing_mode: isolated # "isolated" or "shared-runtime-caches" or "shared-node-deps"
27
- # change profile (recommended): npx workspai bootstrap --profile polyglot
28
- # change mode/dependency manually: edit this file and rerun npx workspai init
29
- rules:
30
- enforce_workspace_marker: true
31
- enforce_toolchain_lock: false
32
- disallow_untrusted_tool_sources: false
33
- `}function Ue(){return `version: "1.0"
34
- cache:
35
- strategy: shared # "shared" or "on-demand"
36
- prune_on_bootstrap: false
37
- self_heal: true
38
- verify_integrity: false
39
- `}async function Ye(){try{let{stdout:t}=await execa("go",["version"],{timeout:3e3,stdio:"pipe"}),o=t.match(/go(\d+\.\d+(?:\.\d+)?)/i);return o?o[1]:void 0}catch{return}}async function qe(){try{let{stdout:t}=await execa("dotnet",["--version"],{timeout:3e3,stdio:"pipe"}),o=t.trim();return o.length>0?o:void 0}catch{return}}async function X(t,o,n,s,r,l){let[d,g]=await Promise.all([Ye(),qe()]),c=[{fileName:"workspace.json",content:Ve(o,n,s,r,l)},{fileName:"toolchain.lock",content:Ge(n,s,process.version,d,g,l)},{fileName:"policies.yml",content:He()},{fileName:"cache-config.yml",content:Ue()}];for(let m of c)await b.outputFile(p.join(t,a,m.fileName),m.content,"utf-8");}async function Ut(t,o){let{workspaceName:n=p.basename(t),installMethod:s="venv",pythonVersion:r,profile:l,writeMarker:d$1=true,writeGitignore:g=true,onlyIfMissing:c$1=true}=o||{},m=[],[y,h]=await Promise.all([Ye(),qe()]),a$1=[{relPath:p.join(a,"workspace.json"),legacyRelPath:p.join(b$1,"workspace.json"),content:Ve(n,s,r,l)},{relPath:p.join(a,"toolchain.lock"),legacyRelPath:p.join(b$1,"toolchain.lock"),content:Ge(s,r,process.version,y,h)},{relPath:p.join(a,"policies.yml"),legacyRelPath:p.join(b$1,"policies.yml"),content:He()},{relPath:p.join(a,"cache-config.yml"),legacyRelPath:p.join(b$1,"cache-config.yml"),content:Ue()}];for(let i of a$1){let x=p.join(t,i.relPath),w=p.join(t,i.legacyRelPath),A=await b.pathExists(x),I=await b.pathExists(w);c$1&&A||(c$1&&I?(await b.copy(w,x),m.push(i.relPath)):(await b.outputFile(x,i.content,"utf-8"),m.push(i.relPath)));}if(d$1&&(!await b.pathExists(p.join(t,c))||!c$1)){let x=d(n,i(),s);r&&(x.metadata||(x.metadata={}),x.metadata.python={pythonVersion:r}),await b$2(t,x),m.push(c);}if(g){let i=p.join(t,".gitignore");(!c$1||!await b.pathExists(i))&&(await U(t),m.push(".gitignore"));}return m}var ze=new Set(["go-only","java-only","dotnet-only","node-only","minimal"]),ct={"python-only":"minimal",polyglot:"node-only",enterprise:"polyglot"};function pt(t){let o=t,n=new Set;for(;!ze.has(o);){if(n.has(o))return "minimal";n.add(o);let s=ct[o];if(!s)return "minimal";o=s;}return o}var H="3.10",Be=["3.10","3.11","3.12"];async function Ne(t){try{let{stdout:o}=await execa(t,["--version"],{timeout:3e3}),n=o.match(/Python (\d+\.\d+\.\d+)/);if(n)return n[1]}catch{}return null}async function dt(t,o){try{await promises.writeFile(p.join(t,".python-version"),`${o}
40
- `,"utf-8"),f$1.debug(`Created .python-version with ${o}`);}catch(n){f$1.warn(`Failed to create .python-version: ${n}`);}}function q(){let n=[...(process.env.PATH||"").split(p.delimiter).filter(Boolean)];for(let s of t())n.includes(s)||n.unshift(s);process.env.PATH=n.join(p.delimiter);}async function de(t,o){q(),t.start("Checking pipx installation");try{return await execa("pipx",["--version"]),t.succeed("pipx found"),{kind:"binary"}}catch{}let n=N();try{return await execa(n,["-m","pipx","--version"]),t.succeed("pipx found"),{kind:"python-module",pythonCmd:n}}catch{}if(o)throw new d$2;t.stop?.();let{installPipx:s}=await b$3([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!s)throw new d$2;t.start("Installing pipx (user install)");try{try{await execa(n,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(n,["-m","pip","install","--user","--upgrade","pipx"]);}catch(r){let l=r,d=String(l?.stderr||l?.shortMessage||l?.message||"");throw new f$2("Install pipx with python -m pip",r instanceof Error?r:new Error(d))}t.succeed("pipx installed"),q();try{return await execa(n,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:n}}catch(r){let l=r,d=String(l?.stderr||l?.shortMessage||l?.message||"pipx not runnable after install");throw new f$2("Verify pipx after install",new Error(`${d}
41
-
42
- Try reopening your terminal or run: ${n} -m pipx ensurepath`))}}async function Y(t,o){return t.kind==="binary"?execa("pipx",o):execa(t.pythonCmd,["-m","pipx",...o])}function ut(t){let o=t.match(/^(\d+)\.(\d+)/);return o?`${o[1]}.${o[2]}`:null}function Ke(t){if(!t)return null;let o=t.match(/Python\s+(\d+)\.(\d+)(?:\.\d+)?/i);return o?`${o[1]}.${o[2]}`:null}function Pe(t,o){let[n,s]=t.split(".").map(d=>Number(d)),[r,l]=o.split(".").map(d=>Number(d));return n!==r?n-r:s-l}function Z(t,o){return Pe(t,o)>=0}async function yt(t){let o=new Set,n=k(14,10);for(let h of n)try{let a=await execa(h.command,h.args,{timeout:2500}),i=Ke(`${a.stdout||""}
43
- ${a.stderr||""}`);i&&Z(i,H)&&o.add(i);}catch{}let s=null;try{let h=await execa(N(),["--version"],{timeout:2500}),a=Ke(`${h.stdout||""}
44
- ${h.stderr||""}`);a&&Z(a,H)&&(s=a,o.add(a));}catch{}let r=Be.filter(h=>Z(h,H)),l=new Set([...r,...o]),d=Array.from(l).sort((h,a)=>Pe(a,h)),g=t?ut(t):null,c=g&&Z(g,H)?g:s||d[0]||H;return l.has(c)||l.add(c),{choices:Array.from(l).sort((h,a)=>Pe(a,h)).map(h=>{let a=[];return h===s&&a.push("current system"),h===H&&a.push("minimum supported"),o.has(h)&&h!==s&&a.push("detected"),{name:a.length>0?`${h} (${a.join(", ")})`:h,value:h}}),defaultValue:c}}async function gt(){q();let t=false,o=false;try{await execa("poetry",["--version"],{timeout:2500}),t=true;}catch{t=false;}try{await execa("pipx",["--version"],{timeout:2500}),o=true;}catch{let n=i$1();try{await execa(n,["-m","pipx","--version"],{timeout:2500}),o=true;}catch{o=false;}}return {poetry:t,pipx:o}}async function Je(){q();try{return await execa("poetry",["--version"],{timeout:2500}),true}catch{return false}}function mt(t,o){return t==="poetry"&&o.poetry?"poetry":t==="pipx"&&o.pipx?"pipx":t==="venv"?"venv":o.poetry?"poetry":"venv"}async function ht(t,o){q(),t.start("Checking Poetry installation");try{await execa("poetry",["--version"]),t.succeed("Poetry found");return}catch{}if(o)throw new c$2;let{installPoetry:n}=await b$3([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!n)throw new c$2;let s=await de(t,o);t.start("Installing Poetry with pipx");try{await Y(s,["install","poetry"]);}catch(r){let l=r,d=String(l?.stderr||l?.shortMessage||l?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(d))try{await Y(s,["upgrade","poetry"]);}catch{}else throw new f$2("Install Poetry with pipx",r instanceof Error?r:new Error(d))}t.succeed("Poetry installed"),q();try{await execa("poetry",["--version"]);}catch(r){let l=r,d=String(l?.stderr||l?.shortMessage||l?.message||"Poetry not found on PATH");throw new f$2("Verify Poetry after pipx install",new Error(`${d}
45
-
46
- Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function wt(t,o={}){let n=t==="poetry",s=o.pythonEngineSkipped?`echo "- Python engine installation was intentionally skipped for this workspace." 1>&2
47
- echo "- For npm-owned workspace commands, run: npx workspai <command>" 1>&2
48
- echo "- To install the local Python engine later, create a RapidKit Core module-enabled project, then run: npx workspai workspace run init" 1>&2
49
- `:`echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
50
- `;return `#!/usr/bin/env sh
51
- set -eu
52
-
53
- SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
54
-
55
- VENV_RAPIDKIT="$SCRIPT_DIR/.venv/bin/rapidkit"
56
- if [ -x "$VENV_RAPIDKIT" ]; then
57
- exec "$VENV_RAPIDKIT" "$@"
58
- fi
59
-
60
- ${n?`if command -v poetry >/dev/null 2>&1 && [ -f "$SCRIPT_DIR/pyproject.toml" ]; then
61
- exec poetry run rapidkit "$@"
62
- fi
63
-
64
- `:""}if command -v rapidkit >/dev/null 2>&1; then
65
- RAPIDKIT_CMD=$(command -v rapidkit)
66
- if [ "$RAPIDKIT_CMD" != "$SCRIPT_DIR/rapidkit" ] && [ "$RAPIDKIT_CMD" != "$SCRIPT_DIR/.workspai/rapidkit" ] && [ "$RAPIDKIT_CMD" != "$SCRIPT_DIR/.rapidkit/rapidkit" ]; then
67
- RAPIDKIT_LOCAL_LAUNCHER_BYPASS=1 exec "$RAPIDKIT_CMD" "$@"
68
- fi
69
- fi
70
-
71
- for RAPIDKIT_CORE in "$HOME/.local/bin/rapidkit" "$HOME/Library/Python/3.14/bin/rapidkit" "$HOME/Library/Python/3.13/bin/rapidkit" "$HOME/Library/Python/3.12/bin/rapidkit" "$HOME/Library/Python/3.11/bin/rapidkit" "$HOME/Library/Python/3.10/bin/rapidkit"; do
72
- if [ -x "$RAPIDKIT_CORE" ]; then
73
- exec "$RAPIDKIT_CORE" "$@"
74
- fi
75
- done
76
-
77
- echo "RapidKit launcher could not find a local Python CLI." 1>&2
78
- ${s}${o.pythonEngineSkipped?"":n?`echo "- If you used Poetry: run 'poetry install' and retry, or activate the env." 1>&2
79
- `:""}${o.pythonEngineSkipped?`echo "Tip: use 'npx workspai workspace model --json' for Workspace Intelligence without the Python engine." 1>&2
80
- `:`echo "Tip: you can also run: ./.venv/bin/rapidkit --help" 1>&2
81
- `}exit 1
82
- `}function ft(t,o={}){let n=t==="poetry",s=o.pythonEngineSkipped?`echo - Python engine installation was intentionally skipped for this workspace. 1>&2
83
- echo - For npm-owned workspace commands, run: npx workspai ^<command^> 1>&2
84
- echo - To install the local Python engine later, create a RapidKit Core module-enabled project, then run: npx workspai workspace run init 1>&2
85
- `:`echo Tip: run .venv\\Scripts\\rapidkit.exe --help 1>&2
86
- `;return `@echo off
87
- setlocal
88
-
89
- set "SCRIPT_DIR=%~dp0"
90
-
91
- if exist "%SCRIPT_DIR%\\.venv\\Scripts\\rapidkit.exe" (
92
- "%SCRIPT_DIR%\\.venv\\Scripts\\rapidkit.exe" %*
93
- exit /b %ERRORLEVEL%
94
- )
95
-
96
- ${n?`where poetry >nul 2>nul
97
- if %ERRORLEVEL%==0 if exist "%SCRIPT_DIR%\\pyproject.toml" (
98
- poetry run rapidkit %*
99
- exit /b %ERRORLEVEL%
100
- )
101
-
102
- `:""}:rapidkit_npm_wrapper_fallback
103
- for /f "delims=" %%R in ('where rapidkit.cmd 2^>nul') do (
104
- if /I not "%%~fR"=="%SCRIPT_DIR%rapidkit.cmd" if /I not "%%~fR"=="%SCRIPT_DIR%.workspai\\rapidkit.cmd" if /I not "%%~fR"=="%SCRIPT_DIR%.rapidkit\\rapidkit.cmd" (
105
- set "RAPIDKIT_LOCAL_LAUNCHER_BYPASS=1"
106
- "%%~fR" %*
107
- exit /b %ERRORLEVEL%
108
- )
109
- )
110
-
111
- :rapidkit_core_fallback
112
- for %%R in ("%USERPROFILE%\\.local\\bin\\rapidkit.exe" "%APPDATA%\\Python\\Scripts\\rapidkit.exe" "%LOCALAPPDATA%\\Programs\\Python\\Scripts\\rapidkit.exe") do (
113
- if exist "%%~R" (
114
- "%%~R" %*
115
- exit /b %ERRORLEVEL%
116
- )
117
- )
118
-
119
- echo RapidKit launcher could not find a local Python CLI. 1>&2
120
- ${s}echo Tip: for npm-owned workspace commands, run npx --yes --package workspai workspai %* from a shell where npm is on PATH. 1>&2
121
- exit /b 1
122
- `}async function pe(t,o,n={}){await b.outputFile(p.join(t,"rapidkit"),wt(o,n),{encoding:"utf-8",mode:493}),await b.outputFile(p.join(t,"rapidkit.cmd"),ft(o,n),"utf-8");}async function Yt(t,o){let{skipGit:n=false,skipPythonEngine:s=false,testMode:r=false,demoMode:l=false,dryRun:d=false,yes:g$1=false,userConfig:c={},installMethod:m,profile:y,parentDirectory:h}=o,a=t||"rapidkit",i=h?p.resolve(h,a):p.resolve(process.cwd(),a);if(await b.pathExists(i))throw new e(a);if(await f(i),d){let k=y||(g$1?"minimal":void 0),_=m||c.defaultInstallMethod||"poetry",v=c.pythonVersion||"3.10";await vt(i,a,l,c,k,_,v,n,s);return}if(l){await kt(i,a,n);return}let x=new Set(["python-only","polyglot","enterprise"]),w=y||"";if(!g$1&&!y){let{selectedProfile:k}=await b$3([{type:"rawlist",name:"selectedProfile",message:"Select workspace profile:",choices:[{name:"minimal \u2014 Foundation files only (fastest bootstrap, mixed projects)",value:"minimal"},{name:"java-only \u2014 Java runtime (Spring Boot services)",value:"java-only"},{name:"python-only \u2014 Python + Poetry (FastAPI, Django, ML pipelines)",value:"python-only"},{name:"node-only \u2014 Node.js runtime (NestJS, Express, Next.js)",value:"node-only"},{name:"go-only \u2014 Go runtime (Fiber, Gin, gRPC, microservices)",value:"go-only"},{name:"dotnet-only \u2014 .NET runtime (ASP.NET Core services)",value:"dotnet-only"},{name:"polyglot \u2014 Python + Node.js + Go + Java + .NET multi-runtime workspace",value:"polyglot"},{name:"enterprise \u2014 Polyglot + governance + Sigstore verification",value:"enterprise"}],default:1}]);w=k;}else w||(w="minimal");let A=!g$1&&x.has(w),I=x.has(w)?s?"skip":A?(await b$3([{type:"confirm",name:"installPythonEngine",message:"Install the optional RapidKit Python engine now? (needed for Python-backed kits/modules)",default:true}])).installPythonEngine!==false?"install":"skip":"install":"skip",L=A&&I==="install",ue=typeof c.pythonVersion=="string"&&c.pythonVersion.trim().length>0?c.pythonVersion.trim():void 0,tt=m||c.defaultInstallMethod||"poetry",ye=L?await gt():{poetry:true,pipx:true},xe=L?await yt(ue):{choices:Be.map(k=>({name:k,value:k})),defaultValue:H},ot=mt(tt,ye),nt=[{name:ye.poetry?"\u{1F3AF} Poetry (Recommended - includes virtual env + dependency mgmt)":"\u{1F3AF} Poetry (Recommended) \u2014 not detected (we can install it)",value:"poetry"},{name:"\u{1F4E6} pip with venv (Standard, zero extra tools)",value:"venv"},{name:ye.pipx?"\u{1F527} pipx (Global isolated - RapidKit Core only, no local venv)":"\u{1F527} pipx (Global isolated) \u2014 not detected (we can install it)",value:"pipx"}],R=L?await b$3([{type:"rawlist",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:xe.choices,default:xe.defaultValue},{type:"rawlist",name:"installMethod",message:"How would you like to manage the workspace environment?",choices:nt,default:ot}]):await(async()=>{if(I==="skip")return {pythonVersion:c.pythonVersion||"3.10",installMethod:"venv"};let k=m||c.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return f$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})();return {pythonVersion:c.pythonVersion||"3.10",installMethod:k}})();L&&(console.log(e$1.gray(`
123
- \u{1F4CC} Configuration notes:`)),R.pythonVersion==="3.10"?console.log(e$1.gray(" \u2022 Python 3.10: Latest stable with widespread compatibility")):R.pythonVersion==="3.11"?console.log(e$1.gray(" \u2022 Python 3.11: Newer, faster (3.10-3.11: ~10% speed improvement)")):R.pythonVersion==="3.12"&&console.log(e$1.gray(" \u2022 Python 3.12: Cutting edge, excellent for performance")),R.installMethod==="poetry"?console.log(e$1.gray(" \u2022 Poetry: Dependency management + virtual env (recommended for teams)")):R.installMethod==="venv"?console.log(e$1.gray(" \u2022 venv: Standard library approach, lightweight, zero dependencies")):console.log(e$1.gray(" \u2022 pipx: Global isolated, RapidKit Core only, no local venv")),console.log(""));let ge=ze;if(ge.has(w)){let k=c$1("Creating workspace",{component:"create",phase:"workspace.python-free"}),_=await ie(i);try{await b.ensureDir(i),k.succeed("Directory created"),await J(i,a,"venv",void 0),await X(i,a,"venv",void 0,w),await U(i);let v={"go-only":"Go-only","java-only":"Java-only","dotnet-only":".NET-only","node-only":"Node.js-only",minimal:"Minimal"};if(await b.outputFile(p.join(i,"README.md"),`# ${a}
124
-
125
- Workspai **${v[w]}** workspace.
126
-
127
- ## Quick start
128
-
129
- \`\`\`bash
130
- `+(w==="go-only"?`npx workspai create project gofiber.standard my-api
131
- cd my-api
132
- npx workspai init
133
- npx workspai dev
134
- `:w==="java-only"?`npx workspai create project springboot.standard my-service
135
- cd my-service
136
- npx workspai init
137
- npx workspai dev
138
- `:w==="dotnet-only"?`npx workspai create project dotnet.webapi.clean my-api
139
- cd my-api
140
- npx workspai init
141
- npx workspai dev
142
- `:w==="node-only"?`npx workspai create project nestjs.standard my-app
143
- cd my-app
144
- npx workspai init
145
- npx workspai dev
146
- `:`npx workspai create project
147
- cd <project-name>
148
- npx workspai init
149
- npx workspai dev
150
- `)+"```\n\n## Workspace Intelligence\n\n```bash\nnpx workspai workspace model --json --write\nnpx workspai workspace context --for-agent --json --write\nnpx workspai pipeline --json --strict\n```\n\nDurable evidence is written to `.workspai/reports/`; generated agent instructions start at `AGENTS.md`.\n","utf-8"),await b$4(i,{workspaceName:a,silent:r}),await B(_),n||await Q(i,k,"Initial commit: Workspai workspace"),console.log(e$1.green(`
151
- \u2728 Workspace created!
152
- `)),console.log(e$1.cyan("\u{1F4C2} Location:"),e$1.white(i)),console.log(e$1.cyan(`
153
- \u{1F680} Get started:
154
- `)),console.log(e$1.white(` ${g(i)}`)),w==="go-only"){console.log(e$1.white(" npx workspai create project gofiber.standard my-api")),console.log(e$1.white(" cd my-api")),console.log(e$1.white(" npx workspai init")),console.log(e$1.white(` npx workspai dev
155
- `)),console.log(e$1.gray("\u{1F4A1} No Python required \u2014 Go kits run entirely through the npm package."));try{let{stdout:f}=await execa("go",["version"],{timeout:3e3}),M=f.match(/go version go(\d+\.\d+(?:\.\d+)?)/),C=M?M[1]:"unknown";console.log(e$1.gray(`\u{1F439} Go ${C} detected \u2014 ready for gofiber.standard / gogin.standard projects`));}catch{console.log(e$1.yellow(`
156
- \u26A0\uFE0F Go is not installed \u2014 install it from https://go.dev/dl/`));}}else if(w==="java-only")console.log(e$1.white(" npx workspai create project springboot.standard my-service")),console.log(e$1.white(" cd my-service")),console.log(e$1.white(" npx workspai init")),console.log(e$1.white(` npx workspai dev
157
- `)),console.log(e$1.gray("\u{1F4A1} No Python required \u2014 Spring Boot kit runs through the npm package with Java tooling."));else if(w==="dotnet-only"){console.log(e$1.white(" npx workspai create project dotnet.webapi.clean my-api")),console.log(e$1.white(" cd my-api")),console.log(e$1.white(" npx workspai init")),console.log(e$1.white(` npx workspai dev
158
- `)),console.log(e$1.gray("\u{1F4A1} No Python required \u2014 ASP.NET Core kit runs through the npm package with .NET tooling."));try{let{stdout:f}=await execa("dotnet",["--version"],{timeout:3e3});console.log(e$1.gray(`\u2699\uFE0F .NET SDK ${f.trim()} detected \u2014 ready for ASP.NET Core projects`));}catch{console.log(e$1.yellow(`
159
- \u26A0\uFE0F .NET SDK is not installed \u2014 install it from https://dotnet.microsoft.com/download`));}}else w==="node-only"?(console.log(e$1.white(" npx workspai create project nestjs.standard my-app")),console.log(e$1.white(" cd my-app")),console.log(e$1.white(" npx workspai init")),console.log(e$1.white(` npx workspai dev
160
- `)),console.log(e$1.gray("\u{1F4A1} Node lifecycle commands run through Node tooling. RapidKit Core module commands for module-enabled kits can install the local Python engine later with workspace run init."))):(console.log(e$1.white(" npx workspai create project")),console.log(e$1.white(" cd <project-name>")),console.log(e$1.white(" npx workspai init")),console.log(e$1.white(` npx workspai dev
161
- `)),console.log(e$1.gray("\u{1F4A1} Bootstrap a specific runtime: workspai bootstrap --profile java-only|python-only|node-only|go-only|dotnet-only|polyglot|enterprise")));console.log(e$1.cyan(`
162
- \u{1F4DA} More info:`)),console.log(e$1.gray(" \u2022 Change profile anytime: workspai bootstrap --profile <profile>")),console.log(e$1.gray(" \u2022 View config: cat "+a+"/.workspai-workspace")),console.log(e$1.gray(" \u2022 Check health: workspai doctor")),console.log("");}catch(v){return k.fail("Failed to create workspace"),console.error(e$1.red(`
163
- \u274C Error:`),v),F(_,v)}return}if(x.has(w)&&I==="skip"){let k=c$1("Creating workspace",{component:"create",phase:"workspace.python-engine-skipped"}),_=await ie(i);try{await b.ensureDir(i),k.succeed("Directory created");let v={bootstrapNote:"python-engine-skipped",pythonEngine:"skipped",pythonEngineReason:"user-opted-out"};await J(i,a,"venv",void 0,v),await X(i,a,"venv",void 0,w,v),await U(i),await pe(i,"venv",{pythonEngineSkipped:true});let f={"python-only":"Python-aware",polyglot:"Polyglot",enterprise:"Enterprise"};await b.outputFile(p.join(i,"README.md"),`# ${a}
164
-
165
- Workspai **${f[w]??w}** workspace with Workspace Intelligence enabled and Python engine installation skipped.
166
-
167
- ## Quick start
168
-
169
- \`\`\`bash
170
- npx workspai workspace model --json --write
171
- npx workspai workspace context --for-agent --json --write
172
- npx workspai adopt /path/to/project
173
- npx workspai workspace verify --json
174
- npx workspai pipeline --json --strict
175
- \`\`\`
176
-
177
- Durable evidence is written to \`.workspai/reports/\`; generated agent instructions start at \`AGENTS.md\`.
178
-
179
- ## Add the Python engine later
180
-
181
- \`\`\`bash
182
- npx workspai create project fastapi.standard api --yes
183
- npx workspai workspace run init
184
- \`\`\`
185
- `,"utf-8"),await b$4(i,{workspaceName:a,silent:r}),await B(_),n||await Q(i,k,`Initial commit: Workspai workspace (${w})`),console.log(e$1.green(`
186
- \u2728 Workspace created!
187
- `)),console.log(e$1.cyan("\u{1F4C2} Location:"),e$1.white(i)),console.log(e$1.cyan("\u2699\uFE0F Configuration:")),console.log(e$1.gray(` \u2022 Profile: ${w}`)),console.log(e$1.gray(" \u2022 Python engine: skipped")),console.log(e$1.gray(" \u2022 Workspace Intelligence: enabled")),console.log(e$1.cyan(`
188
- \u{1F680} Get started:
189
- `)),console.log(e$1.white(` ${g(i)}`)),console.log(e$1.white(" npx workspai workspace model --json")),console.log(e$1.white(" npx workspai adopt /path/to/project")),console.log(e$1.white(` npx workspai workspace verify --json
190
- `)),console.log(e$1.cyan(`\u{1F4A1} Add Python-backed kits/modules later:
191
- `)),console.log(e$1.gray(" npx workspai create project fastapi.standard api --yes")),console.log(e$1.gray(` npx workspai workspace run init
192
- `));return}catch(v){return k.fail("Failed to create workspace"),console.error(e$1.red(`
193
- \u274C Error:`),v),F(_,v)}}{let k=N(),_=false;try{await execa(k,["--version"],{timeout:5e3}),_=true;}catch{try{await execa("python",["--version"],{timeout:5e3}),_=true;}catch{_=false;}}if(!_){let v=w,f=pt(w);if(A&&!g$1){console.log(e$1.yellow(`
194
- \u26A0\uFE0F Python 3.10+ is not detected on this system.
195
- `)),console.log(e$1.cyan(`You have 3 options:
196
- `));let{pythonAction:C}=await b$3([{type:"rawlist",name:"pythonAction",message:"What would you like to do?",choices:[{name:"\u{1F4E5} Install Python now (I'll show you the command for your OS)",value:"install"},{name:`\u{1F504} Switch to "${f}" profile (no Python required)`,value:"fallback"},{name:"\u274C Cancel and install Python manually",value:"cancel"}]}]);if(C==="cancel"&&(console.log(e$1.cyan(`
197
- \u{1F4A1} How to install Python:
198
- `)),console.log(e$1.white(" Ubuntu / Debian: sudo apt install python3.10")),console.log(e$1.white(" macOS (Homebrew): brew install python@3.10")),console.log(e$1.white(` Windows: https://python.org/downloads
199
- `)),console.log(e$1.gray(` After installing Python, run: npx workspai ${a}
200
- `)),process.exit(1)),C==="install"){console.log(e$1.cyan(`
201
- \u{1F4A1} Install Python on your system:
202
- `));let $=process.platform;$==="linux"?console.log(e$1.white(` sudo apt update && sudo apt install python3.10 python3.10-venv
203
- `)):$==="darwin"?console.log(e$1.white(` brew install python@3.10
204
- `)):$==="win32"&&(console.log(e$1.white(` Download: https://python.org/downloads
205
- `)),console.log(e$1.white(` Run the installer and check "Add Python to PATH"
206
- `))),console.log(e$1.gray(` After installing, run: npx workspai ${a}
207
- `)),process.exit(0);}if(C==="fallback"&&(console.log(e$1.green(`
208
- \u2705 Switching to "${f}" profile (no Python required).
209
- `)),w=f,ge.has(f))){let $=c$1("Creating workspace",{component:"create",phase:"workspace.python-free"}),ee=await ie(i);try{await b.ensureDir(i),$.succeed("Directory created"),await J(i,a,"venv",void 0),await X(i,a,"venv",void 0,f,{profileRequested:v,bootstrapNote:"python-free-fallback"}),await U(i);let ae={"go-only":"Go-only","java-only":"Java-only","dotnet-only":".NET-only","node-only":"Node.js-only",minimal:"Minimal"};await b.outputFile(p.join(i,"README.md"),`# ${a}
210
-
211
- Workspai **${ae[f]}** workspace (switched from ${v} due to missing Python).
212
-
213
- ## Quick start
214
-
215
- \`\`\`bash
216
- `+(f==="go-only"?`npx workspai create project gofiber.standard my-api
217
- cd my-api
218
- npx workspai init
219
- npx workspai dev
220
- `:f==="java-only"?`npx workspai create project springboot.standard my-service
221
- cd my-service
222
- npx workspai init
223
- npx workspai dev
224
- `:f==="dotnet-only"?`npx workspai create project dotnet.webapi.clean my-api
225
- cd my-api
226
- npx workspai init
227
- npx workspai dev
228
- `:f==="node-only"?`npx workspai create project nestjs.standard my-app
229
- cd my-app
230
- npx workspai init
231
- npx workspai dev
232
- `:`npx workspai create project
233
- cd <project-name>
234
- npx workspai init
235
- npx workspai dev
236
- `)+"```\n","utf-8"),await b$4(i,{workspaceName:a,silent:r}),await B(ee),n||await Q(i,$,`Initial commit: Workspai workspace (${f} profile)`),console.log(e$1.green(`
237
- \u2728 Workspace created with fallback profile!
238
- `)),console.log(e$1.cyan("\u{1F4C2} Location:"),e$1.white(i)),console.log(e$1.cyan(`
239
- \u{1F680} Get started:
240
- `)),console.log(e$1.white(` ${g(i)}`)),console.log(e$1.white(" npx workspai create project")),console.log(e$1.white(" cd <project-name>")),console.log(e$1.white(" npx workspai init")),console.log(e$1.white(` npx workspai dev
241
- `)),console.log(e$1.cyan(`\u{1F4A1} To use Python later:
242
- `)),console.log(e$1.gray(" 1. Install Python 3.10+")),console.log(e$1.gray(` 2. Run: workspai bootstrap --profile ${v}
243
- `)),console.log("");return}catch(ae){return $.fail("Failed to create workspace"),console.error(e$1.red(`
244
- \u274C Error:`),ae),F(ee,ae)}}}else if(console.log(e$1.yellow(`
245
- \u26A0\uFE0F Python not detected. Auto-switching to "${f}" profile (no Python required).
246
- `)),w=f,ge.has(f)){let C=c$1("Creating workspace",{component:"create",phase:"workspace.python-free"}),$=await ie(i);try{await b.ensureDir(i),C.succeed("Directory created"),await J(i,a,"venv",void 0),await X(i,a,"venv",void 0,f,{profileRequested:v,bootstrapNote:"python-free-fallback"}),await U(i),await b$4(i,{workspaceName:a,silent:r}),await B($),n||await Q(i,C,`Initial commit: Workspai workspace (${f})`),console.log(e$1.green(`
247
- \u2728 Workspace created (auto-fallback profile)!
248
- `)),console.log(e$1.cyan("\u{1F4C2} Location:"),e$1.white(i)),console.log(e$1.cyan("\u{1F4E6} Profile:"),e$1.yellow(f)),console.log(e$1.cyan("\u{1F4A1} Reason:"),e$1.gray(`Python not detected; switched from ${v}`)),console.log(e$1.cyan(`
249
- \u{1F680} Get started:
250
- `)),console.log(e$1.white(` ${g(i)}`)),console.log(e$1.white(" npx workspai create project")),console.log(e$1.white(" cd <project-name>")),console.log(e$1.white(" npx workspai init")),console.log(e$1.white(` npx workspai dev
251
- `)),console.log(e$1.cyan(`\u{1F4A1} Add Python later:
252
- `)),console.log(e$1.gray(" 1. Install Python 3.10+")),console.log(e$1.gray(` 2. Run: ${g(i)} && workspai bootstrap --profile ${v}
253
- `)),console.log("");return}catch(ee){return C.fail("Failed to create workspace"),console.error(e$1.red(`
254
- \u274C Error:`),ee),F($,ee)}}}}f$1.step(1,3,"Setting up Workspai environment");let E=c$1("Creating directory",{component:"create",phase:"workspace.directory"}),Re=await ie(i);try{await b.ensureDir(i),E.succeed("Directory created"),E.start("Detecting Python version");let k=null,_=await Qe(R.pythonVersion);if(_)k=await Ne(_),k?(f$1.info(` Detected Python ${k}`),E.succeed(`Python ${k} detected`)):E.warn("Could not detect exact Python version");else {let v=N();k=await Ne(v),k?E.succeed(`Python ${k} detected`):E.warn("Could not detect Python version, proceeding with defaults");}if(R.installMethod==="poetry"&&!await Je()&&(E.warn("Poetry not found \u2014 auto-fallback to pip + venv"),R.installMethod="venv"),await J(i,a,R.installMethod,k||void 0),k&&await dt(i,k),await X(i,a,R.installMethod,k||R.pythonVersion,w||y),await U(i),await Le(i,a),R.installMethod==="poetry")try{await Xe(i,R.pythonVersion,E,r,c,g$1);}catch(v){let f=v?.details||v?.message||String(v);if(f.includes("pyenv")||f.includes("exit status 127")||f.includes("returned non-zero exit status 127")){E.warn("Poetry encountered Python discovery issues, trying venv method"),f$1.debug(`Poetry error (attempting venv fallback): ${f}`);try{await be(i,R.pythonVersion,E,r,c),R.installMethod="venv";}catch(C){throw C}}else throw v}else R.installMethod==="venv"?await be(i,R.pythonVersion,E,r,c):await Ze(i,E,r,c,g$1);if(await pe(i,R.installMethod),await et(i,R.installMethod),E.succeed("Workspai environment ready!"),await b$4(i,{workspaceName:a,silent:r}),await B(Re),o.skipGit||await Q(i,E,"Initial commit: Workspai environment"),console.log(e$1.green(`
255
- \u2728 Workspai environment created successfully!
256
- `)),console.log(e$1.cyan("\u{1F4C2} Location:"),e$1.white(i)),console.log(e$1.cyan("\u2699\uFE0F Configuration:")),console.log(e$1.gray(` \u2022 Profile: ${w}`)),console.log(e$1.gray(` \u2022 Python: ${R.pythonVersion}`)),console.log(e$1.gray(` \u2022 Install method: ${R.installMethod}`)),console.log(e$1.cyan(`
257
- \u{1F680} Get started:
258
- `)),console.log(e$1.white(` ${g(i)}`)),R.installMethod==="poetry"){let v="source $(poetry env info --path)/bin/activate";try{q();let{stdout:f}=await execa("poetry",["--version"]),M=f.match(/Poetry.*?(\d+)\.(\d+)/);M&&(parseInt(M[1])>=2?v="source $(poetry env info --path)/bin/activate":v="poetry shell");}catch{}console.log(e$1.white(` ${v} # Or: poetry run rapidkit`)),console.log(e$1.white(" workspai create # Interactive mode")),console.log(e$1.white(" cd <project-name>")),console.log(e$1.white(" workspai init")),console.log(e$1.white(" workspai dev")),console.log(e$1.gray(`
259
- \u{1F4E6} Why Poetry? Includes dependency management + virtual environment`));}else R.installMethod==="venv"?(console.log(e$1.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(e$1.white(" workspai create # Interactive mode")),console.log(e$1.white(" cd <project-name>")),console.log(e$1.white(" workspai init")),console.log(e$1.white(" workspai dev")),console.log(e$1.gray(`
260
- \u{1F4E6} Why venv? Standard, zero extra tools, lightweight`))):(console.log(e$1.white(" workspai create # Interactive mode")),console.log(e$1.white(" cd <project-name>")),console.log(e$1.white(" workspai init")),console.log(e$1.white(" workspai dev")),console.log(e$1.gray(`
261
- \u{1F4E6} Why pipx? Global isolated install, no local venv`)));console.log(e$1.cyan(`
262
- \u{1F4DA} Next steps:`)),console.log(e$1.gray(" 1. Check README.md for workspace details")),console.log(e$1.gray(" 2. Create your first project: workspai create project")),console.log(e$1.gray(" 3. See all runtimes: workspai list # Shows: fastapi, nestjs, springboot, gofiber, gogin, dotnet")),console.log(e$1.cyan(`
263
- \u{1F4A1} Profile management:`)),console.log(e$1.gray(" \u2022 Add Python? \u2192 workspai bootstrap --profile python-only|polyglot")),console.log(e$1.gray(" \u2022 Add Node.js? \u2192 workspai bootstrap --profile node-only|polyglot")),console.log(e$1.gray(" \u2022 Add Go? \u2192 workspai bootstrap --profile go-only|polyglot")),console.log(e$1.gray(" \u2022 Add .NET? \u2192 workspai bootstrap --profile dotnet-only|polyglot")),console.log(e$1.gray(" \u2022 Full setup? \u2192 workspai bootstrap --profile enterprise")),console.log(e$1.cyan(`
264
- \u{1F4D6} Common commands:`)),console.log(e$1.white(" workspai create - Create a new project (interactive)")),console.log(e$1.white(" workspai list - List available kits")),console.log(e$1.white(" workspai modules - List available modules")),console.log(e$1.white(" workspai doctor - Check workspace health")),console.log(e$1.white(` workspai bootstrap --help - Advanced workspace configuration
265
- `));try{let{stdout:v}=await execa("go",["version"],{timeout:3e3}),f=v.match(/go version go(\d+\.\d+(?:\.\d+)?)/),M=f?f[1]:"unknown";console.log(e$1.gray(`\u{1F439} Go ${M} detected \u2014 ready for gofiber.standard projects`));}catch{console.log(e$1.yellow("\u26A0\uFE0F Go not installed \u2014 needed for gofiber.standard/gogin.standard projects")),console.log(e$1.gray(" Install: https://go.dev/dl/"));}console.log("");}catch(k){return E.fail("Failed to create Workspai environment"),console.error(e$1.red(`
266
- \u274C Error:`),k),F(Re,k)}}async function Qe(t){let o=[];if(!b$5())try{let{stdout:l}=await execa("pyenv",["which","python"]),d=l.trim();d&&o.push(d);}catch{}let n=Number(t.split(".")[1]),s=k(n,10).map(l=>l.command).filter(Boolean);o.push(`python${t}`,...s,...j());let r=[...new Set(o)];for(let l of r)try{let d=l==="py"?["-3","--version"]:["--version"],g=l==="py"?["-3","-c","import sys; sys.exit(0)"]:["-c","import sys; sys.exit(0)"],{stdout:c}=await execa(l,d,{timeout:2e3}),m=c.match(/Python (\d+\.\d+)/)?.[1];if(m&&Z(m,t))return await execa(l,g,{timeout:2e3}),l}catch{continue}return null}async function Xe(t,o,n,s,r,l=false){await ht(n,l),n.start("Finding Python interpreter");let d=await Qe(o);d?(f$1.debug(`Found working Python: ${d}`),n.succeed("Python found")):n.warn("Could not verify Python path, proceeding with default"),n.start("Initializing Poetry project");let g=p.join(t,"pyproject.toml"),m$1=(await b.pathExists(g)?await promises.readFile(g,"utf-8"):"").includes("rapidkit-core");if(m$1)n.succeed("Poetry project initialized");else {await execa("poetry",["init","--no-interaction","--python",`^${o}`],{cwd:t}),n.succeed("Poetry project initialized");let i=await promises.readFile(g,"utf-8");i.includes("[tool.poetry]")?i=i.replace("[tool.poetry]",`[tool.poetry]
267
- package-mode = false`):i.includes("[project]")&&(i.includes("[build-system]")?i=i.replace("[build-system]",`
268
- [tool.poetry]
269
- package-mode = false
270
-
271
- [build-system]`):i+=`
272
-
273
- [tool.poetry]
274
- package-mode = false
275
- `),await promises.writeFile(g,i,"utf-8");}n.start("Configuring Poetry");try{await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:t}),n.succeed("Poetry configured");}catch{n.warn("Could not configure Poetry virtualenvs.in-project");}n.start("Creating virtualenv");let y=d||N(),h=m(p.join(t,".venv"));try{await execa(y,["-m","venv",".venv"],{cwd:t,timeout:6e4}),n.succeed("Virtualenv created");}catch(a){f$1.debug(`python -m venv failed: ${a}`),n.warn("Could not pre-create virtualenv, Poetry will try"),h=d||N();}try{await execa("poetry",["env","use",h||N()],{cwd:t}),f$1.debug(`Poetry env set to: ${h}`);}catch(a){f$1.debug(`Could not set Poetry env: ${a}`);}if(n.start("Installing RapidKit"),m$1&&!s){let a=e$2(r||{}),i=a?await b.pathExists(a):false,x=i&&a?a:"rapidkit-core";a&&!i&&f$1.warn(`WORKSPAI_DEV_PATH/RAPIDKIT_DEV_PATH points to a path that does not exist: ${a}. Falling back to PyPI.`),n.text=i?"Installing RapidKit from local path":"Installing RapidKit from PyPI";let w=false,A=null;for(let I=1;I<=3;I++)try{i||e$3({status:"started",message:"Installing RapidKit from PyPI",installMethod:"poetry",attempt:I,maxAttempts:3}),await execa(h,["-m","pip","install",x,"--quiet"],{cwd:t,timeout:18e4}),w=true,i||e$3({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"poetry",attempt:I,maxAttempts:3});break}catch(L){A=L,f$1.debug(`pip install rapidkit-core attempt ${I} failed: ${L}`),I<3&&(n.text=`Retrying installation (attempt ${I+1}/3)`,await new Promise(ue=>setTimeout(ue,2e3)));}if(!w){let I=A?.stderr||A?.message||"Unknown error";throw f$1.debug(`All pip install attempts failed. Last error: ${I}`),I.includes("Could not find")||I.includes("No matching distribution")?new g$1:new f$2("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
276
- Error: ${I}
277
-
278
- Possible solutions:
279
- 1. Check your internet connection
280
- 2. Try installing manually: cd ${p.basename(t)} && poetry add rapidkit-core
281
- 3. Use venv method instead: npx workspai ${p.basename(t)} --install-method=venv`))}}else {n.text="Syncing Poetry environment";try{await execa("poetry",["install","--no-root"],{cwd:t,timeout:12e4}),n.succeed("Poetry environment synced");}catch(a){f$1.debug(`poetry install --no-root failed: ${a}`),n.warn("Could not sync Poetry environment, proceeding with add command");}if(n.start("Installing RapidKit"),s){let a=e$2(r||{});if(!a)throw new f$2("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));f$1.debug(`Installing from local path: ${a}`),n.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",a],{cwd:t});}else {n.text="Installing RapidKit from PyPI";let a=false,i=null;for(let x=1;x<=3;x++)try{e$3({status:"started",message:"Installing RapidKit from PyPI",installMethod:"poetry",attempt:x,maxAttempts:3}),await execa("poetry",["add","rapidkit-core"],{cwd:t,timeout:6e4*x}),a=true,e$3({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"poetry",attempt:x,maxAttempts:3});break}catch(w){i=w,f$1.debug(`Poetry add attempt ${x} failed: ${w}`),x<3&&(n.text=`Retrying installation (attempt ${x+1}/3)`,await new Promise(A=>setTimeout(A,2e3)));}if(!a){let x=i?.stderr||i?.message||"Unknown error";throw f$1.debug(`All Poetry install attempts failed. Last error: ${x}`),x.includes("Could not find")||x.includes("No matching distribution")?new g$1:new f$2("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
282
- Error: ${x}
283
-
284
- Possible solutions:
285
- 1. Check your internet connection
286
- 2. Try installing manually: cd ${p.basename(t)} && poetry add rapidkit-core
287
- 3. Use venv method instead: npx workspai ${p.basename(t)} --install-method=venv`))}}}n.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:a}=await import('./pythonRapidkitExec-YR7P5LWG.js');if(!await a()&&!s){n.start("Checking optional global pipx installation");let x=await de(n,true);try{n.start("Installing RapidKit globally with pipx for CLI access"),await Y(x,["install","rapidkit-core"]),n.succeed("RapidKit installed globally");}catch(w){n.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),f$1.debug(`pipx install failed: ${w}`);}}}catch(a){n.succeed("Skipped optional global pipx installation"),f$1.debug(`Global install check skipped: ${a}`);}}async function be(t,o,n,s,r,l=false){n.start(`Checking Python ${o}`);let d=N();try{let{stdout:c}=await execa(d,["--version"]),m=c.match(/Python (\d+\.\d+)/)?.[1];if(m&&!Z(m,o))throw new b$6(o,m);n.succeed(`Python ${m} found`);}catch(c){throw c instanceof b$6?c:new b$6(o)}n.start("Creating virtual environment");try{await execa(d,["-m","venv",".venv"],{cwd:t}),n.succeed("Virtual environment created");}catch(c){if(n.fail("Failed to create virtual environment"),(y=>typeof y=="object"&&y!==null&&"stdout"in y&&typeof y.stdout=="string")(c)&&c.stdout.includes("ensurepip is not")){let y=c.stdout.match(/apt install (python[\d.]+-venv)/),h=y?y[1]:"python3-venv";throw new f$2("Python venv module not available",new Error(`Virtual environment creation failed.
288
-
289
- On Debian/Ubuntu systems, install the venv package:
290
- sudo apt install ${h}
291
-
292
- Or use Poetry instead (recommended):
293
- npx workspai create workspace ${p.basename(t)} --yes --install-method poetry`))}throw new f$2("Virtual environment creation",c instanceof Error?c:new Error(String(c)))}n.start("Installing RapidKit");let g=m(p.join(t,".venv"));if(await execa(g,["-m","pip","install","--upgrade","pip"],{cwd:t}),s){let c=e$2(r||{});if(!c)throw new f$2("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));f$1.debug(`Installing from local path: ${c}`),n.text="Installing RapidKit from local path (test mode)",await execa(g,["-m","pip","install","-e",c],{cwd:t});}else {n.text="Installing RapidKit from PyPI";let c=false,m$1=null;for(let y=1;y<=3;y++)try{e$3({status:"started",message:"Installing RapidKit from PyPI",installMethod:"venv",attempt:y,maxAttempts:3}),await execa(g,["-m","pip","install","rapidkit-core"],{cwd:t,timeout:6e4*y}),c=true,e$3({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"venv",attempt:y,maxAttempts:3});break}catch(h){m$1=h,f$1.debug(`pip install attempt ${y} failed: ${h}`),y<3&&(n.text=`Retrying installation (attempt ${y+1}/3)`,await new Promise(a=>setTimeout(a,2e3)));}if(!c){let y=m$1?.stderr||m$1?.message||"Unknown error";throw f$1.debug(`All pip install attempts failed. Last error: ${y}`),y.includes("Could not find")||y.includes("No matching distribution")?new g$1:new f$2("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
294
- Error: ${y}
295
-
296
- Possible solutions:
297
- 1. Check your internet connection
298
- 2. Try installing manually: cd ${p.basename(t)} && ${m(".venv")} -m pip install rapidkit-core
299
- 3. Use Poetry instead: npx workspai ${p.basename(t)} --install-method=poetry`))}}n.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await import('./pythonRapidkitExec-YR7P5LWG.js');if(!await c()&&!s){n.start("Checking optional global pipx installation");let y=await de(n,true);try{n.start("Installing RapidKit globally with pipx for CLI access"),await Y(y,["install","rapidkit-core"]),n.succeed("RapidKit installed globally");}catch(h){n.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),f$1.debug(`pipx install failed: ${h}`);}}}catch(c){n.succeed("Skipped optional global pipx installation"),f$1.debug(`Global install check skipped: ${c}`);}}async function Ze(t,o,n,s,r=false){if(!n)try{let{checkRapidkitCoreVersionCompatible:d}=await import('./pythonRapidkitExec-YR7P5LWG.js'),g=await d();if(g.isCompatible){o.succeed(`RapidKit ${g.installedVersion??""} already compatible globally; skipping pipx installation`),await b.outputFile(p.join(t,".rapidkit-global"),`RapidKit already available globally (version ${g.installedVersion??"unknown"}) and satisfies expected constraint ${g.expectedConstraint??"n/a"}; workspace will reuse the existing installation
300
- `,"utf-8");return}g.reason==="constraint-missing"?o.warn('Version-aware global reuse skipped: no explicit rapidkit-core version constraint found. Set RAPIDKIT_CORE_PYTHON_PACKAGE (example: RAPIDKIT_CORE_PYTHON_PACKAGE="rapidkit-core>=0.4.0,<0.9.0") to enable version-aware reuse. Proceeding with pipx install/upgrade.'):g.reason==="constraint-unsupported"&&o.warn('Version-aware global reuse skipped: RAPIDKIT_CORE_PYTHON_PACKAGE uses an unsupported spec (path/url/git). Use a version range instead (example: RAPIDKIT_CORE_PYTHON_PACKAGE="rapidkit-core==0.4.0" or "rapidkit-core>=0.4.0,<0.9.0"). Proceeding with pipx install/upgrade.'),f$1.debug(`Global RapidKit install is not reusable via version-aware policy (reason=${g.reason}, installed=${g.installedVersion??"unknown"}, expected=${g.expectedConstraint??"none"}). Proceeding with pipx install/upgrade.`);}catch(d){f$1.debug(`Global RapidKit version-aware check failed before pipx install: ${d}`);}let l=await de(o,r);if(o.start("Installing RapidKit globally with pipx"),n){let d=e$2(s||{});if(!d)throw new f$2("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));f$1.debug(`Installing from local path: ${d}`),o.text="Installing RapidKit from local path (test mode)",await Y(l,["install","-e",d]);}else {o.text="Installing RapidKit from PyPI",e$3({status:"started",message:"Installing RapidKit from PyPI",installMethod:"pipx"});try{await Y(l,["install","rapidkit-core"]),e$3({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"pipx"});}catch(d){try{o.text="RapidKit already installed globally, upgrading to match expected version",await Y(l,["upgrade","rapidkit-core"]),e$3({status:"succeeded",message:"RapidKit upgraded from PyPI",installMethod:"pipx"});}catch(g){throw f$1.debug(`pipx install/upgrade failed: install=${d}, upgrade=${g}`),new g$1}}}o.succeed("RapidKit installed globally"),await b.outputFile(p.join(t,".rapidkit-global"),`RapidKit installed globally with pipx
301
- `,"utf-8");}async function qt(t,o){let{skipGit:n=false,installPythonEngine:s=false,testMode:r=false,userConfig:l={},yes:d=false,installMethod:g,pythonVersion:c="3.10"}=o||{},m="venv";if(s){let a=g||l.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return f$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})();m=a==="poetry"&&!await Je()?"venv":a;}let y=c$1("Registering workspace",{component:"create",phase:"workspace.register"}),h=await lt(t);try{let a=p.basename(t),i=s?void 0:{bootstrapNote:"python-engine-skipped",pythonEngine:"skipped",pythonEngineReason:"project-workspace-foundation"};await J(t,a,m,s?c:void 0,i),await U(t),await X(t,a,m,s?c:void 0,o?.profile??"minimal",i),s?m==="poetry"?(await Le(t,a),await Xe(t,c,y,r,l,d)):m==="venv"?await be(t,c,y,r,l):await Ze(t,y,r,l,d):await pe(t,m,{pythonEngineSkipped:true}),s&&(await pe(t,m),await et(t,m)),y.succeed(s?"Workspace registered":"Workspace registered (Python engine skipped)"),await b$4(t,{workspaceName:p.basename(t),silent:r}),await B(h),n||await Q(t,y,"Initial commit: Workspai workspace");}catch(a){return y.fail("Failed to register workspace"),F(h,a)}}async function et(t,o){let n=o==="poetry"?`source $(poetry env info --path)/bin/activate
302
- # Or simply use: poetry run rapidkit <command>`:o==="venv"?"source .venv/bin/activate # On Windows: .venv\\Scripts\\activate":"N/A (globally installed)",s=o==="poetry"?`# No activation needed (recommended):
303
- ./rapidkit --help
304
- # or:
305
- poetry run rapidkit --help`:o==="venv"?`# No activation needed (recommended):
306
- ./rapidkit --help
307
- # or direct:
308
- ./.venv/bin/rapidkit --help`:`# Optional: use the local launcher
309
- ./rapidkit --help
310
- # (pipx installs may require Poetry/venv to be present in this folder)`,r=b$5()?"python --version (or: py -3 --version)":"python3 --version (or: python --version)",l=`# Workspai Workspace
311
-
312
- This directory contains a Workspai development environment.
313
-
314
- ## Installation Method
315
-
316
- **${o==="poetry"?"Poetry":o==="venv"?"Python venv + pip":"pipx (global)"}**
317
-
318
- ## Getting Started
319
-
320
- ### 0. Run Without Activation (Recommended)
321
-
322
- This workspace includes a local launcher script so you can run the Python Core CLI without activating the environment:
323
-
324
- \`\`\`bash
325
- ${s}
326
- \`\`\`
327
-
328
- ### 1. Activate Environment
329
-
330
- \`\`\`bash
331
- ${n}
332
- \`\`\`
333
-
334
- ### 2. Create Your First Project
335
-
336
- \`\`\`bash
337
- # Interactive mode (recommended):
338
- workspai create
339
- # Follow the prompts to choose kit and project name
340
-
341
- # Or specify directly:
342
- workspai create project fastapi.standard my-project
343
-
344
- # Advanced / Python Core only:
345
- poetry run rapidkit --help
346
- \`\`\`
347
-
348
- Interactive mode will guide you through selecting a kit and configuring your project.
349
-
350
- ### 3. Navigate and Run
351
-
352
- \`\`\`bash
353
- cd my-project
354
- # Install dependencies (preferred):
355
- workspai init
356
-
357
- # Run the server (project-aware):
358
- workspai dev
359
-
360
- # Direct Python Core entrypoint (advanced / only when rapidkit-core is installed in Poetry):
361
- poetry run rapidkit dev
362
-
363
- # Or manually:
364
- uvicorn src.main:app --reload
365
- \`\`\`
366
-
367
- ### 4. Add Modules (Optional)
368
-
369
- \`\`\`bash
370
- # Add common modules to your project:
371
- workspai add module settings
372
- workspai add module logging
373
- workspai add module database
374
-
375
- # List available modules:
376
- workspai modules list
377
- \`\`\`
378
-
379
- ## Available Commands
380
-
381
- - \`workspai create\` - Create a new project (interactive)
382
- - \`workspai create project <kit> <name>\` - Create project with specific kit
383
- - \`workspai dev\` - Run development server
384
- - \`workspai add module <name>\` - Add a module (e.g., \`workspai add module settings\`)
385
- - \`workspai list\` - List available kits
386
- - \`workspai modules\` - List available modules
387
- - \`workspai upgrade\` - Upgrade project templates
388
- - \`workspai doctor\` - Check system requirements
389
- - \`workspai --help\` - Show all commands
390
-
391
- ## Workspace Intelligence
392
-
393
- \`\`\`bash
394
- workspai workspace model --json --write
395
- workspai workspace context --for-agent --json --write
396
- workspai pipeline --json --strict
397
- \`\`\`
398
-
399
- Durable evidence is written to \`.workspai/reports/\`; generated agent instructions start at \`AGENTS.md\`.
400
-
401
- ## Workspai Documentation
402
-
403
- For full documentation, visit: [Workspai Docs](https://workspai.dev/docs)
404
-
405
- ## Workspace Structure
406
-
407
- \`\`\`
408
- ${o==="venv"?".venv/ # Python virtual environment":""}
409
- ${o==="poetry"?"pyproject.toml # Poetry configuration":""}
410
- my-project/ # Your Workspai projects go here
411
- README.md # This file
412
- \`\`\`
413
-
414
- ## Troubleshooting
415
-
416
- If you encounter issues:
417
-
418
- 1. Ensure Python 3.10+ is installed: \`${r}\`
419
- 2. Check Workspai installation: \`workspai --version\`
420
- 3. Run diagnostics: \`workspai doctor\`
421
- 4. Visit Workspai documentation or GitHub issues
422
- `;await promises.writeFile(p.join(t,"README.md"),l,"utf-8");}async function kt(t,o,n){let s=c$1("Creating demo workspace",{component:"create",phase:"workspace.demo"});try{await b.ensureDir(t),s.succeed("Directory created"),s.start("Setting up demo kit generator");let r=JSON.stringify({name:`${o}-workspace`,version:"1.0.0",private:true,description:"Workspai demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(p.join(t,"package.json"),r,"utf-8"),await promises.writeFile(p.join(t,"generate-demo.js"),`#!/usr/bin/env node
423
- /**
424
- * Demo Kit Generator - Create FastAPI demo projects
425
- *
426
- * This workspace contains bundled Workspai templates that you can use
427
- * to generate demo projects without installing Python RapidKit Core.
428
- *
429
- * Usage:
430
- * npm run generate <project-name>
431
- * node generate-demo.js <project-name>
432
- *
433
- * Example:
434
- * npm run generate my-api
435
- */
436
-
437
- const fs = require('fs');
438
- const path = require('path');
439
- const readline = require('readline');
440
-
441
- const projectName = process.argv[2];
442
-
443
- if (!projectName) {
444
- console.error('\\n\u274C Please provide a project name');
445
- console.log('\\nUsage: npm run generate <project-name>\\n');
446
- console.log('Example: npm run generate my-api\\n');
447
- process.exit(1);
448
- }
449
-
450
- const rl = readline.createInterface({
451
- input: process.stdin,
452
- output: process.stdout
453
- });
454
-
455
- function ask(question, defaultValue) {
456
- return new Promise((resolve) => {
457
- rl.question(\`\${question} (\${defaultValue}): \`, (answer) => {
458
- resolve(answer || defaultValue);
459
- });
460
- });
461
- }
462
-
463
- async function main() {
464
- const targetPath = path.join(process.cwd(), projectName);
465
-
466
- if (fs.existsSync(targetPath)) {
467
- console.error(\`\\n\u274C Directory "\${projectName}" already exists\\n\`);
468
- process.exit(1);
469
- }
470
-
471
- console.log(\`\\n\u{1F680} Creating FastAPI project: \${projectName}\\n\`);
472
-
473
- const snakeName = projectName.replace(/-/g, '_').toLowerCase();
474
- const project_name = await ask('Project name (snake_case)', snakeName);
475
- const author = await ask('Author name', process.env.USER || 'Workspai User');
476
- const description = await ask('Description', 'FastAPI service generated with Workspai');
477
-
478
- rl.close();
479
-
480
- // Create project structure
481
- const dirs = [
482
- '',
483
- 'src',
484
- 'src/routing',
485
- 'src/modules',
486
- 'tests',
487
- '.workspai'
488
- ];
489
-
490
- for (const dir of dirs) {
491
- fs.mkdirSync(path.join(targetPath, dir), { recursive: true });
492
- }
493
-
494
- // Template files with content
495
- const files = {
496
- 'src/__init__.py': '"""' + project_name + ' package."""\\n',
497
- 'src/modules/__init__.py': '"""Modules package."""\\n',
498
- 'tests/__init__.py': '"""Tests package."""\\n',
499
- 'src/main.py': \`"""\${project_name} application entrypoint."""
500
-
501
- from __future__ import annotations
502
-
503
- from contextlib import asynccontextmanager
504
- from typing import AsyncIterator
505
-
506
- from fastapi import FastAPI
507
- from fastapi.middleware.cors import CORSMiddleware
508
-
509
- from .routing import api_router
510
-
511
-
512
- @asynccontextmanager
513
- async def lifespan(app: FastAPI) -> AsyncIterator[None]:
514
- """Application lifespan context manager for startup/shutdown events."""
515
- yield
516
-
517
-
518
- app = FastAPI(
519
- title="\${project_name}",
520
- description="\${description}",
521
- version="0.1.0",
522
- docs_url="/docs",
523
- redoc_url="/redoc",
524
- lifespan=lifespan,
525
- )
526
-
527
- app.add_middleware(
528
- CORSMiddleware,
529
- allow_origins=["*"],
530
- allow_credentials=True,
531
- allow_methods=["*"],
532
- allow_headers=["*"],
533
- )
534
-
535
- app.include_router(api_router, prefix="/api")
536
-
537
-
538
- if __name__ == "__main__":
539
- import uvicorn
540
- uvicorn.run("src.main:app", host="0.0.0.0", port=8001, reload=True)
541
- \`,
542
- 'src/routing/__init__.py': \`"""API routing configuration."""
543
-
544
- from fastapi import APIRouter
545
-
546
- from .health import router as health_router
547
-
548
- api_router = APIRouter()
549
-
550
- api_router.include_router(health_router)
551
- \`,
552
- 'src/routing/health.py': \`"""Health check endpoints."""
553
-
554
- from __future__ import annotations
555
-
556
- from fastapi import APIRouter
557
-
558
- router = APIRouter(prefix="/health", tags=["health"])
559
-
560
-
561
- @router.get("/", summary="Health check")
562
- async def heartbeat() -> dict[str, str]:
563
- """Return basic service heartbeat."""
564
- return {"status": "ok"}
565
- \`,
566
- 'src/cli.py': \`"""CLI commands for \${project_name}."""
567
-
568
- import subprocess
569
- import sys
570
- from pathlib import Path
571
-
572
-
573
- def dev():
574
- """Start development server with hot reload."""
575
- print("\u{1F680} Starting development server...")
576
- subprocess.run([
577
- sys.executable, "-m", "uvicorn",
578
- "src.main:app", "--reload",
579
- "--host", "0.0.0.0", "--port", "8000"
580
- ])
581
-
582
-
583
- def start():
584
- """Start production server."""
585
- print("\u26A1 Starting production server...")
586
- subprocess.run([
587
- sys.executable, "-m", "uvicorn",
588
- "src.main:app",
589
- "--host", "0.0.0.0", "--port", "8000"
590
- ])
591
-
592
-
593
- def test():
594
- """Run tests."""
595
- print("\u{1F9EA} Running tests...")
596
- subprocess.run([sys.executable, "-m", "pytest", "-q"])
597
-
598
-
599
- if __name__ == "__main__":
600
- if len(sys.argv) < 2:
601
- print("Usage: python -m src.cli <command>")
602
- print("Commands: dev, start, test")
603
- sys.exit(1)
604
-
605
- cmd = sys.argv[1]
606
- if cmd == "dev":
607
- dev()
608
- elif cmd == "start":
609
- start()
610
- elif cmd == "test":
611
- test()
612
- else:
613
- print(f"Unknown command: {cmd}")
614
- sys.exit(1)
615
- \`,
616
- 'pyproject.toml': \`[tool.poetry]
617
- name = "\${project_name}"
618
- version = "0.1.0"
619
- description = "\${description}"
620
- authors = ["\${author}"]
621
- license = "MIT"
622
- readme = "README.md"
623
- package-mode = false
624
-
625
- [tool.poetry.dependencies]
626
- python = "^3.10"
627
- fastapi = "^0.128.0"
628
- uvicorn = {extras = ["standard"], version = "^0.40.0"}
629
- pydantic = "^2.12.5"
630
- pydantic-settings = "^2.12.0"
631
-
632
- [tool.poetry.group.dev.dependencies]
633
- pytest = "^9.0.2"
634
- pytest-asyncio = "^1.3.0"
635
- pytest-cov = "^7.0.0"
636
- httpx = "^0.28.1"
637
- black = "^25.12.0"
638
- ruff = "^0.14.10"
639
- mypy = "^1.19.1"
640
-
641
- [tool.poetry.scripts]
642
- dev = "src.cli:dev"
643
- start = "src.cli:start"
644
- test = "src.cli:test"
645
-
646
- [build-system]
647
- requires = ["poetry-core"]
648
- build-backend = "poetry.core.masonry.api"
649
-
650
- [tool.pytest.ini_options]
651
- asyncio_mode = "auto"
652
- testpaths = ["tests"]
653
-
654
- [tool.ruff]
655
- line-length = 100
656
- target-version = "py311"
657
-
658
- [tool.black]
659
- line-length = 100
660
- target-version = ["py311"]
661
- \`,
662
- 'README.md': \`# \${project_name}
663
-
664
- \${description}
665
-
666
- ## Quick start
667
-
668
- \\\`\\\`\\\`bash
669
- npx workspai init # Install dependencies
670
- npx workspai dev # Start dev server
671
- \\\`\\\`\\\`
672
-
673
- ## Available commands
674
-
675
- \\\`\\\`\\\`bash
676
- npx workspai init # \u{1F527} Install dependencies
677
- npx workspai dev # \u{1F680} Start development server with hot reload
678
- npx workspai start # \u26A1 Start production server
679
- npx workspai test # \u{1F9EA} Run tests
680
- npx workspai help # \u{1F4DA} Show available commands
681
- \\\`\\\`\\\`
682
-
683
- ## Project layout
684
-
685
- \\\`\\\`\\\`
686
- \${project_name}/
687
- \u251C\u2500\u2500 src/
688
- \u2502 \u251C\u2500\u2500 main.py # FastAPI application
689
- \u2502 \u251C\u2500\u2500 cli.py # CLI commands
690
- \u2502 \u251C\u2500\u2500 routing/ # API routes
691
- \u2502 \u2514\u2500\u2500 modules/ # Module system
692
- \u251C\u2500\u2500 tests/ # Test suite
693
- \u251C\u2500\u2500 pyproject.toml # Poetry configuration
694
- \u2514\u2500\u2500 README.md
695
- \\\`\\\`\\\`
696
- \`,
697
- '.workspai/project.json': JSON.stringify({
698
- kit_name: "fastapi.standard",
699
- profile: "fastapi/standard",
700
- created_at: new Date().toISOString(),
701
- created_by: "workspai-cli-fallback",
702
- workspai_version: "npm-demo",
703
- rapidkit_version: "npm-demo"
704
- }, null, 2),
705
- '.workspai/cli.py': \`#!/usr/bin/env python3
706
- """RapidKit Core wrapper for demo projects."""
707
-
708
- import subprocess
709
- import sys
710
- from pathlib import Path
711
-
712
-
713
- def dev(port=8000, host="0.0.0.0"):
714
- """Start development server."""
715
- print("\u{1F680} Starting development server with hot reload...")
716
- subprocess.run([
717
- sys.executable, "-m", "uvicorn",
718
- "src.main:app", "--reload",
719
- "--host", host, "--port", str(port)
720
- ])
721
-
722
-
723
- def start(port=8000, host="0.0.0.0"):
724
- """Start production server."""
725
- print("\u26A1 Starting production server...")
726
- subprocess.run([
727
- sys.executable, "-m", "uvicorn",
728
- "src.main:app",
729
- "--host", host, "--port", str(port)
730
- ])
731
-
732
-
733
- def init():
734
- """Install dependencies."""
735
- print("\u{1F4E6} Installing dependencies...")
736
- subprocess.run(["poetry", "install"])
737
-
738
-
739
- def test():
740
- """Run tests."""
741
- print("\u{1F9EA} Running tests...")
742
- subprocess.run([sys.executable, "-m", "pytest", "-q"])
743
-
744
-
745
- def help_cmd():
746
- """Show help."""
747
- print("\u{1F4DA} Available commands:")
748
- print(" init - Install dependencies")
749
- print(" dev - Start dev server")
750
- print(" start - Start production server")
751
- print(" test - Run tests")
752
-
753
-
754
- if __name__ == "__main__":
755
- cmd = sys.argv[1] if len(sys.argv) > 1 else "help"
756
- cmds = {"dev": dev, "start": start, "init": init, "test": test, "help": help_cmd}
757
- cmds.get(cmd, help_cmd)()
758
- \`,
759
- '.workspai/rapidkit': '#!/usr/bin/env bash\\n# Local RapidKit Core launcher for demo projects\\nset -euo pipefail\\nSCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"\\nROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"\\ncd "$ROOT_DIR"\\n\\nif [ -f "pyproject.toml" ]; then\\n if command -v poetry >/dev/null 2>&1; then\\n exec poetry run python "$SCRIPT_DIR/cli.py" "$@"\\n fi\\nfi\\n\\necho "Poetry not found. Install with: pip install poetry"\\nexit 1\\n',
760
- '.gitignore': \`# Python
761
- __pycache__/
762
- *.py[cod]
763
- *.so
764
- .Python
765
- build/
766
- dist/
767
- *.egg-info/
768
-
769
- # Virtual environments
770
- .venv/
771
- venv/
772
-
773
- # IDEs
774
- .vscode/
775
- .idea/
776
-
777
- # OS
778
- .DS_Store
779
-
780
- # Project
781
- .env
782
- .env.local
783
- \`
784
- };
785
-
786
- for (const [filePath, content] of Object.entries(files)) {
787
- fs.writeFileSync(path.join(targetPath, filePath), content);
788
- }
789
-
790
- // Make scripts executable
791
- try {
792
- fs.chmodSync(path.join(targetPath, '.workspai/cli.py'), 0o755);
793
- fs.chmodSync(path.join(targetPath, '.workspai/rapidkit'), 0o755);
794
- } catch (e) {
795
- // Ignore on Windows
796
- }
797
-
798
- console.log(\`
799
- \u2728 Demo project created successfully!
800
-
801
- \u{1F4C2} Project: \${targetPath}
802
-
803
- \u{1F680} Get started:
804
- cd \${projectName}
805
- npx workspai init # Install dependencies
806
- npx workspai dev # Start dev server
807
-
808
- \u{1F4DA} Available commands:
809
- npx workspai init # \u{1F527} Install dependencies
810
- npx workspai dev # \u{1F680} Start dev server with hot reload
811
- npx workspai start # \u26A1 Start production server
812
- npx workspai test # \u{1F9EA} Run tests
813
- npx workspai help # \u{1F4DA} Show help
814
-
815
- \u{1F4A1} For Python engine features: pipx install rapidkit-core
816
- \`);
817
- }
818
-
819
- main().catch(console.error);
820
- `,"utf-8");try{await execa("chmod",["+x",p.join(t,"generate-demo.js")]);}catch{}let d=`# Workspai Demo Workspace
821
-
822
- Welcome to your Workspai demo workspace! This environment lets you generate FastAPI demo projects using bundled Workspai templates, without needing to install Python RapidKit Core.
823
-
824
- ## \u{1F680} Quick Start
825
-
826
- ### Generate Your First Demo Project
827
-
828
- \`\`\`bash
829
- # Generate a demo project:
830
- node generate-demo.js my-api
831
-
832
- # Navigate to the project:
833
- cd my-api
834
-
835
- # Install dependencies:
836
- workspai init
837
-
838
- # Run the development server:
839
- workspai dev
840
- \`\`\`
841
-
842
- Your API will be available at \`http://localhost:8000\`
843
-
844
- ## \u{1F4E6} Generate Multiple Projects
845
-
846
- You can create multiple demo projects in this workspace:
847
-
848
- \`\`\`bash
849
- node generate-demo.js api-service
850
- node generate-demo.js auth-service
851
- node generate-demo.js data-service
852
- \`\`\`
853
-
854
- Each project is independent and has its own dependencies.
855
-
856
- ## \u{1F3AF} What's Included
857
-
858
- Each generated demo project contains:
859
-
860
- - **FastAPI Application** - Modern async web framework
861
- - **Routing System** - Organized API routes
862
- - **Module System** - Extensible module architecture
863
- - **CLI Commands** - Built-in command system
864
- - **Testing Setup** - pytest configuration
865
- - **Poetry Configuration** - Dependency management
866
-
867
- ## \u{1F4DA} Next Steps
868
-
869
- 1. **Explore the Generated Code** - Check out \`src/main.py\` and \`src/routing/\`
870
- 2. **Add Routes** - Create new endpoints in \`src/routing/\`
871
- 3. **Install RapidKit Core** - For Python engine features: \`pipx install rapidkit-core\`
872
- 4. **Read the Documentation** - Visit [Workspai Docs](https://workspai.dev/docs)
873
-
874
- ## \u26A0\uFE0F Demo Mode Limitations
875
-
876
- This is a demo workspace with:
877
- - \u2705 Pre-built FastAPI templates
878
- - \u2705 Project generation without Python RapidKit Core
879
- - \u274C No Python RapidKit Core module commands (\`rapidkit add module\`)
880
- - \u274C No interactive module system
881
-
882
- For Python engine features, install RapidKit Core:
883
-
884
- \`\`\`bash
885
- pipx install rapidkit-core
886
- \`\`\`
887
-
888
- ## \u{1F6E0}\uFE0F Workspace Structure
889
-
890
- \`\`\`
891
- ${o}/
892
- \u251C\u2500\u2500 generate-demo.js # Demo project generator
893
- \u251C\u2500\u2500 README.md # This file
894
- \u2514\u2500\u2500 my-api/ # Your generated projects go here
895
- \`\`\`
896
-
897
- ## \u{1F4A1} Tips
898
-
899
- - Run \`node generate-demo.js --help\` for more options (coming soon)
900
- - Each project can have different configurations
901
- - Demo projects are production-ready FastAPI applications
902
- - You can copy and modify templates as needed
903
-
904
- ---
905
-
906
- **Generated with Workspai** | [GitHub](https://github.com/chistiq/workspai)
907
- `;if(await promises.writeFile(p.join(t,"README.md"),d,"utf-8"),s.succeed("Demo workspace setup complete"),!n)if(await Fe(t))s.warn("Git initialization skipped because target is already inside a git worktree");else {s.start("Initializing git repository");try{await execa("git",["init"],{cwd:t,env:a$1()}),await b.outputFile(p.join(t,".gitignore"),`# Dependencies
908
- node_modules/
909
-
910
- # Generated projects
911
- */
912
- !generate-demo.js
913
- !README.md
914
-
915
- # Python
916
- __pycache__/
917
- *.pyc
918
- .venv/
919
- .env
920
- `,"utf-8"),await execa("git",["add","."],{cwd:t,env:a$1()}),await execa("git",["commit","-m","Initial commit: Demo workspace"],{cwd:t,env:a$1()}),s.succeed("Git repository initialized");}catch{s.warn("Could not initialize git repository");}}console.log(e$1.green(`
921
- \u2728 Demo workspace created successfully!
922
- `)),console.log(e$1.cyan("\u{1F4C2} Location:"),e$1.white(t)),console.log(e$1.cyan(`\u{1F680} Get started:
923
- `)),console.log(e$1.white(` ${g(t)}`)),console.log(e$1.white(" node generate-demo.js my-api")),console.log(e$1.white(" cd my-api")),console.log(e$1.white(" workspai init")),console.log(e$1.white(" workspai dev")),console.log(),console.log(e$1.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For Python engine features:"),console.log(e$1.cyan(" pipx install rapidkit-core")),console.log();}catch(r){throw s.fail("Failed to create demo workspace"),r}}async function vt(t,o,n,s,r,l,d,g$1=false,c=false){if(console.log(e$1.cyan(`
924
- \u{1F50D} Dry-run mode - what would be created:
925
- `)),console.log(e$1.white("\u{1F4C2} Workspace path:"),t),console.log(e$1.white("\u{1F4DB} Name:"),e$1.cyan(o)),n)console.log(e$1.white("\u{1F4E6} Type:"),"Demo environment"),console.log(e$1.white(`
926
- \u{1F4DD} Files to create:`)),console.log(e$1.gray(" - package.json")),console.log(e$1.gray(" - generate-demo.js (project generator)")),console.log(e$1.gray(" - README.md")),console.log(e$1.gray(" - .gitignore")),console.log(e$1.white(`
927
- \u{1F3AF} Capabilities:`)),console.log(e$1.gray(" - Generate FastAPI/NestJS demo projects")),console.log(e$1.gray(" - No Python RapidKit installation required")),console.log(e$1.gray(" - Bundled templates"));else {let m=r||"minimal",y=l,h=d,i=new Set(["python-only","polyglot","enterprise"]).has(m);console.log(e$1.white("\u{1F4E6} Profile:"),e$1.cyan(m)),console.log(e$1.white("\u{1F4DD} Configuration:")),i?(console.log(e$1.gray(` - Python version: ${h}`)),console.log(e$1.gray(` - Python engine: ${c?"Skipped":`Install with ${y}`}`)),console.log(e$1.gray(` - Git init: ${g$1?"No":"Yes"}`))):(console.log(e$1.gray(" - Python-free profile (no Python needed)")),console.log(e$1.gray(` - Git init: ${g$1?"No":"Yes"}`))),console.log(e$1.white(`
928
- \u{1F4CB} Files to create:`)),console.log(e$1.gray(" - .workspai-workspace (workspace marker)")),console.log(e$1.gray(" - .workspai/ (workspace config directory)")),console.log(e$1.gray(" - README.md")),console.log(e$1.gray(" - .gitignore")),i&&!c&&console.log(e$1.gray(` - ${y==="poetry"?"pyproject.toml + poetry.lock":".venv/ (virtual environment)"}`)),console.log(e$1.white(`
929
- \u2699\uFE0F Environment setup:`)),i&&c?console.log(e$1.gray(" - Python engine setup skipped")):i&&console.log(y==="poetry"?e$1.gray(" - Poetry virtual environment created (recommended, includes dependency management)"):y==="venv"?e$1.gray(" - Python venv created in .venv/ (standard, zero extra tools)"):e$1.gray(" - Global pipx install (isolated, not local to workspace)")),console.log(e$1.white(`
930
- \u{1F680} Next steps:`)),console.log(e$1.gray(` 1. ${g(t)}`)),console.log(e$1.gray(" 2. npx workspai create project")),console.log(e$1.gray(" 3. npx workspai init")),console.log(e$1.gray(" 4. npx workspai dev")),console.log(e$1.white(`
931
- \u{1F4A1} Learn more:`)),console.log(e$1.gray(" \u2022 Change profile later: workspai bootstrap --profile <profile>")),console.log(e$1.gray(" \u2022 Profile options: minimal|java-only|python-only|node-only|go-only|dotnet-only|polyglot|enterprise")),console.log(e$1.gray(" \u2022 Help: npx workspai --help"));}console.log(e$1.white(`
932
- \u2728 To proceed: remove --dry-run flag
933
- `));}export{Ve as a,Ut as b,ze as c,pt as d,pe as e,Yt as f,qt as g};