workspai 0.73.0 → 0.74.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 (102) hide show
  1. package/contracts/runtime-command-surface.v1.json +7 -3
  2. package/dist/analyze-IA33T6MY.js +1 -0
  3. package/dist/{artifact-remediation-plan-WDK5ISRU.js → artifact-remediation-plan-OVTQM7HN.js} +1 -1
  4. package/dist/autopilot-release-T327V7QK.js +1 -0
  5. package/dist/chunk-252EKOR6.js +2 -0
  6. package/dist/{chunk-3GO7BJ5J.js → chunk-4JJDDL3X.js} +1 -1
  7. package/dist/chunk-5EVBOUYW.js +3 -0
  8. package/dist/chunk-5Y4YRYZI.js +12 -0
  9. package/dist/{chunk-J44PN2FX.js → chunk-773WUMFU.js} +15 -15
  10. package/dist/{chunk-FRH7AIGY.js → chunk-BTJPTJLT.js} +2 -2
  11. package/dist/{chunk-OIGI7MP6.js → chunk-C43NXRRE.js} +1 -1
  12. package/dist/chunk-D6BL7ARI.js +2 -0
  13. package/dist/chunk-DLLHUG2Q.js +9 -0
  14. package/dist/chunk-DPC5DKH6.js +2 -0
  15. package/dist/{chunk-R5OJD5K2.js → chunk-DTLLIA2C.js} +1 -1
  16. package/dist/{chunk-LDJAUIAG.js → chunk-FYR4FD7K.js} +1 -1
  17. package/dist/chunk-G6ADWA2B.js +2 -0
  18. package/dist/chunk-H333GKL4.js +3 -0
  19. package/dist/{chunk-EDDGQ6LM.js → chunk-H5DRKXXC.js} +1 -1
  20. package/dist/{chunk-DNKELRK6.js → chunk-IQFXLJIM.js} +1 -1
  21. package/dist/{chunk-UCNIXOTL.js → chunk-IUOMBLRR.js} +1 -1
  22. package/dist/chunk-K3FXRBER.js +4 -0
  23. package/dist/{chunk-TIZCESKY.js → chunk-KCIET26G.js} +1 -1
  24. package/dist/chunk-LEEOZRWR.js +7 -0
  25. package/dist/{chunk-T5NBSCVX.js → chunk-NCZJUPG5.js} +49 -49
  26. package/dist/{chunk-TSYDTKXO.js → chunk-RPM67N7A.js} +1 -1
  27. package/dist/{chunk-NSMRQOWP.js → chunk-SAZXL36B.js} +1 -1
  28. package/dist/chunk-SVGUAVMG.js +1 -0
  29. package/dist/chunk-TBOIXIQA.js +1 -0
  30. package/dist/chunk-TGDXD4CD.js +1 -0
  31. package/dist/{chunk-IPZT6WKM.js → chunk-TVSMNF5G.js} +1 -1
  32. package/dist/{chunk-D3N2WFDV.js → chunk-UHT2SW7O.js} +1 -1
  33. package/dist/chunk-VLKX5U4H.js +13 -0
  34. package/dist/chunk-XF65LQ6M.js +1 -0
  35. package/dist/chunk-ZKYH44ER.js +1 -0
  36. package/dist/{chunk-TZK2R6RD.js → chunk-ZNKZ2KXR.js} +1 -1
  37. package/dist/chunk-ZS7JHATN.js +1 -0
  38. package/dist/{create-XYKXS3JB.js → create-EKA2QG5R.js} +1 -1
  39. package/dist/doctor-BXSNADVR.js +1 -0
  40. package/dist/{goal-lifecycle-BIX2JVNO.js → goal-lifecycle-XXWNMIAD.js} +1 -1
  41. package/dist/{goal-pack-SUWH6K7U.js → goal-pack-NTHYLISY.js} +1 -1
  42. package/dist/index.js +158 -158
  43. package/dist/pipeline-JLOC2SUT.js +5 -0
  44. package/dist/{project-agent-entry-Y3NEHZED.js → project-agent-entry-ZNUHGCVC.js} +1 -1
  45. package/dist/{project-intelligence-lens-6Q6XSUDJ.js → project-intelligence-lens-W72OUEDW.js} +1 -1
  46. package/dist/{proof-carrying-change-456TYEDW.js → proof-carrying-change-WLUPMUO7.js} +1 -1
  47. package/dist/verified-goal-6O2JZOOR.js +1 -0
  48. package/dist/{workspace-ROUEA3RT.js → workspace-XTIGVLGH.js} +1 -1
  49. package/dist/{workspace-agent-sync-6UYG33EQ.js → workspace-agent-sync-TN6QDNBR.js} +1 -1
  50. package/dist/{workspace-context-H7ZXR6VI.js → workspace-context-Y3TNY2XZ.js} +1 -1
  51. package/dist/{workspace-contract-2V2BI6A3.js → workspace-contract-GRZY7WRD.js} +1 -1
  52. package/dist/{workspace-explain-IBMTRUSF.js → workspace-explain-KUYHJFLY.js} +1 -1
  53. package/dist/{workspace-foundation-H5B3TTZD.js → workspace-foundation-ZBUJTR56.js} +1 -1
  54. package/dist/{workspace-graph-stream-YDEET5LK.js → workspace-graph-stream-KC2XUAE4.js} +1 -1
  55. package/dist/workspace-graph-token-efficiency-YHXFGH3Z.js +1 -0
  56. package/dist/{workspace-intelligence-DXKQXTTM.js → workspace-intelligence-26YT6KMN.js} +1 -1
  57. package/dist/{workspace-intelligence-benchmark-L46EGZZM.js → workspace-intelligence-benchmark-QFVTUBDO.js} +1 -1
  58. package/dist/{workspace-intelligence-evaluation-QDSOOUHH.js → workspace-intelligence-evaluation-4AB4BBRP.js} +1 -1
  59. package/dist/{workspace-intelligence-runner-SCB44IXU.js → workspace-intelligence-runner-HVYKHCTX.js} +1 -1
  60. package/dist/{workspace-knowledge-graph-BNEVFEOW.js → workspace-knowledge-graph-RL3I2FHY.js} +1 -1
  61. package/dist/{workspace-knowledge-graph-query-GOC365ZR.js → workspace-knowledge-graph-query-TT2KK3SF.js} +1 -1
  62. package/dist/workspace-knowledge-graph-snapshot-JEJMRQZL.js +1 -0
  63. package/dist/workspace-marker-7U3NYRPJ.js +1 -0
  64. package/dist/{workspace-mcp-serve-JLZTTEVG.js → workspace-mcp-serve-2FGRXJG4.js} +1 -1
  65. package/dist/{workspace-model-XSNLDUI2.js → workspace-model-2ODVOWDQ.js} +1 -1
  66. package/dist/{workspace-onboarding-IRBVZTT4.js → workspace-onboarding-BY6RUBBH.js} +1 -1
  67. package/dist/{workspace-python-engine-state-BE4A3BL5.js → workspace-python-engine-state-VCOLSEWV.js} +2 -2
  68. package/dist/{workspace-registry-summary-CBZDSG6I.js → workspace-registry-summary-VKTJ7PHV.js} +1 -1
  69. package/dist/workspace-repair-engine-RBM7NCGI.js +3 -0
  70. package/dist/workspace-run-JCA5WPCR.js +1 -0
  71. package/dist/{workspace-verify-QTRY7WW3.js → workspace-verify-NFJ7RKKT.js} +1 -1
  72. package/dist/{workspace-watch-PDQKYBYQ.js → workspace-watch-3DBBB6IP.js} +1 -1
  73. package/docs/ci-workflows.md +1 -1
  74. package/package.json +1 -1
  75. package/dist/analyze-WC2TY5AT.js +0 -1
  76. package/dist/autopilot-release-LJDRECFW.js +0 -1
  77. package/dist/chunk-2BCECNIW.js +0 -1
  78. package/dist/chunk-2LIVMG5C.js +0 -2
  79. package/dist/chunk-3SNP6M4M.js +0 -2
  80. package/dist/chunk-4HQU2GQM.js +0 -1
  81. package/dist/chunk-4JAURS76.js +0 -13
  82. package/dist/chunk-7O7P4MRD.js +0 -1
  83. package/dist/chunk-AQNU5RXV.js +0 -2
  84. package/dist/chunk-CQBM6BBP.js +0 -2
  85. package/dist/chunk-CY4QZ3PE.js +0 -3
  86. package/dist/chunk-F6CTGVJA.js +0 -9
  87. package/dist/chunk-K3O3HENC.js +0 -5
  88. package/dist/chunk-LGC4CRUF.js +0 -3
  89. package/dist/chunk-NNQE4DS2.js +0 -2
  90. package/dist/chunk-NSH7TTSV.js +0 -1
  91. package/dist/chunk-SO4CGS35.js +0 -4
  92. package/dist/chunk-UNXG3ZFV.js +0 -1
  93. package/dist/chunk-VBMWFT7Q.js +0 -1
  94. package/dist/chunk-ZZWGD3X3.js +0 -12
  95. package/dist/doctor-LQ7FT6AZ.js +0 -1
  96. package/dist/pipeline-NSPPWD7U.js +0 -5
  97. package/dist/verified-goal-GRH5UOJR.js +0 -1
  98. package/dist/workspace-graph-token-efficiency-XM3LYFUC.js +0 -1
  99. package/dist/workspace-knowledge-graph-snapshot-2NMV7LEJ.js +0 -1
  100. package/dist/workspace-marker-XGAWZZDX.js +0 -1
  101. package/dist/workspace-repair-engine-TDUNQSFJ.js +0 -3
  102. package/dist/workspace-run-I2W5PIPK.js +0 -1
@@ -1,8 +1,8 @@
1
- import {l,f,e as e$2,g as g$1}from'./chunk-EDDGQ6LM.js';import {b as b$4}from'./chunk-DNKELRK6.js';import {b as b$7,a as a$3}from'./chunk-D5LLTUTY.js';import {b as b$2}from'./chunk-B6FJ6RG6.js';import {a as a$2}from'./chunk-TIZCESKY.js';import {e,g,h as h$1,c as c$1,i as i$1,f as f$1,b as b$6,d as d$4}from'./chunk-46QH3ZVI.js';import {g as g$2}from'./chunk-NNQE4DS2.js';import {d as d$1,b as b$1}from'./chunk-2LIVMG5C.js';import {h,e as e$1,b as b$3,d as d$2}from'./chunk-PKKSRXUS.js';import {a}from'./chunk-TQEMLBAG.js';import {i,b as b$5,k as k$1,j,m,t,s as s$1,q}from'./chunk-RGNCL5OB.js';import {b,a as a$1,c,d as d$3}from'./chunk-VQZ5PI5J.js';import {promises}from'fs';import*as k from'fs-extra';import d from'path';import s from'chalk';import {execa}from'execa';function ct(e){let n=e.projectCount??0,t=n===1?"project":"projects",o=e.pythonEngine==="installed"?`Python ${e.pythonVersion||"3.10+"} \xB7 ${e.installMethod||"local environment"}`:e.pythonEngine==="skipped"?"Python engine not installed":"Runtime-neutral foundation";return ["","\u2713 Workspace ready",`${e.workspaceName} \xB7 ${e.profile} \xB7 ${n} registered ${t}`,`Location ${e.workspacePath}`,`Runtime ${o}`,...e.note?[`Note ${e.note}`]:[],"","Workspace Intelligence"," \u2713 Contract and project registry"," \u2713 Canonical model and proof-backed graph"," \u2713 Agent context, grounding, and evidence index","","Next",` ${g$1(e.workspacePath)}`," npx workspai create"," npx workspai workspace intelligence run --for-agent generic --strict --json","","Evidence .workspai/reports/INDEX.json","Guide README.md",""]}function B(e){let n=ct(e);for(let t of n)t==="\u2713 Workspace ready"?console.log(s.green.bold(t)):t==="Workspace Intelligence"||t==="Next"?console.log(s.cyan.bold(t)):t.startsWith(" \u2713")?console.log(s.green(t)):t.startsWith("Location")||t.startsWith("Runtime")?console.log(s.gray(t)):console.log(t);}function T(){return i()}var pt="transactions";function dt(){return d.join(q(),pt)}async function He(){let e=dt();return await b$7(e),a$3({journalDirectory:e})}async function Ue(e){for(let n of s$1())await e.captureFile(n);}async function se(e){let n=await He();try{return await Ue(n),await n.captureOwnedTree(e),n}catch(t){return F(n,t)}}async function ut(e){let n=await He();try{await Ue(n),await n.captureOwnedTree(d.join(e,a$1)),await n.captureOwnedTree(d.join(e,".venv"));let t=[c,".gitignore",d.join(a$1,"workspace.json"),d.join(a$1,"toolchain.lock"),d.join(a$1,"policies.yml"),d.join(a$1,"cache-config.yml"),g$2,a$2,"pyproject.toml","poetry.toml","poetry.lock","rapidkit","rapidkit.cmd","README.md",".rapidkit-global"];for(let o of t)await n.captureFile(d.join(e,o));return n}catch(t){return F(n,t)}}async function J(e){await e.commit(),e.journalPath&&await promises.rm(d.dirname(e.journalPath),{recursive:true,force:true}).catch(n=>e$1.debug(`Could not remove committed lifecycle journal: ${n}`));}async function F(e,n){try{await e.rollback();}catch(t){throw new AggregateError([n,t],"Workspace lifecycle failed and rollback was incomplete.")}throw n}async function Q(e,n,t,o,a){let l=d$1(n,h(),t,a?.pythonEngine?{coreStatus:a.pythonEngine,...a.pythonEngineReason?{coreReason:a.pythonEngineReason}:{},...o?{pythonVersion:o}:{}}:void 0);o&&!a?.pythonEngine&&(l.metadata||(l.metadata={}),l.metadata.python={pythonVersion:o}),await b$1(e,l);}async function H(e){await k.outputFile(d.join(e,".gitignore"),`.venv/
1
+ import {l,f,e as e$3,g as g$1}from'./chunk-H5DRKXXC.js';import {b as b$3}from'./chunk-IQFXLJIM.js';import {b as b$6,a as a$3}from'./chunk-D5LLTUTY.js';import {b as b$1}from'./chunk-B6FJ6RG6.js';import {a as a$2}from'./chunk-KCIET26G.js';import {e as e$1,g,h as h$1,c as c$2,i as i$1,f as f$1,b as b$5,d as d$3}from'./chunk-46QH3ZVI.js';import {g as g$2}from'./chunk-G6ADWA2B.js';import {e,c as c$1}from'./chunk-252EKOR6.js';import {h,e as e$2,b as b$2,d as d$1}from'./chunk-PKKSRXUS.js';import {a}from'./chunk-TQEMLBAG.js';import {i,b as b$4,k as k$1,j,m,t,s as s$1,q}from'./chunk-RGNCL5OB.js';import {b,a as a$1,c,d as d$2}from'./chunk-VQZ5PI5J.js';import {promises}from'fs';import*as k from'fs-extra';import d from'path';import s from'chalk';import {execa}from'execa';function ct(e){let n=e.projectCount??0,t=n===1?"project":"projects",o=e.pythonEngine==="installed"?`Python ${e.pythonVersion||"3.10+"} \xB7 ${e.installMethod||"local environment"}`:e.pythonEngine==="skipped"?"Python engine not installed":"Runtime-neutral foundation";return ["","\u2713 Workspace ready",`${e.workspaceName} \xB7 ${e.profile} \xB7 ${n} registered ${t}`,`Location ${e.workspacePath}`,`Runtime ${o}`,...e.note?[`Note ${e.note}`]:[],"","Workspace Intelligence"," \u2713 Contract and project registry"," \u2713 Canonical model and proof-backed graph"," \u2713 Agent context, grounding, and evidence index","","Next",` ${g$1(e.workspacePath)}`," npx workspai create"," npx workspai workspace intelligence run --for-agent generic --strict --json","","Evidence .workspai/reports/INDEX.json","Guide README.md",""]}function B(e){let n=ct(e);for(let t of n)t==="\u2713 Workspace ready"?console.log(s.green.bold(t)):t==="Workspace Intelligence"||t==="Next"?console.log(s.cyan.bold(t)):t.startsWith(" \u2713")?console.log(s.green(t)):t.startsWith("Location")||t.startsWith("Runtime")?console.log(s.gray(t)):console.log(t);}function T(){return i()}var pt="transactions";function dt(){return d.join(q(),pt)}async function He(){let e=dt();return await b$6(e),a$3({journalDirectory:e})}async function Ue(e){for(let n of s$1())await e.captureFile(n);}async function se(e){let n=await He();try{return await Ue(n),await n.captureOwnedTree(e),n}catch(t){return F(n,t)}}async function ut(e){let n=await He();try{await Ue(n),await n.captureOwnedTree(d.join(e,a$1)),await n.captureOwnedTree(d.join(e,".venv"));let t=[c,".gitignore",d.join(a$1,"workspace.json"),d.join(a$1,"toolchain.lock"),d.join(a$1,"policies.yml"),d.join(a$1,"cache-config.yml"),g$2,a$2,"pyproject.toml","poetry.toml","poetry.lock","rapidkit","rapidkit.cmd","README.md",".rapidkit-global"];for(let o of t)await n.captureFile(d.join(e,o));return n}catch(t){return F(n,t)}}async function J(e){await e.commit(),e.journalPath&&await promises.rm(d.dirname(e.journalPath),{recursive:true,force:true}).catch(n=>e$2.debug(`Could not remove committed lifecycle journal: ${n}`));}async function F(e,n){try{await e.rollback();}catch(t){throw new AggregateError([n,t],"Workspace lifecycle failed and rollback was incomplete.")}throw n}async function Q(e$1,n,t,o,a){let l=e(n,h(),t,a?.pythonEngine?{coreStatus:a.pythonEngine,...a.pythonEngineReason?{coreReason:a.pythonEngineReason}:{},...o?{pythonVersion:o}:{}}:void 0);o&&!a?.pythonEngine&&(l.metadata||(l.metadata={}),l.metadata.python={pythonVersion:o}),await c$1(e$1,l);}async function H(e){await k.outputFile(d.join(e,".gitignore"),`.venv/
2
2
  __pycache__/
3
3
  *.pyc
4
4
  .env
5
- ${d$3}
5
+ ${d$2}
6
6
  ${b}/
7
7
 
8
8
  `,"utf-8");}async function qe(e){try{let n=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,env:a()});return n.stdout.trim()?d.resolve(e,n.stdout.trim()):null}catch{return null}}function mt(e){if(!e||typeof e!="object")return String(e??"");let n=e;return [n.message,n.shortMessage,n.stderr].filter(t=>typeof t=="string").join(`
@@ -37,12 +37,12 @@ cache:
37
37
  prune_on_bootstrap: false
38
38
  self_heal: true
39
39
  verify_integrity: false
40
- `}async function Xe(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3,stdio:"pipe"}),n=e.match(/go(\d+\.\d+(?:\.\d+)?)/i);return n?n[1]:void 0}catch{return}}async function Ze(){try{let{stdout:e}=await execa("dotnet",["--version"],{timeout:3e3,stdio:"pipe"}),n=e.trim();return n.length>0?n:void 0}catch{return}}async function Z(e,n,t,o,a,l){let[u,g]=await Promise.all([Xe(),Ze()]),c=[{fileName:"workspace.json",content:ze(n,t,o,a,l)},{fileName:"toolchain.lock",content:Be(t,o,process.version,u,g,l)},{fileName:"policies.yml",content:Je()},{fileName:"cache-config.yml",content:Qe()}];for(let h of c)await k.outputFile(d.join(e,a$1,h.fileName),h.content,"utf-8");}async function nn(e,n){let{workspaceName:t=d.basename(e),installMethod:o="venv",pythonVersion:a,profile:l,writeMarker:u=true,writeGitignore:g=true,onlyIfMissing:c$1=true}=n||{},h$1=[],[y,f]=await Promise.all([Xe(),Ze()]),p=[{relPath:d.join(a$1,"workspace.json"),legacyRelPath:d.join(b,"workspace.json"),content:ze(t,o,a,l)},{relPath:d.join(a$1,"toolchain.lock"),legacyRelPath:d.join(b,"toolchain.lock"),content:Be(o,a,process.version,y,f)},{relPath:d.join(a$1,"policies.yml"),legacyRelPath:d.join(b,"policies.yml"),content:Je()},{relPath:d.join(a$1,"cache-config.yml"),legacyRelPath:d.join(b,"cache-config.yml"),content:Qe()}];for(let r of p){let i=d.join(e,r.relPath),_=d.join(e,r.legacyRelPath),P=await k.pathExists(i),R=await k.pathExists(_);c$1&&P||(c$1&&R?(await k.copy(_,i),h$1.push(r.relPath)):(await k.outputFile(i,r.content,"utf-8"),h$1.push(r.relPath)));}if(u&&(!await k.pathExists(d.join(e,c))||!c$1)){let i=d$1(t,h(),o);a&&(i.metadata||(i.metadata={}),i.metadata.python={pythonVersion:a}),await b$1(e,i),h$1.push(c);}if(g){let r=d.join(e,".gitignore");(!c$1||!await k.pathExists(r))&&(await H(e),h$1.push(".gitignore"));}return h$1}var gt={"python-only":"minimal",polyglot:"node-only",enterprise:"polyglot"};function ht(e){let n=e,t=new Set;for(;!l(n);){if(t.has(n))return "minimal";t.add(n);let o=gt[n];if(!o)return "minimal";n=o;}return n}var G="3.10",et=["3.10","3.11","3.12"];async function xe(e){try{let{stdout:n}=await execa(e,["--version"],{timeout:3e3}),t=n.match(/Python (\d+\.\d+\.\d+)/);if(t)return t[1]}catch{}return null}async function ft(e,n){try{await promises.writeFile(d.join(e,".python-version"),`${n}
41
- `,"utf-8"),e$1.debug(`Created .python-version with ${n}`);}catch(t){e$1.warn(`Failed to create .python-version: ${t}`);}}function le(){let t$1=[...(process.env.PATH||"").split(d.delimiter).filter(Boolean)];for(let o of t())t$1.includes(o)||t$1.unshift(o);process.env.PATH=t$1.join(d.delimiter);}async function he(e,n){le(),e.start("Checking pipx installation");try{return await execa("pipx",["--version"]),e.succeed("pipx found"),{kind:"binary"}}catch{}let t=T();try{return await execa(t,["-m","pipx","--version"]),e.succeed("pipx found"),{kind:"python-module",pythonCmd:t}}catch{}if(n)throw new d$4;try{await execa(t,["-m","pip","--version"],{timeout:2500});}catch{throw new h$1}e.stop?.();let{installPipx:o}=await b$2([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!o)throw new d$4;e.start("Installing pipx (user install)");try{try{await execa(t,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(t,["-m","pip","install","--user","--upgrade","pipx"]);}catch(a){let l=a,u=String(l?.stderr||l?.shortMessage||l?.message||"");throw new f$1("Install pipx with python -m pip",a instanceof Error?a:new Error(u))}e.succeed("pipx installed"),le();try{return await execa(t,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:t}}catch(a){let l=a,u=String(l?.stderr||l?.shortMessage||l?.message||"pipx not runnable after install");throw new f$1("Verify pipx after install",new Error(`${u}
40
+ `}async function Xe(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3,stdio:"pipe"}),n=e.match(/go(\d+\.\d+(?:\.\d+)?)/i);return n?n[1]:void 0}catch{return}}async function Ze(){try{let{stdout:e}=await execa("dotnet",["--version"],{timeout:3e3,stdio:"pipe"}),n=e.trim();return n.length>0?n:void 0}catch{return}}async function Z(e,n,t,o,a,l){let[u,g]=await Promise.all([Xe(),Ze()]),c=[{fileName:"workspace.json",content:ze(n,t,o,a,l)},{fileName:"toolchain.lock",content:Be(t,o,process.version,u,g,l)},{fileName:"policies.yml",content:Je()},{fileName:"cache-config.yml",content:Qe()}];for(let h of c)await k.outputFile(d.join(e,a$1,h.fileName),h.content,"utf-8");}async function nn(e$1,n){let{workspaceName:t=d.basename(e$1),installMethod:o="venv",pythonVersion:a,profile:l,writeMarker:u=true,writeGitignore:g=true,onlyIfMissing:c$2=true}=n||{},h$1=[],[y,f]=await Promise.all([Xe(),Ze()]),p=[{relPath:d.join(a$1,"workspace.json"),legacyRelPath:d.join(b,"workspace.json"),content:ze(t,o,a,l)},{relPath:d.join(a$1,"toolchain.lock"),legacyRelPath:d.join(b,"toolchain.lock"),content:Be(o,a,process.version,y,f)},{relPath:d.join(a$1,"policies.yml"),legacyRelPath:d.join(b,"policies.yml"),content:Je()},{relPath:d.join(a$1,"cache-config.yml"),legacyRelPath:d.join(b,"cache-config.yml"),content:Qe()}];for(let r of p){let i=d.join(e$1,r.relPath),_=d.join(e$1,r.legacyRelPath),P=await k.pathExists(i),R=await k.pathExists(_);c$2&&P||(c$2&&R?(await k.copy(_,i),h$1.push(r.relPath)):(await k.outputFile(i,r.content,"utf-8"),h$1.push(r.relPath)));}if(u&&(!await k.pathExists(d.join(e$1,c))||!c$2)){let i=e(t,h(),o);a&&(i.metadata||(i.metadata={}),i.metadata.python={pythonVersion:a}),await c$1(e$1,i),h$1.push(c);}if(g){let r=d.join(e$1,".gitignore");(!c$2||!await k.pathExists(r))&&(await H(e$1),h$1.push(".gitignore"));}return h$1}var gt={"python-only":"minimal",polyglot:"node-only",enterprise:"polyglot"};function ht(e){let n=e,t=new Set;for(;!l(n);){if(t.has(n))return "minimal";t.add(n);let o=gt[n];if(!o)return "minimal";n=o;}return n}var G="3.10",et=["3.10","3.11","3.12"];async function xe(e){try{let{stdout:n}=await execa(e,["--version"],{timeout:3e3}),t=n.match(/Python (\d+\.\d+\.\d+)/);if(t)return t[1]}catch{}return null}async function ft(e,n){try{await promises.writeFile(d.join(e,".python-version"),`${n}
41
+ `,"utf-8"),e$2.debug(`Created .python-version with ${n}`);}catch(t){e$2.warn(`Failed to create .python-version: ${t}`);}}function le(){let t$1=[...(process.env.PATH||"").split(d.delimiter).filter(Boolean)];for(let o of t())t$1.includes(o)||t$1.unshift(o);process.env.PATH=t$1.join(d.delimiter);}async function he(e,n){le(),e.start("Checking pipx installation");try{return await execa("pipx",["--version"]),e.succeed("pipx found"),{kind:"binary"}}catch{}let t=T();try{return await execa(t,["-m","pipx","--version"]),e.succeed("pipx found"),{kind:"python-module",pythonCmd:t}}catch{}if(n)throw new d$3;try{await execa(t,["-m","pip","--version"],{timeout:2500});}catch{throw new h$1}e.stop?.();let{installPipx:o}=await b$1([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!o)throw new d$3;e.start("Installing pipx (user install)");try{try{await execa(t,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(t,["-m","pip","install","--user","--upgrade","pipx"]);}catch(a){let l=a,u=String(l?.stderr||l?.shortMessage||l?.message||"");throw new f$1("Install pipx with python -m pip",a instanceof Error?a:new Error(u))}e.succeed("pipx installed"),le();try{return await execa(t,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:t}}catch(a){let l=a,u=String(l?.stderr||l?.shortMessage||l?.message||"pipx not runnable after install");throw new f$1("Verify pipx after install",new Error(`${u}
42
42
 
43
43
  Try reopening your terminal or run: ${t} -m pipx ensurepath`))}}async function U(e,n){return e.kind==="binary"?execa("pipx",n):execa(e.pythonCmd,["-m","pipx",...n])}function tt(e){let n=e.match(/^(\d+)\.(\d+)/);return n?`${n[1]}.${n[2]}`:null}function Ge(e){if(!e)return null;let n=e.match(/Python\s+(\d+)\.(\d+)(?:\.\d+)?/i);return n?`${n[1]}.${n[2]}`:null}function Ie(e,n){let[t,o]=e.split(".").map(u=>Number(u)),[a,l]=n.split(".").map(u=>Number(u));return t!==a?t-a:o-l}function ee(e,n){return Ie(e,n)>=0}async function wt(e){let n=new Set,t=k$1(14,10);for(let f of t)try{let p=await execa(f.command,f.args,{timeout:2500}),r=Ge(`${p.stdout||""}
44
44
  ${p.stderr||""}`);r&&ee(r,G)&&n.add(r);}catch{}let o=null;try{let f=await execa(T(),["--version"],{timeout:2500}),p=Ge(`${f.stdout||""}
45
- ${f.stderr||""}`);p&&ee(p,G)&&(o=p,n.add(p));}catch{}let a=et.filter(f=>ee(f,G)),l=new Set([...a,...n]),u=Array.from(l).sort((f,p)=>Ie(p,f)),g=e?tt(e):null,c=g&&ee(g,G)?g:o||u[0]||G;return l.has(c)||l.add(c),{choices:Array.from(l).sort((f,p)=>Ie(p,f)).map(f=>{let p=[];return f===o&&p.push("current system"),f===G&&p.push("minimum supported"),n.has(f)&&f!==o&&p.push("detected"),{name:p.length>0?`${f} (${p.join(", ")})`:f,value:f}}),defaultValue:c}}async function vt(){le();let e=false,n=false,t=false,o=false;try{await execa("poetry",["--version"],{timeout:2500}),e=true;}catch{e=false;}try{await execa("pipx",["--version"],{timeout:2500}),n=true;}catch{let l=i();try{await execa(l,["-m","pipx","--version"],{timeout:2500}),n=true;}catch{n=false;}}let a=i();try{await execa(a,["-m","pip","--version"],{timeout:2500}),t=true;}catch{t=false;}try{await execa(a,["-c","import venv, ensurepip"],{timeout:2500}),o=true;}catch{o=false;}return {poetry:e,pipx:n,pip:t,venv:o}}function kt(e,n){return e==="poetry"&&n.poetry?"poetry":e==="pipx"&&n.pipx?"pipx":e==="venv"&&n.venv?"venv":n.poetry?"poetry":n.venv?"venv":"pipx"}async function Pt(e,n){le(),e.start("Checking Poetry installation");try{await execa("poetry",["--version"]),e.succeed("Poetry found");return}catch{}if(n)throw new c$1;let{installPoetry:t}=await b$2([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!t)throw new c$1;let o=await he(e,n);e.start("Installing Poetry with pipx");try{await U(o,["install","poetry"]);}catch(a){let l=a,u=String(l?.stderr||l?.shortMessage||l?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(u))try{await U(o,["upgrade","poetry"]);}catch{}else throw new f$1("Install Poetry with pipx",a instanceof Error?a:new Error(u))}e.succeed("Poetry installed"),le();try{await execa("poetry",["--version"]);}catch(a){let l=a,u=String(l?.stderr||l?.shortMessage||l?.message||"Poetry not found on PATH");throw new f$1("Verify Poetry after pipx install",new Error(`${u}
45
+ ${f.stderr||""}`);p&&ee(p,G)&&(o=p,n.add(p));}catch{}let a=et.filter(f=>ee(f,G)),l=new Set([...a,...n]),u=Array.from(l).sort((f,p)=>Ie(p,f)),g=e?tt(e):null,c=g&&ee(g,G)?g:o||u[0]||G;return l.has(c)||l.add(c),{choices:Array.from(l).sort((f,p)=>Ie(p,f)).map(f=>{let p=[];return f===o&&p.push("current system"),f===G&&p.push("minimum supported"),n.has(f)&&f!==o&&p.push("detected"),{name:p.length>0?`${f} (${p.join(", ")})`:f,value:f}}),defaultValue:c}}async function vt(){le();let e=false,n=false,t=false,o=false;try{await execa("poetry",["--version"],{timeout:2500}),e=true;}catch{e=false;}try{await execa("pipx",["--version"],{timeout:2500}),n=true;}catch{let l=i();try{await execa(l,["-m","pipx","--version"],{timeout:2500}),n=true;}catch{n=false;}}let a=i();try{await execa(a,["-m","pip","--version"],{timeout:2500}),t=true;}catch{t=false;}try{await execa(a,["-c","import venv, ensurepip"],{timeout:2500}),o=true;}catch{o=false;}return {poetry:e,pipx:n,pip:t,venv:o}}function kt(e,n){return e==="poetry"&&n.poetry?"poetry":e==="pipx"&&n.pipx?"pipx":e==="venv"&&n.venv?"venv":n.poetry?"poetry":n.venv?"venv":"pipx"}async function Pt(e,n){le(),e.start("Checking Poetry installation");try{await execa("poetry",["--version"]),e.succeed("Poetry found");return}catch{}if(n)throw new c$2;let{installPoetry:t}=await b$1([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!t)throw new c$2;let o=await he(e,n);e.start("Installing Poetry with pipx");try{await U(o,["install","poetry"]);}catch(a){let l=a,u=String(l?.stderr||l?.shortMessage||l?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(u))try{await U(o,["upgrade","poetry"]);}catch{}else throw new f$1("Install Poetry with pipx",a instanceof Error?a:new Error(u))}e.succeed("Poetry installed"),le();try{await execa("poetry",["--version"]);}catch(a){let l=a,u=String(l?.stderr||l?.shortMessage||l?.message||"Poetry not found on PATH");throw new f$1("Verify Poetry after pipx install",new Error(`${u}
46
46
 
47
47
  Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function bt(e,n={}){let t=e==="poetry",o=n.pythonEngineSkipped?`echo "- Python engine installation was intentionally skipped for this workspace." 1>&2
48
48
  echo "- For npm-owned workspace commands, run: npx workspai <command>" 1>&2
@@ -120,10 +120,10 @@ for %%R in ("%USERPROFILE%\\.local\\bin\\rapidkit.exe" "%APPDATA%\\Python\\Scrip
120
120
  echo RapidKit launcher could not find a local Python CLI. 1>&2
121
121
  ${o}echo Tip: for npm-owned workspace commands, run npx --yes --package workspai workspai %* from a shell where npm is on PATH. 1>&2
122
122
  exit /b 1
123
- `}async function ge(e,n,t={}){await k.outputFile(d.join(e,"rapidkit"),bt(n,t),{encoding:"utf-8",mode:493}),await k.outputFile(d.join(e,"rapidkit.cmd"),Rt(n,t),"utf-8");}async function on(e$2,n){let{skipGit:t=false,skipPythonEngine:o=false,testMode:a=false,demoMode:l$1=false,dryRun:u=false,yes:g$1=false,userConfig:c={},installMethod:h,profile:y,parentDirectory:f$1,suppressReceipt:p=false}=n,r=e$2||"rapidkit",i$1=f$1?d.resolve(f$1,r):d.resolve(process.cwd(),r);if(await k.pathExists(i$1))throw new e(r);if(await f(i$1),u){let w=y||(g$1?"minimal":void 0),I=h||c.defaultInstallMethod||"poetry",E=c.pythonVersion||"3.10";await It(i$1,r,l$1,c,w,I,E,t,o);return}if(l$1){await xt(i$1,r,t);return}let _=new Set(["python-only","polyglot","enterprise"]),P=y||"";if(!g$1&&!y){let{selectedProfile:w}=await b$2([{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}]);P=w;}else P||(P="minimal");let R=!g$1&&_.has(P),O=_.has(P)?o?"skip":R?(await b$2([{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",ce=R&&O==="install",at=typeof c.pythonVersion=="string"&&c.pythonVersion.trim().length>0?c.pythonVersion.trim():void 0,rt=h||c.defaultInstallMethod||"poetry",A=O==="install"?await vt():{poetry:true,pipx:true,pip:true,venv:true},_e=ce?await wt(at):{choices:et.map(w=>({name:w,value:w})),defaultValue:G},st=kt(rt,A),lt=[{name:A.poetry?"\u{1F3AF} Poetry (Recommended - includes virtual env + dependency mgmt)":A.pipx||A.pip?"\u{1F3AF} Poetry (Recommended) \u2014 not detected (can be installed)":"\u{1F3AF} Poetry (Recommended) \u2014 unavailable (system pipx package required)",value:"poetry"},{name:A.venv?"\u{1F4E6} pip with venv (Standard, zero extra tools)":"\u{1F4E6} pip with venv \u2014 unavailable (system venv package required)",value:"venv"},{name:A.pipx?"\u{1F527} pipx (Global isolated - RapidKit Core only, no local venv)":A.pip?"\u{1F527} pipx (Global isolated) \u2014 not detected (can be installed)":"\u{1F527} pipx (Global isolated) \u2014 unavailable (system pipx package required)",value:"pipx"}],x=ce?await b$2([{type:"rawlist",name:"pythonVersion",message:"Select minimum Python version for RapidKit:",choices:_e.choices,default:_e.defaultValue},{type:"rawlist",name:"installMethod",message:"How would you like to manage the workspace environment?",choices:lt,default:st}]):await(async()=>{if(O==="skip")return {pythonVersion:c.pythonVersion||"3.10",installMethod:"venv"};let w=h||c.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return e$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})();return {pythonVersion:c.pythonVersion||"3.10",installMethod:w}})();if(l(P)){let w=b$3("Creating workspace",{component:"create",phase:"workspace.python-free"}),I=await se(i$1);try{await k.ensureDir(i$1),w.succeed("Directory created"),await Q(i$1,r,"venv",void 0),await Z(i$1,r,"venv",void 0,P,{bootstrapNote:"python-engine-skipped",pythonEngine:"skipped",pythonEngineReason:"workspace-profile-does-not-install-python-at-create"}),await H(i$1);let E=await b$4(i$1,{workspaceName:r,silent:true});await J(I),t||await X(i$1,w,"Initial commit: Workspai workspace"),p||B({workspaceName:r,workspacePath:i$1,profile:P,projectCount:E?.projectCount??0});}catch(E){return w.fail("Failed to create workspace"),F(I,E)}return}if(_.has(P)&&O==="skip"){let w=b$3("Creating workspace",{component:"create",phase:"workspace.python-engine-skipped"}),I=await se(i$1);try{await k.ensureDir(i$1),w.succeed("Directory created");let E={bootstrapNote:"python-engine-skipped",pythonEngine:"skipped",pythonEngineReason:"user-opted-out"};await Q(i$1,r,"venv",void 0,E),await Z(i$1,r,"venv",void 0,P,E),await H(i$1),await ge(i$1,"venv",{pythonEngineSkipped:true});let b=await b$4(i$1,{workspaceName:r,silent:true});await J(I),t||await X(i$1,w,`Initial commit: Workspai workspace (${P})`),p||B({workspaceName:r,workspacePath:i$1,profile:P,projectCount:b?.projectCount??0,pythonEngine:"skipped",note:"Install the optional Python engine later only when a Python-backed kit needs it."});return}catch(E){return w.fail("Failed to create workspace"),F(I,E)}}{let w=T(),I=false;try{await execa(w,["--version"],{timeout:5e3}),I=true;}catch{try{await execa("python",["--version"],{timeout:5e3}),I=true;}catch{I=false;}}if(!I){let E=P,b=ht(P);if(R&&!g$1){console.log(s.yellow(`
123
+ `}async function ge(e,n,t={}){await k.outputFile(d.join(e,"rapidkit"),bt(n,t),{encoding:"utf-8",mode:493}),await k.outputFile(d.join(e,"rapidkit.cmd"),Rt(n,t),"utf-8");}async function on(e,n){let{skipGit:t=false,skipPythonEngine:o=false,testMode:a=false,demoMode:l$1=false,dryRun:u=false,yes:g$1=false,userConfig:c={},installMethod:h,profile:y,parentDirectory:f$1,suppressReceipt:p=false}=n,r=e||"rapidkit",i$1=f$1?d.resolve(f$1,r):d.resolve(process.cwd(),r);if(await k.pathExists(i$1))throw new e$1(r);if(await f(i$1),u){let w=y||(g$1?"minimal":void 0),I=h||c.defaultInstallMethod||"poetry",E=c.pythonVersion||"3.10";await It(i$1,r,l$1,c,w,I,E,t,o);return}if(l$1){await xt(i$1,r,t);return}let _=new Set(["python-only","polyglot","enterprise"]),P=y||"";if(!g$1&&!y){let{selectedProfile:w}=await b$1([{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}]);P=w;}else P||(P="minimal");let R=!g$1&&_.has(P),O=_.has(P)?o?"skip":R?(await b$1([{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",ce=R&&O==="install",at=typeof c.pythonVersion=="string"&&c.pythonVersion.trim().length>0?c.pythonVersion.trim():void 0,rt=h||c.defaultInstallMethod||"poetry",A=O==="install"?await vt():{poetry:true,pipx:true,pip:true,venv:true},_e=ce?await wt(at):{choices:et.map(w=>({name:w,value:w})),defaultValue:G},st=kt(rt,A),lt=[{name:A.poetry?"\u{1F3AF} Poetry (Recommended - includes virtual env + dependency mgmt)":A.pipx||A.pip?"\u{1F3AF} Poetry (Recommended) \u2014 not detected (can be installed)":"\u{1F3AF} Poetry (Recommended) \u2014 unavailable (system pipx package required)",value:"poetry"},{name:A.venv?"\u{1F4E6} pip with venv (Standard, zero extra tools)":"\u{1F4E6} pip with venv \u2014 unavailable (system venv package required)",value:"venv"},{name:A.pipx?"\u{1F527} pipx (Global isolated - RapidKit Core only, no local venv)":A.pip?"\u{1F527} pipx (Global isolated) \u2014 not detected (can be installed)":"\u{1F527} pipx (Global isolated) \u2014 unavailable (system pipx package required)",value:"pipx"}],x=ce?await b$1([{type:"rawlist",name:"pythonVersion",message:"Select minimum Python version for RapidKit:",choices:_e.choices,default:_e.defaultValue},{type:"rawlist",name:"installMethod",message:"How would you like to manage the workspace environment?",choices:lt,default:st}]):await(async()=>{if(O==="skip")return {pythonVersion:c.pythonVersion||"3.10",installMethod:"venv"};let w=h||c.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return e$2.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})();return {pythonVersion:c.pythonVersion||"3.10",installMethod:w}})();if(l(P)){let w=b$2("Creating workspace",{component:"create",phase:"workspace.python-free"}),I=await se(i$1);try{await k.ensureDir(i$1),w.succeed("Directory created"),await Q(i$1,r,"venv",void 0),await Z(i$1,r,"venv",void 0,P,{bootstrapNote:"python-engine-skipped",pythonEngine:"skipped",pythonEngineReason:"workspace-profile-does-not-install-python-at-create"}),await H(i$1);let E=await b$3(i$1,{workspaceName:r,silent:true});await J(I),t||await X(i$1,w,"Initial commit: Workspai workspace"),p||B({workspaceName:r,workspacePath:i$1,profile:P,projectCount:E?.projectCount??0});}catch(E){return w.fail("Failed to create workspace"),F(I,E)}return}if(_.has(P)&&O==="skip"){let w=b$2("Creating workspace",{component:"create",phase:"workspace.python-engine-skipped"}),I=await se(i$1);try{await k.ensureDir(i$1),w.succeed("Directory created");let E={bootstrapNote:"python-engine-skipped",pythonEngine:"skipped",pythonEngineReason:"user-opted-out"};await Q(i$1,r,"venv",void 0,E),await Z(i$1,r,"venv",void 0,P,E),await H(i$1),await ge(i$1,"venv",{pythonEngineSkipped:true});let b=await b$3(i$1,{workspaceName:r,silent:true});await J(I),t||await X(i$1,w,`Initial commit: Workspai workspace (${P})`),p||B({workspaceName:r,workspacePath:i$1,profile:P,projectCount:b?.projectCount??0,pythonEngine:"skipped",note:"Install the optional Python engine later only when a Python-backed kit needs it."});return}catch(E){return w.fail("Failed to create workspace"),F(I,E)}}{let w=T(),I=false;try{await execa(w,["--version"],{timeout:5e3}),I=true;}catch{try{await execa("python",["--version"],{timeout:5e3}),I=true;}catch{I=false;}}if(!I){let E=P,b=ht(P);if(R&&!g$1){console.log(s.yellow(`
124
124
  \u26A0\uFE0F Python 3.10+ is not detected on this system.
125
125
  `)),console.log(s.cyan(`You have 3 options:
126
- `));let{pythonAction:D}=await b$2([{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 "${b}" profile (no Python required)`,value:"fallback"},{name:"\u274C Cancel and install Python manually",value:"cancel"}]}]);if(D==="cancel"&&(console.log(s.cyan(`
126
+ `));let{pythonAction:D}=await b$1([{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 "${b}" profile (no Python required)`,value:"fallback"},{name:"\u274C Cancel and install Python manually",value:"cancel"}]}]);if(D==="cancel"&&(console.log(s.cyan(`
127
127
  \u{1F4A1} How to install Python:
128
128
  `)),console.log(s.white(" Ubuntu / Debian: sudo apt install python3.10")),console.log(s.white(" macOS (Homebrew): brew install python@3.10")),console.log(s.white(` Windows: https://python.org/downloads
129
129
  `)),console.log(s.gray(` After installing Python, run: npx workspai ${r}
@@ -136,9 +136,9 @@ exit /b 1
136
136
  `))),console.log(s.gray(` After installing, run: npx workspai ${r}
137
137
  `)),process.exit(0);}if(D==="fallback"&&(console.log(s.green(`
138
138
  \u2705 Switching to "${b}" profile (no Python required).
139
- `)),P=b,l(b))){let S=b$3("Creating workspace",{component:"create",phase:"workspace.python-free"}),q=await se(i$1);try{await k.ensureDir(i$1),S.succeed("Directory created"),await Q(i$1,r,"venv",void 0),await Z(i$1,r,"venv",void 0,b,{profileRequested:E,bootstrapNote:"python-free-fallback",pythonEngine:"skipped",pythonEngineReason:"python-runtime-unavailable"}),await H(i$1);let fe=await b$4(i$1,{workspaceName:r,silent:true});await J(q),t||await X(i$1,S,`Initial commit: Workspai workspace (${b} profile)`),p||B({workspaceName:r,workspacePath:i$1,profile:b,projectCount:fe?.projectCount??0,note:`Requested ${E}; used ${b} because Python was unavailable.`});return}catch(fe){return S.fail("Failed to create workspace"),F(q,fe)}}}else if(console.log(s.yellow(`
139
+ `)),P=b,l(b))){let S=b$2("Creating workspace",{component:"create",phase:"workspace.python-free"}),q=await se(i$1);try{await k.ensureDir(i$1),S.succeed("Directory created"),await Q(i$1,r,"venv",void 0),await Z(i$1,r,"venv",void 0,b,{profileRequested:E,bootstrapNote:"python-free-fallback",pythonEngine:"skipped",pythonEngineReason:"python-runtime-unavailable"}),await H(i$1);let fe=await b$3(i$1,{workspaceName:r,silent:true});await J(q),t||await X(i$1,S,`Initial commit: Workspai workspace (${b} profile)`),p||B({workspaceName:r,workspacePath:i$1,profile:b,projectCount:fe?.projectCount??0,note:`Requested ${E}; used ${b} because Python was unavailable.`});return}catch(fe){return S.fail("Failed to create workspace"),F(q,fe)}}}else if(console.log(s.yellow(`
140
140
  \u26A0\uFE0F Python not detected. Auto-switching to "${b}" profile (no Python required).
141
- `)),P=b,l(b)){let D=b$3("Creating workspace",{component:"create",phase:"workspace.python-free"}),S=await se(i$1);try{await k.ensureDir(i$1),D.succeed("Directory created"),await Q(i$1,r,"venv",void 0),await Z(i$1,r,"venv",void 0,b,{profileRequested:E,bootstrapNote:"python-free-fallback",pythonEngine:"skipped",pythonEngineReason:"python-runtime-unavailable"}),await H(i$1);let q=await b$4(i$1,{workspaceName:r,silent:true});await J(S),t||await X(i$1,D,`Initial commit: Workspai workspace (${b})`),p||B({workspaceName:r,workspacePath:i$1,profile:b,projectCount:q?.projectCount??0,note:`Requested ${E}; used ${b} because Python was unavailable.`});return}catch(q){return D.fail("Failed to create workspace"),F(S,q)}}}}if(x.installMethod==="venv"&&!A.venv){let w=await xe(i()),I=w?tt(w):null;throw new g(`python${I||x.pythonVersion}-venv`,d.basename(i$1))}if(x.installMethod==="pipx"&&!A.pipx&&!A.pip)throw new h$1;if(x.installMethod==="poetry"&&!A.poetry&&!A.pipx&&!A.pip)throw new c$1;let C=b$3("Creating directory",{component:"create",phase:"workspace.directory"}),Ce=await se(i$1);try{await k.ensureDir(i$1),C.succeed("Directory created"),C.start("Detecting Python version");let w=null,I=await nt(x.pythonVersion);if(I)w=await xe(I),w?(e$1.info(` Detected Python ${w}`),C.succeed(`Python ${w} detected`)):C.warn("Could not detect exact Python version");else {let b=T();w=await xe(b),w?C.succeed(`Python ${w} detected`):C.warn("Could not detect Python version, proceeding with defaults");}if(await Q(i$1,r,x.installMethod,w||void 0),await Z(i$1,r,x.installMethod,w||x.pythonVersion,P||y),await H(i$1),await Ye(i$1,r),x.installMethod==="poetry")try{await ot(i$1,x.pythonVersion,C,a,c,g$1);}catch(b){let te=b?.details||b?.message||String(b);if(te.includes("pyenv")||te.includes("exit status 127")||te.includes("returned non-zero exit status 127")){C.warn("Poetry encountered Python discovery issues, trying venv method"),e$1.debug(`Poetry error (attempting venv fallback): ${te}`);try{await Ee(i$1,x.pythonVersion,C,a,c),x.installMethod="venv";}catch(S){throw S}}else throw b}else x.installMethod==="venv"?await Ee(i$1,x.pythonVersion,C,a,c):await it(i$1,C,a,c,g$1);w&&await ft(i$1,w),await ge(i$1,x.installMethod),C.succeed("Workspai environment ready!");let E=await b$4(i$1,{workspaceName:r,silent:true});await J(Ce),n.skipGit||await X(i$1,C,"Initial commit: Workspai environment"),p||B({workspaceName:r,workspacePath:i$1,profile:P,projectCount:E?.projectCount??0,pythonEngine:"installed",pythonVersion:x.pythonVersion,installMethod:x.installMethod});}catch(w){return C.fail("Failed to create Workspai environment"),F(Ce,w)}}async function nt(e){let n=[];if(!b$5())try{let{stdout:l}=await execa("pyenv",["which","python"]),u=l.trim();u&&n.push(u);}catch{}let t=Number(e.split(".")[1]),o=k$1(t,10).map(l=>l.command).filter(Boolean);n.push(`python${e}`,...o,...j());let a=[...new Set(n)];for(let l of a)try{let u=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,u,{timeout:2e3}),h=c.match(/Python (\d+\.\d+)/)?.[1];if(h&&ee(h,e))return await execa(l,g,{timeout:2e3}),l}catch{continue}return null}async function ot(e,n,t,o,a,l=false){await Pt(t,l),t.start("Finding Python interpreter");let u=await nt(n);u?(e$1.debug(`Found working Python: ${u}`),t.succeed("Python found")):t.warn("Could not verify Python path, proceeding with default"),t.start("Initializing Poetry project");let g=d.join(e,"pyproject.toml"),h=(await k.pathExists(g)?await promises.readFile(g,"utf-8"):"").includes("rapidkit-core");if(h)t.succeed("Poetry project initialized");else {await execa("poetry",["init","--no-interaction","--python",`^${n}`],{cwd:e}),t.succeed("Poetry project initialized");let r=await promises.readFile(g,"utf-8");r.includes("[tool.poetry]")?r=r.replace("[tool.poetry]",`[tool.poetry]
141
+ `)),P=b,l(b)){let D=b$2("Creating workspace",{component:"create",phase:"workspace.python-free"}),S=await se(i$1);try{await k.ensureDir(i$1),D.succeed("Directory created"),await Q(i$1,r,"venv",void 0),await Z(i$1,r,"venv",void 0,b,{profileRequested:E,bootstrapNote:"python-free-fallback",pythonEngine:"skipped",pythonEngineReason:"python-runtime-unavailable"}),await H(i$1);let q=await b$3(i$1,{workspaceName:r,silent:true});await J(S),t||await X(i$1,D,`Initial commit: Workspai workspace (${b})`),p||B({workspaceName:r,workspacePath:i$1,profile:b,projectCount:q?.projectCount??0,note:`Requested ${E}; used ${b} because Python was unavailable.`});return}catch(q){return D.fail("Failed to create workspace"),F(S,q)}}}}if(x.installMethod==="venv"&&!A.venv){let w=await xe(i()),I=w?tt(w):null;throw new g(`python${I||x.pythonVersion}-venv`,d.basename(i$1))}if(x.installMethod==="pipx"&&!A.pipx&&!A.pip)throw new h$1;if(x.installMethod==="poetry"&&!A.poetry&&!A.pipx&&!A.pip)throw new c$2;let C=b$2("Creating directory",{component:"create",phase:"workspace.directory"}),Ce=await se(i$1);try{await k.ensureDir(i$1),C.succeed("Directory created"),C.start("Detecting Python version");let w=null,I=await nt(x.pythonVersion);if(I)w=await xe(I),w?(e$2.info(` Detected Python ${w}`),C.succeed(`Python ${w} detected`)):C.warn("Could not detect exact Python version");else {let b=T();w=await xe(b),w?C.succeed(`Python ${w} detected`):C.warn("Could not detect Python version, proceeding with defaults");}if(await Q(i$1,r,x.installMethod,w||void 0),await Z(i$1,r,x.installMethod,w||x.pythonVersion,P||y),await H(i$1),await Ye(i$1,r),x.installMethod==="poetry")try{await ot(i$1,x.pythonVersion,C,a,c,g$1);}catch(b){let te=b?.details||b?.message||String(b);if(te.includes("pyenv")||te.includes("exit status 127")||te.includes("returned non-zero exit status 127")){C.warn("Poetry encountered Python discovery issues, trying venv method"),e$2.debug(`Poetry error (attempting venv fallback): ${te}`);try{await Ee(i$1,x.pythonVersion,C,a,c),x.installMethod="venv";}catch(S){throw S}}else throw b}else x.installMethod==="venv"?await Ee(i$1,x.pythonVersion,C,a,c):await it(i$1,C,a,c,g$1);w&&await ft(i$1,w),await ge(i$1,x.installMethod),C.succeed("Workspai environment ready!");let E=await b$3(i$1,{workspaceName:r,silent:true});await J(Ce),n.skipGit||await X(i$1,C,"Initial commit: Workspai environment"),p||B({workspaceName:r,workspacePath:i$1,profile:P,projectCount:E?.projectCount??0,pythonEngine:"installed",pythonVersion:x.pythonVersion,installMethod:x.installMethod});}catch(w){return C.fail("Failed to create Workspai environment"),F(Ce,w)}}async function nt(e){let n=[];if(!b$4())try{let{stdout:l}=await execa("pyenv",["which","python"]),u=l.trim();u&&n.push(u);}catch{}let t=Number(e.split(".")[1]),o=k$1(t,10).map(l=>l.command).filter(Boolean);n.push(`python${e}`,...o,...j());let a=[...new Set(n)];for(let l of a)try{let u=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,u,{timeout:2e3}),h=c.match(/Python (\d+\.\d+)/)?.[1];if(h&&ee(h,e))return await execa(l,g,{timeout:2e3}),l}catch{continue}return null}async function ot(e,n,t,o,a,l=false){await Pt(t,l),t.start("Finding Python interpreter");let u=await nt(n);u?(e$2.debug(`Found working Python: ${u}`),t.succeed("Python found")):t.warn("Could not verify Python path, proceeding with default"),t.start("Initializing Poetry project");let g=d.join(e,"pyproject.toml"),h=(await k.pathExists(g)?await promises.readFile(g,"utf-8"):"").includes("rapidkit-core");if(h)t.succeed("Poetry project initialized");else {await execa("poetry",["init","--no-interaction","--python",`^${n}`],{cwd:e}),t.succeed("Poetry project initialized");let r=await promises.readFile(g,"utf-8");r.includes("[tool.poetry]")?r=r.replace("[tool.poetry]",`[tool.poetry]
142
142
  package-mode = false`):r.includes("[project]")&&(r.includes("[build-system]")?r=r.replace("[build-system]",`
143
143
  [tool.poetry]
144
144
  package-mode = false
@@ -147,27 +147,27 @@ package-mode = false
147
147
 
148
148
  [tool.poetry]
149
149
  package-mode = false
150
- `),await promises.writeFile(g,r,"utf-8");}t.start("Configuring Poetry");try{await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:e}),t.succeed("Poetry configured");}catch{t.warn("Could not configure Poetry virtualenvs.in-project");}t.start("Creating virtualenv");let y=u||T(),f=m(d.join(e,".venv"));try{await execa(y,["-m","venv",".venv"],{cwd:e,timeout:6e4}),t.succeed("Virtualenv created");}catch(p){e$1.debug(`python -m venv failed: ${p}`),t.warn("Could not pre-create virtualenv, Poetry will try"),f=u||T();}try{await execa("poetry",["env","use",f||T()],{cwd:e}),e$1.debug(`Poetry env set to: ${f}`);}catch(p){e$1.debug(`Could not set Poetry env: ${p}`);}if(t.start("Installing RapidKit"),h&&!o){let p=e$2(a||{}),r=p?await k.pathExists(p):false,i=r&&p?p:"rapidkit-core";p&&!r&&e$1.warn(`WORKSPAI_DEV_PATH/RAPIDKIT_DEV_PATH points to a path that does not exist: ${p}. Falling back to PyPI.`),t.text=r?"Installing RapidKit from local path":"Installing RapidKit from PyPI";let _=false,P=null;for(let R=1;R<=3;R++)try{r||d$2({status:"started",message:"Installing RapidKit from PyPI",installMethod:"poetry",attempt:R,maxAttempts:3}),await execa(f,["-m","pip","install",i,"--quiet"],{cwd:e,timeout:18e4}),_=true,r||d$2({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"poetry",attempt:R,maxAttempts:3});break}catch(O){P=O,e$1.debug(`pip install rapidkit-core attempt ${R} failed: ${O}`),R<3&&(t.text=`Retrying installation (attempt ${R+1}/3)`,await new Promise(ce=>setTimeout(ce,2e3)));}if(!_){let R=P?.stderr||P?.message||"Unknown error";throw e$1.debug(`All pip install attempts failed. Last error: ${R}`),R.includes("Could not find")||R.includes("No matching distribution")?new i$1:new f$1("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
150
+ `),await promises.writeFile(g,r,"utf-8");}t.start("Configuring Poetry");try{await execa("poetry",["config","virtualenvs.in-project","true","--local"],{cwd:e}),t.succeed("Poetry configured");}catch{t.warn("Could not configure Poetry virtualenvs.in-project");}t.start("Creating virtualenv");let y=u||T(),f=m(d.join(e,".venv"));try{await execa(y,["-m","venv",".venv"],{cwd:e,timeout:6e4}),t.succeed("Virtualenv created");}catch(p){e$2.debug(`python -m venv failed: ${p}`),t.warn("Could not pre-create virtualenv, Poetry will try"),f=u||T();}try{await execa("poetry",["env","use",f||T()],{cwd:e}),e$2.debug(`Poetry env set to: ${f}`);}catch(p){e$2.debug(`Could not set Poetry env: ${p}`);}if(t.start("Installing RapidKit"),h&&!o){let p=e$3(a||{}),r=p?await k.pathExists(p):false,i=r&&p?p:"rapidkit-core";p&&!r&&e$2.warn(`WORKSPAI_DEV_PATH/RAPIDKIT_DEV_PATH points to a path that does not exist: ${p}. Falling back to PyPI.`),t.text=r?"Installing RapidKit from local path":"Installing RapidKit from PyPI";let _=false,P=null;for(let R=1;R<=3;R++)try{r||d$1({status:"started",message:"Installing RapidKit from PyPI",installMethod:"poetry",attempt:R,maxAttempts:3}),await execa(f,["-m","pip","install",i,"--quiet"],{cwd:e,timeout:18e4}),_=true,r||d$1({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"poetry",attempt:R,maxAttempts:3});break}catch(O){P=O,e$2.debug(`pip install rapidkit-core attempt ${R} failed: ${O}`),R<3&&(t.text=`Retrying installation (attempt ${R+1}/3)`,await new Promise(ce=>setTimeout(ce,2e3)));}if(!_){let R=P?.stderr||P?.message||"Unknown error";throw e$2.debug(`All pip install attempts failed. Last error: ${R}`),R.includes("Could not find")||R.includes("No matching distribution")?new i$1:new f$1("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
151
151
  Error: ${R}
152
152
 
153
153
  Possible solutions:
154
154
  1. Check your internet connection
155
155
  2. Try installing manually: cd ${d.basename(e)} && poetry add rapidkit-core
156
- 3. Use venv method instead: npx workspai ${d.basename(e)} --install-method=venv`))}}else {t.text="Syncing Poetry environment";try{await execa("poetry",["install","--no-root"],{cwd:e,timeout:12e4}),t.succeed("Poetry environment synced");}catch(p){e$1.debug(`poetry install --no-root failed: ${p}`),t.warn("Could not sync Poetry environment, proceeding with add command");}if(t.start("Installing RapidKit"),o){let p=e$2(a||{});if(!p)throw new f$1("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));e$1.debug(`Installing from local path: ${p}`),t.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",p],{cwd:e});}else {t.text="Installing RapidKit from PyPI";let p=false,r=null;for(let i=1;i<=3;i++)try{d$2({status:"started",message:"Installing RapidKit from PyPI",installMethod:"poetry",attempt:i,maxAttempts:3}),await execa("poetry",["add","rapidkit-core"],{cwd:e,timeout:6e4*i}),p=true,d$2({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"poetry",attempt:i,maxAttempts:3});break}catch(_){r=_,e$1.debug(`Poetry add attempt ${i} failed: ${_}`),i<3&&(t.text=`Retrying installation (attempt ${i+1}/3)`,await new Promise(P=>setTimeout(P,2e3)));}if(!p){let i=r?.stderr||r?.message||"Unknown error";throw e$1.debug(`All Poetry install attempts failed. Last error: ${i}`),i.includes("Could not find")||i.includes("No matching distribution")?new i$1:new f$1("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
156
+ 3. Use venv method instead: npx workspai ${d.basename(e)} --install-method=venv`))}}else {t.text="Syncing Poetry environment";try{await execa("poetry",["install","--no-root"],{cwd:e,timeout:12e4}),t.succeed("Poetry environment synced");}catch(p){e$2.debug(`poetry install --no-root failed: ${p}`),t.warn("Could not sync Poetry environment, proceeding with add command");}if(t.start("Installing RapidKit"),o){let p=e$3(a||{});if(!p)throw new f$1("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));e$2.debug(`Installing from local path: ${p}`),t.text="Installing RapidKit from local path (test mode)",await execa("poetry",["add",p],{cwd:e});}else {t.text="Installing RapidKit from PyPI";let p=false,r=null;for(let i=1;i<=3;i++)try{d$1({status:"started",message:"Installing RapidKit from PyPI",installMethod:"poetry",attempt:i,maxAttempts:3}),await execa("poetry",["add","rapidkit-core"],{cwd:e,timeout:6e4*i}),p=true,d$1({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"poetry",attempt:i,maxAttempts:3});break}catch(_){r=_,e$2.debug(`Poetry add attempt ${i} failed: ${_}`),i<3&&(t.text=`Retrying installation (attempt ${i+1}/3)`,await new Promise(P=>setTimeout(P,2e3)));}if(!p){let i=r?.stderr||r?.message||"Unknown error";throw e$2.debug(`All Poetry install attempts failed. Last error: ${i}`),i.includes("Could not find")||i.includes("No matching distribution")?new i$1:new f$1("Install rapidkit-core with Poetry",new Error(`Failed to install rapidkit-core after 3 attempts.
157
157
  Error: ${i}
158
158
 
159
159
  Possible solutions:
160
160
  1. Check your internet connection
161
161
  2. Try installing manually: cd ${d.basename(e)} && poetry add rapidkit-core
162
- 3. Use venv method instead: npx workspai ${d.basename(e)} --install-method=venv`))}}}t.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:p}=await import('./pythonRapidkitExec-44ORGQ4R.js');if(!await p()&&!o){t.start("Checking optional global pipx installation");let i=await he(t,true);try{t.start("Installing RapidKit globally with pipx for CLI access"),await U(i,["install","rapidkit-core"]),t.succeed("RapidKit installed globally");}catch(_){t.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),e$1.debug(`pipx install failed: ${_}`);}}}catch(p){t.succeed("Skipped optional global pipx installation"),e$1.debug(`Global install check skipped: ${p}`);}}async function Ee(e,n,t,o,a,l=false){t.start(`Checking Python ${n}`);let u=T();try{let{stdout:c}=await execa(u,["--version"]),h=c.match(/Python (\d+\.\d+)/)?.[1];if(h&&!ee(h,n))throw new b$6(n,h);t.succeed(`Python ${h} found`);}catch(c){throw c instanceof b$6?c:new b$6(n)}t.start("Creating virtual environment");try{await execa(u,["-m","venv",".venv"],{cwd:e}),t.succeed("Virtual environment created");}catch(c){if(t.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)/),f=y?y[1]:"python3-venv";throw new g(f,d.basename(e))}throw new f$1("Virtual environment creation",c instanceof Error?c:new Error(String(c)))}t.start("Installing RapidKit");let g$1=m(d.join(e,".venv"));if(await execa(g$1,["-m","pip","install","--upgrade","pip"],{cwd:e}),o){let c=e$2(a||{});if(!c)throw new f$1("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));e$1.debug(`Installing from local path: ${c}`),t.text="Installing RapidKit from local path (test mode)",await execa(g$1,["-m","pip","install","-e",c],{cwd:e});}else {t.text="Installing RapidKit from PyPI";let c=false,h=null;for(let y=1;y<=3;y++)try{d$2({status:"started",message:"Installing RapidKit from PyPI",installMethod:"venv",attempt:y,maxAttempts:3}),await execa(g$1,["-m","pip","install","rapidkit-core"],{cwd:e,timeout:6e4*y}),c=true,d$2({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"venv",attempt:y,maxAttempts:3});break}catch(f){h=f,e$1.debug(`pip install attempt ${y} failed: ${f}`),y<3&&(t.text=`Retrying installation (attempt ${y+1}/3)`,await new Promise(p=>setTimeout(p,2e3)));}if(!c){let y=h?.stderr||h?.message||"Unknown error";throw e$1.debug(`All pip install attempts failed. Last error: ${y}`),y.includes("Could not find")||y.includes("No matching distribution")?new i$1:new f$1("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
162
+ 3. Use venv method instead: npx workspai ${d.basename(e)} --install-method=venv`))}}}t.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:p}=await import('./pythonRapidkitExec-44ORGQ4R.js');if(!await p()&&!o){t.start("Checking optional global pipx installation");let i=await he(t,true);try{t.start("Installing RapidKit globally with pipx for CLI access"),await U(i,["install","rapidkit-core"]),t.succeed("RapidKit installed globally");}catch(_){t.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),e$2.debug(`pipx install failed: ${_}`);}}}catch(p){t.succeed("Skipped optional global pipx installation"),e$2.debug(`Global install check skipped: ${p}`);}}async function Ee(e,n,t,o,a,l=false){t.start(`Checking Python ${n}`);let u=T();try{let{stdout:c}=await execa(u,["--version"]),h=c.match(/Python (\d+\.\d+)/)?.[1];if(h&&!ee(h,n))throw new b$5(n,h);t.succeed(`Python ${h} found`);}catch(c){throw c instanceof b$5?c:new b$5(n)}t.start("Creating virtual environment");try{await execa(u,["-m","venv",".venv"],{cwd:e}),t.succeed("Virtual environment created");}catch(c){if(t.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)/),f=y?y[1]:"python3-venv";throw new g(f,d.basename(e))}throw new f$1("Virtual environment creation",c instanceof Error?c:new Error(String(c)))}t.start("Installing RapidKit");let g$1=m(d.join(e,".venv"));if(await execa(g$1,["-m","pip","install","--upgrade","pip"],{cwd:e}),o){let c=e$3(a||{});if(!c)throw new f$1("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));e$2.debug(`Installing from local path: ${c}`),t.text="Installing RapidKit from local path (test mode)",await execa(g$1,["-m","pip","install","-e",c],{cwd:e});}else {t.text="Installing RapidKit from PyPI";let c=false,h=null;for(let y=1;y<=3;y++)try{d$1({status:"started",message:"Installing RapidKit from PyPI",installMethod:"venv",attempt:y,maxAttempts:3}),await execa(g$1,["-m","pip","install","rapidkit-core"],{cwd:e,timeout:6e4*y}),c=true,d$1({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"venv",attempt:y,maxAttempts:3});break}catch(f){h=f,e$2.debug(`pip install attempt ${y} failed: ${f}`),y<3&&(t.text=`Retrying installation (attempt ${y+1}/3)`,await new Promise(p=>setTimeout(p,2e3)));}if(!c){let y=h?.stderr||h?.message||"Unknown error";throw e$2.debug(`All pip install attempts failed. Last error: ${y}`),y.includes("Could not find")||y.includes("No matching distribution")?new i$1:new f$1("Install rapidkit-core with pip",new Error(`Failed to install rapidkit-core after 3 attempts.
163
163
  Error: ${y}
164
164
 
165
165
  Possible solutions:
166
166
  1. Check your internet connection
167
167
  2. Try installing manually: cd ${d.basename(e)} && ${m(".venv")} -m pip install rapidkit-core
168
- 3. Use Poetry instead: npx workspai ${d.basename(e)} --install-method=poetry`))}}t.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await import('./pythonRapidkitExec-44ORGQ4R.js');if(!await c()&&!o){t.start("Checking optional global pipx installation");let y=await he(t,true);try{t.start("Installing RapidKit globally with pipx for CLI access"),await U(y,["install","rapidkit-core"]),t.succeed("RapidKit installed globally");}catch(f){t.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),e$1.debug(`pipx install failed: ${f}`);}}}catch(c){t.succeed("Skipped optional global pipx installation"),e$1.debug(`Global install check skipped: ${c}`);}}async function it(e,n,t,o,a=false){if(!t)try{let{checkRapidkitCoreVersionCompatible:u}=await import('./pythonRapidkitExec-44ORGQ4R.js'),g=await u();if(g.isCompatible){n.succeed(`RapidKit ${g.installedVersion??""} already compatible globally; skipping pipx installation`),await k.outputFile(d.join(e,".rapidkit-global"),`RapidKit already available globally (version ${g.installedVersion??"unknown"}) and satisfies expected constraint ${g.expectedConstraint??"n/a"}; workspace will reuse the existing installation
169
- `,"utf-8");return}g.reason==="constraint-missing"?e$1.debug('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"&&e$1.debug('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.'),e$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(u){e$1.debug(`Global RapidKit version-aware check failed before pipx install: ${u}`);}let l=await he(n,a);if(n.start("Installing RapidKit globally with pipx"),t){let u=e$2(o||{});if(!u)throw new f$1("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));e$1.debug(`Installing from local path: ${u}`),n.text="Installing RapidKit from local path (test mode)",await U(l,["install","-e",u]);}else {n.text="Installing RapidKit from PyPI",d$2({status:"started",message:"Installing RapidKit from PyPI",installMethod:"pipx"});try{await U(l,["install","rapidkit-core"]),d$2({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"pipx"});}catch(u){try{n.text="RapidKit already installed globally, upgrading to match expected version",await U(l,["upgrade","rapidkit-core"]),d$2({status:"succeeded",message:"RapidKit upgraded from PyPI",installMethod:"pipx"});}catch(g){throw e$1.debug(`pipx install/upgrade failed: install=${u}, upgrade=${g}`),new i$1}}}n.succeed("RapidKit installed globally"),await k.outputFile(d.join(e,".rapidkit-global"),`RapidKit installed globally with pipx
170
- `,"utf-8");}async function an(e,n){let{skipGit:t=false,installPythonEngine:o=false,testMode:a=false,userConfig:l={},yes:u=false,installMethod:g,pythonVersion:c="3.10"}=n||{},h="venv";o&&(h=g||l.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return e$1.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})());let y=b$3("Registering workspace",{component:"create",phase:"workspace.register"}),f=await ut(e);try{let p=d.basename(e),r=o?void 0:{bootstrapNote:"python-engine-skipped",pythonEngine:"skipped",pythonEngineReason:"project-workspace-foundation"};await Q(e,p,h,o?c:void 0,r),await H(e),await Z(e,p,h,o?c:void 0,n?.profile??"minimal",r),o?h==="poetry"?(await Ye(e,p),await ot(e,c,y,a,l,u)):h==="venv"?await Ee(e,c,y,a,l):await it(e,y,a,l,u):await ge(e,h,{pythonEngineSkipped:true}),o&&await ge(e,h),y.succeed(o?"Workspace registered":"Workspace registered (Python engine skipped)"),await b$4(e,{workspaceName:d.basename(e),silent:a}),await J(f),t||await X(e,y,"Initial commit: Workspai workspace");}catch(p){return y.fail("Failed to register workspace"),F(f,p)}}async function xt(e,n,t){let o=b$3("Creating demo workspace",{component:"create",phase:"workspace.demo"});try{await k.ensureDir(e),o.succeed("Directory created"),o.start("Setting up demo kit generator");let a$1=JSON.stringify({name:`${n}-workspace`,version:"1.0.0",private:true,description:"Workspai demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(d.join(e,"package.json"),a$1,"utf-8"),await promises.writeFile(d.join(e,"generate-demo.js"),`#!/usr/bin/env node
168
+ 3. Use Poetry instead: npx workspai ${d.basename(e)} --install-method=poetry`))}}t.succeed("RapidKit installed in project virtualenv");try{let{checkRapidkitCoreAvailable:c}=await import('./pythonRapidkitExec-44ORGQ4R.js');if(!await c()&&!o){t.start("Checking optional global pipx installation");let y=await he(t,true);try{t.start("Installing RapidKit globally with pipx for CLI access"),await U(y,["install","rapidkit-core"]),t.succeed("RapidKit installed globally");}catch(f){t.warn("Could not install globally (non-fatal, project virtualenv has RapidKit)"),e$2.debug(`pipx install failed: ${f}`);}}}catch(c){t.succeed("Skipped optional global pipx installation"),e$2.debug(`Global install check skipped: ${c}`);}}async function it(e,n,t,o,a=false){if(!t)try{let{checkRapidkitCoreVersionCompatible:u}=await import('./pythonRapidkitExec-44ORGQ4R.js'),g=await u();if(g.isCompatible){n.succeed(`RapidKit ${g.installedVersion??""} already compatible globally; skipping pipx installation`),await k.outputFile(d.join(e,".rapidkit-global"),`RapidKit already available globally (version ${g.installedVersion??"unknown"}) and satisfies expected constraint ${g.expectedConstraint??"n/a"}; workspace will reuse the existing installation
169
+ `,"utf-8");return}g.reason==="constraint-missing"?e$2.debug('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"&&e$2.debug('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.'),e$2.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(u){e$2.debug(`Global RapidKit version-aware check failed before pipx install: ${u}`);}let l=await he(n,a);if(n.start("Installing RapidKit globally with pipx"),t){let u=e$3(o||{});if(!u)throw new f$1("Test mode installation",new Error("No local RapidKit path configured. Set WORKSPAI_DEV_PATH (or legacy RAPIDKIT_DEV_PATH)."));e$2.debug(`Installing from local path: ${u}`),n.text="Installing RapidKit from local path (test mode)",await U(l,["install","-e",u]);}else {n.text="Installing RapidKit from PyPI",d$1({status:"started",message:"Installing RapidKit from PyPI",installMethod:"pipx"});try{await U(l,["install","rapidkit-core"]),d$1({status:"succeeded",message:"RapidKit installed from PyPI",installMethod:"pipx"});}catch(u){try{n.text="RapidKit already installed globally, upgrading to match expected version",await U(l,["upgrade","rapidkit-core"]),d$1({status:"succeeded",message:"RapidKit upgraded from PyPI",installMethod:"pipx"});}catch(g){throw e$2.debug(`pipx install/upgrade failed: install=${u}, upgrade=${g}`),new i$1}}}n.succeed("RapidKit installed globally"),await k.outputFile(d.join(e,".rapidkit-global"),`RapidKit installed globally with pipx
170
+ `,"utf-8");}async function an(e,n){let{skipGit:t=false,installPythonEngine:o=false,testMode:a=false,userConfig:l={},yes:u=false,installMethod:g,pythonVersion:c="3.10"}=n||{},h="venv";o&&(h=g||l.defaultInstallMethod||await(async()=>{try{return await execa("poetry",["--version"],{timeout:3e3}),"poetry"}catch{return e$2.warn("Poetry not found \u2014 auto-selecting venv. Pass --install-method poetry to override."),"venv"}})());let y=b$2("Registering workspace",{component:"create",phase:"workspace.register"}),f=await ut(e);try{let p=d.basename(e),r=o?void 0:{bootstrapNote:"python-engine-skipped",pythonEngine:"skipped",pythonEngineReason:"project-workspace-foundation"};await Q(e,p,h,o?c:void 0,r),await H(e),await Z(e,p,h,o?c:void 0,n?.profile??"minimal",r),o?h==="poetry"?(await Ye(e,p),await ot(e,c,y,a,l,u)):h==="venv"?await Ee(e,c,y,a,l):await it(e,y,a,l,u):await ge(e,h,{pythonEngineSkipped:true}),o&&await ge(e,h),y.succeed(o?"Workspace registered":"Workspace registered (Python engine skipped)"),await b$3(e,{workspaceName:d.basename(e),silent:a}),await J(f),t||await X(e,y,"Initial commit: Workspai workspace");}catch(p){return y.fail("Failed to register workspace"),F(f,p)}}async function xt(e,n,t){let o=b$2("Creating demo workspace",{component:"create",phase:"workspace.demo"});try{await k.ensureDir(e),o.succeed("Directory created"),o.start("Setting up demo kit generator");let a$1=JSON.stringify({name:`${n}-workspace`,version:"1.0.0",private:true,description:"Workspai demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(d.join(e,"package.json"),a$1,"utf-8"),await promises.writeFile(d.join(e,"generate-demo.js"),`#!/usr/bin/env node
171
171
  /**
172
172
  * Demo Kit Generator - Create FastAPI demo projects
173
173
  *
@@ -2,7 +2,7 @@ import {c}from'./chunk-N4B2M44I.js';import {a}from'./chunk-A5FBGRJA.js';import {
2
2
  `);}async function se(e,r){let t=n.dirname(e);await promises.mkdir(t,{recursive:true});let o=`${e}.${process.pid}.${randomUUID()}.tmp`;try{await promises.writeFile(o,r);let a=await promises.open(o,"r");try{await ae(a);}finally{await a.close();}try{await promises.rename(o,e);}catch(s){let i=s.code;if(i!=="EEXIST"&&i!=="EPERM")throw s;await le.move(o,e,{overwrite:true});}}finally{await promises.rm(o,{force:true}).catch(()=>{});}}async function Z(e){try{return {exists:true,content:await promises.readFile(e)}}catch(r){if(r.code==="ENOENT")return {exists:false};throw r}}async function ee(e,r){if(!r.exists){await promises.rm(e,{force:true});return}await se(e,r.content);}async function we(e,r){let t=n.join(e,"workspaces.json.lock"),o=randomUUID();await promises.mkdir(e,{recursive:true});let a=Date.now(),s;for(;!s;)try{s=await promises.open(t,"wx"),await s.writeFile(`${JSON.stringify({pid:process.pid,lockId:o,createdAt:new Date().toISOString()})}
3
3
  `),await ae(s);}catch(i){if(i.code!=="EEXIST")throw i;let c=await promises.stat(t).catch(()=>null);if(c&&Date.now()-c.mtimeMs>de){let d=await promises.readFile(t,"utf8").then(g=>JSON.parse(g)).catch(()=>null),u=Number(d?.pid),f=false;if(Number.isInteger(u)&&u>0)try{process.kill(u,0),f=true;}catch(g){f=g.code==="EPERM";}if(!f){await promises.rm(t,{force:true}).catch(()=>{});continue}}if(Date.now()-a>me)throw new Error(`Timed out waiting for workspace registry lock: ${t}`);await new Promise(d=>setTimeout(d,25));}try{return await r()}finally{await s.close().catch(()=>{}),await promises.readFile(t,"utf8").then(c=>JSON.parse(c).lockId===o).catch(()=>false)&&await promises.rm(t,{force:true}).catch(()=>{});}}async function S(e){let r$1=q(),t=n.join(r$1,"workspaces.json"),o=n.join(r(),"workspaces.json"),a=[...new Set(s$1())];return we(r$1,async()=>{let[s,i]=await Promise.all([Z(t),Z(o)]),c=await oe(a);await e(c);let d=I(c);try{await X(t,d),await X(o,d);}catch(u){let g=(await Promise.allSettled([ee(t,s),ee(o,i)])).filter(k=>k.status==="rejected").map(k=>k.reason);throw g.length>0?new AggregateError([u,...g],"Workspace registry transaction failed and could not be fully restored"):u}return d})}async function ie(e,r){let t=a(e);await S(o=>{let a=o.workspaces.find(s=>s.path===t);if(a){a.name=r,a.mode=a.mode||"full",a.projects=Array.isArray(a.projects)?a.projects:[];return}o.workspaces.push({name:r,path:t,mode:"full",projects:[]});});}async function He(e){let r=a(e),o=(await oe()).workspaces.find(a=>a.path===r);return o?{...o,projects:o.projects.map(a=>({...a}))}:null}async function Ke(e,r){let t=a(e);await S(o=>{let a=o.workspaces.findIndex(i=>i.path===t);if(!r){a>=0&&o.workspaces.splice(a,1);return}let s=G(r);a>=0?o.workspaces[a]=s:o.workspaces.push(s);});}async function qe(e){let r=a(e);await S(t=>{t.workspaces=t.workspaces.filter(o=>o.path!==r);});}async function he(e,r){try{await ie(e,r);}catch{console.warn(p.gray("Note: Could not register workspace in shared registry"));}}async function Qe(e,r=false){let t=a(e),o={workspacePath:t,workspaceFound:false,added:[],skipped:0};try{let a$1=await z(),s=a$1.workspaces.find(k=>k.path===t);if(!s){if(await he(t,n.basename(n.resolve(e))),a$1=await z(),s=a$1.workspaces.find(k=>k.path===t),!s)return r||console.log("\u26A0\uFE0F Workspace could not be registered in registry"),o;r||console.log("\u2714 Registered workspace in shared registry");}Array.isArray(s.projects)||(s.projects=[]);let i=0,c=0,d=[],u$1=[],f=[e],g=new Set;for(;f.length>0;){let k=f.shift();if(!k||g.has(k))continue;g.add(k);let w=await promises.readdir(k,{withFileTypes:true});for(let h of w){if(!h.isDirectory()||h.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(h.name))continue;let v=n.join(k,h.name),y=a(v);try{let x=false;for(let P of [...u(y,"context.json"),...u(y,"project.json")])try{await promises.access(P),x=true;break}catch{}if(x){let P=n.basename(y),m=s.projects.some($=>$.path===y);u$1.push({name:P,path:y}),m?c++:(s.projects.push({name:P,path:y}),i++,d.push(y),r||console.log(`\u2714 Added: ${n.relative(e,y)}`));continue}}catch{}f.push(v);}}return await S(k=>{let w=k.workspaces.find(y=>y.path===t);if(!w)return;let h=`${t}${n.sep}`,v=(w.projects||[]).filter(y=>y.path!==t&&!y.path.startsWith(h));w.projects=G({...w,projects:[...v,...u$1]}).projects;}),i>0?r||console.log(`
4
4
  \u2705 Synced ${i} project(s) to registry`):r||console.log(`
5
- \u2705 All projects already registered (${c} found)`),{workspacePath:t,workspaceFound:true,added:d,skipped:c}}catch(a){return r||console.error("\u274C Failed to sync projects:",a.message),o}}async function ye(e,r,t){let o=a(e),a$1=a(t);await S(s=>{let i=s.workspaces.find(u=>u.path===o);if(!i)throw new Error(`Workspace is not registered: ${o}`);i.projects=Array.isArray(i.projects)?i.projects:[];let c=i.projects.findIndex(u=>u.path===a$1||u.name===r),d={name:r,path:a$1};c>=0?i.projects[c]=d:i.projects.push(d);});}async function Xe(e,r,t){try{await ye(e,r,t);}catch{}}async function Ze(e,r){let t=N("Creating Workspai workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(n.join(e,".workspai"),{recursive:true});let o={workspace_name:r.name,author:r.author,rapidkit_version:h(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(n.join(e,".workspai","config.json"),JSON.stringify(o,null,2));let{syncWorkspaceFoundationFiles:a}=await import('./create-XYKXS3JB.js');await a(e,{workspaceName:r.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let s=$e();await promises.writeFile(n.join(e,"rapidkit"),s),await promises.chmod(n.join(e,"rapidkit"),493);let i=je();await promises.writeFile(n.join(e,"rapidkit.cmd"),i);let c=ve(r.name);await promises.writeFile(n.join(e,"README.md"),c),await promises.writeFile(n.join(e,".gitignore"),`# Workspai workspace
5
+ \u2705 All projects already registered (${c} found)`),{workspacePath:t,workspaceFound:true,added:d,skipped:c}}catch(a){return r||console.error("\u274C Failed to sync projects:",a.message),o}}async function ye(e,r,t){let o=a(e),a$1=a(t);await S(s=>{let i=s.workspaces.find(u=>u.path===o);if(!i)throw new Error(`Workspace is not registered: ${o}`);i.projects=Array.isArray(i.projects)?i.projects:[];let c=i.projects.findIndex(u=>u.path===a$1||u.name===r),d={name:r,path:a$1};c>=0?i.projects[c]=d:i.projects.push(d);});}async function Xe(e,r,t){try{await ye(e,r,t);}catch{}}async function Ze(e,r){let t=N("Creating Workspai workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(n.join(e,".workspai"),{recursive:true});let o={workspace_name:r.name,author:r.author,rapidkit_version:h(),created_at:new Date().toISOString(),type:"workspace"};await promises.writeFile(n.join(e,".workspai","config.json"),JSON.stringify(o,null,2));let{syncWorkspaceFoundationFiles:a}=await import('./create-EKA2QG5R.js');await a(e,{workspaceName:r.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let s=$e();await promises.writeFile(n.join(e,"rapidkit"),s),await promises.chmod(n.join(e,"rapidkit"),493);let i=je();await promises.writeFile(n.join(e,"rapidkit.cmd"),i);let c=ve(r.name);await promises.writeFile(n.join(e,"README.md"),c),await promises.writeFile(n.join(e,".gitignore"),`# Workspai workspace
6
6
  .env
7
7
  .env.*
8
8
  !.env.example
@@ -17,7 +17,7 @@ Thumbs.db
17
17
 
18
18
  # Logs
19
19
  *.log
20
- `),await _e(e),t.succeed("Workspace created!"),r.skipGit||await re(e,N(),"Initial commit: Workspai workspace"),await ie(e,r.name);let{publishWorkspaceRegistrySummary:u}=await import('./workspace-registry-summary-CBZDSG6I.js');await u(e),console.log(`
20
+ `),await _e(e),t.succeed("Workspace created!"),r.skipGit||await re(e,N(),"Initial commit: Workspai workspace"),await ie(e,r.name);let{publishWorkspaceRegistrySummary:u}=await import('./workspace-registry-summary-VKTJ7PHV.js');await u(e),console.log(`
21
21
  ${p.green("\u2728 Workspai workspace created successfully!")}
22
22
 
23
23
  ${p.bold("\u{1F4C2} Workspace structure:")}
@@ -1 +1 @@
1
- import {b}from'./chunk-TSYDTKXO.js';import {m,j,e}from'./chunk-UNXG3ZFV.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {a}from'./chunk-2LIVMG5C.js';import {s}from'./chunk-ODK4LCEL.js';import x from'crypto';import l from'path';import g from'fs-extra';var L=s.workspaceIntelligenceBenchmark.schemaVersion,O=s.workspaceIntelligenceBenchmark.artifactPath,S=s.workspaceIntelligenceBenchmark.contractPath,q={"agent-core.v1":{id:"agent-core.v1",version:1,title:"Cross-project agent retrieval core",scenarios:[{id:"architecture",title:"Architecture and runtime discovery",preferredKinds:["service","runtime-unit","language","project","workspace"]},{id:"ownership",title:"Dependency and ownership discovery",preferredKinds:["package","module","owner","project","workspace"]},{id:"interfaces",title:"Interface and contract discovery",preferredKinds:["api","endpoint","protocol","schema","project","workspace"]},{id:"change-safety",title:"Change safety and verification discovery",preferredKinds:["test-suite","lifecycle-stage","pipeline","module","project","workspace"]},{id:"delivery",title:"Build and delivery discovery",preferredKinds:["pipeline","deployment","container","lifecycle-stage","project","workspace"]}]}};function y(e,t){if(e.length===0)return 0;let n=[...e].sort((a,r)=>a-r),i=Math.min(n.length-1,Math.max(0,Math.ceil(t*n.length)-1));return n[i]??0}function G(e,t){let n=new Map;for(let a of e.entities){let r=a.label.trim().toLowerCase();n.set(r,(n.get(r)??0)+1);}for(let a of t){let r=e.entities.filter(s=>s.kind===a).sort((s,m)=>s.id.localeCompare(m.id)),o=r.find(s=>n.get(s.label.trim().toLowerCase())===1);if(o)return {entity:o,query:o.label};let u=r[0];if(u)return {entity:u,query:u.identity.key}}let i=[...e.entities].sort((a,r)=>a.id.localeCompare(r.id))[0];if(!i)throw new Error("Workspace benchmark requires at least one graph entity.");return {entity:i,query:i.identity.key}}function R(e){if(!e||e.summary.modelCalls===0)return "unavailable";let t=e.summary.tokenSources,n=t.providerReported+t.tokenizerCounted;return n+t.estimated+t.unavailable!==e.summary.modelCalls?"mixed":n===e.summary.modelCalls?"measured":t.estimated===e.summary.modelCalls?"estimated":t.unavailable===e.summary.modelCalls?"unavailable":"mixed"}function H(e){return e.comparison?.taskAligned===true&&e.comparison.comparableOutcome===true&&e.currentProvenance==="measured"&&e.baselineProvenance==="measured"?e.comparison.delta.reductionPercent:null}async function W(e,t){try{return await j(e,t)}catch{return}}async function Y(e$1){let t=l.resolve(e$1.workspacePath),n=e$1.suite??"agent-core.v1",i=q[n],a$2=[],r;for(let c of i.scenarios){let v=G(e$1.graph,c.preferredKinds),h=v.entity,d=await b({workspacePath:t,graph:e$1.graph,query:v.query,limit:e$1.limit??12,...r?{corpus:r}:{},now:e$1.now});r=d.corpus;let C=d.retrieval.payload.entities.some(M=>M.id===h.id);a$2.push({id:c.id,title:c.title,query:v.query,queryOrigin:"graph-derived",targetEntityId:h.id,targetKind:h.kind,targetRetrieved:C,result:C?"matched":"empty",matchCount:d.retrieval.matchCount,truncated:d.retrieval.truncated,retrievalCharacterCount:d.retrieval.characterCount,retrievalEstimatedTokens:d.retrieval.estimatedTokens,estimatedTokensAvoided:d.savings.estimatedTokensAvoided,estimatedReductionPercent:d.savings.reductionPercent});}r??={artifactCount:0,characterCount:0,estimatedTokens:0,unreadableArtifacts:[]};let o=await W(t,e$1.evaluationPath??e),u=e$1.baselineEvaluationPath?await W(t,e$1.baselineEvaluationPath):void 0,s=o&&u?m(o,u):void 0,m$1=R(o),_=R(u),K=H({comparison:s,currentProvenance:m$1,baselineProvenance:_}),N=await a(t),f=a$2.filter(c=>c.result==="matched").length,E=a$2.map(c=>c.retrievalEstimatedTokens),B=a$2.map(c=>c.estimatedReductionPercent),b$1={schemaVersion:L,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:N?.name||l.basename(t),path:t},suite:{id:i.id,version:i.version,title:i.title},graph:{schemaVersion:e$1.graph.schemaVersion,sourceArtifact:e$1.graph.source.artifact,sourceHash:e$1.graph.source.hash,entityCount:e$1.graph.entities.length,relationCount:e$1.graph.relations.length,proofCount:e$1.graph.proofs.length},methodology:{id:"multi-scenario-bounded-retrieval.v1",charsPerEstimatedToken:4,deterministic:true,networkRequired:false,scenarioTargetPolicy:"evidence-backed-representative.v1",claimBoundary:"Retrieval values estimate payload size against readable proof-source text across fixed scenario categories with deterministic evidence-backed representative targets. They do not establish answer equivalence, model billing savings, or task success."},corpus:r,scenarios:a$2,retrievalSummary:{provenance:"estimated",scenarioCount:a$2.length,matchedScenarioCount:f,medianRetrievalEstimatedTokens:y(E,.5),p95RetrievalEstimatedTokens:y(E,.95),medianEstimatedReductionPercent:y(B,.5),status:r.estimatedTokens===0?"unavailable":f===a$2.length?"passed":"partial"},evaluation:{availability:o?"available":"unavailable",provenance:m$1,...o?{current:{runId:o.runId,taskId:o.configuration.taskId,strategy:o.configuration.strategy,status:o.status,summary:o.summary}}:{},...s?{comparison:s}:{},trustedMeasuredReductionPercent:K,claimBoundary:"A measured reduction is reported only for task-aligned runs with comparable verified outcomes when every model call in both runs uses provider-reported or tokenizer-counted usage."}};return a$1(b$1,S,"workspace intelligence benchmark"),b$1}async function Z(e,t,n=O){a$1(t,S,n);let i=l.isAbsolute(n)?n:l.join(l.resolve(e),n),a=l.relative(l.resolve(e),i);if(a.startsWith("..")||l.isAbsolute(a))throw new Error("Workspace benchmark output must remain inside the workspace.");await g.ensureDir(l.dirname(i));let r=`${i}.${process.pid}.${x.randomUUID()}.tmp`;try{await g.writeJson(r,t,{spaces:2}),await g.rename(r,i);}finally{await g.remove(r).catch(()=>{});}return i}export{L as a,O as b,S as c,q as d,R as e,H as f,Y as g,Z as h};
1
+ import {b}from'./chunk-RPM67N7A.js';import {m,j,e}from'./chunk-ZS7JHATN.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {a}from'./chunk-252EKOR6.js';import {s}from'./chunk-ODK4LCEL.js';import x from'crypto';import l from'path';import g from'fs-extra';var L=s.workspaceIntelligenceBenchmark.schemaVersion,O=s.workspaceIntelligenceBenchmark.artifactPath,S=s.workspaceIntelligenceBenchmark.contractPath,q={"agent-core.v1":{id:"agent-core.v1",version:1,title:"Cross-project agent retrieval core",scenarios:[{id:"architecture",title:"Architecture and runtime discovery",preferredKinds:["service","runtime-unit","language","project","workspace"]},{id:"ownership",title:"Dependency and ownership discovery",preferredKinds:["package","module","owner","project","workspace"]},{id:"interfaces",title:"Interface and contract discovery",preferredKinds:["api","endpoint","protocol","schema","project","workspace"]},{id:"change-safety",title:"Change safety and verification discovery",preferredKinds:["test-suite","lifecycle-stage","pipeline","module","project","workspace"]},{id:"delivery",title:"Build and delivery discovery",preferredKinds:["pipeline","deployment","container","lifecycle-stage","project","workspace"]}]}};function y(e,t){if(e.length===0)return 0;let n=[...e].sort((a,r)=>a-r),i=Math.min(n.length-1,Math.max(0,Math.ceil(t*n.length)-1));return n[i]??0}function G(e,t){let n=new Map;for(let a of e.entities){let r=a.label.trim().toLowerCase();n.set(r,(n.get(r)??0)+1);}for(let a of t){let r=e.entities.filter(s=>s.kind===a).sort((s,m)=>s.id.localeCompare(m.id)),o=r.find(s=>n.get(s.label.trim().toLowerCase())===1);if(o)return {entity:o,query:o.label};let u=r[0];if(u)return {entity:u,query:u.identity.key}}let i=[...e.entities].sort((a,r)=>a.id.localeCompare(r.id))[0];if(!i)throw new Error("Workspace benchmark requires at least one graph entity.");return {entity:i,query:i.identity.key}}function R(e){if(!e||e.summary.modelCalls===0)return "unavailable";let t=e.summary.tokenSources,n=t.providerReported+t.tokenizerCounted;return n+t.estimated+t.unavailable!==e.summary.modelCalls?"mixed":n===e.summary.modelCalls?"measured":t.estimated===e.summary.modelCalls?"estimated":t.unavailable===e.summary.modelCalls?"unavailable":"mixed"}function H(e){return e.comparison?.taskAligned===true&&e.comparison.comparableOutcome===true&&e.currentProvenance==="measured"&&e.baselineProvenance==="measured"?e.comparison.delta.reductionPercent:null}async function W(e,t){try{return await j(e,t)}catch{return}}async function Y(e$1){let t=l.resolve(e$1.workspacePath),n=e$1.suite??"agent-core.v1",i=q[n],a$2=[],r;for(let c of i.scenarios){let v=G(e$1.graph,c.preferredKinds),h=v.entity,d=await b({workspacePath:t,graph:e$1.graph,query:v.query,limit:e$1.limit??12,...r?{corpus:r}:{},now:e$1.now});r=d.corpus;let C=d.retrieval.payload.entities.some(M=>M.id===h.id);a$2.push({id:c.id,title:c.title,query:v.query,queryOrigin:"graph-derived",targetEntityId:h.id,targetKind:h.kind,targetRetrieved:C,result:C?"matched":"empty",matchCount:d.retrieval.matchCount,truncated:d.retrieval.truncated,retrievalCharacterCount:d.retrieval.characterCount,retrievalEstimatedTokens:d.retrieval.estimatedTokens,estimatedTokensAvoided:d.savings.estimatedTokensAvoided,estimatedReductionPercent:d.savings.reductionPercent});}r??={artifactCount:0,characterCount:0,estimatedTokens:0,unreadableArtifacts:[]};let o=await W(t,e$1.evaluationPath??e),u=e$1.baselineEvaluationPath?await W(t,e$1.baselineEvaluationPath):void 0,s=o&&u?m(o,u):void 0,m$1=R(o),_=R(u),K=H({comparison:s,currentProvenance:m$1,baselineProvenance:_}),N=await a(t),f=a$2.filter(c=>c.result==="matched").length,E=a$2.map(c=>c.retrievalEstimatedTokens),B=a$2.map(c=>c.estimatedReductionPercent),b$1={schemaVersion:L,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:N?.name||l.basename(t),path:t},suite:{id:i.id,version:i.version,title:i.title},graph:{schemaVersion:e$1.graph.schemaVersion,sourceArtifact:e$1.graph.source.artifact,sourceHash:e$1.graph.source.hash,entityCount:e$1.graph.entities.length,relationCount:e$1.graph.relations.length,proofCount:e$1.graph.proofs.length},methodology:{id:"multi-scenario-bounded-retrieval.v1",charsPerEstimatedToken:4,deterministic:true,networkRequired:false,scenarioTargetPolicy:"evidence-backed-representative.v1",claimBoundary:"Retrieval values estimate payload size against readable proof-source text across fixed scenario categories with deterministic evidence-backed representative targets. They do not establish answer equivalence, model billing savings, or task success."},corpus:r,scenarios:a$2,retrievalSummary:{provenance:"estimated",scenarioCount:a$2.length,matchedScenarioCount:f,medianRetrievalEstimatedTokens:y(E,.5),p95RetrievalEstimatedTokens:y(E,.95),medianEstimatedReductionPercent:y(B,.5),status:r.estimatedTokens===0?"unavailable":f===a$2.length?"passed":"partial"},evaluation:{availability:o?"available":"unavailable",provenance:m$1,...o?{current:{runId:o.runId,taskId:o.configuration.taskId,strategy:o.configuration.strategy,status:o.status,summary:o.summary}}:{},...s?{comparison:s}:{},trustedMeasuredReductionPercent:K,claimBoundary:"A measured reduction is reported only for task-aligned runs with comparable verified outcomes when every model call in both runs uses provider-reported or tokenizer-counted usage."}};return a$1(b$1,S,"workspace intelligence benchmark"),b$1}async function Z(e,t,n=O){a$1(t,S,n);let i=l.isAbsolute(n)?n:l.join(l.resolve(e),n),a=l.relative(l.resolve(e),i);if(a.startsWith("..")||l.isAbsolute(a))throw new Error("Workspace benchmark output must remain inside the workspace.");await g.ensureDir(l.dirname(i));let r=`${i}.${process.pid}.${x.randomUUID()}.tmp`;try{await g.writeJson(r,t,{spaces:2}),await g.rename(r,i);}finally{await g.remove(r).catch(()=>{});}return i}export{L as a,O as b,S as c,q as d,R as e,H as f,Y as g,Z as h};
@@ -0,0 +1,2 @@
1
+ import {q as q$1,l,m,k as k$1}from'./chunk-TGDXD4CD.js';import {a}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {d as d$1}from'./chunk-G6ADWA2B.js';import {h as h$1}from'./chunk-FE5R6EUV.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {e,d,b as b$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import k from'path';import V from'fs-extra';import {spawnSync}from'child_process';function ue(){let e={...process.env};return delete e.GIT_DIR,delete e.GIT_WORK_TREE,delete e.GIT_INDEX_FILE,delete e.GIT_PREFIX,e}function x(e,t,a){let r=spawnSync("git",t,{cwd:e,env:ue(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(r.status!==0)return {ok:false,stdout:""};let i=r.stdout??"";return {ok:true,stdout:a?.preserveWhitespace?i:i.trim()}}function ge(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return t===".workspai/AGENT-GROUNDING.md"?true:[".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(a=>t.startsWith(a))}function ke(e){let t=[],a=[],r=[];for(let i of e.split(`
2
+ `)){if(!i.trim())continue;let n=i.slice(0,2),c=i.slice(3).trim();if(c&&!ge(c)){if(n==="??"){a.push(c);continue}n.includes("D")&&r.push(c),t.push(c);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(a)].sort(),deletedFiles:[...new Set(r)].sort()}}function Q(e,t){let a={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=x(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return a;let i=x(e,["rev-parse","--abbrev-ref","HEAD"]),n=x(e,["rev-parse","HEAD"]),c=x(e,["status","--porcelain=v1","--untracked-files=all"],{preserveWhitespace:true}),p=ke(c.stdout),m=p.changedFiles.length>0||p.untrackedFiles.length>0||p.deletedFiles.length>0;return {available:true,branch:i.ok?i.stdout:void 0,commit:n.ok?n.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:p.changedFiles,untrackedFiles:p.untrackedFiles,deletedFiles:p.deletedFiles}}var oe=q.snapshot,L=q.diff,T=p.snapshot,ae=p.diff,he=q.impact,we=p.impact;function ye(e$1){if(e$1.model.projectTopology||!e$1.model.graph||e$1.modelHash!==e(e$1.model))return null;let t={...e$1.model,projectTopology:e$1.model.graph,graph:e$1.model.graph};return {...e$1,modelHash:d(t),model:t}}function ne(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function We(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function se(e,t){return k.isAbsolute(t)?t:k.join(e,t)}async function be(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion===oe){a$1(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=a;if(!r.model||r.model.schemaVersion!==k$1)throw new Error(`Invalid workspace model snapshot: ${e}`);let i=d(r.model);if(r.modelHash!==i){let n=ye(r);if(!n)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:n.model,hash:n.modelHash}}return {model:r.model,hash:r.modelHash}}if(a.schemaVersion===k$1){a$1(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=a;return {model:r,hash:d(r)}}throw a.schemaVersion===L?new Error(`workspace diff --from received a diff report (${k.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${T}. To analyze an existing diff report, run: npx workspai workspace impact --from ${k.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(a.schemaVersion)}`)}async function ve(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion!==L)return null;a$1(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=a;if(!r.currentModel||r.currentModel.schemaVersion!==k$1||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==d(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Ye(e){let t=e.model??await q$1({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:oe,generatedAt:(e.now??new Date).toISOString(),modelHash:d(t),modelRef:l,model:t}}async function Qe(e,t){return h$1(t,T,d$1(e))}function F(e){let{evidence:t,...a}=e;return a}function h(e,t){e.push(t);}function je(e,t){let a=[],r=["name","profile","type"],i=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let n of r){let c=e.workspace[n],p=t.workspace[n];b$1(c)!==b$1(p)&&h(a,{type:"workspace.changed",severity:"info",target:`workspace.${n}`,message:`Workspace metadata field changed: ${String(n)}`,before:c,after:p});}for(let n of i){let c=e.identity[n],p=t.identity[n];b$1(c)!==b$1(p)&&h(a,{type:"workspace.changed",severity:"info",target:`identity.${n}`,message:`Workspace identity field changed: ${String(n)}`,before:c,after:p});}return b$1(e.policies)!==b$1(t.policies)&&h(a,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),b$1(e.discovery)!==b$1(t.discovery)&&h(a,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&h(a,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),a}function Me(e,t){let a=e.validation??null,r=t.validation??null;return b$1(a)===b$1(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:a,after:r}]}function Ie(e,t){let a=[],r=new Map(e.projects.map(n=>[n.path,n])),i=new Map(t.projects.map(n=>[n.path,n]));for(let[n,c]of i.entries()){let p=r.get(n);if(!p){h(a,{type:"project.added",severity:"info",target:n,message:`Project added: ${c.name}`,after:F(c)});continue}let m=F(p),l=F(c);if(b$1(m)!==b$1(l)){let u=p.runtime!==c.runtime||p.framework!==c.framework;h(a,{type:"project.changed",severity:u?"warning":"info",target:n,message:`Project changed: ${c.name}`,before:m,after:l});}}for(let[n,c]of r.entries())i.has(n)||h(a,{type:"project.removed",severity:"warning",target:n,message:`Project removed: ${c.name}`,before:F(c)});return a.sort((n,c)=>`${n.type}:${n.target}`.localeCompare(`${c.type}:${c.target}`))}async function Pe(e){let t=k.resolve(e.workspacePath),a=ne(e.fromPath),r=a?We(e.fromPath):void 0,i=e.fromPath;if(a){let f=k.join(t,T);if(!await V.pathExists(f))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");i=T;}let n=se(t,i),c=await be(n),p=e.model??await q$1({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=d(p),l$1=[...je(c.model,p),...Ie(c.model,p),...Me(c.model,p)],u;e.includeGitObservation!==false&&(u=e.gitObservation??Q(t,{ref:r}),u.available&&Se(l$1,u,p));let v=c.hash!==m;v&&!l$1.some(f=>!f.type.startsWith("git."))&&h(l$1,{type:"workspace.changed",severity:"warning",target:"model.structural-hash",message:"Workspace structural identity changed outside the currently classified diff fields.",before:c.hash,after:m});let P=l$1.filter(f=>f.type.startsWith("git.")).length,w=a?`git:${r??"HEAD"}`:k.relative(t,n).split(k.sep).join("/");return {schemaVersion:L,generatedAt:(e.now??new Date).toISOString(),fromRef:w,toRef:l,fromHash:c.hash,toHash:m,summary:{changed:v||P>0,addedProjects:l$1.filter(f=>f.type==="project.added").length,removedProjects:l$1.filter(f=>f.type==="project.removed").length,changedProjects:l$1.filter(f=>f.type==="project.changed").length,workspaceChanges:l$1.filter(f=>f.type==="workspace.changed").length,validationChanges:l$1.filter(f=>f.type==="validation.changed").length,gitChangedFiles:P},git:u?.available?Oe(u,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:l$1,currentModel:p}}async function Ze(e,t){return h$1(t,ae,d$1(e))}function I(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Z(e){return e.reduce((t,a)=>I(a)>I(t)?a:t,"none")}var N=["none","low","medium","high","critical"];function Re(e){let t=Math.max(1,I(e)-1);return N[t]}function Ce(e){let t=Math.min(N.length-1,I(e)+1);return N[t]}function ee(e){return e.join(" ")}function b(e,t,a,r){return {id:e,label:t,scope:r.scope,project:r.project,display:ee(["npx","workspai",...a]),execute:ee(["npx","--yes","--package","workspai","workspai",...a]),required:r.required!==false}}function te(e){let t=`project:${e.name}`,a=e.commands.fleetStages,r={init:`Run init for ${e.name}`,test:`Run tests for ${e.name}`,build:`Run build for ${e.name}`,start:`Run start for ${e.name}`};return ["init","test","build","start"].filter(i=>a.includes(i)).map(i=>b(`project.${e.name}.${i}`,r[i],["workspace","run",i,"--scope",t,"--json"],{scope:"project",project:e.name}))}function _(){return [b("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),b("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),b("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),b("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),b("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),b("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Ee(e,t){let a=t.split(k.sep).join("/");return e.projects.filter(i=>{let n=i.path.split(k.sep).join("/");return a===n||a.startsWith(`${n}/`)}).sort((i,n)=>n.path.length-i.path.length)[0]}function Se(e,t,a){let r=new Set(e.map(n=>n.target)),i=(n,c)=>{let p=c.split(k.sep).join("/"),m=`git:${p}`;if(r.has(m))return;let l=Ee(a,p),u=l?`${l.name} (${l.path})`:"workspace";h(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:m,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${u}: ${p}`,after:{path:p,project:l?.name,projectPath:l?.path}}),r.add(m);};for(let n of t.changedFiles)i("git.file.changed",n);for(let n of t.untrackedFiles)i("git.untracked",n);for(let n of t.deletedFiles)i("git.deleted",n);}function Oe(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Ae(e){let t=new Set,a=[];for(let r of e){let i=`${r.scope}:${r.project??""}:${r.display}`;t.has(i)||(t.add(i),a.push(r));}return a}function De(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function $e(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function xe(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(a=>a.severity==="critical"?false:a.type.startsWith("git.")||a.type==="validation.changed")?e.risk:I(e.risk)>=I("high")||e.risk==="medium"?"low":e.risk}function re(e,t){if(!e||e==="workspace")return true;let a=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,k.basename(t.path),t.absolutePath].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim().toLowerCase()).includes(a)}function Fe(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(a=>a.project?.name??a.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function et(e){let t=k.resolve(e.workspacePath),a$1=ne(e.fromPath),r=e.diff;if(!r&&!a$1){let o=se(t,e.fromPath);r=await ve(o)??void 0;}r||(r=await Pe({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let i=new Map(r.currentModel.projects.map(o=>[o.path,o])),n=new Map(r.currentModel.projects.map(o=>[o.name,o])),c$1=r.changes.filter(o=>o.type.startsWith("project.")),p=new Map;for(let o of c$1){let d=(i.get(o.target)??(typeof o.before?.name=="string"?n.get(o.before.name):void 0))?.path??o.target,y=p.get(d)??[];y.push(o),p.set(d,y);}let m$1=[];for(let[o,s]of p.entries()){let d=i.get(o);if(d&&!re(e.scope,d))continue;let y=Z(s.map(De)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):o);m$1.push({id:`project:${C}`,scope:"project",target:o,title:`Project impact: ${C}`,summary:s.map(j=>j.message).join(" "),risk:y,reasons:s.map(j=>`${j.type}: ${j.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?te(d):_()});}let l=m(r.currentModel),u=l?a(l):void 0,v=new Set(m$1.map(o=>o.project?.name).filter(o=>typeof o=="string")),P=new Map;for(let o of m$1)if(o.project?.name){let s=u?.byId.get(o.project.name);s&&(o.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(o.risk=Ce(o.risk),o.reasons=[...o.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),o.origin="direct",o.distance=0,P.set(o.project.name,o.risk);}let w=[],f=0;if(l&&v.size>0){let o=c(l,v);for(let s of o.values()){if(s.distance===0||v.has(s.id))continue;let d=n.get(s.id);if(d&&!re(e.scope,d))continue;let y=s.path[0],C=s.path[s.path.length-2]??y,j=P.get(y)??"medium",de=Re(j),M=u?.byId.get(s.id);f=Math.max(f,s.distance),w.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${y}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:de,reasons:[`graph.dependent: depends on ${C}${s.via?` via ${s.via}`:""} (path ${s.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?te(d):_(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...M?{centrality:{fanIn:M.fanIn,fanOut:M.fanOut,reach:M.reach,betweenness:M.betweenness,isHotspot:M.isHotspot}}:{}});}}w.sort((o,s)=>o.target.localeCompare(s.target));let ie=u?u.hotspots.flatMap(o=>{let s=u.byId.get(o);return s?[{project:o,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],ce=r.changes.filter(o=>!o.type.startsWith("project.")),K=r.currentModel.summary?.projectCount??r.currentModel.projects.length,R=ce.map(o=>({id:`workspace:${o.target}`,scope:"workspace",target:o.target,title:`Workspace impact: ${o.target}`,summary:o.message,risk:$e(o,{projectCount:K}),reasons:[`${o.type}: ${o.message}`],verification:_()})),B=Ae([...m$1.flatMap(o=>o.verification),...w.flatMap(o=>o.verification),...R.flatMap(o=>o.verification),...r.summary.changed?_():[]]).filter(o=>o.required),pe=Z([...m$1.map(o=>o.risk),...w.map(o=>o.risk),...R.map(o=>o.risk)]),z=xe({risk:pe,affectedProjects:m$1.length,projectCount:K,changes:r.changes}),q={changed:r.summary.changed,risk:z,affectedProjects:m$1.length,workspaceItems:R.length,recommendedCommands:B.length,blastRadius:{directlyAffected:m$1.length,transitivelyAffected:w.length,maxDistance:f,graphEdges:l?.edges.length??0}};return {schemaVersion:he,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:ae,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:q,affectedProjects:m$1.sort((o,s)=>o.target.localeCompare(s.target)),transitiveImpact:w,criticalPathHotspots:ie,workspaceImpact:R.sort((o,s)=>o.target.localeCompare(s.target)),verificationPlan:B,agentBrief:Fe({changed:q.changed,risk:z,affectedProjects:m$1,workspaceImpact:R}),diff:r}}async function tt(e,t){return h$1(t,we,d$1(e))}export{Q as a,oe as b,L as c,T as d,ae as e,he as f,we as g,ye as h,ne as i,We as j,Ye as k,Qe as l,Pe as m,Ze as n,_ as o,et as p,tt as q};
@@ -0,0 +1,9 @@
1
+ import {f,e,h as h$1,g}from'./chunk-XF65LQ6M.js';import {a as a$1,b as b$1}from'./chunk-MGL6DBOR.js';import {b as b$2,c}from'./chunk-ND5YAC4T.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {p,a as a$3}from'./chunk-G6ADWA2B.js';import {k as k$1,m,l}from'./chunk-YYELANJO.js';import {h}from'./chunk-FE5R6EUV.js';import {p as p$1,q}from'./chunk-ODK4LCEL.js';import {k,t,u}from'./chunk-VQZ5PI5J.js';import v from'fs';import s from'path';import a from'chalk';var ne=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function S(e){try{return await v.promises.access(e,v.constants.F_OK),true}catch{return false}}async function E(e){try{let n=JSON.parse(await v.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function b(e){try{return await v.promises.readFile(e,"utf-8")}catch{return ""}}function te(e){return a$1(e)}async function re(e,n){return await Z([...u(e,"project.json"),...u(e,"context.json")])?true:b$1(e)?false:s.resolve(e)===s.resolve(n)?k$1(e).length>0:k$1(e).length>0}async function oe(e){let n=await a$2(e,{skipDirs:ne,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:re}),o=(await a$3(e)).filter(i=>i.relationship==="adopted"||i.source==="adopted-local").map(i=>s.resolve(i.path)).filter(i=>v.existsSync(i)),r=[...new Set([...n.map(i=>s.resolve(i)),...o])];return r.length>0?r:b$1(e)?[]:k$1(e).length>0?[e]:[]}function ie(e,n){return s.relative(e,n).replace(/\\/g,"/")||"."}async function W(e,n){for(let t of n)if(await S(s.join(e,t)))return true;return false}async function Z(e){for(let n of e)if(await S(n))return true;return false}async function ee(e){for(let n of e){let t=await E(n);if(t)return t}return null}async function ae(e,n){if(await W(e,[".env",".env.local"]))return true;let t=n?.contracts&&typeof n.contracts=="object"?n.contracts:null;if(Array.isArray(t?.env)&&t.env.length>0)return true;let o=await E(s.join(e,"package.json")),r={...o?.dependencies??{},...o?.devDependencies??{}};if(Object.keys(r).some(d=>/^(?:dotenv|dotenv-flow|env-cmd)$/iu.test(d)))return true;let i=await b(s.join(e,"pyproject.toml"));if(/\b(?:python-dotenv|pydantic-settings)\b/iu.test(i))return true;let l=[await b(s.join(e,"compose.yaml")),await b(s.join(e,"compose.yml")),await b(s.join(e,"docker-compose.yml")),await b(s.join(e,"docker-compose.yaml"))].join(`
2
+ `);return /^\s*(?:env_file|environment)\s*:/imu.test(l)}async function se(e){return (await g(e)).detected}async function ce(e){let n=await E(s.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function y(e,n,t,o,r,i,l){return {id:e,severity:n,target:t,title:o,detail:r,remediation:i,...l&&l.length>0?{files:[...l]}:{}}}function de(e){let n=e.reduce((t,o)=>o.severity==="fail"?t+28:o.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function le(e,n,t){let o=await ee(u(n,"project.json")),r=m(n,o),i=l(n),l$1=r.runtime==="unknown"?i[0]||"unknown":r.runtime,d=[l$1,...i.filter($=>$!==l$1)],p=r.key==="unknown"&&new Set(d.filter($=>$!=="unknown")).size>1,A=await b$2(n,o,{runtime:l$1,framework:r.key}),f=["backend","service","worker"].includes(A),h=f&&/^(?:fastapi|django|flask|nestjs|express|fastify|springboot|gofiber|gogin|dotnet-webapi|laravel|rails|phoenix|axum|actix|rocket)$/u.test(r.key),k=ie(e,n),m$1=k,F=await ce(n),P=await Z([...u(n,"project.json"),...u(n,"context.json")]),x=await se(n),R=await W(n,["Dockerfile","dockerfile"]),z=await W(n,[".env.example","env.example","config/env.example"]),w=await ae(n,o),c$1=await c({projectPath:n,declaration:t?.governance}),u$1=c$1.ci.status==="repository",C=await h$1(n),g=[];return r.key==="unknown"&&g.push(y(p?"project.stack.aggregate":"project.stack.unknown",p?"info":"fail",m$1,p?"Multi-runtime aggregate boundary detected":"Project stack is unknown",p?`Workspai detected multiple runtimes (${d.join(", ")}) and intentionally did not promote one nested framework as the aggregate project identity.`:"Workspai cannot confidently classify this backend project.",p?"Adopt independently operated nested projects when they need separate lifecycle, ownership, or release evidence.":"Add .workspai/project.json metadata or import the project with `workspai import`.")),P||g.push(y("project.marker.missing","warn",m$1,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),x||g.push(y("project.tests.missing","warn",m$1,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),f&&w&&!z&&g.push(y("project.env.example.missing","info",m$1,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.",[".env.example"])),c$1.ci.status==="unknown"?g.push(y("project.ci.missing","warn",m$1,"CI governance is not proven","No repository CI surface or canonical external CI declaration was found for this project.","Add repository CI configuration or declare the external CI authority in the workspace contract.",[".github/workflows/ci.yml"])):c$1.ci.status==="external-observed"&&g.push(y("project.ci.external-observed","info",m$1,"Continuous integration appears externally managed",`Repository documentation references an external CI control plane (${c$1.ci.evidence.join(", ")}).`,"Declare the external CI provider in the canonical workspace contract when authoritative release gating depends on it.")),h&&!C&&g.push(y("project.health.missing","info",m$1,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),f&&!R&&g.push(y("project.container.missing","info",m$1,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.",["Dockerfile"])),{name:typeof o?.name=="string"&&o.name.trim()?o.name.trim():s.basename(n),path:n,relativePath:k,runtime:l$1,runtimeCandidates:d,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:P,hasTests:x,hasDockerfile:R,hasEnvExample:z,hasCiConfig:u$1,governance:c$1,hasHealthEndpoint:C,scripts:F,findings:g,score:de(g)}}function pe(e){return e.name.toLowerCase()}async function ue(e){let n=new Map(e.map(r=>[pe(r),r])),t=[];for(let r of e){let i=await E(s.join(r.path,"package.json")),l={...i?.dependencies??{},...i?.devDependencies??{},...i?.peerDependencies??{}};for(let p of Object.keys(l)){let A=p.replace(/^@[^/]+\//,"").toLowerCase(),f=n.get(A);f&&f.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:f.relativePath,kind:"package"});}let d=await b(s.join(r.path,"pyproject.toml"));for(let p of e)p.relativePath!==r.relativePath&&d.includes(p.name)&&t.push({from:r.relativePath,to:p.relativePath,kind:"workspace-reference"});}let o=new Set;return t.filter(r=>{let i=`${r.from}\0${r.to}\0${r.kind}`;return o.has(i)?false:(o.add(i),true)})}function me(e,n){let t=new Map;for(let o of e)t.set(o.relativePath,{project:o.relativePath,directDependents:0,directDependencies:0});for(let o of n){let r=t.get(o.from),i=t.get(o.to);r&&(r.directDependencies+=1),i&&(i.directDependents+=1);}return Array.from(t.values()).sort((o,r)=>r.directDependents-o.directDependents||r.directDependencies-o.directDependencies)}async function fe(e){let n=await ee(t(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function ge(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function ye(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasCanonicalGraph||n.push("Generate canonical topology with `workspai workspace model --write --include-evidence`."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function Ge(e$1={}){let n=s.resolve(e$1.workspacePath||process.cwd());if(!await S(n))throw new Error(`Workspace path does not exist: ${n}`);let t=te(n)??n,o=k(t),r=await fe(t),i=await oe(t),l;try{l=(await p({workspacePath:t})).contract;}catch{}let d=await Promise.all(i.map(c=>{let u=l?.projects.find(C=>{let g=C.externalPath??C.relativePath;return s.resolve(t,g)===s.resolve(c)});return le(t,c,u)})),p$2=await ue(d),A=me(d,p$2),f$1=[];o||f$1.push(y("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),d.length===0&&f$1.push(y("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let h$1=[...f$1,...d.flatMap(c=>c.findings)],k$1=ge(h$1),m={};for(let c of d)for(let u of c.runtimeCandidates)m[u]=(m[u]||0)+1;let F=d.length>0?Math.round(d.reduce((c,u)=>c+u.score,0)/d.length):0,P=f$1.reduce((c,u)=>c+(u.severity==="fail"?20:u.severity==="warn"?8:2),0),x=Math.max(0,F-P),R=d.length===0&&k$1.fail===0&&h$1.length>0&&h$1.every(c=>c.id==="workspace.projects.missing"&&c.severity==="warn"),z=k$1.fail>0||e$1.strict&&k$1.warn>0&&!R?"blocked":k$1.warn>0?"needs-attention":"ready",w={schemaVersion:q.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:o,profile:r,summary:{statusScope:"source-structure",releaseReadiness:"not-evaluated",score:x,verdict:z,projectCount:d.length,runtimeCount:Object.keys(m).length,findings:k$1},runtimes:m,projects:d,dependencyGraph:{status:p$2.length>0?"generated":"empty",edges:p$2,topImpactedProjects:A.slice(0,5)},findings:h$1,nextActions:ye({findings:h$1,projectCount:d.length,hasCanonicalGraph:await S(s.join(t,p$1.knowledgeGraph)),workspaceDetected:o}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:p$1.analyze}};if(e$1.output&&(await v.promises.mkdir(s.dirname(s.resolve(e$1.output)),{recursive:true}),await v.promises.writeFile(s.resolve(e$1.output),`${JSON.stringify(w,null,2)}
3
+ `)),!e$1.output&&o){let c=f(w,{commandId:"workspaceAnalyze",exitCode:w.summary.verdict==="blocked"?2:w.summary.verdict==="needs-attention"?1:0,generatedAt:w.generatedAt,blockers:w.findings.filter(u=>u.severity==="fail").map(u=>u.title).slice(0,12),runId:e()});await h(t,p$1.analyze,c);}return w}function We(e){let n=e.summary.verdict==="ready"?a.green:e.summary.verdict==="needs-attention"?a.yellow:a.red;if(console.log(a.bold(`
4
+ Workspai Workspace Analysis
5
+ `)),console.log(a.cyan("Workspace:"),e.workspacePath),console.log(a.cyan("Profile:"),e.profile||"not configured"),console.log(a.cyan("Source score:"),`${e.summary.score}/100`),console.log(a.cyan("Source verdict:"),n(e.summary.verdict)),console.log(a.cyan("Release readiness:"),e.summary.releaseReadiness),console.log(a.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(a.bold(`
6
+ Projects`));for(let t of e.projects){let o=t.score>=85?a.green("pass"):t.score>=65?a.yellow("watch"):a.red("risk");console.log(` ${t.relativePath} ${a.gray(`${t.runtime}/${t.framework}`)} ${o} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(a.bold(`
7
+ Dependency Graph`)),console.log(a.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(a.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(a.bold(`
8
+ Top Findings`));for(let t of e.findings.slice(0,8)){let o=t.severity==="fail"?a.red:t.severity==="warn"?a.yellow:a.gray;console.log(` ${o(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(a.gray(` ${t.remediation}`));}}console.log(a.bold(`
9
+ Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(a.gray(` - ${t}`));console.log();}export{Ge as a,We as b};
@@ -0,0 +1,2 @@
1
+ import {l}from'./chunk-TBOIXIQA.js';import {a as a$1}from'./chunk-UHT2SW7O.js';import {b}from'./chunk-EBQS5T7Q.js';import {j}from'./chunk-TGDXD4CD.js';import {b as b$1}from'./chunk-K33JJVQZ.js';import {a}from'./chunk-AFIFZTOY.js';import {c}from'./chunk-EWZZUQBR.js';import {s,t,p}from'./chunk-ODK4LCEL.js';import Pe from'crypto';import O from'fs';import M from'fs/promises';import f from'path';var fe=s.projectAgentEntry.schemaVersion,L=t.projectAgentEntry,Ce="workspai.agent-bootstrap-receipt.v1",Ve="<!-- WORKSPAI:AGENT-ENTRY:START -->",Be="<!-- WORKSPAI:AGENT-ENTRY:END -->",B=["generic","codex","claude","gemini","qwen","kimi","grok","copilot","cursor","windsurf","amazon-q"],Ue=["CLAUDE.md","GEMINI.md","QWEN.md",".amazonq/rules/workspai-agent-entry.md"];function Se(t){let s=t?.trim().toLowerCase()||"generic";if(s==="orca")return "grok";if(B.includes(s))return s;throw new Error(`Unsupported agent host "${s}". Expected one of: ${B.join(", ")}.`)}function me(t){let s=t.map(c=>c.id).sort(),n=[...B].sort();if(s.length!==n.length||s.some((c,p)=>c!==n[p]))throw new Error("Project agent entry must define each supported host exactly once.")}function U(t){let{integrity:s,...n}=t;return n}function T(t){return c(t)}function Je(t$1){me(t$1.hosts);let s={schemaVersion:fe,generatedAt:t$1.context.generatedAt,project:{name:t$1.context.project.name,relativePath:t$1.context.project.relativePath,...t$1.context.project.runtime?{runtime:t$1.context.project.runtime}:{},...t$1.context.project.framework?{framework:t$1.context.project.framework}:{}},workspace:{name:t$1.context.workspace.name,relationship:t$1.context.workspace.relationship,localBinding:t.projectWorkspaceLink,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"},canonical:{projectContext:t.projectContextAgent,projectGrounding:".workspai/PROJECT-GROUNDING.md",projectKnowledgeGraph:t.projectKnowledgeGraphReference,goalIndex:`workspace:${t.goalIndex}`,workspaceIndex:`workspace:${p.agentIndex}`,workspaceContext:`workspace:${p.agentContext}`,workspaceModel:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,workspaceSkillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json"},protocol:{mode:"canonical-first",bootstrapCommand:"workspai agent bootstrap --for-agent generic --strict --json",verifyCommand:"workspai project agent-entry verify --for-agent all --strict --json",requiredReadOrder:[L,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",t.projectContextAgent,`workspace:${t.goalIndex}`,`workspace:${p.skillsIndex}`,"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json","source:targeted-live-files"],sourcePolicy:{liveSourceAuthority:"exact-implementation",workspaceEvidenceAuthority:"identity-topology-readiness-goals",broadScanBeforeBootstrap:false,sourceMutation:"governed-only",verificationClaims:"cli-evidence-only"},degradedMode:{discloseMissingEvidence:true,allowCompleteArchitectureClaims:false,allowReadOnlySourceInspection:true}},hosts:[...t$1.hosts].sort((c,p)=>c.id.localeCompare(p.id))},n={...s,integrity:{algorithm:"sha256",projectContextHash:t$1.context.integrity.payloadHash,payloadHash:T(s),portable:true,absolutePathsEmitted:false}};if(!A(n))throw new Error("Project agent entry rejected a non-portable local path.");return a(n,"contracts/workspace-intelligence/project-agent-entry.v1.json","Project agent entry"),n}function A(t){return typeof t=="string"?!(/^[A-Za-z]:[\\/]/.test(t)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(t)||/(?:^|[\s("'`])file:\/\//i.test(t)||/(?:^|[\s("'`])\\\\[^\\\s]+[\\]/.test(t)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(t)):Array.isArray(t)?t.every(A):t&&typeof t=="object"?Object.values(t).every(A):true}async function Te(t){let s=f.join(t,L),n=JSON.parse(await M.readFile(s,"utf8"));if(a(n,"contracts/workspace-intelligence/project-agent-entry.v1.json","Project agent entry"),n.integrity.payloadHash!==T(U(n)))throw new Error("Project agent entry integrity validation failed.");if(me(n.hosts),!A(n)||n.integrity.absolutePathsEmitted)throw new Error("Project agent entry contains a non-portable local path.");return n}async function Re(t$1){let s=f.join(t$1,t.projectContextAgent),n=JSON.parse(await M.readFile(s,"utf8"));a(n,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent");let c=U(n),p=Pe.createHash("sha256").update(JSON.stringify(c)).digest("hex");if(n.integrity.payloadHash!==p)throw new Error("Project context agent integrity validation failed.");if(!A(n)||n.integrity.absolutePathsEmitted)throw new Error("Project context agent contains a non-portable local path.");return n}function xe(t){return t.includes("blocked")?"blocked":t.includes("degraded")?"degraded":"ready"}async function Ye(t$1){let s=b({startPath:f.resolve(t$1.startPath??process.cwd()),strict:true,requireProjectMembership:true});if(!s?.projectPath)throw new Error("No canonically bound Workspai project was resolved.");let n=s.projectPath,c$1=s.workspacePath,p$1=await Te(n),o=await Re(n);if(p$1.integrity.projectContextHash!==o.integrity.payloadHash||p$1.project.name!==o.project.name||p$1.workspace.name!==o.workspace.name)throw new Error("Project agent entry is not bound to the current project context.");let J=t$1.forAgent?.trim().toLowerCase()||"generic",Y=J==="all",g=Y?"all":Se(J),D=g,m=Y?p$1.hosts:p$1.hosts.filter(e=>e.id===g),z=p$1.hosts.find(e=>e.id==="generic");if(m.length===0&&z&&m.push(z),m.length===0)throw new Error("Project agent entry does not define generic host coverage.");let y=[],d=(e,r,P,h)=>y.push({id:e,status:r,message:P,...h?{artifact:h}:{}});d("workspace-binding","passed","Canonical workspace membership is resolved."),d("entry-integrity","passed","Project entry manifest integrity is valid.",L),d("project-context-integrity","passed","Project context integrity and manifest binding are valid.",t.projectContextAgent);let $=[...new Set(m.flatMap(e=>e.entryFiles))].sort(),ue=$.filter(e=>!O.existsSync(f.join(n,e))),k=m.some(e=>e.status==="blocked")||ue.length>0?"blocked":m.some(e=>e.status==="degraded")?"degraded":"ready";d("host-discovery",k==="ready"?"passed":k==="degraded"?"warning":"failed",k==="ready"?`${g} has discoverable Workspai entry coverage.`:k==="degraded"?m.find(e=>e.reason)?.reason??`${g} entry coverage is degraded.`:`${g} entry coverage is missing required files.`,$[0]);let Z=[p.agentIndex,p.agentContext,p.skillsIndex,p.model,p.knowledgeGraph],R=Z.filter(e=>!O.existsSync(f.join(c$1,e)));d("canonical-evidence",R.length===0?"passed":"failed",R.length===0?"Required canonical workspace evidence is present.":`Required canonical evidence is missing: ${R.join(", ")}.`);let E=[],x=null,u=null;for(let e of Z)if(!R.includes(e))try{let r=JSON.parse(await M.readFile(f.join(c$1,e),"utf8"));b$1(e,r,e),e===p.model&&(x=r),e===p.knowledgeGraph&&(u=r);}catch{E.push(e);}d("canonical-contracts",E.length===0?"passed":"failed",E.length===0?"Canonical workspace evidence satisfies its published schemas.":`Canonical evidence failed contract validation: ${E.join(", ")}.`);let b$2=t.projectKnowledgeGraphReference,Q=f.join(n,b$2),X="failed",I="The project Knowledge Graph reference is missing.";if(O.existsSync(Q)&&u)try{let e=JSON.parse(await M.readFile(Q,"utf8"));b$1(b$2,e,b$2);let r=j(u,o.project.name),{integrity:P,...h}=e,C=u.source;e.project.name===o.project.name&&e.canonical.sourceHash===C?.hash&&e.canonical.projectionHash===c(r)&&e.integrity.payloadHash===c(h)?(X="passed",I="The project reference integrity-binds the exact current projection of canonical workspace evidence."):I="The project Knowledge Graph reference is stale or does not match the canonical project projection.";}catch{I="The project Knowledge Graph reference failed schema or integrity validation.";}d("project-knowledge-graph",X,I,b$2);let ee=x?.workspace,te=u?.workspace,oe=Array.isArray(u?.entities)?u.entities:[],ne=Array.isArray(x?.projects)?x.projects:[],re=E.length===0&&ee?.name===o.workspace.name&&te?.name===o.workspace.name&&ne.some(e=>e.name===o.project.name)&&oe.some(e=>e.projectId===o.project.name);d("canonical-project-membership",re?"passed":"failed",re?"The project and workspace identities agree across the entry, Model, and Graph.":`The project or workspace identity is missing or inconsistent in canonical evidence (entry workspace=${o.workspace.name}, model workspace=${String(ee?.name??"missing")}, graph workspace=${String(te?.name??"missing")}, entry project=${o.project.name}, model projects=${ne.map(e=>String(e.name??"missing")).join(",")||"missing"}, graph projects=${[...new Set(oe.map(e=>e.projectId).filter(e=>typeof e=="string"))].join(",")||"missing"}).`);let se=!o.intelligence.freshness.graphMatchesModel||["missing","stale"].includes(o.intelligence.freshness.model)||["missing","stale"].includes(o.intelligence.freshness.graph)?"failed":o.intelligence.freshness.model==="unknown"||o.intelligence.freshness.graph==="unknown"?"warning":"passed",j$1=false,G;if(t$1.validateLiveInputs!==false)try{let e=await a$1(c$1);j$1=e.status==="hit";let r=e.status==="hit"?"Live project inputs match the persisted Model and Knowledge Graph snapshot.":`Live project inputs require an intelligence refresh (${e.reason}).`;G={id:"live-inputs",status:j$1?"passed":"failed",message:r};}catch{G={id:"live-inputs",status:"failed",message:"Live project inputs could not be validated against canonical graph evidence."};}else G={id:"live-inputs",status:"warning",message:"Live input validation was skipped; persisted compatibility was checked only."};let K=se==="warning"&&o.intelligence.freshness.model==="unknown"&&o.intelligence.freshness.graph==="fresh"&&o.intelligence.freshness.graphMatchesModel&&j$1?"passed":se;d("persisted-freshness",K,K==="passed"?o.intelligence.freshness.model==="unknown"?"Model and Graph bindings are current; live input validation closes structural freshness while verify-before-use facts remain individually governed.":"Persisted Model and Knowledge Graph bindings are current.":K==="warning"?"Persisted evidence is compatible, but at least one freshness state is unknown.":"Persisted Model or Knowledge Graph evidence is missing, stale, or mismatched."),y.push(G);let i={present:false,appliesToProject:false,status:"none"},_=[],we=f.join(c$1,t.goalIndex);if(O.existsSync(we)){let e=null;try{e=await l({workspacePath:c$1,validateBindings:false});}catch{_.push("workspai goal --list --json"),d("active-goal","failed","The Goal index is present but invalid.");}if(e?.active&&(i={present:true,appliesToProject:e.active.scope.projects.includes(o.project.name),status:"invalid",id:e.active.id,objective:e.active.objective,lifecycle:e.active.lifecycle,goalPack:`workspace:${e.active.goalPack}`,agentHandoff:`workspace:${e.active.agentHandoff}`}),e)try{let r=await l({workspacePath:c$1,validateBindings:true});r.active&&(i={present:true,appliesToProject:r.active.scope.projects.includes(o.project.name),status:"ready",id:r.active.id,objective:r.active.objective,lifecycle:r.active.lifecycle,goalPack:`workspace:${r.active.goalPack}`,agentHandoff:`workspace:${r.active.agentHandoff}`}),d("active-goal","passed",r.active?"The active Goal Pack and agent handoff have valid canonical bindings.":"No active Goal Pack is selected.");}catch(r){let P=r instanceof Error?r.message:String(r),h=i.present&&/\bstale\b|--refresh/i.test(P);if(i.present&&(i.status=h?"stale":"invalid"),h&&i.objective){let w=e.active,ve=w?.scope.kind==="project"&&w.scope.projects.length===1?`project:${w.scope.projects[0]}`:w?.scope.kind==="project-set"&&w.scope.projects.length>1?`projects:${w.scope.projects.join(",")}`:"workspace";_.push(`workspai goal ${JSON.stringify(i.objective)} --scope ${ve} --for-agent generic --refresh --json`);}else _.push("workspai goal --status --json");let C=!i.present||i.appliesToProject;d("active-goal",C?"failed":"warning",h?C?"The selected Goal Pack is present but stale; regenerate it against current canonical evidence before acting.":"The selected Goal Pack is stale, but it does not apply to this project; current project evidence remains usable while the Goal is refreshed for its own scope.":i.present?C?"The selected Goal Pack is present but its canonical binding or handoff is invalid.":"The selected Goal Pack has an invalid canonical binding, but it does not apply to this project; current project evidence remains usable while the Goal is repaired for its own scope.":"The Goal index could not be validated.");}}else d("active-goal","passed","No Goal index is present for this workspace.");let ae=y.filter(e=>e.id!=="active-goal"),W=ae.some(e=>e.status==="failed")?"blocked":ae.some(e=>e.status==="warning")?"degraded":"ready",ye=y.some(e=>e.id==="active-goal"&&e.status==="failed")?"blocked":y.some(e=>e.id==="active-goal"&&e.status==="warning")?"degraded":"ready",N=xe([k,W,ye]),v=o.blockers.some(e=>e.severity==="error")?"blocked":o.blockers.length>0?"degraded":"ready",ke=v==="blocked"?"blocked":v==="degraded"?"degraded":"not-verified",je=`command:workspai agent bootstrap --for-agent ${g} --strict --json`,Ae=p$1.protocol.requiredReadOrder.map(e=>e==="command:workspai agent bootstrap --for-agent generic --strict --json"?je:e),ie={schemaVersion:Ce,generatedAt:(t$1.now??new Date).toISOString(),status:N,statusScope:"agent-grounding",readiness:{agentGrounding:N,architectureEvidence:W,projectEnvironment:v,release:ke},requestedAgent:D,resolvedHost:g,project:{name:o.project.name,relativePath:o.project.relativePath,...o.project.runtime?{runtime:o.project.runtime}:{},...o.project.framework?{framework:o.project.framework}:{}},workspace:{name:o.workspace.name,relationship:o.workspace.relationship,resolved:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"},entry:{artifact:L,schemaVersion:fe,hostStatus:k,entryFiles:$},canonicalEvidence:{projectContext:t.projectContextAgent,projectKnowledgeGraph:t.projectKnowledgeGraphReference,workspaceIndex:`workspace:${p.agentIndex}`,workspaceContext:`workspace:${p.agentContext}`,workspaceModel:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,workspaceSkillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:"command:workspai workspace graph search <task-query> --scope project:<project> --limit 12 --json",modelFreshness:j$1?"fresh":o.intelligence.freshness.model,graphFreshness:j$1?"fresh":o.intelligence.freshness.graph,graphMatchesModel:o.intelligence.freshness.graphMatchesModel,liveInputsValidated:j$1,blockerCount:o.blockers.length},activeGoal:i,requiredReadOrder:Ae,claims:{architecture:W==="ready"?"allowed-with-citations":"prohibited",sourceInspection:"bounded-and-targeted",sourceMutation:"governed-cli-transaction-only",verification:"cli-evidence-only"},checks:y,nextActions:N==="ready"?[...i.present&&i.appliesToProject&&i.agentHandoff?[`read:${i.agentHandoff}`]:[],...v==="blocked"?["workspai doctor project --json","workspai workspace explain release-blocked --json"]:v==="degraded"?["workspai doctor project --json"]:[],`workspai workspace graph search <task-query> --scope project:${o.project.name} --limit 12 --json`,"inspect only the returned proof paths and target source files"]:[..._,"workspai workspace intelligence run --for-agent generic --strict --json",`workspai agent bootstrap --for-agent ${g} --strict --json`]},ce=T(U(p$1)),Ee=T({manifestHash:ce,projectContextHash:o.integrity.payloadHash,requestedAgent:D,status:N,generatedAt:ie.generatedAt}),pe={...ie,receiptId:Ee},F={...pe,integrity:{algorithm:"sha256",manifestHash:ce,projectContextHash:o.integrity.payloadHash,payloadHash:T(pe),portable:true,absolutePathsEmitted:false}};if(!A(F))throw new Error("Agent bootstrap receipt rejected a non-portable local path.");return a(F,"contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json","Agent bootstrap receipt"),F}
2
+ export{fe as a,L as b,Ce as c,Ve as d,Be as e,B as f,Ue as g,Se as h,Je as i,Ye as j};