workspai 0.65.0 → 0.67.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 (211) hide show
  1. package/README.md +28 -23
  2. package/contracts/agent-customization-pack.v1.json +4 -2
  3. package/contracts/analyze-last-run.v1.json +9 -1
  4. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +117 -0
  5. package/contracts/extension-cli-compatibility.v1.json +6 -0
  6. package/contracts/published-contract-catalog.v1.json +30 -0
  7. package/contracts/runtime-command-surface.v1.json +100 -2
  8. package/contracts/workspace-activity-board.v1.json +114 -0
  9. package/contracts/workspace-activity-event.v1.json +132 -0
  10. package/contracts/workspace-activity-monitor-fleet.v1.json +18 -0
  11. package/contracts/workspace-activity-monitor-snapshot.v1.json +161 -0
  12. package/contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json +17 -0
  13. package/contracts/workspace-intelligence/mcp-design.v1.json +49 -2
  14. package/contracts/workspace-intelligence/project-agent-entry.v1.json +3 -0
  15. package/contracts/workspace-intelligence/project-context-agent.v1.json +49 -7
  16. package/contracts/workspace-intelligence/project-knowledge-graph-reference.v1.json +51 -0
  17. package/contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json +196 -0
  18. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +97 -2
  19. package/contracts/workspace-intelligence/workspace-skills-index.v1.json +34 -0
  20. package/contracts/workspace-intelligence-architecture.v1.json +17 -0
  21. package/contracts/workspace-intelligence-chain.v1.json +17 -0
  22. package/dist/analyze-IC2KRVCG.js +1 -0
  23. package/dist/{artifact-remediation-plan-XIQNI35L.js → artifact-remediation-plan-GFFHC2ZU.js} +1 -1
  24. package/dist/autopilot-release-RECEZAZI.js +1 -0
  25. package/dist/capabilities-command-X4WZIJNR.js +1 -0
  26. package/dist/chunk-2LIVMG5C.js +2 -0
  27. package/dist/chunk-2M62CU3O.js +2 -0
  28. package/dist/chunk-2MTJWPQ4.js +1 -0
  29. package/dist/chunk-2MVIRJJR.js +1 -0
  30. package/dist/chunk-2RPFCBS4.js +1 -0
  31. package/dist/chunk-3O7LZPKA.js +4 -0
  32. package/dist/chunk-3OGPTLI2.js +1 -0
  33. package/dist/{chunk-6TBTMWNA.js → chunk-4RV4JVGR.js} +1 -1
  34. package/dist/{chunk-YYQEWAES.js → chunk-4WVOAX2V.js} +1 -1
  35. package/dist/{chunk-N4QQADXX.js → chunk-5EVDW7JM.js} +1 -1
  36. package/dist/{chunk-J3X56S7L.js → chunk-5ME4W4LN.js} +1 -1
  37. package/dist/chunk-5OA33JH2.js +2 -0
  38. package/dist/chunk-5TY74LLW.js +2 -0
  39. package/dist/chunk-6254CWUY.js +49 -0
  40. package/dist/{chunk-D5YJOQYK.js → chunk-6E2Y3XGT.js} +1 -1
  41. package/dist/chunk-ARUFY5W3.js +1 -0
  42. package/dist/chunk-B4IVVTMQ.js +2 -0
  43. package/dist/{chunk-HDNATYW7.js → chunk-BHFRP7TV.js} +1 -1
  44. package/dist/{chunk-KTN2ARZJ.js → chunk-BHM6RHTA.js} +3 -3
  45. package/dist/chunk-BRYJTW6S.js +2 -0
  46. package/dist/{chunk-HCFWT42C.js → chunk-BUYLM6QV.js} +1 -1
  47. package/dist/chunk-CPR2CMOY.js +1 -0
  48. package/dist/{chunk-XGE2FDI4.js → chunk-CZVT7T2X.js} +1 -1
  49. package/dist/chunk-EHCKITR4.js +2 -0
  50. package/dist/chunk-ENZPM52J.js +1 -0
  51. package/dist/chunk-FPDH3N3A.js +7 -0
  52. package/dist/{chunk-PXWKMPPI.js → chunk-FX5J6JCK.js} +1 -1
  53. package/dist/chunk-FY4X2VOE.js +39 -0
  54. package/dist/chunk-GIQ4SDRJ.js +1 -0
  55. package/dist/chunk-H77ZNH5O.js +1 -0
  56. package/dist/{chunk-2RL6RRT2.js → chunk-HQLBO23O.js} +50 -50
  57. package/dist/chunk-HYE5UHPV.js +2 -0
  58. package/dist/{chunk-D65FCQIO.js → chunk-IKUFNK46.js} +1 -1
  59. package/dist/{chunk-WRQWVSBJ.js → chunk-IQQMFRWM.js} +1 -1
  60. package/dist/chunk-JCGSIDMC.js +2 -0
  61. package/dist/chunk-KENOAC2Q.js +13 -0
  62. package/dist/chunk-KQ2TMI26.js +97 -0
  63. package/dist/chunk-L5Q2S5GY.js +3 -0
  64. package/dist/chunk-LPCZHKD5.js +1 -0
  65. package/dist/chunk-N4QFNOAI.js +1 -0
  66. package/dist/chunk-NMXGSVMD.js +1 -0
  67. package/dist/{chunk-GQSRNUCU.js → chunk-NVND4727.js} +3 -3
  68. package/dist/{chunk-W6FHVXNL.js → chunk-OCNPOYMA.js} +1 -1
  69. package/dist/chunk-PSYQ6IJA.js +12 -0
  70. package/dist/{chunk-VRGEPPUB.js → chunk-QMQBX3RV.js} +1 -1
  71. package/dist/{chunk-YUGKQ44M.js → chunk-SLFOUSRW.js} +1 -1
  72. package/dist/chunk-SRLWHOLF.js +1 -0
  73. package/dist/chunk-SVYY55IS.js +157 -0
  74. package/dist/chunk-SX6A656X.js +1 -0
  75. package/dist/{chunk-X6TNBARH.js → chunk-TABXSDTR.js} +2 -2
  76. package/dist/chunk-THIG2YQP.js +681 -0
  77. package/dist/chunk-TP7VKEUF.js +1 -0
  78. package/dist/chunk-U5ENEDJA.js +7 -0
  79. package/dist/chunk-UTV4DTNM.js +1 -0
  80. package/dist/chunk-VI4ZRAY6.js +1 -0
  81. package/dist/chunk-VQZ5PI5J.js +1 -0
  82. package/dist/chunk-VWBMDGPY.js +9 -0
  83. package/dist/chunk-XDPTAV2T.js +2 -0
  84. package/dist/chunk-XWKGZRHN.js +1 -0
  85. package/dist/chunk-Y35VLVF6.js +5 -0
  86. package/dist/{chunk-VYDURWN7.js → chunk-Y4Z6CEII.js} +1 -1
  87. package/dist/chunk-YYY2WXOH.js +1 -0
  88. package/dist/chunk-ZGHJIQXL.js +1 -0
  89. package/dist/chunk-ZI2E7P6O.js +4 -0
  90. package/dist/{create-ALT2ME6H.js → create-72ITVZXV.js} +1 -1
  91. package/dist/{demo-kit-QHIDCSBI.js → demo-kit-5UQH2OXC.js} +1 -1
  92. package/dist/{doctor-RW4R3O5C.js → doctor-CVYUESRQ.js} +1 -1
  93. package/dist/{dotnet-webapi-clean-AVHPJG7Y.js → dotnet-webapi-clean-YEHYIGOT.js} +1 -1
  94. package/dist/{goal-lifecycle-VYOKS6E6.js → goal-lifecycle-H55AGFCB.js} +1 -1
  95. package/dist/goal-pack-6OBZOPCD.js +1 -0
  96. package/dist/{gofiber-standard-47S2GYAO.js → gofiber-standard-C44IIQYH.js} +1 -1
  97. package/dist/{gogin-standard-EWB4XNOI.js → gogin-standard-X7VKACVR.js} +1 -1
  98. package/dist/index.d.ts +20 -2
  99. package/dist/index.js +177 -177
  100. package/dist/live-command-5VXPR43F.js +15 -0
  101. package/dist/{pipeline-U4N2DVD7.js → pipeline-SKYOXWHW.js} +1 -1
  102. package/dist/{project-agent-entry-YAQCHIMP.js → project-agent-entry-5IUBEREI.js} +1 -1
  103. package/dist/project-intelligence-lens-LQCN65P2.js +1 -0
  104. package/dist/{project-test-coverage-4S7MEQ6T.js → project-test-coverage-KD4LLFGV.js} +1 -1
  105. package/dist/{pythonRapidkitExec-VAW5XE4Z.js → pythonRapidkitExec-44ORGQ4R.js} +1 -1
  106. package/dist/{rust-axum-M5X4ZC4Z.js → rust-axum-JKZTZDRZ.js} +1 -1
  107. package/dist/{springboot-standard-Y5ADLZMQ.js → springboot-standard-PI4FLTAN.js} +1 -1
  108. package/dist/verified-goal-HN7G532B.js +1 -0
  109. package/dist/{workspace-HGUZWNAB.js → workspace-5W7FYGDQ.js} +1 -1
  110. package/dist/{workspace-agent-sync-GEN3KBAX.js → workspace-agent-sync-OZCDQORK.js} +1 -1
  111. package/dist/{workspace-archive-ZBCKJHXS.js → workspace-archive-NOSGRKRZ.js} +1 -1
  112. package/dist/{workspace-context-4WIWFW26.js → workspace-context-L65BR5L6.js} +1 -1
  113. package/dist/{workspace-contract-7DXK4GF5.js → workspace-contract-JYHNEJPV.js} +1 -1
  114. package/dist/workspace-explain-SUBK6FLO.js +1 -0
  115. package/dist/workspace-explain-contract-WMREJWHF.js +1 -0
  116. package/dist/{workspace-feedback-RQ4TGJW6.js → workspace-feedback-MWGCT5R2.js} +1 -1
  117. package/dist/{workspace-foundation-J3NNRMI3.js → workspace-foundation-VIB3PXNH.js} +1 -1
  118. package/dist/{workspace-graph-stream-PQI7OGCE.js → workspace-graph-stream-45JHE4MG.js} +1 -1
  119. package/dist/workspace-graph-token-efficiency-NPECU6Y5.js +1 -0
  120. package/dist/{workspace-history-SYCDK7FO.js → workspace-history-JKW3VJO3.js} +1 -1
  121. package/dist/{workspace-intelligence-6FS26JOQ.js → workspace-intelligence-3C47PK4L.js} +1 -1
  122. package/dist/workspace-intelligence-benchmark-SRDIHX3X.js +1 -0
  123. package/dist/workspace-intelligence-evaluation-OJIQS5SN.js +1 -0
  124. package/dist/{workspace-intelligence-runner-XYUPCSLN.js → workspace-intelligence-runner-OWN5ZI6W.js} +1 -1
  125. package/dist/{workspace-intelligence-runtime-registry-IW6J53LO.js → workspace-intelligence-runtime-registry-UKFB3BI7.js} +1 -1
  126. package/dist/workspace-knowledge-graph-AKG5NUU6.js +1 -0
  127. package/dist/{workspace-knowledge-graph-contract-L3CLAM2M.js → workspace-knowledge-graph-contract-X52KXBXJ.js} +1 -1
  128. package/dist/{workspace-knowledge-graph-query-FZXSPWGK.js → workspace-knowledge-graph-query-DXA4CROE.js} +1 -1
  129. package/dist/workspace-knowledge-graph-snapshot-SNI5K2RL.js +1 -0
  130. package/dist/{workspace-marker-7NHMDIRL.js → workspace-marker-XGAWZZDX.js} +1 -1
  131. package/dist/workspace-mcp-serve-PK226GMV.js +3 -0
  132. package/dist/workspace-model-R4ISKDB2.js +1 -0
  133. package/dist/{workspace-onboarding-X3PWRIIS.js → workspace-onboarding-Y5RPEFUD.js} +1 -1
  134. package/dist/{workspace-python-engine-state-J4QKW55K.js → workspace-python-engine-state-BE4A3BL5.js} +1 -1
  135. package/dist/{workspace-readme-G7TZ3V5T.js → workspace-readme-PL5V3UDH.js} +2 -2
  136. package/dist/{workspace-registry-summary-LJN4WHIZ.js → workspace-registry-summary-STGUGROG.js} +1 -1
  137. package/dist/workspace-repair-engine-FNLL5ZDK.js +3 -0
  138. package/dist/workspace-run-GFBFGUFM.js +1 -0
  139. package/dist/{workspace-verify-USRRIM2F.js → workspace-verify-AXVX3PF3.js} +1 -1
  140. package/dist/{workspace-watch-43YZPLF7.js → workspace-watch-RLBEJKXE.js} +1 -1
  141. package/docs/DEVELOPMENT.md +19 -0
  142. package/docs/README.md +19 -16
  143. package/docs/SETUP.md +10 -0
  144. package/docs/agent-entry.md +22 -7
  145. package/docs/ci-workflows.md +1 -1
  146. package/docs/commands-reference.md +58 -8
  147. package/docs/contracts/ARTIFACT_CATALOG.md +64 -44
  148. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +1 -0
  149. package/docs/contracts/NAMING_AND_COEXISTENCE.md +20 -18
  150. package/docs/contracts/README.md +7 -3
  151. package/docs/real-world-qualification.md +19 -3
  152. package/docs/workspace-intelligence-benchmark.md +82 -0
  153. package/docs/workspace-knowledge-graph.md +95 -27
  154. package/docs/workspace-live-activity.md +209 -0
  155. package/docs/workspace-operations.md +32 -9
  156. package/package.json +4 -2
  157. package/dist/analyze-5PDVWECJ.js +0 -1
  158. package/dist/autopilot-release-JVIJCTKX.js +0 -1
  159. package/dist/capabilities-command-LHM3XIS6.js +0 -1
  160. package/dist/chunk-2647BYBC.js +0 -1
  161. package/dist/chunk-27UR373Z.js +0 -1
  162. package/dist/chunk-2C5ZBVBI.js +0 -2
  163. package/dist/chunk-6JWNDWOA.js +0 -1
  164. package/dist/chunk-CCDGHPEJ.js +0 -2
  165. package/dist/chunk-DFG33SBR.js +0 -2
  166. package/dist/chunk-FY4IIAIF.js +0 -1
  167. package/dist/chunk-HEZZ72V4.js +0 -94
  168. package/dist/chunk-HN7P4T3B.js +0 -681
  169. package/dist/chunk-ILIBOMYL.js +0 -1
  170. package/dist/chunk-J7QYANXK.js +0 -8
  171. package/dist/chunk-JD3A5QM6.js +0 -2
  172. package/dist/chunk-JQLJBK5N.js +0 -1
  173. package/dist/chunk-KLSSPJTV.js +0 -1
  174. package/dist/chunk-L22EABIC.js +0 -7
  175. package/dist/chunk-LNXIMF3O.js +0 -1
  176. package/dist/chunk-MDTI3UEB.js +0 -1
  177. package/dist/chunk-MOSXTVPU.js +0 -1
  178. package/dist/chunk-MYJQGGIU.js +0 -5
  179. package/dist/chunk-NOV6723U.js +0 -1
  180. package/dist/chunk-NYEAMMUL.js +0 -1
  181. package/dist/chunk-NZ3WZYD5.js +0 -1
  182. package/dist/chunk-O5B2L3R2.js +0 -1
  183. package/dist/chunk-OWB5KWSS.js +0 -13
  184. package/dist/chunk-P5PSZQPB.js +0 -2
  185. package/dist/chunk-QCKWQFCD.js +0 -1
  186. package/dist/chunk-QI3HG6IG.js +0 -144
  187. package/dist/chunk-SWGSFLTC.js +0 -1
  188. package/dist/chunk-THIOE2PB.js +0 -2
  189. package/dist/chunk-U5FCQTVL.js +0 -4
  190. package/dist/chunk-UXEO5QCF.js +0 -33
  191. package/dist/chunk-VR6XMUF3.js +0 -2
  192. package/dist/chunk-VVJK5NFY.js +0 -2
  193. package/dist/chunk-VXKWWX7S.js +0 -8
  194. package/dist/chunk-W322YDHS.js +0 -49
  195. package/dist/chunk-WPRLXKWC.js +0 -8
  196. package/dist/chunk-Y5YAP4F3.js +0 -2
  197. package/dist/chunk-YN5X2FTP.js +0 -1
  198. package/dist/chunk-YOCN7GF4.js +0 -1
  199. package/dist/goal-pack-YWPI43QL.js +0 -1
  200. package/dist/project-intelligence-lens-MRQR2LQW.js +0 -1
  201. package/dist/verified-goal-WM34TTGE.js +0 -1
  202. package/dist/workspace-explain-TE2LGOAV.js +0 -1
  203. package/dist/workspace-explain-contract-V2IVSROX.js +0 -1
  204. package/dist/workspace-graph-token-efficiency-2I4X374C.js +0 -1
  205. package/dist/workspace-intelligence-evaluation-CQDKOYZZ.js +0 -1
  206. package/dist/workspace-knowledge-graph-SWCKDTPF.js +0 -1
  207. package/dist/workspace-knowledge-graph-snapshot-M572JRB4.js +0 -1
  208. package/dist/workspace-mcp-serve-IBMTFQDY.js +0 -3
  209. package/dist/workspace-model-ZL6WCICX.js +0 -1
  210. package/dist/workspace-repair-engine-NX7I632M.js +0 -3
  211. package/dist/workspace-run-6GT5OBQ5.js +0 -1
@@ -1,8 +1,8 @@
1
- import {c as c$1}from'./chunk-HCFWT42C.js';import {a}from'./chunk-A5FBGRJA.js';import {a as a$2}from'./chunk-27UR373Z.js';import {b as b$1}from'./chunk-D65FCQIO.js';import {i,h as h$1}from'./chunk-NZ3WZYD5.js';import {h}from'./chunk-X6TNBARH.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {t,s}from'./chunk-MOSXTVPU.js';import {q as q$1,r,s as s$1}from'./chunk-RGNCL5OB.js';import {promises}from'fs';import {randomUUID}from'crypto';import p from'path';import c from'chalk';import ne from'fs-extra';import P from'ora';import {execa}from'execa';var ce=3e4,pe=45e3;async function le(e){try{let r=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,env:a$1()});return r.stdout.trim()?p.resolve(e,r.stdout.trim()):null}catch{return null}}async function Z(e,r,t){if(await le(e)){r.warn("Git initialization skipped because target is already inside a git worktree");return}r.start("Initializing git repository...");try{await execa("git",["init"],{cwd:e,env:a$1()}),await execa("git",["add","."],{cwd:e,env:a$1()}),await execa("git",["-c","user.name=Workspai","-c","user.email=workspai@localhost","commit","-m",t],{cwd:e,env:a$1()}),r.succeed("Git repository initialized");}catch{r.warn("Could not initialize git repository");}}function B(e){let r=a(e.path),t=Array.isArray(e.projects)?e.projects:[],o=[],a$1=new Set;for(let s of t){if(!s||typeof s.name!="string"||typeof s.path!="string")continue;let i=a(s.path);a$1.has(i)||(a$1.add(i),o.push({name:s.name,path:i}));}return {name:e.name,path:r,mode:e.mode,projects:o}}function b(e){let r=[],t=new Set;for(let o of e.workspaces||[]){if(!o||typeof o.name!="string"||typeof o.path!="string")continue;let a=B(o);t.has(a.path)||(t.add(a.path),r.push(a));}return {workspaces:r}}async function de(e){let r;try{r=await promises.readFile(e,"utf8");}catch(t){if(t.code==="ENOENT")return {workspaces:[]};throw t}try{let t=JSON.parse(r);if(!t||!Array.isArray(t.workspaces))throw new Error("missing workspaces array");return b(t)}catch(t){throw new Error(`Workspace registry is invalid: ${e}`,{cause:t})}}async function me(e){let r;try{r=await promises.readFile(e,"utf8");}catch(o){if(o.code==="ENOENT")return {workspaces:[]};throw o}let t;try{t=JSON.parse(r);}catch(o){throw new Error(`Workspace registry is invalid: ${e}`,{cause:o})}if(!t||typeof t!="object"||!Array.isArray(t.workspaces))throw new Error(`Workspace registry is invalid: ${e}`);for(let o of t.workspaces)if(!o||typeof o.name!="string"||typeof o.path!="string"||o.mode!==void 0&&typeof o.mode!="string"||o.projects!==void 0&&!Array.isArray(o.projects)||Array.isArray(o.projects)&&o.projects.some(a=>!a||typeof a.name!="string"||typeof a.path!="string"))throw new Error(`Workspace registry contains an invalid entry: ${e}`);return b(t)}async function F(){let e={workspaces:[]},r=new Set;for(let t of s$1()){let o=await de(t);for(let a of o.workspaces)r.has(a.path)||(r.add(a.path),e.workspaces.push(a));}return e}async function ee(e=s$1()){let r={workspaces:[]},t=new Set;for(let o of e){let a=await me(o);for(let s of a.workspaces)t.has(s.path)||(t.add(s.path),r.workspaces.push(s));}return r}function ge(e){let r=e?.code;return process.platform==="win32"&&(r==="EPERM"||r==="EINVAL"||r==="ENOSYS")}async function te(e){try{await e.sync();}catch(r){if(!ge(r))throw r}}async function K(e,r){let t=p.dirname(e);await promises.mkdir(t,{recursive:true});let o=`${p.basename(e)}.`,a=Date.now();for(let i of await promises.readdir(t)){if(!i.startsWith(o)||!i.endsWith(".tmp"))continue;let n=p.join(t,i),d=await promises.stat(n).catch(()=>null);d&&a-d.mtimeMs>3e4&&await promises.rm(n,{force:true}).catch(()=>{});}let s=await promises.readFile(e,"utf8").catch(()=>null);if(s!==null){let i=false;try{let n=JSON.parse(s);i=Array.isArray(n.workspaces);}catch{i=false;}if(!i){let n=`${e}.corrupt-${Date.now()}`;await promises.copyFile(e,n);}}await re(e,`${JSON.stringify(b(r),null,2)}
2
- `);}async function re(e,r){let t=p.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 te(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 ne.move(o,e,{overwrite:true});}}finally{await promises.rm(o,{force:true}).catch(()=>{});}}async function q(e){try{return {exists:true,content:await promises.readFile(e)}}catch(r){if(r.code==="ENOENT")return {exists:false};throw r}}async function Q(e,r){if(!r.exists){await promises.rm(e,{force:true});return}await re(e,r.content);}async function ue(e,r){let t=p.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
- `),await te(s);}catch(i){if(i.code!=="EEXIST")throw i;let n=await promises.stat(t).catch(()=>null);if(n&&Date.now()-n.mtimeMs>ce){let d=await promises.readFile(t,"utf8").then(m=>JSON.parse(m)).catch(()=>null),u=Number(d?.pid),w=false;if(Number.isInteger(u)&&u>0)try{process.kill(u,0),w=true;}catch(m){w=m.code==="EPERM";}if(!w){await promises.rm(t,{force:true}).catch(()=>{});continue}}if(Date.now()-a>pe)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(n=>JSON.parse(n).lockId===o).catch(()=>false)&&await promises.rm(t,{force:true}).catch(()=>{});}}async function _(e){let r$1=q$1(),t=p.join(r$1,"workspaces.json"),o=p.join(r(),"workspaces.json"),a=[...new Set(s$1())];return ue(r$1,async()=>{let[s,i]=await Promise.all([q(t),q(o)]),n=await ee(a);await e(n);let d=b(n);try{await K(t,d),await K(o,d);}catch(u){let m=(await Promise.allSettled([Q(t,s),Q(o,i)])).filter(g=>g.status==="rejected").map(g=>g.reason);throw m.length>0?new AggregateError([u,...m],"Workspace registry transaction failed and could not be fully restored"):u}return d})}async function oe(e,r){let t=a(e);await _(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 ze(e){let r=a(e),o=(await ee()).workspaces.find(a=>a.path===r);return o?{...o,projects:o.projects.map(a=>({...a}))}:null}async function Ge(e,r){let t=a(e);await _(o=>{let a=o.workspaces.findIndex(i=>i.path===t);if(!r){a>=0&&o.workspaces.splice(a,1);return}let s=B(r);a>=0?o.workspaces[a]=s:o.workspaces.push(s);});}async function Me(e){let r=a(e);await _(t=>{t.workspaces=t.workspaces.filter(o=>o.path!==r);});}async function ke(e,r){try{await oe(e,r);}catch{console.warn(c.gray("Note: Could not register workspace in shared registry"));}}async function Ve(e,r=false){let t$1=a(e),o={workspacePath:t$1,workspaceFound:false,added:[],skipped:0};try{let a$1=await F(),s=a$1.workspaces.find(g=>g.path===t$1);if(!s){if(await ke(t$1,p.basename(p.resolve(e))),a$1=await F(),s=a$1.workspaces.find(g=>g.path===t$1),!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,n=0,d=[],u=[],w=[e],m=new Set;for(;w.length>0;){let g=w.shift();if(!g||m.has(g))continue;m.add(g);let y=await promises.readdir(g,{withFileTypes:true});for(let h of y){if(!h.isDirectory()||h.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(h.name))continue;let j=p.join(g,h.name),f=a(j);try{let k=false;for(let $ of [...t(f,"context.json"),...t(f,"project.json")])try{await promises.access($),k=true;break}catch{}if(k){let $=p.basename(f),R=s.projects.some(C=>C.path===f);u.push({name:$,path:f}),R?n++:(s.projects.push({name:$,path:f}),i++,d.push(f),r||console.log(`\u2714 Added: ${p.relative(e,f)}`));continue}}catch{}w.push(j);}}return await _(g=>{let y=g.workspaces.find(f=>f.path===t$1);if(!y)return;let h=`${t$1}${p.sep}`,j=(y.projects||[]).filter(f=>f.path!==t$1&&!f.path.startsWith(h));y.projects=B({...y,projects:[...j,...u]}).projects;}),i>0?r||console.log(`
1
+ import {c}from'./chunk-BUYLM6QV.js';import {a}from'./chunk-A5FBGRJA.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {b}from'./chunk-IKUFNK46.js';import {i,h as h$1}from'./chunk-ZGHJIQXL.js';import {h}from'./chunk-TABXSDTR.js';import {a as a$1}from'./chunk-TQEMLBAG.js';import {q,r,s}from'./chunk-RGNCL5OB.js';import {u,t}from'./chunk-VQZ5PI5J.js';import {promises}from'fs';import {randomUUID}from'crypto';import n from'path';import p from'chalk';import le from'fs-extra';import N from'ora';import {execa}from'execa';var de=3e4,me=45e3;async function ge(e){try{let r=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,env:a$1()});return r.stdout.trim()?n.resolve(e,r.stdout.trim()):null}catch{return null}}async function re(e,r,t){if(await ge(e)){r.warn("Git initialization skipped because target is already inside a git worktree");return}r.start("Initializing git repository...");try{await execa("git",["init"],{cwd:e,env:a$1()}),await execa("git",["add","."],{cwd:e,env:a$1()}),await execa("git",["-c","user.name=Workspai","-c","user.email=workspai@localhost","commit","-m",t],{cwd:e,env:a$1()}),r.succeed("Git repository initialized");}catch{r.warn("Could not initialize git repository");}}function G(e){let r=a(e.path),t=Array.isArray(e.projects)?e.projects:[],o=[],a$1=new Set;for(let s of t){if(!s||typeof s.name!="string"||typeof s.path!="string")continue;let i=a(s.path);a$1.has(i)||(a$1.add(i),o.push({name:s.name,path:i}));}return {name:e.name,path:r,mode:e.mode,projects:o}}function I(e){let r=[],t=new Set;for(let o of e.workspaces||[]){if(!o||typeof o.name!="string"||typeof o.path!="string")continue;let a=G(o);t.has(a.path)||(t.add(a.path),r.push(a));}return {workspaces:r}}async function ue(e){let r;try{r=await promises.readFile(e,"utf8");}catch(t){if(t.code==="ENOENT")return {workspaces:[]};throw t}try{let t=JSON.parse(r);if(!t||!Array.isArray(t.workspaces))throw new Error("missing workspaces array");return I(t)}catch(t){throw new Error(`Workspace registry is invalid: ${e}`,{cause:t})}}async function ke(e){let r;try{r=await promises.readFile(e,"utf8");}catch(o){if(o.code==="ENOENT")return {workspaces:[]};throw o}let t;try{t=JSON.parse(r);}catch(o){throw new Error(`Workspace registry is invalid: ${e}`,{cause:o})}if(!t||typeof t!="object"||!Array.isArray(t.workspaces))throw new Error(`Workspace registry is invalid: ${e}`);for(let o of t.workspaces)if(!o||typeof o.name!="string"||typeof o.path!="string"||o.mode!==void 0&&typeof o.mode!="string"||o.projects!==void 0&&!Array.isArray(o.projects)||Array.isArray(o.projects)&&o.projects.some(a=>!a||typeof a.name!="string"||typeof a.path!="string"))throw new Error(`Workspace registry contains an invalid entry: ${e}`);return I(t)}async function z(){let e={workspaces:[]},r=new Set;for(let t of s()){let o=await ue(t);for(let a of o.workspaces)r.has(a.path)||(r.add(a.path),e.workspaces.push(a));}return e}async function oe(e=s()){let r={workspaces:[]},t=new Set;for(let o of e){let a=await ke(o);for(let s of a.workspaces)t.has(s.path)||(t.add(s.path),r.workspaces.push(s));}return r}function fe(e){let r=e?.code;return process.platform==="win32"&&(r==="EPERM"||r==="EINVAL"||r==="ENOSYS")}async function ae(e){try{await e.sync();}catch(r){if(!fe(r))throw r}}async function X(e,r){let t=n.dirname(e);await promises.mkdir(t,{recursive:true});let o=`${n.basename(e)}.`,a=Date.now();for(let i of await promises.readdir(t)){if(!i.startsWith(o)||!i.endsWith(".tmp"))continue;let c=n.join(t,i),d=await promises.stat(c).catch(()=>null);d&&a-d.mtimeMs>3e4&&await promises.rm(c,{force:true}).catch(()=>{});}let s=await promises.readFile(e,"utf8").catch(()=>null);if(s!==null){let i=false;try{let c=JSON.parse(s);i=Array.isArray(c.workspaces);}catch{i=false;}if(!i){let c=`${e}.corrupt-${Date.now()}`;await promises.copyFile(e,c);}}await se(e,`${JSON.stringify(I(r),null,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
+ `),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())];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 (${n} found)`),{workspacePath:t$1,workspaceFound:true,added:d,skipped:n}}catch(a){return r||console.error("\u274C Failed to sync projects:",a.message),o}}async function we(e,r,t){let o=a(e),a$1=a(t);await _(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 n=i.projects.findIndex(u=>u.path===a$1||u.name===r),d={name:r,path:a$1};n>=0?i.projects[n]=d:i.projects.push(d);});}async function Ye(e,r,t){try{await we(e,r,t);}catch{}}async function He(e,r){let t=P("Creating Workspai workspace...").start();try{await promises.mkdir(e,{recursive:true}),await promises.mkdir(p.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(p.join(e,".workspai","config.json"),JSON.stringify(o,null,2));let{syncWorkspaceFoundationFiles:a}=await import('./create-ALT2ME6H.js');await a(e,{workspaceName:r.name,installMethod:"venv",writeMarker:true,writeGitignore:false,onlyIfMissing:true});let s=fe();await promises.writeFile(p.join(e,"rapidkit"),s),await promises.chmod(p.join(e,"rapidkit"),493);let i=he();await promises.writeFile(p.join(e,"rapidkit.cmd"),i);let n=ye(r.name);await promises.writeFile(p.join(e,"README.md"),n),await promises.writeFile(p.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-72ITVZXV.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,10 +17,10 @@ Thumbs.db
17
17
 
18
18
  # Logs
19
19
  *.log
20
- `),await $e(e),t.succeed("Workspace created!"),r.skipGit||await Z(e,P(),"Initial commit: Workspai workspace"),await oe(e,r.name);let{publishWorkspaceRegistrySummary:u}=await import('./workspace-registry-summary-LJN4WHIZ.js');await u(e),console.log(`
21
- ${c.green("\u2728 Workspai workspace created successfully!")}
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-STGUGROG.js');await u(e),console.log(`
21
+ ${p.green("\u2728 Workspai workspace created successfully!")}
22
22
 
23
- ${c.bold("\u{1F4C2} Workspace structure:")}
23
+ ${p.bold("\u{1F4C2} Workspace structure:")}
24
24
  ${e}/
25
25
  \u251C\u2500\u2500 rapidkit # Local CLI wrapper
26
26
  \u251C\u2500\u2500 rapidkit.cmd # Windows local CLI wrapper
@@ -32,29 +32,29 @@ ${e}/
32
32
  \u2502 \u2514\u2500\u2500 config.json # Workspai workspace config
33
33
  \u2514\u2500\u2500 README.md
34
34
 
35
- ${c.bold("\u{1F680} Get started:")}
36
- ${c.cyan(`cd ${r.name}`)}
37
- ${c.cyan("npx workspai create project fastapi.standard my-api --yes")}
38
- ${c.cyan("cd my-api")}
39
- ${c.cyan("npx workspai init")}
40
- ${c.cyan("npx workspai dev")}
35
+ ${p.bold("\u{1F680} Get started:")}
36
+ ${p.cyan(`cd ${r.name}`)}
37
+ ${p.cyan("npx workspai create project fastapi.standard my-api --yes")}
38
+ ${p.cyan("cd my-api")}
39
+ ${p.cyan("npx workspai init")}
40
+ ${p.cyan("npx workspai dev")}
41
41
 
42
- ${c.bold("\u{1F4E6} Available templates:")}
42
+ ${p.bold("\u{1F4E6} Available templates:")}
43
43
  fastapi - FastAPI + Python
44
44
  nestjs - NestJS + TypeScript
45
45
  springboot - Spring Boot + Java
46
46
  gofiber - Go Fiber
47
47
  gogin - Go Gin
48
48
 
49
- ${c.bold("\u{1F4DA} Commands:")}
49
+ ${p.bold("\u{1F4DA} Commands:")}
50
50
  npx workspai create project <kit> <name> Create a new project
51
51
  npx workspai init Install dependencies
52
52
  npx workspai dev Start dev server
53
53
  npx workspai help Show all commands
54
54
 
55
- ${c.gray("Alternative: npx workspai dev, make dev")}
56
- ${c.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx")}
57
- `);}catch(o){throw t.fail("Failed to create workspace"),o}}function fe(){return `#!/usr/bin/env bash
55
+ ${p.gray("Alternative: npx workspai dev, make dev")}
56
+ ${p.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx")}
57
+ `);}catch(o){throw t.fail("Failed to create workspace"),o}}function $e(){return `#!/usr/bin/env bash
58
58
  #
59
59
  # Workspai CLI - local workspace commands
60
60
  # This script provides legacy ./rapidkit commands within the workspace
@@ -440,7 +440,7 @@ main() {
440
440
  }
441
441
 
442
442
  main "$@"
443
- `}function he(){return `@echo off
443
+ `}function je(){return `@echo off
444
444
  setlocal enabledelayedexpansion
445
445
 
446
446
  set "SCRIPT_DIR=%~dp0"
@@ -460,7 +460,7 @@ if %ERRORLEVEL%==0 (
460
460
  echo [Workspai] No sh/bash found. Falling back to npx workspai.
461
461
  npx workspai %*
462
462
  exit /b %ERRORLEVEL%
463
- `}function ye(e){return `# ${e}
463
+ `}function ve(e){return `# ${e}
464
464
 
465
465
  Workspai workspace for building API projects.
466
466
 
@@ -517,7 +517,7 @@ instructions start at \`AGENTS.md\`.
517
517
 
518
518
  - [Workspai Documentation](https://workspai.dev)
519
519
  - [GitHub Repository](https://github.com/chistiq/workspai)
520
- `}async function $e(e){let{fileURLToPath:r}=await import('url'),t=r(import.meta.url),o=p.dirname(t),a=p.resolve(o,".."),s=p.join(a,"templates","kits"),i=p.join(e,".workspai","templates"),{default:n}=await import('fs-extra');await n.copy(s,i);let d=p.join(a,"templates","generator.js"),u=p.join(e,".workspai","generator.js");await n.copy(d,u);}async function Ke(e,r){let t=r.template==="fastapi",o=t?"FastAPI":"NestJS",a=P(`Creating ${o} project...`).start();try{let{fileURLToPath:s}=await import('url'),i=s(import.meta.url),n=p.dirname(i),d=p.resolve(n,".."),u=t?"fastapi-standard":"nestjs-standard",w=p.join(d,"templates","kits",u);await promises.mkdir(e,{recursive:true});let m={project_name:t?r.name.replace(/-/g,"_").toLowerCase():r.name.replace(/_/g,"-").toLowerCase(),author:r.author,description:r.description||`${o} application generated with Workspai`,app_version:"0.1.0",license:"MIT",package_manager:r.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:h()};await ae(w,e,m);let g=t?`# Python
520
+ `}async function _e(e){let{fileURLToPath:r}=await import('url'),t=r(import.meta.url),o=n.dirname(t),a=n.resolve(o,".."),s=n.join(a,"templates","kits"),i=n.join(e,".workspai","templates"),{default:c}=await import('fs-extra');await c.copy(s,i);let d=n.join(a,"templates","generator.js"),u=n.join(e,".workspai","generator.js");await c.copy(d,u);}async function et(e,r){let t=r.template==="fastapi",o=t?"FastAPI":"NestJS",a=N(`Creating ${o} project...`).start();try{let{fileURLToPath:s}=await import('url'),i=s(import.meta.url),c=n.dirname(i),d=n.resolve(c,".."),u=t?"fastapi-standard":"nestjs-standard",f=n.join(d,"templates","kits",u);await promises.mkdir(e,{recursive:true});let g={project_name:t?r.name.replace(/-/g,"_").toLowerCase():r.name.replace(/_/g,"-").toLowerCase(),author:r.author,description:r.description||`${o} application generated with Workspai`,app_version:"0.1.0",license:"MIT",package_manager:r.package_manager||"npm",created_at:new Date().toISOString(),rapidkit_version:h()};await ne(f,e,g);let k=t?`# Python
521
521
  __pycache__/
522
522
  *.py[cod]
523
523
  *$py.class
@@ -585,10 +585,10 @@ Thumbs.db
585
585
 
586
586
  # Coverage
587
587
  coverage/
588
- `;if(await promises.writeFile(p.join(e,".gitignore"),g),a.succeed(`${o} project created!`),r.skipGit||await Z(e,P(),`Initial commit: ${o} project via Workspai`),!r.skipInstall&&!t){let h=r.package_manager||"npm",j=P(`Installing dependencies with ${h}...`).start();try{await execa(h,["install"],{cwd:e}),j.succeed("Dependencies installed");}catch{j.warn(`Could not install dependencies. Run '${h} install' manually.`);}}let y=p.basename(e);console.log(t?`
589
- ${c.green("\u2728 FastAPI project created successfully!")}
588
+ `;if(await promises.writeFile(n.join(e,".gitignore"),k),a.succeed(`${o} project created!`),r.skipGit||await re(e,N(),`Initial commit: ${o} project via Workspai`),!r.skipInstall&&!t){let h=r.package_manager||"npm",v=N(`Installing dependencies with ${h}...`).start();try{await execa(h,["install"],{cwd:e}),v.succeed("Dependencies installed");}catch{v.warn(`Could not install dependencies. Run '${h} install' manually.`);}}let w=n.basename(e);console.log(t?`
589
+ ${p.green("\u2728 FastAPI project created successfully!")}
590
590
 
591
- ${c.bold("\u{1F4C2} Project structure:")}
591
+ ${p.bold("\u{1F4C2} Project structure:")}
592
592
  ${e}/
593
593
  \u251C\u2500\u2500 .workspai/ # Project metadata
594
594
  \u251C\u2500\u2500 src/
@@ -600,12 +600,12 @@ ${e}/
600
600
  \u251C\u2500\u2500 pyproject.toml # Poetry configuration
601
601
  \u2514\u2500\u2500 README.md
602
602
 
603
- ${c.bold("\u{1F680} Get started:")}
604
- ${c.cyan(`cd ${y}`)}
605
- ${c.cyan("npx workspai init")} ${c.gray("# Install dependencies")}
606
- ${c.cyan("npx workspai dev")} ${c.gray("# Start dev server")}
603
+ ${p.bold("\u{1F680} Get started:")}
604
+ ${p.cyan(`cd ${w}`)}
605
+ ${p.cyan("npx workspai init")} ${p.gray("# Install dependencies")}
606
+ ${p.cyan("npx workspai dev")} ${p.gray("# Start dev server")}
607
607
 
608
- ${c.bold("\u{1F4DA} Available commands:")}
608
+ ${p.bold("\u{1F4DA} Available commands:")}
609
609
  npx workspai init # Install dependencies (poetry install)
610
610
  npx workspai dev # Start dev server with hot reload
611
611
  npx workspai start # Start production server
@@ -613,12 +613,12 @@ ${c.bold("\u{1F4DA} Available commands:")}
613
613
  npx workspai lint # Lint code
614
614
  npx workspai format # Format code
615
615
 
616
- ${c.gray("Alternative: make dev, npx workspai dev, poetry run dev")}
617
- ${c.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx")}
616
+ ${p.gray("Alternative: make dev, npx workspai dev, poetry run dev")}
617
+ ${p.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx")}
618
618
  `:`
619
- ${c.green("\u2728 NestJS project created successfully!")}
619
+ ${p.green("\u2728 NestJS project created successfully!")}
620
620
 
621
- ${c.bold("\u{1F4C2} Project structure:")}
621
+ ${p.bold("\u{1F4C2} Project structure:")}
622
622
  ${e}/
623
623
  \u251C\u2500\u2500 .workspai/ # Project metadata
624
624
  \u251C\u2500\u2500 src/
@@ -630,13 +630,13 @@ ${e}/
630
630
  \u251C\u2500\u2500 package.json # Dependencies
631
631
  \u2514\u2500\u2500 README.md
632
632
 
633
- ${c.bold("\u{1F680} Get started:")}
634
- ${c.cyan(`cd ${y}`)}
635
- ${r.skipInstall?c.cyan("npx workspai init")+c.gray(" # npm install")+`
636
- `:""}${c.cyan("cp .env.example .env")}
637
- ${c.cyan("npx workspai dev")} ${c.gray("# Start dev server")}
633
+ ${p.bold("\u{1F680} Get started:")}
634
+ ${p.cyan(`cd ${w}`)}
635
+ ${r.skipInstall?p.cyan("npx workspai init")+p.gray(" # npm install")+`
636
+ `:""}${p.cyan("cp .env.example .env")}
637
+ ${p.cyan("npx workspai dev")} ${p.gray("# Start dev server")}
638
638
 
639
- ${c.bold("\u{1F4DA} Available commands:")}
639
+ ${p.bold("\u{1F4DA} Available commands:")}
640
640
  npx workspai init # Install dependencies
641
641
  npx workspai dev # Start dev server with hot reload
642
642
  npx workspai start # Start production server
@@ -645,22 +645,22 @@ ${c.bold("\u{1F4DA} Available commands:")}
645
645
  npx workspai lint # Lint code
646
646
  npx workspai format # Format code
647
647
 
648
- ${c.bold("\u{1F310} API endpoints:")}
648
+ ${p.bold("\u{1F310} API endpoints:")}
649
649
  http://localhost:8000/health # Health check
650
650
  http://localhost:8000/docs # Swagger docs
651
651
  http://localhost:8000/examples/notes # Example API
652
652
 
653
- ${c.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx")}
654
- `);}catch(s){throw a.fail(`Failed to create ${o} project`),s}}async function ae(e,r,t){let o=await promises.readdir(e,{withFileTypes:true});for(let a of o){let s=p.join(e,a.name),i=a.name.replace(/\.j2$/,""),n=p.join(r,i);if(a.isDirectory())await promises.mkdir(n,{recursive:true}),await ae(s,n,t);else {let d=await promises.readFile(s,"utf-8");a.name.endsWith(".j2")&&(d=je(d,t)),await promises.writeFile(n,d),(i==="rapidkit"||i==="activate"||i.endsWith(".py")&&(n.includes(".workspai")||n.includes(".rapidkit")))&&await promises.chmod(n,493);}}}function je(e,r){let t=e;for(let[o,a]of Object.entries(r)){let s=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");t=t.replace(s,String(a));let i=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");t=t.replace(i,(u,w,m)=>String(a).replace(new RegExp(w,"g"),m));let n=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");t=t.replace(n,String(a).toLowerCase());let d=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");t=t.replace(d,(u,w,m)=>String(a).replace(new RegExp(w,"g"),m).toLowerCase());}return t}async function qe(e={}){let r=q$1(),t=p.join(r,"workspaces.json"),o=await F();if(o.workspaces.length===0){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:false}},null,2));return}console.log(c.yellow(`
653
+ ${p.gray("\u{1F4A1} Tip: Install globally (npm i -g workspai) to use without npx")}
654
+ `);}catch(s){throw a.fail(`Failed to create ${o} project`),s}}async function ne(e,r,t){let o=await promises.readdir(e,{withFileTypes:true});for(let a of o){let s=n.join(e,a.name),i=a.name.replace(/\.j2$/,""),c=n.join(r,i);if(a.isDirectory())await promises.mkdir(c,{recursive:true}),await ne(s,c,t);else {let d=await promises.readFile(s,"utf-8");a.name.endsWith(".j2")&&(d=Pe(d,t)),await promises.writeFile(c,d),(i==="rapidkit"||i==="activate"||i.endsWith(".py")&&(c.includes(".workspai")||c.includes(".rapidkit")))&&await promises.chmod(c,493);}}}function Pe(e,r){let t=e;for(let[o,a]of Object.entries(r)){let s=new RegExp(`\\{\\{\\s*${o}\\s*\\}\\}`,"g");t=t.replace(s,String(a));let i=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\}\\}`,"g");t=t.replace(i,(u,f,g)=>String(a).replace(new RegExp(f,"g"),g));let c=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*lower\\s*\\}\\}`,"g");t=t.replace(c,String(a).toLowerCase());let d=new RegExp(`\\{\\{\\s*${o}\\s*\\|\\s*replace\\s*\\(\\s*['"]([^'"]+)['"]\\s*,\\s*['"]([^'"]*)['"]\\s*\\)\\s*\\|\\s*lower\\s*\\}\\}`,"g");t=t.replace(d,(u,f,g)=>String(a).replace(new RegExp(f,"g"),g).toLowerCase());}return t}async function tt(e={}){let r=q(),t=n.join(r,"workspaces.json"),o=await z();if(o.workspaces.length===0){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:false}},null,2));return}console.log(p.yellow(`
655
655
  \u26A0\uFE0F No workspaces registered yet.
656
- `)),console.log(c.gray(`Create a workspace with: npx workspai <workspace-name>
657
- `));return}try{let a=o;if(!a||typeof a!="object"||!Array.isArray(a.workspaces)){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:true,registryValid:false},error:{code:"workspace.registry.invalid",message:"Workspace registry is invalid."}},null,2));return}console.log(c.yellow(`
656
+ `)),console.log(p.gray(`Create a workspace with: npx workspai <workspace-name>
657
+ `));return}try{let a=o;if(!a||typeof a!="object"||!Array.isArray(a.workspaces)){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:true,registryValid:false},error:{code:"workspace.registry.invalid",message:"Workspace registry is invalid."}},null,2));return}console.log(p.yellow(`
658
658
  \u26A0\uFE0F Workspace registry is invalid; resetting to empty state.
659
- `)),await _(m=>{m.workspaces=[];});return}let s=b(a),i=[],n=0;for(let m of s.workspaces)await promises.stat(m.path).catch(()=>null)?i.push(m):n+=1;let d={workspaces:i},u=JSON.stringify(a),w=JSON.stringify(d);if(!e.json&&u!==w){let m=new Set(i.map(g=>g.path));await _(g=>{g.workspaces=g.workspaces.filter(y=>m.has(y.path));});}if(!d.workspaces||d.workspaces.length===0){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:n,registryExists:true,registryValid:true,cleanupApplied:false}},null,2));return}console.log(c.yellow(`
659
+ `)),await S(g=>{g.workspaces=[];});return}let s=I(a),i=[],c=0;for(let g of s.workspaces)await promises.stat(g.path).catch(()=>null)?i.push(g):c+=1;let d={workspaces:i},u=JSON.stringify(a),f=JSON.stringify(d);if(!e.json&&u!==f){let g=new Set(i.map(k=>k.path));await S(k=>{k.workspaces=k.workspaces.filter(w=>g.has(w.path));});}if(!d.workspaces||d.workspaces.length===0){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:c,registryExists:true,registryValid:true,cleanupApplied:false}},null,2));return}console.log(p.yellow(`
660
660
  \u26A0\uFE0F No workspaces registered yet.
661
- `)),n>0&&console.log(c.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.
662
- `));return}if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:d.workspaces,summary:{total:d.workspaces.length,missing:n,registryExists:true,registryValid:true,cleanupApplied:false}},null,2));return}console.log(c.bold(`
661
+ `)),c>0&&console.log(p.gray(`Cleaned ${c} stale workspace entr${c===1?"y":"ies"}.
662
+ `));return}if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:d.workspaces,summary:{total:d.workspaces.length,missing:c,registryExists:true,registryValid:true,cleanupApplied:false}},null,2));return}console.log(p.bold(`
663
663
  \u{1F4E6} Registered Workspai Workspaces:
664
- `));for(let m of d.workspaces)console.log(c.cyan(` ${m.name}`)),console.log(c.gray(` Path: ${m.path}`)),console.log(c.gray(` Projects: ${m.projects?.length||0}`)),console.log();n>0&&console.log(c.gray(`Cleaned ${n} stale workspace entr${n===1?"y":"ies"}.`)),console.log(c.gray(`Total: ${d.workspaces.length} workspace(s)
665
- `));}catch(a){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:true,registryValid:false},error:{code:"workspace.registry.read_failed",message:a.message}},null,2));return}console.error(c.red(`
666
- \u274C Failed to read workspace registry`)),console.error(c.gray(String(a)));}}async function ve(e){try{let r=await promises.readFile(e,"utf8");return JSON.parse(r)}catch{return null}}async function D(e){for(let r of e){let t=await ve(r);if(t!==null)return t}return null}function _e(e){return c$1(e)}async function Ee(e){return a$2(e,{skipDirs:new Set(["node_modules","dist","build","target","coverage","htmlcov"]),includeHiddenDirs:false,descendIntoMatchedProjects:true})}async function O(e){try{return (await promises.readdir(e,{withFileTypes:true})).filter(t=>t.isFile()&&t.name.toLowerCase().endsWith(".json")).map(t=>t.name).sort((t,o)=>t.localeCompare(o))}catch{return []}}async function Qe(e,r){let t$1=r?.includePaths===true,o=r?.includeDoctorEvidence!==false,a=r?.includeBlueprint!==false,s$1=p.resolve(e),i$1=await D(s(s$1,"workspace.json")),n=typeof i$1?.workspace_name=="string"&&i$1.workspace_name.trim()||p.basename(s$1),d=typeof i$1?.profile=="string"?i$1.profile:void 0,u=typeof i$1?.rapidkit_version=="string"?i$1.rapidkit_version:void 0,w=await Ee(s$1),m=[];for(let k of w){let $=await D(t(k,"project.json")),R=p.relative(s$1,k)||".",C=p.dirname(t(k,p.join("reports","placeholder"))[0]),J=p.dirname(t(k,p.join("reports","placeholder"))[1]),N={name:p.basename(k),relative_path:R,runtime:typeof $?.runtime=="string"?$.runtime:void 0,kit_name:typeof $?.kit_name=="string"?$.kit_name:void 0,modules:Array.isArray($?.modules)?$.modules.filter(E=>typeof E=="string"):void 0};if(t$1&&(N.absolute_path=k),o){let E=await D([p.join(C,"doctor-last-run.json"),p.join(J,"doctor-last-run.json")]);_e(E)&&(N.doctor_report=E);}let U=[...await O(C),...await O(J)].filter((E,se,ie)=>ie.indexOf(E)===se);U.length>0&&(N.reports=U),m.push(N);}let g=s(s$1,"reports"),y=[...await O(g[0]),...await O(g[1])].filter((k,$,R)=>R.indexOf(k)===$),h=await D(s(s$1,"workspace.contract.json")),j={schema_version:h$1.workspaceShareBundle.schemaVersion,generated_at:new Date().toISOString(),generated_by:"workspai",workspace:{name:n,relative_root:".",profile:d,rapidkit_version:u,...t$1?{absolute_root:s$1}:{}},summary:{project_count:m.length,doctor_evidence_included:o,contract_included:!!h},reports:{workspace:y},projects:m,...h?{contract:h}:{}};a&&(j.blueprint={schema_version:"rapidkit.workspace-blueprint.v1",purpose:"portable-reproducibility",workspace:{name:n,profile:d},projects:m.map(k=>({name:k.name,relative_path:k.relative_path,runtime:k.runtime,kit_name:k.kit_name,modules:k.modules??[],recreate_commands:[...k.kit_name?[`npx workspai create project ${k.kit_name} ${k.name} --yes --skip-install`]:[],`cd ${k.relative_path}`,"npx workspai init","npx workspai test"]})),recommended_commands:["npx workspai workspace contract verify --strict","npx workspai doctor workspace","npx workspai workspace run init --json","npx workspai workspace run test --strict --json","npx workspai readiness --strict --json"]});let f=r?.outputPath?p.resolve(r.outputPath):p.join(g[0],"share-bundle.json");return r?.outputPath||b$1(i.workspaceShareBundle,j),await promises.mkdir(p.dirname(f),{recursive:true}),await promises.writeFile(f,JSON.stringify(j,null,2),"utf8"),f}export{B as a,oe as b,ze as c,Ge as d,Me as e,ke as f,Ve as g,we as h,Ye as i,He as j,Ke as k,qe as l,Qe as m};
664
+ `));for(let g of d.workspaces)console.log(p.cyan(` ${g.name}`)),console.log(p.gray(` Path: ${g.path}`)),console.log(p.gray(` Projects: ${g.projects?.length||0}`)),console.log();c>0&&console.log(p.gray(`Cleaned ${c} stale workspace entr${c===1?"y":"ies"}.`)),console.log(p.gray(`Total: ${d.workspaces.length} workspace(s)
665
+ `));}catch(a){if(e.json){console.log(JSON.stringify({schemaVersion:"rapidkit-workspace-list-v1",registryPath:t,workspaces:[],summary:{total:0,missing:0,registryExists:true,registryValid:false},error:{code:"workspace.registry.read_failed",message:a.message}},null,2));return}console.error(p.red(`
666
+ \u274C Failed to read workspace registry`)),console.error(p.gray(String(a)));}}function Re(e){if(!e||typeof e!="object"||Array.isArray(e))return [];let r=e.projects;return Array.isArray(r)?r.filter(t=>!!t&&typeof t=="object"&&!Array.isArray(t)):[]}function Se(e,r){if(r||!e||typeof e!="object"||Array.isArray(e))return e;let t=structuredClone(e);return Array.isArray(t.projects)&&(t.projects=t.projects.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return o;let a={...o};return delete a.externalPath,a})),t}async function xe(e){try{let r=await promises.readFile(e,"utf8");return JSON.parse(r)}catch{return null}}async function B(e){for(let r of e){let t=await xe(r);if(t!==null)return t}return null}function Ee(e){return c(e)}async function We(e){return a$2(e,{skipDirs:new Set(["node_modules","dist","build","target","coverage","htmlcov"]),includeHiddenDirs:false,descendIntoMatchedProjects:true})}async function J(e){try{return (await promises.readdir(e,{withFileTypes:true})).filter(t=>t.isFile()&&t.name.toLowerCase().endsWith(".json")).map(t=>t.name).sort((t,o)=>t.localeCompare(o))}catch{return []}}async function rt(e,r){let t$1=r?.includePaths===true,o=r?.includeDoctorEvidence!==false,a=r?.includeBlueprint!==false,s=n.resolve(e),i$1=await B(t(s,"workspace.json")),c=typeof i$1?.workspace_name=="string"&&i$1.workspace_name.trim()||n.basename(s),d=typeof i$1?.profile=="string"?i$1.profile:void 0,u$1=typeof i$1?.rapidkit_version=="string"?i$1.rapidkit_version:void 0,f=await B(t(s,"workspace.contract.json")),g=Se(f,t$1),k=await We(s),w=new Map;for(let m of k)w.set(n.resolve(m),{projectPath:n.resolve(m)});for(let m of Re(f)){let $=typeof m.externalPath=="string"?m.externalPath.trim():"",j=typeof m.relativePath=="string"?m.relativePath.trim():"";if(!$&&!j)continue;let b=n.resolve(s,$||j),R=w.get(b);w.set(b,{projectPath:b,name:typeof m.slug=="string"&&m.slug.trim()?m.slug.trim():R?.name,relativePath:j||R?.relativePath,runtime:typeof m.runtime=="string"&&m.runtime.trim()?m.runtime.trim():R?.runtime,kit:typeof m.kit=="string"&&m.kit.trim()?m.kit.trim():R?.kit,modules:Array.isArray(m.modules)?m.modules.filter(L=>typeof L=="string"):R?.modules});}let h=[];for(let m of w.values()){let $=m.projectPath,j=await B(u($,"project.json")),b=m.relativePath||n.relative(s,$)||".",R=n.dirname(u($,n.join("reports","placeholder"))[0]),L=n.dirname(u($,n.join("reports","placeholder"))[1]),D={name:m.name||n.basename($),relative_path:b,runtime:typeof j?.runtime=="string"?j.runtime:m.runtime,kit_name:typeof j?.kit_name=="string"?j.kit_name:m.kit,modules:Array.isArray(j?.modules)?j.modules.filter(E=>typeof E=="string"):m.modules};if(t$1&&(D.absolute_path=$),o){let E=await B([n.join(R,"doctor-last-run.json"),n.join(L,"doctor-last-run.json")]);Ee(E)&&(D.doctor_report=E);}let M=[...await J(R),...await J(L)].filter((E,ce,pe)=>pe.indexOf(E)===ce);M.length>0&&(D.reports=M),h.push(D);}let v=t(s,"reports"),y=[...await J(v[0]),...await J(v[1])].filter((m,$,j)=>j.indexOf(m)===$),x={schema_version:h$1.workspaceShareBundle.schemaVersion,generated_at:new Date().toISOString(),generated_by:"workspai",workspace:{name:c,relative_root:".",profile:d,rapidkit_version:u$1,...t$1?{absolute_root:s}:{}},summary:{project_count:h.length,doctor_evidence_included:o,contract_included:!!g},reports:{workspace:y},projects:h,...g?{contract:g}:{}};a&&(x.blueprint={schema_version:"rapidkit.workspace-blueprint.v1",purpose:"portable-reproducibility",workspace:{name:c,profile:d},projects:h.map(m=>({name:m.name,relative_path:m.relative_path,runtime:m.runtime,kit_name:m.kit_name,modules:m.modules??[],recreate_commands:[...m.kit_name?[`npx workspai create project ${m.kit_name} ${m.name} --yes --skip-install`]:[],`cd ${m.relative_path}`,"npx workspai init","npx workspai test"]})),recommended_commands:["npx workspai workspace contract verify --strict","npx workspai doctor workspace","npx workspai workspace run init --json","npx workspai workspace run test --strict --json","npx workspai readiness --strict --json"]});let P=r?.outputPath?n.resolve(r.outputPath):n.join(v[0],"share-bundle.json");return r?.outputPath||b(i.workspaceShareBundle,x),await promises.mkdir(n.dirname(P),{recursive:true}),await promises.writeFile(P,JSON.stringify(x,null,2),"utf8"),P}export{G as a,ie as b,He as c,Ke as d,qe as e,he as f,Qe as g,ye as h,Xe as i,Ze as j,et as k,tt as l,rt as m};
@@ -0,0 +1,2 @@
1
+ import {b as b$1}from'./chunk-B6FJ6RG6.js';import {k,q as q$1}from'./chunk-NVND4727.js';import {a}from'./chunk-EHCKITR4.js';import {c,j as j$1}from'./chunk-L5Q2S5GY.js';import {m as m$2}from'./chunk-U5ENEDJA.js';import {e,f}from'./chunk-TABXSDTR.js';import {b}from'./chunk-UJXE4UAX.js';import {m as m$1,t,k as k$2,u,l}from'./chunk-VQZ5PI5J.js';import le,{promises}from'fs';import c$1 from'path';import U,{homedir}from'os';import {pathToFileURL}from'url';import m from'process';import k$1 from'fs-extra';function Q(o){let t=o.label.indexOf(" \u2014 ");return t>=0?o.label.slice(t+3).trim():o.label.trim()}function X(){let o=c().map(n=>({value:n.id,label:`${D(n.category)} \xB7 ${Q(n)}`,hint:`${n.runtime} \xB7 tested baseline`,name:n.label})),e=k().map(n=>({value:n.kitId,label:`Frontend \xB7 ${n.displayName}`,hint:"official \xB7 latest stable",name:`${n.displayName} \u2014 ${n.framework}`})),t=q$1().map(n=>({value:n.kitId,label:`${D(n.category)} \xB7 ${n.displayName}`,hint:`${n.runtimeCandidates.join(" + ")} \xB7 official latest stable`,name:`${n.displayName} \u2014 ${n.category}`})),r=[...o,...e,...t].sort((n,i)=>{let s=["Backend","Frontend","Desktop","Extension"],a=n.label?.split(" \xB7 ")[0]??"",l=i.label?.split(" \xB7 ")[0]??"";return s.indexOf(a)-s.indexOf(l)||(n.label??"").localeCompare(i.label??"")});return T(r),r}function D(o){return o.charAt(0).toUpperCase()+o.slice(1)}function T(o){let e=new Set,t=new Set;for(let r of o){let n=r.label??r.name??String(r.value),i=String(r.value);if(e.has(n))throw new Error(`Duplicate kit picker label: ${n}`);if(t.has(i))throw new Error(`Duplicate kit picker value: ${i}`);e.add(n),t.add(i);}}var ee=".workspairc.json",oe=".rapidkitrc.json",te=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"],ne=["workspai.config.json","rapidkit.config.json"];function B(o){return typeof o=="object"&&o!==null&&"code"in o&&o.code==="ENOENT"}function C(o,e){let t=e instanceof Error?e.message:String(e),r=o.endsWith(".js")&&/module is not defined in ES module scope/i.test(t)?' CommonJS syntax in a .js config is not valid when the project package uses "type": "module"; rename the file to .cjs or use export default.':"";return `Failed to load Workspai config at ${o}.${r} Cause: ${t}`}async function Qe(){for(let o of [c$1.join(U.homedir(),ee),c$1.join(U.homedir(),oe)])try{let e$1=await promises.readFile(o,"utf-8"),t=JSON.parse(e$1);return e.debug(`Loaded config from ${o}`),t}catch{}return e.debug("No user config found, using defaults"),{}}async function Xe(o=process.cwd(),e$1={}){let t=o,r=c$1.parse(t).root;for(;t!==r;){for(let n of ne){let i=c$1.join(t,n);try{let s=await promises.readFile(i,"utf-8"),a=JSON.parse(s);if(!a||typeof a!="object"||Array.isArray(a))throw new Error("configuration root must be a JSON object");return e.debug(`Loaded data-only Workspai config from ${n}`),a}catch(s){if(B(s))continue;throw new Error(C(i,s))}}for(let n of te){let i=c$1.join(t,n);try{await promises.access(i);}catch(s){if(B(s))continue;throw new Error(C(i,s))}if(e.debug(`Found config file: ${i}`),!e$1.trustExecutableConfig)throw new Error(`Refusing to execute Workspai config at ${i} without explicit trust. Use a data-only workspai.config.json file, pass --trust-config, or set WORKSPAI_TRUST_CONFIG=1.`);try{let a=await import(pathToFileURL(i).href),l=a.default||a;return e.debug(`Loaded Workspai config from ${n}`),l}catch(s){throw new Error(C(i,s))}}t=c$1.dirname(t);}return e.debug("No Workspai config file found, using defaults"),{}}function Ze(o,e,t){return {author:t.author||e.workspace?.defaultAuthor||o.author,pythonVersion:t.pythonVersion||e.workspace?.pythonVersion||o.pythonVersion,defaultInstallMethod:t.defaultInstallMethod||e.workspace?.installMethod||o.defaultInstallMethod,defaultKit:t.defaultKit||e.projects?.defaultKit||o.defaultKit,skipGit:t.skipGit??e.projects?.skipGit??o.skipGit,license:t.license||o.license,testRapidKitPath:t.testRapidKitPath||o.testRapidKitPath}}function eo(o){return f("DEV_PATH")||o.testRapidKitPath||void 0}var j=class extends Error{constructor(t,r){super(["Workspai workspaces cannot be nested.",`Target: ${t}`,`Containing workspace: ${r}`,"Choose Managed home or pass --output <path> with a location outside the current workspace."].join(`
2
+ `));this.targetPath=t;this.containingWorkspacePath=r;this.name="NestedWorkspaceCreationError";}targetPath;containingWorkspacePath;code="WORKSPACE_NESTING_NOT_SUPPORTED"};async function ie(o){try{return !!await k$1.stat(o)}catch{return false}}function se(o,e){let t=o.indexOf(e);if(t>=0&&t+1<o.length)return o[t+1];let r=o.find(n=>n.startsWith(`${e}=`));if(r)return r.slice(e.length+1)}function ae(o){return o.includes("--here")}async function J(o){let e=c$1.resolve(o);for(;;){let t=[c$1.join(e,".workspai-workspace"),c$1.join(e,".rapidkit-workspace"),c$1.join(e,".workspai","workspace.json"),c$1.join(e,".rapidkit","workspace.json")];if((await Promise.all(t.map(ie))).some(Boolean))return e;let r=c$1.dirname(e);if(r===e)return;e=r;}}async function po(o){let e=c$1.resolve(o),t=await J(c$1.dirname(e));if(t)throw new j(e,t)}async function ce(o,e=homedir()){let r=[{value:"managed",label:"Managed home",hint:l(e)}];return await J(o)||r.push({value:"here",label:"Current directory",hint:o}),r}function V(o,e=m.cwd()){if(ae(o))return c$1.resolve(e);let t=se(o,"--output");if(t)return c$1.resolve(t)}function uo(o,e=m.cwd()){let t=c$1.resolve(o),r=c$1.resolve(e),n=c$1.relative(r,t);return n.length>0&&!n.startsWith("..")&&!c$1.isAbsolute(n)?`cd ${n}`:`cd ${t}`}function mo(o,e={}){let t=e.argv??[],r=e.outputParent??V(t,m.cwd());return m$1(o.trim(),{homeDir:e.homeDir,outputDir:r})}function fo(o,e,t={}){return o?c$1.resolve(o)===c$1.resolve(e)?true:t.outputParent===void 0:false}async function go(o,e={}){let t=e.cwd??m.cwd(),r=e.homeDir??homedir(),n=V(o,t);if(n!==void 0)return n;let i=e.hasYes??(o.includes("--yes")||o.includes("-y"));if(!(e.interactive??(!i&&!!m.stdin.isTTY&&!b())))return;let a=await ce(t,r);if(a.length===1)return;let{location:l}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:a,default:0}]);if(l==="here")return c$1.resolve(t)}var pe=["minimal","python-only","node-only","go-only","java-only","dotnet-only","polyglot","enterprise"],de=new Set(["minimal","node-only","go-only","java-only","dotnet-only"]),xo=new Set(["python-only","polyglot","enterprise"]);function ue(o){return typeof o=="string"&&pe.includes(o)}function jo(o){return ue(o)&&de.has(o)}var q={"python-only":"python","node-only":"node","go-only":"go","java-only":"java","dotnet-only":"dotnet"},me={python:"Python",node:"Node",go:"Go",java:"Java",dotnet:".NET",php:"PHP",ruby:"Ruby",rust:"Rust",elixir:"Elixir",clojure:"Clojure",scala:"Scala",kotlin:"Kotlin",deno:"Deno",bun:"Bun",c:"C",cpp:"C++",unknown:"Unknown"},fe={python:"python-only",node:"node-only",go:"go-only",java:"java-only",dotnet:"dotnet-only"},H=["node","deno","bun","python","go","java","kotlin","scala","dotnet","php","ruby","rust","elixir","clojure","c","cpp","unknown"];function E(o){return o==="bun"||o==="deno"?"node":o==="kotlin"||o==="scala"?"java":o}function v(o){return typeof o!="string"||o.trim().length===0?"minimal":o.trim().toLowerCase()}function g(o){if(typeof o!="string")return "unknown";let e=o.trim().toLowerCase();return e==="python"||e==="node"||e==="go"||e==="java"||e==="dotnet"||e==="php"||e==="ruby"||e==="rust"||e==="elixir"||e==="clojure"||e==="scala"||e==="kotlin"||e==="deno"||e==="bun"||e==="c"||e==="cpp"?e:e==="c++"||e==="cplusplus"||e==="cc"||e==="clang++"||e==="g++"?"cpp":e==="clang"||e==="gcc"?"c":"unknown"}function w(o){let e=new Set;for(let t of o)e.add(g(t));return [...e].sort((t,r)=>H.indexOf(t)-H.indexOf(r))}function ge(o){let e=w(o).filter(t=>t!=="unknown");if(e.length!==0)return e.length===1?fe[e[0]]:"polyglot"}function Y(o,e={}){return `npx workspai bootstrap --profile ${o}${e.ci?" --ci --json":""}`}function he(o,e){return o?"none":e==="strict"?"error":"warning"}function h(o){let e=o.ok?void 0:ge(o.runtimes)??"polyglot";return {ok:o.ok,checkId:o.checkId,status:o.ok?"passed":"failed",profile:o.profile,runtimes:o.runtimes,message:o.message,recommendedProfile:e,recommendedCommand:e?Y(e):void 0,ciRecommendedCommand:e?Y(e,{ci:true}):void 0,severity:he(o.ok,o.mode)}}function Eo(o){let e=v(o.profile),t=w(o.runtimes),r=o.mode??"warn",n=q[e];if(n){let i=t.length===0||t.every(s=>E(s)===n);return h({ok:i,checkId:`profile.${e}`,profile:e,runtimes:t,message:i?`${e} profile validated for discovered projects.`:`${e} profile mismatch: detected runtimes [${t.join(", ")}].`,mode:r})}if(e==="minimal"){let i=t.filter(l=>l!=="unknown"),a=new Set(i.map(l=>E(l))).size<=1;return h({ok:a,checkId:"profile.minimal",profile:e,runtimes:t,message:a?"minimal profile is compatible with detected runtime mix.":`minimal profile mismatch: multiple runtimes detected [${i.join(", ")}].`,mode:r})}return h({ok:true,checkId:`profile.${e}`,profile:e,runtimes:t,message:`${e} profile accepts the detected runtime mix.`,mode:r})}function vo(o){let e=v(o.profile),t=g(o.runtime),r=o.mode??"warn",n=q[e];if(!n||t==="unknown")return h({ok:true,checkId:`profile.${e}`,profile:e,runtimes:[t],message:t==="unknown"?`Project "${o.subjectLabel}" runtime is unknown; profile compatibility will be checked by workspace doctor.`:`${e} profile accepts project "${o.subjectLabel}".`,mode:r});let i=E(t)===n;return h({ok:i,checkId:`profile.${e}`,profile:e,runtimes:i?[t]:w([n,t]),message:i?`Project "${o.subjectLabel}" is compatible with workspace profile "${e}".`:`Project "${o.subjectLabel}" is ${me[t]}, but workspace profile is "${e}".`,mode:r})}async function Fo(o){let e=(await Promise.all(t(o,"policies.yml").map(async t=>await k$1.pathExists(t)?t:null))).find(t=>typeof t=="string");if(!e)return "warn";try{return (await k$1.readFile(e,"utf-8")).match(/^\s*mode:\s*(warn|strict)\s*(?:#.*)?$/m)?.[1]==="strict"?"strict":"warn"}catch{return "warn"}}async function Io(o){let e=(await Promise.all(t(o,"workspace.json").map(async t=>await k$1.pathExists(t)?t:null))).find(t=>typeof t=="string");if(!e)return "minimal";try{let t=await k$1.readJson(e);return v(t.profile)}catch{return "minimal"}}async function $o(o,e={}){let t=new Set,r=[],n=new Set,i=[o];for(;i.length>0;){let s=i.pop();if(!s||n.has(s))continue;n.add(s);let a=[];try{a=await le.promises.readdir(s,{withFileTypes:true});}catch{continue}for(let l of a){if(!l.isDirectory()||l.name.startsWith(".")||["node_modules","dist","build","target","coverage","htmlcov"].includes(l.name))continue;let p=c$1.join(s,l.name);if(p!==o&&k$2(p))continue;if((await Promise.all([...u(p,"context.json"),...u(p,"project.json")].map(async z=>k$1.pathExists(z)))).some(Boolean)){r.push(p);continue}i.push(p);}}for(let s of r){if(e.excludeProjectPath&&c$1.resolve(s)===c$1.resolve(e.excludeProjectPath))continue;let a=j$1(s);t.add(g(m$2(s,a).runtime));}for(let s of await a(o))e.excludeProjectPath&&c$1.resolve(s.path)===c$1.resolve(e.excludeProjectPath)||t.add(g(s.runtime));for(let s of e.additionalRuntimes??[])t.add(g(s));return w(t)}function Ao(o,e={}){let t=e.ci?o.ciRecommendedCommand:o.recommendedCommand;return t?`Recommended: ${t}`:null}export{X as a,Qe as b,Xe as c,Ze as d,eo as e,po as f,uo as g,mo as h,fo as i,go as j,xo as k,jo as l,Eo as m,vo as n,Fo as o,Io as p,$o as q,Ao as r};
@@ -1,2 +1,2 @@
1
- import {a}from'./chunk-AFIFZTOY.js';import {e,g,f,h,p,j}from'./chunk-NZ3WZYD5.js';import h$1 from'path';function u(t){let r=Object.values(p).filter(e=>e.produces.includes(t)).map(e=>[...e.command]),o=j[t]??[];return [...r,...o.map(e=>[...e])]}var P=Object.keys(e).flatMap(t=>{let r=t,o=f[r],e$1=g[r];if(!o||!e$1)return [];let n=e[r];return [{artifactPath:n,schemaVersion:o,contractPath:e$1,producerCommands:u(n)}]}),T=Object.values(h).map(t=>({...t,producerCommands:t.producerCommands.map(r=>[...r])})),d=Object.freeze(Object.fromEntries([...P,...T].map(t=>[t.artifactPath,t])));function l(t){return t.split(h$1.sep).join("/").replace(/^\.\//,"")}var s=h,I=[{pattern:/^\.workspai\/reports\/bootstrap-compliance-[^/]+\.json$/,canonicalPath:s.bootstrapCompliance.artifactPath},{pattern:/^\.workspai\/reports\/mirror-ops-[^/]+\.json$/,canonicalPath:s.mirrorOps.artifactPath},{pattern:/^\.workspai\/reports\/transparency-evidence-[^/]+\.json$/,canonicalPath:s.transparencyEvidence.artifactPath},{pattern:/^\.workspai\/reports\/projects\/[^/]+\/doctor-project-last-run\.json$/,canonicalPath:s.doctorProject.artifactPath},{pattern:/^\.workspai\/reports\/projects\/[^/]+\/project-test-coverage-last-run\.json$/,canonicalPath:s.projectTestCoverage.artifactPath}];function R(t){let r=l(t),o=d[r];if(o)return o;let e=I.find(n=>n.pattern.test(r));return e?d[e.canonicalPath]??null:null}function k(t,r,o=t){let e=l(t),n=R(t);if(!n){if(e.startsWith(".workspai/reports/")&&e.endsWith(".json"))throw new Error(`${o} is a public workspace report without a registered artifact contract`);return}let f=n.schemaVersionField??"schemaVersion",i=r&&typeof r=="object"?r[f]:void 0;if(i!==n.schemaVersion)throw new Error(`${o} schemaVersion is ${String(i)}, expected ${n.schemaVersion}`);a(r,n.contractPath,o);}
1
+ import {a}from'./chunk-AFIFZTOY.js';import {e,g,f,h,p,j}from'./chunk-ZGHJIQXL.js';import h$1 from'path';function u(t){let r=Object.values(p).filter(e=>e.produces.includes(t)).map(e=>[...e.command]),o=j[t]??[];return [...r,...o.map(e=>[...e])]}var P=Object.keys(e).flatMap(t=>{let r=t,o=f[r],e$1=g[r];if(!o||!e$1)return [];let n=e[r];return [{artifactPath:n,schemaVersion:o,contractPath:e$1,producerCommands:u(n)}]}),T=Object.values(h).map(t=>({...t,producerCommands:t.producerCommands.map(r=>[...r])})),d=Object.freeze(Object.fromEntries([...P,...T].map(t=>[t.artifactPath,t])));function l(t){return t.split(h$1.sep).join("/").replace(/^\.\//,"")}var s=h,I=[{pattern:/^\.workspai\/reports\/bootstrap-compliance-[^/]+\.json$/,canonicalPath:s.bootstrapCompliance.artifactPath},{pattern:/^\.workspai\/reports\/mirror-ops-[^/]+\.json$/,canonicalPath:s.mirrorOps.artifactPath},{pattern:/^\.workspai\/reports\/transparency-evidence-[^/]+\.json$/,canonicalPath:s.transparencyEvidence.artifactPath},{pattern:/^\.workspai\/reports\/projects\/[^/]+\/doctor-project-last-run\.json$/,canonicalPath:s.doctorProject.artifactPath},{pattern:/^\.workspai\/reports\/projects\/[^/]+\/project-test-coverage-last-run\.json$/,canonicalPath:s.projectTestCoverage.artifactPath}];function R(t){let r=l(t),o=d[r];if(o)return o;let e=I.find(n=>n.pattern.test(r));return e?d[e.canonicalPath]??null:null}function k(t,r,o=t){let e=l(t),n=R(t);if(!n){if(e.startsWith(".workspai/reports/")&&e.endsWith(".json"))throw new Error(`${o} is a public workspace report without a registered artifact contract`);return}let f=n.schemaVersionField??"schemaVersion",i=r&&typeof r=="object"?r[f]:void 0;if(i!==n.schemaVersion)throw new Error(`${o} schemaVersion is ${String(i)}, expected ${n.schemaVersion}`);a(r,n.contractPath,o);}
2
2
  export{R as a,k as b};
@@ -1,3 +1,3 @@
1
- import {a as a$1,b as b$1}from'./chunk-VYDURWN7.js';import {b as b$2}from'./chunk-AO2ZI42U.js';import {a,e,b}from'./chunk-CCDGHPEJ.js';import {i,h as h$1}from'./chunk-NZ3WZYD5.js';import h from'path';import {existsSync}from'fs';import X from'fs-extra';var Y=[{artifactKind:"bootstrap-compliance",cardId:"bootstrap",fileNames:["bootstrap-compliance.latest.json"]},{artifactKind:"doctor-workspace",cardId:"doctor",fileNames:["doctor-remediation-plan-last-run.json","doctor-last-run.json"]},{artifactKind:"analyze",cardId:"analyze",fileNames:["analyze-last-run.json"]},{artifactKind:"readiness",cardId:"readiness",fileNames:["release-readiness-last-run.json"]},{artifactKind:"pipeline",cardId:"pipeline",fileNames:["pipeline-last-run.json"]},{artifactKind:"workspace-run",cardId:"workspaceRun",fileNames:["workspace-run-last.json"]},{artifactKind:"workspace-verify",cardId:"workspaceVerify",fileNames:["workspace-verify-last-run.json"]}];function g(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function w(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function I(e){return [...new Set(e.map(r=>r.trim()).filter(Boolean))]}function V(e){return (e.notes.includes("Doctor finding status: blocking")?16:0)+(e.transaction?8:0)+(e.operation?4:0)+(e.invocation?2:0)+(e.strategy?.length?1:0)}function ee(e){let r=V(e.incoming)>V(e.existing),o=structuredClone(r?e.incoming:e.existing),i=r?e.existing:e.incoming,t=i.sourceStepId;return o.order=e.existing.order,o.files=I([...o.files,...i.files]),o.notes=I([...o.notes,...i.notes.filter(a=>!a.startsWith("Source Doctor capability:")&&!a.startsWith("Doctor finding status:")),...t?[`Also satisfies Doctor capability: ${t}`]:[]]),o}function te(e,r,o){return o?r:h.relative(e,r).split(h.sep).join("/")}function D(e){return e.includeAbsolutePaths?e.projectPath:b$1({workspacePath:e.workspacePath,projectPath:e.projectPath,projectName:e.projectName}).contractRelativePath}function z(e){let r=h.isAbsolute(e.filePath)?h.resolve(e.filePath):h.resolve(e.projectPath,e.filePath);if(e.includeAbsolutePaths)return r;let o=h.relative(e.projectPath,r);return !o||o===".."||o.startsWith(`..${h.sep}`)||h.isAbsolute(o)?void 0:`${D(e)}/${o.split(h.sep).join("/")}`}function re(e){let r=e?.trim()||"npx workspai bootstrap";if(!/(?:^|\s)--ci(?:\s|$)/.test(r)&&/(?:^|\s)--json(?:\s|$)/.test(r))return r.replace(/(?:^|\s)--json(?:\s|$)/,i=>{let t=i.startsWith(" ")?" ":"",a=i.endsWith(" ")?" ":"";return `${t}--ci --json${a}`}).trim();let o=/(?:^|\s)--ci(?:\s|$)/.test(r)?r:`${r} --ci`;return /(?:^|\s)--json(?:\s|$)/.test(o)?o:`${o} --json`}function q(e,r){return h.basename(e).toLowerCase().replace(/\.cmd$/,"")==="npx"&&r[0]==="workspai"&&!r.includes("--no-install")?["--no-install",...r]:r}function oe(e){return `${JSON.stringify({schemaVersion:h$1.compatibilityMatrix.schemaVersion,generatedAt:e,source:"workspai workspace remediation-plan",runtimes:{},notes:["Minimal enterprise baseline. Add runtime and toolchain entries as governance matures."]},null,2)}
1
+ import {a as a$1,b as b$1}from'./chunk-Y4Z6CEII.js';import {b as b$2}from'./chunk-AO2ZI42U.js';import {a,e,b}from'./chunk-XDPTAV2T.js';import {i,h as h$1}from'./chunk-ZGHJIQXL.js';import h from'path';import {existsSync}from'fs';import X from'fs-extra';var Y=[{artifactKind:"bootstrap-compliance",cardId:"bootstrap",fileNames:["bootstrap-compliance.latest.json"]},{artifactKind:"doctor-workspace",cardId:"doctor",fileNames:["doctor-remediation-plan-last-run.json","doctor-last-run.json"]},{artifactKind:"analyze",cardId:"analyze",fileNames:["analyze-last-run.json"]},{artifactKind:"readiness",cardId:"readiness",fileNames:["release-readiness-last-run.json"]},{artifactKind:"pipeline",cardId:"pipeline",fileNames:["pipeline-last-run.json"]},{artifactKind:"workspace-run",cardId:"workspaceRun",fileNames:["workspace-run-last.json"]},{artifactKind:"workspace-verify",cardId:"workspaceVerify",fileNames:["workspace-verify-last-run.json"]}];function g(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function w(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function I(e){return [...new Set(e.map(r=>r.trim()).filter(Boolean))]}function V(e){return (e.notes.includes("Doctor finding status: blocking")?16:0)+(e.transaction?8:0)+(e.operation?4:0)+(e.invocation?2:0)+(e.strategy?.length?1:0)}function ee(e){let r=V(e.incoming)>V(e.existing),o=structuredClone(r?e.incoming:e.existing),i=r?e.existing:e.incoming,t=i.sourceStepId;return o.order=e.existing.order,o.files=I([...o.files,...i.files]),o.notes=I([...o.notes,...i.notes.filter(a=>!a.startsWith("Source Doctor capability:")&&!a.startsWith("Doctor finding status:")),...t?[`Also satisfies Doctor capability: ${t}`]:[]]),o}function te(e,r,o){return o?r:h.relative(e,r).split(h.sep).join("/")}function D(e){return e.includeAbsolutePaths?e.projectPath:b$1({workspacePath:e.workspacePath,projectPath:e.projectPath,projectName:e.projectName}).contractRelativePath}function z(e){let r=h.isAbsolute(e.filePath)?h.resolve(e.filePath):h.resolve(e.projectPath,e.filePath);if(e.includeAbsolutePaths)return r;let o=h.relative(e.projectPath,r);return !o||o===".."||o.startsWith(`..${h.sep}`)||h.isAbsolute(o)?void 0:`${D(e)}/${o.split(h.sep).join("/")}`}function re(e){let r=e?.trim()||"npx workspai bootstrap";if(!/(?:^|\s)--ci(?:\s|$)/.test(r)&&/(?:^|\s)--json(?:\s|$)/.test(r))return r.replace(/(?:^|\s)--json(?:\s|$)/,i=>{let t=i.startsWith(" ")?" ":"",a=i.endsWith(" ")?" ":"";return `${t}--ci --json${a}`}).trim();let o=/(?:^|\s)--ci(?:\s|$)/.test(r)?r:`${r} --ci`;return /(?:^|\s)--json(?:\s|$)/.test(o)?o:`${o} --json`}function q(e,r){return h.basename(e).toLowerCase().replace(/\.cmd$/,"")==="npx"&&r[0]==="workspai"&&!r.includes("--no-install")?["--no-install",...r]:r}function oe(e){return `${JSON.stringify({schemaVersion:h$1.compatibilityMatrix.schemaVersion,generatedAt:e,source:"workspai workspace remediation-plan",runtimes:{},notes:["Minimal enterprise baseline. Add runtime and toolchain entries as governance matures."]},null,2)}
2
2
  `}function ie(e){return `${JSON.stringify({schema_version:"1.0",enabled:false,strategy:"on-demand",artifacts:[],created_at:e,note:"Minimal enterprise baseline. Set enabled: true and add artifact entries to activate mirroring."},null,2)}
3
3
  `}function ae(e){let r=e.payload,o=w(r.blockers),i=w(r.blockingReasons),t=w(r.failures),a=w(r.reasons),d=w(r.policyViolations),s=g(r.summary),f=w(s?.blockers);if(e.artifactKind==="analyze"){let c=(Array.isArray(r.findings)?r.findings:[]).map(y=>g(y)).filter(y=>!!y).map(y=>String(y.message??y.title??y.id??"").trim()).filter(Boolean);return I([...o,...c,...i])}if(e.artifactKind==="workspace-run"){let b=g(r.stages),c=Object.entries(b??{}).flatMap(([y,m])=>{let n=g(m);return (Array.isArray(n?.projects)?n.projects:[]).map(p=>g(p)).filter(p=>!!p).filter(p=>p.status==="failed"||p.ok===false).map(p=>`${y}: ${String(p.project??p.name??"project")} failed`)});return I([...o,...c,...i])}return I([...o,...i,...t,...a,...d,...f])}function j(e){let r=e.findingId?.trim()||e.sourceStepId?.trim()||e.id,o=e.findingStatus??"blocking",i=e.causalKey?.trim()||[e.cardId,e.projectName??e.scope??"workspace",r].map(t=>String(t).trim().toLowerCase()).join(":");return {id:e.id,artifactKind:e.artifactKind,cardId:e.cardId,title:e.title,order:e.order,phase:e.phase,scope:e.scope??"workspace",...e.projectName?{projectName:e.projectName}:{},...e.projectPath?{projectPath:e.projectPath}:{},...e.sourceStepId?{sourceStepId:e.sourceStepId}:{},findingId:r,findingStatus:o,causalKey:i,...e.dependsOn?{dependsOn:e.dependsOn}:{},...e.strategy?{strategy:structuredClone(e.strategy)}:{},...e.transaction?{transaction:structuredClone(e.transaction)}:{},status:e.status??"ready",mode:e.mode,risk:e.risk,requiresApproval:true,blocker:e.blocker,summary:e.summary,...e.command?{command:e.command}:{},...e.invocation?{invocation:structuredClone(e.invocation)}:{},verifyCommand:e.verifyCommand,cwd:e.cwd??"workspace",files:e.files??[],...e.operation?{operation:e.operation}:{},rollback:e.rollback??(e.operation?{available:true,strategy:"idempotent"}:{available:false,strategy:"none"}),notes:e.notes??[]}}function ne(e){return (Array.isArray(e.report.payload.steps)?e.report.payload.steps:[]).flatMap((o,i)=>{let t=g(o),a=typeof t?.id=="string"?t.id.trim():"",d=typeof t?.projectName=="string"?t.projectName.trim():"",s=typeof t?.projectPath=="string"?t.projectPath.trim():"",f=typeof t?.originalCommand=="string"?t.originalCommand.trim():"";if(!t||!a||!d||!s)return [];let b=g(t.studioStatus),c=b?.state==="ready"||b?.state==="review-required"||b?.state==="blocked"||b?.state==="guidance-only"?b.state:"guidance-only",y=t.risk==="safe"||t.risk==="guarded"||t.risk==="invasive"?t.risk:"guarded",m=g(t.preview),n=D({workspacePath:e.workspacePath,projectPath:s,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}),u=J({capability:{...t,command:f},absoluteProjectPath:s,includeAbsolutePaths:e.includeAbsolutePaths}),p=U({capability:t,absoluteProjectPath:s,includeAbsolutePaths:e.includeAbsolutePaths}),P=M({operation:t.operation,absoluteProjectPath:s}),k=t.findingStatus==="blocking"||t.findingStatus==="advisory"||t.findingStatus==="informational"?t.findingStatus:"unknown",l=typeof t.diagnosisFindingId=="string"&&t.diagnosisFindingId.trim()?t.diagnosisFindingId.trim():typeof t.issueId=="string"&&t.issueId.trim()?t.issueId.trim():a,A=typeof t.causalKey=="string"&&t.causalKey.trim()?t.causalKey.trim():void 0,S=t.executableInCurrentEnvironment===true&&!!u,$=H({strategy:t.strategy,includeAbsolutePaths:e.includeAbsolutePaths}),R=g(t.transaction),x=R?.schemaVersion==="workspai.doctor-dependency-repair-transaction.v1"?structuredClone(R):void 0;return x&&(x.projectPath=n),[j({id:`doctor.${a}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof m?.title=="string"&&m.title.trim()?m.title.trim():`Repair ${d}`,order:e.startOrder+i,phase:typeof t.phase=="string"?t.phase:"doctor-remediation",blocker:typeof m?.summary=="string"&&m.summary.trim()?m.summary.trim():`Doctor remediation is pending for ${d}.`,summary:typeof m?.summary=="string"&&m.summary.trim()?m.summary.trim():`Execute the CLI-authored Doctor step for ${d}.`,mode:S?"run-command":"manual-guidance",risk:y,status:c,...S&&u?{command:u}:{},...S&&p?{invocation:p}:{},...P?{operation:P}:{},verifyCommand:typeof t.verifyCommand=="string"&&t.verifyCommand.trim()?t.verifyCommand.trim():"npx workspai doctor project --json",files:w(t.files).map(v=>z({workspacePath:e.workspacePath,projectPath:s,projectName:d,filePath:v,includeAbsolutePaths:e.includeAbsolutePaths})).filter(v=>!!v),notes:[`Source Doctor step: ${a}`,`Doctor finding id: ${l}`,`Doctor finding status: ${k}`,...typeof b?.reason=="string"?[b.reason]:[]],scope:"project",projectName:d,projectPath:n,sourceStepId:a,findingId:l,findingStatus:k,causalKey:A,dependsOn:w(t.dependsOn).map(v=>`doctor.${v}`),strategy:$,transaction:x,cwd:"project",...g(t.rollback)?.available===true?{rollback:{available:true,strategy:"manual"}}:{}})]})}function J(e){let r=typeof e.capability.command=="string"?e.capability.command.trim():"";if(e.includeAbsolutePaths&&r)return r;let o=M({operation:e.capability.operation,absoluteProjectPath:e.absoluteProjectPath});if(o)return b$2(o);let i=g(e.capability.invocation),t=typeof i?.executable=="string"?i.executable.trim():"",a=q(t,w(i?.args));if(t)return [t,...a].map(s=>/^[a-zA-Z0-9_./:@=+-]+$/.test(s)?s:JSON.stringify(s)).join(" ");if(!r)return;let d=e.absoluteProjectPath.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return r.replace(new RegExp(`^cd\\s+["']?${d}["']?\\s*&&\\s*`,"i"),"").replaceAll(e.absoluteProjectPath,".")}function U(e){let r=g(e.capability.invocation),o=typeof r?.executable=="string"?r.executable.trim():"",i=w(r?.args);if(!(!o||i.length!==(Array.isArray(r?.args)?r.args.length:0)))return {cwd:e.includeAbsolutePaths?e.absoluteProjectPath:".",executable:o,args:q(o,i)}}function M(e){let r=g(e.operation);if(!r||typeof r.type!="string")return;let o=structuredClone(r);for(let i of ["path","sourcePath"]){let t=o[i];if(typeof t!="string")continue;let a=h.isAbsolute(t)?h.relative(e.absoluteProjectPath,t):t;if(!a||a===".."||a.startsWith(`..${h.sep}`)||h.isAbsolute(a))return;o[i]=a.split(h.sep).join("/");}return o}function H(e){if(!Array.isArray(e.strategy))return;let r=structuredClone(e.strategy);if(!e.includeAbsolutePaths)for(let o of r)o.invocation&&(o.invocation.cwd=".");return r}function se(e){let r=Array.isArray(e.report.payload.projects)?e.report.payload.projects:e.report.payload.project?[e.report.payload.project]:[],o=new Set,i=[];for(let t of r){let a=g(t);if(!a)continue;let d=typeof a.name=="string"?a.name.trim():"",s=typeof a.path=="string"?a.path.trim():"";if(!d||!s)continue;let f=Array.isArray(a.repairCapabilities)?a.repairCapabilities:Array.isArray(a.probes)?a.probes.map(m=>g(m)?.repairCapability).filter(m=>m!==void 0):[],b=new Map,c=new Map,y=g(a.diagnosis);for(let m of Array.isArray(y?.findings)?y.findings:[]){let n=g(m),u=g(n?.repair),p=typeof u?.capabilityId=="string"?u.capabilityId.trim():"",P=typeof n?.id=="string"?n.id.trim():"",k=typeof n?.causalKey=="string"?n.causalKey.trim():"",l=n?.status==="blocking"||n?.status==="advisory"||n?.status==="informational"||n?.status==="unknown"?n.status:"unknown";p&&P&&k&&c.set(p,{findingId:P,causalKey:k,findingStatus:l});}for(let m of Array.isArray(a.probes)?a.probes:[]){let n=g(m),u=g(n?.repairCapability),p=typeof u?.id=="string"?u.id.trim():"";p&&b.set(p,n?.status==="fail"?"blocking":"advisory");}for(let m of f){let n=g(m),u=typeof n?.id=="string"?n.id.trim():"";if(!n||!u)continue;let p=`${d}:${u}`;if(o.has(p))continue;o.add(p);let P=n.risk==="safe"||n.risk==="guarded"||n.risk==="invasive"?n.risk:"guarded",k=J({capability:n,absoluteProjectPath:s,includeAbsolutePaths:e.includeAbsolutePaths}),l=U({capability:n,absoluteProjectPath:s,includeAbsolutePaths:e.includeAbsolutePaths}),A=M({operation:n.operation,absoluteProjectPath:s}),S=n.status==="available"&&!!k,$=g(n.transaction),R=$?.schemaVersion==="workspai.doctor-dependency-repair-transaction.v1"?structuredClone($):void 0,x=c.get(u),v=x?.findingStatus??b.get(u)??(R?"blocking":"advisory");R&&(R.projectPath=D({workspacePath:e.workspacePath,projectPath:s,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}));let Z=H({strategy:n.strategy,includeAbsolutePaths:e.includeAbsolutePaths}),G=w(n.files).map(C=>z({workspacePath:e.workspacePath,projectPath:s,projectName:d,filePath:C,includeAbsolutePaths:e.includeAbsolutePaths})).filter(C=>!!C),E=j({id:`doctor.${d}.${u}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof n.title=="string"&&n.title.trim()?n.title.trim():`Repair ${d}`,order:e.startOrder+i.length,phase:R?"dependency-remediation":"doctor-remediation",blocker:typeof n.reason=="string"&&n.reason.trim()?n.reason.trim():`Doctor remediation is pending for ${d}.`,summary:typeof n.reason=="string"&&n.reason.trim()?n.reason.trim():`Execute the Doctor-authored repair capability for ${d}.`,mode:S?n.canEditFiles===true?"edit-file":"run-command":"manual-guidance",risk:P,status:S?"ready":n.status==="manual"?"guidance-only":"blocked",...k?{command:k}:{},...l?{invocation:l}:{},verifyCommand:typeof n.verifyCommand=="string"&&n.verifyCommand.trim()?n.verifyCommand.trim():"npx workspai doctor project --json",files:G,notes:[`Source Doctor capability: ${u}`,`Doctor finding status: ${v}`,...w(n.limitations)],scope:"project",projectName:d,projectPath:D({workspacePath:e.workspacePath,projectPath:s,projectName:d,includeAbsolutePaths:e.includeAbsolutePaths}),sourceStepId:u,findingId:x?.findingId??(typeof n.issueId=="string"&&n.issueId.trim()?n.issueId.trim():u),findingStatus:v,causalKey:x?.causalKey,strategy:Z,transaction:R,cwd:"project",...A?{operation:A,rollback:{available:true,strategy:"manual"}}:{}}),O=k?i.findIndex(C=>C.projectName===d&&C.command===k&&C.cwd==="project"):-1;if(O>=0){i[O]=ee({existing:i[O],incoming:E});continue}i.push(E);}}return i}function ce(e){let r=[],o=re("npx workspai bootstrap --json");for(let i$1 of e.blockers)i$1.includes("profile.enterprise.ci")&&r.push(j({id:"bootstrap.enterprise-ci",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Run bootstrap in deterministic CI mode",order:10,phase:"bootstrap-preflight",blocker:i$1,summary:"Enterprise bootstrap compliance requires --ci for deterministic execution.",mode:"run-command",risk:"safe",command:o,verifyCommand:o})),i$1.includes("profile.enterprise.compatibility-matrix")&&r.push(j({id:"bootstrap.compatibility-matrix",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise compatibility matrix baseline",order:20,phase:"bootstrap-config",blocker:i$1,summary:"Create the missing compatibility matrix baseline without overwriting user data.",mode:"edit-file",risk:"safe",verifyCommand:o,files:[i.compatibilityMatrix],operation:{type:"file-create",path:i.compatibilityMatrix,content:oe(e.generatedAt),overwrite:false}})),i$1.includes("profile.enterprise.mirror-config")&&r.push(j({id:"bootstrap.mirror-config",artifactKind:"bootstrap-compliance",cardId:"bootstrap",title:"Create enterprise mirror config baseline",order:30,phase:"bootstrap-config",blocker:i$1,summary:"Create the missing mirror configuration baseline without enabling mirroring.",mode:"edit-file",risk:"safe",verifyCommand:o,files:[".workspai/mirror-config.json"],operation:{type:"file-create",path:".workspai/mirror-config.json",content:ie(e.generatedAt),overwrite:false}}));return r}function de(e){let r=Array.isArray(e.report.payload.steps)?e.report.payload.steps:[],o=[],i=new Map;for(let t of r){let a=g(t),d=g(a?.command),s=typeof a?.id=="string"?a.id.trim():"",f=typeof a?.project=="string"?a.project.trim():"",b=typeof a?.status=="string"?a.status:"",c=typeof d?.display=="string"?d.display.trim():"",y=a?.required===true;if(!s.startsWith("project.")||!f||!y||b!=="fail"&&b!=="missing"||!/^npx\s+workspai\s+workspace\s+run\s+/i.test(c))continue;let m=s.split(".").at(-1)??"stage",n=`workspaceVerify.${s}`,u=i.get(f),p=/(?:^|\s)--no-gates(?:\s|$)/.test(c)?c:`${c} --no-gates`;o.push(j({id:n,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:typeof a.label=="string"&&a.label.trim()?a.label.trim():`Run ${m} for ${f}`,order:e.startOrder+o.length,phase:"fleet-run",blocker:typeof a.message=="string"&&a.message.trim()?a.message.trim():`${m} evidence is not current for ${f}.`,summary:`Produce fresh ${m} evidence for ${f} without re-entering the blocked aggregate gates.`,mode:"run-command",risk:m==="start"?"guarded":"safe",status:"ready",command:p,verifyCommand:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",scope:"project",projectName:f,projectPath:f,sourceStepId:s,...u?{dependsOn:[u]}:{},cwd:"workspace",notes:[`Source Workspace Verify step: ${s}`,"Aggregate verification must run only after this project evidence producer completes."]})),i.set(f,n);}return o}function le(e){let r=I(e.blockers.flatMap(i=>{let t=i.match(/(?:project runtimes?|workspace)\s*\(([^)]+)\)\s+(?:is|are) not pinned/i);return t?.[1]?t[1].split(",").map(a=>a.trim().toLowerCase()).filter(a=>/^(python|node|go|java|dotnet|rust|php)$/.test(a)):[]})),o=[];for(let i of r){let t=`readiness.toolchain.${i}.setup`,a=e.blockers.find(d=>d.toLowerCase().includes(`(${i})`))??`The ${i} runtime is not pinned in the canonical workspace toolchain.`;o.push(j({id:t,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Pin ${i} in the workspace toolchain`,order:e.startOrder+o.length,phase:"toolchain-reconciliation",blocker:a,summary:`Detect and persist the current ${i} runtime in the canonical workspace toolchain lock.`,mode:"run-command",risk:"safe",command:`npx workspai setup ${i} --json`,verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",notes:["Run from the workspace root so the canonical toolchain.lock is updated."]})),o.push(j({id:`readiness.toolchain.${i}.bootstrap`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:`Reconcile the ${i} workspace foundation`,order:e.startOrder+o.length,phase:"toolchain-reconciliation",blocker:`The ${i} runtime pin must be reconciled with the workspace foundation.`,summary:"Refresh the workspace foundation after the runtime pin is written.",mode:"run-command",risk:"guarded",command:"npx workspai bootstrap --ci --json",verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",dependsOn:[t]}));}return o}function pe(e){if(e.report.artifactKind==="readiness"&&/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(e.blocker))return j({id:`${e.report.cardId}.doctor-owner.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:"Resolve dependency vulnerability through Doctor",order:e.order,phase:"dependency-remediation",blocker:e.blocker,summary:"Release Readiness is the aggregate gate; use the project-scoped Doctor remediation capability that owns this dependency failure.",mode:"verify-before-fix",risk:"guarded",status:"review-required",command:"npx workspai doctor workspace --plan --json",verifyCommand:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",notes:["Read doctor-remediation-plan-last-run.json and execute the matching surface-security-hygiene capability before rerunning Readiness.","Do not treat a Readiness refresh as remediation for a source dependency vulnerability."]});let o={analyze:{title:"Refresh analyze evidence",phase:"analysis",command:"npx workspai analyze --strict --json",verify:"npx workspai analyze --strict --json"},readiness:{title:"Refresh release readiness",phase:"release-readiness",command:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json",verify:e.ciMode?"npx workspai readiness --strict --json":"npx workspai readiness --json"},pipeline:{title:"Rerun governance pipeline",phase:"governance-pipeline",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"},"workspace-run":{title:"Rerun failed workspace stage",phase:"fleet-run",command:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json",verify:e.ciMode?"npx workspai workspace run test --strict --json":"npx workspai workspace run test --json"},"workspace-verify":{title:"Refresh workspace verify gate",phase:"verification",command:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json",verify:e.ciMode?"npx workspai workspace verify --strict --json":"npx workspai workspace verify --json"},"doctor-workspace":{title:"Use Doctor remediation plan",phase:"doctor-remediation",command:"npx workspai doctor workspace --plan --json",verify:"npx workspai doctor workspace --json"}}[e.report.artifactKind]??{title:"Refresh artifact evidence",phase:"evidence-refresh",command:"npx workspai pipeline --json --strict",verify:"npx workspai pipeline --json --strict"};return j({id:`${e.report.cardId}.refresh.${e.order}`,artifactKind:e.report.artifactKind,cardId:e.report.cardId,title:o.title,order:e.order,phase:o.phase,blocker:e.blocker,summary:"No deterministic file operation is available for this artifact yet; refresh the evidence and continue with the card-specific plan.",mode:e.report.artifactKind==="doctor-workspace"?"verify-before-fix":"run-command",risk:"guarded",status:e.report.artifactKind==="doctor-workspace"?"review-required":"ready",command:o.command,verifyCommand:o.verify,notes:e.report.artifactKind==="doctor-workspace"?["Read doctor-remediation-plan-last-run.json for ordered file-level steps."]:[]})}async function fe(e){let r=[a(e,".workspai/reports"),b(e,".workspai/reports")],o=[],i=new Set;for(let t of Y)for(let a of t.fileNames){let d=(await Promise.all(r.map(s=>h.join(s,a)))).find(s=>existsSync(s));if(!(!d||i.has(`${t.artifactKind}:${a}`))){i.add(`${t.artifactKind}:${a}`);try{let s=await X.readJSON(d),f=g(s);if(!f)continue;o.push({artifactKind:t.artifactKind,cardId:t.cardId,fileName:a,absolutePath:d,payload:f});break}catch{o.push({artifactKind:t.artifactKind,cardId:t.cardId,fileName:a,absolutePath:d,payload:{blockers:[`${t.artifactKind}: report exists but could not be parsed.`]}});break}}}return o}async function Pe(e){let r=h.resolve(e.workspacePath),o=e.includeAbsolutePaths===true,i=e.ciMode===true,t=new Date().toISOString(),a$2=a(r,".workspai/reports"),d=await fe(r),s=[],f=1;for(let c of d){if(c.artifactKind==="doctor-workspace"){let l=Array.isArray(c.payload.steps)?ne({report:c,workspacePath:r,includeAbsolutePaths:o,startOrder:f}):se({report:c,workspacePath:r,includeAbsolutePaths:o,startOrder:f});s.push(...l),f+=l.length;continue}let y=ae(c);if(y.length===0)continue;if(c.artifactKind==="bootstrap-compliance"){s.push(...ce({blockers:y,generatedAt:t})),f=s.length+1;continue}if(c.artifactKind==="workspace-verify"){let l=de({report:c,startOrder:f,ciMode:i});if(l.length>0){s.push(...l),f+=l.length;continue}}if(c.artifactKind==="readiness"){let l=le({report:c,blockers:y,startOrder:f,ciMode:i});if(l.length>0){s.push(...l),f+=l.length;continue}}let m=s.some(l=>l.transaction?.kind==="dependency-security"),n=c.artifactKind==="readiness"&&y.some(l=>/dependenc(?:y|ies).*vulnerabil|vulnerabil.*dependenc(?:y|ies)|security audit/i.test(l));if(m&&n)continue;let u=y[0],p=pe({report:c,blocker:u,order:f,ciMode:i}),k={readiness:new Set(["bootstrap","doctor"]),pipeline:new Set(["bootstrap","doctor","analyze","readiness"]),workspaceVerify:new Set(["bootstrap","doctor","readiness","workspaceRun"])}[c.cardId];if(c.cardId==="pipeline"){let l=["doctor","analyze","readiness"].find(A=>u.toLowerCase().includes(A));l&&(k=new Set([l]));}if(k){let l=s.filter(A=>k.has(A.cardId)&&A.risk!=="invasive"&&A.status!=="blocked"&&A.status!=="guidance-only").map(A=>A.id);l.length>0&&(p.dependsOn=I([...p.dependsOn??[],...l]),p.notes.push("This aggregate gate must run after its contract-owned upstream remediation actions."));}y.length>1&&p.notes.push(...y.slice(1,8).map(l=>`Related blocker: ${l}`)),s.push(p),f+=1;}let b={safe:s.filter(c=>c.risk==="safe").length,guarded:s.filter(c=>c.risk==="guarded").length,invasive:s.filter(c=>c.risk==="invasive").length};return {schemaVersion:a$1,generatedAt:t,workspace:{name:h.basename(r),...o?{path:r}:{}},source:{command:"workspace remediation-plan",reportsDir:te(r,a$2,o),includeAbsolutePaths:o,ciMode:i},summary:{artifactsScanned:d.length,cardsCovered:I(s.map(c=>c.cardId)).length,totalActions:s.length,executableActions:s.filter(c=>c.status==="ready").length,risk:b},actions:s}}async function Re(e$1,r){return e(r,i.artifactRemediationPlan,e$1)}export{Pe as a,Re as b};
@@ -0,0 +1,2 @@
1
+ import {b as b$1}from'./chunk-3OGPTLI2.js';import {b}from'./chunk-PSYQ6IJA.js';import {q,f as f$1,g}from'./chunk-TP7VKEUF.js';import {d}from'./chunk-EHCKITR4.js';import {e as e$1,d as d$1}from'./chunk-XDPTAV2T.js';import {f,e}from'./chunk-ZGHJIQXL.js';import E from'path';import A from'fs-extra';var re=f.agentContext,se=e.agentContext;function ne(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="gemini"||t==="qwen"||t==="kimi"||t==="grok"||t==="copilot"||t==="windsurf"||t==="amazon-q"||t==="orca"?t:"generic"}function G(e){return `npx --yes --package workspai workspai ${e}`.trim()}function x(e){return `npx workspai ${e}`.trim()}async function C(e,t,i){let s=E.join(e,t);if(!await A.pathExists(s))return null;try{let n=await A.readJson(s);return typeof n!="object"||n===null||!("schemaVersion"in n)||n.schemaVersion!==i?null:n}catch{return null}}function m(e$1){return {id:e$1.id,scope:e$1.scope,display:x(e$1.args),execute:G(e$1.args),description:e$1.description,...e$1.project?{project:e$1.project}:{},freshness:f$1({id:`command.${e$1.id}`,label:`${e$1.id} command`,scope:"command",value:{display:x(e$1.args),execute:G(e$1.args)},...e$1.project?{project:e$1.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:e$1.generatedAt,now:e$1.now,sourceArtifact:e.model,sourcePath:`safeCommands.${e$1.id}`,reason:"Safe command surfaces are derived from workspace model command capabilities."}}).freshness}}function L(e,t){return `workspace run ${t} --scope project:${e.name}`}function ae(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function oe(e){return [e.name,e.path,E.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function ie(e,t,i){let s={generatedAt:e.generatedAt,now:i},n=[m({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model.",...s}),m({id:"workspace.graph.entities",scope:"workspace",args:"workspace graph entities --json",description:"Query proof-backed workspace entities without loading the full graph.",...s}),m({id:"workspace.graph.evidence",scope:"workspace",args:"workspace graph evidence <entity-or-relation> --json",description:"Resolve portable evidence for a graph entity or relation.",...s}),m({id:"workspace.graph.path",scope:"workspace",args:"workspace graph path <from> <to> --json",description:"Find a shortest proof-carrying path between workspace entities.",...s}),m({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification.",...s}),m({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop.",...s}),m({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges.",...s}),m({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions.",...s})],c=t?[t]:e.projects;for(let a of c)a.commands.fleetStages.includes("test")&&n.push(m({id:`project.${a.name}.test`,scope:"project",project:a.name,args:L(a,"test"),description:`Run tests for ${a.name} through workspace orchestration.`,...s})),a.commands.fleetStages.includes("build")&&n.push(m({id:`project.${a.name}.build`,scope:"project",project:a.name,args:L(a,"build"),description:`Build ${a.name} through workspace orchestration.`,...s}));return n}function ce(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function pe(e,t){if(!t?.startsWith("project:"))return;let i=ae(t);if(i)return e.projects.find(s=>oe(s).includes(i))}function de(e,t,i){let s=[...e.validation?.issues??[]];t?.startsWith("project:")&&!i&&s.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let n=s.filter(a=>a.severity==="error").length,c=s.filter(a=>a.severity==="warning").length;return {status:n>0?"failed":c>0?"warning":"passed",errors:n,warnings:c,issues:s}}async function me(e,t){let i=[],s=[];for(let[n,c]of Object.entries(e.evidence))c&&await d$1(t,c.path)!==null?i.push(`${n}: ${c.path}`):s.push(n);return {available:i.sort(),missing:s.sort()}}function le(e){let t=e.summary.projectCount,i=e.summary.runtimes.length?`${e.summary.runtimes.join(", ")} runtime coverage`:"no runtime coverage",s=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${i}, and ${s}.`}function ge(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),((e.summary.extendedProjects??0)>0||e.summary.observedProjects>0)&&t.push("Some projects use extended or observed support tiers; command coverage may be partial."),t}async function We(e$1){let t=e$1.model??await q({workspacePath:e$1.workspacePath,includeEvidence:e$1.includeEvidence===true,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),i=ne(e$1.agent),s=pe(t,e$1.scope),n=de(t,e$1.scope,s);if(e$1.strict===true&&n.status!=="passed"){let r=n.issues.map(g=>`${g.severity}:${g.code}:${g.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${r}`)}let c=e$1.now??new Date,a=t.facts??[],K=new Set((s?[s]:t.projects).map(r=>r.name)),R=a.filter(r=>r.project?K.has(r.project):true),H=(s?[s]:t.projects).map(r=>{let g=R.filter(p=>p.project===r.name);return {name:r.name,path:r.path,kind:r.kind,category:r.category,runtime:r.runtime,framework:r.frameworkDisplayName,...r.generator?{generator:r.generator}:{},createCapability:r.createCapability,supportTier:r.supportTier,...r.governance?{governance:r.governance}:{},safeCommands:ce(r),importantFiles:r.importantFiles,facts:g}}),S=await me(t,e$1.workspacePath),F=E.join(e$1.workspacePath,e.knowledgeGraph),u=await A.pathExists(F)?await A.readJson(F).catch(()=>null):null,N=false;if(u?.schemaVersion===f.knowledgeGraph)try{b(u,t),N=true;}catch{}let $=le(t),M=ie(t,s,c),b$2=await C(e$1.workspacePath,e.impact,f.impact),l=await C(e$1.workspacePath,e.doctor,f.doctor),v=await C(e$1.workspacePath,e.analyze,f.analyze),k=await C(e$1.workspacePath,e.readiness,f.readiness),h=await C(e$1.workspacePath,e.verify,f.verify),w=await C(e$1.workspacePath,e.explain,f.explain),f$2=await C(e$1.workspacePath,e.diff,f.diff),B=b$2?.summary?{changed:b$2.summary.changed,risk:b$2.summary.risk,affectedProjects:b$2.summary.affectedProjects,blastRadius:b$2.summary.blastRadius,recommendedCommands:b$2.summary.recommendedCommands}:void 0,U=l?.summary?{verdict:l.summary.verdict,totalIssues:l.summary.totalIssues,advisoryFindings:l.summary.advisoryFindings,blockingFindings:l.summary.blockingFindings,unknownFindings:l.summary.unknownFindings,hasSystemErrors:l.summary.hasSystemErrors,topSignals:(()=>{let r=Array.isArray(l.projects)?l.projects:[],g=[];for(let p of r.slice(0,6)){let te=Array.isArray(p.probes)?p.probes:[];for(let y of te.slice(0,10))(y?.status==="fail"||y?.severity==="error")&&g.push({label:y.label,scope:y.scope,issueClass:y.issueClass,status:y.status,severity:y.severity,recommendation:y.recommendation});}return g.slice(0,8)})()}:void 0,J=v?.summary?{score:v.summary.score,verdict:v.summary.verdict,findingCounts:v.summary.findings,topFindings:(Array.isArray(v.findings)?v.findings:[]).filter(p=>p?.severity==="fail"||p?.severity==="warn").slice(0,8).map(p=>({severity:p.severity,title:p.title,target:p.target,remediation:p.remediation}))}:void 0,X=k?{overallStatus:k.overallStatus,blocking:k.blocking,blockingReasons:k.blockingReasons,evidencePath:k.evidencePath,gates:Array.isArray(k.gates)?k.gates.slice(0,6).map(r=>({gate:r.gate,status:r.status,summary:r.summary})):void 0}:void 0,Q=h?.summary?{verdict:h.summary.verdict,exitCode:h.summary.exitCode,stepsFailed:h.summary.stepsFailed,stepsMissing:h.summary.stepsMissing,blockingReasons:h.blockingReasons,missingEvidence:h.missingEvidence}:void 0,Y=w?{summary:w.summary,blockingReasons:w.blockingReasons,releaseVerdict:w.releaseVerdict,evidenceFreshness:w.evidenceFreshness,sections:Array.isArray(w.sections)?w.sections.slice(0,4).map(r=>({id:r.id,title:r.title,body:r.body})):void 0}:void 0,Z=f$2?.summary?{changed:f$2.summary.changed,addedProjects:f$2.summary.addedProjects,removedProjects:f$2.summary.removedProjects,changedProjects:f$2.summary.changedProjects,workspaceChanges:f$2.summary.workspaceChanges,validationChanges:f$2.summary.validationChanges,gitChangedFiles:f$2.summary.gitChangedFiles}:void 0,ee=M.map(r=>f$1({id:`context.command.${r.id}`,label:`${r.id} safe command`,scope:"command",value:{display:r.display,execute:r.execute,scope:r.scope},...r.project?{project:r.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:t.generatedAt,now:c,sourceArtifact:e.agentContext,sourcePath:`safeCommands.${r.id}`,reason:"Context safe commands are derived from workspace model command capabilities."}})),I=[...R,...ee],W=g({facts:I,generatedAt:c.toISOString(),now:c}),j=b$1();return {schemaVersion:re,generatedAt:c.toISOString(),agent:i,workspaceSummary:$,modelRef:e.model,knowledgeGraph:{artifact:e.knowledgeGraph,schemaVersion:f.knowledgeGraph,available:N,...typeof u?.quality?.entityCount=="number"?{entityCount:u.quality.entityCount}:{},...typeof u?.quality?.relationCount=="number"?{relationCount:u.quality.relationCount}:{},...typeof u?.quality?.proofCount=="number"?{proofCount:u.quality.proofCount}:{},queryCommands:[x("workspace graph search <query> --limit 12 --json"),x("workspace graph entities [kind] --json"),x("workspace graph evidence <entity-or-relation> --json"),x("workspace graph path <from> <to> --json")]},intelligenceChain:{schemaVersion:j.schemaVersion,contractPath:j.contractPath,currentStep:"context",canonicalReadOrder:[...j.consumers.agents.canonicalReadOrder]},workspace:{name:t.workspace.name,root:`workspace:${t.workspace.name}`,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e$1.scope??"workspace",...s?{activeProject:s.name}:{}},projects:H,safeCommands:M,facts:I,factFreshness:W,evidence:S,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:n,agentInstructions:[`Read \`${e.agentIndex}\` first, then this context pack and linked evidence reports.`,"Use `workspace graph search <query> --limit 12 --json` for bounded, proof-backed retrieval before loading the full graph.",`Load \`${e.knowledgeGraph}\` only when a complete graph export is explicitly required.`,"Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Treat `facts[].freshness.verifyBeforeUse` as a hard refresh requirement before using that fact in advice, fixes, or release decisions.","Do not carry extracted facts beyond their freshness contract; re-read or regenerate evidence when the contract says stale, unknown, live, or verify-before-use.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx workspai workspace agent-sync --write --refresh-context`."],unsafeAssumptions:[...ge(t),...W.verifyBeforeUseFacts>0?[`${W.verifyBeforeUseFacts} fact(s) require verification before use; do not treat them as durable workspace structure.`]:[]],humanSummary:[$,`Evidence available: ${S.available.length}. Missing evidence groups: ${S.missing.join(", ")||"none"}.`,s?`Active project scope: ${s.name} (${s.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
2
+ `),impactSummary:B,doctorSummary:U,analyzeSummary:J,readinessSummary:X,verifySummary:Q,explainSummary:Y,diffSummary:Z}}async function je(e,t){return e$1(t,se,d(e))}export{re as a,se as b,We as c,je as d};
@@ -0,0 +1,13 @@
1
+ import {a as a$1}from'./chunk-JEI6BTZI.js';import {a}from'./chunk-FX5J6JCK.js';import {c,e,d}from'./chunk-SLFOUSRW.js';import {d as d$1,b}from'./chunk-YYY2WXOH.js';import {g}from'./chunk-BRYJTW6S.js';import {q as q$1,m}from'./chunk-TP7VKEUF.js';import {p,d as d$2}from'./chunk-EHCKITR4.js';import {e as e$1}from'./chunk-XDPTAV2T.js';import {b as b$1}from'./chunk-IKUFNK46.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import j from'path';import W from'fs-extra';function X(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function q(e$1){switch(e$1){case "why":return d;case "trace":return e;default:return c}}async function P(e,n,o){try{if(!await W.pathExists(e))return null;let r=await W.readJson(e);return n?b$1(n,r,e):o&&a$2(r,o,e),r}catch(r){if((n||o)&&await W.pathExists(e))throw r;return null}}function Y(e,n){if(!e)return null;let o=n.trim().toLowerCase();return e.projects.find(r=>r.slug.toLowerCase()===o||r.relativePath.toLowerCase()===o)??null}function Q(e,n,o){let r=o.trim().toLowerCase(),t=(m(e)?.nodes.map(i=>i.id)??e.projects.map(i=>i.name)).find(i=>i.toLowerCase()===r);if(t)return t;let m$1=e.projects.find(i=>[i.name,i.path,j.basename(i.path)].filter(u=>u.trim().length>0).some(u=>u.toLowerCase()===r));if(m$1)return m$1.name;let p=Y(n,o);if(p){let i=e.projects.find(u=>u.path===p.relativePath||u.path.endsWith(`/${p.relativePath}`));if(i)return i.name}return o}function U(e,n){if(!e)return [];let o=n.trim().toLowerCase(),r=new Set;for(let d of e.projects){d.contracts.dependsOn?.some(t=>t.toLowerCase()===o)&&r.add(d.slug);for(let t of d.contracts.consumes??[])for(let m of e.projects)m.contracts.publishes?.includes(t)&&m.slug===o&&r.add(d.slug);}return [...r].sort()}function Z(e,n){if(!e)return [];let o=n.trim().toLowerCase();return e.steps.filter(r=>r.scope==="project"&&r.project?.toLowerCase()===o&&r.command?.display).map(r=>r.command.display).slice(0,8)}function l(e,n,o){return {id:e,title:n,body:o.trim()}}async function ke(e){let n=j.resolve(e.workspacePath),o=(e.now??new Date).toISOString(),r=e.model??await q$1({workspacePath:n,includeEvidence:true}),d=e.contract;if(d===void 0)try{d=(await p({workspacePath:n})).contract;}catch{d=null;}let t=e.verify;t===void 0&&(t=await P(j.join(n,d$1),d$1));let m$1=e.impact;if(m$1===void 0&&(m$1=await P(j.join(n,g),g)),e.target.kind==="release-blocked"){let s=t?.blockingReasons??[],c=(r.summary?.projectCount??r.projects.length)===0,g=[l("verdict",c?"Workspace scaffold posture":"Release verdict",t?c?`Scaffold posture: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Freshness: **${t.freshness.verdict}**. No registered projects yet \u2014 release gates apply after the first project is added.`:`Verdict: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Risk: **${t.impact.risk}**. Freshness: **${t.freshness.verdict}**.`:"No workspace verify report found. Run `npx workspai workspace verify --json --write` first."),l("blockers",c?"Pre-project signals":"Blocking reasons",s.length?s.map(h=>`- ${h}`).join(`
2
+ `):c?"No pre-project signals in the latest verify report.":"No blocking reasons in the latest verify report.")];return t?.resolutionHints?.length&&g.push(l("resolution","Resolution hints",t.resolutionHints.map(h=>`- **${h.blockerId}** (${h.resolutionClass}): ${h.commandRetryHint??h.fixHints[0]?.detail??"See fix hints"}`).join(`
3
+ `))),{schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:t?c?b(s.length,t.summary.verdict):s.length>0||t.summary.verdict==="blocked"?`Release blocked: ${t.summary.verdict} with ${s.length} blocking reason(s).`:t.summary.verdict==="needs-attention"?"Release needs attention: advisory or incomplete verification evidence remains; no blocking reason was reported.":`Release posture: ${t.summary.verdict}; no blocking reason was reported.`:"Release posture unknown \u2014 verify report missing.",sections:g,releaseVerdict:t?.summary.verdict,evidenceFreshness:t?.freshness.verdict,blocking:!!(t&&(t.summary.verdict==="blocked"||s.length>0)),releaseRisk:t?.impact.risk,blockingReasons:s,resolutionHints:t?.resolutionHints}}if(e.target.kind==="blocker"){let s=e.target,f=t?.resolutionHints?.find(g=>g.blockerId===s.blockerId),c=t?.blockingReasons.find(g=>g.includes(s.blockerId))??t?.blockingReasons[0];return {schemaVersion:a,generatedAt:o,workspacePath:n,target:s,summary:f?`Blocker ${s.blockerId}: ${f.resolutionClass}`:`Blocker ${s.blockerId} (no structured hint)`,sections:[l("reason","Blocking signal",c??"No matching blocking reason in verify."),l("hint","Resolution class",f?`${f.resolutionClass}
4
+
5
+ ${f.commandRetryHint??""}
6
+
7
+ ${f.fixHints.map(g=>`- ${g.detail}`).join(`
8
+ `)}`:"Run workspace verify to emit resolutionHints for this blocker.")],blockingReasons:c?[c]:[],resolutionHints:f?[f]:[]}}if(e.target.kind==="trace"){let s=j.isAbsolute(e.target.diffRef)?e.target.diffRef:j.join(n,e.target.diffRef),f=await P(s,void 0,"contracts/workspace-intelligence/workspace-model-diff.v1.json"),c=[...new Set((f?.changes??[]).filter(a=>a.type?.startsWith("project.")).map(a=>{let O=X(a.after),H=X(a.before);return typeof O.name=="string"&&O.name.trim()||typeof H.name=="string"&&H.name.trim()||a.project?.trim()||a.target?.trim()||""}).filter(Boolean))],h=(r.summary?.projectCount??r.projects.length)===0,_=m$1?.transitiveImpact?.map(a=>`${a.project?.name??a.target} (d${a.distance??0}, via ${a.via??"\u2014"})`)??[],y=t?.affectedSubgraph;return {schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:c?.length?`Trace from ${c.length} changed project(s) through blast radius to gate coverage.`:h?"Trace: workspace scaffold baseline \u2014 no project changes in the latest diff.":"Trace: diff baseline present with no project changes.",sections:[l("origin","Change origin",c?.length?c.map(a=>`- ${a}`).join(`
9
+ `):"No changed projects in diff."),l("blast-radius","Transitive impact",_.length?_.map(a=>`- ${a}`).join(`
10
+ `):"No transitive impact report."),l("gate","Subgraph gate",y?`Directly changed: ${y.directlyChanged}; transitive dependents: ${y.transitiveDependents}; covered: ${y.covered}; uncovered: ${y.uncovered}; unverifiable: ${y.unverifiable}.`:"No verify subgraph coverage available.")],releaseRisk:m$1?.summary?.risk??t?.impact.risk,blockingReasons:t?.blockingReasons}}let p$1=e.target.project,i=Q(r,d,p$1),u=m(r),k=u?a$1(u,i):{found:false,centrality:null,directDependents:[],transitiveDependents:[]},w=Y(d,p$1),E=U(d,p$1),x=Z(t,p$1),v=r.projects.find(s=>s.name.toLowerCase()===p$1.toLowerCase()),A=[l("overview","Project overview",v?`${v.name} (${v.frameworkDisplayName}, ${v.runtime}) at \`${v.path}\`.`:`Project **${p$1}** ${k.found?"exists in graph":"not found in workspace model"}.`),l("consumers","Consumers / dependents",[`Direct dependents: ${k.directDependents.join(", ")||"none"}`,`Contract consumers: ${E.join(", ")||"none"}`,`Transitive dependents (blast radius): ${k.transitiveDependents.length}`].join(`
11
+ `)),l("contracts","Critical contracts",w?[`Owns: ${w.contracts?.owns?.join(", ")||"none"}`,`Publishes: ${w.contracts.publishes.join(", ")||"none"}`,`Consumes: ${w.contracts.consumes.join(", ")||"none"}`,`APIs: ${w.contracts.apis.map(s=>s.name).join(", ")||"none"}`].join(`
12
+ `):"No workspace.contract.json entry for this project."),l("verification","Required verification",x.length?x.map(s=>`- ${s}`).join(`
13
+ `):"- `npx workspai workspace verify --json`\n- Project test/build via `workspace run` when configured")];k.centrality&&A.push(l("centrality","Graph centrality",`fanIn ${k.centrality.fanIn}, fanOut ${k.centrality.fanOut}, reach ${k.centrality.reach}, hotspot ${k.centrality.isHotspot?"yes":"no"}.`));let I=p$1.trim().toLowerCase(),T=s=>s.project?.name?.toLowerCase()===I||s.target.toLowerCase()===I,S=m$1?.affectedProjects?.find(T)?.risk??m$1?.transitiveImpact?.find(T)?.risk??t?.impact.risk??"unknown";return {schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:`${p$1}: ${E.length} consumer(s), release risk **${S}**.`,sections:A,releaseRisk:String(S)}}async function he(e,n,o="explain"){let r=q(o);return await e$1(n,r,d$2(e)),r}export{q as a,ke as b,he as c};