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
@@ -0,0 +1,157 @@
1
+ import {g,b,i as i$1,d as d$1,e as e$1,f}from'./chunk-2M62CU3O.js';import {c}from'./chunk-FPDH3N3A.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$2,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {a}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {h,e,i}from'./chunk-ZGHJIQXL.js';import {u,h as h$1,g as g$1}from'./chunk-VQZ5PI5J.js';import be from'crypto';import ne from'fs';import y from'fs/promises';import l from'path';import {execa}from'execa';import X from'fs-extra';async function Q(e,t){let[n,o]=await Promise.all([X.realpath(e).catch(()=>null),X.realpath(t).catch(()=>null)]);if(!n||!o)return null;let s=l.relative(n,o);return !s||l.isAbsolute(s)||s===".."||s.startsWith(`..${l.sep}`)?null:(await X.stat(o).catch(()=>null))?.isFile()?o:null}var Ne=h.projectContextAgent.schemaVersion,ft=["managed","local","off"],se="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",ve="<!-- WORKSPAI:PROJECT-GROUNDING:END -->",ee="<!-- WORKSPAI:GENERATED-PROJECT-SKILL -->",B=".agents/skills/workspai-grounding/SKILL.md";function he(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function A(e){try{return JSON.parse(await y.readFile(e,"utf8"))}catch(t){return null}}function W(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function _(e,t,n){let o=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(o);if(!l.isAbsolute(e)&&!s)return W(o);if(s&&process.platform!=="win32")return null;let a=l.resolve(e),i=l.relative(n,a);if(i&&!i.startsWith("..")&&!l.isAbsolute(i))return W(i);let c=l.relative(t,a);return c&&!c.startsWith("..")&&!l.isAbsolute(c)?`workspace:${W(c)}`:null}function I(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[a,i])=>a.length>0?s.split(a).join(i):s,e)}function Ae(e,t){return he(e?.adoption)?.mode==="linked"?"adopted":he(e?.import)?"imported":t}function xe(e){if(!e.model)return null;let t=W(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||W(n.path)===t)??null}function U(e,t){e[t]=(e[t]??0)+1;}var fe=["project","language","service","api","endpoint","schema","protocol","runtime-unit","lifecycle-stage","database","queue","container","deployment","pipeline","environment","test-suite","owner","decision","document","package","file","module","symbol"],te=48,re=12*1024;function Le(e,t=te,n=re){let o={language:12,api:8,service:8,endpoint:8,schema:8,protocol:8,"runtime-unit":12,"lifecycle-stage":12,file:4,module:4,symbol:4},s=new Map,a={};for(let u of e)U(a,u.kind);for(let u of fe)s.set(u,e.filter(k=>k.kind===u).sort((k,f)=>k.label.localeCompare(f.label)||k.id.localeCompare(f.id)).slice(0,o[u]??6));let i=[],c={},h=0,p=0,d=true;for(;i.length<t&&d;){d=false;for(let u of fe){let k=s.get(u)?.[p];if(!k)continue;let f=Buffer.byteLength(JSON.stringify(k));if(!(h+f>n)&&(i.push(k),h+=f,U(c,u),d=true,i.length>=t))break}p+=1;}let m=Object.fromEntries(Object.entries(a).map(([u,k])=>[u,k-(c[u]??0)]).filter(([,u])=>u>0).sort(([u],[k])=>u.localeCompare(k)));return {entities:i,selectedBytes:h,selectedByKind:c,omittedByKind:m}}function $e(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},languages:{},semantic:{protocolConceptCount:0,protocolImplementationBindings:0,equivalenceBindings:0,generationBindings:0,runtimeUnitCount:0,lifecycleStageCount:0,runtimeCoverage:[]},projection:{mode:"stratified-byte-bounded",maxEntities:te,byteBudget:re,selectedBytes:0,eligibleCount:0,selectedCount:0,omittedCount:0,selectedByKind:{},omittedByKind:{}},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(r=>r.kind==="project"&&(r.id===t||r.label===t||r.projectId===t)),o=new Set(e.entities.filter(r=>r.projectId===t||r.id===n?.id||r.kind==="project"&&r.label===t).map(r=>r.id));n&&o.add(n.id);let s=e.relations.filter(r=>o.has(r.from)||o.has(r.to)),a=new Set(o);for(let r of s)a.add(r.from),a.add(r.to);let i=e.entities.filter(r=>a.has(r.id)),c=new Set,h={},p={},d={},m=new Set(i.filter(r=>r.kind==="language").map(r=>r.attributes.language).filter(r=>typeof r=="string"));for(let r of i){U(h,r.kind);let w=typeof r.attributes.language=="string"?r.attributes.language:void 0;if(w&&r.kind==="language")d[w]={fileCount:typeof r.attributes.fileCount=="number"?r.attributes.fileCount:0,symbolCount:d[w]?.symbolCount??0,generatedFileCount:typeof r.attributes.generatedFileCount=="number"?r.attributes.generatedFileCount:0};else if(w&&(r.kind==="file"||r.kind==="symbol")){let b=d[w]??{fileCount:0,symbolCount:0,generatedFileCount:0};r.kind==="file"&&!m.has(w)?(b.fileCount+=1,r.attributes.generated===true&&(b.generatedFileCount+=1)):r.kind==="symbol"&&(b.symbolCount+=1),d[w]=b;}for(let b of r.proofIds)c.add(b);}for(let r of s){U(p,r.kind);for(let w of r.proofIds)c.add(w);}let u=e.proofs.filter(r=>c.has(r.id)),k=[...new Set(e.entities.filter(r=>a.has(r.id)&&r.projectId&&r.projectId!==t).map(r=>r.projectId))].sort(),f=e.diagnostics.filter(r=>(!r.entityIds||r.entityIds.length===0)&&(!r.relationIds||r.relationIds.length===0)||r.entityIds?.some(w=>a.has(w))||r.relationIds?.some(w=>s.some(b=>b.id===w))).map(r=>({code:r.code,severity:r.severity,message:r.message,...r.recommendation?{recommendation:r.recommendation}:{}})),j=(r,w)=>({project:w,kind:r.kind,source:r.source,confidence:r.confidence,evidence:[...new Set(r.evidence.map(b=>b.file.replace(/\\/g,"/")))].sort()}),P=e.projectTopology.edges.filter(r=>r.from===t).map(r=>j(r,r.to)).sort((r,w)=>`${r.project}:${r.kind}`.localeCompare(`${w.project}:${w.kind}`)),S=e.projectTopology.edges.filter(r=>r.to===t).map(r=>j(r,r.from)).sort((r,w)=>`${r.project}:${r.kind}`.localeCompare(`${w.project}:${w.kind}`)),N=Le(i),T=N.entities,L=i.filter(r=>r.kind==="runtime-unit"),E=new Set(T.map(r=>r.id)),$=[...s].sort((r,w)=>{let b=Number(E.has(r.from)||E.has(r.to));return Number(E.has(w.from)||E.has(w.to))-b||r.id.localeCompare(w.id)}).slice(0,16),D=new Set([...T.flatMap(r=>r.proofIds),...$.flatMap(r=>r.proofIds)]),g=u.filter(r=>D.has(r.id)).sort((r,w)=>r.id.localeCompare(w.id)).slice(0,16);return {entityCount:i.length,relationCount:s.length,proofCount:u.length,entitiesByKind:h,relationsByKind:p,languages:Object.fromEntries(Object.entries(d).sort(([r],[w])=>r.localeCompare(w))),semantic:{protocolConceptCount:h.protocol??0,protocolImplementationBindings:p["implements-protocol"]??0,equivalenceBindings:p["equivalent-to"]??0,generationBindings:(p["generated-from"]??0)+(p["generated-by"]??0),runtimeUnitCount:L.length,lifecycleStageCount:h["lifecycle-stage"]??0,runtimeCoverage:[...new Set(L.map(r=>r.attributes.runtime).filter(r=>typeof r=="string"))].sort()},projection:{mode:"stratified-byte-bounded",maxEntities:te,byteBudget:re,selectedBytes:N.selectedBytes,eligibleCount:i.length,selectedCount:T.length,omittedCount:Math.max(0,i.length-T.length),selectedByKind:Object.fromEntries(Object.entries(N.selectedByKind).sort(([r],[w])=>r.localeCompare(w))),omittedByKind:N.omittedByKind},relatedProjects:k,proofArtifacts:[...new Set(g.map(r=>r.artifact))].sort().slice(0,24),entities:T,relations:$,proofs:g,topology:{status:P.length>0||S.length>0?"proven":e.projectTopology.nodes.some(r=>r.id===t)?"unproven":"unavailable",dependencies:P,dependents:S},diagnostics:f}}function Ee(e,t,n){return Array.isArray(e)?e.map(o=>typeof o=="string"?I(o,t,n):o):typeof e=="string"?I(e,t,n):e}function Ge(e,t,n){return {id:e.id,kind:e.kind,label:I(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([o,s])=>[o,Ee(s,t,n)])),proofIds:[...e.proofIds].sort()}}function We(e,t,n){let o=(...a)=>e.filter(i=>a.includes(i.kind)).map(i=>Ge(i,t,n)).slice(0,4),s=[];for(let a of e){for(let[i,c]of Object.entries(a.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(i)&&(s.push({entityId:a.id,label:I(a.label,t,n),attribute:i,value:Ee(c,t,n)}),s.length>=8))break;if(s.length>=8)break}return {services:o("service"),packages:o("package"),protocols:o("protocol"),runtimeUnits:o("runtime-unit"),lifecycleStages:o("lifecycle-stage"),apis:o("api"),endpoints:o("endpoint"),dataStores:o("database","queue"),deployments:o("container","deployment","environment"),pipelines:o("pipeline"),tests:o("test-suite"),owners:o("owner"),decisions:o("decision"),ports:s}}function Oe(e,t,n){let o=_(e.artifact,t,n);return o?{id:e.id,provider:e.provider,artifact:o,...e.pointer?{pointer:I(e.pointer,t,n)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function Ke(e,t,n){let o=[],s=await A(l.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let d of s.blockers)typeof d=="string"&&(d.startsWith(`${n}:`)||d.includes(`project:${n}`)||d.includes(`project ${n}`))&&o.push({source:"workspace-report-index",severity:"error",message:I(d,e,t)});let a=await A(l.join(e,".workspai","reports","doctor-project-last-run.json")),i=await A(l.join(e,".workspai","reports","doctor-last-run.json")),c=i?.projects?.find(d=>d.name===n),p=[...a?.project&&(a.projectName===n||a.project.name===n)?[{generatedAt:a.generatedAt,project:a.project}]:[],...c?[{generatedAt:i?.generatedAt,project:c}]:[]].sort((d,m)=>{let u=typeof d.generatedAt=="string"&&Date.parse(d.generatedAt)||0;return (typeof m.generatedAt=="string"&&Date.parse(m.generatedAt)||0)-u})[0];if(p)for(let d of c$1({project:p.project}))o.push({source:"doctor-project",severity:d.status==="blocking"?"error":"warning",message:I(d.message,e,t),...d.id?{code:d.id}:{}});return [...new Map(o.map(d=>[`${d.source}:${d.code??""}:${d.message}`,d])).values()].slice(0,32)}function oe(e,t=[]){return typeof e=="string"?/^[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(e)||t.some(n=>n.length>0&&(e.includes(n)||e.includes(n.replace(/\\/g,"/")))):Array.isArray(e)?e.some(n=>oe(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>oe(n,t)):false}function _e(e){return be.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Fe(e$1){let t=l.resolve(e$1.workspacePath),n=l.resolve(e$1.projectPath),o=u(n,"project.json").find(g=>ne.existsSync(g)),s=o?await A(o):null,a$1=await A(l.join(t,".workspai","workspace.contract.json")),i$1=l.resolve(n),c=a$1?.projects?.find(g=>g.externalPath?l.resolve(g.externalPath)===i$1:!g.relativePath||g.relativePath.startsWith("external/")?false:l.resolve(t,g.relativePath)===i$1)??a$1?.projects?.find(g=>g.slug===e$1.projectName||g.slug===l.basename(n)),h=e$1.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??l.basename(n),p=c?.relativePath??(()=>{let g=W(l.relative(t,n));return !g||g.startsWith("..")?`external/${h}`:g})(),d$1=await A(l.join(t,e.model)),m=await A(l.join(t,e.knowledgeGraph)),u$1=d$1?d(d$1):void 0,k=!!(u$1&&m?.source.hash===u$1),f=xe({model:d$1,projectName:h,relativePath:p}),j=$e(k?m:null,h),P=await Ke(t,n,h),S=j.proofs.map(g=>g.freshness),N=m?!k||S.includes("stale")?"stale":S.includes("unknown")?"unknown":"fresh":"missing",T=d$1?d$1.factFreshness?.status??"unknown":"missing",L=[...d$1?[]:[{code:"project.context.model-missing",severity:"warning",message:"The canonical Workspace Model has not been generated yet. Refresh workspace intelligence before relying on project topology."}],...d$1&&!f?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...m?[]:[{code:"project.context.graph-missing",severity:"warning",message:"The Workspace Knowledge Graph has not been generated yet. Run the workspace intelligence loop to build proof-backed relationships."}],...m&&!k?[{code:"project.context.graph-model-mismatch",severity:"warning",message:"The persisted Knowledge Graph does not match the current Workspace Model and was excluded from this project lens."}]:[]],E=Ae(s,e$1.relationship??c?.relationship??"managed"),$={schemaVersion:Ne,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:a$1?.workspace?.name??d$1?.workspace.name??l.basename(t),...a$1?.workspace?.profile||d$1?.workspace.profile?{profile:a$1?.workspace?.profile??d$1?.workspace.profile}:{},relationship:E,contract:`workspace:${i.workspaceContract}`,projectKnowledgeGraph:i.projectKnowledgeGraphReference,model:`workspace:${e.model}`,knowledgeGraph:`workspace:${e.knowledgeGraph}`,index:`workspace:${e.agentIndex}`,context:`workspace:${e.agentContext}`,skillsIndex:`workspace:${e.skillsIndex}`,boundedGraphSearch:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`,access:{localBinding:i.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:h,relativePath:p,...f?.kind?{kind:f.kind}:{},...f?.runtime||c?.runtime?{runtime:f?.runtime??c?.runtime}:{},...f?.runtimeCandidates?.length?{runtimeCandidates:[...f.runtimeCandidates].sort()}:{},...f?.framework||c?.framework?{framework:f?.framework??c?.framework}:{},...f?.kit||c?.kit?{kit:f?.kit??c?.kit}:{},...f?.supportTier?{supportTier:f.supportTier}:{},...f?.governance?{governance:f.governance}:{},commands:{supported:[...f?.commands.supported??[]].sort(),unsupported:[...f?.commands.unsupported??[]].sort(),fleetStages:[...f?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((f?.importantFiles??[]).map(g=>_(g,t,n)).filter(g=>g!==null))].sort()},intelligence:{...d$1?.generatedAt?{modelGeneratedAt:d$1.generatedAt}:{},...m?.generatedAt?{graphGeneratedAt:m.generatedAt}:{},...m?.source.hash?{graphModelHash:m.source.hash}:{},entityCount:j.entityCount,relationCount:j.relationCount,proofCount:j.proofCount,entitiesByKind:j.entitiesByKind,relationsByKind:j.relationsByKind,languages:j.languages,semantic:j.semantic,projection:{...j.projection,continuationCommand:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`},relatedProjects:j.relatedProjects,freshness:{model:T,graph:N,graphMatchesModel:k},topology:{...j.topology,dependencies:j.topology.dependencies.map(g=>({...g,evidence:g.evidence.map(r=>_(r,t,n)).filter(r=>r!==null)})),dependents:j.topology.dependents.map(g=>({...g,evidence:g.evidence.map(r=>_(r,t,n)).filter(r=>r!==null)}))},surfaces:We(j.entities,t,n),diagnostics:[...L,...j.diagnostics].map(g=>({...g,message:I(g.message,t,n),...g.recommendation?{recommendation:I(g.recommendation,t,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",i.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${i.goalPackLastRun}`,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`],projectProofArtifacts:[...new Set(j.proofArtifacts.map(g=>_(g,t,n)).filter(g=>g!==null))],relations:j.relations.map(g=>({id:g.id,from:g.from,to:g.to,kind:g.kind,derivation:g.derivation,trust:g.trust,confidence:g.confidence,proofIds:[...g.proofIds].sort()})),proofs:j.proofs.map(g=>Oe(g,t,n)).filter(g=>g!==null)},blockers:P,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"workspai agent bootstrap --for-agent generic --strict --json",successCondition:"ready"},workspaceLocator:{command:"workspai project workspace status --json",successCondition:"resolved",outputClassification:"machine-local",persistence:"forbidden",disclosure:"forbidden",portableUriScheme:"workspace:"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[b,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",i.projectContextAgent,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`],degradedMode:{allowCompleteArchitectureClaims:false,requireDisclosure:true}},commands:{refresh:"workspai workspace intelligence run --for-agent generic --strict --json",verify:"workspai workspace verify --strict --json",graphSearch:`workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(oe($,[t,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let D={...$,integrity:{algorithm:"sha256",...u$1?{modelHash:u$1}:{},payloadHash:_e($),portable:true,absolutePathsEmitted:false}};return a(D,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),D}function Be(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(s=>`\`${s}\``).join(", "):"No proven cross-project relation is currently available.",n=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
2
+ `):"- No project-scoped graph diagnostic is currently recorded.",o=e.blockers.length>0?e.blockers.slice(0,12).map(s=>`- **${s.severity}${s.code?` \xB7 ${s.code}`:""}:** ${s.message}`).join(`
3
+ `):"- No current project-scoped blocker is recorded.";return `# Workspai project grounding
4
+
5
+ This project is adopted into the **${e.workspace.name}** Workspai workspace.
6
+ That value is the canonical workspace identity, not its filesystem path. Workspai
7
+ commands launched here resolve the machine-local workspace automatically.
8
+
9
+ ## Mandatory first contact
10
+
11
+ Do not begin broad repository discovery, architecture claims, planning, or mutation
12
+ until this sequence is complete:
13
+
14
+ 1. Read \`${b}\` to discover the portable protocol.
15
+ 2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
16
+ 3. Follow the receipt's \`requiredReadOrder\` exactly.
17
+ 4. Read \`.workspai/reports/project-context-agent.json\`.
18
+ 5. If the receipt reports an active Goal, read its immutable Goal Pack and agent
19
+ handoff before choosing or expanding work.
20
+ 6. Read the compact workspace Skills index and load only a matching playbook.
21
+ 7. Query the bounded Workspace Graph with the user's actual task before opening broad
22
+ source, then inspect only returned proof paths and targeted live files.
23
+
24
+ Receipt policy:
25
+
26
+ - \`ready\`: continue with bounded evidence and targeted source inspection.
27
+ - \`degraded\`: disclose the limitation and do not claim complete architecture or verification.
28
+ - \`blocked\`: stop governed claims, execute \`nextActions\`, and rerun bootstrap.
29
+
30
+ ## Workspace location and portable paths
31
+
32
+ - \`${e.workspace.name}\` is an identity, not a directory name to guess.
33
+ - Project-local paths begin with \`.workspai/\`.
34
+ - Canonical workspace paths begin with \`workspace:\`.
35
+ - Resolve the exact local workspace root only when direct file access is necessary by
36
+ running \`workspai project workspace status --json\` from this project.
37
+ - The resolver's absolute paths are machine-local runtime data. Never persist or copy
38
+ them into answers, shared logs, commits, prompts, telemetry, or portable artifacts.
39
+
40
+ ## Authority boundary
41
+
42
+ The Workspace Model owns canonical project identity and its compact \`projectTopology\`.
43
+ The Workspace Knowledge Graph is a separate, proof-backed enrichment containing
44
+ files, symbols, APIs, infrastructure, tests, owners, and decisions. Do not treat
45
+ an unproven topology edge as proof that two projects are independent. Live source owns
46
+ exact implementation. CLI evidence owns Goal, readiness, repair, and verification claims.
47
+ Repository-authored instructions remain authoritative for source changes after this
48
+ entry gate; Workspai preserves rather than replaces them.
49
+
50
+ ## Knowledge Graph routing
51
+
52
+ - Project graph reference: \`${e.workspace.projectKnowledgeGraph}\`. It integrity-binds
53
+ this project to its exact canonical projection without duplicating the full graph.
54
+ - Workspace aggregate: \`${e.workspace.knowledgeGraph}\`. Resolve it through the
55
+ workspace binding only for cross-project or workspace-wide consumption.
56
+ - Default agent path: use the bounded graph-search command below; resolve the canonical
57
+ graph only when the task explicitly requires full graph interchange.
58
+
59
+ ## Project
60
+
61
+ - Name: \`${e.project.name}\`
62
+ - Workspace-relative identity: \`${e.project.relativePath}\`
63
+ - Runtime: \`${e.project.runtime??"unknown"}\`
64
+ - Framework: \`${e.project.framework??"unknown"}\`
65
+ - Relationship: \`${e.workspace.relationship}\`
66
+ - Related projects: ${t}
67
+ - Topology status: \`${e.intelligence.topology.status}\`
68
+ - Model freshness: \`${e.intelligence.freshness.model}\`
69
+ - Knowledge Graph freshness: \`${e.intelligence.freshness.graph}\`
70
+
71
+ ## Current evidence coverage
72
+
73
+ - Project-scoped entities: ${e.intelligence.entityCount}
74
+ - Project-scoped relations: ${e.intelligence.relationCount}
75
+ - Portable proofs: ${e.intelligence.proofCount}
76
+
77
+ ${n}
78
+
79
+ ## Current project blockers
80
+
81
+ ${o}
82
+
83
+ ## Safe commands from this project
84
+
85
+ \`\`\`bash
86
+ ${e.commands.workspaceStatus}
87
+ ${e.commands.doctor}
88
+ ${e.commands.graphSearch}
89
+ ${e.commands.verify}
90
+ \`\`\`
91
+
92
+ The machine-local workspace binding lives only in
93
+ \`.workspai/workspace-link.local.json\`, which is gitignored. Portable grounding files
94
+ never publish its value.
95
+ `}function Me(e){return `# Workspai agent entry gate (mandatory)
96
+
97
+ - Project: \`${e.project.name}\`
98
+ - Workspace identity: \`${e.workspace.name}\` (logical name, not a filesystem path)
99
+ - Entry contract: \`${b}\`
100
+
101
+ Before broad repository discovery, architecture claims, planning, or mutation:
102
+
103
+ 1. Read \`${b}\`.
104
+ 2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
105
+ 3. Follow the receipt's \`requiredReadOrder\` exactly.
106
+ 4. If a Goal is active, read its immutable Goal Pack and handoff before acting.
107
+ 5. Read the compact workspace Skills index and load only a matching playbook.
108
+ 6. Query the bounded Workspace Graph with the user's task, then inspect only returned proofs and targeted live source.
109
+
110
+ Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations and may not claim complete architecture or verification; \`blocked\` must stop governed claims, execute \`nextActions\`, and rerun bootstrap.
111
+
112
+ \`workspace:\` paths belong to the canonical workspace, not this project's \`.workspai\` directory. Resolve their machine-local root at runtime with \`workspai project workspace status --json\`. That output is machine-local: never copy it into answers, shared logs, commits, or portable artifacts.
113
+
114
+ Authority: Workspai evidence owns identity, topology, goals, readiness, and verification. Live source and repository-authored rules own exact implementation and source conventions.`}function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(e,t){return new RegExp(`${ke(e)}[\\s\\S]*?${ke(t)}`,"m")}function Ce(e){let t=e.replace(q(se,ve),"");return d$2(t)?.includes("# Workspai project boundary")&&(t=t.replace(q(a$1,b$1),"")),t.replace(/\n{3,}/g,`
115
+
116
+ `).trim()}function De(e,t){let n=Ce(e),o=`${se}
117
+ ${t.trim()}
118
+ ${ve}`;return n?`${o}
119
+
120
+ ${n}
121
+ `:`${o}
122
+ `}async function x(e,t){await y.mkdir(l.dirname(e),{recursive:true});let n=`${e}.${process.pid}.${be.randomUUID()}.tmp`;try{await y.writeFile(n,t,"utf8");try{await y.rename(n,e);}catch(o){let s=o.code;if(s!=="EEXIST"&&s!=="EPERM")throw o;await X.move(n,e,{overwrite:true});}}finally{await y.rm(n,{force:true}).catch(()=>{});}}async function F(e,t){let n=l.resolve(e),o=await y.realpath(n).catch(()=>n),s=l.resolve(t),a=l.relative(n,s);if(!a||a===".."||a.startsWith(`..${l.sep}`)||l.isAbsolute(a))throw new Error("Project agent output path must remain inside the project.");let i=a.split(l.sep),c=n;for(let[h,p]of i.entries()){c=l.join(c,p);let d=await y.lstat(c).catch(u=>{if(u.code==="ENOENT")return null;throw u});if(!d)return l.join(c,...i.slice(h+1));let m=h===i.length-1;if(d.isSymbolicLink()){if(m)throw new Error(`Project agent output is blocked by authored state: ${a}`);let u=await y.realpath(c),k=l.relative(o,u),f=await y.stat(u);if(k===".."||k.startsWith(`..${l.sep}`)||l.isAbsolute(k)||!f.isDirectory())throw new Error(`Project agent output is blocked by authored state: ${a}`);c=u;continue}if(m?!d.isFile():!d.isDirectory())throw new Error(`Project agent output is blocked by authored state: ${a}`)}return c}async function kt(e$1){let t=l.join(e$1.projectPath,".agents","skills");try{await F(e$1.projectPath,l.join(t,"workspai-grounding","SKILL.md"));}catch{return []}let n=await A(l.join(e$1.workspacePath,e.skillsIndex)),o=new Set([B,...(n?.skills??[]).map(i=>`.agents/skills/${i.skillId}/SKILL.md`)]),s=await y.readdir(t,{withFileTypes:true}).catch(i=>{if(i.code==="ENOENT")return [];throw i});for(let i of s)i.isDirectory()&&i.name.startsWith("workspai-")&&o.add(`.agents/skills/${i.name}/SKILL.md`);let a=[];for(let i of o){let c=l.join(e$1.projectPath,i);a.push(await F(e$1.projectPath,c));}return a}function Je(e,t){let n=t?.skillId??"workspai-grounding",o=t?.title??"Workspai project grounding",s=t?`workspace:${t.path}`:null;return ["---",`name: ${n}`,`description: ${JSON.stringify(`${o} through the Workspai project intelligence contract`)}`,"---","",ee,"",`# ${o}`,"",`This is a portable project entry for \`${e.project.name}\`. It contains no machine-local workspace path.`,"","## Workflow","",`1. Read \`${b}\`.`,"2. Run `workspai agent bootstrap --for-agent generic --strict --json`.","3. Continue only when the receipt permits it and follow its bounded `requiredReadOrder`.",...s?[`4. Resolve and follow the canonical Skill \`${s}\` listed in \`workspace:.workspai/reports/workspace-skills-index.json\`.`,`5. Query the graph with \`workspai workspace graph search <task-query> --scope project:${e.project.name} --limit 12 --json\` before broad source inspection.`]:["4. Load only the matching canonical Skill from `workspace:.workspai/reports/workspace-skills-index.json`.",`5. Query the graph with \`workspai workspace graph search <task-query> --scope project:${e.project.name} --limit 12 --json\` before broad source inspection.`],"","Repository-authored instructions and live source remain authoritative for exact implementation.",""].join(`
123
+ `)}async function we(e$1){let t=l.join(e$1.projectPath,".agents","skills"),n=await A(l.join(e$1.workspacePath,e.skillsIndex)),o=e$1.context?[{relativePath:B,skill:void 0},...(n?.skills??[]).map(p=>({relativePath:`.agents/skills/${p.skillId}/SKILL.md`,skill:p}))]:[],s=new Set(o.map(p=>p.relativePath)),a=[],i=[],c=[];try{await F(e$1.projectPath,l.join(t,"workspai-grounding","SKILL.md"));}catch(p){return {availableFiles:a,writtenFiles:i,authoredCollisions:c,reason:String(p)}}if(e$1.mode==="managed"&&e$1.context)for(let p of o){let d=l.join(e$1.projectPath,p.relativePath),m=await F(e$1.projectPath,d),u=await y.readFile(m,"utf8").catch(f=>{if(f.code==="ENOENT")return "";throw f});if(u&&!u.includes(ee)){a.push(p.relativePath),c.push(p.relativePath);continue}let k=Je(e$1.context,p.skill);k!==u&&await x(m,k),a.push(p.relativePath),i.push(p.relativePath);}let h=await y.readdir(t,{withFileTypes:true}).catch(p=>{if(p.code==="ENOENT")return [];throw p});for(let p of h){if(!p.isDirectory()||!p.name.startsWith("workspai-"))continue;let d=`.agents/skills/${p.name}/SKILL.md`;if(e$1.mode==="managed"&&s.has(d))continue;let m=l.join(e$1.projectPath,d),u=await F(e$1.projectPath,m);(await y.readFile(u,"utf8").catch(()=>"")).includes(ee)&&await y.rm(l.dirname(u),{recursive:true,force:true});}return {availableFiles:a,writtenFiles:i,authoredCollisions:c}}async function Re(e,t){let n;try{n=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,reject:false});}catch{return false}if(n?.exitCode!==0)return false;let o=n.stdout.trim();if(!o)return false;let s,a;try{[s,a]=await Promise.all([y.realpath(l.resolve(o)),y.realpath(e)]);}catch{return false}let i=l.resolve(a,t),c=l.relative(s,i).replace(/\\/g,"/");if(!c||l.isAbsolute(c)||c===".."||c.startsWith("../"))return false;let h;try{h=await execa("git",["cat-file","-e",`HEAD:${c}`],{cwd:s,reject:false});}catch{return false}if(h?.exitCode!==0)return false;let p;try{p=await execa("git",["ls-files","--deleted","--error-unmatch","--",`:(top)${c}`],{cwd:s,reject:false});}catch{return false}return p?.exitCode===0}async function ye(e,t){let n=l.join(e,".gitignore"),o=await y.readFile(n,"utf8").catch(c=>{if(c.code==="ENOENT")return "";throw c}),s=[g$1,h$1,b],a=o.split(/\r?\n/).filter(c=>c.trim()!=="# Workspai local project grounding"&&!s.includes(c.trim()));for(;a.length>0&&a[a.length-1]==="";)a.pop();t==="local"&&(a.length>0&&a.push(""),a.push("# Workspai local project grounding",...s));let i=a.length>0?`${a.join(`
124
+ `)}
125
+ `:"";i!==o&&await x(n,i);}var M=[{host:"claude",relativePath:"CLAUDE.md",importFromAgents:"@AGENTS.md",importFromGrounding:"@.workspai/PROJECT-GROUNDING.md"},{host:"gemini",relativePath:"GEMINI.md",importFromAgents:"@./AGENTS.md",importFromGrounding:"@./.workspai/PROJECT-GROUNDING.md"},{host:"qwen",relativePath:"QWEN.md",importFromAgents:"@AGENTS.md",importFromGrounding:"@.workspai/PROJECT-GROUNDING.md"},{host:"amazon-q",relativePath:".amazonq/rules/workspai-agent-entry.md",importFromAgents:"",importFromGrounding:""}];if(M.length!==g.length||M.some((e,t)=>e.relativePath!==g[t]))throw new Error("Project agent adapter paths must match the portable entry contract.");async function Ue(e,t){let n=t.split("/").slice(0,-1),o=e;for(let s of n){o=l.join(o,s);let a=await y.lstat(o).catch(i=>{if(i.code==="ENOENT")return null;throw i});if(!a)return null;if(a.isSymbolicLink()||!a.isDirectory())return l.relative(e,o).split(l.sep).join("/")}return null}function qe(e){let t=e.agentsAvailable?e.adapter.importFromAgents:e.adapter.importFromGrounding;return t?`${e.importAlreadyPresent?"":`${t}
126
+
127
+ `}# Workspai host binding \xB7 ${e.adapter.host}
128
+
129
+ The imported Workspai entry gate is mandatory. Validate this host with
130
+ \`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`, then follow
131
+ the receipt's \`requiredReadOrder\`, Goal handoff, bounded Graph queries, proof paths,
132
+ status policy, workspace locator privacy policy, and authority boundary. Do not repeat
133
+ the imported instructions or replace repository-authored source rules.`:`# Workspai entry for ${e.adapter.host}
134
+
135
+ Before broad repository discovery, architecture claims, planning, or mutation:
136
+
137
+ 1. Read \`${b}\`.
138
+ 2. Run \`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`.
139
+ 3. Follow \`requiredReadOrder\`, any active Goal handoff, bounded Graph queries, and returned proof paths.
140
+
141
+ Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations; \`blocked\` must execute \`nextActions\` and rerun bootstrap before governed claims.
142
+
143
+ The workspace name is a logical identity, not a path. Resolve \`workspace:\` URIs at runtime with \`workspai project workspace status --json\`; its absolute paths are machine-local and must never be copied into shared output or portable artifacts. Live source owns exact implementation; Workspai evidence owns identity, topology, goals, readiness, and verification. Repository-authored rules remain authoritative for source changes after this entry gate.`}async function je(e){let t=await Ue(e.projectPath,e.adapter.relativePath);if(t)return {reason:`${e.adapter.relativePath} has an unsafe repository-authored parent at ${t}.`};let n=l.join(e.projectPath,e.adapter.relativePath),o=n,s=await y.lstat(n).catch(m=>{if(m.code==="ENOENT")return null;throw m});if(s?.isSymbolicLink()){let m=await Q(e.projectPath,n);if(!m)return {reason:`${e.adapter.relativePath} is a symbolic link without a safe repository-local file target.`};let u=await y.readFile(m,"utf8");if(e.agentsAvailable&&u.includes(se)){let f=`${u.replace(q(d$1,e$1),"").replace(/\n{3,}/g,`
144
+
145
+ `).trimEnd()}
146
+ `;return f!==u&&await x(m,f),{path:e.adapter.relativePath}}if(u.includes(d$1))return {path:e.adapter.relativePath};o=m;}let a=s?.isFile()===true,i=await y.readFile(o,"utf8").catch(m=>{if(m.code==="ENOENT")return "";throw m});if(e.mode==="managed"&&!a&&await Re(e.projectPath,e.adapter.relativePath))return {reason:`${e.adapter.relativePath} has an authored tracked deletion.`};let c=i.replace(q(d$1,e$1),"").replace(/\n{3,}/g,`
147
+
148
+ `).trim(),h=!!(e.agentsAvailable&&e.adapter.importFromAgents&&c.split(/\r?\n/u).some(m=>m.trim()===e.adapter.importFromAgents)),p=e.mode==="managed"?[c,`${d$1}
149
+ ${qe({...e,importAlreadyPresent:h}).trim()}
150
+ ${e$1}`].filter(Boolean).join(`
151
+
152
+ `):c;if(!p)return a&&!s?.isSymbolicLink()&&await y.rm(o,{force:true}),{};let d=`${p.trimEnd()}
153
+ `;return d!==i&&await x(o,d),e.mode==="managed"?{path:e.adapter.relativePath}:{}}function He(e){let t={id:"generic",discovery:"portable-fallback",entryFiles:[g$1],status:"ready",managed:e.mode==="managed"},o=["codex","kimi","grok","copilot","cursor","windsurf"].map(i=>({id:i,discovery:"native",entryFiles:["AGENTS.md",...["codex","kimi","grok"].includes(i)&&e.portableSkillsAvailable?[B]:[]],status:e.agentsAvailable?["codex","kimi","grok"].includes(i)&&!e.portableSkillsAvailable?"blocked":["codex","kimi","grok"].includes(i)&&e.portableGroundingAuthoredCollision?"degraded":"ready":"blocked",managed:e.mode==="managed"&&e.agentsAvailable&&(!["codex","kimi","grok"].includes(i)||e.portableSkillsAvailable&&!e.portableGroundingAuthoredCollision),...e.agentsAvailable?["codex","kimi","grok"].includes(i)&&!e.portableSkillsAvailable?{reason:e.portableSkillsReason??"The provider-neutral project Skill projection could not be generated safely."}:["codex","kimi","grok"].includes(i)&&e.portableGroundingAuthoredCollision?{reason:"An authored Skill occupies the Workspai grounding path; it was preserved and AGENTS.md remains the fallback entry."}:{}:{reason:"AGENTS.md could not be managed without overriding authored repository state."}})),s=M.map(i=>{let c=e.adapters.get(i.host);return {id:i.host,discovery:"adapter",entryFiles:[i.relativePath],status:c?.path?"ready":e.mode==="managed"?"blocked":"degraded",managed:!!c?.path,...c?.path?{}:{reason:c?.reason??"Provider adapter generation is disabled by the project grounding policy."}}}),a=[t,...o,...s];return f.map(i=>a.find(c=>c.id===i))}async function Pe(e,t,n){let o=l.join(e,"AGENTS.md"),s=await y.lstat(o).catch(d=>{if(d.code==="ENOENT")return null;throw d}),a=s?.isSymbolicLink()?await Q(e,o):o;if(!a)return;let i=s?.isFile()===true||s?.isSymbolicLink()===true,c=await y.readFile(a,"utf8").catch(d=>{if(d.code==="ENOENT")return "";throw d});if(t==="managed"&&!n)throw new Error("Managed project grounding requires a project context.");if(t==="managed"&&!i&&await Re(e,"AGENTS.md"))return;let h=t==="managed"&&n?De(c,Me(n)):Ce(c);if(!h){i&&!s?.isSymbolicLink()&&await y.rm(a,{force:true});return}let p=`${h.trimEnd()}
154
+ `;return p!==c&&await x(a,p),t==="managed"?o:void 0}async function ze(e){let t=e.mode??"managed",n=l.resolve(e.workspacePath),o=l.resolve(e.projectPath);if(t==="off"){let P=u(o,"project.json").find(E=>ne.existsSync(E)),S=P?await A(P):null,N=e.projectName??(typeof S?.name=="string"?S.name:void 0)??l.basename(o),T=Ae(S,e.relationship??"managed"),L=await c({workspacePath:n,projectPath:o,projectName:N,relationship:T,now:e.now});return await ye(o,t),await Pe(o,t),await we({workspacePath:n,projectPath:o,mode:t}),await Promise.all(M.map(E=>je({projectPath:o,adapter:E,mode:t,agentsAvailable:false}))),await Promise.all([y.rm(l.join(o,h$1),{force:true}),y.rm(l.join(o,g$1),{force:true}),y.rm(l.join(o,b),{force:true}),y.rm(l.join(o,i.projectKnowledgeGraphReference),{force:true})]),{mode:t,projectPath:o,linkPath:L.linkPath,writtenFiles:[i.projectWorkspaceLink]}}let s=await Fe(e),a=s.workspace.relationship,i$2=await c({workspacePath:n,projectPath:o,projectName:s.project.name,relationship:a,workspaceName:s.workspace.name,relativePath:s.project.relativePath,now:e.now});await ye(o,t);let c$1=await Pe(o,t,s),h=new Map;for(let P of M)h.set(P.host,await je({projectPath:o,adapter:P,mode:t,agentsAvailable:!!c$1}));let p=await we({workspacePath:n,projectPath:o,mode:t,context:s}),d=He({mode:t,agentsAvailable:!!c$1,portableSkillsAvailable:p.availableFiles.includes(B),portableGroundingAuthoredCollision:p.authoredCollisions.includes(B),...p.reason?{portableSkillsReason:p.reason}:{},adapters:h}),m=l.join(o,h$1),u$1=l.join(o,g$1),k=l.join(o,b),f=i$1({context:s,hosts:d});await x(m,`${JSON.stringify(s,null,2)}
155
+ `),await x(u$1,`${Be(s).trimEnd()}
156
+ `),await x(k,`${JSON.stringify(f,null,2)}
157
+ `);let j=[i.projectWorkspaceLink,h$1,g$1,b];c$1&&j.push("AGENTS.md");for(let P of h.values())P.path&&j.push(P.path);return j.push(...p.writtenFiles),{mode:t,projectPath:o,linkPath:i$2.linkPath,groundingPath:u$1,contextPath:m,agentEntryPath:k,agentsPath:c$1,hostCoverage:d,writtenFiles:j}}async function wt(e){let t=l.resolve(e.workspacePath),n=e.mode??"managed",o=await Ve(t),s=[],a=[];for(let i of o.resolved)try{s.push(await ze({workspacePath:t,projectPath:i.projectPath,projectName:i.name,relationship:i.relationship,mode:n,now:e.now}));}catch(c){a.push({name:i.name,reason:c instanceof Error?c.message:String(c)});}return {workspacePath:t,mode:n,projects:s,skipped:[...o.skipped,...a]}}async function Ve(e){let t=l.resolve(e),n=await A(l.join(t,".workspai","workspace.contract.json")),o=[],s=[];for(let a of n?.projects??[]){let i=a.slug??a.relativePath??"unknown-project",c=typeof a.externalPath=="string"?l.resolve(a.externalPath):typeof a.relativePath=="string"&&!a.relativePath.startsWith("external/")?l.resolve(t,a.relativePath):null;if(!c||!ne.existsSync(c)){s.push({name:i,reason:"project path is unavailable on this machine"});continue}o.push({name:i,projectPath:c,relationship:a.relationship??"managed"});}return {resolved:o,skipped:s}}export{Q as a,Ne as b,ft as c,se as d,ve as e,ee as f,B as g,Le as h,Fe as i,kt as j,ze as k,wt as l,Ve as m};
@@ -0,0 +1 @@
1
+ import {b,e,a as a$2}from'./chunk-B4IVVTMQ.js';import {b as b$1,a as a$1}from'./chunk-UJXE4UAX.js';import {a,f}from'./chunk-5TY74LLW.js';import {randomUUID}from'crypto';var o=null;function m(){return o}function P(t){let e$1=t.argv??process.argv,n=I(e$1.slice(2)),r=process.env.WORKSPAI_PARENT_RUN_ID,i={runId:randomUUID(),startedAt:new Date().toISOString(),command:n,cwd:t.cwd??process.cwd(),rapidkitVersion:t.rapidkitVersion,...r?{parentRunId:r}:{},...r?{previousParentRunId:r}:{},finalized:false};return o=i,b(i.runId),process.env.WORKSPAI_PARENT_RUN_ID=i.runId,a({runId:i.runId,command:i.command,cwd:i.cwd,rapidkitVersion:i.rapidkitVersion,parentRunId:i.parentRunId,blueprint:t.activityBlueprint}),b$1(e$1)&&e(c(i,"run.started","info","CLI run started")),i}function R(t,e$1){if(!(!o||o.finalized)){if(o.finalized=true,f(t,e$1),o.previousParentRunId?process.env.WORKSPAI_PARENT_RUN_ID=o.previousParentRunId:delete process.env.WORKSPAI_PARENT_RUN_ID,!b$1()){o=null;return}t===0?e(c(o,"run.completed","info",e$1??"CLI run completed",{exitCode:t})):e(c(o,"run.failed","error",e$1??"CLI run failed",{exitCode:t})),o=null;}}function S(t=process.argv){a$1(t)==="json"&&(process.env.WORKSPAI_LOG_FORMAT="json",process.env.RAPIDKIT_LOG_FORMAT="json");let e=t.slice(0,2),n=I(t.slice(2));n.length!==t.length-2&&(process.argv=[...e,...n]);}function I(t){let e=[];for(let n=0;n<t.length;n+=1){let r=t[n];if(r!=="--log-json"){if(r==="--log-format"){n+=1;continue}r.startsWith("--log-format=")||e.push(r);}}return e}function c(t,e,n,r,i){return {schemaVersion:a$2,runId:t.runId,timestamp:new Date().toISOString(),level:n,event:e,component:"cli",message:r,command:t.command,metadata:{cwd:t.cwd,rapidkitVersion:t.rapidkitVersion,startedAt:t.startedAt,...i}}}var g=false,T=()=>{let t=process.exitCode??0,e=typeof t=="number"?t:Number.parseInt(t,10);R(Number.isFinite(e)?e:1);};function V(t){if(g||!t?.force&&(process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"))return;g=true,process.once("beforeExit",T);let e=process.exit.bind(process);process.exit=(n=>{let r=typeof n=="number"?n:typeof n=="string"?Number.parseInt(n,10):0,i=Number.isFinite(r)?r:1;return R(i),e(n)});}function z(){return m()?.runId}function G(t,e){let{blockers:n,stderrTail:r,runId:i,generatedAt:v,...C}=e,x=v||(typeof t.generatedAt=="string"?t.generatedAt:void 0)||(typeof t.timestamp=="string"?t.timestamp:void 0)||new Date().toISOString();return {...t,...C,generatedAt:x,...n&&n.length>0?{blockers:n}:{},...r&&r.trim()?{stderrTail:r.trim()}:{},...i?{runId:i}:{}}}export{P as a,R as b,S as c,V as d,z as e,G as f};
@@ -1,5 +1,5 @@
1
- import {a}from'./chunk-J7G3YL4O.js';import {d as d$1}from'./chunk-VR6XMUF3.js';import {b as b$1}from'./chunk-UJXE4UAX.js';import {b as b$2}from'./chunk-2FIX2MDC.js';import {spinner,log,note}from'@clack/prompts';import {execa}from'execa';import v from'chalk';import {createRequire}from'module';import {promises}from'fs';import C from'path';import _ from'os';function d(e,t,r){d$1({level:t==="failed"?"error":t==="warn"?"warn":"info",event:"progress",component:e.component,message:r,metadata:{phase:e.phase,status:t,...e.metadata}});}function A(e,t){let r=e;if(b$1())return d(t,"started",e),{start(n){return n&&(r=n),d(t,"started",r),this},succeed(n){d(t,"succeeded",n??r);},fail(n){d(t,"failed",n??r);},warn(n){d(t,"warn",n??r);},stop(n){d(t,"succeeded",n??r);},get text(){return r},set text(n){r=n,d(t,"started",n);}};let i=spinner();return i.start(e),{start(n){return i.start(n??r),n&&(r=n),this},succeed(n){i.stop(n??r);},fail(n){i.stop(n??r,1);},warn(n){i.stop(n??r);},stop(n){i.stop(n??r);},get text(){return r},set text(n){r=n,i.message(n);}}}function B(e,t){return A(e,t)}function E(e,t,r,i="create"){d$1({level:"info",event:"progress",component:i,message:r,metadata:{phase:"step",stepNum:e,total:t,status:"started"}});}function Q(e){d$1({level:e.status==="failed"?"error":e.status==="warn"?"warn":"info",event:"progress",component:"workspace",message:e.message,metadata:{phase:`workspace.${e.action}`,action:e.action,status:e.status,...e.metadata??{}}});}function X(e){d$1({level:e.status==="failed"?"error":"info",event:"progress",component:e.component??"create",message:e.message,metadata:{phase:e.phase??"workspace.install.pypi",status:e.status,installMethod:e.installMethod,...e.attempt!==void 0?{attempt:e.attempt}:{},...e.maxAttempts!==void 0?{maxAttempts:e.maxAttempts}:{}}});}function c(e,t,r){b$1()&&d$1({level:e,event:"log",component:"cli",message:t,metadata:r});}var u={info(e){c("info",e),!b$1()&&log.info(e);},success(e){c("info",e,{outcome:"success"}),!b$1()&&log.success(e);},warn(e){c("warn",e),!b$1()&&log.warn(e);},error(e){c("error",e),!b$1()&&log.error(e);},step(e){c("info",e,{phase:"step"}),!b$1()&&log.step(e);},stepNumbered(e,t,r){let i=`${a.dim(`[${e}/${t}]`)} ${r}`;c("info",r,{phase:"step",stepNum:e,total:t}),!b$1()&&log.step(i);},note(e,t){c("info",e,{kind:"note",title:t}),!b$1()&&note(e,t);},message(e,t=a.brand("\u25C7")){c("info",e),!b$1()&&log.message(e,{symbol:t});},dim(e){b$1()||console.log(a.dim(e));},plain(e){b$1()||console.log(e);},nextSteps(e){b$1()||u.note(e.map(t=>a.white(t)).join(`
2
- `),a.brand("Next steps"));}};var y=class{debugEnabled=false;setDebug(t){this.debugEnabled=t;}isJsonMode(){return b$1()}debug(t,...r){this.debugEnabled&&this.write("debug",t,r);}info(t,...r){this.write("info",t,r);}success(t,...r){this.write("info",t,r,{outcome:"success"},"success");}warn(t,...r){this.write("warn",t,r,void 0,"warn");}error(t,...r){this.write("error",t,r,void 0,"error");}step(t,r,i){if(b$1()){E(t,r,i);return}u.stepNumbered(t,r,i);}write(t,r,i,n,l="info"){let p=i.length>0?{details:i.map(k=>j(k))}:void 0;if(b$1()){d$1({level:t,event:"log",component:"cli",message:r,metadata:{...n,...p}});return}let o=t==="debug"?`[debug] ${r}`:r;switch(l){case "success":u.success(o);break;case "warn":u.warn(o);break;case "error":u.error(o);break;default:t==="debug"?u.dim(o):u.info(o);}}};function j(e){return e instanceof Error?{name:e.name,message:e.message}:e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:String(e)}var b=new y;function R(e){let t=e.startsWith("WORKSPAI_")?e:`WORKSPAI_${e.replace(/^RAPIDKIT_/,"")}`,r=e.startsWith("RAPIDKIT_")?e:`RAPIDKIT_${e.replace(/^WORKSPAI_/,"")}`,i=process.env[t]?.trim();return i||process.env[r]?.trim()||void 0}var T="workspai",W=createRequire(import.meta.url),O=W("../package.json"),g=O?.version??"0.0.0";function I(e){let r=e.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!r)return null;let i=r[4]?r[4].split(".").map(n=>n.match(/^\d+$/)?Number(n):n):[];return {major:Number(r[1]),minor:Number(r[2]),patch:Number(r[3]),prerelease:i}}function V(e,t){let r=I(e),i=I(t);if(!r||!i)return 0;if(r.major!==i.major)return r.major>i.major?1:-1;if(r.minor!==i.minor)return r.minor>i.minor?1:-1;if(r.patch!==i.patch)return r.patch>i.patch?1:-1;if(r.prerelease.length===0&&i.prerelease.length===0)return 0;if(r.prerelease.length===0)return 1;if(i.prerelease.length===0)return -1;let n=Math.max(r.prerelease.length,i.prerelease.length);for(let l=0;l<n;l+=1){let p=r.prerelease[l],o=i.prerelease[l];if(p===void 0)return -1;if(o===void 0)return 1;if(p===o)continue;let k=typeof p=="number",P=typeof o=="number";return k&&P?p>o?1:-1:k?-1:P||String(p)>String(o)?1:-1}return 0}var K=14400*1e3;function $(){let e=R("CACHE_DIR")||(process.env.VITEST_WORKER_ID?C.join(_.homedir(),".workspai","cache",`vitest-${process.env.VITEST_WORKER_ID}`):C.join(_.homedir(),".workspai","cache"));return C.join(e,"update-check.json")}async function L(){try{let e=await promises.readFile($(),"utf-8"),t=JSON.parse(e);return typeof t.latestVersion=="string"&&typeof t.checkedAt=="number"&&t.currentVersion===g&&Date.now()-t.checkedAt<K?t:null}catch{return null}}async function F(e){try{let t=$();await promises.mkdir(C.dirname(t),{recursive:true}),await promises.writeFile(t,JSON.stringify({latestVersion:e,checkedAt:Date.now(),currentVersion:g}),"utf-8");}catch{}}async function Se(){try{b.debug("Checking for updates...");let e=await L();if(e){let i=Math.round((Date.now()-e.checkedAt)/6e4);b.debug(`Update check: cache hit (${i}m old)`),V(e.latestVersion,g)>0&&(console.log(v.yellow(`
1
+ import {a}from'./chunk-J7G3YL4O.js';import {d as d$1}from'./chunk-B4IVVTMQ.js';import {b as b$1}from'./chunk-UJXE4UAX.js';import {b as b$2}from'./chunk-2FIX2MDC.js';import {spinner,log,note}from'@clack/prompts';import {execa}from'execa';import v from'chalk';import {createRequire}from'module';import {promises}from'fs';import C from'path';import _ from'os';function o(e,t,r){d$1({level:t==="failed"?"error":t==="warn"?"warn":"info",event:"progress",component:e.component,message:r,metadata:{phase:e.phase,status:t,...e.metadata}});}function A(e,t){let r=e;if(o(t,"started",e),b$1())return {start(n){return n&&(r=n),o(t,"started",r),this},succeed(n){o(t,"succeeded",n??r);},fail(n){o(t,"failed",n??r);},warn(n){o(t,"warn",n??r);},stop(n){o(t,"succeeded",n??r);},get text(){return r},set text(n){r=n,o(t,"started",n);}};let i=spinner();return i.start(e),{start(n){return i.start(n??r),n&&(r=n),o(t,"started",r),this},succeed(n){i.stop(n??r),o(t,"succeeded",n??r);},fail(n){i.stop(n??r,1),o(t,"failed",n??r);},warn(n){i.stop(n??r),o(t,"warn",n??r);},stop(n){i.stop(n??r),o(t,"succeeded",n??r);},get text(){return r},set text(n){r=n,i.message(n),o(t,"started",n);}}}function B(e,t){return A(e,t)}function E(e,t,r,i="create"){d$1({level:"info",event:"progress",component:i,message:r,metadata:{phase:"step",stepNum:e,total:t,status:"started"}});}function Q(e){d$1({level:e.status==="failed"?"error":e.status==="warn"?"warn":"info",event:"progress",component:"workspace",message:e.message,metadata:{phase:`workspace.${e.action}`,action:e.action,status:e.status,...e.metadata??{}}});}function X(e){d$1({level:e.status==="failed"?"error":"info",event:"progress",component:e.component??"create",message:e.message,metadata:{phase:e.phase??"workspace.install.pypi",status:e.status,installMethod:e.installMethod,...e.attempt!==void 0?{attempt:e.attempt}:{},...e.maxAttempts!==void 0?{maxAttempts:e.maxAttempts}:{}}});}function u(e,t,r){b$1()&&d$1({level:e,event:"log",component:"cli",message:t,metadata:r});}var d={info(e){u("info",e),!b$1()&&log.info(e);},success(e){u("info",e,{outcome:"success"}),!b$1()&&log.success(e);},warn(e){u("warn",e),!b$1()&&log.warn(e);},error(e){u("error",e),!b$1()&&log.error(e);},step(e){u("info",e,{phase:"step"}),!b$1()&&log.step(e);},stepNumbered(e,t,r){let i=`${a.dim(`[${e}/${t}]`)} ${r}`;u("info",r,{phase:"step",stepNum:e,total:t}),!b$1()&&log.step(i);},note(e,t){u("info",e,{kind:"note",title:t}),!b$1()&&note(e,t);},message(e,t=a.brand("\u25C7")){u("info",e),!b$1()&&log.message(e,{symbol:t});},dim(e){b$1()||console.log(a.dim(e));},plain(e){b$1()||console.log(e);},nextSteps(e){b$1()||d.note(e.map(t=>a.white(t)).join(`
2
+ `),a.brand("Next steps"));}};var y=class{debugEnabled=false;setDebug(t){this.debugEnabled=t;}isJsonMode(){return b$1()}debug(t,...r){this.debugEnabled&&this.write("debug",t,r);}info(t,...r){this.write("info",t,r);}success(t,...r){this.write("info",t,r,{outcome:"success"},"success");}warn(t,...r){this.write("warn",t,r,void 0,"warn");}error(t,...r){this.write("error",t,r,void 0,"error");}step(t,r,i){if(b$1()){E(t,r,i);return}d.stepNumbered(t,r,i);}write(t,r,i,n,l="info"){let p=i.length>0?{details:i.map(k=>j(k))}:void 0;if(b$1()){d$1({level:t,event:"log",component:"cli",message:r,metadata:{...n,...p}});return}let a=t==="debug"?`[debug] ${r}`:r;switch(l){case "success":d.success(a);break;case "warn":d.warn(a);break;case "error":d.error(a);break;default:t==="debug"?d.dim(a):d.info(a);}}};function j(e){return e instanceof Error?{name:e.name,message:e.message}:e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:String(e)}var b=new y;function R(e){let t=e.startsWith("WORKSPAI_")?e:`WORKSPAI_${e.replace(/^RAPIDKIT_/,"")}`,r=e.startsWith("RAPIDKIT_")?e:`RAPIDKIT_${e.replace(/^WORKSPAI_/,"")}`,i=process.env[t]?.trim();return i||process.env[r]?.trim()||void 0}var T="workspai",W=createRequire(import.meta.url),O=W("../package.json"),g=O?.version??"0.0.0";function I(e){let r=e.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!r)return null;let i=r[4]?r[4].split(".").map(n=>n.match(/^\d+$/)?Number(n):n):[];return {major:Number(r[1]),minor:Number(r[2]),patch:Number(r[3]),prerelease:i}}function V(e,t){let r=I(e),i=I(t);if(!r||!i)return 0;if(r.major!==i.major)return r.major>i.major?1:-1;if(r.minor!==i.minor)return r.minor>i.minor?1:-1;if(r.patch!==i.patch)return r.patch>i.patch?1:-1;if(r.prerelease.length===0&&i.prerelease.length===0)return 0;if(r.prerelease.length===0)return 1;if(i.prerelease.length===0)return -1;let n=Math.max(r.prerelease.length,i.prerelease.length);for(let l=0;l<n;l+=1){let p=r.prerelease[l],a=i.prerelease[l];if(p===void 0)return -1;if(a===void 0)return 1;if(p===a)continue;let k=typeof p=="number",P=typeof a=="number";return k&&P?p>a?1:-1:k?-1:P||String(p)>String(a)?1:-1}return 0}var K=14400*1e3;function $(){let e=R("CACHE_DIR")||(process.env.VITEST_WORKER_ID?C.join(_.homedir(),".workspai","cache",`vitest-${process.env.VITEST_WORKER_ID}`):C.join(_.homedir(),".workspai","cache"));return C.join(e,"update-check.json")}async function L(){try{let e=await promises.readFile($(),"utf-8"),t=JSON.parse(e);return typeof t.latestVersion=="string"&&typeof t.checkedAt=="number"&&t.currentVersion===g&&Date.now()-t.checkedAt<K?t:null}catch{return null}}async function F(e){try{let t=$();await promises.mkdir(C.dirname(t),{recursive:true}),await promises.writeFile(t,JSON.stringify({latestVersion:e,checkedAt:Date.now(),currentVersion:g}),"utf-8");}catch{}}async function Se(){try{b.debug("Checking for updates...");let e=await L();if(e){let i=Math.round((Date.now()-e.checkedAt)/6e4);b.debug(`Update check: cache hit (${i}m old)`),V(e.latestVersion,g)>0&&(console.log(v.yellow(`
3
3
  \u26A0\uFE0F Update available: ${g} \u2192 ${e.latestVersion}`)),console.log(v.cyan(`Run: npm install -g workspai@latest
4
4
  `)));return}let{stdout:t}=await execa("npm",["view",T,"version"],{timeout:b$2()}),r=t.trim();await F(r),r&&V(r,g)>0?(console.log(v.yellow(`
5
5
  \u26A0\uFE0F Update available: ${g} \u2192 ${r}`)),console.log(v.cyan(`Run: npm install -g workspai@latest