workspai 0.68.0 → 0.69.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 (175) hide show
  1. package/README.md +38 -18
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +459 -0
  3. package/contracts/extension-cli-compatibility.v1.json +11 -0
  4. package/contracts/published-contract-catalog.v1.json +55 -0
  5. package/contracts/runtime-command-surface.v1.json +282 -0
  6. package/contracts/workspace-intelligence/architecture-change-lease.v1.json +50 -0
  7. package/contracts/workspace-intelligence/architecture-surprise-report.v1.json +46 -0
  8. package/contracts/workspace-intelligence/change-operation-result.v1.json +43 -0
  9. package/contracts/workspace-intelligence/decision-checkpoint.v1.json +18 -0
  10. package/contracts/workspace-intelligence/decision-event.v1.json +134 -0
  11. package/contracts/workspace-intelligence/decision-transaction.v1.json +29 -0
  12. package/contracts/workspace-intelligence/goal-index.v1.json +13 -0
  13. package/contracts/workspace-intelligence/goal-pack.v1.json +2 -1
  14. package/contracts/workspace-intelligence/predicted-architecture-change.v1.json +34 -0
  15. package/contracts/workspace-intelligence/proof-carrying-change-capsule-export.v1.json +14 -0
  16. package/contracts/workspace-intelligence/proof-carrying-change-capsule-validation.v1.json +16 -0
  17. package/contracts/workspace-intelligence/proof-carrying-change-capsule.v1.json +62 -0
  18. package/contracts/workspace-intelligence/proof-carrying-change-list.v1.json +80 -0
  19. package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +9 -1
  20. package/dist/analyze-GPYPXXRT.js +1 -0
  21. package/dist/{artifact-remediation-plan-I7IKC5MR.js → artifact-remediation-plan-JHHZ4L24.js} +1 -1
  22. package/dist/autopilot-release-FL47VMF7.js +1 -0
  23. package/dist/capabilities-command-MYSLJIYS.js +1 -0
  24. package/dist/chunk-2LZWBUJD.js +1 -0
  25. package/dist/{chunk-7DDEMDG2.js → chunk-37ZLNFV5.js} +2 -2
  26. package/dist/{chunk-OFYY4725.js → chunk-3G5FF2JZ.js} +1 -1
  27. package/dist/chunk-3HFFKW4Q.js +2 -0
  28. package/dist/{chunk-BHM6RHTA.js → chunk-3WHE7V4M.js} +1 -1
  29. package/dist/chunk-A3MYO55A.js +3 -0
  30. package/dist/chunk-ABMB6MJT.js +1 -0
  31. package/dist/chunk-AD4ZY3RF.js +12 -0
  32. package/dist/chunk-BM2F5C4J.js +1 -0
  33. package/dist/chunk-COICGD62.js +1 -0
  34. package/dist/{chunk-4WVOAX2V.js → chunk-DWL3PPLA.js} +1 -1
  35. package/dist/{chunk-3Z4SVBMR.js → chunk-EBEAJIBI.js} +1 -1
  36. package/dist/chunk-EBQS5T7Q.js +7 -0
  37. package/dist/{chunk-5OV2WXAR.js → chunk-EG6EZ7HW.js} +1 -1
  38. package/dist/chunk-ERVWW5HX.js +1 -0
  39. package/dist/chunk-EZPLMAW2.js +1 -0
  40. package/dist/chunk-FIK343LI.js +1 -0
  41. package/dist/chunk-GSSJJS5M.js +6 -0
  42. package/dist/{chunk-TMRCPT7S.js → chunk-GYN6RPNU.js} +1 -1
  43. package/dist/{chunk-6E2Y3XGT.js → chunk-HCFOVANQ.js} +1 -1
  44. package/dist/chunk-I3UCODXU.js +1 -0
  45. package/dist/{chunk-3BMYMZQB.js → chunk-IGJA6GBQ.js} +1 -1
  46. package/dist/{chunk-FX5J6JCK.js → chunk-IVYPC36J.js} +1 -1
  47. package/dist/chunk-K33JJVQZ.js +2 -0
  48. package/dist/{chunk-KDY4X7SQ.js → chunk-M37ALD4V.js} +1 -1
  49. package/dist/{chunk-3XF7O66C.js → chunk-MAWHHHU3.js} +5 -5
  50. package/dist/chunk-MBICKDYP.js +1 -0
  51. package/dist/{chunk-QMQBX3RV.js → chunk-MGL6DBOR.js} +1 -1
  52. package/dist/chunk-MHQHRMKU.js +5 -0
  53. package/dist/{chunk-2C5XJBYI.js → chunk-N2Q4MSSP.js} +64 -64
  54. package/dist/chunk-N4B2M44I.js +1 -0
  55. package/dist/chunk-NSH7TTSV.js +1 -0
  56. package/dist/chunk-O5XQP5E7.js +1 -0
  57. package/dist/chunk-ODK4LCEL.js +1 -0
  58. package/dist/chunk-OU3BBWH5.js +49 -0
  59. package/dist/chunk-OZXCNVGW.js +2 -0
  60. package/dist/{chunk-SLFOUSRW.js → chunk-QYEQVNBF.js} +1 -1
  61. package/dist/chunk-RVOW3BHQ.js +2 -0
  62. package/dist/chunk-TKXRP2B4.js +1 -0
  63. package/dist/chunk-UNXG3ZFV.js +1 -0
  64. package/dist/chunk-UW4SESKD.js +2 -0
  65. package/dist/{chunk-2MTJWPQ4.js → chunk-V52R2W2Q.js} +1 -1
  66. package/dist/chunk-V6TIT6M3.js +157 -0
  67. package/dist/chunk-VNKAISFE.js +8 -0
  68. package/dist/chunk-W6WRT77T.js +1 -0
  69. package/dist/chunk-WHR5SL33.js +4 -0
  70. package/dist/{chunk-IXXQMD34.js → chunk-WZ5V5U2K.js} +1 -1
  71. package/dist/chunk-XPGCFVGC.js +4 -0
  72. package/dist/chunk-YKY4JFCF.js +1 -0
  73. package/dist/{chunk-VIN7NJW3.js → chunk-YWZBGSFE.js} +3 -3
  74. package/dist/chunk-YZL7ZY7J.js +2 -0
  75. package/dist/{create-U5PQHOZ4.js → create-GWBQ74ZI.js} +1 -1
  76. package/dist/doctor-OQAXSMEM.js +1 -0
  77. package/dist/goal-lifecycle-YWBVQ2DF.js +1 -0
  78. package/dist/goal-pack-KUXPZVNO.js +1 -0
  79. package/dist/index.d.ts +35 -2
  80. package/dist/index.js +239 -239
  81. package/dist/pipeline-PGB5TEV3.js +5 -0
  82. package/dist/{project-agent-entry-MH7364BE.js → project-agent-entry-H3JAGNLS.js} +1 -1
  83. package/dist/{project-intelligence-lens-ZCCHUKVI.js → project-intelligence-lens-7NMKHV5N.js} +1 -1
  84. package/dist/{project-test-coverage-JPWTBSSJ.js → project-test-coverage-3DKZKLWY.js} +1 -1
  85. package/dist/proof-carrying-change-QFH7WI2E.js +1 -0
  86. package/dist/verified-goal-7XHRWYSE.js +1 -0
  87. package/dist/{workspace-B33BFZZ3.js → workspace-TJHCETBV.js} +1 -1
  88. package/dist/{workspace-agent-sync-T3MJO2MX.js → workspace-agent-sync-Z35NTXCB.js} +1 -1
  89. package/dist/{workspace-archive-NOSGRKRZ.js → workspace-archive-OSMU3CK6.js} +1 -1
  90. package/dist/{workspace-context-KOCEP4MJ.js → workspace-context-KNJQUJWC.js} +1 -1
  91. package/dist/{workspace-contract-MQ3QE52V.js → workspace-contract-VIUQT5SZ.js} +1 -1
  92. package/dist/workspace-explain-HM6GMK26.js +1 -0
  93. package/dist/workspace-explain-contract-KV7RTEJU.js +1 -0
  94. package/dist/{workspace-feedback-3YLIUFQ7.js → workspace-feedback-YSPEGCON.js} +1 -1
  95. package/dist/{workspace-foundation-O7O3QIS4.js → workspace-foundation-PLXFPI3J.js} +1 -1
  96. package/dist/{workspace-graph-stream-XTGGBD7D.js → workspace-graph-stream-FNRQ2FTB.js} +1 -1
  97. package/dist/workspace-graph-token-efficiency-WNAFAN2F.js +1 -0
  98. package/dist/{workspace-history-7HDZZ4G5.js → workspace-history-HDDFG6LH.js} +1 -1
  99. package/dist/{workspace-intelligence-TFEQBPUP.js → workspace-intelligence-QLSD5EEV.js} +1 -1
  100. package/dist/{workspace-intelligence-benchmark-PLVUBGWO.js → workspace-intelligence-benchmark-S5OXVNLC.js} +1 -1
  101. package/dist/{workspace-intelligence-evaluation-OJIQS5SN.js → workspace-intelligence-evaluation-QDSOOUHH.js} +1 -1
  102. package/dist/{workspace-intelligence-runner-6ZAV6RO4.js → workspace-intelligence-runner-4EW4T2OW.js} +1 -1
  103. package/dist/workspace-intelligence-runtime-registry-ZLPF7BAY.js +1 -0
  104. package/dist/{workspace-knowledge-graph-AUXYL3L6.js → workspace-knowledge-graph-EEOW5VAJ.js} +1 -1
  105. package/dist/workspace-knowledge-graph-change-overlay-FIIAFLO6.js +1 -0
  106. package/dist/{workspace-knowledge-graph-contract-X52KXBXJ.js → workspace-knowledge-graph-contract-FVX5T7SU.js} +1 -1
  107. package/dist/{workspace-knowledge-graph-query-A7TKONWY.js → workspace-knowledge-graph-query-WHCGPBGS.js} +1 -1
  108. package/dist/workspace-knowledge-graph-snapshot-X347REDB.js +1 -0
  109. package/dist/workspace-mcp-serve-NQ42PE2I.js +3 -0
  110. package/dist/{workspace-model-GVXNLSQM.js → workspace-model-NCOOY5LC.js} +1 -1
  111. package/dist/{workspace-onboarding-ECZ2KJ2A.js → workspace-onboarding-JNC7ZFMR.js} +1 -1
  112. package/dist/{workspace-readme-6N5Y2ZSJ.js → workspace-readme-OV2ADTLW.js} +2 -2
  113. package/dist/{workspace-registry-summary-5SFBTRGQ.js → workspace-registry-summary-ONT4VOJX.js} +1 -1
  114. package/dist/{workspace-repair-engine-CKJCTWKX.js → workspace-repair-engine-WMJCYWO4.js} +2 -2
  115. package/dist/workspace-run-3S35MDX6.js +1 -0
  116. package/dist/{workspace-verify-D3QTMAUI.js → workspace-verify-MLABQUWK.js} +1 -1
  117. package/dist/{workspace-watch-XYJEW2Z2.js → workspace-watch-MJOG5AZ3.js} +1 -1
  118. package/docs/README.md +2 -0
  119. package/docs/ci-workflows.md +1 -1
  120. package/docs/commands-reference.md +23 -0
  121. package/docs/contracts/ARTIFACT_CATALOG.md +37 -18
  122. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +17 -0
  123. package/docs/contracts/PROOF_CARRYING_CHANGE_CONTRACT_PLAN.md +65 -0
  124. package/docs/proof-carrying-change.implementation.v1.json +118 -0
  125. package/docs/proof-carrying-change.md +202 -0
  126. package/package.json +1 -1
  127. package/dist/analyze-JDEWUBC6.js +0 -1
  128. package/dist/autopilot-release-OELUFNLL.js +0 -1
  129. package/dist/capabilities-command-RAAYENQ6.js +0 -1
  130. package/dist/chunk-2KX6KHEC.js +0 -1
  131. package/dist/chunk-3KU3YUWD.js +0 -2
  132. package/dist/chunk-3NF3M3RE.js +0 -1
  133. package/dist/chunk-3OGPTLI2.js +0 -1
  134. package/dist/chunk-5ME4W4LN.js +0 -1
  135. package/dist/chunk-5XUAAQSV.js +0 -5
  136. package/dist/chunk-5YZ2W57R.js +0 -8
  137. package/dist/chunk-7DZNZ3GM.js +0 -3
  138. package/dist/chunk-BG6IX6HA.js +0 -1
  139. package/dist/chunk-BMAFHX6A.js +0 -1
  140. package/dist/chunk-BUYLM6QV.js +0 -1
  141. package/dist/chunk-C2VTO5WT.js +0 -2
  142. package/dist/chunk-CPR2CMOY.js +0 -1
  143. package/dist/chunk-CSZPE637.js +0 -2
  144. package/dist/chunk-DFVG4DDZ.js +0 -6
  145. package/dist/chunk-EHLGPLIU.js +0 -1
  146. package/dist/chunk-FPDH3N3A.js +0 -7
  147. package/dist/chunk-GVQKAINC.js +0 -49
  148. package/dist/chunk-IKUFNK46.js +0 -2
  149. package/dist/chunk-JYMO7QXQ.js +0 -1
  150. package/dist/chunk-KY2GOSO5.js +0 -1
  151. package/dist/chunk-LEOFD3W5.js +0 -12
  152. package/dist/chunk-LPCZHKD5.js +0 -1
  153. package/dist/chunk-N5HPMATQ.js +0 -1
  154. package/dist/chunk-P3622IM5.js +0 -4
  155. package/dist/chunk-Q7UGDNSM.js +0 -1
  156. package/dist/chunk-RVAOJOXA.js +0 -2
  157. package/dist/chunk-TCLKGPXF.js +0 -2
  158. package/dist/chunk-W5VKBDSD.js +0 -157
  159. package/dist/chunk-WRZSQDZV.js +0 -1
  160. package/dist/chunk-Y4Z6CEII.js +0 -1
  161. package/dist/chunk-ZEEV5J4I.js +0 -1
  162. package/dist/chunk-ZGHJIQXL.js +0 -1
  163. package/dist/doctor-D7YI7LSA.js +0 -1
  164. package/dist/goal-lifecycle-BMS6GSIU.js +0 -1
  165. package/dist/goal-pack-RBSVQMMX.js +0 -1
  166. package/dist/pipeline-QOMXH2EK.js +0 -5
  167. package/dist/verified-goal-XUXU2X5H.js +0 -1
  168. package/dist/workspace-explain-DTFCKYXK.js +0 -1
  169. package/dist/workspace-explain-contract-WMREJWHF.js +0 -1
  170. package/dist/workspace-graph-token-efficiency-5LJKQU2J.js +0 -1
  171. package/dist/workspace-intelligence-runtime-registry-UKFB3BI7.js +0 -1
  172. package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +0 -1
  173. package/dist/workspace-knowledge-graph-snapshot-GPBDAKAU.js +0 -1
  174. package/dist/workspace-mcp-serve-TDUXJUAA.js +0 -3
  175. package/dist/workspace-run-ZZ5WHL7W.js +0 -1
@@ -1,6 +1,6 @@
1
- import {a as a$4}from'./chunk-ZEEV5J4I.js';import {f as f$1,e as e$1}from'./chunk-KY2GOSO5.js';import {a as a$1,b}from'./chunk-QMQBX3RV.js';import {b as b$1,c}from'./chunk-2MTJWPQ4.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {p,a as a$3}from'./chunk-TCLKGPXF.js';import {k as k$1,m,l}from'./chunk-U5ENEDJA.js';import {e as e$2}from'./chunk-C2VTO5WT.js';import {e,f}from'./chunk-ZGHJIQXL.js';import {k,t,u}from'./chunk-VQZ5PI5J.js';import j from'fs';import i from'path';import a from'chalk';var Z=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function I(e){try{return await j.promises.access(e,j.constants.F_OK),true}catch{return false}}async function S(e){try{let n=JSON.parse(await j.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function v(e){try{return await j.promises.readFile(e,"utf-8")}catch{return ""}}function ee(e){return a$1(e)}async function ne(e,n){return await X([...u(e,"project.json"),...u(e,"context.json")])?true:b(e)?false:i.resolve(e)===i.resolve(n)?k$1(e).length>0:k$1(e).length>0}async function te(e){let n=await a$2(e,{skipDirs:Z,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:ne}),r=(await a$3(e)).filter(s=>s.relationship==="adopted"||s.source==="adopted-local").map(s=>i.resolve(s.path)).filter(s=>j.existsSync(s)),o=[...new Set([...n.map(s=>i.resolve(s)),...r])];return o.length>0?o:b(e)?[]:k$1(e).length>0?[e]:[]}function re(e,n){return i.relative(e,n).replace(/\\/g,"/")||"."}async function E(e,n){for(let t of n)if(await I(i.join(e,t)))return true;return false}async function X(e){for(let n of e)if(await I(n))return true;return false}async function Y(e){for(let n of e){let t=await S(n);if(t)return t}return null}async function oe(e){if(await E(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts","app/controllers/health_controller.rb","app/controllers/health_check_controller.rb","config/initializers/health_check.rb"]))return true;let t=await v(i.join(e,"config","routes.rb"));return /(?:health|readiness|liveness|readiness_check|health_check)/iu.test(t)}async function se(e,n){if(await E(e,[".env",".env.local"]))return true;let t=n?.contracts&&typeof n.contracts=="object"?n.contracts:null;if(Array.isArray(t?.env)&&t.env.length>0)return true;let r=await S(i.join(e,"package.json")),o={...r?.dependencies??{},...r?.devDependencies??{}};if(Object.keys(o).some(c=>/^(?:dotenv|dotenv-flow|env-cmd)$/iu.test(c)))return true;let s=await v(i.join(e,"pyproject.toml"));if(/\b(?:python-dotenv|pydantic-settings)\b/iu.test(s))return true;let p=[await v(i.join(e,"compose.yaml")),await v(i.join(e,"compose.yml")),await v(i.join(e,"docker-compose.yml")),await v(i.join(e,"docker-compose.yaml"))].join(`
2
- `);return /^\s*(?:env_file|environment)\s*:/imu.test(p)}async function ae(e){return (await a$4(e)).detected}async function ie(e){let n=await S(i.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function y(e,n,t,r,o,s,p){return {id:e,severity:n,target:t,title:r,detail:o,remediation:s,...p&&p.length>0?{files:[...p]}:{}}}function ce(e){let n=e.reduce((t,r)=>r.severity==="fail"?t+28:r.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function de(e,n,t){let r=await Y(u(n,"project.json")),o=m(n,r),s=l(n),p=o.runtime==="unknown"?s[0]||"unknown":o.runtime,c$1=[p,...s.filter(G=>G!==p)],g=await b$1(n,r,{runtime:p,framework:o.key}),w=["backend","service","worker"].includes(g),h=w&&/^(?:fastapi|django|flask|nestjs|express|fastify|springboot|gofiber|gogin|dotnet-webapi|laravel|rails|phoenix|axum|actix|rocket)$/u.test(o.key),k=re(e,n),u$1=k,b=await ie(n),C=await X([...u(n,"project.json"),...u(n,"context.json")]),P=await ae(n),x=await E(n,["Dockerfile","dockerfile"]),R=await E(n,[".env.example","env.example","config/env.example"]),F=await se(n,r),m$1=await c({projectPath:n,declaration:t?.governance}),d=m$1.ci.status==="repository",l$1=await oe(n),f=[];return o.key==="unknown"&&f.push(y("project.stack.unknown","fail",u$1,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),C||f.push(y("project.marker.missing","warn",u$1,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),P||f.push(y("project.tests.missing","warn",u$1,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),w&&F&&!R&&f.push(y("project.env.example.missing","info",u$1,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.",[".env.example"])),m$1.ci.status==="unknown"?f.push(y("project.ci.missing","warn",u$1,"CI governance is not proven","No repository CI surface or canonical external CI declaration was found for this project.","Add repository CI configuration or declare the external CI authority in the workspace contract.",[".github/workflows/ci.yml"])):m$1.ci.status==="external-observed"&&f.push(y("project.ci.external-observed","info",u$1,"Continuous integration appears externally managed",`Repository documentation references an external CI control plane (${m$1.ci.evidence.join(", ")}).`,"Declare the external CI provider in the canonical workspace contract when authoritative release gating depends on it.")),h&&!l$1&&f.push(y("project.health.missing","info",u$1,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),w&&!x&&f.push(y("project.container.missing","info",u$1,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.",["Dockerfile"])),{name:typeof r?.name=="string"&&r.name.trim()?r.name.trim():i.basename(n),path:n,relativePath:k,runtime:p,runtimeCandidates:c$1,framework:o.key,confidence:o.confidence,supportTier:o.supportTier,hasRapidKitMarker:C,hasTests:P,hasDockerfile:x,hasEnvExample:R,hasCiConfig:d,governance:m$1,hasHealthEndpoint:l$1,scripts:b,findings:f,score:ce(f)}}function le(e){return e.name.toLowerCase()}async function pe(e){let n=new Map(e.map(o=>[le(o),o])),t=[];for(let o of e){let s=await S(i.join(o.path,"package.json")),p={...s?.dependencies??{},...s?.devDependencies??{},...s?.peerDependencies??{}};for(let g of Object.keys(p)){let w=g.replace(/^@[^/]+\//,"").toLowerCase(),h=n.get(w);h&&h.relativePath!==o.relativePath&&t.push({from:o.relativePath,to:h.relativePath,kind:"package"});}let c=await v(i.join(o.path,"pyproject.toml"));for(let g of e)g.relativePath!==o.relativePath&&c.includes(g.name)&&t.push({from:o.relativePath,to:g.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(o=>{let s=`${o.from}\0${o.to}\0${o.kind}`;return r.has(s)?false:(r.add(s),true)})}function ue(e,n){let t=new Map;for(let r of e)t.set(r.relativePath,{project:r.relativePath,directDependents:0,directDependencies:0});for(let r of n){let o=t.get(r.from),s=t.get(r.to);o&&(o.directDependencies+=1),s&&(s.directDependents+=1);}return Array.from(t.values()).sort((r,o)=>o.directDependents-r.directDependents||o.directDependencies-r.directDependencies)}async function me(e){let n=await Y(t(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function fe(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function ge(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasCanonicalGraph||n.push("Generate canonical topology with `workspai workspace model --write --include-evidence`."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function Fe(e$3={}){let n=i.resolve(e$3.workspacePath||process.cwd());if(!await I(n))throw new Error(`Workspace path does not exist: ${n}`);let t=ee(n)??n,r=k(t),o=await me(t),s=await te(t),p$1;try{p$1=(await p({workspacePath:t})).contract;}catch{}let c=await Promise.all(s.map(d=>{let l=p$1?.projects.find(f=>{let G=f.externalPath??f.relativePath;return i.resolve(t,G)===i.resolve(d)});return de(t,d,l)})),g=await pe(c),w=ue(c,g),h=[];r||h.push(y("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),c.length===0&&h.push(y("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let k$1=[...h,...c.flatMap(d=>d.findings)],u=fe(k$1),b={};for(let d of c)for(let l of d.runtimeCandidates)b[l]=(b[l]||0)+1;let C=c.length>0?Math.round(c.reduce((d,l)=>d+l.score,0)/c.length):0,P=h.reduce((d,l)=>d+(l.severity==="fail"?20:l.severity==="warn"?8:2),0),x=Math.max(0,C-P),R=c.length===0&&u.fail===0&&k$1.length>0&&k$1.every(d=>d.id==="workspace.projects.missing"&&d.severity==="warn"),F=u.fail>0||e$3.strict&&u.warn>0&&!R?"blocked":u.warn>0?"needs-attention":"ready",m={schemaVersion:f.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:o,summary:{statusScope:"source-structure",releaseReadiness:"not-evaluated",score:x,verdict:F,projectCount:c.length,runtimeCount:Object.keys(b).length,findings:u},runtimes:b,projects:c,dependencyGraph:{status:g.length>0?"generated":"empty",edges:g,topImpactedProjects:w.slice(0,5)},findings:k$1,nextActions:ge({findings:k$1,projectCount:c.length,hasCanonicalGraph:await I(i.join(t,e.knowledgeGraph)),workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:e.analyze}};if(e$3.output&&(await j.promises.mkdir(i.dirname(i.resolve(e$3.output)),{recursive:true}),await j.promises.writeFile(i.resolve(e$3.output),`${JSON.stringify(m,null,2)}
3
- `)),!e$3.output&&r){let d=f$1(m,{commandId:"workspaceAnalyze",exitCode:m.summary.verdict==="blocked"?2:m.summary.verdict==="needs-attention"?1:0,generatedAt:m.generatedAt,blockers:m.findings.filter(l=>l.severity==="fail").map(l=>l.title).slice(0,12),runId:e$1()});await e$2(t,e.analyze,d);}return m}function Ge(e){let n=e.summary.verdict==="ready"?a.green:e.summary.verdict==="needs-attention"?a.yellow:a.red;if(console.log(a.bold(`
1
+ import {f,e,g as g$1}from'./chunk-NSH7TTSV.js';import {a as a$1,b}from'./chunk-MGL6DBOR.js';import {b as b$1,c}from'./chunk-V52R2W2Q.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {p,a as a$3}from'./chunk-UW4SESKD.js';import {k as k$1,m,l}from'./chunk-U5ENEDJA.js';import {g}from'./chunk-OZXCNVGW.js';import {p as p$1,q}from'./chunk-ODK4LCEL.js';import {k,t,u}from'./chunk-VQZ5PI5J.js';import j from'fs';import i from'path';import a from'chalk';var Z=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function I(e){try{return await j.promises.access(e,j.constants.F_OK),true}catch{return false}}async function S(e){try{let n=JSON.parse(await j.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function v(e){try{return await j.promises.readFile(e,"utf-8")}catch{return ""}}function ee(e){return a$1(e)}async function ne(e,n){return await X([...u(e,"project.json"),...u(e,"context.json")])?true:b(e)?false:i.resolve(e)===i.resolve(n)?k$1(e).length>0:k$1(e).length>0}async function te(e){let n=await a$2(e,{skipDirs:Z,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:ne}),r=(await a$3(e)).filter(s=>s.relationship==="adopted"||s.source==="adopted-local").map(s=>i.resolve(s.path)).filter(s=>j.existsSync(s)),o=[...new Set([...n.map(s=>i.resolve(s)),...r])];return o.length>0?o:b(e)?[]:k$1(e).length>0?[e]:[]}function re(e,n){return i.relative(e,n).replace(/\\/g,"/")||"."}async function E(e,n){for(let t of n)if(await I(i.join(e,t)))return true;return false}async function X(e){for(let n of e)if(await I(n))return true;return false}async function Y(e){for(let n of e){let t=await S(n);if(t)return t}return null}async function oe(e){if(await E(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts","app/controllers/health_controller.rb","app/controllers/health_check_controller.rb","config/initializers/health_check.rb"]))return true;let t=await v(i.join(e,"config","routes.rb"));return /(?:health|readiness|liveness|readiness_check|health_check)/iu.test(t)}async function se(e,n){if(await E(e,[".env",".env.local"]))return true;let t=n?.contracts&&typeof n.contracts=="object"?n.contracts:null;if(Array.isArray(t?.env)&&t.env.length>0)return true;let r=await S(i.join(e,"package.json")),o={...r?.dependencies??{},...r?.devDependencies??{}};if(Object.keys(o).some(c=>/^(?:dotenv|dotenv-flow|env-cmd)$/iu.test(c)))return true;let s=await v(i.join(e,"pyproject.toml"));if(/\b(?:python-dotenv|pydantic-settings)\b/iu.test(s))return true;let p=[await v(i.join(e,"compose.yaml")),await v(i.join(e,"compose.yml")),await v(i.join(e,"docker-compose.yml")),await v(i.join(e,"docker-compose.yaml"))].join(`
2
+ `);return /^\s*(?:env_file|environment)\s*:/imu.test(p)}async function ae(e){return (await g$1(e)).detected}async function ie(e){let n=await S(i.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function y(e,n,t,r,o,s,p){return {id:e,severity:n,target:t,title:r,detail:o,remediation:s,...p&&p.length>0?{files:[...p]}:{}}}function ce(e){let n=e.reduce((t,r)=>r.severity==="fail"?t+28:r.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function de(e,n,t){let r=await Y(u(n,"project.json")),o=m(n,r),s=l(n),p=o.runtime==="unknown"?s[0]||"unknown":o.runtime,c$1=[p,...s.filter(G=>G!==p)],g=await b$1(n,r,{runtime:p,framework:o.key}),w=["backend","service","worker"].includes(g),h=w&&/^(?:fastapi|django|flask|nestjs|express|fastify|springboot|gofiber|gogin|dotnet-webapi|laravel|rails|phoenix|axum|actix|rocket)$/u.test(o.key),k=re(e,n),u$1=k,b=await ie(n),C=await X([...u(n,"project.json"),...u(n,"context.json")]),P=await ae(n),x=await E(n,["Dockerfile","dockerfile"]),R=await E(n,[".env.example","env.example","config/env.example"]),F=await se(n,r),m$1=await c({projectPath:n,declaration:t?.governance}),d=m$1.ci.status==="repository",l$1=await oe(n),f=[];return o.key==="unknown"&&f.push(y("project.stack.unknown","fail",u$1,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),C||f.push(y("project.marker.missing","warn",u$1,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),P||f.push(y("project.tests.missing","warn",u$1,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),w&&F&&!R&&f.push(y("project.env.example.missing","info",u$1,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.",[".env.example"])),m$1.ci.status==="unknown"?f.push(y("project.ci.missing","warn",u$1,"CI governance is not proven","No repository CI surface or canonical external CI declaration was found for this project.","Add repository CI configuration or declare the external CI authority in the workspace contract.",[".github/workflows/ci.yml"])):m$1.ci.status==="external-observed"&&f.push(y("project.ci.external-observed","info",u$1,"Continuous integration appears externally managed",`Repository documentation references an external CI control plane (${m$1.ci.evidence.join(", ")}).`,"Declare the external CI provider in the canonical workspace contract when authoritative release gating depends on it.")),h&&!l$1&&f.push(y("project.health.missing","info",u$1,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),w&&!x&&f.push(y("project.container.missing","info",u$1,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.",["Dockerfile"])),{name:typeof r?.name=="string"&&r.name.trim()?r.name.trim():i.basename(n),path:n,relativePath:k,runtime:p,runtimeCandidates:c$1,framework:o.key,confidence:o.confidence,supportTier:o.supportTier,hasRapidKitMarker:C,hasTests:P,hasDockerfile:x,hasEnvExample:R,hasCiConfig:d,governance:m$1,hasHealthEndpoint:l$1,scripts:b,findings:f,score:ce(f)}}function le(e){return e.name.toLowerCase()}async function pe(e){let n=new Map(e.map(o=>[le(o),o])),t=[];for(let o of e){let s=await S(i.join(o.path,"package.json")),p={...s?.dependencies??{},...s?.devDependencies??{},...s?.peerDependencies??{}};for(let g of Object.keys(p)){let w=g.replace(/^@[^/]+\//,"").toLowerCase(),h=n.get(w);h&&h.relativePath!==o.relativePath&&t.push({from:o.relativePath,to:h.relativePath,kind:"package"});}let c=await v(i.join(o.path,"pyproject.toml"));for(let g of e)g.relativePath!==o.relativePath&&c.includes(g.name)&&t.push({from:o.relativePath,to:g.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(o=>{let s=`${o.from}\0${o.to}\0${o.kind}`;return r.has(s)?false:(r.add(s),true)})}function ue(e,n){let t=new Map;for(let r of e)t.set(r.relativePath,{project:r.relativePath,directDependents:0,directDependencies:0});for(let r of n){let o=t.get(r.from),s=t.get(r.to);o&&(o.directDependencies+=1),s&&(s.directDependents+=1);}return Array.from(t.values()).sort((r,o)=>o.directDependents-r.directDependents||o.directDependencies-r.directDependencies)}async function me(e){let n=await Y(t(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function fe(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function ge(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasCanonicalGraph||n.push("Generate canonical topology with `workspai workspace model --write --include-evidence`."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function Fe(e$1={}){let n=i.resolve(e$1.workspacePath||process.cwd());if(!await I(n))throw new Error(`Workspace path does not exist: ${n}`);let t=ee(n)??n,r=k(t),o=await me(t),s=await te(t),p$2;try{p$2=(await p({workspacePath:t})).contract;}catch{}let c=await Promise.all(s.map(d=>{let l=p$2?.projects.find(f=>{let G=f.externalPath??f.relativePath;return i.resolve(t,G)===i.resolve(d)});return de(t,d,l)})),g$1=await pe(c),w=ue(c,g$1),h=[];r||h.push(y("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),c.length===0&&h.push(y("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let k$1=[...h,...c.flatMap(d=>d.findings)],u=fe(k$1),b={};for(let d of c)for(let l of d.runtimeCandidates)b[l]=(b[l]||0)+1;let C=c.length>0?Math.round(c.reduce((d,l)=>d+l.score,0)/c.length):0,P=h.reduce((d,l)=>d+(l.severity==="fail"?20:l.severity==="warn"?8:2),0),x=Math.max(0,C-P),R=c.length===0&&u.fail===0&&k$1.length>0&&k$1.every(d=>d.id==="workspace.projects.missing"&&d.severity==="warn"),F=u.fail>0||e$1.strict&&u.warn>0&&!R?"blocked":u.warn>0?"needs-attention":"ready",m={schemaVersion:q.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:o,summary:{statusScope:"source-structure",releaseReadiness:"not-evaluated",score:x,verdict:F,projectCount:c.length,runtimeCount:Object.keys(b).length,findings:u},runtimes:b,projects:c,dependencyGraph:{status:g$1.length>0?"generated":"empty",edges:g$1,topImpactedProjects:w.slice(0,5)},findings:k$1,nextActions:ge({findings:k$1,projectCount:c.length,hasCanonicalGraph:await I(i.join(t,p$1.knowledgeGraph)),workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:p$1.analyze}};if(e$1.output&&(await j.promises.mkdir(i.dirname(i.resolve(e$1.output)),{recursive:true}),await j.promises.writeFile(i.resolve(e$1.output),`${JSON.stringify(m,null,2)}
3
+ `)),!e$1.output&&r){let d=f(m,{commandId:"workspaceAnalyze",exitCode:m.summary.verdict==="blocked"?2:m.summary.verdict==="needs-attention"?1:0,generatedAt:m.generatedAt,blockers:m.findings.filter(l=>l.severity==="fail").map(l=>l.title).slice(0,12),runId:e()});await g(t,p$1.analyze,d);}return m}function Ge(e){let n=e.summary.verdict==="ready"?a.green:e.summary.verdict==="needs-attention"?a.yellow:a.red;if(console.log(a.bold(`
4
4
  Workspai Workspace Analysis
5
5
  `)),console.log(a.cyan("Workspace:"),e.workspacePath),console.log(a.cyan("Profile:"),e.profile||"not configured"),console.log(a.cyan("Source score:"),`${e.summary.score}/100`),console.log(a.cyan("Source verdict:"),n(e.summary.verdict)),console.log(a.cyan("Release readiness:"),e.summary.releaseReadiness),console.log(a.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(a.bold(`
6
6
  Projects`));for(let t of e.projects){let r=t.score>=85?a.green("pass"):t.score>=65?a.yellow("watch"):a.red("risk");console.log(` ${t.relativePath} ${a.gray(`${t.runtime}/${t.framework}`)} ${r} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(a.bold(`
@@ -0,0 +1,2 @@
1
+ import {b as b$1}from'./chunk-COICGD62.js';import {b}from'./chunk-AD4ZY3RF.js';import {q as q$1,f,g}from'./chunk-2LZWBUJD.js';import {d}from'./chunk-UW4SESKD.js';import {g as g$1,f as f$1}from'./chunk-OZXCNVGW.js';import {q,p}from'./chunk-ODK4LCEL.js';import E from'path';import A from'fs-extra';var re=q.agentContext,se=p.agentContext;function ne(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="gemini"||t==="qwen"||t==="kimi"||t==="grok"||t==="copilot"||t==="windsurf"||t==="amazon-q"||t==="orca"?t:"generic"}function G(e){return `npx --yes --package workspai workspai ${e}`.trim()}function x(e){return `npx workspai ${e}`.trim()}async function C(e,t,i){let s=E.join(e,t);if(!await A.pathExists(s))return null;try{let n=await A.readJson(s);return typeof n!="object"||n===null||!("schemaVersion"in n)||n.schemaVersion!==i?null:n}catch{return null}}function m(e){return {id:e.id,scope:e.scope,display:x(e.args),execute:G(e.args),description:e.description,...e.project?{project:e.project}:{},freshness:f({id:`command.${e.id}`,label:`${e.id} command`,scope:"command",value:{display:x(e.args),execute:G(e.args)},...e.project?{project:e.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:e.generatedAt,now:e.now,sourceArtifact:p.model,sourcePath:`safeCommands.${e.id}`,reason:"Safe command surfaces are derived from workspace model command capabilities."}}).freshness}}function L(e,t){return `workspace run ${t} --scope project:${e.name}`}function ae(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function oe(e){return [e.name,e.path,E.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function ie(e,t,i){let s={generatedAt:e.generatedAt,now:i},n=[m({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model.",...s}),m({id:"workspace.graph.entities",scope:"workspace",args:"workspace graph entities --json",description:"Query proof-backed workspace entities without loading the full graph.",...s}),m({id:"workspace.graph.evidence",scope:"workspace",args:"workspace graph evidence <entity-or-relation> --json",description:"Resolve portable evidence for a graph entity or relation.",...s}),m({id:"workspace.graph.path",scope:"workspace",args:"workspace graph path <from> <to> --json",description:"Find a shortest proof-carrying path between workspace entities.",...s}),m({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification.",...s}),m({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop.",...s}),m({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges.",...s}),m({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions.",...s})],c=t?[t]:e.projects;for(let a of c)a.commands.fleetStages.includes("test")&&n.push(m({id:`project.${a.name}.test`,scope:"project",project:a.name,args:L(a,"test"),description:`Run tests for ${a.name} through workspace orchestration.`,...s})),a.commands.fleetStages.includes("build")&&n.push(m({id:`project.${a.name}.build`,scope:"project",project:a.name,args:L(a,"build"),description:`Build ${a.name} through workspace orchestration.`,...s}));return n}function ce(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function pe(e,t){if(!t?.startsWith("project:"))return;let i=ae(t);if(i)return e.projects.find(s=>oe(s).includes(i))}function de(e,t,i){let s=[...e.validation?.issues??[]];t?.startsWith("project:")&&!i&&s.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let n=s.filter(a=>a.severity==="error").length,c=s.filter(a=>a.severity==="warning").length;return {status:n>0?"failed":c>0?"warning":"passed",errors:n,warnings:c,issues:s}}async function me(e,t){let i=[],s=[];for(let[n,c]of Object.entries(e.evidence))c&&await f$1(t,c.path)!==null?i.push(`${n}: ${c.path}`):s.push(n);return {available:i.sort(),missing:s.sort()}}function le(e){let t=e.summary.projectCount,i=e.summary.runtimes.length?`${e.summary.runtimes.join(", ")} runtime coverage`:"no runtime coverage",s=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${i}, and ${s}.`}function ge(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),((e.summary.extendedProjects??0)>0||e.summary.observedProjects>0)&&t.push("Some projects use extended or observed support tiers; command coverage may be partial."),t}async function We(e){let t=e.model??await q$1({workspacePath:e.workspacePath,includeEvidence:e.includeEvidence===true,observableScanDepth:e.observableScanDepth,now:e.now}),i=ne(e.agent),s=pe(t,e.scope),n=de(t,e.scope,s);if(e.strict===true&&n.status!=="passed"){let r=n.issues.map(g=>`${g.severity}:${g.code}:${g.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${r}`)}let c=e.now??new Date,a=t.facts??[],K=new Set((s?[s]:t.projects).map(r=>r.name)),R=a.filter(r=>r.project?K.has(r.project):true),H=(s?[s]:t.projects).map(r=>{let g=R.filter(p=>p.project===r.name);return {name:r.name,path:r.path,kind:r.kind,category:r.category,runtime:r.runtime,framework:r.frameworkDisplayName,...r.generator?{generator:r.generator}:{},createCapability:r.createCapability,supportTier:r.supportTier,...r.governance?{governance:r.governance}:{},safeCommands:ce(r),importantFiles:r.importantFiles,facts:g}}),S=await me(t,e.workspacePath),F=E.join(e.workspacePath,p.knowledgeGraph),u=await A.pathExists(F)?await A.readJson(F).catch(()=>null):null,N=false;if(u?.schemaVersion===q.knowledgeGraph)try{b(u,t),N=true;}catch{}let $=le(t),M=ie(t,s,c),b$2=await C(e.workspacePath,p.impact,q.impact),l=await C(e.workspacePath,p.doctor,q.doctor),v=await C(e.workspacePath,p.analyze,q.analyze),k=await C(e.workspacePath,p.readiness,q.readiness),h=await C(e.workspacePath,p.verify,q.verify),w=await C(e.workspacePath,p.explain,q.explain),f$1=await C(e.workspacePath,p.diff,q.diff),B=b$2?.summary?{changed:b$2.summary.changed,risk:b$2.summary.risk,affectedProjects:b$2.summary.affectedProjects,blastRadius:b$2.summary.blastRadius,recommendedCommands:b$2.summary.recommendedCommands}:void 0,U=l?.summary?{verdict:l.summary.verdict,totalIssues:l.summary.totalIssues,advisoryFindings:l.summary.advisoryFindings,blockingFindings:l.summary.blockingFindings,unknownFindings:l.summary.unknownFindings,hasSystemErrors:l.summary.hasSystemErrors,topSignals:(()=>{let r=Array.isArray(l.projects)?l.projects:[],g=[];for(let p of r.slice(0,6)){let te=Array.isArray(p.probes)?p.probes:[];for(let y of te.slice(0,10))(y?.status==="fail"||y?.severity==="error")&&g.push({label:y.label,scope:y.scope,issueClass:y.issueClass,status:y.status,severity:y.severity,recommendation:y.recommendation});}return g.slice(0,8)})()}:void 0,J=v?.summary?{score:v.summary.score,verdict:v.summary.verdict,findingCounts:v.summary.findings,topFindings:(Array.isArray(v.findings)?v.findings:[]).filter(p=>p?.severity==="fail"||p?.severity==="warn").slice(0,8).map(p=>({severity:p.severity,title:p.title,target:p.target,remediation:p.remediation}))}:void 0,X=k?{overallStatus:k.overallStatus,blocking:k.blocking,blockingReasons:k.blockingReasons,evidencePath:k.evidencePath,gates:Array.isArray(k.gates)?k.gates.slice(0,6).map(r=>({gate:r.gate,status:r.status,summary:r.summary})):void 0}:void 0,Q=h?.summary?{verdict:h.summary.verdict,exitCode:h.summary.exitCode,stepsFailed:h.summary.stepsFailed,stepsMissing:h.summary.stepsMissing,blockingReasons:h.blockingReasons,missingEvidence:h.missingEvidence}:void 0,Y=w?{summary:w.summary,blockingReasons:w.blockingReasons,releaseVerdict:w.releaseVerdict,evidenceFreshness:w.evidenceFreshness,sections:Array.isArray(w.sections)?w.sections.slice(0,4).map(r=>({id:r.id,title:r.title,body:r.body})):void 0}:void 0,Z=f$1?.summary?{changed:f$1.summary.changed,addedProjects:f$1.summary.addedProjects,removedProjects:f$1.summary.removedProjects,changedProjects:f$1.summary.changedProjects,workspaceChanges:f$1.summary.workspaceChanges,validationChanges:f$1.summary.validationChanges,gitChangedFiles:f$1.summary.gitChangedFiles}:void 0,ee=M.map(r=>f({id:`context.command.${r.id}`,label:`${r.id} safe command`,scope:"command",value:{display:r.display,execute:r.execute,scope:r.scope},...r.project?{project:r.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:t.generatedAt,now:c,sourceArtifact:p.agentContext,sourcePath:`safeCommands.${r.id}`,reason:"Context safe commands are derived from workspace model command capabilities."}})),I=[...R,...ee],W=g({facts:I,generatedAt:c.toISOString(),now:c}),j=b$1();return {schemaVersion:re,generatedAt:c.toISOString(),agent:i,workspaceSummary:$,modelRef:p.model,knowledgeGraph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,available:N,...typeof u?.quality?.entityCount=="number"?{entityCount:u.quality.entityCount}:{},...typeof u?.quality?.relationCount=="number"?{relationCount:u.quality.relationCount}:{},...typeof u?.quality?.proofCount=="number"?{proofCount:u.quality.proofCount}:{},queryCommands:[x("workspace graph search <query> --limit 12 --json"),x("workspace graph entities [kind] --json"),x("workspace graph evidence <entity-or-relation> --json"),x("workspace graph path <from> <to> --json")]},intelligenceChain:{schemaVersion:j.schemaVersion,contractPath:j.contractPath,currentStep:"context",canonicalReadOrder:[...j.consumers.agents.canonicalReadOrder]},workspace:{name:t.workspace.name,root:`workspace:${t.workspace.name}`,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e.scope??"workspace",...s?{activeProject:s.name}:{}},projects:H,safeCommands:M,facts:I,factFreshness:W,evidence:S,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:n,agentInstructions:[`Read \`${p.agentIndex}\` first, then this context pack and linked evidence reports.`,"Use `workspace graph search <query> --limit 12 --json` for bounded, proof-backed retrieval before loading the full graph.",`Load \`${p.knowledgeGraph}\` only when a complete graph export is explicitly required.`,"Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Treat `facts[].freshness.verifyBeforeUse` as a hard refresh requirement before using that fact in advice, fixes, or release decisions.","Do not carry extracted facts beyond their freshness contract; re-read or regenerate evidence when the contract says stale, unknown, live, or verify-before-use.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx workspai workspace agent-sync --write --refresh-context`."],unsafeAssumptions:[...ge(t),...W.verifyBeforeUseFacts>0?[`${W.verifyBeforeUseFacts} fact(s) require verification before use; do not treat them as durable workspace structure.`]:[]],humanSummary:[$,`Evidence available: ${S.available.length}. Missing evidence groups: ${S.missing.join(", ")||"none"}.`,s?`Active project scope: ${s.name} (${s.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
2
+ `),impactSummary:B,doctorSummary:U,analyzeSummary:J,readinessSummary:X,verifySummary:Q,explainSummary:Y,diffSummary:Z}}async function je(e,t){return g$1(t,se,d(e))}export{re as a,se as b,We as c,je as d};
@@ -1 +1 @@
1
- export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-KDY4X7SQ.js';
1
+ export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-M37ALD4V.js';
@@ -0,0 +1 @@
1
+ export{d as DOCTOR_WORKSPACE_REPORT_PATH,q as applyEnvKeyAddFix,m as applyFileAppendFix,n as applyFileCopyFix,l as applyFileCreateFix,p as applyJsonEditFix,r as applyMakefileTargetFix,k as applyPackageScriptFix,i as assertOperationPathInsideProject,j as assertOperationPathInsideProjectResolved,h as buildRepairOperationIdentity,t as computeDoctorFixAwareExitCode,s as computeDoctorGateExitCode,o as decodeJsonPointerSegment,g as parseInternalRepairCommand,f as parsePackageScriptFix,e as resolveDoctorPolicyProfile,u as runDoctor}from'./chunk-N2Q4MSSP.js';
@@ -0,0 +1 @@
1
+ export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,q as linkGoalChangeTransaction,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-BM2F5C4J.js';
@@ -0,0 +1 @@
1
+ import {c as c$3}from'./chunk-EBEAJIBI.js';import {c}from'./chunk-ABMB6MJT.js';import {j,i,d as d$1,f,c as c$2,e as e$1,h as h$1}from'./chunk-BM2F5C4J.js';export{b as GOAL_AGENT_HANDOFF_SCHEMA_VERSION,f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,g as GOAL_LIFECYCLE_RESULT_SCHEMA_VERSION,d as GOAL_PACK_LAST_RUN_PATH,a as GOAL_PACK_SCHEMA_VERSION,c as GOAL_PLAN_RESULT_SCHEMA_VERSION}from'./chunk-BM2F5C4J.js';import {f as f$1}from'./chunk-EZPLMAW2.js';import {a as a$1}from'./chunk-MBICKDYP.js';import {b}from'./chunk-EBQS5T7Q.js';import {b as b$1}from'./chunk-AD4ZY3RF.js';import {e,h}from'./chunk-OZXCNVGW.js';import {a}from'./chunk-AFIFZTOY.js';import {d,c as c$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import C from'path';import _ from'fs-extra';var ve=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,ye=/(?:^|\s)(?:\/(?:home|Users|private|var|tmp|mnt|opt|srv|root|workspace|workspaces|data|Volumes|etc|usr|run|dev|proc|sys)\/[^\s]+|[A-Za-z]:[\\/][^\s]+|\\\\[^\\\s]+\\[^\s]+)/,Pe=/(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:github_pat_|gh[pousr]_|glpat-|npm_|xox[baprs]-|sk-(?:proj-)?)[A-Za-z0-9_-]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[A-Za-z0-9_-]{20,}|\bBearer\s+[A-Za-z0-9._~+/-]{16,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/]+:[^\s@/]+@|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^\s]{6,})/i,je=[{category:"test-coverage",patterns:[/\b(?:test\s+)?coverage\b/i,/\bcoverage\s+(?:to|above|at least)\b/i]},{category:"dependency-security",patterns:[/\b(?:dependency|dependencies|package|packages)\b.*\b(?:security|vulnerab|audit)\b/i,/\b(?:security|vulnerab|audit)\b.*\b(?:dependency|dependencies|package|packages)\b/i]},{category:"release-readiness",patterns:[/\brelease[ -]readiness\b/i,/\bready (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare (?:this |the )?(?:workspace|project) for release\b/i,/\bprepare\b[^\n]{0,80}\bfor release\b/i]},{category:"defect-repair",patterns:[/\b(?:fix|repair|resolve|debug)\b.*\b(?:bug|error|failure|issue|regression)\b/i]},{category:"performance",patterns:[/\b(?:performance|latency|throughput|cpu|optimi[sz]e|faster|slower)\b/i,/\b(?:memory\s+(?:allocation|consumption|footprint|leak|pressure|usage)|out[ -]of[ -]memory|heap|ram)\b/i]},{category:"refactor",patterns:[/\b(?:refactor|restructure|decouple|extract|simplify|cleanup|clean up)\b/i]},{category:"documentation",patterns:[/\b(?:document|documentation|readme|guide|tutorial|docs)\b/i]},{category:"feature-change",patterns:[/\b(?:add|build|create|enforce|enhance|harden|implement|improve|introduce|support)\b/i]},{category:"system-understanding",patterns:[/\b(?:understand|explain|map|find|where|how|architecture|analy[sz]e|search)\b/i]}];function Ge(e){if(typeof e!="string")throw new Error("Goal intent must be text.");let t=e.trim().replace(/\s+/g," ");if(!t)throw new Error("Goal intent cannot be empty.");if(t.length>2e3)throw new Error("Goal intent exceeds the 2000 character safety limit.");if(ve.test(t))throw new Error("Goal intent contains unsupported control characters.");if(ye.test(t))throw new Error("Goal intent contains a machine-local absolute path. Use a workspace-relative path or project scope.");if(Pe.test(t))throw new Error("Goal intent appears to contain secret material and was not persisted.");return t}function Ce(e){let t=e.match(/\b(?:coverage\D{0,24})?((?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?))\s*(?:%|percent(?:age)?(?:\s+points?)?)/i);if(!t||!/coverage/i.test(e))return null;let r=Number(t[1]);return Number.isFinite(r)&&r>=0&&r<=100?r:null}var re=[{runtime:"cpp",patterns:[/\bc\+\+/i,/\bcpp\b/i]},{runtime:"dotnet",patterns:[/\.net\b/i,/\bdotnet\b/i,/\bc#/i,/\bcsharp\b/i]},{runtime:"node",patterns:[/\bnode(?:\.js)?\b/i,/\btypescript\b/i,/\bjavascript\b/i,/\b(?:js|ts)\b/i]},{runtime:"python",patterns:[/\bpython\b/i,/\bpytest\b/i]},{runtime:"go",patterns:[/\bgolang\b/i,/\bgo(?:\s+(?:test|coverage|tests))\b/i]},{runtime:"java",patterns:[/\bjava\b/i,/\bjunit\b/i,/\bjacoco\b/i]},{runtime:"rust",patterns:[/\brust\b/i,/\bcargo\b/i]},{runtime:"php",patterns:[/\bphp\b/i,/\bphpunit\b/i]},{runtime:"ruby",patterns:[/\bruby\b/i,/\brspec\b/i]},{runtime:"kotlin",patterns:[/\bkotlin\b/i]},{runtime:"scala",patterns:[/\bscala\b/i]},{runtime:"clojure",patterns:[/\bclojure\b/i]},{runtime:"elixir",patterns:[/\belixir\b/i]},{runtime:"deno",patterns:[/\bdeno\b/i]},{runtime:"bun",patterns:[/\bbun\b/i]},{runtime:"c",patterns:[/\bc(?:\s+(?:test|coverage|tests|code))\b/i]}];function Ae(e){return re.filter(t=>t.patterns.some(r=>r.test(e))).map(t=>t.runtime)}function K(e,t={}){let r=Ge(e),n=je.filter(u=>u.patterns.some(j=>j.test(r))).map(u=>u.category),a=n.some(u=>u!=="feature-change")?n.filter(u=>u!=="feature-change"):n,s=a[0]??"feature-change",l=Ce(r),d=Ae(r),p=d.length===0&&t.selectedCoverageRuntime?[t.selectedCoverageRuntime]:d,m=[...new Set((t.availableCoverageRuntimes??[]).filter(u=>re.some(j=>j.runtime===u)))].sort(),b=[];return a.length>1&&a[0]!=="test-coverage"&&b.push(`The intent also contains signals for: ${a.slice(1).join(", ")}.`),s==="test-coverage"&&l===null&&b.push("A numeric test coverage target is required for machine verification."),s==="test-coverage"&&p.length>1&&b.push(`The Goal names multiple coverage runtimes: ${p.join(", ")}. Select one runtime per Goal.`),s==="test-coverage"&&p.length===0&&m.length>1&&b.push(`Coverage scope is ambiguous across detected runtimes: ${m.join(", ")}. Name one runtime or language in the Goal.`),s==="test-coverage"&&p.length===1&&m.length>0&&!m.includes(p[0])&&b.push(`The requested ${p[0]} coverage runtime is not present in the selected scope. Detected runtimes: ${m.join(", ")}.`),{original:r,normalized:r.toLocaleLowerCase("en-US"),statement:r.replace(/[.!?]+$/,""),category:s,confidence:a.length===1?"high":a.length>1?"medium":"low",ambiguities:b,...l===null?{}:{requestedTarget:{metric:"test-coverage-percent",operator:"at-least",value:l,...p.length===1?{runtime:p[0]}:{}}}}}function oe(e){let t={"test-coverage":["test suite coverage configuration instrumentation","CI tests LCOV Cobertura JaCoCo LLVM coverage"],"dependency-security":["dependency manifest lockfile security audit vulnerability"],"release-readiness":["release pipeline readiness gates build test deploy"],"defect-repair":["failure error test implementation call path"],"feature-change":["API implementation module dependency tests"],refactor:["module dependency ownership implementation tests"],performance:["performance benchmark latency throughput runtime"],documentation:["documentation README guide architecture decision"],"system-understanding":["architecture service API dependency ownership"]};return [...new Set([e.statement,...t[e.category]])].slice(0,3)}var ae="contracts/workspace-intelligence/goal-pack.v1.json",se="contracts/workspace-intelligence/goal-agent-handoff.v1.json",Re="contracts/workspace-intelligence/goal-plan-result.v1.json",pe="contracts/workspace-intelligence/goal-index.v1.json",ue=new Set(["node","bun","deno","python","go","java","dotnet","rust","php","ruby","elixir","clojure","scala","kotlin","c","cpp"]);function Se(e,t){let r=e.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)??[],n=new Set(t.map(m=>m.toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"")).filter(Boolean)),a=[];for(let m=0;m<r.length;){let b=0;for(let u=Math.min(4,r.length-m);u>=1;u-=1){let j=r.slice(m,m+u).join("").toLocaleLowerCase("en-US").replace(/[^a-z0-9]/g,"");if(n.has(j)){b=u;break}}if(b>0){m+=b;continue}a.push(r[m]),m+=1;}let s=a.findIndex((m,b)=>{let u=m.toLocaleLowerCase("en-US"),j=a[b+1]?.toLocaleLowerCase("en-US");return u==="without"&&["breaking","changing","modifying","removing"].includes(j??"")||u==="while"&&["keeping","maintaining","preserving"].includes(j??"")}),l=s>=2?a.slice(0,s):a,d=l.length>=2?l.join(" "):e;if(s<2)return [d];let p=a.slice(s).filter(m=>!["without","while","breaking","changing","modifying","removing","keeping","maintaining","preserving"].includes(m.toLocaleLowerCase("en-US")));return p.length>0?[d,p.join(" ")]:[d]}function ie(e){return e.split(C.sep).join("/")}function V(e,t){return C.resolve(t.absolutePath??C.join(e,t.path))}function ce(e){let t=e.requested.trim().replace(/^project:/,"");if(!t)throw new Error("Project goal scope must name a project.");let r=C.isAbsolute(t)?C.resolve(t):null,n=e.model.projects.filter(a=>a.name===t||ie(a.path)===ie(t)||r!==null&&V(e.workspacePath,a)===r);if(n.length!==1)throw new Error(n.length===0?`Project goal scope was not found in the canonical model: ${t}`:`Project goal scope is ambiguous in the canonical model: ${t}`);return n[0]}async function Ee(e){let t=await a$1(e);if(t.status==="miss")throw new Error(`Canonical model and live graph evidence are required (${t.reason}). Run \`workspai workspace intelligence run --for-agent generic --strict --json\` or retry with --refresh.`);let{model:r,graph:n}=t;return a(r,"contracts/workspace-intelligence/workspace-model.v1.json","Goal source model"),a(n,"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json","Goal source graph"),b$1(n,r),{model:r,graph:n}}function le(e){let t=e.scope.trim();if(t==="workspace")return {kind:"workspace",projects:e.model.projects.map(n=>n.name).sort(),selectionSource:e.selectionSource,resolution:"selected"};let r=t.startsWith("projects:")?"projects:":t.startsWith("project:")&&t.slice(8).includes(",")?"project:":null;if(r){let n=t.slice(r.length).split(",").map(l=>l.trim()).filter(Boolean);if(n.length<2)throw new Error("A project-set Goal scope must name at least two projects.");let a=n.map(l=>ce({workspacePath:e.workspacePath,model:e.model,requested:l})),s=[...new Set(a.map(l=>l.name))].sort();if(s.length!==n.length)throw new Error("A project-set Goal scope must not contain duplicate projects.");return {kind:"project-set",projects:s,selectionSource:e.selectionSource,resolution:"selected"}}if(t)return {kind:"project",projects:[ce({workspacePath:e.workspacePath,model:e.model,requested:t}).name],selectionSource:e.selectionSource,resolution:"selected"};throw new Error("Goal scope cannot be empty.")}async function Ie(e){if(e.explicitScope?.trim())return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:e.explicitScope,selectionSource:"explicit"}),selectionRequired:false};if(e.invocationProjectPath){let t=C.resolve(e.invocationProjectPath),r=e.model.projects.filter(n=>V(e.workspacePath,n)===t);if(r.length!==1)throw new Error("The invocation project is not represented uniquely in the canonical workspace model. Refresh intelligence or pass --scope explicitly.");return {scope:{kind:"project",projects:[r[0].name],selectionSource:"invocation-project",resolution:"selected"},selectionRequired:false}}if(e.model.projects.length===1)return {scope:{kind:"project",projects:[e.model.projects[0].name],selectionSource:"single-project-workspace",resolution:"selected"},selectionRequired:false};if(e.selectScope){let t=await e.selectScope({workspaceName:e.model.workspace.name,projects:e.model.projects.map(n=>({name:n.name,runtime:n.runtime,runtimeCandidates:[...n.runtimeCandidates].sort(),framework:n.framework})).sort((n,a)=>n.name.localeCompare(a.name))}),r=t.kind==="workspace"?"workspace":t.projects.length===1?`project:${t.projects[0]}`:`projects:${t.projects.join(",")}`;return {scope:le({workspacePath:e.workspacePath,model:e.model,scope:r,selectionSource:"interactive"}),selectionRequired:false}}return {scope:{kind:"workspace",projects:e.model.projects.map(t=>t.name).sort(),selectionSource:"workspace",resolution:"selection-required"},selectionRequired:true}}function Te(e,t){if(t.kind==="workspace")return {entities:e.quality.entityCount,relationships:e.quality.relationCount,proofs:e.quality.proofCount,unresolved:e.quality.unknownCount,proofCoveragePercent:Number((e.quality.relationProofCoverageRatio*100).toFixed(2))};let r=new Set(t.projects),n=e.entities.filter(p=>p.projectId!==void 0&&r.has(p.projectId)),a=new Set(n.map(p=>p.id)),s=e.relations.filter(p=>a.has(p.from)||a.has(p.to)),l=new Set([...n.flatMap(p=>p.proofIds),...s.flatMap(p=>p.proofIds)]),d=s.filter(p=>p.proofIds.length>0).length;return {entities:n.length,relationships:s.length,proofs:l.size,unresolved:s.length-d,proofCoveragePercent:s.length===0?100:Number((d/s.length*100).toFixed(2))}}function xe(e){let t=new Map;for(let n of e){let a=t.get(n.kind)??[];a.push(n),t.set(n.kind,a);}let r=[];for(let n=0;[...t.values()].some(a=>n<a.length);n+=1)for(let a of t.values()){let s=a[n];s&&r.push(s);}return r}async function _e(e){let t=C.join(e.workspacePath,p.intelligenceRun),r=await _.readJson(t).catch(()=>null),a=(Array.isArray(r?.stages)?r.stages:[]).filter(o=>o.status==="blocked"||o.status==="failed").map(o=>String(o.id??"unknown")).sort(),s=r?.status,l={status:s==="passed"?"passed":s==="blocked"||s==="failed"?"blocked":"unknown",artifact:p.intelligenceRun,blockedStages:a},d={status:"not-applicable",runtime:null,runtimeChoices:[],runner:null,existingEvidence:[],prerequisites:[]};if(e.intent.category==="test-coverage"){let o=e.intent.requestedTarget?.runtime;if(e.intent.ambiguities.some(P=>P.startsWith("Coverage scope is ambiguous")||P.startsWith("The Goal names multiple coverage runtimes")||P.startsWith("The selected projects do not share a common canonical coverage runtime")||P.startsWith("The requested ")))d={status:"requires-setup",runtime:o??null,runtimeChoices:e.coverageRuntimeChoices,runner:null,existingEvidence:[],prerequisites:["Select exactly one detected runtime or language for this coverage Goal."]};else {let P=o?e.projects.filter(c=>c.runtimeCandidates.includes(o)):e.projects,i=await Promise.all(P.map(async c=>({project:c,capability:await c$3(V(e.workspacePath,c),o??(ue.has(c.runtime)?c.runtime:"unknown"))}))),h=i.map(c=>c.capability.status);d={status:h.includes("unsupported")?"unsupported":h.includes("requires-setup")?"requires-setup":"available",runtime:i.length===1?i[0].capability.runtime:[...new Set(i.map(c=>c.capability.runtime))].join(","),runtimeChoices:e.coverageRuntimeChoices,runner:i.length===1?i[0].capability.runner:[...new Set(i.flatMap(c=>c.capability.runner?[c.capability.runner]:[]))].join(",")||null,existingEvidence:i.flatMap(c=>c.capability.existingEvidence.map(A=>({project:c.project.name,...A}))).filter((c,A,w)=>w.findIndex(k=>k.project===c.project&&k.path===c.path&&k.sha256===c.sha256)===A).sort((c,A)=>c.project.localeCompare(A.project)||c.path.localeCompare(A.path)),prerequisites:[...new Set(i.flatMap(c=>c.capability.prerequisites))].sort()};}}let p$1=oe(e.intent),m=[...Se(p$1[0],e.projects.map(o=>o.name)),...p$1.slice(1)].filter((o,y,P)=>P.indexOf(o)===y).slice(0,3),b=m.map((o,y)=>{let P=o.match(/[A-Za-z0-9][A-Za-z0-9+#.%_-]*/g)?.length??0,i=y===0&&P>=4?2:1,h=e.projects.map(w=>{let k=G=>f$1(e.graph,{query:o,projectId:w.name,...G?{kind:G}:{},limit:60,relationsPerEntity:0,minimumTermMatches:i}).entities,S=k(),de=[...new Set(e.graph.entities.filter(G=>G.projectId===w.name||G.projectId===void 0&&G.identity.scope==="workspace").map(G=>G.kind))].flatMap(G=>k(G).slice(0,8)),U=[...S,...de];return U.filter((G,me)=>U.findIndex(ge=>ge.id===G.id)===me)}),c=[],A=new Set;for(let w=0;h.some(k=>w<k.length);w+=1)for(let k of h){let S=k[w];!S||A.has(S.id)||(A.add(S.id),c.push(S));}return xe(c)}),u={"test-coverage":["test-suite"],"dependency-security":["package","module"],"release-readiness":["pipeline","deployment","lifecycle-stage"],"defect-repair":["test-suite","lifecycle-stage"],"feature-change":["project","runtime-unit","api","package","module","test-suite"],refactor:["package","module","api","test-suite"],performance:["lifecycle-stage","test-suite","pipeline"],documentation:["document","decision"],"system-understanding":["project","service","api","package","protocol"]},j=new Set(e.projects.map(o=>o.name)),v=e.graph.entities.filter(o=>o.proofIds.length>0&&(!o.projectId||j.has(o.projectId))&&u[e.intent.category].includes(o.kind)).sort((o,y)=>u[e.intent.category].indexOf(o.kind)-u[e.intent.category].indexOf(y.kind)||o.label.localeCompare(y.label)),f=[],M=new Set,E=o=>{!o||f.length>=20||M.has(o.id)||(M.add(o.id),f.push(o));},I=(e.intent.statement.match(/[A-Za-z][A-Za-z0-9+#.-]{1,}/g)??[]).length>=2,g=I?b[0]??[]:[];for(let o of g.slice(0,12))E(o);if(!I)for(let o of v)E(o);for(let o=0;f.length<20&&b.slice(1).some(y=>o<y.length);o+=1)for(let y of b.slice(1))E(y[o]);if(I)for(let o of v)E(o);for(let o of g.slice(12))E(o);let T=f.map(o=>({entityId:o.id,kind:o.kind,label:o.label,proofIds:o.proofIds.slice(0,12)})),L=b[0]?.length??0;return {workspaceIntelligence:l,measurement:d,retrieval:{status:I&&L>=3?"grounded":T.length>0?"partial":"empty",strategy:"deterministic-category-v1",queries:m,anchors:T}}}async function Le(e){let t=C.join(e,f);if(!await _.pathExists(t))return {schemaVersion:e$1,generatedAt:new Date(0).toISOString(),activeGoalId:null,goals:[]};let r=await _.readJson(t);a(r,pe,"Goal index");try{i(r);}catch(n){let a=h$1(r);if(!(a!==null&&n instanceof Error&&n.message==="Goal index is inconsistent: activeGoalId must identify the only selected actionable lifecycle entry.")||!a)throw n;return a}return r}function Ne(e,t,r){let n=e.goals.find(l=>l.id===t.id),a=t.state==="ready-to-plan",s={id:t.id,fingerprint:t.fingerprint,objective:t.intent.statement,category:t.intent.category,state:t.state,lifecycle:n?.lifecycle==="cancelled"?"cancelled":a?"active":"planned",scope:t.scope,createdAt:n?.createdAt??t.generatedAt,updatedAt:r,goalPack:t.artifacts.goalPack,agentHandoff:t.artifacts.agentHandoff,...n?.verifiedGoalId?{verifiedGoalId:n.verifiedGoalId}:{},...n?.repairTransactionId?{repairTransactionId:n.repairTransactionId}:{},...n?.repairTransactionIds?{repairTransactionIds:n.repairTransactionIds}:{},...n?.changeTransactionId?{changeTransactionId:n.changeTransactionId}:{},...n?.changeTransactionIds?{changeTransactionIds:n.changeTransactionIds}:{},...n?.verificationReceipt?{verificationReceipt:n.verificationReceipt}:{}};return {schemaVersion:e$1,generatedAt:r,activeGoalId:s.lifecycle==="active"?t.id:e.activeGoalId===t.id?null:e.activeGoalId,goals:[...e.goals.filter(l=>l.id!==t.id).map(l=>s.lifecycle==="active"&&l.lifecycle==="active"?{...l,lifecycle:"planned",updatedAt:r}:l),s].sort((l,d)=>l.id.localeCompare(d.id))}}async function et(e$1){let t=b({startPath:C.resolve(e$1.startPath),explicitWorkspacePath:e$1.workspacePath,strict:true,requireProjectMembership:true});if(!t)throw new Error("No canonical Workspai workspace could be resolved.");let r=C.resolve(t.workspacePath);e$1.refresh&&await c({workspacePath:r,strict:false,agent:"generic"});let{model:n,graph:a$1}=await Ee(r),s=await Ie({workspacePath:r,invocationProjectPath:t.projectPath,model:n,explicitScope:e$1.scope,selectScope:e$1.selectScope}),l=s.scope,d$2=n.projects.filter(i=>l.projects.includes(i.name));if(d$2.length===0)throw new Error("A Goal Pack requires at least one registered project in its selected scope.");let p$1=e$1.maxAttempts??5;if(!Number.isInteger(p$1)||p$1<1||p$1>25)throw new Error("--max-attempts must be an integer from 1 to 25.");let m=new Date().toISOString(),b$1=d(n),u=d$2.map(i=>({name:i.name,runtimes:[...new Set(i.runtimeCandidates.filter(h=>ue.has(h)))].sort()})),j$1=[...new Set(u.flatMap(i=>i.runtimes))].sort(),v=u.length<=1?j$1:u[0].runtimes.filter(i=>u.every(h=>h.runtimes.includes(i))),f$1=K(e$1.intent,{availableCoverageRuntimes:v,...e$1.runtime?{selectedCoverageRuntime:e$1.runtime}:v.length===1?{selectedCoverageRuntime:v[0]}:{}});if(e$1.runtime&&!v.includes(e$1.runtime)){let i=e$1.runtime,h=u.filter(c=>!c.runtimes.includes(i)).map(c=>c.name);throw new Error(d$2.length>1&&h.length>0?`--runtime ${e$1.runtime} is not canonical for every project in the selected Goal scope. Missing from: ${h.join(", ")}. Split the projects into runtime-compatible Goal scopes.`:`--runtime ${e$1.runtime} is not present in the canonical Workspace Model for the selected Goal scope. Available runtimes: ${v.join(", ")||"none"}.`)}if(e$1.runtime&&f$1.category!=="test-coverage")throw new Error("--runtime is valid only for a test-coverage Goal.");if(e$1.runtime&&f$1.requestedTarget?.runtime&&f$1.requestedTarget.runtime!==e$1.runtime)throw new Error(`--runtime ${e$1.runtime} conflicts with the ${f$1.requestedTarget.runtime} runtime named in the Goal intent.`);if(!s.selectionRequired&&f$1.category==="test-coverage"&&f$1.requestedTarget&&!f$1.requestedTarget.runtime&&v.length>1&&!e$1.runtime&&e$1.selectCoverageRuntime){let i=await e$1.selectCoverageRuntime({workspaceName:n.workspace.name,scope:l,projects:d$2.map(h=>({name:h.name,runtime:h.runtime,runtimeCandidates:[...h.runtimeCandidates].sort()})),runtimes:v});if(!v.includes(i))throw new Error("The selected coverage runtime is outside the canonical Goal scope.");f$1=K(e$1.intent,{availableCoverageRuntimes:v,selectedCoverageRuntime:i});}!s.selectionRequired&&f$1.category==="test-coverage"&&d$2.length>1&&v.length===0&&(f$1={...f$1,ambiguities:[`The selected projects do not share a common canonical coverage runtime: ${u.map(i=>`${i.name} (${i.runtimes.join(", ")||"none"})`).join("; ")}. Split them into runtime-compatible Goal scopes so every selected project is verified.`,...f$1.ambiguities]}),s.selectionRequired&&(f$1={...f$1,ambiguities:[`Goal scope is unresolved across ${l.projects.length} registered projects: ${l.projects.join(", ")}. Select one project, multiple projects, or the entire workspace.`,...f$1.ambiguities]});let M=await _e({workspacePath:r,projects:d$2,graph:a$1,intent:f$1,coverageRuntimeChoices:v}),E={generatedAt:m,intent:f$1,workspaceName:n.workspace.name,scope:l,sourceBinding:{model:{artifact:p.model,schemaVersion:q.model,hashAlgorithm:"sha256",hashSemantics:"workspace-model-structural-v1",hash:b$1,generatedAt:n.generatedAt},graph:{artifact:p.knowledgeGraph,schemaVersion:q.knowledgeGraph,hashAlgorithm:"sha256",hashSemantics:"canonical-json-v1",hash:c$1(a$1),generatedAt:a$1.generatedAt,modelHash:a$1.source.hash,...a$1.source.inputs?.hash?{inputHash:a$1.source.inputs.hash}:{}}},preflight:M,baseline:{projectCount:d$2.length,runtimes:[...new Set(d$2.flatMap(i=>i.runtimeCandidates))].sort(),frameworks:[...new Set(d$2.map(i=>i.framework))].sort(),graph:Te(a$1,l)},maxAttempts:p$1,consumer:e$1.consumer??"generic"},I={digestCanonical:c$1},{goalPack:g,handoff:T}=j(E,I);a(g,ae,"Goal Pack"),a(T,se,"Goal agent handoff");let L=false,o=async()=>{let i=C.join(r,g.artifacts.goalPack),h=C.join(r,g.artifacts.agentHandoff),[c,A]=await Promise.all([_.pathExists(i),_.pathExists(h)]);if(c!==A)throw new Error(`Goal Pack instance is incomplete and cannot be resumed: ${g.id}`);if(!c)return;let[w,k]=await Promise.all([_.readJson(i),_.readJson(h)]);a(w,ae,"Persisted Goal Pack"),a(k,se,"Persisted goal agent handoff");let S=j({...E,generatedAt:w.generatedAt,sourceBinding:w.sourceBinding},I);if(w.id!==g.id||k.goalId!==g.id||c$1(w)!==c$1(S.goalPack)||c$1(k)!==c$1(S.handoff))throw new Error(`Goal Pack instance failed immutable integrity validation: ${g.id}`);g=w,T=k,L=true;};if(e$1.dryRun)await o();else {let i$1=`.workspai/goals/${g.id}/publication`;await e(r,i$1,async()=>{await o();let h$1=Ne(await Le(r),g,new Date().toISOString());a(h$1,pe,"Goal index"),i(h$1),await h(r,d$1,L?[{relativePath:d$1,payload:g},{relativePath:f,payload:h$1}]:[{relativePath:g.artifacts.goalPack,payload:g},{relativePath:g.artifacts.agentHandoff,payload:T},{relativePath:d$1,payload:g},{relativePath:f,payload:h$1}]);});}let y=[g.artifacts.goalPack,g.artifacts.agentHandoff,d$1,f],P={schemaVersion:c$2,result:g.state==="needs-confirmation"?"needs-confirmation":g.state==="blocked"?"blocked":g.state==="needs-evidence"?"needs-evidence":"planned",resolution:{source:t.source,invocationScope:t.projectPath?"project":"workspace"},goalPack:g,agentHandoff:T,writtenArtifacts:e$1.dryRun?[]:L?[d$1,f]:y,dryRun:e$1.dryRun===true,resumed:L};return a(P,Re,"Goal plan result"),P}export{et as planGoalPack};
package/dist/index.d.ts CHANGED
@@ -74,6 +74,17 @@ declare function getPublishedContractVersions(): {
74
74
  goalPlanResult: "workspai.goal-plan-result.v1";
75
75
  goalIndex: "workspai.goal-index.v1";
76
76
  goalLifecycleResult: "workspai.goal-lifecycle-result.v1";
77
+ decisionEvent: "workspai.decision-event.v1";
78
+ decisionTransaction: "workspai.decision-transaction.v1";
79
+ decisionCheckpoint: "workspai.decision-checkpoint.v1";
80
+ changeOperationResult: "workspai.change-operation-result.v1";
81
+ architectureChangeLease: "workspai.architecture-change-lease.v1";
82
+ predictedArchitectureChange: "workspai.predicted-architecture-change.v1";
83
+ architectureSurpriseReport: "workspai.architecture-surprise-report.v1";
84
+ proofCarryingChangeCapsule: "workspai.proof-carrying-change-capsule.v1";
85
+ proofCarryingChangeList: "workspai.proof-carrying-change-list.v1";
86
+ proofCarryingChangeCapsuleValidation: "workspai.proof-carrying-change-capsule-validation.v1";
87
+ proofCarryingChangeCapsuleExport: "workspai.proof-carrying-change-capsule-export.v1";
77
88
  workspaceIntelligenceArchitecture: string;
78
89
  workspaceIntelligenceChain: "workspai-workspace-intelligence-chain-v1";
79
90
  workspaceIntelligenceArtifacts: {
@@ -287,6 +298,17 @@ declare function getVersionContract(): {
287
298
  goalPlanResult: "workspai.goal-plan-result.v1";
288
299
  goalIndex: "workspai.goal-index.v1";
289
300
  goalLifecycleResult: "workspai.goal-lifecycle-result.v1";
301
+ decisionEvent: "workspai.decision-event.v1";
302
+ decisionTransaction: "workspai.decision-transaction.v1";
303
+ decisionCheckpoint: "workspai.decision-checkpoint.v1";
304
+ changeOperationResult: "workspai.change-operation-result.v1";
305
+ architectureChangeLease: "workspai.architecture-change-lease.v1";
306
+ predictedArchitectureChange: "workspai.predicted-architecture-change.v1";
307
+ architectureSurpriseReport: "workspai.architecture-surprise-report.v1";
308
+ proofCarryingChangeCapsule: "workspai.proof-carrying-change-capsule.v1";
309
+ proofCarryingChangeList: "workspai.proof-carrying-change-list.v1";
310
+ proofCarryingChangeCapsuleValidation: "workspai.proof-carrying-change-capsule-validation.v1";
311
+ proofCarryingChangeCapsuleExport: "workspai.proof-carrying-change-capsule-export.v1";
290
312
  workspaceIntelligenceArchitecture: string;
291
313
  workspaceIntelligenceChain: "workspai-workspace-intelligence-chain-v1";
292
314
  workspaceIntelligenceArtifacts: {
@@ -493,6 +515,17 @@ declare function getGlobalCommandCapabilities(): {
493
515
  goalPlanResult: "workspai.goal-plan-result.v1";
494
516
  goalIndex: "workspai.goal-index.v1";
495
517
  goalLifecycleResult: "workspai.goal-lifecycle-result.v1";
518
+ decisionEvent: "workspai.decision-event.v1";
519
+ decisionTransaction: "workspai.decision-transaction.v1";
520
+ decisionCheckpoint: "workspai.decision-checkpoint.v1";
521
+ changeOperationResult: "workspai.change-operation-result.v1";
522
+ architectureChangeLease: "workspai.architecture-change-lease.v1";
523
+ predictedArchitectureChange: "workspai.predicted-architecture-change.v1";
524
+ architectureSurpriseReport: "workspai.architecture-surprise-report.v1";
525
+ proofCarryingChangeCapsule: "workspai.proof-carrying-change-capsule.v1";
526
+ proofCarryingChangeList: "workspai.proof-carrying-change-list.v1";
527
+ proofCarryingChangeCapsuleValidation: "workspai.proof-carrying-change-capsule-validation.v1";
528
+ proofCarryingChangeCapsuleExport: "workspai.proof-carrying-change-capsule-export.v1";
496
529
  workspaceIntelligenceArchitecture: string;
497
530
  workspaceIntelligenceChain: "workspai-workspace-intelligence-chain-v1";
498
531
  workspaceIntelligenceArtifacts: {
@@ -619,8 +652,8 @@ declare function getGlobalCommandCapabilities(): {
619
652
  };
620
653
  workspace: {
621
654
  command: string;
622
- subcommands: ("archive" | "snapshot" | "list" | "import" | "goal" | "init" | "sync" | "agent-sync" | "model" | "intelligence" | "run" | "contract" | "share" | "remediation-plan" | "graph" | "diff" | "impact" | "verify" | "explain" | "why" | "trace" | "registry" | "foundation" | "watch" | "context" | "repair" | "feedback" | "eval" | "mcp" | "policy" | "export" | "hydrate" | "connect")[];
623
- intelligenceSubcommands: ("snapshot" | "goal" | "agent-sync" | "model" | "intelligence" | "contract" | "remediation-plan" | "graph" | "diff" | "impact" | "verify" | "explain" | "why" | "trace" | "watch" | "context" | "repair" | "feedback" | "eval" | "mcp")[];
655
+ subcommands: ("list" | "explain" | "verify" | "export" | "archive" | "snapshot" | "import" | "goal" | "init" | "sync" | "agent-sync" | "model" | "intelligence" | "run" | "contract" | "share" | "remediation-plan" | "graph" | "diff" | "impact" | "why" | "trace" | "registry" | "foundation" | "watch" | "context" | "repair" | "feedback" | "eval" | "mcp" | "policy" | "hydrate" | "connect")[];
656
+ intelligenceSubcommands: ("explain" | "verify" | "snapshot" | "goal" | "agent-sync" | "model" | "intelligence" | "contract" | "remediation-plan" | "graph" | "diff" | "impact" | "why" | "trace" | "watch" | "context" | "repair" | "feedback" | "eval" | "mcp")[];
624
657
  };
625
658
  commandMap: any;
626
659
  runtimeInventory: RuntimeCommandInventoryPayload;