workspai 0.74.0 → 0.75.1

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 (140) hide show
  1. package/contracts/agent-framework-capabilities.v1.json +454 -0
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +166 -0
  3. package/contracts/create-planner-capabilities.v1.json +24 -0
  4. package/contracts/extension-cli-compatibility.v1.json +6 -0
  5. package/contracts/published-contract-catalog.v1.json +30 -0
  6. package/contracts/runtime-command-surface.v1.json +71 -1
  7. package/contracts/workspace-intelligence/agent-framework-adapter-manifest.v1.json +2127 -0
  8. package/contracts/workspace-intelligence/agent-framework-admission-candidate.v1.json +193 -0
  9. package/contracts/workspace-intelligence/agent-framework-change-plan.v1.json +280 -0
  10. package/contracts/workspace-intelligence/agent-framework-conformance-report.v1.json +269 -0
  11. package/contracts/workspace-intelligence/agent-framework-ownership-receipt.v1.json +147 -0
  12. package/contracts/workspace-intelligence/workspace-model.v1.json +4 -0
  13. package/contracts/workspace-intelligence-architecture.v1.json +28 -2
  14. package/dist/analyze-Z3EZNJRI.js +1 -0
  15. package/dist/{artifact-remediation-plan-OVTQM7HN.js → artifact-remediation-plan-HD5K52UJ.js} +1 -1
  16. package/dist/autopilot-release-T6XFRWZT.js +1 -0
  17. package/dist/capabilities-command-VK3LQLP2.js +1 -0
  18. package/dist/{chunk-UHT2SW7O.js → chunk-25V5XMWB.js} +1 -1
  19. package/dist/chunk-2CT5SN2L.js +2 -0
  20. package/dist/chunk-2GWQ6NZV.js +1 -0
  21. package/dist/{chunk-KCIET26G.js → chunk-2OCJKLTW.js} +1 -1
  22. package/dist/{chunk-SAZXL36B.js → chunk-3WQ5TYCO.js} +1 -1
  23. package/dist/chunk-4VSQNSGH.js +9 -0
  24. package/dist/chunk-566NQQTJ.js +97 -0
  25. package/dist/chunk-5EEXLM45.js +1 -0
  26. package/dist/chunk-65AE7EC5.js +2 -0
  27. package/dist/{chunk-PKKSRXUS.js → chunk-6B7L4NZE.js} +1 -1
  28. package/dist/{chunk-BTJPTJLT.js → chunk-6KMR5PKQ.js} +3 -3
  29. package/dist/chunk-6NSJBKKK.js +4 -0
  30. package/dist/chunk-7NKM6EHE.js +7 -0
  31. package/dist/chunk-ABUSBLBH.js +1 -0
  32. package/dist/{chunk-TVSMNF5G.js → chunk-AICCXYY5.js} +4 -4
  33. package/dist/{chunk-FE5R6EUV.js → chunk-BLEIUQL6.js} +1 -1
  34. package/dist/{chunk-37SWTS2B.js → chunk-BR6QIYQS.js} +1 -1
  35. package/dist/chunk-CMLLERGG.js +418 -0
  36. package/dist/{chunk-MGL6DBOR.js → chunk-COOVCORC.js} +1 -1
  37. package/dist/chunk-DFREJHG7.js +1 -0
  38. package/dist/{chunk-C43NXRRE.js → chunk-DJH2CH42.js} +1 -1
  39. package/dist/chunk-FU6SQ2ND.js +1 -0
  40. package/dist/{chunk-IQFXLJIM.js → chunk-HDISUL3F.js} +1 -1
  41. package/dist/{chunk-JK6XEF7K.js → chunk-JKAAKE4Z.js} +1 -1
  42. package/dist/{chunk-G6ADWA2B.js → chunk-M6DVNC6X.js} +1 -1
  43. package/dist/chunk-NGZF4YJS.js +2 -0
  44. package/dist/{chunk-4JJDDL3X.js → chunk-NI5QWBZK.js} +1 -1
  45. package/dist/{chunk-3WHE7V4M.js → chunk-NLRZFIC6.js} +1 -1
  46. package/dist/{chunk-5Y4YRYZI.js → chunk-NRIMJMTF.js} +8 -8
  47. package/dist/{chunk-EBQS5T7Q.js → chunk-OA2YJN22.js} +1 -1
  48. package/dist/chunk-OH6LV5JP.js +6 -0
  49. package/dist/chunk-PTI743SC.js +7 -0
  50. package/dist/{chunk-TBOIXIQA.js → chunk-QBKOPXKC.js} +1 -1
  51. package/dist/chunk-RTD5D35M.js +13 -0
  52. package/dist/{chunk-XVTN5DDV.js → chunk-RU3UT7GJ.js} +1 -1
  53. package/dist/{chunk-DPC5DKH6.js → chunk-SCKEFXF5.js} +1 -1
  54. package/dist/chunk-UE7ART6X.js +1 -0
  55. package/dist/{chunk-FY4X2VOE.js → chunk-VHMDWRDG.js} +2 -2
  56. package/dist/chunk-VJQPIH2S.js +681 -0
  57. package/dist/{chunk-H333GKL4.js → chunk-W7I65IXY.js} +1 -1
  58. package/dist/{chunk-ZNKZ2KXR.js → chunk-WPPRUFJW.js} +1 -1
  59. package/dist/{chunk-HAZGSAKP.js → chunk-ZI54C2AO.js} +1 -1
  60. package/dist/{create-EKA2QG5R.js → create-P4XJVZCL.js} +1 -1
  61. package/dist/{demo-kit-RKTHTXHJ.js → demo-kit-ALW6OSQV.js} +1 -1
  62. package/dist/{doctor-BXSNADVR.js → doctor-PFN6KB6P.js} +1 -1
  63. package/dist/{dotnet-webapi-clean-VJX6SGGP.js → dotnet-webapi-clean-6Z4EXEJY.js} +1 -1
  64. package/dist/{goal-lifecycle-XXWNMIAD.js → goal-lifecycle-BDWTWS55.js} +1 -1
  65. package/dist/goal-pack-5JDNZFKV.js +1 -0
  66. package/dist/{gofiber-standard-I6ASLOEE.js → gofiber-standard-TDJQIVQZ.js} +1 -1
  67. package/dist/{gogin-standard-U2LSRLIP.js → gogin-standard-UEF3IHSJ.js} +1 -1
  68. package/dist/index.d.ts +18 -0
  69. package/dist/index.js +276 -251
  70. package/dist/{pipeline-JLOC2SUT.js → pipeline-OUYS4ZYV.js} +1 -1
  71. package/dist/{project-agent-entry-ZNUHGCVC.js → project-agent-entry-75WO3QWP.js} +1 -1
  72. package/dist/{project-intelligence-lens-W72OUEDW.js → project-intelligence-lens-JCHFOIA7.js} +1 -1
  73. package/dist/{project-test-coverage-5PXAHBYQ.js → project-test-coverage-3P5FH6E5.js} +1 -1
  74. package/dist/proof-carrying-change-LAYV4LTI.js +1 -0
  75. package/dist/{pythonRapidkitExec-44ORGQ4R.js → pythonRapidkitExec-UMFLDIYR.js} +1 -1
  76. package/dist/{rust-axum-JMV7UPO7.js → rust-axum-4TRVPFMB.js} +1 -1
  77. package/dist/{springboot-standard-OC2RS3KC.js → springboot-standard-COWL75GT.js} +1 -1
  78. package/dist/verified-goal-75KGBWTE.js +1 -0
  79. package/dist/{workspace-XTIGVLGH.js → workspace-CBQDOUSH.js} +1 -1
  80. package/dist/{workspace-agent-sync-TN6QDNBR.js → workspace-agent-sync-RTOTO3DY.js} +1 -1
  81. package/dist/{workspace-archive-OSMU3CK6.js → workspace-archive-3AURTMYA.js} +1 -1
  82. package/dist/{workspace-context-Y3TNY2XZ.js → workspace-context-STRZO2N3.js} +1 -1
  83. package/dist/{workspace-contract-GRZY7WRD.js → workspace-contract-PMHUUKFM.js} +1 -1
  84. package/dist/{workspace-explain-KUYHJFLY.js → workspace-explain-CATMJUMN.js} +1 -1
  85. package/dist/{workspace-feedback-D6HJLKBQ.js → workspace-feedback-FF34CSJE.js} +1 -1
  86. package/dist/{workspace-foundation-ZBUJTR56.js → workspace-foundation-OULCDCXG.js} +1 -1
  87. package/dist/{workspace-graph-stream-KC2XUAE4.js → workspace-graph-stream-Q55CI4K4.js} +1 -1
  88. package/dist/{workspace-history-WWPS4U7H.js → workspace-history-EQG5UBKW.js} +1 -1
  89. package/dist/{workspace-intelligence-26YT6KMN.js → workspace-intelligence-3RPZRWSF.js} +1 -1
  90. package/dist/{workspace-intelligence-benchmark-QFVTUBDO.js → workspace-intelligence-benchmark-R5MEGJQS.js} +1 -1
  91. package/dist/{workspace-intelligence-runner-HVYKHCTX.js → workspace-intelligence-runner-BNZUYUUN.js} +1 -1
  92. package/dist/{workspace-knowledge-graph-RL3I2FHY.js → workspace-knowledge-graph-VJLD35ES.js} +1 -1
  93. package/dist/workspace-knowledge-graph-snapshot-TQAKDDUA.js +1 -0
  94. package/dist/workspace-mcp-serve-67NTYD67.js +3 -0
  95. package/dist/workspace-model-6TKZMNEF.js +1 -0
  96. package/dist/{workspace-onboarding-BY6RUBBH.js → workspace-onboarding-7V7EH3RH.js} +1 -1
  97. package/dist/{workspace-readme-HA6XLDME.js → workspace-readme-4FCKAQME.js} +1 -1
  98. package/dist/{workspace-registry-summary-VKTJ7PHV.js → workspace-registry-summary-ILVO7DEU.js} +1 -1
  99. package/dist/{workspace-repair-engine-RBM7NCGI.js → workspace-repair-engine-2VGFB3DJ.js} +1 -1
  100. package/dist/workspace-run-X7KV6MIT.js +1 -0
  101. package/dist/{workspace-verify-NFJ7RKKT.js → workspace-verify-VQWYDAF2.js} +1 -1
  102. package/dist/workspace-watch-2Z636HWS.js +1 -0
  103. package/docs/README.md +4 -1
  104. package/docs/agent-framework-adapters.md +279 -0
  105. package/docs/ci-workflows.md +15 -8
  106. package/docs/commands-reference.md +22 -0
  107. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +5 -0
  108. package/docs/creating-workspaces-and-projects.md +18 -4
  109. package/docs/workspace-operations.md +12 -2
  110. package/package.json +7 -1
  111. package/scripts/enterprise-package-smoke.mjs +98 -0
  112. package/dist/analyze-IA33T6MY.js +0 -1
  113. package/dist/autopilot-release-T327V7QK.js +0 -1
  114. package/dist/capabilities-command-NFGX42CH.js +0 -1
  115. package/dist/chunk-46QH3ZVI.js +0 -105
  116. package/dist/chunk-5EVBOUYW.js +0 -3
  117. package/dist/chunk-773WUMFU.js +0 -681
  118. package/dist/chunk-D6BL7ARI.js +0 -2
  119. package/dist/chunk-DLLHUG2Q.js +0 -9
  120. package/dist/chunk-DTLLIA2C.js +0 -1
  121. package/dist/chunk-FYR4FD7K.js +0 -1
  122. package/dist/chunk-H5DRKXXC.js +0 -2
  123. package/dist/chunk-IUOMBLRR.js +0 -2
  124. package/dist/chunk-K3FXRBER.js +0 -4
  125. package/dist/chunk-LEEOZRWR.js +0 -7
  126. package/dist/chunk-NCZJUPG5.js +0 -97
  127. package/dist/chunk-ND5YAC4T.js +0 -1
  128. package/dist/chunk-SVGUAVMG.js +0 -1
  129. package/dist/chunk-TGDXD4CD.js +0 -1
  130. package/dist/chunk-VLKX5U4H.js +0 -13
  131. package/dist/chunk-YYELANJO.js +0 -7
  132. package/dist/goal-pack-NTHYLISY.js +0 -1
  133. package/dist/proof-carrying-change-WLUPMUO7.js +0 -1
  134. package/dist/verified-goal-6O2JZOOR.js +0 -1
  135. package/dist/workspace-knowledge-graph-snapshot-JEJMRQZL.js +0 -1
  136. package/dist/workspace-mcp-serve-2FGRXJG4.js +0 -3
  137. package/dist/workspace-model-2ODVOWDQ.js +0 -1
  138. package/dist/workspace-run-JCA5WPCR.js +0 -1
  139. package/dist/workspace-watch-3DBBB6IP.js +0 -1
  140. /package/dist/{chunk-K33JJVQZ.js → chunk-VN2MKTQO.js} +0 -0
@@ -1,4 +1,4 @@
1
- import {g,b,i,d as d$1,e,f}from'./chunk-DPC5DKH6.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$2,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {c}from'./chunk-EBQS5T7Q.js';import {a}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {s,p,t}from'./chunk-ODK4LCEL.js';import {u,h,g as g$1}from'./chunk-VQZ5PI5J.js';import Ee from'crypto';import se from'fs';import y from'fs/promises';import l from'path';import {execa}from'execa';import Q from'fs-extra';async function Z(e,t){let[n,r]=await Promise.all([Q.realpath(e).catch(()=>null),Q.realpath(t).catch(()=>null)]);if(!n||!r)return null;let s=l.relative(n,r);return !s||l.isAbsolute(s)||s===".."||s.startsWith(`..${l.sep}`)?null:(await Q.stat(r).catch(()=>null))?.isFile()?r:null}var Ge=s.projectContextAgent.schemaVersion,yt=["managed","local","off"],ae="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",Ce="<!-- WORKSPAI:PROJECT-GROUNDING:END -->",te="<!-- WORKSPAI:GENERATED-PROJECT-SKILL -->",B=".agents/skills/workspai-grounding/SKILL.md";function ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function A(e){try{return JSON.parse(await y.readFile(e,"utf8"))}catch(t){return null}}function $(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function _(e,t,n){let r=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(r);if(!l.isAbsolute(e)&&!s)return $(r);if(s&&process.platform!=="win32")return null;let a=l.resolve(e),i=l.relative(n,a);if(i&&!i.startsWith("..")&&!l.isAbsolute(i))return $(i);let c=l.relative(t,a);return c&&!c.startsWith("..")&&!l.isAbsolute(c)?`workspace:${$(c)}`:null}function I(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[a,i])=>a.length>0?s.split(a).join(i):s,e)}function Re(e,t){return ke(e?.adoption)?.mode==="linked"?"adopted":ke(e?.import)?"imported":t}function We(e){if(!e.model)return null;let t=$(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||$(n.path)===t)??null}function U(e,t){e[t]=(e[t]??0)+1;}var we=["project","language","service","api","endpoint","schema","protocol","runtime-unit","lifecycle-stage","database","queue","container","deployment","pipeline","environment","test-suite","owner","decision","document","package","file","module","symbol"],oe=48,ye=16,re=12*1024;function Oe(e,t=oe,n=re){let r={language:12,api:8,service:8,endpoint:8,schema:8,protocol:8,"runtime-unit":12,"lifecycle-stage":12,file:4,module:4,symbol:4},s=new Map,a={};for(let u of e)U(a,u.kind);for(let u of we)s.set(u,e.filter(w=>w.kind===u).sort((w,f)=>w.label.localeCompare(f.label)||w.id.localeCompare(f.id)).slice(0,r[u]??6));let i=[],c={},h=0,g=0,d=true;for(;i.length<t&&d;){d=false;for(let u of we){let w=s.get(u)?.[g];if(!w)continue;let f=Buffer.byteLength(JSON.stringify(w));if(!(h+f>n)&&(i.push(w),h+=f,U(c,u),d=true,i.length>=t))break}g+=1;}let m=Object.fromEntries(Object.entries(a).map(([u,w])=>[u,w-(c[u]??0)]).filter(([,u])=>u>0).sort(([u],[w])=>u.localeCompare(w)));return {entities:i,selectedBytes:h,selectedByKind:c,omittedByKind:m}}function Ke(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},languages:{},semantic:{protocolConceptCount:0,protocolImplementationBindings:0,equivalenceBindings:0,generationBindings:0,runtimeUnitCount:0,lifecycleStageCount:0,runtimeCoverage:[]},projection:{mode:"stratified-byte-bounded",maxEntities:oe,byteBudget:re,selectedBytes:0,eligibleCount:0,selectedCount:0,omittedCount:0,selectedByKind:{},omittedByKind:{}},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(o=>o.kind==="project"&&(o.id===t||o.label===t||o.projectId===t)),r=new Set(e.entities.filter(o=>o.projectId===t||o.id===n?.id||o.kind==="project"&&o.label===t).map(o=>o.id));n&&r.add(n.id);let s=e.relations.filter(o=>r.has(o.from)||r.has(o.to)),a=new Set(r);for(let o of s)a.add(o.from),a.add(o.to);let i=e.entities.filter(o=>a.has(o.id)),c=new Set,h={},g={},d={},m=new Set(i.filter(o=>o.kind==="language").map(o=>o.attributes.language).filter(o=>typeof o=="string"));for(let o of i){U(h,o.kind);let k=typeof o.attributes.language=="string"?o.attributes.language:void 0;if(k&&o.kind==="language")d[k]={fileCount:typeof o.attributes.fileCount=="number"?o.attributes.fileCount:0,symbolCount:d[k]?.symbolCount??0,generatedFileCount:typeof o.attributes.generatedFileCount=="number"?o.attributes.generatedFileCount:0};else if(k&&(o.kind==="file"||o.kind==="symbol")){let p=d[k]??{fileCount:0,symbolCount:0,generatedFileCount:0};o.kind==="file"&&!m.has(k)?(p.fileCount+=1,o.attributes.generated===true&&(p.generatedFileCount+=1)):o.kind==="symbol"&&(p.symbolCount+=1),d[k]=p;}for(let p of o.proofIds)c.add(p);}for(let o of s){U(g,o.kind);for(let k of o.proofIds)c.add(k);}let u=e.proofs.filter(o=>c.has(o.id)),w=[...new Set(e.entities.filter(o=>a.has(o.id)&&o.projectId&&o.projectId!==t).map(o=>o.projectId))].sort(),f=e.diagnostics.filter(o=>(!o.entityIds||o.entityIds.length===0)&&(!o.relationIds||o.relationIds.length===0)||o.entityIds?.some(k=>a.has(k))||o.relationIds?.some(k=>s.some(p=>p.id===k))).map(o=>({code:o.code,severity:o.severity,message:o.message,...o.recommendation?{recommendation:o.recommendation}:{}})),j=(o,k)=>({project:k,kind:o.kind,source:o.source,confidence:o.confidence,evidence:[...new Set(o.evidence.map(p=>p.file.replace(/\\/g,"/")))].sort()}),P=e.projectTopology.edges.filter(o=>o.from===t).map(o=>j(o,o.to)).sort((o,k)=>`${o.project}:${o.kind}`.localeCompare(`${k.project}:${k.kind}`)),S=e.projectTopology.edges.filter(o=>o.to===t).map(o=>j(o,o.from)).sort((o,k)=>`${o.project}:${o.kind}`.localeCompare(`${k.project}:${k.kind}`)),N=Oe(i),T=N.entities,G=i.filter(o=>o.kind==="runtime-unit"),b=new Set(T.map(o=>o.id)),W=[...s].sort((o,k)=>{let p=Number(b.has(o.from)||b.has(o.to));return Number(b.has(k.from)||b.has(k.to))-p||o.id.localeCompare(k.id)}).slice(0,16),H=new Set([...T.flatMap(o=>o.proofIds),...W.flatMap(o=>o.proofIds)]),D=u.filter(o=>H.has(o.id)).sort((o,k)=>o.id.localeCompare(k.id)).slice(0,16);return {entityCount:i.length,relationCount:s.length,proofCount:u.length,entitiesByKind:h,relationsByKind:g,languages:Object.fromEntries(Object.entries(d).sort(([o],[k])=>o.localeCompare(k))),semantic:{protocolConceptCount:h.protocol??0,protocolImplementationBindings:g["implements-protocol"]??0,equivalenceBindings:g["equivalent-to"]??0,generationBindings:(g["generated-from"]??0)+(g["generated-by"]??0),runtimeUnitCount:G.length,lifecycleStageCount:h["lifecycle-stage"]??0,runtimeCoverage:[...new Set(G.map(o=>o.attributes.runtime).filter(o=>typeof o=="string"))].sort()},projection:{mode:"stratified-byte-bounded",maxEntities:oe,byteBudget:re,selectedBytes:N.selectedBytes,eligibleCount:i.length,selectedCount:T.length,omittedCount:Math.max(0,i.length-T.length),selectedByKind:Object.fromEntries(Object.entries(N.selectedByKind).sort(([o],[k])=>o.localeCompare(k))),omittedByKind:N.omittedByKind},relatedProjects:w,proofArtifacts:[...new Set(D.map(o=>o.artifact))].sort().slice(0,24),entities:T,relations:W,proofs:D,topology:{status:P.length>0||S.length>0?"proven":e.projectTopology.nodes.some(o=>o.id===t)?"unproven":"unavailable",dependencies:P,dependents:S},diagnostics:f}}function Se(e,t,n){return Array.isArray(e)?e.map(r=>typeof r=="string"?I(r,t,n):r):typeof e=="string"?I(e,t,n):e}function _e(e,t,n){return {id:e.id,kind:e.kind,label:I(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([r,s])=>[r,Se(s,t,n)])),proofIds:[...e.proofIds].sort()}}function Fe(e,t,n){let r=(...a)=>e.filter(i=>a.includes(i.kind)).map(i=>_e(i,t,n)).slice(0,4),s=[];for(let a of e){for(let[i,c]of Object.entries(a.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(i)&&(s.push({entityId:a.id,label:I(a.label,t,n),attribute:i,value:Se(c,t,n)}),s.length>=8))break;if(s.length>=8)break}return {services:r("service"),packages:r("package"),protocols:r("protocol"),runtimeUnits:r("runtime-unit"),lifecycleStages:r("lifecycle-stage"),apis:r("api"),endpoints:r("endpoint"),dataStores:r("database","queue"),deployments:r("container","deployment","environment"),pipelines:r("pipeline"),tests:r("test-suite"),owners:r("owner"),decisions:r("decision"),ports:s}}function Be(e,t,n){let r=_(e.artifact,t,n);return r?{id:e.id,provider:e.provider,artifact:r,...e.pointer?{pointer:I(e.pointer,t,n)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function Me(e,t,n){let r=[],s=await A(l.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let d of s.blockers)typeof d=="string"&&(d.startsWith(`${n}:`)||d.includes(`project:${n}`)||d.includes(`project ${n}`))&&r.push({source:"workspace-report-index",severity:"error",message:I(d,e,t)});let a=await A(l.join(e,".workspai","reports","doctor-project-last-run.json")),i=await A(l.join(e,".workspai","reports","doctor-last-run.json")),c=i?.projects?.find(d=>d.name===n),g=[...a?.project&&(a.projectName===n||a.project.name===n)?[{generatedAt:a.generatedAt,project:a.project}]:[],...c?[{generatedAt:i?.generatedAt,project:c}]:[]].sort((d,m)=>{let u=typeof d.generatedAt=="string"&&Date.parse(d.generatedAt)||0;return (typeof m.generatedAt=="string"&&Date.parse(m.generatedAt)||0)-u})[0];if(g)for(let d of c$1({project:g.project}))r.push({source:"doctor-project",severity:d.status==="blocking"?"error":"warning",message:I(d.message,e,t),...d.id?{code:d.id}:{}});return [...new Map(r.map(d=>[`${d.source}:${d.code??""}:${d.message}`,d])).values()].slice(0,32)}function ne(e,t=[]){return typeof e=="string"?/^[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(e)||t.some(n=>n.length>0&&(e.includes(n)||e.includes(n.replace(/\\/g,"/")))):Array.isArray(e)?e.some(n=>ne(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>ne(n,t)):false}function De(e){return Ee.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Je(e){let t$1=l.resolve(e.workspacePath),n=l.resolve(e.projectPath),r=u(n,"project.json").find(p=>se.existsSync(p)),s=r?await A(r):null,a$1=await A(l.join(t$1,".workspai","workspace.contract.json")),i=l.resolve(n),c=a$1?.projects?.find(p=>p.externalPath?l.resolve(p.externalPath)===i:!p.relativePath||p.relativePath.startsWith("external/")?false:l.resolve(t$1,p.relativePath)===i)??a$1?.projects?.find(p=>p.slug===e.projectName||p.slug===l.basename(n)),h=e.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??l.basename(n),g=c?.relativePath??(()=>{let p=$(l.relative(t$1,n));return !p||p.startsWith("..")?`external/${h}`:p})(),d$1=await A(l.join(t$1,p.model)),m=await A(l.join(t$1,p.knowledgeGraph)),u$1=d$1?d(d$1):void 0,w=!!(u$1&&m?.source.hash===u$1),f=We({model:d$1,projectName:h,relativePath:g}),j=Ke(w?m:null,h),P=await Me(t$1,n,h),S=j.proofs.map(p=>p.freshness),N=m?!w||S.includes("stale")?"stale":S.includes("unknown")?"unknown":"fresh":"missing",T=d$1?d$1.factFreshness?.status??"unknown":"missing",b$1=[...[...d$1?[]:[{code:"project.context.model-missing",severity:"warning",message:"The canonical Workspace Model has not been generated yet. Refresh workspace intelligence before relying on project topology."}],...d$1&&!f?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...m?[]:[{code:"project.context.graph-missing",severity:"warning",message:"The Workspace Knowledge Graph has not been generated yet. Run the workspace intelligence loop to build proof-backed relationships."}],...m&&!w?[{code:"project.context.graph-model-mismatch",severity:"warning",message:"The persisted Knowledge Graph does not match the current Workspace Model and was excluded from this project lens."}]:[]],...j.diagnostics].filter((p,E,Ne)=>Ne.findIndex(ie=>ie.code===p.code&&ie.message===p.message)===E),W=Math.max(0,b$1.length-ye+1),H=W>0?[...b$1.slice(0,ye-1),{code:"project.context.diagnostics-truncated",severity:"info",message:`${W} additional diagnostic(s) remain available in the canonical Workspace Knowledge Graph.`,recommendation:"Inspect workspace:.workspai/reports/workspace-knowledge-graph.json for the complete diagnostic set."}]:b$1,D=Re(s,e.relationship??c?.relationship??"managed"),o={schemaVersion:Ge,generatedAt:(e.now??new Date).toISOString(),workspace:{name:a$1?.workspace?.name??d$1?.workspace.name??l.basename(t$1),...a$1?.workspace?.profile||d$1?.workspace.profile?{profile:a$1?.workspace?.profile??d$1?.workspace.profile}:{},relationship:D,contract:`workspace:${t.workspaceContract}`,projectKnowledgeGraph:t.projectKnowledgeGraphReference,model:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,index:`workspace:${p.agentIndex}`,context:`workspace:${p.agentContext}`,skillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`,access:{localBinding:t.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:h,relativePath:g,...f?.kind?{kind:f.kind}:{},...f?.runtime||c?.runtime?{runtime:f?.runtime??c?.runtime}:{},...f?.runtimeCandidates?.length?{runtimeCandidates:[...f.runtimeCandidates].sort()}:{},...f?.framework||c?.framework?{framework:f?.framework??c?.framework}:{},...f?.kit||c?.kit?{kit:f?.kit??c?.kit}:{},...f?.supportTier?{supportTier:f.supportTier}:{},...f?.governance?{governance:f.governance}:{},commands:{supported:[...f?.commands.supported??[]].sort(),unsupported:[...f?.commands.unsupported??[]].sort(),fleetStages:[...f?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((f?.importantFiles??[]).map(p=>_(p,t$1,n)).filter(p=>p!==null))].sort()},intelligence:{...d$1?.generatedAt?{modelGeneratedAt:d$1.generatedAt}:{},...m?.generatedAt?{graphGeneratedAt:m.generatedAt}:{},...m?.source.hash?{graphModelHash:m.source.hash}:{},entityCount:j.entityCount,relationCount:j.relationCount,proofCount:j.proofCount,entitiesByKind:j.entitiesByKind,relationsByKind:j.relationsByKind,languages:j.languages,semantic:j.semantic,projection:{...j.projection,continuationCommand:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`},relatedProjects:j.relatedProjects,freshness:{model:T,graph:N,graphMatchesModel:w},topology:{...j.topology,dependencies:j.topology.dependencies.map(p=>({...p,evidence:p.evidence.map(E=>_(E,t$1,n)).filter(E=>E!==null)})),dependents:j.topology.dependents.map(p=>({...p,evidence:p.evidence.map(E=>_(E,t$1,n)).filter(E=>E!==null)}))},surfaces:Fe(j.entities,t$1,n),diagnostics:H.map(p=>({...p,message:I(p.message,t$1,n),...p.recommendation?{recommendation:I(p.recommendation,t$1,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",t.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${t.goalPackLastRun}`,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`],projectProofArtifacts:[...new Set(j.proofArtifacts.map(p=>_(p,t$1,n)).filter(p=>p!==null))],relations:j.relations.map(p=>({id:p.id,from:p.from,to:p.to,kind:p.kind,derivation:p.derivation,trust:p.trust,confidence:p.confidence,proofIds:[...p.proofIds].sort()})),proofs:j.proofs.map(p=>Be(p,t$1,n)).filter(p=>p!==null)},blockers:P,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"workspai agent bootstrap --for-agent generic --strict --json",successCondition:"ready"},workspaceLocator:{command:"workspai project workspace status --json",successCondition:"resolved",outputClassification:"machine-local",persistence:"forbidden",disclosure:"forbidden",portableUriScheme:"workspace:"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[b,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",t.projectContextAgent,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`],degradedMode:{allowCompleteArchitectureClaims:false,requireDisclosure:true}},commands:{refresh:"workspai workspace intelligence run --for-agent generic --strict --json",verify:"workspai workspace verify --strict --json",graphSearch:`workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(ne(o,[t$1,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let k={...o,integrity:{algorithm:"sha256",...u$1?{modelHash:u$1}:{},payloadHash:De(o),portable:true,absolutePathsEmitted:false}};return a(k,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),k}function Ue(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(s=>`\`${s}\``).join(", "):"No proven cross-project relation is currently available.",n=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
1
+ import {g,b,i,d as d$1,e,f}from'./chunk-SCKEFXF5.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$2,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {c}from'./chunk-OA2YJN22.js';import {a}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {u,h,g as g$1}from'./chunk-VQZ5PI5J.js';import {s,p,t}from'./chunk-ODK4LCEL.js';import Ee from'crypto';import se from'fs';import y from'fs/promises';import l from'path';import {execa}from'execa';import Q from'fs-extra';async function Z(e,t){let[n,r]=await Promise.all([Q.realpath(e).catch(()=>null),Q.realpath(t).catch(()=>null)]);if(!n||!r)return null;let s=l.relative(n,r);return !s||l.isAbsolute(s)||s===".."||s.startsWith(`..${l.sep}`)?null:(await Q.stat(r).catch(()=>null))?.isFile()?r:null}var Ge=s.projectContextAgent.schemaVersion,yt=["managed","local","off"],ae="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",Ce="<!-- WORKSPAI:PROJECT-GROUNDING:END -->",te="<!-- WORKSPAI:GENERATED-PROJECT-SKILL -->",B=".agents/skills/workspai-grounding/SKILL.md";function ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function A(e){try{return JSON.parse(await y.readFile(e,"utf8"))}catch(t){return null}}function $(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function _(e,t,n){let r=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(r);if(!l.isAbsolute(e)&&!s)return $(r);if(s&&process.platform!=="win32")return null;let a=l.resolve(e),i=l.relative(n,a);if(i&&!i.startsWith("..")&&!l.isAbsolute(i))return $(i);let c=l.relative(t,a);return c&&!c.startsWith("..")&&!l.isAbsolute(c)?`workspace:${$(c)}`:null}function I(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[a,i])=>a.length>0?s.split(a).join(i):s,e)}function Re(e,t){return ke(e?.adoption)?.mode==="linked"?"adopted":ke(e?.import)?"imported":t}function We(e){if(!e.model)return null;let t=$(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||$(n.path)===t)??null}function U(e,t){e[t]=(e[t]??0)+1;}var we=["project","language","service","api","endpoint","schema","protocol","runtime-unit","lifecycle-stage","database","queue","container","deployment","pipeline","environment","test-suite","owner","decision","document","package","file","module","symbol"],oe=48,ye=16,re=12*1024;function Oe(e,t=oe,n=re){let r={language:12,api:8,service:8,endpoint:8,schema:8,protocol:8,"runtime-unit":12,"lifecycle-stage":12,file:4,module:4,symbol:4},s=new Map,a={};for(let u of e)U(a,u.kind);for(let u of we)s.set(u,e.filter(w=>w.kind===u).sort((w,f)=>w.label.localeCompare(f.label)||w.id.localeCompare(f.id)).slice(0,r[u]??6));let i=[],c={},h=0,g=0,d=true;for(;i.length<t&&d;){d=false;for(let u of we){let w=s.get(u)?.[g];if(!w)continue;let f=Buffer.byteLength(JSON.stringify(w));if(!(h+f>n)&&(i.push(w),h+=f,U(c,u),d=true,i.length>=t))break}g+=1;}let m=Object.fromEntries(Object.entries(a).map(([u,w])=>[u,w-(c[u]??0)]).filter(([,u])=>u>0).sort(([u],[w])=>u.localeCompare(w)));return {entities:i,selectedBytes:h,selectedByKind:c,omittedByKind:m}}function Ke(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},languages:{},semantic:{protocolConceptCount:0,protocolImplementationBindings:0,equivalenceBindings:0,generationBindings:0,runtimeUnitCount:0,lifecycleStageCount:0,runtimeCoverage:[]},projection:{mode:"stratified-byte-bounded",maxEntities:oe,byteBudget:re,selectedBytes:0,eligibleCount:0,selectedCount:0,omittedCount:0,selectedByKind:{},omittedByKind:{}},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(o=>o.kind==="project"&&(o.id===t||o.label===t||o.projectId===t)),r=new Set(e.entities.filter(o=>o.projectId===t||o.id===n?.id||o.kind==="project"&&o.label===t).map(o=>o.id));n&&r.add(n.id);let s=e.relations.filter(o=>r.has(o.from)||r.has(o.to)),a=new Set(r);for(let o of s)a.add(o.from),a.add(o.to);let i=e.entities.filter(o=>a.has(o.id)),c=new Set,h={},g={},d={},m=new Set(i.filter(o=>o.kind==="language").map(o=>o.attributes.language).filter(o=>typeof o=="string"));for(let o of i){U(h,o.kind);let k=typeof o.attributes.language=="string"?o.attributes.language:void 0;if(k&&o.kind==="language")d[k]={fileCount:typeof o.attributes.fileCount=="number"?o.attributes.fileCount:0,symbolCount:d[k]?.symbolCount??0,generatedFileCount:typeof o.attributes.generatedFileCount=="number"?o.attributes.generatedFileCount:0};else if(k&&(o.kind==="file"||o.kind==="symbol")){let p=d[k]??{fileCount:0,symbolCount:0,generatedFileCount:0};o.kind==="file"&&!m.has(k)?(p.fileCount+=1,o.attributes.generated===true&&(p.generatedFileCount+=1)):o.kind==="symbol"&&(p.symbolCount+=1),d[k]=p;}for(let p of o.proofIds)c.add(p);}for(let o of s){U(g,o.kind);for(let k of o.proofIds)c.add(k);}let u=e.proofs.filter(o=>c.has(o.id)),w=[...new Set(e.entities.filter(o=>a.has(o.id)&&o.projectId&&o.projectId!==t).map(o=>o.projectId))].sort(),f=e.diagnostics.filter(o=>(!o.entityIds||o.entityIds.length===0)&&(!o.relationIds||o.relationIds.length===0)||o.entityIds?.some(k=>a.has(k))||o.relationIds?.some(k=>s.some(p=>p.id===k))).map(o=>({code:o.code,severity:o.severity,message:o.message,...o.recommendation?{recommendation:o.recommendation}:{}})),j=(o,k)=>({project:k,kind:o.kind,source:o.source,confidence:o.confidence,evidence:[...new Set(o.evidence.map(p=>p.file.replace(/\\/g,"/")))].sort()}),P=e.projectTopology.edges.filter(o=>o.from===t).map(o=>j(o,o.to)).sort((o,k)=>`${o.project}:${o.kind}`.localeCompare(`${k.project}:${k.kind}`)),S=e.projectTopology.edges.filter(o=>o.to===t).map(o=>j(o,o.from)).sort((o,k)=>`${o.project}:${o.kind}`.localeCompare(`${k.project}:${k.kind}`)),N=Oe(i),T=N.entities,G=i.filter(o=>o.kind==="runtime-unit"),b=new Set(T.map(o=>o.id)),W=[...s].sort((o,k)=>{let p=Number(b.has(o.from)||b.has(o.to));return Number(b.has(k.from)||b.has(k.to))-p||o.id.localeCompare(k.id)}).slice(0,16),H=new Set([...T.flatMap(o=>o.proofIds),...W.flatMap(o=>o.proofIds)]),D=u.filter(o=>H.has(o.id)).sort((o,k)=>o.id.localeCompare(k.id)).slice(0,16);return {entityCount:i.length,relationCount:s.length,proofCount:u.length,entitiesByKind:h,relationsByKind:g,languages:Object.fromEntries(Object.entries(d).sort(([o],[k])=>o.localeCompare(k))),semantic:{protocolConceptCount:h.protocol??0,protocolImplementationBindings:g["implements-protocol"]??0,equivalenceBindings:g["equivalent-to"]??0,generationBindings:(g["generated-from"]??0)+(g["generated-by"]??0),runtimeUnitCount:G.length,lifecycleStageCount:h["lifecycle-stage"]??0,runtimeCoverage:[...new Set(G.map(o=>o.attributes.runtime).filter(o=>typeof o=="string"))].sort()},projection:{mode:"stratified-byte-bounded",maxEntities:oe,byteBudget:re,selectedBytes:N.selectedBytes,eligibleCount:i.length,selectedCount:T.length,omittedCount:Math.max(0,i.length-T.length),selectedByKind:Object.fromEntries(Object.entries(N.selectedByKind).sort(([o],[k])=>o.localeCompare(k))),omittedByKind:N.omittedByKind},relatedProjects:w,proofArtifacts:[...new Set(D.map(o=>o.artifact))].sort().slice(0,24),entities:T,relations:W,proofs:D,topology:{status:P.length>0||S.length>0?"proven":e.projectTopology.nodes.some(o=>o.id===t)?"unproven":"unavailable",dependencies:P,dependents:S},diagnostics:f}}function Se(e,t,n){return Array.isArray(e)?e.map(r=>typeof r=="string"?I(r,t,n):r):typeof e=="string"?I(e,t,n):e}function _e(e,t,n){return {id:e.id,kind:e.kind,label:I(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([r,s])=>[r,Se(s,t,n)])),proofIds:[...e.proofIds].sort()}}function Fe(e,t,n){let r=(...a)=>e.filter(i=>a.includes(i.kind)).map(i=>_e(i,t,n)).slice(0,4),s=[];for(let a of e){for(let[i,c]of Object.entries(a.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(i)&&(s.push({entityId:a.id,label:I(a.label,t,n),attribute:i,value:Se(c,t,n)}),s.length>=8))break;if(s.length>=8)break}return {services:r("service"),packages:r("package"),protocols:r("protocol"),runtimeUnits:r("runtime-unit"),lifecycleStages:r("lifecycle-stage"),apis:r("api"),endpoints:r("endpoint"),dataStores:r("database","queue"),deployments:r("container","deployment","environment"),pipelines:r("pipeline"),tests:r("test-suite"),owners:r("owner"),decisions:r("decision"),ports:s}}function Be(e,t,n){let r=_(e.artifact,t,n);return r?{id:e.id,provider:e.provider,artifact:r,...e.pointer?{pointer:I(e.pointer,t,n)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function Me(e,t,n){let r=[],s=await A(l.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let d of s.blockers)typeof d=="string"&&(d.startsWith(`${n}:`)||d.includes(`project:${n}`)||d.includes(`project ${n}`))&&r.push({source:"workspace-report-index",severity:"error",message:I(d,e,t)});let a=await A(l.join(e,".workspai","reports","doctor-project-last-run.json")),i=await A(l.join(e,".workspai","reports","doctor-last-run.json")),c=i?.projects?.find(d=>d.name===n),g=[...a?.project&&(a.projectName===n||a.project.name===n)?[{generatedAt:a.generatedAt,project:a.project}]:[],...c?[{generatedAt:i?.generatedAt,project:c}]:[]].sort((d,m)=>{let u=typeof d.generatedAt=="string"&&Date.parse(d.generatedAt)||0;return (typeof m.generatedAt=="string"&&Date.parse(m.generatedAt)||0)-u})[0];if(g)for(let d of c$1({project:g.project}))r.push({source:"doctor-project",severity:d.status==="blocking"?"error":"warning",message:I(d.message,e,t),...d.id?{code:d.id}:{}});return [...new Map(r.map(d=>[`${d.source}:${d.code??""}:${d.message}`,d])).values()].slice(0,32)}function ne(e,t=[]){return typeof e=="string"?/^[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(e)||t.some(n=>n.length>0&&(e.includes(n)||e.includes(n.replace(/\\/g,"/")))):Array.isArray(e)?e.some(n=>ne(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>ne(n,t)):false}function De(e){return Ee.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Je(e){let t$1=l.resolve(e.workspacePath),n=l.resolve(e.projectPath),r=u(n,"project.json").find(p=>se.existsSync(p)),s=r?await A(r):null,a$1=await A(l.join(t$1,".workspai","workspace.contract.json")),i=l.resolve(n),c=a$1?.projects?.find(p=>p.externalPath?l.resolve(p.externalPath)===i:!p.relativePath||p.relativePath.startsWith("external/")?false:l.resolve(t$1,p.relativePath)===i)??a$1?.projects?.find(p=>p.slug===e.projectName||p.slug===l.basename(n)),h=e.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??l.basename(n),g=c?.relativePath??(()=>{let p=$(l.relative(t$1,n));return !p||p.startsWith("..")?`external/${h}`:p})(),d$1=await A(l.join(t$1,p.model)),m=await A(l.join(t$1,p.knowledgeGraph)),u$1=d$1?d(d$1):void 0,w=!!(u$1&&m?.source.hash===u$1),f=We({model:d$1,projectName:h,relativePath:g}),j=Ke(w?m:null,h),P=await Me(t$1,n,h),S=j.proofs.map(p=>p.freshness),N=m?!w||S.includes("stale")?"stale":S.includes("unknown")?"unknown":"fresh":"missing",T=d$1?d$1.factFreshness?.status??"unknown":"missing",b$1=[...[...d$1?[]:[{code:"project.context.model-missing",severity:"warning",message:"The canonical Workspace Model has not been generated yet. Refresh workspace intelligence before relying on project topology."}],...d$1&&!f?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...m?[]:[{code:"project.context.graph-missing",severity:"warning",message:"The Workspace Knowledge Graph has not been generated yet. Run the workspace intelligence loop to build proof-backed relationships."}],...m&&!w?[{code:"project.context.graph-model-mismatch",severity:"warning",message:"The persisted Knowledge Graph does not match the current Workspace Model and was excluded from this project lens."}]:[]],...j.diagnostics].filter((p,E,Ne)=>Ne.findIndex(ie=>ie.code===p.code&&ie.message===p.message)===E),W=Math.max(0,b$1.length-ye+1),H=W>0?[...b$1.slice(0,ye-1),{code:"project.context.diagnostics-truncated",severity:"info",message:`${W} additional diagnostic(s) remain available in the canonical Workspace Knowledge Graph.`,recommendation:"Inspect workspace:.workspai/reports/workspace-knowledge-graph.json for the complete diagnostic set."}]:b$1,D=Re(s,e.relationship??c?.relationship??"managed"),o={schemaVersion:Ge,generatedAt:(e.now??new Date).toISOString(),workspace:{name:a$1?.workspace?.name??d$1?.workspace.name??l.basename(t$1),...a$1?.workspace?.profile||d$1?.workspace.profile?{profile:a$1?.workspace?.profile??d$1?.workspace.profile}:{},relationship:D,contract:`workspace:${t.workspaceContract}`,projectKnowledgeGraph:t.projectKnowledgeGraphReference,model:`workspace:${p.model}`,knowledgeGraph:`workspace:${p.knowledgeGraph}`,index:`workspace:${p.agentIndex}`,context:`workspace:${p.agentContext}`,skillsIndex:`workspace:${p.skillsIndex}`,boundedGraphSearch:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`,access:{localBinding:t.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:h,relativePath:g,...f?.kind?{kind:f.kind}:{},...f?.runtime||c?.runtime?{runtime:f?.runtime??c?.runtime}:{},...f?.runtimeCandidates?.length?{runtimeCandidates:[...f.runtimeCandidates].sort()}:{},...f?.framework||c?.framework?{framework:f?.framework??c?.framework}:{},...f?.kit||c?.kit?{kit:f?.kit??c?.kit}:{},...f?.supportTier?{supportTier:f.supportTier}:{},...f?.governance?{governance:f.governance}:{},commands:{supported:[...f?.commands.supported??[]].sort(),unsupported:[...f?.commands.unsupported??[]].sort(),fleetStages:[...f?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((f?.importantFiles??[]).map(p=>_(p,t$1,n)).filter(p=>p!==null))].sort()},intelligence:{...d$1?.generatedAt?{modelGeneratedAt:d$1.generatedAt}:{},...m?.generatedAt?{graphGeneratedAt:m.generatedAt}:{},...m?.source.hash?{graphModelHash:m.source.hash}:{},entityCount:j.entityCount,relationCount:j.relationCount,proofCount:j.proofCount,entitiesByKind:j.entitiesByKind,relationsByKind:j.relationsByKind,languages:j.languages,semantic:j.semantic,projection:{...j.projection,continuationCommand:`workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`},relatedProjects:j.relatedProjects,freshness:{model:T,graph:N,graphMatchesModel:w},topology:{...j.topology,dependencies:j.topology.dependencies.map(p=>({...p,evidence:p.evidence.map(E=>_(E,t$1,n)).filter(E=>E!==null)})),dependents:j.topology.dependents.map(p=>({...p,evidence:p.evidence.map(E=>_(E,t$1,n)).filter(E=>E!==null)}))},surfaces:Fe(j.entities,t$1,n),diagnostics:H.map(p=>({...p,message:I(p.message,t$1,n),...p.recommendation?{recommendation:I(p.recommendation,t$1,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",t.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${t.goalPackLastRun}`,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search <task-query> --scope project:${h} --limit 12 --json`],projectProofArtifacts:[...new Set(j.proofArtifacts.map(p=>_(p,t$1,n)).filter(p=>p!==null))],relations:j.relations.map(p=>({id:p.id,from:p.from,to:p.to,kind:p.kind,derivation:p.derivation,trust:p.trust,confidence:p.confidence,proofIds:[...p.proofIds].sort()})),proofs:j.proofs.map(p=>Be(p,t$1,n)).filter(p=>p!==null)},blockers:P,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"workspai agent bootstrap --for-agent generic --strict --json",successCondition:"ready"},workspaceLocator:{command:"workspai project workspace status --json",successCondition:"resolved",outputClassification:"machine-local",persistence:"forbidden",disclosure:"forbidden",portableUriScheme:"workspace:"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[b,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",t.projectContextAgent,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`],degradedMode:{allowCompleteArchitectureClaims:false,requireDisclosure:true}},commands:{refresh:"workspai workspace intelligence run --for-agent generic --strict --json",verify:"workspai workspace verify --strict --json",graphSearch:`workspai workspace graph search ${JSON.stringify(h)} --scope ${JSON.stringify(`project:${h}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(ne(o,[t$1,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let k={...o,integrity:{algorithm:"sha256",...u$1?{modelHash:u$1}:{},payloadHash:De(o),portable:true,absolutePathsEmitted:false}};return a(k,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),k}function Ue(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(s=>`\`${s}\``).join(", "):"No proven cross-project relation is currently available.",n=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
2
2
  `):"- No project-scoped graph diagnostic is currently recorded.",r=e.blockers.length>0?e.blockers.slice(0,12).map(s=>`- **${s.severity}${s.code?` \xB7 ${s.code}`:""}:** ${s.message}`).join(`
3
3
  `):"- No current project-scoped blocker is recorded.";return `# Workspai project grounding
4
4
 
@@ -0,0 +1,9 @@
1
+ import {f,e,h as h$1,g}from'./chunk-XF65LQ6M.js';import {a,b}from'./chunk-COOVCORC.js';import {b as b$1,c as c$1}from'./chunk-DFREJHG7.js';import {a as a$1}from'./chunk-NMXGSVMD.js';import {p,a as a$2}from'./chunk-M6DVNC6X.js';import {k as k$2,m,l}from'./chunk-7NKM6EHE.js';import {h}from'./chunk-BLEIUQL6.js';import {k,t,u}from'./chunk-VQZ5PI5J.js';import {p as p$1,q}from'./chunk-ODK4LCEL.js';import k$1 from'fs';import c from'path';import s from'chalk';var ee=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function E(e){try{return await k$1.promises.access(e,k$1.constants.F_OK),true}catch{return false}}async function F(e){try{let n=JSON.parse(await k$1.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function C(e){try{return await k$1.promises.readFile(e,"utf-8")}catch{return ""}}function re(e){return a(e)}async function oe(e,n){return await ne([...u(e,"project.json"),...u(e,"context.json")])?true:b(e)?false:c.resolve(e)===c.resolve(n)?k$2(e).length>0:k$2(e).length>0}async function ie(e){let n=await a$1(e,{skipDirs:ee,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:oe}),o=(await a$2(e)).filter(i=>i.relationship==="adopted"||i.source==="adopted-local").map(i=>c.resolve(i.path)).filter(i=>k$1.existsSync(i)),r=[...new Set([...n.map(i=>c.resolve(i)),...o])];return r.length>0?r:b(e)?[]:k$2(e).length>0?[e]:[]}function ae(e,n){return c.relative(e,n).replace(/\\/g,"/")||"."}async function T(e,n){for(let t of n)if(await E(c.join(e,t)))return true;return false}async function se(e,n,t=4){let o=async(r,i)=>{if(i>t)return false;let l;try{l=await k$1.promises.readdir(r,{withFileTypes:true});}catch{return false}for(let a of l)if(a.isFile()&&n.has(a.name.toLowerCase())||a.isDirectory()&&!a.isSymbolicLink()&&!ee.has(a.name)&&await o(c.join(r,a.name),i+1))return true;return false};return o(e,0)}async function ne(e){for(let n of e)if(await E(n))return true;return false}async function te(e){for(let n of e){let t=await F(n);if(t)return t}return null}async function ce(e,n){if(await T(e,[".env",".env.local"]))return true;let t=n?.contracts&&typeof n.contracts=="object"?n.contracts:null;if(Array.isArray(t?.env)&&t.env.length>0)return true;let o=await F(c.join(e,"package.json")),r={...o?.dependencies??{},...o?.devDependencies??{}};if(Object.keys(r).some(a=>/^(?:dotenv|dotenv-flow|env-cmd)$/iu.test(a)))return true;let i=await C(c.join(e,"pyproject.toml"));if(/\b(?:python-dotenv|pydantic-settings)\b/iu.test(i))return true;let l=[await C(c.join(e,"compose.yaml")),await C(c.join(e,"compose.yml")),await C(c.join(e,"docker-compose.yml")),await C(c.join(e,"docker-compose.yaml"))].join(`
2
+ `);return /^\s*(?:env_file|environment)\s*:/imu.test(l)}async function de(e){return (await g(e)).detected}async function le(e){let n=await F(c.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function w(e,n,t,o,r,i,l){return {id:e,severity:n,target:t,title:o,detail:r,remediation:i,...l&&l.length>0?{files:[...l]}:{}}}function pe(e){let n=e.reduce((t,o)=>o.severity==="fail"?t+28:o.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function ue(e,n,t){let o=await te(u(n,"project.json")),r=m(n,o),i=l(n),l$1=r.runtime==="unknown"?i[0]||"unknown":r.runtime,a=[l$1,...i.filter(G=>G!==l$1)],u$1=r.key==="unknown"&&new Set(a.filter(G=>G!=="unknown")).size>1,b=await b$1(n,o,{runtime:l$1,framework:r.key}),m$1=["backend","service","worker","agent"].includes(b),h=["backend","service","worker"].includes(b),v=m$1&&/^(?:fastapi|django|flask|nestjs|express|fastify|springboot|gofiber|gogin|dotnet-webapi|laravel|rails|phoenix|axum|actix|rocket)$/u.test(r.key),j=ae(e,n),f=j,$=await le(n),P=await ne([...u(n,"project.json"),...u(n,"context.json")]),x=await de(n),R=await T(n,["Dockerfile","dockerfile"]),g=await T(n,[".env.example","env.example","config/env.example"])||await se(n,new Set([".env.example","env.example"])),p=await ce(n,o),d=await c$1({projectPath:n,declaration:t?.governance}),z=d.ci.status==="repository",D=await h$1(n),y=[];return r.key==="unknown"&&y.push(w(u$1?"project.stack.aggregate":"project.stack.unknown",u$1?"info":"fail",f,u$1?"Multi-runtime aggregate boundary detected":"Project stack is unknown",u$1?`Workspai detected multiple runtimes (${a.join(", ")}) and intentionally did not promote one nested framework as the aggregate project identity.`:"Workspai cannot confidently classify this backend project.",u$1?"Adopt independently operated nested projects when they need separate lifecycle, ownership, or release evidence.":"Add .workspai/project.json metadata or import the project with `workspai import`.")),P||y.push(w("project.marker.missing","warn",f,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),x||y.push(w("project.tests.missing","warn",f,"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.")),m$1&&p&&!g&&y.push(w("project.env.example.missing","info",f,"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"])),d.ci.status==="unknown"?y.push(w("project.ci.missing","warn",f,"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"])):d.ci.status==="external-observed"&&y.push(w("project.ci.external-observed","info",f,"Continuous integration appears externally managed",`Repository documentation references an external CI control plane (${d.ci.evidence.join(", ")}).`,"Declare the external CI provider in the canonical workspace contract when authoritative release gating depends on it.")),v&&!D&&y.push(w("project.health.missing","info",f,"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.")),h&&!R&&y.push(w("project.container.missing","info",f,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.",["Dockerfile"])),{name:typeof o?.name=="string"&&o.name.trim()?o.name.trim():c.basename(n),path:n,relativePath:j,runtime:l$1,runtimeCandidates:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:P,hasTests:x,hasDockerfile:R,hasEnvExample:g,hasCiConfig:z,governance:d,hasHealthEndpoint:D,scripts:$,findings:y,score:pe(y)}}function me(e){return e.name.toLowerCase()}async function fe(e){let n=new Map(e.map(r=>[me(r),r])),t=[];for(let r of e){let i=await F(c.join(r.path,"package.json")),l={...i?.dependencies??{},...i?.devDependencies??{},...i?.peerDependencies??{}};for(let u of Object.keys(l)){let b=u.replace(/^@[^/]+\//,"").toLowerCase(),m=n.get(b);m&&m.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:m.relativePath,kind:"package"});}let a=await C(c.join(r.path,"pyproject.toml"));for(let u of e)u.relativePath!==r.relativePath&&a.includes(u.name)&&t.push({from:r.relativePath,to:u.relativePath,kind:"workspace-reference"});}let o=new Set;return t.filter(r=>{let i=`${r.from}\0${r.to}\0${r.kind}`;return o.has(i)?false:(o.add(i),true)})}function ge(e,n){let t=new Map;for(let o of e)t.set(o.relativePath,{project:o.relativePath,directDependents:0,directDependencies:0});for(let o of n){let r=t.get(o.from),i=t.get(o.to);r&&(r.directDependencies+=1),i&&(i.directDependents+=1);}return Array.from(t.values()).sort((o,r)=>r.directDependents-o.directDependents||r.directDependencies-o.directDependencies)}async function ye(e){let n=await te(t(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function we(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 ke(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 Te(e$1={}){let n=c.resolve(e$1.workspacePath||process.cwd());if(!await E(n))throw new Error(`Workspace path does not exist: ${n}`);let t=re(n)??n,o=k(t),r=await ye(t),i=await ie(t),l;try{l=(await p({workspacePath:t})).contract;}catch{}let a=await Promise.all(i.map(p=>{let d=l?.projects.find(z=>{let D=z.externalPath??z.relativePath;return c.resolve(t,D)===c.resolve(p)});return ue(t,p,d)})),u=await fe(a),b=ge(a,u),m=[];o||m.push(w("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.")),a.length===0&&m.push(w("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let h$1=[...m,...a.flatMap(p=>p.findings)],v=we(h$1),j={};for(let p of a)for(let d of p.runtimeCandidates)j[d]=(j[d]||0)+1;let f$1=a.length>0?Math.round(a.reduce((p,d)=>p+d.score,0)/a.length):0,$=m.reduce((p,d)=>p+(d.severity==="fail"?20:d.severity==="warn"?8:2),0),P=Math.max(0,f$1-$),x=a.length===0&&v.fail===0&&h$1.length>0&&h$1.every(p=>p.id==="workspace.projects.missing"&&p.severity==="warn"),R=v.fail>0||e$1.strict&&v.warn>0&&!x?"blocked":v.warn>0?"needs-attention":"ready",g={schemaVersion:q.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:o,profile:r,summary:{statusScope:"source-structure",releaseReadiness:"not-evaluated",score:P,verdict:R,projectCount:a.length,runtimeCount:Object.keys(j).length,findings:v},runtimes:j,projects:a,dependencyGraph:{status:u.length>0?"generated":"empty",edges:u,topImpactedProjects:b.slice(0,5)},findings:h$1,nextActions:ke({findings:h$1,projectCount:a.length,hasCanonicalGraph:await E(c.join(t,p$1.knowledgeGraph)),workspaceDetected:o}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:p$1.analyze}};if(e$1.output&&(await k$1.promises.mkdir(c.dirname(c.resolve(e$1.output)),{recursive:true}),await k$1.promises.writeFile(c.resolve(e$1.output),`${JSON.stringify(g,null,2)}
3
+ `)),!e$1.output&&o){let p=f(g,{commandId:"workspaceAnalyze",exitCode:g.summary.verdict==="blocked"?2:g.summary.verdict==="needs-attention"?1:0,generatedAt:g.generatedAt,blockers:g.findings.filter(d=>d.severity==="fail").map(d=>d.title).slice(0,12),runId:e()});await h(t,p$1.analyze,p);}return g}function Ne(e){let n=e.summary.verdict==="ready"?s.green:e.summary.verdict==="needs-attention"?s.yellow:s.red;if(console.log(s.bold(`
4
+ Workspai Workspace Analysis
5
+ `)),console.log(s.cyan("Workspace:"),e.workspacePath),console.log(s.cyan("Profile:"),e.profile||"not configured"),console.log(s.cyan("Source score:"),`${e.summary.score}/100`),console.log(s.cyan("Source verdict:"),n(e.summary.verdict)),console.log(s.cyan("Release readiness:"),e.summary.releaseReadiness),console.log(s.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(s.bold(`
6
+ Projects`));for(let t of e.projects){let o=t.score>=85?s.green("pass"):t.score>=65?s.yellow("watch"):s.red("risk");console.log(` ${t.relativePath} ${s.gray(`${t.runtime}/${t.framework}`)} ${o} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(s.bold(`
7
+ Dependency Graph`)),console.log(s.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(s.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(s.bold(`
8
+ Top Findings`));for(let t of e.findings.slice(0,8)){let o=t.severity==="fail"?s.red:t.severity==="warn"?s.yellow:s.gray;console.log(` ${o(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(s.gray(` ${t.remediation}`));}}console.log(s.bold(`
9
+ Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(s.gray(` - ${t}`));console.log();}export{Te as a,Ne as b};