workspai 0.64.0 → 0.66.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 (207) hide show
  1. package/README.md +40 -44
  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 +2 -0
  6. package/contracts/published-contract-catalog.v1.json +10 -0
  7. package/contracts/runtime-command-surface.v1.json +59 -3
  8. package/contracts/workspace-activity-event.v1.json +132 -0
  9. package/contracts/workspace-contract.v1.json +51 -6
  10. package/contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json +17 -0
  11. package/contracts/workspace-intelligence/mcp-design.v1.json +49 -2
  12. package/contracts/workspace-intelligence/project-agent-entry.v1.json +3 -0
  13. package/contracts/workspace-intelligence/project-context-agent.v1.json +78 -7
  14. package/contracts/workspace-intelligence/project-knowledge-graph-reference.v1.json +51 -0
  15. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +108 -3
  16. package/contracts/workspace-intelligence/workspace-model.v1.json +28 -1
  17. package/contracts/workspace-intelligence/workspace-skills-index.v1.json +34 -0
  18. package/contracts/workspace-model-cache.v1.json +4 -0
  19. package/contracts/workspace-repair-capabilities.v1.json +66 -0
  20. package/dist/analyze-UJQWGNM2.js +1 -0
  21. package/dist/{artifact-remediation-plan-XIQNI35L.js → artifact-remediation-plan-M2XBS2IU.js} +1 -1
  22. package/dist/autopilot-release-U6F4M2BQ.js +1 -0
  23. package/dist/capabilities-command-XUKPO25Z.js +1 -0
  24. package/dist/chunk-2LIVMG5C.js +2 -0
  25. package/dist/{chunk-ZGS5NKEO.js → chunk-2PACEMNE.js} +1 -1
  26. package/dist/chunk-334J2KIP.js +7 -0
  27. package/dist/{chunk-6TBTMWNA.js → chunk-3H5ACWWZ.js} +1 -1
  28. package/dist/{chunk-HCFWT42C.js → chunk-3NM3JAZW.js} +1 -1
  29. package/dist/chunk-4XEH3WNV.js +13 -0
  30. package/dist/chunk-5OA33JH2.js +2 -0
  31. package/dist/chunk-5TY74LLW.js +2 -0
  32. package/dist/{chunk-QCKWQFCD.js → chunk-5U4L6VF2.js} +1 -1
  33. package/dist/{chunk-W6FHVXNL.js → chunk-5XGR3LRI.js} +1 -1
  34. package/dist/{chunk-KTN2ARZJ.js → chunk-6JX56VAL.js} +3 -3
  35. package/dist/chunk-6UNATTB7.js +1 -0
  36. package/dist/{chunk-J3X56S7L.js → chunk-727IQFGN.js} +1 -1
  37. package/dist/chunk-7FF5EOIO.js +2 -0
  38. package/dist/chunk-AP4PV6WJ.js +1 -0
  39. package/dist/chunk-AXUA7PFV.js +2 -0
  40. package/dist/chunk-B4IVVTMQ.js +2 -0
  41. package/dist/{chunk-LNXIMF3O.js → chunk-C4S22E6S.js} +1 -1
  42. package/dist/{chunk-PXWKMPPI.js → chunk-D4UHRJAP.js} +1 -1
  43. package/dist/chunk-DUBOKZMA.js +49 -0
  44. package/dist/{chunk-VYDURWN7.js → chunk-ECLMYTWT.js} +1 -1
  45. package/dist/{chunk-VB6I52ZT.js → chunk-EHH4SKVH.js} +50 -50
  46. package/dist/chunk-EP4CUWOO.js +9 -0
  47. package/dist/chunk-FY4X2VOE.js +39 -0
  48. package/dist/chunk-GAYK3WGV.js +2 -0
  49. package/dist/{chunk-YUGKQ44M.js → chunk-H5RJCS5E.js} +1 -1
  50. package/dist/{chunk-5SFCBZOH.js → chunk-H7MRINGP.js} +1 -1
  51. package/dist/chunk-HJLGXFMK.js +1 -0
  52. package/dist/{chunk-VRGEPPUB.js → chunk-HLWDIIWL.js} +1 -1
  53. package/dist/{chunk-KJXMLBSY.js → chunk-IIFFEEMX.js} +1 -1
  54. package/dist/chunk-IVF6NEHS.js +1 -0
  55. package/dist/chunk-JC4XSU7G.js +1 -0
  56. package/dist/chunk-JRP6WP5C.js +681 -0
  57. package/dist/chunk-JZJBA2V2.js +1 -0
  58. package/dist/{chunk-N4QQADXX.js → chunk-L5CCIIF2.js} +1 -1
  59. package/dist/chunk-L5Q2S5GY.js +3 -0
  60. package/dist/chunk-LPCZHKD5.js +1 -0
  61. package/dist/chunk-MZ7U4BIQ.js +157 -0
  62. package/dist/chunk-NMXGSVMD.js +1 -0
  63. package/dist/{chunk-GQSRNUCU.js → chunk-NVND4727.js} +3 -3
  64. package/dist/chunk-O37UBRMX.js +4 -0
  65. package/dist/chunk-OI2VOU6S.js +1 -0
  66. package/dist/chunk-PD7Y6HIM.js +2 -0
  67. package/dist/chunk-PJPS7CNH.js +1 -0
  68. package/dist/chunk-QGAPGZPL.js +97 -0
  69. package/dist/chunk-R2M5OJOK.js +5 -0
  70. package/dist/chunk-SX6A656X.js +1 -0
  71. package/dist/{chunk-X6TNBARH.js → chunk-TABXSDTR.js} +2 -2
  72. package/dist/chunk-TTHO4MFC.js +2 -0
  73. package/dist/chunk-U5ENEDJA.js +7 -0
  74. package/dist/chunk-UOCERSAN.js +1 -0
  75. package/dist/chunk-UPIPSSXY.js +1 -0
  76. package/dist/chunk-UTV4DTNM.js +1 -0
  77. package/dist/chunk-VA5VSOBL.js +2 -0
  78. package/dist/chunk-VQOWB26M.js +12 -0
  79. package/dist/chunk-VQZ5PI5J.js +1 -0
  80. package/dist/chunk-WCJU3CFG.js +1 -0
  81. package/dist/chunk-WTWRSEOW.js +1 -0
  82. package/dist/{chunk-D65FCQIO.js → chunk-XESFJN52.js} +1 -1
  83. package/dist/chunk-XQFWUM2P.js +1 -0
  84. package/dist/chunk-XWKGZRHN.js +1 -0
  85. package/dist/{chunk-WRQWVSBJ.js → chunk-YX5VWPR5.js} +1 -1
  86. package/dist/chunk-ZEEV5J4I.js +1 -0
  87. package/dist/chunk-ZQH2I5RQ.js +1 -0
  88. package/dist/{create-PWJDTKDN.js → create-SOLLXXAB.js} +1 -1
  89. package/dist/{demo-kit-QHIDCSBI.js → demo-kit-5UQH2OXC.js} +1 -1
  90. package/dist/{doctor-CGXY4IDE.js → doctor-NQ5PUCUP.js} +1 -1
  91. package/dist/{dotnet-webapi-clean-AVHPJG7Y.js → dotnet-webapi-clean-YEHYIGOT.js} +1 -1
  92. package/dist/{goal-lifecycle-BRFFTIU2.js → goal-lifecycle-IPNY7KNR.js} +1 -1
  93. package/dist/goal-pack-2WV3EA4Y.js +1 -0
  94. package/dist/{gofiber-standard-47S2GYAO.js → gofiber-standard-C44IIQYH.js} +1 -1
  95. package/dist/{gogin-standard-EWB4XNOI.js → gogin-standard-X7VKACVR.js} +1 -1
  96. package/dist/index.d.ts +8 -2
  97. package/dist/index.js +170 -170
  98. package/dist/live-command-Q6E45N7S.js +18 -0
  99. package/dist/{pipeline-DF4UIHAD.js → pipeline-MIMENSI7.js} +1 -1
  100. package/dist/{project-agent-entry-IWUCV72J.js → project-agent-entry-OWLJ3IHQ.js} +1 -1
  101. package/dist/project-intelligence-lens-I67EO6AE.js +1 -0
  102. package/dist/{project-test-coverage-4S7MEQ6T.js → project-test-coverage-OPDVSFPH.js} +1 -1
  103. package/dist/{pythonRapidkitExec-VAW5XE4Z.js → pythonRapidkitExec-44ORGQ4R.js} +1 -1
  104. package/dist/{rust-axum-M5X4ZC4Z.js → rust-axum-JKZTZDRZ.js} +1 -1
  105. package/dist/{springboot-standard-Y5ADLZMQ.js → springboot-standard-PI4FLTAN.js} +1 -1
  106. package/dist/verified-goal-46JWNCDY.js +1 -0
  107. package/dist/{workspace-35Q2IXAR.js → workspace-KO37XHF6.js} +1 -1
  108. package/dist/{workspace-agent-sync-FFNSW2PD.js → workspace-agent-sync-32FIJQBH.js} +1 -1
  109. package/dist/{workspace-archive-ZBCKJHXS.js → workspace-archive-6R5DRNZW.js} +1 -1
  110. package/dist/{workspace-context-IJ36ZP6G.js → workspace-context-JKRPX775.js} +1 -1
  111. package/dist/workspace-contract-4T3NYNK5.js +1 -0
  112. package/dist/workspace-explain-MOGL4GEA.js +1 -0
  113. package/dist/workspace-explain-contract-W2E6LF4Q.js +1 -0
  114. package/dist/{workspace-feedback-RQ4TGJW6.js → workspace-feedback-6VQ7T4CR.js} +1 -1
  115. package/dist/{workspace-foundation-GMGDUMPR.js → workspace-foundation-GHWO3BZU.js} +1 -1
  116. package/dist/workspace-graph-stream-PTVS47NJ.js +1 -0
  117. package/dist/workspace-graph-token-efficiency-Z5JD5NHI.js +1 -0
  118. package/dist/{workspace-history-SYCDK7FO.js → workspace-history-M2K4M2JY.js} +1 -1
  119. package/dist/{workspace-intelligence-5NO4K5SC.js → workspace-intelligence-PJIPTXL3.js} +1 -1
  120. package/dist/{workspace-intelligence-evaluation-CQDKOYZZ.js → workspace-intelligence-evaluation-GONCRE6O.js} +1 -1
  121. package/dist/{workspace-intelligence-runner-FGEBFVVM.js → workspace-intelligence-runner-M47QR3JM.js} +1 -1
  122. package/dist/{workspace-intelligence-runtime-registry-IW6J53LO.js → workspace-intelligence-runtime-registry-FFGQF4A7.js} +1 -1
  123. package/dist/workspace-knowledge-graph-V2EAYDCL.js +1 -0
  124. package/dist/workspace-knowledge-graph-contract-VANN7RCA.js +1 -0
  125. package/dist/{workspace-knowledge-graph-query-ON45H6Y7.js → workspace-knowledge-graph-query-RASPF7FS.js} +1 -1
  126. package/dist/workspace-knowledge-graph-snapshot-5YIG6EMG.js +1 -0
  127. package/dist/{workspace-marker-7NHMDIRL.js → workspace-marker-XGAWZZDX.js} +1 -1
  128. package/dist/workspace-mcp-serve-YRORNE4P.js +3 -0
  129. package/dist/workspace-model-VSVKLX7M.js +1 -0
  130. package/dist/{workspace-onboarding-VS3YYNGK.js → workspace-onboarding-2VMJZVLZ.js} +1 -1
  131. package/dist/{workspace-python-engine-state-J4QKW55K.js → workspace-python-engine-state-BE4A3BL5.js} +1 -1
  132. package/dist/{workspace-readme-G7TZ3V5T.js → workspace-readme-6X3GLTBM.js} +2 -2
  133. package/dist/{workspace-registry-summary-MIDFG6EC.js → workspace-registry-summary-QVSJKKTX.js} +1 -1
  134. package/dist/workspace-repair-engine-WSKV3Q4V.js +3 -0
  135. package/dist/workspace-run-3BXKTLVL.js +1 -0
  136. package/dist/{workspace-verify-4R7QHUPO.js → workspace-verify-EJCSOBIK.js} +1 -1
  137. package/dist/workspace-watch-JTIFBF4Z.js +1 -0
  138. package/docs/SETUP.md +10 -0
  139. package/docs/agent-entry.md +22 -7
  140. package/docs/ci-workflows.md +1 -1
  141. package/docs/commands-reference.md +43 -7
  142. package/docs/contracts/ARTIFACT_CATALOG.md +63 -44
  143. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +1 -0
  144. package/docs/contracts/NAMING_AND_COEXISTENCE.md +20 -18
  145. package/docs/contracts/README.md +4 -3
  146. package/docs/real-world-qualification.md +19 -3
  147. package/docs/workspace-knowledge-graph.md +131 -27
  148. package/docs/workspace-live-activity.md +199 -0
  149. package/docs/workspace-operations.md +54 -9
  150. package/docs/workspace-repair-engine.md +17 -0
  151. package/package.json +1 -1
  152. package/dist/analyze-NUGNB256.js +0 -1
  153. package/dist/autopilot-release-TWJWSVVF.js +0 -1
  154. package/dist/capabilities-command-LHM3XIS6.js +0 -1
  155. package/dist/chunk-2647BYBC.js +0 -1
  156. package/dist/chunk-27UR373Z.js +0 -1
  157. package/dist/chunk-2VJUAKMS.js +0 -2
  158. package/dist/chunk-3A23KJAQ.js +0 -1
  159. package/dist/chunk-4PUJVYRM.js +0 -1
  160. package/dist/chunk-5B2GAZAC.js +0 -5
  161. package/dist/chunk-6DAQ7PYT.js +0 -13
  162. package/dist/chunk-CCAXADKP.js +0 -49
  163. package/dist/chunk-CCDGHPEJ.js +0 -2
  164. package/dist/chunk-CJHWKXDN.js +0 -1
  165. package/dist/chunk-CT4IODPG.js +0 -2
  166. package/dist/chunk-DK6JNE6K.js +0 -2
  167. package/dist/chunk-DOXNVBX6.js +0 -1
  168. package/dist/chunk-DWB2RRF4.js +0 -1
  169. package/dist/chunk-FQSBOLM7.js +0 -1
  170. package/dist/chunk-ILIBOMYL.js +0 -1
  171. package/dist/chunk-ISOOENLW.js +0 -8
  172. package/dist/chunk-J7RU5WR5.js +0 -2
  173. package/dist/chunk-JQLJBK5N.js +0 -1
  174. package/dist/chunk-KANAJH65.js +0 -681
  175. package/dist/chunk-KV6PS54A.js +0 -8
  176. package/dist/chunk-L22EABIC.js +0 -7
  177. package/dist/chunk-MOSXTVPU.js +0 -1
  178. package/dist/chunk-NHTDPXTW.js +0 -4
  179. package/dist/chunk-NZ3WZYD5.js +0 -1
  180. package/dist/chunk-Q2WF7D5U.js +0 -2
  181. package/dist/chunk-RSG2GJXT.js +0 -2
  182. package/dist/chunk-SFO5GVRT.js +0 -1
  183. package/dist/chunk-T5YRFRJV.js +0 -1
  184. package/dist/chunk-THIOE2PB.js +0 -2
  185. package/dist/chunk-TOYN76K4.js +0 -144
  186. package/dist/chunk-U5WVR74V.js +0 -1
  187. package/dist/chunk-UXEO5QCF.js +0 -33
  188. package/dist/chunk-VR6XMUF3.js +0 -2
  189. package/dist/chunk-WY4DOMEA.js +0 -1
  190. package/dist/chunk-XKDR5BGS.js +0 -6
  191. package/dist/chunk-Y5YAP4F3.js +0 -2
  192. package/dist/chunk-ZH7CXQH3.js +0 -94
  193. package/dist/goal-pack-FG3QDNQH.js +0 -1
  194. package/dist/project-intelligence-lens-PZPPSCUW.js +0 -1
  195. package/dist/verified-goal-BBHZRYYH.js +0 -1
  196. package/dist/workspace-contract-JS4LZZQZ.js +0 -1
  197. package/dist/workspace-explain-TITIT5XN.js +0 -1
  198. package/dist/workspace-explain-contract-V2IVSROX.js +0 -1
  199. package/dist/workspace-graph-stream-7UU2YVHC.js +0 -1
  200. package/dist/workspace-graph-token-efficiency-D7CUT6NX.js +0 -1
  201. package/dist/workspace-knowledge-graph-RSDP2E36.js +0 -1
  202. package/dist/workspace-knowledge-graph-snapshot-3FJHH5IK.js +0 -1
  203. package/dist/workspace-mcp-serve-WUIQ2AE6.js +0 -3
  204. package/dist/workspace-model-OKY4CQ3X.js +0 -1
  205. package/dist/workspace-repair-engine-VUBT77Y7.js +0 -3
  206. package/dist/workspace-run-SSF6Z26G.js +0 -1
  207. package/dist/workspace-watch-IOPSHQS5.js +0 -1
@@ -1,10 +1,10 @@
1
- import {a}from'./chunk-GR6442P7.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {i}from'./chunk-NZ3WZYD5.js';import {j,s,p as p$1,v}from'./chunk-MOSXTVPU.js';import z from'crypto';import Y from'os';import l from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as Q from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import {lookup}from'dns/promises';import T from'net';import p from'fs-extra';import*as ee from'yauzl';import*as te from'yazl';var qe="workspai-workspace-archive-capabilities-v1",q="workspai-workspace-archive-manifest-v1",k="workspai-workspace-archive-operation-result-v1";var K="contracts/workspace-archive-manifest.v1.json",Z="contracts/workspace-archive-operation-result.v1.json",Ke={archiveCompression:{signature:"--archive-compression <mode>",description:"Archive compression: store (default) or deflate",appliesTo:["export"]},maxDownloadSize:{signature:"--max-download-size <size>",description:"Maximum remote archive download size (secure default: 5gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},maxExpandedSize:{signature:"--max-expanded-size <size>",description:"Maximum expanded archive payload size (secure default: 20gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},downloadTimeoutMs:{signature:"--download-timeout-ms <ms>",description:"Remote archive download timeout in milliseconds; 0 disables it",appliesTo:["inspect","verify","doctor","hydrate","import"]},allowPrivateNetwork:{signature:"--allow-private-network",description:"Allow archive downloads from loopback/private networks (unsafe for untrusted input)",appliesTo:["inspect","verify","doctor","hydrate","import"]}};var A=".workspai/archive-manifest.json",R=".rapidkit/archive-manifest.json",de="workspai.workspace.archive",ye=300*1e3,ve=5*1024*1024*1024,we=20*1024*1024*1024,J=2e5,ge=5*1024*1024*1024,ke=1e3,M=5,Ee=64*1024*1024;function Ae(r){let t=r.toLowerCase().split("%")[0];if(T.isIPv4(t)){let e=t.split(".").map(Number);return e[0]===0||e[0]===10||e[0]===127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]>=224}return T.isIPv6(t)?t==="::"||t==="::1"||t.startsWith("fc")||t.startsWith("fd")||/^fe[89ab]/.test(t)||t.startsWith("ff")||t.startsWith("::ffff:127.")||t.startsWith("::ffff:10.")||t.startsWith("::ffff:192.168."):true}async function X(r,t){let e=new URL(r);if(e.protocol!=="https:"&&e.protocol!=="http:")throw new Error(`Workspace archive URL protocol is not supported: ${e.protocol}`);if(e.protocol!=="https:"&&!t)throw new Error("Remote workspace archives require HTTPS unless private-network access is explicitly enabled.");if(e.username||e.password)throw new Error("Workspace archive URL must not contain embedded credentials.");if(t)return e;let i=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(i==="localhost"||i.endsWith(".localhost"))throw new Error("Workspace archive URL resolves to a private or local network address.");let a=T.isIP(i)?[{address:i}]:await lookup(i,{all:true,verbatim:true});if(a.length===0||a.some(({address:s})=>Ae(s)))throw new Error("Workspace archive URL resolves to a private or local network address.");return e}async function Pe(r,t,e){let i=await X(r,e);for(let a=0;a<=M;a+=1){let s=await fetch(i,{signal:t,redirect:"manual",credentials:"omit"});if(![301,302,303,307,308].includes(s.status))return s;let n=s.headers.get("location");if(await s.body?.cancel(),!n)throw new Error("Workspace archive redirect is missing a Location header.");if(a===M)throw new Error(`Workspace archive download exceeded ${M} redirects.`);i=await X(new URL(n,i).href,e);}throw new Error("Workspace archive redirect policy failed.")}var We=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),be=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log","workspace-link.local.json","imported-projects.json","workspace-registry.v1.json"]),Se=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function _(r){return r.replace(/\\/g,"/")}function re(r){return r.trim().replace(/\.workspai-archive\.zip$/i,"").replace(/\.rapidkit-archive\.zip$/i,"").replace(/\.zip$/i,"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,64)||"imported-workspace"}function ie(r){let t=_(r).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let e=t.split("/").filter(Boolean);return e.length>0&&!e.some(i=>i===".."||i===".")}function ae(r){if(!ie(r))throw new Error(`Archive contains an unsafe path: ${r}`)}function Re(r,t){let e=l.relative(t,r);return e===""||!!e&&!e.startsWith("..")&&!l.isAbsolute(e)}function _e(r,t){let e=_(r),i$1=e.split("/").filter(Boolean);if(i$1.some((n,o)=>(n===".workspai"||n===".rapidkit")&&["cache","reports"].includes(i$1[o+1]||""))||i$1.some(n=>We.has(n)||a(n)))return true;let s=i$1[i$1.length-1]||"";return e===i.workspaceContract||e===".rapidkit/workspace.contract.json"||be.has(s)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(s)||!t?.includeEnv&&Se.some(n=>n.test(s))?true:s.endsWith(".pyc")||s.endsWith(".log")}async function Ce(r){for(let t of [l.join(r,".workspai","workspace.contract.json"),l.join(r,".rapidkit","workspace.contract.json")])if(await p.pathExists(t))try{return await p.readJson(t)}catch(e){throw new Error(`Workspace contract could not be inspected safely for archive portability: ${t}: ${e instanceof Error?e.message:String(e)}`)}return null}function xe(r){return (r?.projects??[]).filter(t=>typeof t.externalPath=="string"||typeof t.relativePath=="string"&&t.relativePath.startsWith("external/")).map(t=>({name:t.slug||t.relativePath||"external-project",relationship:["adopted","linked","imported","managed","restored"].includes(String(t.relationship))?t.relationship:"adopted",included:false,requiredAction:"relink"})).sort((t,e)=>t.name.localeCompare(e.name))}function Oe(r){if(r)return {...r,workspace:{...r.workspace},projects:r.projects.filter(t=>typeof t.externalPath!="string"&&!t.relativePath.startsWith("external/")).map(({externalPath:t,...e})=>({...e,modules:[...e.modules],ports:e.ports.map(i=>({...i})),contracts:{owns:[...e.contracts.owns],apis:e.contracts.apis.map(i=>({...i})),publishes:[...e.contracts.publishes],consumes:[...e.contracts.consumes],dependsOn:[...e.contracts.dependsOn],env:[...e.contracts.env]}}))}}async function*se(r,t,e){let i=(await p.readdir(t,{withFileTypes:true})).sort((a,s)=>a.name.localeCompare(s.name));for(let a of i){let s=l.join(t,a.name),n=_(l.relative(r,s));if(!(!n||_e(n,e))){if(a.isDirectory()){yield*se(r,s,e);continue}a.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function ze(r){for(let t of s(r,"workspace.json"))try{let e=await p.readJson(t);if(typeof e.workspace_name=="string"&&e.workspace_name.trim())return e.workspace_name.trim();if(typeof e.name=="string"&&e.name.trim())return e.name.trim()}catch{}return l.basename(l.resolve(r))}async function Ne(r){let t=await p.stat(r.fullPath),e=z.createHash("sha256"),i=0;for await(let s of createReadStream(r.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);i+=n.length,e.update(n);}let a=await p.stat(r.fullPath);if(t.size!==a.size||t.mtimeMs!==a.mtimeMs||i!==a.size)throw new Error(`Workspace file changed while preparing archive: ${r.relativePath}`);return {...r,size:i,mtimeMs:a.mtimeMs,sha256:e.digest("hex")}}async function E(r,t){r.write(t)||await once(r,"drain");}async function ne(r){await new Promise((t,e)=>{r.once("error",e),r.end(t);});}async function*O(r){let t=Q.createInterface({input:createReadStream(r),crlfDelay:1/0});for await(let e of t){let i=e.trim();i&&(yield JSON.parse(i));}}async function Me(r){let t=createWriteStream(r.manifestPath,{flags:"wx"});try{await E(t,`{
1
+ import {a}from'./chunk-GR6442P7.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {i}from'./chunk-6UNATTB7.js';import {k as k$1,t,q as q$1,w}from'./chunk-VQZ5PI5J.js';import z from'crypto';import Y from'os';import l from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as Q from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import {lookup}from'dns/promises';import T from'net';import p from'fs-extra';import*as ee from'yauzl';import*as te from'yazl';var qe="workspai-workspace-archive-capabilities-v1",q="workspai-workspace-archive-manifest-v1",k="workspai-workspace-archive-operation-result-v1";var K="contracts/workspace-archive-manifest.v1.json",Z="contracts/workspace-archive-operation-result.v1.json",Ke={archiveCompression:{signature:"--archive-compression <mode>",description:"Archive compression: store (default) or deflate",appliesTo:["export"]},maxDownloadSize:{signature:"--max-download-size <size>",description:"Maximum remote archive download size (secure default: 5gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},maxExpandedSize:{signature:"--max-expanded-size <size>",description:"Maximum expanded archive payload size (secure default: 20gb)",appliesTo:["inspect","verify","doctor","hydrate","import"]},downloadTimeoutMs:{signature:"--download-timeout-ms <ms>",description:"Remote archive download timeout in milliseconds; 0 disables it",appliesTo:["inspect","verify","doctor","hydrate","import"]},allowPrivateNetwork:{signature:"--allow-private-network",description:"Allow archive downloads from loopback/private networks (unsafe for untrusted input)",appliesTo:["inspect","verify","doctor","hydrate","import"]}};var A=".workspai/archive-manifest.json",R=".rapidkit/archive-manifest.json",de="workspai.workspace.archive",ye=300*1e3,ve=5*1024*1024*1024,we=20*1024*1024*1024,J=2e5,ge=5*1024*1024*1024,ke=1e3,M=5,Ee=64*1024*1024;function Ae(r){let t=r.toLowerCase().split("%")[0];if(T.isIPv4(t)){let e=t.split(".").map(Number);return e[0]===0||e[0]===10||e[0]===127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]>=224}return T.isIPv6(t)?t==="::"||t==="::1"||t.startsWith("fc")||t.startsWith("fd")||/^fe[89ab]/.test(t)||t.startsWith("ff")||t.startsWith("::ffff:127.")||t.startsWith("::ffff:10.")||t.startsWith("::ffff:192.168."):true}async function X(r,t){let e=new URL(r);if(e.protocol!=="https:"&&e.protocol!=="http:")throw new Error(`Workspace archive URL protocol is not supported: ${e.protocol}`);if(e.protocol!=="https:"&&!t)throw new Error("Remote workspace archives require HTTPS unless private-network access is explicitly enabled.");if(e.username||e.password)throw new Error("Workspace archive URL must not contain embedded credentials.");if(t)return e;let i=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(i==="localhost"||i.endsWith(".localhost"))throw new Error("Workspace archive URL resolves to a private or local network address.");let a=T.isIP(i)?[{address:i}]:await lookup(i,{all:true,verbatim:true});if(a.length===0||a.some(({address:s})=>Ae(s)))throw new Error("Workspace archive URL resolves to a private or local network address.");return e}async function Pe(r,t,e){let i=await X(r,e);for(let a=0;a<=M;a+=1){let s=await fetch(i,{signal:t,redirect:"manual",credentials:"omit"});if(![301,302,303,307,308].includes(s.status))return s;let n=s.headers.get("location");if(await s.body?.cancel(),!n)throw new Error("Workspace archive redirect is missing a Location header.");if(a===M)throw new Error(`Workspace archive download exceeded ${M} redirects.`);i=await X(new URL(n,i).href,e);}throw new Error("Workspace archive redirect policy failed.")}var We=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),be=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log","workspace-link.local.json","imported-projects.json","workspace-registry.v1.json"]),Se=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function _(r){return r.replace(/\\/g,"/")}function re(r){return r.trim().replace(/\.workspai-archive\.zip$/i,"").replace(/\.rapidkit-archive\.zip$/i,"").replace(/\.zip$/i,"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,64)||"imported-workspace"}function ie(r){let t=_(r).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let e=t.split("/").filter(Boolean);return e.length>0&&!e.some(i=>i===".."||i===".")}function ae(r){if(!ie(r))throw new Error(`Archive contains an unsafe path: ${r}`)}function Re(r,t){let e=l.relative(t,r);return e===""||!!e&&!e.startsWith("..")&&!l.isAbsolute(e)}function _e(r,t){let e=_(r),i$1=e.split("/").filter(Boolean);if(i$1.some((n,o)=>(n===".workspai"||n===".rapidkit")&&["cache","reports"].includes(i$1[o+1]||""))||i$1.some(n=>We.has(n)||a(n)))return true;let s=i$1[i$1.length-1]||"";return e===i.workspaceContract||e===".rapidkit/workspace.contract.json"||be.has(s)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(s)||!t?.includeEnv&&Se.some(n=>n.test(s))?true:s.endsWith(".pyc")||s.endsWith(".log")}async function Ce(r){for(let t of [l.join(r,".workspai","workspace.contract.json"),l.join(r,".rapidkit","workspace.contract.json")])if(await p.pathExists(t))try{return await p.readJson(t)}catch(e){throw new Error(`Workspace contract could not be inspected safely for archive portability: ${t}: ${e instanceof Error?e.message:String(e)}`)}return null}function xe(r){return (r?.projects??[]).filter(t=>typeof t.externalPath=="string"||typeof t.relativePath=="string"&&t.relativePath.startsWith("external/")).map(t=>({name:t.slug||t.relativePath||"external-project",relationship:["adopted","linked","imported","managed","restored"].includes(String(t.relationship))?t.relationship:"adopted",included:false,requiredAction:"relink"})).sort((t,e)=>t.name.localeCompare(e.name))}function Oe(r){if(r)return {...r,workspace:{...r.workspace},projects:r.projects.filter(t=>typeof t.externalPath!="string"&&!t.relativePath.startsWith("external/")).map(({externalPath:t,...e})=>({...e,modules:[...e.modules],ports:e.ports.map(i=>({...i})),contracts:{owns:[...e.contracts.owns],apis:e.contracts.apis.map(i=>({...i})),publishes:[...e.contracts.publishes],consumes:[...e.contracts.consumes],dependsOn:[...e.contracts.dependsOn],env:[...e.contracts.env]}}))}}async function*se(r,t,e){let i=(await p.readdir(t,{withFileTypes:true})).sort((a,s)=>a.name.localeCompare(s.name));for(let a of i){let s=l.join(t,a.name),n=_(l.relative(r,s));if(!(!n||_e(n,e))){if(a.isDirectory()){yield*se(r,s,e);continue}a.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function ze(r){for(let t$1 of t(r,"workspace.json"))try{let e=await p.readJson(t$1);if(typeof e.workspace_name=="string"&&e.workspace_name.trim())return e.workspace_name.trim();if(typeof e.name=="string"&&e.name.trim())return e.name.trim()}catch{}return l.basename(l.resolve(r))}async function Ne(r){let t=await p.stat(r.fullPath),e=z.createHash("sha256"),i=0;for await(let s of createReadStream(r.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);i+=n.length,e.update(n);}let a=await p.stat(r.fullPath);if(t.size!==a.size||t.mtimeMs!==a.mtimeMs||i!==a.size)throw new Error(`Workspace file changed while preparing archive: ${r.relativePath}`);return {...r,size:i,mtimeMs:a.mtimeMs,sha256:e.digest("hex")}}async function E(r,t){r.write(t)||await once(r,"drain");}async function ne(r){await new Promise((t,e)=>{r.once("error",e),r.end(t);});}async function*O(r){let t=Q.createInterface({input:createReadStream(r),crlfDelay:1/0});for await(let e of t){let i=e.trim();i&&(yield JSON.parse(i));}}async function Me(r){let t=createWriteStream(r.manifestPath,{flags:"wx"});try{await E(t,`{
2
2
  `);for(let[i,a]of Object.entries(r.manifestBase))await E(t,` ${JSON.stringify(i)}: ${JSON.stringify(a,null,2)},
3
3
  `);await E(t,` "files": [
4
4
  `);let e=true;for await(let i of O(r.spoolPath)){let{mtimeMs:a,...s}=i;await E(t,`${e?"":`,
5
5
  `} ${JSON.stringify(s)}`),e=false;}await E(t,`
6
6
  ]
7
7
  }
8
- `),await ne(t);}catch(e){throw t.destroy(),await p.remove(r.manifestPath).catch(()=>{}),e}}async function Te(r,t){let e=[];for await(let i of O(t)){let{mtimeMs:a,...s}=i;e.push(s);}return {...r,files:e}}async function Ie(r,t){try{await p.rename(r,t);}catch(e){let i=e.code;if(i!=="EEXIST"&&i!=="EPERM")throw e;await p.move(r,t,{overwrite:true});}}async function ht(r){let t=l.resolve(r.workspacePath);if(!j(t))throw new Error("Workspace export requires a Workspai workspace root with .workspai-workspace or a legacy .rapidkit-workspace marker.");let e=await ze(t),i=await Ce(t),a=xe(i),s=Oe(i),n=l.resolve(r.outputPath||`${re(e)}.workspai-archive.zip`),o={schemaVersion:q,version:1,kind:de,workspaceName:e,exportedAt:(r.now??new Date).toISOString(),exportedBy:"workspai",archiveFormat:r.compression==="deflate"?"zip-deflate":"zip-store",containerFormat:"zip64",compression:r.compression==="deflate"?"deflate":"store",streaming:true,security:{envFilesIncluded:r.includeEnv===true,excludedByDefault:[".git","node_modules",".venv",".workspai/cache",".workspai/reports",".rapidkit/cache",".rapidkit/reports","dist","build","target",".env","*.pem","*.key","*.log"]},...a.length>0?{externalProjects:a}:{},...s?{portableContract:s}:{}},m=l.resolve(n);await p.ensureDir(l.dirname(n));let h=`${n}.${process.pid}.${z.randomUUID()}.tmp`,u=await p.mkdtemp(l.join(Y.tmpdir(),"workspai-archive-export-")),y=l.join(u,"manifest-files.jsonl"),c=l.join(u,"archive-manifest.json"),f=new te.ZipFile,w=r.now??new Date,v=r.compression==="deflate";try{let P=createWriteStream(y,{flags:"wx"});try{for await(let d of se(t,t,{includeEnv:r.includeEnv===true})){if(l.resolve(d.fullPath)===m)continue;let g=await Ne(d),x={path:g.relativePath,size:g.size,sha256:g.sha256,mtimeMs:g.mtimeMs};await E(P,`${JSON.stringify(x)}
9
- `);}await ne(P);}catch(d){throw P.destroy(),d}await Me({manifestBase:o,spoolPath:y,manifestPath:c});for await(let d of O(y)){let g=l.join(t,...d.path.split("/"));f.addFile(g,d.path,{compress:v,forceZip64Format:d.size>=4294967295,mtime:w});}f.addFile(c,A,{compress:v,mtime:w}),f.end({forceZip64Format:true,comment:""}),await pipeline(f.outputStream,createWriteStream(h,{flags:"wx"}));for await(let d of O(y)){let g=l.join(t,...d.path.split("/")),x=await p.stat(g);if(x.size!==d.size||x.mtimeMs!==d.mtimeMs)throw new Error(`Workspace file changed while writing archive: ${d.path}`)}let W=await p.stat(h);await Ie(h,n);let b=await Te(o,y);return C({schemaVersion:k,operation:"export",status:"passed",archivePath:n,manifest:b,bytesWritten:W.size})}finally{await p.remove(u).catch(()=>{}),await p.remove(h).catch(()=>{});}}async function oe(r,t={}){if(/^https?:\/\//i.test(r)){let e=await p.mkdtemp(l.join(Y.tmpdir(),"workspai-workspace-archive-")),i=l.join(e,"workspace.workspai-archive.zip"),a=new AbortController,s=t.downloadTimeoutMs??ye,n=s>0?setTimeout(()=>a.abort(new Error("Download timed out")),s):null;try{let o=await Pe(r,a.signal,t.allowPrivateNetwork===true);if(!o.ok)throw new Error(`Failed to download workspace archive: HTTP ${o.status}`);if(!o.body)throw new Error("Failed to download workspace archive: response body is empty.");let m=t.maxDownloadBytes??ve,h=Number(o.headers.get("content-length"));if(Number.isFinite(h)&&h>m)throw new Error(`Workspace archive download exceeds configured limit (${h} > ${m} bytes).`);let u=0,y=new Transform({transform(f,w,v){if(u+=f.length,u>m){v(new Error(`Workspace archive download exceeds configured limit (${m} bytes).`));return}v(null,f);}}),c=Readable.fromWeb(o.body);return await pipeline(c,y,createWriteStream(i,{flags:"wx"})),{archivePath:i,cleanup:e}}catch(o){throw await p.remove(e).catch(()=>{}),a.signal.aborted?new Error(`Workspace archive download timed out after ${s}ms.`,{cause:o}):o}finally{n&&clearTimeout(n);}}return {archivePath:l.resolve(r)}}function $e(r){return new Promise((t,e)=>{ee.open(r,{autoClose:false,lazyEntries:true,decodeStrings:true,validateEntrySizes:true,strictFileNames:true},(i,a)=>{i||!a?e(i??new Error("Failed to open workspace archive.")):t(a);});})}function Fe(r){return new Promise((t,e)=>{let i=[],a=s=>e(s);r.once("error",a),r.on("entry",s=>{try{if(ae(s.fileName),s.isEncrypted())throw new Error(`Encrypted workspace archive entries are not supported: ${s.fileName}`);s.fileName.endsWith("/")||i.push({name:s.fileName,size:s.uncompressedSize,compressedSize:s.compressedSize,crc32:s.crc32,entry:s}),r.readEntry();}catch(n){e(n);}}),r.once("end",()=>{r.removeListener("error",a),t(i);}),r.readEntry();})}function $(r,t){return new Promise((e,i)=>{r.openReadStream(t,(a,s)=>{a||!s?i(a??new Error(`Failed to read ${t.fileName}.`)):e(s);});})}async function Le(r,t,e=Ee){if(t.size>e)throw new Error(`Workspace archive manifest exceeds ${e} bytes.`);let i=[],a=0,s=await $(r,t.entry);for await(let n of s){let o=Buffer.isBuffer(n)?n:Buffer.from(n);if(a+=o.length,a>e)throw s.destroy(),new Error(`Workspace archive manifest exceeds ${e} bytes.`);i.push(o);}return Buffer.concat(i,a)}function Ve(r){let t=JSON.parse(r.toString("utf-8"));a$1(t,K,"Workspace archive manifest");let e=new Set;for(let i of t.files){if(!ie(i.path)||_(i.path)!==i.path)throw new Error(`Workspace archive manifest contains an unsafe path: ${i.path}`);if(i.path===A||i.path===R)throw new Error(`Workspace archive manifest cannot inventory itself: ${i.path}`);if(e.has(i.path))throw new Error(`Workspace archive manifest contains duplicate path: ${i.path}`);e.add(i.path);}return t}function C(r){return a$1(r,Z,"Workspace archive operation result"),r}function Be(r){return v(_(r))}function De(r){let t=new Map;for(let e of r){if(e.name===A||e.name===R)continue;let i=Be(e.name),a=t.get(i);if(!a){t.set(i,{...e,sourceName:e.name,targetName:i});continue}let s=e.name===i,n=a.sourceName===a.targetName;if(s&&!n){t.set(i,{...e,sourceName:e.name,targetName:i});continue}if(!(a.size===e.size&&a.crc32===e.crc32)&&!n)throw new Error(`Workspace archive contains conflicting entries for ${i}: ${a.sourceName}, ${e.name}`)}return [...t.values()].sort((e,i)=>e.targetName.localeCompare(i.targetName))}async function F(r,t={}){let e=await oe(r,t),i;try{i=await $e(e.archivePath);let a=await Fe(i);if(a.length>J)throw new Error(`Workspace archive contains too many entries (${a.length} > ${J}).`);for(let h of a){if(h.size>ge)throw new Error(`Workspace archive entry is too large: ${h.name}`);if(h.size/Math.max(1,h.compressedSize)>ke)throw new Error(`Workspace archive entry has an unsafe compression ratio: ${h.name}`)}let s=a.reduce((h,u)=>h+u.size,0),n=t.maxExpandedBytes??we;if(s>n)throw new Error(`Workspace archive payload exceeds configured limit (${s} > ${n} bytes).`);let o=a.find(h=>h.name===A||h.name===R);if(!o)throw new Error(`Workspace archive is missing ${p$1("","archive-manifest.json").replace(/^\//,"")}.`);let m=Ve(await Le(i,o));return {archivePath:e.archivePath,entries:a,manifest:m,zipFile:i,cleanup:e.cleanup}}catch(a){throw i?.close(),e.cleanup&&await p.remove(e.cleanup).catch(()=>{}),a}}async function L(r){r.zipFile?.close(),r.cleanup&&await p.remove(r.cleanup).catch(()=>{});}async function je(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(a=>a.name!==A&&a.name!==R).map(a=>[a.name,a])),i=t.manifest.files.map(a=>({path:a.path,size:e.get(a.path)?.size??a.size,hasChecksum:typeof a.sha256=="string"&&a.sha256.length>0}));return C({schemaVersion:k,operation:"inspect",status:"passed",archivePath:t.archivePath,manifest:t.manifest,fileCount:i.length,totalBytes:i.reduce((a,s)=>a+s.size,0),entries:i})}finally{await L(t);}}async function ce(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(c=>c.name!==A&&c.name!==R).map(c=>[c.name,c])),i=new Set(t.manifest.files.map(c=>c.path)),a=[...e.keys()].filter(c=>!i.has(c)).sort(),s=[],n=[],o=[],m=0;for(let c of t.manifest.files){ae(c.path);let f=e.get(c.path);if(!f){s.push(c.path);continue}let w=z.createHash("sha256"),v=0,P=await $(t.zipFile,f.entry);for await(let b of P){let d=Buffer.isBuffer(b)?b:Buffer.from(b);v+=d.length,w.update(d);}let W={size:v,sha256:w.digest("hex")};if(v!==f.size||v!==c.size){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:W});continue}if(!c.sha256){n.push(c.path);continue}if(W.sha256!==c.sha256){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:W});continue}m+=1;}let h=r.requireChecksums===true&&n.length>0,u=s.length>0||o.length>0||h||a.length>0,y=n.length>0;return C({schemaVersion:k,operation:"verify",archivePath:t.archivePath,manifest:t.manifest,status:u?"failed":y?"warning":"passed",fileCount:t.manifest.files.length,totalBytes:t.manifest.files.reduce((c,f)=>c+f.size,0),verifiedFiles:m,missingChecksumFiles:n,missingArchiveEntries:s,extraArchiveEntries:a,mismatches:o})}finally{await L(t);}}async function mt(r){let t=await oe(r.archivePathOrUrl,r.safety);try{return await He({archivePath:t.archivePath,strict:r.strict})}finally{t.cleanup&&await p.remove(t.cleanup).catch(()=>{});}}async function He(r){let t=await je({archivePathOrUrl:r.archivePath}),e=await ce({archivePathOrUrl:r.archivePath,requireChecksums:r.strict===true}),i=[],a=[];i.push({id:"manifest-present",status:"passed",message:`Archive manifest found for workspace "${t.manifest.workspaceName}".`}),i.push({id:"integrity",status:e.status,message:e.status==="passed"?`Verified ${e.verifiedFiles}/${e.fileCount} files.`:"Archive integrity verification did not fully pass."});let s=t.manifest.security?.envFilesIncluded===true;i.push({id:"secrets-policy",status:s?"warning":"passed",message:s?"Archive manifest says environment/private files were intentionally included.":"Archive manifest excludes environment/private files by default."}),s&&a.push("Share this archive only through trusted internal channels."),e.missingChecksumFiles.length>0&&a.push("Re-export the archive with the latest RapidKit/Workspai tooling."),e.mismatches.length>0&&a.push("Reject this archive and request a fresh export from the owner."),(e.extraArchiveEntries.length>0||e.missingArchiveEntries.length>0)&&a.push("Regenerate the archive so ZIP entries and manifest entries match."),r.strict===true&&e.status!=="passed"&&a.push("Do not hydrate this archive in strict or production workflows.");let n=i.some(m=>m.status==="failed"),o=i.some(m=>m.status==="warning");return C({schemaVersion:k,operation:"doctor",archivePath:t.archivePath,status:n?"failed":o?"warning":"passed",workspaceName:t.manifest.workspaceName,fileCount:t.fileCount,totalBytes:t.totalBytes,checks:i,recommendedActions:a})}async function Ue(r,t){let e=await p.lstat(r).catch(a=>{if(a.code==="ENOENT")return null;throw a});if(!e)return false;if(e.isSymbolicLink())throw new Error(`Output directory must not be a symbolic link: ${r}`);if(!e.isDirectory())throw new Error(`Output path is not a directory: ${r}`);if((await p.readdir(r)).length>0&&!t)throw new Error(`Output directory is not empty: ${r}. Use --force to overwrite.`);return true}async function ft(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=await ce({archivePathOrUrl:t.archivePath,requireChecksums:r.strict===true});if(e.status==="failed"){let o=[e.missingArchiveEntries.length?`missing entries: ${e.missingArchiveEntries.join(", ")}`:"",e.extraArchiveEntries.length?`unexpected entries: ${e.extraArchiveEntries.join(", ")}`:"",e.mismatches.length?`checksum/size mismatches: ${e.mismatches.map(m=>m.path).join(", ")}`:"",e.missingChecksumFiles.length&&r.strict===true?`missing checksums: ${e.missingChecksumFiles.join(", ")}`:""].filter(Boolean).join("; ");throw new Error(`Workspace archive verification failed${o?` (${o})`:""}.`)}if(e.status==="warning"&&r.strict===true)throw new Error(`Workspace archive verification requires checksums for every file: ${e.missingChecksumFiles.join(", ")}`);let i=De(t.entries),a=t.manifest,s=l.resolve(r.outputPath||re(a.workspaceName||"imported-workspace")),n=await Ue(s,r.force===true);if(!r.dryRun){let o=l.dirname(s),m=`${process.pid}-${z.randomUUID()}`,h=l.join(o,`.${l.basename(s)}.hydrate-${m}.tmp`),u=l.join(o,`.${l.basename(s)}.hydrate-${m}.backup`),y=false,c=false;await p.ensureDir(o);try{await p.ensureDir(h);for(let f of i){let w=l.resolve(h,f.targetName);if(!Re(w,h))throw new Error(`Archive entry escapes output directory: ${f.targetName}`);await p.ensureDir(l.dirname(w));let v=await $(t.zipFile,f.entry);await pipeline(v,createWriteStream(w,{flags:"wx"}));}n&&(await p.rename(s,u),y=true),await p.rename(h,s),c=true,y&&await p.remove(u).catch(()=>{});}catch(f){throw y&&!await p.pathExists(s)&&await p.rename(u,s).catch(()=>{}),f}finally{await p.remove(h).catch(()=>{}),c&&await p.remove(u).catch(()=>{});}}return C({schemaVersion:k,operation:"hydrate",status:"passed",archivePath:t.archivePath,outputPath:s,dryRun:r.dryRun===true,manifest:a,files:i.map(o=>({path:o.targetName,size:o.size}))})}finally{await L(t);}}
8
+ `),await ne(t);}catch(e){throw t.destroy(),await p.remove(r.manifestPath).catch(()=>{}),e}}async function Te(r,t){let e=[];for await(let i of O(t)){let{mtimeMs:a,...s}=i;e.push(s);}return {...r,files:e}}async function Ie(r,t){try{await p.rename(r,t);}catch(e){let i=e.code;if(i!=="EEXIST"&&i!=="EPERM")throw e;await p.move(r,t,{overwrite:true});}}async function ht(r){let t=l.resolve(r.workspacePath);if(!k$1(t))throw new Error("Workspace export requires a Workspai workspace root with .workspai-workspace or a legacy .rapidkit-workspace marker.");let e=await ze(t),i=await Ce(t),a=xe(i),s=Oe(i),n=l.resolve(r.outputPath||`${re(e)}.workspai-archive.zip`),o={schemaVersion:q,version:1,kind:de,workspaceName:e,exportedAt:(r.now??new Date).toISOString(),exportedBy:"workspai",archiveFormat:r.compression==="deflate"?"zip-deflate":"zip-store",containerFormat:"zip64",compression:r.compression==="deflate"?"deflate":"store",streaming:true,security:{envFilesIncluded:r.includeEnv===true,excludedByDefault:[".git","node_modules",".venv",".workspai/cache",".workspai/reports",".rapidkit/cache",".rapidkit/reports","dist","build","target",".env","*.pem","*.key","*.log"]},...a.length>0?{externalProjects:a}:{},...s?{portableContract:s}:{}},m=l.resolve(n);await p.ensureDir(l.dirname(n));let h=`${n}.${process.pid}.${z.randomUUID()}.tmp`,u=await p.mkdtemp(l.join(Y.tmpdir(),"workspai-archive-export-")),y=l.join(u,"manifest-files.jsonl"),c=l.join(u,"archive-manifest.json"),f=new te.ZipFile,w=r.now??new Date,v=r.compression==="deflate";try{let P=createWriteStream(y,{flags:"wx"});try{for await(let d of se(t,t,{includeEnv:r.includeEnv===true})){if(l.resolve(d.fullPath)===m)continue;let g=await Ne(d),x={path:g.relativePath,size:g.size,sha256:g.sha256,mtimeMs:g.mtimeMs};await E(P,`${JSON.stringify(x)}
9
+ `);}await ne(P);}catch(d){throw P.destroy(),d}await Me({manifestBase:o,spoolPath:y,manifestPath:c});for await(let d of O(y)){let g=l.join(t,...d.path.split("/"));f.addFile(g,d.path,{compress:v,forceZip64Format:d.size>=4294967295,mtime:w});}f.addFile(c,A,{compress:v,mtime:w}),f.end({forceZip64Format:true,comment:""}),await pipeline(f.outputStream,createWriteStream(h,{flags:"wx"}));for await(let d of O(y)){let g=l.join(t,...d.path.split("/")),x=await p.stat(g);if(x.size!==d.size||x.mtimeMs!==d.mtimeMs)throw new Error(`Workspace file changed while writing archive: ${d.path}`)}let W=await p.stat(h);await Ie(h,n);let b=await Te(o,y);return C({schemaVersion:k,operation:"export",status:"passed",archivePath:n,manifest:b,bytesWritten:W.size})}finally{await p.remove(u).catch(()=>{}),await p.remove(h).catch(()=>{});}}async function oe(r,t={}){if(/^https?:\/\//i.test(r)){let e=await p.mkdtemp(l.join(Y.tmpdir(),"workspai-workspace-archive-")),i=l.join(e,"workspace.workspai-archive.zip"),a=new AbortController,s=t.downloadTimeoutMs??ye,n=s>0?setTimeout(()=>a.abort(new Error("Download timed out")),s):null;try{let o=await Pe(r,a.signal,t.allowPrivateNetwork===true);if(!o.ok)throw new Error(`Failed to download workspace archive: HTTP ${o.status}`);if(!o.body)throw new Error("Failed to download workspace archive: response body is empty.");let m=t.maxDownloadBytes??ve,h=Number(o.headers.get("content-length"));if(Number.isFinite(h)&&h>m)throw new Error(`Workspace archive download exceeds configured limit (${h} > ${m} bytes).`);let u=0,y=new Transform({transform(f,w,v){if(u+=f.length,u>m){v(new Error(`Workspace archive download exceeds configured limit (${m} bytes).`));return}v(null,f);}}),c=Readable.fromWeb(o.body);return await pipeline(c,y,createWriteStream(i,{flags:"wx"})),{archivePath:i,cleanup:e}}catch(o){throw await p.remove(e).catch(()=>{}),a.signal.aborted?new Error(`Workspace archive download timed out after ${s}ms.`,{cause:o}):o}finally{n&&clearTimeout(n);}}return {archivePath:l.resolve(r)}}function $e(r){return new Promise((t,e)=>{ee.open(r,{autoClose:false,lazyEntries:true,decodeStrings:true,validateEntrySizes:true,strictFileNames:true},(i,a)=>{i||!a?e(i??new Error("Failed to open workspace archive.")):t(a);});})}function Fe(r){return new Promise((t,e)=>{let i=[],a=s=>e(s);r.once("error",a),r.on("entry",s=>{try{if(ae(s.fileName),s.isEncrypted())throw new Error(`Encrypted workspace archive entries are not supported: ${s.fileName}`);s.fileName.endsWith("/")||i.push({name:s.fileName,size:s.uncompressedSize,compressedSize:s.compressedSize,crc32:s.crc32,entry:s}),r.readEntry();}catch(n){e(n);}}),r.once("end",()=>{r.removeListener("error",a),t(i);}),r.readEntry();})}function $(r,t){return new Promise((e,i)=>{r.openReadStream(t,(a,s)=>{a||!s?i(a??new Error(`Failed to read ${t.fileName}.`)):e(s);});})}async function Le(r,t,e=Ee){if(t.size>e)throw new Error(`Workspace archive manifest exceeds ${e} bytes.`);let i=[],a=0,s=await $(r,t.entry);for await(let n of s){let o=Buffer.isBuffer(n)?n:Buffer.from(n);if(a+=o.length,a>e)throw s.destroy(),new Error(`Workspace archive manifest exceeds ${e} bytes.`);i.push(o);}return Buffer.concat(i,a)}function Ve(r){let t=JSON.parse(r.toString("utf-8"));a$1(t,K,"Workspace archive manifest");let e=new Set;for(let i of t.files){if(!ie(i.path)||_(i.path)!==i.path)throw new Error(`Workspace archive manifest contains an unsafe path: ${i.path}`);if(i.path===A||i.path===R)throw new Error(`Workspace archive manifest cannot inventory itself: ${i.path}`);if(e.has(i.path))throw new Error(`Workspace archive manifest contains duplicate path: ${i.path}`);e.add(i.path);}return t}function C(r){return a$1(r,Z,"Workspace archive operation result"),r}function Be(r){return w(_(r))}function De(r){let t=new Map;for(let e of r){if(e.name===A||e.name===R)continue;let i=Be(e.name),a=t.get(i);if(!a){t.set(i,{...e,sourceName:e.name,targetName:i});continue}let s=e.name===i,n=a.sourceName===a.targetName;if(s&&!n){t.set(i,{...e,sourceName:e.name,targetName:i});continue}if(!(a.size===e.size&&a.crc32===e.crc32)&&!n)throw new Error(`Workspace archive contains conflicting entries for ${i}: ${a.sourceName}, ${e.name}`)}return [...t.values()].sort((e,i)=>e.targetName.localeCompare(i.targetName))}async function F(r,t={}){let e=await oe(r,t),i;try{i=await $e(e.archivePath);let a=await Fe(i);if(a.length>J)throw new Error(`Workspace archive contains too many entries (${a.length} > ${J}).`);for(let h of a){if(h.size>ge)throw new Error(`Workspace archive entry is too large: ${h.name}`);if(h.size/Math.max(1,h.compressedSize)>ke)throw new Error(`Workspace archive entry has an unsafe compression ratio: ${h.name}`)}let s=a.reduce((h,u)=>h+u.size,0),n=t.maxExpandedBytes??we;if(s>n)throw new Error(`Workspace archive payload exceeds configured limit (${s} > ${n} bytes).`);let o=a.find(h=>h.name===A||h.name===R);if(!o)throw new Error(`Workspace archive is missing ${q$1("","archive-manifest.json").replace(/^\//,"")}.`);let m=Ve(await Le(i,o));return {archivePath:e.archivePath,entries:a,manifest:m,zipFile:i,cleanup:e.cleanup}}catch(a){throw i?.close(),e.cleanup&&await p.remove(e.cleanup).catch(()=>{}),a}}async function L(r){r.zipFile?.close(),r.cleanup&&await p.remove(r.cleanup).catch(()=>{});}async function je(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(a=>a.name!==A&&a.name!==R).map(a=>[a.name,a])),i=t.manifest.files.map(a=>({path:a.path,size:e.get(a.path)?.size??a.size,hasChecksum:typeof a.sha256=="string"&&a.sha256.length>0}));return C({schemaVersion:k,operation:"inspect",status:"passed",archivePath:t.archivePath,manifest:t.manifest,fileCount:i.length,totalBytes:i.reduce((a,s)=>a+s.size,0),entries:i})}finally{await L(t);}}async function ce(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(c=>c.name!==A&&c.name!==R).map(c=>[c.name,c])),i=new Set(t.manifest.files.map(c=>c.path)),a=[...e.keys()].filter(c=>!i.has(c)).sort(),s=[],n=[],o=[],m=0;for(let c of t.manifest.files){ae(c.path);let f=e.get(c.path);if(!f){s.push(c.path);continue}let w=z.createHash("sha256"),v=0,P=await $(t.zipFile,f.entry);for await(let b of P){let d=Buffer.isBuffer(b)?b:Buffer.from(b);v+=d.length,w.update(d);}let W={size:v,sha256:w.digest("hex")};if(v!==f.size||v!==c.size){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:W});continue}if(!c.sha256){n.push(c.path);continue}if(W.sha256!==c.sha256){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:W});continue}m+=1;}let h=r.requireChecksums===true&&n.length>0,u=s.length>0||o.length>0||h||a.length>0,y=n.length>0;return C({schemaVersion:k,operation:"verify",archivePath:t.archivePath,manifest:t.manifest,status:u?"failed":y?"warning":"passed",fileCount:t.manifest.files.length,totalBytes:t.manifest.files.reduce((c,f)=>c+f.size,0),verifiedFiles:m,missingChecksumFiles:n,missingArchiveEntries:s,extraArchiveEntries:a,mismatches:o})}finally{await L(t);}}async function mt(r){let t=await oe(r.archivePathOrUrl,r.safety);try{return await He({archivePath:t.archivePath,strict:r.strict})}finally{t.cleanup&&await p.remove(t.cleanup).catch(()=>{});}}async function He(r){let t=await je({archivePathOrUrl:r.archivePath}),e=await ce({archivePathOrUrl:r.archivePath,requireChecksums:r.strict===true}),i=[],a=[];i.push({id:"manifest-present",status:"passed",message:`Archive manifest found for workspace "${t.manifest.workspaceName}".`}),i.push({id:"integrity",status:e.status,message:e.status==="passed"?`Verified ${e.verifiedFiles}/${e.fileCount} files.`:"Archive integrity verification did not fully pass."});let s=t.manifest.security?.envFilesIncluded===true;i.push({id:"secrets-policy",status:s?"warning":"passed",message:s?"Archive manifest says environment/private files were intentionally included.":"Archive manifest excludes environment/private files by default."}),s&&a.push("Share this archive only through trusted internal channels."),e.missingChecksumFiles.length>0&&a.push("Re-export the archive with the latest RapidKit/Workspai tooling."),e.mismatches.length>0&&a.push("Reject this archive and request a fresh export from the owner."),(e.extraArchiveEntries.length>0||e.missingArchiveEntries.length>0)&&a.push("Regenerate the archive so ZIP entries and manifest entries match."),r.strict===true&&e.status!=="passed"&&a.push("Do not hydrate this archive in strict or production workflows.");let n=i.some(m=>m.status==="failed"),o=i.some(m=>m.status==="warning");return C({schemaVersion:k,operation:"doctor",archivePath:t.archivePath,status:n?"failed":o?"warning":"passed",workspaceName:t.manifest.workspaceName,fileCount:t.fileCount,totalBytes:t.totalBytes,checks:i,recommendedActions:a})}async function Ue(r,t){let e=await p.lstat(r).catch(a=>{if(a.code==="ENOENT")return null;throw a});if(!e)return false;if(e.isSymbolicLink())throw new Error(`Output directory must not be a symbolic link: ${r}`);if(!e.isDirectory())throw new Error(`Output path is not a directory: ${r}`);if((await p.readdir(r)).length>0&&!t)throw new Error(`Output directory is not empty: ${r}. Use --force to overwrite.`);return true}async function ft(r){let t=await F(r.archivePathOrUrl,r.safety);try{let e=await ce({archivePathOrUrl:t.archivePath,requireChecksums:r.strict===true});if(e.status==="failed"){let o=[e.missingArchiveEntries.length?`missing entries: ${e.missingArchiveEntries.join(", ")}`:"",e.extraArchiveEntries.length?`unexpected entries: ${e.extraArchiveEntries.join(", ")}`:"",e.mismatches.length?`checksum/size mismatches: ${e.mismatches.map(m=>m.path).join(", ")}`:"",e.missingChecksumFiles.length&&r.strict===true?`missing checksums: ${e.missingChecksumFiles.join(", ")}`:""].filter(Boolean).join("; ");throw new Error(`Workspace archive verification failed${o?` (${o})`:""}.`)}if(e.status==="warning"&&r.strict===true)throw new Error(`Workspace archive verification requires checksums for every file: ${e.missingChecksumFiles.join(", ")}`);let i=De(t.entries),a=t.manifest,s=l.resolve(r.outputPath||re(a.workspaceName||"imported-workspace")),n=await Ue(s,r.force===true);if(!r.dryRun){let o=l.dirname(s),m=`${process.pid}-${z.randomUUID()}`,h=l.join(o,`.${l.basename(s)}.hydrate-${m}.tmp`),u=l.join(o,`.${l.basename(s)}.hydrate-${m}.backup`),y=false,c=false;await p.ensureDir(o);try{await p.ensureDir(h);for(let f of i){let w=l.resolve(h,f.targetName);if(!Re(w,h))throw new Error(`Archive entry escapes output directory: ${f.targetName}`);await p.ensureDir(l.dirname(w));let v=await $(t.zipFile,f.entry);await pipeline(v,createWriteStream(w,{flags:"wx"}));}n&&(await p.rename(s,u),y=true),await p.rename(h,s),c=true,y&&await p.remove(u).catch(()=>{});}catch(f){throw y&&!await p.pathExists(s)&&await p.rename(u,s).catch(()=>{}),f}finally{await p.remove(h).catch(()=>{}),c&&await p.remove(u).catch(()=>{});}}return C({schemaVersion:k,operation:"hydrate",status:"passed",archivePath:t.archivePath,outputPath:s,dryRun:r.dryRun===true,manifest:a,files:i.map(o=>({path:o.targetName,size:o.size}))})}finally{await L(t);}}
10
10
  export{qe as a,q as b,k as c,Ke as d,A as e,de as f,Ae as g,X as h,re as i,ie as j,_e as k,ht as l,je as m,ce as n,mt as o,ft as p};
@@ -0,0 +1 @@
1
+ var r="workspai.doctor-capabilities.v1",k="universal-doctor-capabilities-v1",t="workspai.doctor-validation.v1",w="doctor-disease-corpus-v1";var o={model:".workspai/reports/workspace-model.json",knowledgeGraph:".workspai/reports/workspace-knowledge-graph.json",snapshot:".workspai/reports/workspace-model-snapshot.json",diff:".workspai/reports/workspace-model-diff-last-run.json",impact:".workspai/reports/workspace-impact-last-run.json",analyze:".workspai/reports/analyze-last-run.json",doctor:".workspai/reports/doctor-last-run.json",contractVerify:".workspai/reports/workspace-contract-verify-last-run.json",readiness:".workspai/reports/release-readiness-last-run.json",verify:".workspai/reports/workspace-verify-last-run.json",history:".workspai/reports/workspace-intelligence-history.json",agentContext:".workspai/reports/workspace-context-agent.json",agentIndex:".workspai/reports/INDEX.json",agentCustomizationPack:".workspai/reports/agent-customization-pack.json",skillsIndex:".workspai/reports/workspace-skills-index.json",agents:"AGENTS.md",explain:".workspai/reports/workspace-explain-last-run.json",intelligenceRun:".workspai/reports/workspace-intelligence-run-last-run.json",evaluationLive:".workspai/reports/workspace-intelligence-evaluation-live.json",evaluationLastRun:".workspai/reports/workspace-intelligence-evaluation-last-run.json",verifiedGoalStatus:".workspai/reports/verified-goal-last-run.json",repairTransaction:".workspai/reports/workspace-repair-last-run.json"},s={model:"workspace-model.v1",knowledgeGraph:"workspace-knowledge-graph.v1",snapshot:"workspace-model-snapshot.v1",diff:"workspace-model-diff.v1",impact:"workspace-impact.v1",analyze:"rapidkit-analyze-v1",doctor:"doctor-workspace-evidence-v1",contractVerify:"workspace-contract-verify.v1",readiness:"release-readiness-v1",verify:"workspace-verify.v1",history:"workspace-intelligence-history.v1",agentContext:"workspace-context.v1",agentIndex:"rapidkit-agent-reports-index.v1",agentCustomizationPack:"rapidkit-agent-customization-pack.v1",skillsIndex:"workspace-skills-index.v1",agents:null,explain:"workspace-explain.v1",intelligenceRun:"workspace-intelligence-run.v1",evaluationLive:"workspace-intelligence-evaluation.v1",evaluationLastRun:"workspace-intelligence-evaluation.v1",verifiedGoalStatus:"workspai.verified-goal-status.v1",repairTransaction:"workspai.workspace-repair-transaction.v1"},c={model:"contracts/workspace-intelligence/workspace-model.v1.json",knowledgeGraph:"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json",snapshot:"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",diff:"contracts/workspace-intelligence/workspace-model-diff.v1.json",impact:"contracts/workspace-intelligence/workspace-impact.v1.json",analyze:"contracts/analyze-last-run.v1.json",doctor:"contracts/doctor-workspace-evidence.v1.json",contractVerify:"contracts/workspace-intelligence/workspace-contract-verify.v1.json",readiness:"contracts/release-readiness.v1.json",verify:"contracts/workspace-intelligence/workspace-verify.v1.json",history:"contracts/workspace-intelligence/workspace-intelligence-history.v1.json",agentContext:"contracts/workspace-intelligence/workspace-context.v1.json",agentIndex:"contracts/workspace-intelligence/agent-reports-index.v1.json",agentCustomizationPack:"contracts/workspace-intelligence/agent-customization-pack-report.v1.json",skillsIndex:"contracts/workspace-intelligence/workspace-skills-index.v1.json",agents:null,explain:"contracts/workspace-intelligence/workspace-explain.v1.json",intelligenceRun:"contracts/workspace-intelligence/workspace-intelligence-run.v1.json",evaluationLive:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",evaluationLastRun:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",verifiedGoalStatus:"contracts/workspace-intelligence/verified-goal-status.v1.json",repairTransaction:"contracts/workspace-intelligence/workspace-repair-transaction.v1.json"},l={goalIndex:{artifactPath:".workspai/goals/index.json",schemaVersion:"workspai.goal-index.v1",contractPath:"contracts/workspace-intelligence/goal-index.v1.json",producerCommands:[["goal"]]},projectWorkspaceLink:{artifactPath:".workspai/workspace-link.local.json",schemaVersion:"project-workspace-link.v1",contractPath:"contracts/project-workspace-link.v1.json",producerCommands:[["adopt"],["import"],["project","workspace","relink"],["workspace","sync"]]},projectContextAgent:{artifactPath:".workspai/reports/project-context-agent.json",schemaVersion:"project-context-agent.v1",contractPath:"contracts/workspace-intelligence/project-context-agent.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},projectKnowledgeGraphReference:{artifactPath:".workspai/reports/project-knowledge-graph-reference.json",schemaVersion:"project-knowledge-graph-reference.v1",contractPath:"contracts/workspace-intelligence/project-knowledge-graph-reference.v1.json",producerCommands:[["adopt"],["import"],["workspace","model"],["workspace","sync"],["workspace","intelligence","run"]]},projectAgentEntry:{artifactPath:".workspai/agent-entry.v1.json",schemaVersion:"workspai.agent-entry.v1",contractPath:"contracts/workspace-intelligence/project-agent-entry.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},workspaceContract:{artifactPath:".workspai/workspace.contract.json",schemaVersion:1,contractPath:"contracts/workspace-contract.v1.json",producerCommands:[["workspace","sync"],["workspace","contract","sync"]]},workspaceModelCache:{artifactPath:".workspai/cache/workspace-model.v1.json",schemaVersion:"workspace-model-cache.v1",contractPath:"contracts/workspace-model-cache.v1.json",producerCommands:[["workspace","model"]]},workspaceRegistry:{artifactPath:".workspai/workspace-registry.v1.json",schemaVersion:"workspace-registry.v1",contractPath:"contracts/workspace-registry.v1.json",producerCommands:[["workspace","sync"]]},compatibilityMatrix:{artifactPath:".workspai/compatibility-matrix.json",schemaVersion:"rapidkit.compatibility-matrix.v1",contractPath:"contracts/compatibility-matrix.v1.json",producerCommands:[["bootstrap"]]},doctorWorkspaceCache:{artifactPath:".workspai/reports/doctor-workspace-cache.json",schemaVersion:"doctor-workspace-cache-v2",contractPath:"contracts/doctor-workspace-cache.v2.json",producerCommands:[["doctor","workspace"]]},doctorCapabilities:{artifactPath:".workspai/reports/doctor-capabilities.json",schemaVersion:r,contractPath:"contracts/workspace-intelligence/doctor-capabilities.v1.json",producerCommands:[["doctor","capabilities","--write"]]},doctorValidation:{artifactPath:".workspai/reports/doctor-validation-last-run.json",schemaVersion:t,contractPath:"contracts/workspace-intelligence/doctor-validation.v1.json",producerCommands:[["doctor","capabilities","--validate","--write"]]},bootstrapCompliance:{artifactPath:".workspai/reports/bootstrap-compliance.latest.json",schemaVersion:"bootstrap-compliance.v1",contractPath:"contracts/bootstrap-compliance.v1.json",producerCommands:[["bootstrap"]]},mirrorOps:{artifactPath:".workspai/reports/mirror-ops.latest.json",schemaVersion:"mirror-ops.v1",contractPath:"contracts/mirror-ops.v1.json",producerCommands:[["mirror","status"]]},transparencyEvidence:{artifactPath:".workspai/reports/transparency-evidence.latest.json",schemaVersion:"transparency-evidence.v1",contractPath:"contracts/transparency-evidence.v1.json",producerCommands:[["mirror","sync"]]},workspaceShareBundle:{artifactPath:".workspai/reports/share-bundle.json",schemaVersion:"1.1",schemaVersionField:"schema_version",contractPath:"contracts/workspace-share-bundle.v1.json",producerCommands:[["workspace","share"]]},doctorProject:{artifactPath:".workspai/reports/doctor-project-last-run.json",schemaVersion:"doctor-project-evidence-v1",contractPath:"contracts/doctor-project-evidence.v1.json",producerCommands:[["doctor","project"]]},doctorReceipt:{artifactPath:".workspai/reports/doctor-receipt-last-run.json",schemaVersion:"workspai.doctor-receipt.v1",contractPath:"contracts/workspace-intelligence/doctor-receipt.v1.json",producerCommands:[["doctor","workspace"],["doctor","project"]]},projectTestCoverage:{artifactPath:".workspai/reports/project-test-coverage-last-run.json",schemaVersion:"workspai.project-test-coverage.v1",contractPath:"contracts/project-test-coverage.v1.json",producerCommands:[["project","coverage"]]},goalPackLastRun:{artifactPath:".workspai/reports/goal-pack-last-run.json",schemaVersion:"workspai.goal-pack.v1",contractPath:"contracts/workspace-intelligence/goal-pack.v1.json",producerCommands:[["goal"]]},doctorRemediationPlan:{artifactPath:".workspai/reports/doctor-remediation-plan-last-run.json",schemaVersion:"doctor-remediation-plan-v2",contractPath:"contracts/doctor-remediation-plan.v2.json",producerCommands:[["workspace","remediation-plan"]]},artifactRemediationPlan:{artifactPath:".workspai/reports/artifact-remediation-plan-last-run.json",schemaVersion:"artifact-remediation-plan-v1",contractPath:"contracts/artifact-remediation-plan.v1.json",producerCommands:[["workspace","remediation-plan"]]},doctorFixResult:{artifactPath:".workspai/reports/doctor-fix-result-last-run.json",schemaVersion:"rapidkit-doctor-fix-result-v1",contractPath:"contracts/workspace-intelligence/doctor-fix-result.v1.json",producerCommands:[["doctor","workspace"]]},pipelineLastRun:{artifactPath:".workspai/reports/pipeline-last-run.json",schemaVersion:"rapidkit-pipeline-v1",contractPath:"contracts/pipeline-last-run.v1.json",producerCommands:[["pipeline"]]},autopilotReleaseLastRun:{artifactPath:".workspai/reports/autopilot-release-last-run.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},autopilotReleaseAlias:{artifactPath:".workspai/reports/autopilot-release.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},workspaceRunLast:{artifactPath:".workspai/reports/workspace-run-last.json",schemaVersion:"workspace-run-v1",contractPath:"contracts/workspace-run-last.v1.json",producerCommands:[["workspace","run"]]},workspaiMcpDesign:{artifactPath:".workspai/reports/workspai-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},legacyMcpDesign:{artifactPath:".workspai/reports/rapidkit-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},workspaceWhy:{artifactPath:".workspai/reports/workspace-why-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","why"]]},workspaceTrace:{artifactPath:".workspai/reports/workspace-trace-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","trace"]]},agentHooks:{artifactPath:".vscode/workspai-agent-hooks.json",schemaVersion:"workspai-agent-hooks.v1",contractPath:"contracts/workspace-intelligence/agent-hooks.v1.json",producerCommands:[["workspace","agent-sync"]]},infraPlan:{artifactPath:".workspai/reports/infra-plan.json",schemaVersion:"rapidkit.infra-plan.v1",contractPath:"contracts/infra-plan.v1.json",producerCommands:[["infra","plan"]]}},h=Object.freeze(Object.fromEntries(Object.entries(l).map(([a,n])=>[a,n.artifactPath]))),u={[o.intelligenceRun]:[["workspace","intelligence","run"]],[o.snapshot]:[["workspace","snapshot"]],[o.history]:[["workspace","feedback","record","--json"]],[o.evaluationLive]:[["workspace","eval","init"],["workspace","eval","record","--json"]],[o.evaluationLastRun]:[["workspace","eval","report","--json"]],[o.verifiedGoalStatus]:[["workspace","goal","plan"],["workspace","goal","verify"]],[o.repairTransaction]:[["workspace","repair","plan"],["workspace","repair","propose"],["workspace","repair","approve"],["workspace","repair","decide"],["workspace","repair","execute"],["workspace","repair","resume"],["workspace","repair","rollback"],["workspace","repair","cancel"]]},j={analyze:"analyze",workspace:"workspace <action> [subaction] [key] [value]",doctor:"doctor [scope]",readiness:"readiness"},f=["analyze","readiness","doctor","workspace"],C=["model","diff","impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify","context","agent-sync","explain"],P=["sync","baseline"],y={sync:[".workspai/workspace.contract.json",".workspai/workspace-registry.v1.json"],baseline:[o.snapshot]},e=o,d={model:{command:["workspace","model","--json","--write"],produces:[e.model,e.knowledgeGraph]},diff:{command:["workspace","diff","--from",e.snapshot,"--json"],produces:[e.diff]},impact:{command:["workspace","impact","--from",e.diff,"--json"],produces:[e.impact]},"doctor-evidence":{command:["doctor","workspace","--json"],produces:[e.doctor]},"contract-evidence":{command:["workspace","contract","verify","--strict","--json"],produces:[e.contractVerify]},"analyze-evidence":{command:["analyze","--json"],produces:[e.analyze]},"readiness-evidence":{command:["readiness","--json","--skip-verify"],produces:[e.readiness]},verify:{command:["workspace","verify","--from-impact",e.impact,"--json"],produces:[e.verify,e.history]},context:{command:["workspace","context","--for-agent","--json","--write","--no-agent-sync"],produces:[e.agentContext]},"agent-sync":{command:["workspace","agent-sync","--write","--json","--preset","enterprise"],produces:[e.agentIndex,e.agentCustomizationPack,e.skillsIndex,e.agents]},explain:{command:["workspace","explain","release-blocked","--json","--write"],produces:[e.explain]}};function I(a){return d[a]}export{r as a,k as b,t as c,w as d,o as e,s as f,c as g,l as h,h as i,u as j,j as k,f as l,C as m,P as n,y as o,d as p,I as q};
@@ -1 +1 @@
1
- import {h}from'./chunk-NZ3WZYD5.js';var i=h.doctorFixResult.schemaVersion,n="npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json";function a(t){return {schemaVersion:i,generatedAt:new Date().toISOString(),appliedFixes:t.appliedFixes,remainingBlockers:t.remainingBlockers,verifyRecommended:t.verifyRecommended??n}}var g="workspai.doctor-summary.v1";var m="doctor-graph-diagnosis.v1";export{i as a,n as b,a as c,m as d,g as e};
1
+ import {h}from'./chunk-6UNATTB7.js';var i=h.doctorFixResult.schemaVersion,n="npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json";function a(t){return {schemaVersion:i,generatedAt:new Date().toISOString(),appliedFixes:t.appliedFixes,remainingBlockers:t.remainingBlockers,verifyRecommended:t.verifyRecommended??n}}var g="workspai.doctor-summary.v1";var m="doctor-graph-diagnosis.v1";export{i as a,n as b,a as c,m as d,g as e};
@@ -0,0 +1,2 @@
1
+ import {z as z$1}from'./chunk-L5Q2S5GY.js';import {j,m as m$1}from'./chunk-U5ENEDJA.js';import {a as a$1}from'./chunk-GR6442P7.js';import {a as a$2,d,c as c$1,e as e$1}from'./chunk-GAYK3WGV.js';import {b}from'./chunk-XESFJN52.js';import {l}from'./chunk-OCGZNSOE.js';import {i,e,h,f}from'./chunk-6UNATTB7.js';import {c}from'./chunk-B4IVVTMQ.js';import {a}from'./chunk-XWKGZRHN.js';import {t,u,q}from'./chunk-VQZ5PI5J.js';import*as m from'path';import m__default from'path';import k from'fs-extra';import Ce from'crypto';var ye="unknown-run";function se(e){let t=c();return !t||t===ye?e:{...e,runId:t}}async function ce(e,t){await k.ensureDir(m.dirname(e));let r=`${e}.${process.pid}.${Date.now()}.${Ce.randomUUID()}.tmp`;try{await k.writeJSON(r,t,{spaces:2}),await k.move(r,e,{overwrite:true});}finally{await k.remove(r).catch(()=>{});}}function ie(e){return q(e,"imported-projects.json")}async function I(e){let t$1=(await Promise.all(t(e,"imported-projects.json").map(async r=>await k.pathExists(r)?r:null))).find(r=>typeof r=="string");if(!t$1)return [];try{let r=await k.readJSON(t$1);if(!r||typeof r!="object"||r.version!==1||!Array.isArray(r.projects))throw new Error("expected a version 1 registry with a projects array");let o=r.projects,n=o.filter(i=>{if(!i||typeof i!="object")return false;let c=i;return typeof c.name=="string"&&typeof c.path=="string"&&typeof c.stack=="string"&&typeof c.confidence=="string"&&typeof c.importedAt=="string"});if(n.length!==o.length)throw new Error("one or more project entries are invalid");return n}catch(r){throw new Error(`Imported-project registry is invalid: ${t$1}`,{cause:r})}}async function He(e,t){if(t.length===0)return;let r=ie(e);await a(`${r}.lock`,async()=>{let o=await I(e),n=new Map;for(let c of o)n.set(c.path,c);for(let c of t)n.set(c.path,c);let i=Array.from(n.values()).sort((c,u)=>c.name.localeCompare(u.name)).map(c=>({...c}));await ce(r,{version:1,updatedAt:new Date().toISOString(),projects:i});},{timeoutMs:3e4,staleMs:6e4,purpose:"imported-projects-registry-upsert"});}async function Je(e,t){if(t.length===0)return;let r=ie(e);await a(`${r}.lock`,async()=>{let o=await I(e),n=new Set(t.map(c=>m.resolve(c))),i=o.filter(c=>!n.has(m.resolve(c.path)));await ce(r,{version:1,updatedAt:new Date().toISOString(),projects:i});},{timeoutMs:3e4,staleMs:6e4,purpose:"imported-projects-registry-remove"});}var ze="workspace-dependency-graph.v1",pe=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"],de=["inferred","contract","manual"];var v=i.workspaceContract,Ee=e.contractVerify,_=h.workspaceContract.schemaVersion,ve=f.contractVerify,N=class extends Error{constructor(r){super(`Workspace contract verification failed: ${r.violations.join("; ")}`);this.verification=r;this.name="WorkspaceContractVerificationError";}verification};function fe(e){return e.replace(/\\/g,"/")}function z(e){let t=fe(e).trim();return !t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0")?false:!t.split("/").filter(Boolean).some(r=>r===".."||r===".")}function le(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||t}function je(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function ue(e){let r=(Array.isArray(e.ports)?e.ports:[]).map(i=>{if(!i||typeof i!="object"||Array.isArray(i))return null;let c=i,u=Number(c.port);if(!Number.isInteger(u)||u<1||u>65535)return null;let g=c.protocol==="https"||c.protocol==="grpc"||c.protocol==="tcp"||c.protocol==="udp"?c.protocol:"http";return {name:typeof c.name=="string"&&c.name.trim()?c.name:"http",port:u,protocol:g}}).filter(i=>i!==null);if(r.length>0)return r;let o=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,n=Number(e.port??o?.default_port);return Number.isInteger(n)&&n>=1&&n<=65535?[{name:"http",port:n,protocol:"http"}]:[]}async function be(e){let t=m__default.join(e,"Dockerfile");if(!await k.pathExists(t))return [];try{let r=await k.readFile(t,"utf8"),o=new Map;for(let n of r.matchAll(/^\s*EXPOSE\s+(.+)$/gim))for(let i of n[1].split(/\s+/)){let c=i.match(/^(\d{1,5})(?:\/(tcp|udp))?$/i),u=Number(c?.[1]);if(!c||!Number.isInteger(u)||u<1||u>65535)continue;let g=c[2]?.toLowerCase();o.set(u,{name:"http",port:u,protocol:g==="udp"?"udp":"http"});}return [...o.values()].sort((n,i)=>n.port-i.port)}catch{return []}}async function D(e){for(let t of e)if(await k.pathExists(t))return t;return null}async function We(e){for(let t$1 of t(e,"workspace.json"))try{let r=await k.readJson(t$1);return {name:typeof r.workspace_name=="string"&&r.workspace_name.trim()||typeof r.name=="string"&&r.name.trim()||m__default.basename(e),profile:typeof r.profile=="string"?r.profile:void 0}}catch{}return {name:m__default.basename(e)}}async function Se(e){let t=[],r=[e],o=new Set,n=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;r.length>0;){let i=r.shift();if(!i||o.has(i))continue;o.add(i);let c=await D(u(i,"project.json")),u$1=await D(u(i,"context.json"));if(c||u$1){t.push(c??u$1??"");continue}let g;try{g=await k.readdir(i,{withFileTypes:true});}catch{continue}for(let d of g)!d.isDirectory()||n.has(d.name)||a$1(d.name)||r.push(m__default.join(i,d.name));}return t.sort()}function Ae(e){let t=(e||"").toLowerCase();if(t.includes("fastapi"))return "fastapi";if(t.includes("nestjs"))return "nestjs";if(t.includes("springboot"))return "springboot";if(t.includes("gofiber"))return "fiber";if(t.includes("gogin"))return "gin"}function Re(e,t){let r=(e||"").toLowerCase(),o=(t||"").toLowerCase();return r.includes("vscode-extension")?null:r.includes("fastapi")?8e3:r.includes("nestjs")?3e3:r.includes("springboot")?8080:r.includes("gofiber")?3e3:r.includes("gogin")?8080:r.startsWith("adopted.")?null:o==="node"?3e3:o==="python"?8e3:o==="java"||o==="go"?8080:null}function U(e,t){let r=e;for(;t.has(r)&&r<65535;)r+=1;return r}function B(e,t,r){let o=e!==void 0&&e.source===void 0,n=Re(t.kit,t.runtime),i=e?.ports||[],c=t.ports||[],u=(t.kit||"").toLowerCase().includes("vscode-extension"),g=t.source==="adopted-local"&&e?.source!==void 0,d=t.source!==void 0&&e?.source!==void 0,p=(u&&c.length===0?[]:g?c.length>0?c:n?[{name:"http",port:U(n,r),protocol:"http"}]:[]:i.length>0?i:c.length>0?c:n?[{name:"http",port:U(n,r),protocol:"http"}]:[]).map(w=>({...w,port:U(w.port,r)}));for(let w of p)r.add(w.port);let f={...t,...e,slug:e?.slug||t.slug,relativePath:o&&e?.relativePath&&z(e.relativePath)?e.relativePath:t.relativePath,source:o&&e?.source||t.source,relationship:o&&e?.relationship||t.relationship,externalPath:o&&e?.externalPath||t.externalPath,runtime:d?t.runtime:e?.runtime||t.runtime,framework:d?t.framework:e?.framework||t.framework,kit:d?t.kit:e?.kit||t.kit,modules:e?.modules?.length?e.modules:t.modules,ports:p,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:e?.contracts?.env||[]}},h=JSON.stringify(e||null)!==JSON.stringify(f);return {project:f,changed:h}}async function he(e){let t=m__default.resolve(e.workspacePath),r=await We(t),o=await Se(t),n=await I(t),i=new Map(n.map(s=>[m__default.resolve(s.path),s])),c=[];for(let s of n){let p=m__default.resolve(s.path),f=await D(u(p,"project.json"))??await D(u(p,"context.json"));!f||o.some(h=>m__default.resolve(h)===m__default.resolve(f))||c.push({projectJsonPath:f,registryEntry:s});}let u$1=[],g=[...o.map(s=>({projectJsonPath:s,registryEntry:i.get(m__default.resolve(m__default.dirname(m__default.dirname(s))))})),...c];for(let{projectJsonPath:s,registryEntry:p}of g){let f=m__default.dirname(m__default.dirname(s)),h=fe(m__default.relative(t,f)),w=p!==void 0&&!z(h),C=le(p?.name||m__default.basename(f),m__default.basename(f)),b=w?`external/${C}`:h||C,P=await k.readJson(s),a=typeof P.kit_name=="string"&&P.kit_name||typeof P.kit=="string"&&P.kit||void 0,E=j(P)?m$1(f,P):void 0,j$1=E!==void 0&&E.key!=="unknown",T=j$1?E.runtime:typeof P.runtime=="string"?P.runtime:void 0,y=j$1?E.key:typeof P.framework=="string"&&P.framework||Ae(a),$=p?.relationship==="adopted"?"adopted":"imported",K=j$1?`${$}.${E.key}`:a;u$1.push({slug:p?.name||b||m__default.basename(f),relativePath:b,source:p?.source??"workspace",relationship:p?.relationship,externalPath:w?f:void 0,runtime:T,framework:y,kit:K,modules:je(P.modules),ports:ue(P).length>0?ue(P):await be(f),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}let d=new Map;for(let s of u$1){let p=le(s.slug,s.relativePath),f=d.get(p);(!f||f.source!=="workspace"&&s.source==="workspace")&&d.set(p,s);}return {schemaVersion:_,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:r,projects:[...d.values()]}}async function dt(e){let t=m__default.resolve(e.outputPath||a$2(e.workspacePath,v));if(await k.pathExists(t)&&e.force!==true)throw new Error(`Workspace contract already exists: ${t}. Use --force to overwrite.`);let r=await he({workspacePath:e.workspacePath,now:e.now}),o=new Set,n={...r,projects:r.projects.map(c=>B(void 0,c,o).project)},i=await Pe({workspacePath:e.workspacePath,contractPath:t,contract:n});if(e.strict&&i.status==="failed")throw new N(i);return await ke({workspacePath:e.workspacePath,contractPath:t,contract:n,now:e.now}),{contractPath:t,contract:n}}async function lt(e){let t=m__default.resolve(e.workspacePath),r=a$2(t,v),o=await d(t,v)??r,n=await he({workspacePath:t,now:e.now}),i=await k.pathExists(o)?await k.readJson(o):null,c=new Map((i?.projects||[]).map(h=>[h.slug,h])),u=new Set,g=[],d$1=[],s=[];for(let h of n.projects){let w=c.get(h.slug),C=B(w,h,u);w?C.changed&&d$1.push(h.slug):g.push(h.slug),s.push(C.project),c.delete(h.slug);}for(let h of c.values()){if(h.source)continue;let w=B(h,h,u);s.push(w.project);}let p={schemaVersion:_,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...i?.workspace||{},...n.workspace,name:n.workspace.name||i?.workspace?.name||m__default.basename(t)},projects:s.sort((h,w)=>h.slug.localeCompare(w.slug))},f=await Pe({workspacePath:t,contractPath:r,contract:p});if(e.strict&&f.status==="failed")throw new N(f);return await ke({workspacePath:t,contractPath:r,contract:p,now:e.now}),{contractPath:r,contract:p,addedProjects:g,updatedProjects:d$1,verification:f}}async function me(e){return await k.pathExists(e)?{exists:true,contents:await k.readFile(e)}:{exists:false}}async function ge(e,t){if(!t.exists){await k.remove(e);return}await k.outputFile(e,t.contents);}async function ke(e){let{buildWorkspaceRegistrySummary:t,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:r}=await import('./workspace-registry-summary-QVSJKKTX.js'),o=await t(e.workspacePath,{now:e.now,contract:e.contract}),n=a$2(e.workspacePath,r),i=c=>{if(!c||typeof c!="object"||Array.isArray(c))return JSON.stringify(c);let{generatedAt:u,...g}=c;return JSON.stringify(g)};if(await k.pathExists(e.contractPath)&&await k.pathExists(n)){let[c,u]=await Promise.all([k.readJson(e.contractPath),k.readJson(n)]);if(i(c)===i(e.contract)&&i(u)===i(o))return}b(v,e.contract),b(r,o),await c$1(e.workspacePath,v,async()=>{let[c,u]=await Promise.all([me(e.contractPath),me(n)]);try{if(e.contractPath===a$2(e.workspacePath,v)?await e$1(e.workspacePath,v,e.contract):(await k.ensureDir(m__default.dirname(e.contractPath)),await k.writeJson(e.contractPath,e.contract,{spaces:2})),process.env.WORKSPAI_TEST_FAIL_WORKSPACE_REGISTRY_PUBLISH==="1")throw new Error("Injected workspace registry summary publication failure.");await e$1(e.workspacePath,r,o);}catch(g){let s=(await Promise.allSettled([ge(e.contractPath,c),ge(n,u)])).filter(p=>p.status==="rejected");throw s.length>0?new AggregateError([g,...s.map(p=>p.reason)],"Workspace contract publication failed and rollback was incomplete."):g}});}async function we(e){let t=e.contractPath??(await d(e.workspacePath,v)||a$2(e.workspacePath,v)),r=await k.readJson(t);return {contractPath:t,contract:r}}var xe={metadata:[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json"],manifests:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","pyproject.toml","poetry.lock","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","Gemfile","composer.json"],entrypoints:["src/main.ts","src/index.ts","src/app.ts","src/main.js","src/index.js","main.py","app/main.py","manage.py","main.go","cmd/main.go","Program.cs"],apiSpecifications:["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"],infrastructure:["Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","k8s","kubernetes","terraform"],documentation:["README.md","ARCHITECTURE.md","CONTRIBUTING.md","docs"]};function _e(e,t){return t.externalPath?m__default.resolve(t.externalPath):m__default.resolve(e,t.relativePath)}async function Ge(e){let t={metadata:[],manifests:[],entrypoints:[],apiSpecifications:[],infrastructure:[],documentation:[]};for(let[r,o]of Object.entries(xe))for(let n of o)await k.pathExists(m__default.join(e,n))&&t[r].push(n);try{let r=await k.readdir(e,{withFileTypes:true});for(let o of r)o.isFile()&&(o.name.endsWith(".csproj")||o.name.endsWith(".sln"))&&t.manifests.push(o.name),o.isFile()&&o.name.endsWith(".tf")&&t.infrastructure.push(o.name);}catch{}for(let r of Object.values(t))r.sort((o,n)=>o.localeCompare(n));return t}function x(e){return !e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e).sort((t,r)=>t.localeCompare(r))}async function Oe(e){try{let t=await k.readJson(m__default.join(e,"package.json")),r={runtime:x(t.dependencies),development:x(t.devDependencies),peer:x(t.peerDependencies),optional:x(t.optionalDependencies)};return {...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{},...typeof t.private=="boolean"?{private:t.private}:{},scripts:x(t.scripts),dependencies:r,dependencyCount:new Set(Object.values(r).flat()).size}}catch{return}}async function Ie(e){for(let t of [".env.example",".env.sample",".env.template"])try{return (await k.readFile(m__default.join(e,t),"utf8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("#")&&o.includes("=")).map(o=>o.slice(0,o.indexOf("=")).trim()).filter(o=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)).sort((o,n)=>o.localeCompare(n))}catch{}return []}function Ne(e,t){try{let r=z$1(e);if(r.engine!=="unknown")return r;let o=k.pathExistsSync(m__default.join(e,"package.json"))?"npm":k.pathExistsSync(m__default.join(e,"pyproject.toml"))?"python":k.pathExistsSync(m__default.join(e,"requirements.txt"))?"pip":"unknown";return {...r,engine:o,runtime:t.runtime??r.runtime,framework:t.framework??r.framework,frameworkDisplayName:t.framework??r.frameworkDisplayName}}catch{return {schemaVersion:1,scope:"project",projectRoot:null,engine:"unknown",runtime:"unknown",runtimeCandidates:["unknown"],compositeRuntime:false,lifecycleCoverage:"complete",framework:"unknown",frameworkDisplayName:"Unknown",frameworkConfidence:"low",frameworkSupportTier:"observed",runtimeSupportTier:"observed",runtimeDoctorSupport:"observed",moduleSupport:false,fleetStages:[],localOnlyCommands:[],commandMap:{},supportedCommands:[],unsupportedCommands:[],globalCommands:[]}}}function De(e,t,r){let o=e.projects.map(n=>({id:n.slug,path:n.relativePath,runtime:n.runtime,framework:n.framework}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:t,nodes:o,edges:[],stats:{nodeCount:o.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:o.length,connectedNodeCount:0,density:0,edgeCoverageRatio:o.length===0?1:0,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:[{code:"graph.enrichment.failed",severity:"warning",message:r,recommendation:"Review project manifests and graph overrides, then rerun workspace contract graph."}]}}async function ut(e$1){let{contractPath:t,contract:r}=await we(e$1),o=e$1.now??new Date,n=o.toISOString(),{buildWorkspaceModel:i,workspaceModelProjectTopology:c}=await import('./workspace-model-VSVKLX7M.js'),{hashWorkspaceModel:u}=await import('./workspace-model-hash-ZXYPIGCW.js'),g=await i({workspacePath:e$1.workspacePath,includeEvidence:false,now:o}),d=c(g)??De(r,n,"The canonical Workspace Model did not provide a project dependency topology."),s=new Map(d.nodes.map(a=>[a.id,a.operationalProfile])),{buildWorkspaceKnowledgeGraph:p}=await import('./workspace-knowledge-graph-V2EAYDCL.js'),f=await p({workspacePath:e$1.workspacePath,workspace:{name:g.workspace.name,...g.workspace.profile?{profile:g.workspace.profile}:{}},contract:r,projectTopology:d,now:o,projects:g.projects.map(a=>({id:a.name,path:a.path,...a.absolutePath?{absolutePath:a.absolutePath}:{},runtime:a.runtime,runtimeCandidates:a.runtimeCandidates,framework:a.framework,...a.kit?{kit:a.kit}:{}})),source:{kind:"workspace-model",artifact:e.model,hashAlgorithm:"sha256",hash:u(g)}}),h=await Promise.all(r.projects.map(async a=>{let l=_e(e$1.workspacePath,a),[E,j,T]=await Promise.all([Ge(l),Oe(l),Ie(l)]),y=Ne(l,a);return {id:a.slug,label:a.slug,relativePath:a.relativePath,source:a.source,relationship:a.relationship,externalPath:a.externalPath,runtime:a.runtime??y.runtime,framework:a.framework??y.framework,kit:a.kit,modules:a.modules,ports:a.ports,apis:a.contracts.apis,owns:a.contracts.owns,env:[...new Set([...a.contracts.env,...T])].sort(($,K)=>$.localeCompare(K)),contracts:{owns:[...a.contracts.owns],apis:[...a.contracts.apis],publishes:[...a.contracts.publishes],consumes:[...a.contracts.consumes],dependsOn:[...a.contracts.dependsOn],env:[...a.contracts.env]},capabilities:{engine:y.engine,supportTier:y.frameworkSupportTier,runtimeSupportTier:y.runtimeSupportTier,doctorSupport:y.runtimeDoctorSupport,moduleSupport:y.moduleSupport,fleetStages:[...y.fleetStages],localOnlyCommands:[...y.localOnlyCommands],supportedCommands:[...y.supportedCommands]},files:E,...j?{package:j}:{},...s.get(a.slug)?{operationalProfile:s.get(a.slug)}:{}}})),w=new Set(h.map(a=>a.id)),C=new Map,b=[];for(let a of r.projects){for(let l of a.contracts.dependsOn||[])w.has(l)&&b.push({from:l,to:a.slug,type:"dependency",label:"dependsOn"});for(let l of a.contracts.publishes||[])C.has(l)||C.set(l,new Set),C.get(l)?.add(a.slug);}for(let a of r.projects)for(let l of a.contracts.consumes||[]){let E=C.get(l);if(E)for(let j of E)j!==a.slug&&b.push({from:j,to:a.slug,type:"event",label:l});}let P={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:r.workspace,generatedAt:n,nodes:h.sort((a,l)=>a.id.localeCompare(l.id)),edges:b.sort((a,l)=>`${a.from}:${a.to}:${a.type}:${a.label}`.localeCompare(`${l.from}:${l.to}:${l.type}:${l.label}`)),dependencyGraph:d,knowledgeGraph:f,semantics:{legacyEdges:"producer-to-consumer",dependencyGraphEdges:"consumer-to-dependency"},summary:{projectCount:h.length,dependencyEdges:b.filter(a=>a.type==="dependency").length,eventEdges:b.filter(a=>a.type==="event").length,portCount:h.reduce((a,l)=>a+l.ports.length,0),apiCount:h.reduce((a,l)=>a+l.apis.length,0),relationshipEdges:d.stats.edgeCount,inferredEdges:d.stats.inferredEdges,authoritativeEdges:d.stats.authoritativeEdges,orphanProjects:d.stats.orphanCount,hotspotProjects:d.stats.hotspotCount,evidenceCoverageRatio:d.stats.evidenceCoverageRatio,edgeCoverageRatio:d.stats.edgeCoverageRatio,connectedProjects:d.stats.connectedNodeCount,lowConfidenceEdges:d.stats.lowConfidenceEdges,hasCycle:d.stats.hasCycle,manifestCount:h.reduce((a,l)=>a+l.files.manifests.length,0),entrypointCount:h.reduce((a,l)=>a+l.files.entrypoints.length,0),diagnostics:d.diagnostics?.length??0,relationshipKinds:Object.fromEntries(pe.map(a=>[a,d.edges.filter(l=>l.kind===a).length])),relationshipSources:Object.fromEntries(de.map(a=>[a,d.edges.filter(l=>l.source===a).length])),entityCount:f.quality.entityCount,knowledgeRelations:f.quality.relationCount,proofCount:f.quality.proofCount,providerCount:f.providers.length,knowledgeUnknowns:f.quality.unknownCount}};return {contractPath:t,graph:P}}async function Pe(e){let t=e.contract?{contractPath:e.contractPath??a$2(e.workspacePath,v),contract:e.contract}:await we(e),{contractPath:r,contract:o}=t,n=[],i=[];o.kind!=="rapidkit.workspace.contract"&&n.push("Contract kind must be rapidkit.workspace.contract."),o.schemaVersion!==_&&n.push(`Contract schemaVersion must be ${_}.`),o.workspace?.name||n.push("Contract workspace.name is required."),Array.isArray(o.projects)||n.push("Contract projects must be an array.");let c=new Set,u=new Map;for(let s of o.projects||[]){if(!s.slug){n.push("Every project must declare slug.");continue}c.has(s.slug)&&n.push(`Duplicate project slug: ${s.slug}.`),c.add(s.slug),s.relativePath?z(s.relativePath)||n.push(`Project ${s.slug} declares unsafe relativePath: ${s.relativePath}.`):n.push(`Project ${s.slug} must declare relativePath.`),s.externalPath&&(s.relationship==="adopted"||s.source==="adopted-local"||s.source==="local-folder"||s.source==="git-url"||n.push(`Project ${s.slug} declares externalPath without imported/adopted provenance.`),m__default.isAbsolute(s.externalPath)||n.push(`Project ${s.slug} declares non-absolute externalPath.`));for(let p of s.ports||[]){(!Number.isInteger(p.port)||p.port<1||p.port>65535)&&n.push(`Project ${s.slug} declares invalid port: ${p.port}.`);let f=u.get(p.port);f&&n.push(`Port ${p.port} is claimed by both ${f} and ${s.slug}.`),u.set(p.port,s.slug);}for(let p of s.contracts?.apis||[])(!p.name?.trim()||!p.basePath?.startsWith("/"))&&n.push(`Project ${s.slug} declares invalid API contract.`);for(let p of [...s.contracts?.publishes||[],...s.contracts?.consumes||[]])p.trim()||n.push(`Project ${s.slug} declares an empty event contract.`);for(let p of s.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(p)||n.push(`Project ${s.slug} declares invalid env contract: ${p}.`);for(let p of s.contracts?.dependsOn||[])c.has(p);}for(let s of o.projects||[])for(let p of s.contracts?.dependsOn||[])c.has(p)||n.push(`Project ${s.slug} depends on unknown project: ${p}.`);i.push({id:"schema",status:o.kind==="rapidkit.workspace.contract"&&o.schemaVersion===_?"passed":"failed",message:"Contract schema and kind are valid."}),i.push({id:"projects",status:Array.isArray(o.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(o.projects)?o.projects.length:0} project(s).`}),i.push({id:"ports",status:n.some(s=>s.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:n.some(s=>s.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:n.some(s=>s.includes("unsafe relativePath")||s.includes("invalid API contract")||s.includes("event contract")||s.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let g=await l(e.workspacePath);if(g.moduleCount>0){for(let s of g.issues)n.push(`${m__default.basename(s.projectRoot)}: ${s.message} (slug=${s.slug})`);i.push({id:"module-paths",status:g.status,message:g.status==="passed"?`All ${g.moduleCount} registered module(s) resolve under canonical paths.`:`${g.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&i.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:n.length>0?"failed":"passed",contractPath:r,projectCount:Array.isArray(o.projects)?o.projects.length:0,checks:i,violations:n}}async function mt(e){let t=m__default.resolve(e.workspacePath),r={schemaVersion:ve,generatedAt:e.generatedAt??new Date().toISOString(),status:e.result.status,contractPath:e.result.contractPath,projectCount:e.result.projectCount,checks:e.result.checks,violations:e.result.violations};return e$1(t,Ee,se(r))}
2
+ export{I as a,He as b,Je as c,se as d,ze as e,pe as f,v as g,Ee as h,_ as i,ve as j,N as k,Se as l,he as m,dt as n,lt as o,we as p,ut as q,Pe as r,mt as s};
@@ -0,0 +1 @@
1
+ import {f}from'./chunk-6UNATTB7.js';var i=f.knowledgeGraph,s=["workspace","project","service","api","endpoint","schema","protocol","language","package","runtime-unit","lifecycle-stage","module","file","symbol","database","queue","container","deployment","pipeline","environment","document","decision","test-suite","owner"],p=["contains","defines","imports","depends-on","exposes","implements","implements-protocol","uses-language","equivalent-to","calls","reads-from","writes-to","publishes","consumes","deploys","runs-on","routes-to","documents","decided-by","tests","owns","generated-by","generated-from","configured-by","references"],a=["extracted","inferred","authored"],d=["authoritative","corroborated","observed","ambiguous"],c=["high","medium","low"],l=["fresh","stale","unknown"];export{i as a,s as b,p as c,a as d,d as e,c as f,l as g};
@@ -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-7FF5EOIO.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};
@@ -0,0 +1,2 @@
1
+ import {b}from'./chunk-UJXE4UAX.js';import {c,b as b$1}from'./chunk-5TY74LLW.js';var d="cli-log-event-v1";var l="unknown-run";function y(e){l=e;}function v(){return l}function L(e){return {schemaVersion:d,runId:v(),timestamp:new Date().toISOString(),level:e.level,event:e.event,component:e.component,message:e.message,...e.command?{command:e.command}:{},...e.metadata&&Object.keys(e.metadata).length>0?{metadata:f(e.metadata)}:{}}}function S(e){E(e),b()&&u(L(e));}function E(e){if(e.event==="progress"){let r=typeof e.metadata?.phase=="string"?e.metadata.phase:`${e.component}.progress`,n=String(e.metadata?.intelligenceMilestoneStatus??e.metadata?.status??"started"),t=n==="succeeded"||n==="passed"?"succeeded":n==="failed"?"failed":n==="blocked"?"blocked":n==="skipped"?"skipped":n==="warn"||n==="warning"?"warned":"running",o=Number(e.metadata?.completed??e.metadata?.stepNum),s=Number(e.metadata?.total),a=Number(e.metadata?.percent);c({blockId:r,status:t,message:e.message,component:e.component,...Number.isFinite(o)||Number.isFinite(s)||Number.isFinite(a)?{progress:{...Number.isFinite(o)?{completed:o}:{},...Number.isFinite(s)?{total:s}:{},...Number.isFinite(a)?{percent:a}:{}}}:{},attributes:e.metadata});return}(e.level==="warn"||e.level==="error")&&b$1({kind:e.level==="error"?"operation.failed":"warning.detected",status:e.level==="error"?"failed":"warned",component:e.component,message:e.message,attributes:e.metadata});}function u(e){process.stderr.write(`${JSON.stringify(e)}
2
+ `);}function f(e){let r={};for(let[n,t]of Object.entries(e))if(t!==void 0){if(t instanceof Error){r[n]={name:t.name,message:t.message};continue}if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"){r[n]=t;continue}if(Array.isArray(t)){r[n]=t.map(o=>typeof o=="string"||typeof o=="number"||typeof o=="boolean"?o:String(o));continue}r[n]=String(t);}return r}export{d as a,y as b,v as c,S as d,u as e};
@@ -1 +1 @@
1
- import {e,i,p,f as f$1,g}from'./chunk-NZ3WZYD5.js';var l="workspai-workspace-intelligence-chain-v1",u="contracts/workspace-intelligence-chain.v1.json";function f(){let e$1=e,t=p,s=[{id:"model",ordinal:1,phase:"understand",label:"Model",command:[...t.model.command],consumes:["workspace markers","project metadata","registry","contract","policies"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules","existing-evidence"],consumesArtifacts:[],produces:[...t.model.produces],dependsOn:[],exitPolicy:"stop-on-error",purpose:"Build the canonical current model and its structurally bound, derived Knowledge Graph."},{id:"diff",ordinal:2,phase:"change",label:"Diff",command:[...t.diff.command],consumes:[e$1.model,e$1.snapshot],inputRefs:["changes","model-baseline"],consumesArtifacts:[e$1.model,e$1.snapshot],produces:[...t.diff.produces],dependsOn:["model"],exitPolicy:"stop-on-error",purpose:"Describe structural change against the selected baseline."},{id:"impact",ordinal:3,phase:"change",label:"Impact",command:[...t.impact.command],consumes:[e$1.model,e$1.diff],inputRefs:[],consumesArtifacts:[e$1.model,e$1.diff],produces:[...t.impact.produces],dependsOn:["diff"],exitPolicy:"stop-on-error",purpose:"Calculate transitive blast radius over the workspace graph."},{id:"doctor-evidence",ordinal:4,phase:"evidence",label:"Doctor Evidence",command:[...t["doctor-evidence"].command],consumes:["workspace runtime and project health signals"],inputRefs:["projects-repositories","runtime-dependencies","existing-evidence"],consumesArtifacts:[],produces:[...t["doctor-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh health evidence after the impact artifact exists."},{id:"contract-evidence",ordinal:5,phase:"evidence",label:"Contract Evidence",command:[...t["contract-evidence"].command],consumes:[i.workspaceContract],inputRefs:["workspace-rules"],consumesArtifacts:[],produces:[...t["contract-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh structural contract evidence without hiding failed verdicts."},{id:"analyze-evidence",ordinal:6,phase:"evidence",label:"Analyze Evidence",command:[...t["analyze-evidence"].command],consumes:[e$1.model,"workspace runtime and dependency signals"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules"],consumesArtifacts:[e$1.model],produces:[...t["analyze-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh analysis evidence required by the release-readiness gate."},{id:"readiness-evidence",ordinal:7,phase:"evidence",label:"Readiness Evidence",command:[...t["readiness-evidence"].command],consumes:["doctor, analysis, runtime, and release signals"],inputRefs:["runtime-dependencies","existing-evidence"],consumesArtifacts:[e$1.doctor,e$1.contractVerify,e$1.analyze],produces:[...t["readiness-evidence"].produces],dependsOn:["doctor-evidence","contract-evidence","analyze-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh release-readiness evidence before the definitive gate."},{id:"verify",ordinal:8,phase:"gate",label:"Verify",command:[...t.verify.command],consumes:[e$1.impact,e$1.doctor,e$1.contractVerify,e$1.readiness],inputRefs:[],consumesArtifacts:[e$1.impact,e$1.doctor,e$1.contractVerify,e$1.readiness],produces:[...t.verify.produces],dependsOn:["impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Emit the definitive evidence-backed workspace gate."},{id:"context",ordinal:9,phase:"ground",label:"Agent Context",command:[...t.context.command],consumes:[e$1.model,e$1.impact,e$1.verify],inputRefs:[],consumesArtifacts:[e$1.model,e$1.impact,e$1.verify],produces:[...t.context.produces],dependsOn:["verify"],exitPolicy:"stop-on-error",purpose:"Build compact agent context from the same verified evidence."},{id:"agent-sync",ordinal:10,phase:"distribute",label:"Agent Grounding",command:[...t["agent-sync"].command],consumerArgs:{vscode:["--target","vscode"]},consumes:[e$1.agentContext],inputRefs:[],consumesArtifacts:[e$1.agentContext],produces:[...t["agent-sync"].produces],dependsOn:["context"],exitPolicy:"stop-on-error",purpose:"Distribute one context into portable agent and IDE surfaces."},{id:"explain",ordinal:11,phase:"explain",label:"Explain",command:[...t.explain.command],consumes:[e$1.verify,e$1.impact],inputRefs:[],consumesArtifacts:[e$1.verify,e$1.impact],produces:[...t.explain.produces],dependsOn:["verify"],exitPolicy:"continue-on-structured-verdict",purpose:"Translate evidence and blockers into a human and agent-readable narrative."}];return {schemaVersion:l,name:"Workspace Intelligence Chain",contractPath:u,invariant:"Every consumer must preserve step identity, dependencies, artifact flow, and verdict semantics; presentation may change, chain meaning may not.",invariants:["Missing or unreadable input is unknown or unavailable; it must not be presented as verified absence.","Freshness and provenance travel with evidence and must not be discarded by projections.","The current graph is an evidence-backed workspace knowledge graph with bounded source intelligence, not a complete cross-language symbol or call graph.","Simple and standard presentations summarize the contract; their contractRefs must preserve complete traceability.","Conditional provider outputs must be resolved through their dedicated inventory contract.","Auxiliary capabilities expose or refresh intelligence but are not mandatory execution-chain steps.","Canonical step commands are stage-pure: they must not implicitly execute a downstream chain step or regenerate an upstream artifact.","Canonical JSON artifacts must satisfy their registered schema both when produced and when consumed across CLI, MCP, IDE, and CI trust boundaries.","Schema validity is necessary but not sufficient: hashes, embedded models, summaries, counts, graph statistics, and artifact references must remain semantically coherent.","Persisted impact evidence must be rejected as stale when the current workspace model or Git observation no longer matches its embedded diff.","Canonical artifact replacement must be atomic and workspace-contained; an interrupted or denied write must preserve the last valid artifact.","Concurrent history updates must be serialized without silently dropping entries, and invalid history must never be overwritten as if it were absent.","The canonical global registry is ~/.workspai/workspaces.json; ~/.rapidkit/workspaces.json is a non-authoritative compatibility mirror for legacy consumers and must not diverge after a CLI registry mutation."],semantics:{workspace:"The governed operating boundary that relates one or more projects and repositories to shared metadata, policies, contracts, evidence, and consumers.",repository:"A source-control boundary that may contain one or more projects and may live inside or outside the workspace root.",project:"A discoverable build or runtime unit with its own path, metadata or observable manifests, command capabilities, and evidence.",evidence:"A sourced observation or generated verification result with provenance and freshness; evidence may be consumed by a later run.",artifact:"A durable generated file that another command or consumer can read without parsing terminal prose.",gate:"A structured verdict with reasons and exit semantics derived from current evidence."},workspaceLifecycle:{ingestionRoutes:[{id:"create",label:"Create",commands:["create workspace","create project"],result:"Create a workspace or supported project and write canonical Workspai metadata."},{id:"adopt",label:"Adopt",commands:["adopt"],result:"Register an existing project in place without requiring source relocation."},{id:"import",label:"Import",commands:["import","workspace import"],result:"Attach an existing project or repository path to the workspace inventory."}],durableState:[{id:"workspace-identity",paths:[".workspai-workspace",".workspai/workspace.json"],purpose:"Identify the workspace boundary, profile, and canonical root."},{id:"project-inventory",paths:[".workspai/project.json",".workspai/context.json",".workspai/adopt.json","~/.workspai/workspaces.json","~/.rapidkit/workspaces.json (legacy compatibility mirror)"],purpose:"Record native, adopted, imported, and globally registered project locations while preserving a non-authoritative mirror for legacy extension discovery."},{id:"governance",paths:[".workspai/policies.yml",i.workspaceContract],purpose:"Define workspace policy and explicit structural relationships."},{id:"graph-overrides",paths:[".workspai/workspace-graph.overrides.json"],purpose:"Provide explicit dependency edges that override inferred relationships."}],rule:"Create, adopt, and import are ingestion routes, not intelligence facts. Their durable state becomes observable input to Model."},runtimeRegistry:{authority:"contracts/workspace-intelligence-runtime-registry.ts",artifacts:Object.entries(e).map(([r,a])=>({id:r,path:a,schemaVersion:f$1[r],schemaContract:g[r]}))},executionEnvelope:{rule:"Sync and baseline resolution are deterministic execution prerequisites, not canonical intelligence stages; every run reports them separately and preserves the exact canonical stage sequence.",operations:[{id:"sync",executionPoint:"before:model",artifacts:[i.workspaceContract,i.workspaceRegistry],failurePolicy:"stop-and-report",purpose:"Reconcile portable workspace inventory and contract inputs before modeling."},{id:"baseline",executionPoint:"after:model-before:diff",artifacts:[e$1.snapshot],failurePolicy:"stop-and-report",purpose:"Create an initial structural baseline when absent or reuse the existing baseline before Diff."}],report:{artifact:e$1.intelligenceRun,schemaVersion:f$1.intelligenceRun,invariant:"The report must preserve exact preflight and stage order, registry-owned artifacts, failure propagation, and aggregate status/exit semantics."}},boundaries:{inputs:[{id:"projects-repositories",label:"Projects and repositories",sources:["projects","repositories","services","modules","imported paths"],entersAt:"model"},{id:"runtime-dependencies",label:"Runtime and dependencies",sources:["runtime manifests","lockfiles","scripts","framework markers","package dependencies","bounded multi-language source observations for supported file extensions"],entersAt:"model"},{id:"workspace-rules",label:"Workspace rules",sources:["workspace markers","registry","project metadata","contracts","policies","ownership","graph overrides"],entersAt:"model"},{id:"changes",label:"Changes",sources:["repository state","git state","model baseline","workspace diff"],entersAt:"diff"},{id:"model-baseline",label:"Explicit model baseline",sources:[e$1.snapshot],entersAt:"diff"},{id:"existing-evidence",label:"Existing evidence",sources:["doctor reports","analysis reports","contract verification","release readiness","pipeline results","tests and runtime evidence","previous intelligence artifacts"],entersAt:"doctor-evidence"}],outputs:[{id:"understanding",label:"System understanding",artifacts:[e$1.model,e$1.knowledgeGraph,e$1.diff,e$1.impact],producedBy:["model","diff","impact"],inventory:"complete-for-chain"},{id:"governance-evidence",label:"Governance evidence",artifacts:[e$1.doctor,e$1.contractVerify,e$1.analyze,e$1.readiness,e$1.verify,e$1.history],producedBy:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify"],inventory:"complete-for-chain"},{id:"agent-grounding",label:"Agent grounding",artifacts:[e$1.agentContext,e$1.agentIndex,e$1.agentCustomizationPack,e$1.skillsIndex,e$1.agents],producedBy:["context","agent-sync"],inventory:"canonical-minimum",inventoryContract:"contracts/agent-customization-pack.v1.json"},{id:"explanations",label:"Explainable decisions",artifacts:[e$1.explain],producedBy:["explain"],inventory:"complete-for-chain"}],consumers:[{id:"developers",label:"Developers",channels:["CLI","reports","AGENTS.md"]},{id:"ci",label:"CI",channels:["JSON artifacts","exit codes","release gates"]},{id:"ides",label:"IDEs",channels:["synced contracts","extension","agent context"]},{id:"ai-agents",label:"AI agents",channels:["INDEX.json","context","skills","MCP"]}]},deliveryChannels:[{id:"artifacts",carries:["reports","models","context","grounding","skills"],authority:"canonical"},{id:"json-stdout",carries:["structured command results"],authority:"projection"},{id:"human-cli",carries:["summaries","diagnostics","next actions"],authority:"projection"},{id:"exit-codes",carries:["gate and command status"],authority:"projection"},{id:"watch-events",carries:["incremental workspace change events"],authority:"projection"},{id:"mcp",carries:["read-mostly access to current workspace artifacts"],authority:"projection"}],feedback:{from:["developers","ci","ides","ai-agents"],signals:["source commits","dependency updates","policy and contract edits","repairs","test and runtime results","agent action outcomes"],reentersThrough:["projects-repositories","runtime-dependencies","workspace-rules","changes","existing-evidence"],rule:"Consumer actions are not silently treated as truth. They re-enter as observable changes or evidence and must be modeled and verified again."},auxiliaryCapabilities:[{id:"graph",commands:["workspace graph emit","workspace graph explain","workspace graph entities","workspace graph evidence","workspace graph path","workspace graph search","workspace graph benchmark","workspace graph overlay","workspace graph dot","workspace graph mermaid","workspace graph jsonld","workspace graph graphml","workspace graph gexf"],reads:[e$1.model,e$1.knowledgeGraph],role:"Query the proof-backed graph derived from the canonical workspace model.",chainStep:false},{id:"evaluation",commands:["workspace eval init","workspace eval record","workspace eval status","workspace eval report","workspace eval compare"],reads:[e$1.evaluationLive,e$1.evaluationLastRun],produces:[e$1.evaluationLive,e$1.evaluationLastRun],role:"Measure model usage, activity, cost provenance, and verified outcomes without storing prompt or response bodies.",chainStep:false},{id:"watch",commands:["workspace watch"],reads:["workspace inputs",e$1.model],role:"Refresh the model incrementally and emit deterministic change events.",chainStep:false},{id:"mcp",commands:["workspace mcp serve"],reads:["workspace evidence artifacts"],role:"Expose read-mostly workspace evidence to compatible clients.",chainStep:false}],presentations:{simple:{layers:["inputs","intelligence","outputs","consumers"],nodes:[{id:"input-layer",kind:"inputs",label:"Input Layer",summary:"Projects \xB7 Repositories \xB7 Dependencies \xB7 Changes",contractRefs:["projects-repositories","runtime-dependencies","workspace-rules","changes","model-baseline","existing-evidence"]},{id:"workspace-intelligence",kind:"intelligence",label:"Workspace Intelligence",summary:"Model \xB7 Graph \xB7 Impact \xB7 Verify",contractRefs:s.map(r=>r.id)},{id:"agent-grounding",kind:"outputs",label:"Agent Grounding",summary:"AGENTS.md \xB7 Skills \xB7 Context",contractRefs:["agent-grounding"]},{id:"evidence-and-decisions",kind:"outputs",label:"Evidence Contracts",summary:"Reports \xB7 Artifacts \xB7 Gates",contractRefs:["understanding","governance-evidence","explanations"]},{id:"shared-consumers",kind:"consumers",label:"Shared Consumers",summary:"Developers \xB7 CI \xB7 IDEs \xB7 AI agents",contractRefs:["developers","ci","ides","ai-agents"]}],rule:"Use concrete user-facing language for first-contact explanations. Every input, output, consumer, and chain step must remain traceable through contractRefs even when details are summarized."},standard:{phases:["understand","change","evidence","gate","ground","distribute","explain"],nodes:[{id:"understand",label:"Understand",question:"What exists in the current workspace?",stepRefs:["model"]},{id:"change",label:"Change",question:"What changed, and what can it affect?",stepRefs:["diff","impact"]},{id:"evidence",label:"Evidence",question:"What health, contract, and readiness facts were observed?",stepRefs:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"]},{id:"gate",label:"Gate",question:"Is the current state acceptable and trustworthy?",stepRefs:["verify"]},{id:"ground",label:"Ground",question:"What should an agent know before acting?",stepRefs:["context"]},{id:"distribute",label:"Distribute",question:"Which durable agent and IDE surfaces receive that context?",stepRefs:["agent-sync"]},{id:"explain",label:"Explain",question:"Why did the system reach this result or verdict?",stepRefs:["explain"]}],rule:"Use for architecture education and product surfaces. Every phase must appear once and in order."},advanced:{steps:s.map(r=>r.id),requiredFields:["command","inputRefs","consumesArtifacts","produces","dependsOn","exitPolicy","purpose"],rule:"Use for implementers, adapters, IDEs, and CI. Preserve every step and its artifact and verdict semantics."}},steps:s,diagram:{direction:"TB",nodes:s.map(({id:r,label:a,phase:p})=>({id:r,label:a,phase:p})),edges:s.flatMap(r=>r.dependsOn.map(a=>({from:a,to:r.id,meaning:"required before"})))},consumers:{agents:{canonicalReadOrder:[e$1.agentIndex,i.goalIndex,i.goalPackLastRun,e$1.agentContext,e$1.skillsIndex,e$1.verify,e$1.impact,e$1.explain],entrypoints:[e$1.agents,".workspai/AGENT-GROUNDING.md"],rule:"Agents must cite current artifacts, preserve verified versus inferred status, and re-run the producing step when evidence is missing or stale."},ideAndCi:{requiredArtifacts:[e$1.model,e$1.knowledgeGraph,e$1.impact,e$1.verify],rule:"IDEs and CI must consume structured artifacts and verdict exit semantics rather than parse human help or terminal prose."},docsAndDiagrams:{rule:"Documentation and diagrams must derive labels, ordering, and edges from this contract and must not invent implemented steps."}}}}export{l as a,f as b};
1
+ import {e,i,p,f as f$1,g}from'./chunk-6UNATTB7.js';var l="workspai-workspace-intelligence-chain-v1",u="contracts/workspace-intelligence-chain.v1.json";function f(){let e$1=e,t=p,s=[{id:"model",ordinal:1,phase:"understand",label:"Model",command:[...t.model.command],consumes:["workspace markers","project metadata","registry","contract","policies"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules","existing-evidence"],consumesArtifacts:[],produces:[...t.model.produces],dependsOn:[],exitPolicy:"stop-on-error",purpose:"Build the canonical current model and its structurally bound, derived Knowledge Graph."},{id:"diff",ordinal:2,phase:"change",label:"Diff",command:[...t.diff.command],consumes:[e$1.model,e$1.snapshot],inputRefs:["changes","model-baseline"],consumesArtifacts:[e$1.model,e$1.snapshot],produces:[...t.diff.produces],dependsOn:["model"],exitPolicy:"stop-on-error",purpose:"Describe structural change against the selected baseline."},{id:"impact",ordinal:3,phase:"change",label:"Impact",command:[...t.impact.command],consumes:[e$1.model,e$1.diff],inputRefs:[],consumesArtifacts:[e$1.model,e$1.diff],produces:[...t.impact.produces],dependsOn:["diff"],exitPolicy:"stop-on-error",purpose:"Calculate transitive blast radius over the workspace graph."},{id:"doctor-evidence",ordinal:4,phase:"evidence",label:"Doctor Evidence",command:[...t["doctor-evidence"].command],consumes:["workspace runtime and project health signals"],inputRefs:["projects-repositories","runtime-dependencies","existing-evidence"],consumesArtifacts:[],produces:[...t["doctor-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh health evidence after the impact artifact exists."},{id:"contract-evidence",ordinal:5,phase:"evidence",label:"Contract Evidence",command:[...t["contract-evidence"].command],consumes:[i.workspaceContract],inputRefs:["workspace-rules"],consumesArtifacts:[],produces:[...t["contract-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh structural contract evidence without hiding failed verdicts."},{id:"analyze-evidence",ordinal:6,phase:"evidence",label:"Analyze Evidence",command:[...t["analyze-evidence"].command],consumes:[e$1.model,"workspace runtime and dependency signals"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules"],consumesArtifacts:[e$1.model],produces:[...t["analyze-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh analysis evidence required by the release-readiness gate."},{id:"readiness-evidence",ordinal:7,phase:"evidence",label:"Readiness Evidence",command:[...t["readiness-evidence"].command],consumes:["doctor, analysis, runtime, and release signals"],inputRefs:["runtime-dependencies","existing-evidence"],consumesArtifacts:[e$1.doctor,e$1.contractVerify,e$1.analyze],produces:[...t["readiness-evidence"].produces],dependsOn:["doctor-evidence","contract-evidence","analyze-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh release-readiness evidence before the definitive gate."},{id:"verify",ordinal:8,phase:"gate",label:"Verify",command:[...t.verify.command],consumes:[e$1.impact,e$1.doctor,e$1.contractVerify,e$1.readiness],inputRefs:[],consumesArtifacts:[e$1.impact,e$1.doctor,e$1.contractVerify,e$1.readiness],produces:[...t.verify.produces],dependsOn:["impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Emit the definitive evidence-backed workspace gate."},{id:"context",ordinal:9,phase:"ground",label:"Agent Context",command:[...t.context.command],consumes:[e$1.model,e$1.impact,e$1.verify],inputRefs:[],consumesArtifacts:[e$1.model,e$1.impact,e$1.verify],produces:[...t.context.produces],dependsOn:["verify"],exitPolicy:"stop-on-error",purpose:"Build compact agent context from the same verified evidence."},{id:"agent-sync",ordinal:10,phase:"distribute",label:"Agent Grounding",command:[...t["agent-sync"].command],consumerArgs:{vscode:["--target","vscode"]},consumes:[e$1.agentContext],inputRefs:[],consumesArtifacts:[e$1.agentContext],produces:[...t["agent-sync"].produces],dependsOn:["context"],exitPolicy:"stop-on-error",purpose:"Distribute one context into portable agent and IDE surfaces."},{id:"explain",ordinal:11,phase:"explain",label:"Explain",command:[...t.explain.command],consumes:[e$1.verify,e$1.impact],inputRefs:[],consumesArtifacts:[e$1.verify,e$1.impact],produces:[...t.explain.produces],dependsOn:["verify"],exitPolicy:"continue-on-structured-verdict",purpose:"Translate evidence and blockers into a human and agent-readable narrative."}];return {schemaVersion:l,name:"Workspace Intelligence Chain",contractPath:u,invariant:"Every consumer must preserve step identity, dependencies, artifact flow, and verdict semantics; presentation may change, chain meaning may not.",invariants:["Missing or unreadable input is unknown or unavailable; it must not be presented as verified absence.","Freshness and provenance travel with evidence and must not be discarded by projections.","The current graph is an evidence-backed workspace knowledge graph with bounded source intelligence, not a complete cross-language symbol or call graph.","Simple and standard presentations summarize the contract; their contractRefs must preserve complete traceability.","Conditional provider outputs must be resolved through their dedicated inventory contract.","Auxiliary capabilities expose or refresh intelligence but are not mandatory execution-chain steps.","Canonical step commands are stage-pure: they must not implicitly execute a downstream chain step or regenerate an upstream artifact.","Canonical JSON artifacts must satisfy their registered schema both when produced and when consumed across CLI, MCP, IDE, and CI trust boundaries.","Schema validity is necessary but not sufficient: hashes, embedded models, summaries, counts, graph statistics, and artifact references must remain semantically coherent.","Persisted impact evidence must be rejected as stale when the current workspace model or Git observation no longer matches its embedded diff.","Canonical artifact replacement must be atomic and workspace-contained; an interrupted or denied write must preserve the last valid artifact.","Concurrent history updates must be serialized without silently dropping entries, and invalid history must never be overwritten as if it were absent.","The canonical global registry is ~/.workspai/workspaces.json; ~/.rapidkit/workspaces.json is a non-authoritative compatibility mirror for legacy consumers and must not diverge after a CLI registry mutation."],semantics:{workspace:"The governed operating boundary that relates one or more projects and repositories to shared metadata, policies, contracts, evidence, and consumers.",repository:"A source-control boundary that may contain one or more projects and may live inside or outside the workspace root.",project:"A discoverable build or runtime unit with its own path, metadata or observable manifests, command capabilities, and evidence.",evidence:"A sourced observation or generated verification result with provenance and freshness; evidence may be consumed by a later run.",artifact:"A durable generated file that another command or consumer can read without parsing terminal prose.",gate:"A structured verdict with reasons and exit semantics derived from current evidence."},workspaceLifecycle:{ingestionRoutes:[{id:"create",label:"Create",commands:["create workspace","create project"],result:"Create a workspace or supported project and write canonical Workspai metadata."},{id:"adopt",label:"Adopt",commands:["adopt"],result:"Register an existing project in place without requiring source relocation."},{id:"import",label:"Import",commands:["import","workspace import"],result:"Attach an existing project or repository path to the workspace inventory."}],durableState:[{id:"workspace-identity",paths:[".workspai-workspace",".workspai/workspace.json"],purpose:"Identify the workspace boundary, profile, and canonical root."},{id:"project-inventory",paths:[".workspai/project.json",".workspai/context.json",".workspai/adopt.json","~/.workspai/workspaces.json","~/.rapidkit/workspaces.json (legacy compatibility mirror)"],purpose:"Record native, adopted, imported, and globally registered project locations while preserving a non-authoritative mirror for legacy extension discovery."},{id:"governance",paths:[".workspai/policies.yml",i.workspaceContract],purpose:"Define workspace policy and explicit structural relationships."},{id:"graph-overrides",paths:[".workspai/workspace-graph.overrides.json"],purpose:"Provide explicit dependency edges that override inferred relationships."}],rule:"Create, adopt, and import are ingestion routes, not intelligence facts. Their durable state becomes observable input to Model."},runtimeRegistry:{authority:"contracts/workspace-intelligence-runtime-registry.ts",artifacts:Object.entries(e).map(([r,a])=>({id:r,path:a,schemaVersion:f$1[r],schemaContract:g[r]}))},executionEnvelope:{rule:"Sync and baseline resolution are deterministic execution prerequisites, not canonical intelligence stages; every run reports them separately and preserves the exact canonical stage sequence.",operations:[{id:"sync",executionPoint:"before:model",artifacts:[i.workspaceContract,i.workspaceRegistry],failurePolicy:"stop-and-report",purpose:"Reconcile portable workspace inventory and contract inputs before modeling."},{id:"baseline",executionPoint:"after:model-before:diff",artifacts:[e$1.snapshot],failurePolicy:"stop-and-report",purpose:"Create an initial structural baseline when absent or reuse the existing baseline before Diff."}],report:{artifact:e$1.intelligenceRun,schemaVersion:f$1.intelligenceRun,invariant:"The report must preserve exact preflight and stage order, registry-owned artifacts, failure propagation, and aggregate status/exit semantics."}},boundaries:{inputs:[{id:"projects-repositories",label:"Projects and repositories",sources:["projects","repositories","services","modules","imported paths"],entersAt:"model"},{id:"runtime-dependencies",label:"Runtime and dependencies",sources:["runtime manifests","lockfiles","scripts","framework markers","package dependencies","bounded multi-language source observations for supported file extensions"],entersAt:"model"},{id:"workspace-rules",label:"Workspace rules",sources:["workspace markers","registry","project metadata","contracts","policies","ownership","graph overrides"],entersAt:"model"},{id:"changes",label:"Changes",sources:["repository state","git state","model baseline","workspace diff"],entersAt:"diff"},{id:"model-baseline",label:"Explicit model baseline",sources:[e$1.snapshot],entersAt:"diff"},{id:"existing-evidence",label:"Existing evidence",sources:["doctor reports","analysis reports","contract verification","release readiness","pipeline results","tests and runtime evidence","previous intelligence artifacts"],entersAt:"doctor-evidence"}],outputs:[{id:"understanding",label:"System understanding",artifacts:[e$1.model,e$1.knowledgeGraph,e$1.diff,e$1.impact],producedBy:["model","diff","impact"],inventory:"complete-for-chain"},{id:"governance-evidence",label:"Governance evidence",artifacts:[e$1.doctor,e$1.contractVerify,e$1.analyze,e$1.readiness,e$1.verify,e$1.history],producedBy:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify"],inventory:"complete-for-chain"},{id:"agent-grounding",label:"Agent grounding",artifacts:[e$1.agentContext,e$1.agentIndex,e$1.agentCustomizationPack,e$1.skillsIndex,e$1.agents],producedBy:["context","agent-sync"],inventory:"canonical-minimum",inventoryContract:"contracts/agent-customization-pack.v1.json"},{id:"explanations",label:"Explainable decisions",artifacts:[e$1.explain],producedBy:["explain"],inventory:"complete-for-chain"}],consumers:[{id:"developers",label:"Developers",channels:["CLI","reports","AGENTS.md"]},{id:"ci",label:"CI",channels:["JSON artifacts","exit codes","release gates"]},{id:"ides",label:"IDEs",channels:["synced contracts","extension","agent context"]},{id:"ai-agents",label:"AI agents",channels:["INDEX.json","context","skills","MCP"]}]},deliveryChannels:[{id:"artifacts",carries:["reports","models","context","grounding","skills"],authority:"canonical"},{id:"json-stdout",carries:["structured command results"],authority:"projection"},{id:"human-cli",carries:["summaries","diagnostics","next actions"],authority:"projection"},{id:"exit-codes",carries:["gate and command status"],authority:"projection"},{id:"watch-events",carries:["incremental workspace change events"],authority:"projection"},{id:"mcp",carries:["read-mostly access to current workspace artifacts"],authority:"projection"}],feedback:{from:["developers","ci","ides","ai-agents"],signals:["source commits","dependency updates","policy and contract edits","repairs","test and runtime results","agent action outcomes"],reentersThrough:["projects-repositories","runtime-dependencies","workspace-rules","changes","existing-evidence"],rule:"Consumer actions are not silently treated as truth. They re-enter as observable changes or evidence and must be modeled and verified again."},auxiliaryCapabilities:[{id:"graph",commands:["workspace graph emit","workspace graph explain","workspace graph entities","workspace graph evidence","workspace graph path","workspace graph search","workspace graph benchmark","workspace graph overlay","workspace graph dot","workspace graph mermaid","workspace graph jsonld","workspace graph graphml","workspace graph gexf"],reads:[e$1.model,e$1.knowledgeGraph],role:"Query the proof-backed graph derived from the canonical workspace model.",chainStep:false},{id:"evaluation",commands:["workspace eval init","workspace eval record","workspace eval status","workspace eval report","workspace eval compare"],reads:[e$1.evaluationLive,e$1.evaluationLastRun],produces:[e$1.evaluationLive,e$1.evaluationLastRun],role:"Measure model usage, activity, cost provenance, and verified outcomes without storing prompt or response bodies.",chainStep:false},{id:"watch",commands:["workspace watch"],reads:["workspace inputs",e$1.model],role:"Refresh the model incrementally and emit deterministic change events.",chainStep:false},{id:"mcp",commands:["workspace mcp serve"],reads:["workspace evidence artifacts"],role:"Expose read-mostly workspace evidence to compatible clients.",chainStep:false}],presentations:{simple:{layers:["inputs","intelligence","outputs","consumers"],nodes:[{id:"input-layer",kind:"inputs",label:"Input Layer",summary:"Projects \xB7 Repositories \xB7 Dependencies \xB7 Changes",contractRefs:["projects-repositories","runtime-dependencies","workspace-rules","changes","model-baseline","existing-evidence"]},{id:"workspace-intelligence",kind:"intelligence",label:"Workspace Intelligence",summary:"Model \xB7 Graph \xB7 Impact \xB7 Verify",contractRefs:s.map(r=>r.id)},{id:"agent-grounding",kind:"outputs",label:"Agent Grounding",summary:"AGENTS.md \xB7 Skills \xB7 Context",contractRefs:["agent-grounding"]},{id:"evidence-and-decisions",kind:"outputs",label:"Evidence Contracts",summary:"Reports \xB7 Artifacts \xB7 Gates",contractRefs:["understanding","governance-evidence","explanations"]},{id:"shared-consumers",kind:"consumers",label:"Shared Consumers",summary:"Developers \xB7 CI \xB7 IDEs \xB7 AI agents",contractRefs:["developers","ci","ides","ai-agents"]}],rule:"Use concrete user-facing language for first-contact explanations. Every input, output, consumer, and chain step must remain traceable through contractRefs even when details are summarized."},standard:{phases:["understand","change","evidence","gate","ground","distribute","explain"],nodes:[{id:"understand",label:"Understand",question:"What exists in the current workspace?",stepRefs:["model"]},{id:"change",label:"Change",question:"What changed, and what can it affect?",stepRefs:["diff","impact"]},{id:"evidence",label:"Evidence",question:"What health, contract, and readiness facts were observed?",stepRefs:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"]},{id:"gate",label:"Gate",question:"Is the current state acceptable and trustworthy?",stepRefs:["verify"]},{id:"ground",label:"Ground",question:"What should an agent know before acting?",stepRefs:["context"]},{id:"distribute",label:"Distribute",question:"Which durable agent and IDE surfaces receive that context?",stepRefs:["agent-sync"]},{id:"explain",label:"Explain",question:"Why did the system reach this result or verdict?",stepRefs:["explain"]}],rule:"Use for architecture education and product surfaces. Every phase must appear once and in order."},advanced:{steps:s.map(r=>r.id),requiredFields:["command","inputRefs","consumesArtifacts","produces","dependsOn","exitPolicy","purpose"],rule:"Use for implementers, adapters, IDEs, and CI. Preserve every step and its artifact and verdict semantics."}},steps:s,diagram:{direction:"TB",nodes:s.map(({id:r,label:a,phase:p})=>({id:r,label:a,phase:p})),edges:s.flatMap(r=>r.dependsOn.map(a=>({from:a,to:r.id,meaning:"required before"})))},consumers:{agents:{canonicalReadOrder:[e$1.agentIndex,i.goalIndex,i.goalPackLastRun,e$1.agentContext,e$1.skillsIndex,e$1.verify,e$1.impact,e$1.explain],entrypoints:[e$1.agents,".workspai/AGENT-GROUNDING.md"],rule:"Agents must cite current artifacts, preserve verified versus inferred status, and re-run the producing step when evidence is missing or stale."},ideAndCi:{requiredArtifacts:[e$1.model,e$1.knowledgeGraph,e$1.impact,e$1.verify],rule:"IDEs and CI must consume structured artifacts and verdict exit semantics rather than parse human help or terminal prose."},docsAndDiagrams:{rule:"Documentation and diagrams must derive labels, ordering, and edges from this contract and must not invent implemented steps."}}}}export{l as a,f as b};
@@ -1 +1 @@
1
- import {f}from'./chunk-NZ3WZYD5.js';var i=f.explain,u=["project","release-blocked","blocker","trace"];function s(t){let e=t.trim();if(!e)return null;if(e==="release-blocked")return {kind:"release-blocked"};if(e.startsWith("project:")){let r=e.slice(8).trim();return r?{kind:"project",project:r}:null}if(e.startsWith("blocker:")){let r=e.slice(8).trim();return r?{kind:"blocker",blockerId:r}:null}if(e.startsWith("trace:")){let r=e.slice(6).trim();return r?{kind:"trace",diffRef:r}:null}return {kind:"project",project:e}}function E(t){let e=t.trim();if(!e)return null;if(e.startsWith("trace:")){let n=s(e);return n?.kind==="trace"?n:null}let r=e.replace(/\\/g,"/").trim().toLowerCase();return r.endsWith(".json")||r.includes("workspace-model-diff")||r.startsWith(".rapidkit/")||r.includes("/.rapidkit/")?{kind:"trace",diffRef:e}:null}function A(t){if(!t||typeof t!="object"||Array.isArray(t))return false;let e=t;return e.schemaVersion===i&&typeof e.generatedAt=="string"&&typeof e.summary=="string"&&Array.isArray(e.sections)&&e.target!=null&&typeof e.target=="object"&&!Array.isArray(e.target)&&typeof e.target.kind=="string"}export{i as a,u as b,s as c,E as d,A as e};
1
+ import {f}from'./chunk-6UNATTB7.js';var i=f.explain,u=["project","release-blocked","blocker","trace"];function s(t){let e=t.trim();if(!e)return null;if(e==="release-blocked")return {kind:"release-blocked"};if(e.startsWith("project:")){let r=e.slice(8).trim();return r?{kind:"project",project:r}:null}if(e.startsWith("blocker:")){let r=e.slice(8).trim();return r?{kind:"blocker",blockerId:r}:null}if(e.startsWith("trace:")){let r=e.slice(6).trim();return r?{kind:"trace",diffRef:r}:null}return {kind:"project",project:e}}function E(t){let e=t.trim();if(!e)return null;if(e.startsWith("trace:")){let n=s(e);return n?.kind==="trace"?n:null}let r=e.replace(/\\/g,"/").trim().toLowerCase();return r.endsWith(".json")||r.includes("workspace-model-diff")||r.startsWith(".rapidkit/")||r.includes("/.rapidkit/")?{kind:"trace",diffRef:e}:null}function A(t){if(!t||typeof t!="object"||Array.isArray(t))return false;let e=t;return e.schemaVersion===i&&typeof e.generatedAt=="string"&&typeof e.summary=="string"&&Array.isArray(e.sections)&&e.target!=null&&typeof e.target=="object"&&!Array.isArray(e.target)&&typeof e.target.kind=="string"}export{i as a,u as b,s as c,E as d,A as e};