workspai 0.46.0 → 0.48.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 (143) hide show
  1. package/README.md +225 -81
  2. package/contracts/agent-customization-pack.v1.json +11 -1
  3. package/contracts/bootstrap-compliance.v1.json +14 -0
  4. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
  5. package/contracts/extension-cli-compatibility.v1.json +13 -2
  6. package/contracts/mirror-ops.v1.json +16 -0
  7. package/contracts/published-contract-catalog.v1.json +59 -1
  8. package/contracts/runtime-command-surface.v1.json +294 -2
  9. package/contracts/transparency-evidence.v1.json +13 -0
  10. package/contracts/workspace-contract.v1.json +78 -0
  11. package/contracts/workspace-intelligence/model-usage-event.v1.json +82 -0
  12. package/contracts/workspace-intelligence/workspace-context.v1.json +20 -0
  13. package/contracts/workspace-intelligence/workspace-graph-token-efficiency.v1.json +72 -0
  14. package/contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json +53 -0
  15. package/contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json +120 -0
  16. package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +6 -1
  17. package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +200 -0
  18. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +260 -0
  19. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +60 -0
  20. package/contracts/workspace-intelligence-architecture.v1.json +37 -5
  21. package/contracts/workspace-intelligence-chain.v1.json +58 -6
  22. package/contracts/workspace-share-bundle.v1.json +16 -0
  23. package/dist/analyze-EEEU3MIF.js +1 -0
  24. package/dist/artifact-remediation-plan-SPOUHMK5.js +3 -0
  25. package/dist/autopilot-release-XGVXPOZI.js +1 -0
  26. package/dist/chunk-32OJDBIG.js +2 -0
  27. package/dist/chunk-37CVKXBD.js +1 -0
  28. package/dist/chunk-3NU32T4A.js +2 -0
  29. package/dist/chunk-3VFA7D5T.js +1 -0
  30. package/dist/chunk-4HDYADHT.js +13 -0
  31. package/dist/chunk-54EP5CEV.js +8 -0
  32. package/dist/chunk-5S3DJQEP.js +8 -0
  33. package/dist/chunk-AFL3ACCR.js +2 -0
  34. package/dist/{chunk-VFDM65IE.js → chunk-BFLJ2R4D.js} +22 -22
  35. package/dist/chunk-BGPXQQNY.js +4 -0
  36. package/dist/chunk-BMWFQXGW.js +1 -0
  37. package/dist/{chunk-UQWOVV6V.js → chunk-CRHYBQI3.js} +1 -1
  38. package/dist/chunk-CV5HKU4P.js +1 -0
  39. package/dist/chunk-ESLPI3XZ.js +1 -0
  40. package/dist/chunk-FB7SCXAZ.js +1 -0
  41. package/dist/{chunk-WPEEC5BX.js → chunk-HDXNIN4N.js} +1 -1
  42. package/dist/chunk-HZDXO65G.js +36 -0
  43. package/dist/{chunk-J5PIZCAU.js → chunk-I46XEIPL.js} +1 -1
  44. package/dist/chunk-J5ENLXDF.js +1 -0
  45. package/dist/chunk-KB44JP4M.js +2 -0
  46. package/dist/chunk-LHOZXC2M.js +2 -0
  47. package/dist/chunk-NAJCUQ4X.js +2 -0
  48. package/dist/chunk-OA537ZQ5.js +1 -0
  49. package/dist/chunk-OW42TZFB.js +1 -0
  50. package/dist/chunk-P3D5YQB2.js +1 -0
  51. package/dist/chunk-PHXQR6PX.js +2 -0
  52. package/dist/{chunk-ZKAI3PJE.js → chunk-PRTR2DQ2.js} +1 -1
  53. package/dist/{chunk-QA5BGEQW.js → chunk-QNONOO4F.js} +1 -1
  54. package/dist/chunk-RHQW3DTP.js +1 -0
  55. package/dist/chunk-T4YR4RAI.js +2 -0
  56. package/dist/chunk-THIOE2PB.js +2 -0
  57. package/dist/{chunk-4LGXSBCN.js → chunk-VU7NZHPM.js} +1 -1
  58. package/dist/chunk-WDKNMTJQ.js +1 -0
  59. package/dist/{chunk-YUATNVOT.js → chunk-Y5UJLPS4.js} +16 -16
  60. package/dist/{chunk-6IIZJQLV.js → chunk-YJZOMRAS.js} +1 -1
  61. package/dist/{create-WCV3L6XH.js → create-DBQNAMKP.js} +1 -1
  62. package/dist/{doctor-5BWM2EMJ.js → doctor-4NNUDNGZ.js} +1 -1
  63. package/dist/{dotnet-webapi-clean-6TVFBTVI.js → dotnet-webapi-clean-A6MVDYXX.js} +4 -4
  64. package/dist/{gofiber-standard-2BL7GWZB.js → gofiber-standard-I5YPQG5V.js} +1 -1
  65. package/dist/{gogin-standard-XGP3KBXA.js → gogin-standard-VY2L4QT5.js} +1 -1
  66. package/dist/index.d.ts +56 -14
  67. package/dist/index.js +322 -320
  68. package/dist/pipeline-TQM43A3K.js +5 -0
  69. package/dist/{springboot-standard-JJNUID6M.js → springboot-standard-55XKCBIZ.js} +4 -4
  70. package/dist/{workspace-7OXW5YTJ.js → workspace-NCWRINEF.js} +1 -1
  71. package/dist/{workspace-agent-sync-O4IA6VOA.js → workspace-agent-sync-662QHXGF.js} +1 -1
  72. package/dist/{workspace-archive-H74NBBNW.js → workspace-archive-P76EDIUG.js} +1 -1
  73. package/dist/{workspace-context-R7IPUBPG.js → workspace-context-23YYCUCP.js} +1 -1
  74. package/dist/workspace-contract-TU2I7GC2.js +1 -0
  75. package/dist/workspace-dependency-graph-BP4EXYQ5.js +1 -0
  76. package/dist/workspace-explain-MWUEN643.js +1 -0
  77. package/dist/workspace-explain-contract-ZPI3JXJU.js +1 -0
  78. package/dist/{workspace-feedback-REOS36ZZ.js → workspace-feedback-SUVH2LUJ.js} +1 -1
  79. package/dist/{workspace-foundation-KXT4QI5O.js → workspace-foundation-WXJ6I7ES.js} +1 -1
  80. package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +1 -0
  81. package/dist/{workspace-history-OGOVSKZG.js → workspace-history-BANOJRQ2.js} +1 -1
  82. package/dist/workspace-intelligence-MFJE7W67.js +1 -0
  83. package/dist/workspace-intelligence-evaluation-IPH7M3WV.js +1 -0
  84. package/dist/workspace-intelligence-runner-THYLHHMF.js +1 -0
  85. package/dist/workspace-knowledge-graph-ARDC6HHG.js +1 -0
  86. package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +1 -0
  87. package/dist/workspace-knowledge-graph-export-UYAYFTWX.js +10 -0
  88. package/dist/workspace-knowledge-graph-query-VOSPPH4W.js +1 -0
  89. package/dist/workspace-mcp-serve-EZR6O76D.js +3 -0
  90. package/dist/workspace-model-7OU2M3LE.js +1 -0
  91. package/dist/workspace-model-hash-MHXK5MEI.js +1 -0
  92. package/dist/{workspace-registry-summary-SZ46R5PD.js → workspace-registry-summary-ORDK7A36.js} +1 -1
  93. package/dist/workspace-run-RLIYSOTN.js +1 -0
  94. package/dist/{workspace-verify-MFQ7IXGD.js → workspace-verify-EBVL7FWT.js} +1 -1
  95. package/dist/workspace-watch-3BPGLFLB.js +1 -0
  96. package/docs/AI_DYNAMIC_INTEGRATION.md +73 -428
  97. package/docs/AI_EXAMPLES.md +37 -395
  98. package/docs/AI_FEATURES.md +76 -456
  99. package/docs/AI_QUICKSTART.md +49 -212
  100. package/docs/GLOSSARY.md +64 -0
  101. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +68 -7
  102. package/docs/README.md +70 -41
  103. package/docs/README_CONTENT_CONTRACT.md +154 -0
  104. package/docs/commands-reference.md +64 -4
  105. package/docs/config-file-guide.md +6 -2
  106. package/docs/contracts/ARTIFACT_CATALOG.md +76 -37
  107. package/docs/contracts/README.md +47 -8
  108. package/docs/graph-benchmark-methodology.md +121 -0
  109. package/docs/workspace-intelligence-evaluation.md +147 -0
  110. package/docs/workspace-knowledge-graph.md +316 -0
  111. package/docs/workspace-operations.md +49 -0
  112. package/package.json +2 -1
  113. package/dist/analyze-BEBEZSZK.js +0 -1
  114. package/dist/artifact-remediation-plan-FFQSESAM.js +0 -3
  115. package/dist/autopilot-release-WUR4CQIT.js +0 -1
  116. package/dist/chunk-2G7FASAO.js +0 -2
  117. package/dist/chunk-4EPHWD27.js +0 -8
  118. package/dist/chunk-CVHMUSRX.js +0 -1
  119. package/dist/chunk-DIPD72H4.js +0 -2
  120. package/dist/chunk-EFYHGCGX.js +0 -2
  121. package/dist/chunk-FWRXA435.js +0 -2
  122. package/dist/chunk-HDURFXW5.js +0 -2
  123. package/dist/chunk-HMUKBW2S.js +0 -4
  124. package/dist/chunk-K4WNYXKK.js +0 -33
  125. package/dist/chunk-LG6RFLPZ.js +0 -1
  126. package/dist/chunk-N7DV5L7C.js +0 -1
  127. package/dist/chunk-PRBVYW3T.js +0 -1
  128. package/dist/chunk-QZLIURER.js +0 -13
  129. package/dist/chunk-RIEF2DDX.js +0 -8
  130. package/dist/chunk-SXMTSV5M.js +0 -1
  131. package/dist/chunk-SXPY523X.js +0 -1
  132. package/dist/chunk-V3LRQZ36.js +0 -1
  133. package/dist/chunk-WYFPXTTS.js +0 -2
  134. package/dist/pipeline-ORIWVVYM.js +0 -5
  135. package/dist/workspace-contract-HKCMOMFE.js +0 -1
  136. package/dist/workspace-explain-GOPQYTPQ.js +0 -1
  137. package/dist/workspace-explain-contract-SVFJAAEI.js +0 -1
  138. package/dist/workspace-intelligence-7IESQSXY.js +0 -1
  139. package/dist/workspace-intelligence-runner-6GJ5M4HB.js +0 -1
  140. package/dist/workspace-mcp-serve-FRVWBO36.js +0 -3
  141. package/dist/workspace-model-PPYX7B4S.js +0 -1
  142. package/dist/workspace-run-V3KKHTVF.js +0 -1
  143. package/dist/workspace-watch-SOPZHRWA.js +0 -1
@@ -1,2 +0,0 @@
1
- import {a as a$1}from'./chunk-FXQJX34Z.js';import {c,f as f$1,b as b$1,e as e$1,g}from'./chunk-HDURFXW5.js';import {a,b}from'./chunk-N7DV5L7C.js';import {e}from'./chunk-RO73VVHW.js';import {p,o}from'./chunk-5XATWNME.js';import {l}from'./chunk-OCGZNSOE.js';import d from'path';import f from'fs-extra';var q="unknown-run";function J(t){let e$1=e();return !e$1||e$1===q?t:{...t,runId:e$1}}var P=".workspai/workspace.contract.json",Q=a.contractVerify,j=1,X=b.contractVerify,W=class extends Error{constructor(s){super(`Workspace contract verification failed: ${s.violations.join("; ")}`);this.verification=s;this.name="WorkspaceContractVerificationError";}verification};function D(t){return t.replace(/\\/g,"/")}function S(t){let e=D(t).trim();return !e||e.startsWith("/")||e.startsWith("~")||/^[a-zA-Z]:\//.test(e)||e.includes("\0")?false:!e.split("/").filter(Boolean).some(s=>s===".."||s===".")}function F(t,e){return t.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||e}function tt(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.trim().length>0):[]}function et(t){let s=(Array.isArray(t.ports)?t.ports:[]).map(i=>{if(!i||typeof i!="object"||Array.isArray(i))return null;let p=i,u=Number(p.port);if(!Number.isInteger(u)||u<1||u>65535)return null;let o=p.protocol==="https"||p.protocol==="grpc"||p.protocol==="tcp"||p.protocol==="udp"?p.protocol:"http";return {name:typeof p.name=="string"&&p.name.trim()?p.name:"http",port:u,protocol:o}}).filter(i=>i!==null);if(s.length>0)return s;let c=t.frontend&&typeof t.frontend=="object"&&!Array.isArray(t.frontend)?t.frontend:void 0,a=Number(t.port??c?.default_port);return Number.isInteger(a)&&a>=1&&a<=65535?[{name:"http",port:a,protocol:"http"}]:[]}async function v(t){for(let e of t)if(await f.pathExists(e))return e;return null}async function rt(t){for(let e of o(t,"workspace.json"))try{let s=await f.readJson(e);return {name:typeof s.workspace_name=="string"&&s.workspace_name.trim()||typeof s.name=="string"&&s.name.trim()||d.basename(t),profile:typeof s.profile=="string"?s.profile:void 0}}catch{}return {name:d.basename(t)}}async function ot(t){let e=[],s=[t],c=new Set,a=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;s.length>0;){let i=s.shift();if(!i||c.has(i))continue;c.add(i);let p$1=await v(p(i,"project.json")),u=await v(p(i,"context.json"));if(p$1||u){e.push(p$1??u??"");continue}let o;try{o=await f.readdir(i,{withFileTypes:true});}catch{continue}for(let l of o)!l.isDirectory()||a.has(l.name)||s.push(d.join(i,l.name));}return e.sort()}function st(t){let e=(t||"").toLowerCase();if(e.includes("fastapi"))return "fastapi";if(e.includes("nestjs"))return "nestjs";if(e.includes("springboot"))return "springboot";if(e.includes("gofiber"))return "fiber";if(e.includes("gogin"))return "gin"}function nt(t,e){let s=(t||"").toLowerCase(),c=(e||"").toLowerCase();return s.includes("fastapi")?8e3:s.includes("nestjs")?3e3:s.includes("springboot")?8080:s.includes("gofiber")?3e3:s.includes("gogin")?8080:c==="node"?3e3:c==="python"?8e3:c==="java"||c==="go"?8080:null}function K(t,e){let s=t;for(;e.has(s)&&s<65535;)s+=1;return s}function R(t,e,s){let c=t!==void 0&&t.source===void 0,a=nt(e.kit,e.runtime),i=t?.ports||[],p=e.ports||[],o=(i.length>0?i:p.length>0?p:a?[{name:"http",port:K(a,s),protocol:"http"}]:[]).map(n=>({...n,port:K(n.port,s)}));for(let n of o)s.add(n.port);let l={...e,...t,slug:t?.slug||e.slug,relativePath:c&&t?.relativePath&&S(t.relativePath)?t.relativePath:e.relativePath,source:c&&t?.source||e.source,relationship:c&&t?.relationship||e.relationship,externalPath:c&&t?.externalPath||e.externalPath,runtime:t?.runtime||e.runtime,framework:t?.framework||e.framework,kit:t?.kit||e.kit,modules:t?.modules?.length?t.modules:e.modules,ports:o,contracts:{owns:t?.contracts?.owns||[],apis:t?.contracts?.apis||[],publishes:t?.contracts?.publishes||[],consumes:t?.contracts?.consumes||[],dependsOn:t?.contracts?.dependsOn||[],env:t?.contracts?.env||[]}},r=JSON.stringify(t||null)!==JSON.stringify(l);return {project:l,changed:r}}async function L(t){let e=d.resolve(t.workspacePath),s=await rt(e),c=await ot(e),a=await a$1(e),i=[];for(let l of a){let r=d.resolve(l.path),n=await v(p(r,"project.json"))??await v(p(r,"context.json"));!n||c.some(g=>d.resolve(g)===d.resolve(n))||i.push({projectJsonPath:n,registryEntry:l});}let p$1=[],u=[...c.map(l=>({projectJsonPath:l})),...i];for(let{projectJsonPath:l,registryEntry:r}of u){let n=d.dirname(d.dirname(l)),g=D(d.relative(e,n)),h=r!==void 0&&!S(g),k=F(r?.name||d.basename(n),d.basename(n)),C=h?`external/${k}`:g||k,m=await f.readJson(l),x=typeof m.kit_name=="string"&&m.kit_name||typeof m.kit=="string"&&m.kit||void 0,Y=typeof m.framework=="string"&&m.framework||st(x);p$1.push({slug:r?.name||C||d.basename(n),relativePath:C,source:r?.source??"workspace",relationship:r?.relationship,externalPath:h?n:void 0,runtime:typeof m.runtime=="string"?m.runtime:void 0,framework:Y,kit:x,modules:tt(m.modules),ports:et(m),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}let o=new Map;for(let l of p$1){let r=F(l.slug,l.relativePath),n=o.get(r);(!n||n.source!=="workspace"&&l.source==="workspace")&&o.set(r,l);}return {schemaVersion:j,kind:"rapidkit.workspace.contract",generatedAt:(t.now??new Date).toISOString(),workspace:s,projects:[...o.values()]}}async function kt(t){let e=d.resolve(t.outputPath||c(t.workspacePath,P));if(await f.pathExists(e)&&t.force!==true)throw new Error(`Workspace contract already exists: ${e}. Use --force to overwrite.`);let s=await L({workspacePath:t.workspacePath,now:t.now}),c$1=new Set,a={...s,projects:s.projects.map(p=>R(void 0,p,c$1).project)},i=await B({workspacePath:t.workspacePath,contractPath:e,contract:a});if(t.strict&&i.status==="failed")throw new W(i);return await z({workspacePath:t.workspacePath,contractPath:e,contract:a,now:t.now}),{contractPath:e,contract:a}}async function wt(t){let e=d.resolve(t.workspacePath),s=c(e,P),c$1=await f$1(e,P)??s,a=await L({workspacePath:e,now:t.now}),i=await f.pathExists(c$1)?await f.readJson(c$1):null,p=new Map((i?.projects||[]).map(h=>[h.slug,h])),u=new Set,o=[],l=[],r=[];for(let h of a.projects){let k=p.get(h.slug),C=R(k,h,u);k?C.changed&&l.push(h.slug):o.push(h.slug),r.push(C.project),p.delete(h.slug);}for(let h of p.values()){if(h.source)continue;let k=R(h,h,u);r.push(k.project);}let n={schemaVersion:j,kind:"rapidkit.workspace.contract",generatedAt:(t.now??new Date).toISOString(),workspace:{...a.workspace,...i?.workspace||{},name:i?.workspace?.name||a.workspace.name},projects:r.sort((h,k)=>h.slug.localeCompare(k.slug))},g=await B({workspacePath:e,contractPath:s,contract:n});if(t.strict&&g.status==="failed")throw new W(g);return await z({workspacePath:e,contractPath:s,contract:n,now:t.now}),{contractPath:s,contract:n,addedProjects:o,updatedProjects:l,verification:g}}async function M(t){return await f.pathExists(t)?{exists:true,contents:await f.readFile(t)}:{exists:false}}async function G(t,e){if(!e.exists){await f.remove(t);return}await f.outputFile(t,e.contents);}async function z(t){let{buildWorkspaceRegistrySummary:e,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:s}=await import('./workspace-registry-summary-SZ46R5PD.js'),c$1=await e(t.workspacePath,{now:t.now,contract:t.contract}),a=c(t.workspacePath,s),i=p=>{if(!p||typeof p!="object"||Array.isArray(p))return JSON.stringify(p);let{generatedAt:u,...o}=p;return JSON.stringify(o)};if(await f.pathExists(t.contractPath)&&await f.pathExists(a)){let[p,u]=await Promise.all([f.readJson(t.contractPath),f.readJson(a)]);if(i(p)===i(t.contract)&&i(u)===i(c$1))return}b$1(P,t.contract),b$1(s,c$1),await e$1(t.workspacePath,P,async()=>{let[p,u]=await Promise.all([M(t.contractPath),M(a)]);try{if(t.contractPath===c(t.workspacePath,P)?await g(t.workspacePath,P,t.contract):(await f.ensureDir(d.dirname(t.contractPath)),await f.writeJson(t.contractPath,t.contract,{spaces:2})),process.env.WORKSPAI_TEST_FAIL_WORKSPACE_REGISTRY_PUBLISH==="1")throw new Error("Injected workspace registry summary publication failure.");await g(t.workspacePath,s,c$1);}catch(o){let r=(await Promise.allSettled([G(t.contractPath,p),G(a,u)])).filter(n=>n.status==="rejected");throw r.length>0?new AggregateError([o,...r.map(n=>n.reason)],"Workspace contract publication failed and rollback was incomplete."):o}});}async function H(t){let e=t.contractPath??(await f$1(t.workspacePath,P)||c(t.workspacePath,P)),s=await f.readJson(e);return {contractPath:e,contract:s}}async function Ct(t){let{contractPath:e,contract:s}=await H(t),c=s.projects.map(o=>({id:o.slug,label:o.slug,relativePath:o.relativePath,source:o.source,relationship:o.relationship,externalPath:o.externalPath,runtime:o.runtime,framework:o.framework,kit:o.kit,modules:o.modules,ports:o.ports,apis:o.contracts.apis,owns:o.contracts.owns,env:o.contracts.env})),a=new Set(c.map(o=>o.id)),i=new Map,p=[];for(let o of s.projects){for(let l of o.contracts.dependsOn||[])a.has(l)&&p.push({from:l,to:o.slug,type:"dependency",label:"dependsOn"});for(let l of o.contracts.publishes||[])i.has(l)||i.set(l,new Set),i.get(l)?.add(o.slug);}for(let o of s.projects)for(let l of o.contracts.consumes||[]){let r=i.get(l);if(r)for(let n of r)n!==o.slug&&p.push({from:n,to:o.slug,type:"event",label:l});}let u={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:s.workspace,generatedAt:new Date().toISOString(),nodes:c.sort((o,l)=>o.id.localeCompare(l.id)),edges:p.sort((o,l)=>`${o.from}:${o.to}:${o.type}:${o.label}`.localeCompare(`${l.from}:${l.to}:${l.type}:${l.label}`)),summary:{projectCount:c.length,dependencyEdges:p.filter(o=>o.type==="dependency").length,eventEdges:p.filter(o=>o.type==="event").length,portCount:c.reduce((o,l)=>o+l.ports.length,0),apiCount:c.reduce((o,l)=>o+l.apis.length,0)}};return {contractPath:e,graph:u}}async function B(t){let e=t.contract?{contractPath:t.contractPath??c(t.workspacePath,P),contract:t.contract}:await H(t),{contractPath:s,contract:c$1}=e,a=[],i=[];c$1.kind!=="rapidkit.workspace.contract"&&a.push("Contract kind must be rapidkit.workspace.contract."),c$1.schemaVersion!==j&&a.push(`Contract schemaVersion must be ${j}.`),c$1.workspace?.name||a.push("Contract workspace.name is required."),Array.isArray(c$1.projects)||a.push("Contract projects must be an array.");let p=new Set,u=new Map;for(let r of c$1.projects||[]){if(!r.slug){a.push("Every project must declare slug.");continue}p.has(r.slug)&&a.push(`Duplicate project slug: ${r.slug}.`),p.add(r.slug),r.relativePath?S(r.relativePath)||a.push(`Project ${r.slug} declares unsafe relativePath: ${r.relativePath}.`):a.push(`Project ${r.slug} must declare relativePath.`),r.externalPath&&(r.relationship==="adopted"||r.source==="adopted-local"||r.source==="local-folder"||r.source==="git-url"||a.push(`Project ${r.slug} declares externalPath without imported/adopted provenance.`),d.isAbsolute(r.externalPath)||a.push(`Project ${r.slug} declares non-absolute externalPath.`));for(let n of r.ports||[]){(!Number.isInteger(n.port)||n.port<1||n.port>65535)&&a.push(`Project ${r.slug} declares invalid port: ${n.port}.`);let g=u.get(n.port);g&&a.push(`Port ${n.port} is claimed by both ${g} and ${r.slug}.`),u.set(n.port,r.slug);}for(let n of r.contracts?.apis||[])(!n.name?.trim()||!n.basePath?.startsWith("/"))&&a.push(`Project ${r.slug} declares invalid API contract.`);for(let n of [...r.contracts?.publishes||[],...r.contracts?.consumes||[]])n.trim()||a.push(`Project ${r.slug} declares an empty event contract.`);for(let n of r.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(n)||a.push(`Project ${r.slug} declares invalid env contract: ${n}.`);for(let n of r.contracts?.dependsOn||[])p.has(n);}for(let r of c$1.projects||[])for(let n of r.contracts?.dependsOn||[])p.has(n)||a.push(`Project ${r.slug} depends on unknown project: ${n}.`);i.push({id:"schema",status:c$1.kind==="rapidkit.workspace.contract"&&c$1.schemaVersion===j?"passed":"failed",message:"Contract schema and kind are valid."}),i.push({id:"projects",status:Array.isArray(c$1.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(c$1.projects)?c$1.projects.length:0} project(s).`}),i.push({id:"ports",status:a.some(r=>r.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),i.push({id:"dependencies",status:a.some(r=>r.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),i.push({id:"contracts",status:a.some(r=>r.includes("unsafe relativePath")||r.includes("invalid API contract")||r.includes("event contract")||r.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let o=await l(t.workspacePath);if(o.moduleCount>0){for(let r of o.issues)a.push(`${d.basename(r.projectRoot)}: ${r.message} (slug=${r.slug})`);i.push({id:"module-paths",status:o.status,message:o.status==="passed"?`All ${o.moduleCount} registered module(s) resolve under canonical paths.`:`${o.issues.length} registered module(s) missing canonical install paths.`});}else t.strict&&i.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:a.length>0?"failed":"passed",contractPath:s,projectCount:Array.isArray(c$1.projects)?c$1.projects.length:0,checks:i,violations:a}}async function yt(t){let e=d.resolve(t.workspacePath),s={schemaVersion:X,generatedAt:t.generatedAt??new Date().toISOString(),status:t.result.status,contractPath:t.result.contractPath,projectCount:t.result.projectCount,checks:t.result.checks,violations:t.result.violations};return g(e,Q,J(s))}
2
- export{J as a,P as b,Q as c,j as d,X as e,W as f,ot as g,L as h,kt as i,wt as j,H as k,Ct as l,B as m,yt as n};
@@ -1,5 +0,0 @@
1
- import {c as c$1}from'./chunk-4EPHWD27.js';import {a as a$2}from'./chunk-RIEF2DDX.js';import {q}from'./chunk-VFDM65IE.js';import {d}from'./chunk-YUATNVOT.js';import {c as c$2}from'./chunk-FPJNWPKU.js';import {a as a$3}from'./chunk-HMUKBW2S.js';import {f as f$1,e}from'./chunk-T3GJ7YVG.js';import {a}from'./chunk-22DT744Z.js';import {f,c,g}from'./chunk-HDURFXW5.js';import {a as a$1}from'./chunk-N7DV5L7C.js';import c$3 from'chalk';import p from'path';function G(a){return a===0?"pass":a===2?"warn":"fail"}function I(a){return a.some(r=>r.status==="fail")?"blocked":a.some(r=>r.status==="warn")?"needs-attention":"ready"}function j(a,r){if(r)return 3;let i=a.some(o=>o.status==="fail"),t=a.some(o=>o.status==="warn");return i?1:t?2:0}function N(a,r){return a===2&&!r?0:a}async function O(a){let r=await d(a,true),i=false;try{let{syncWorkspaceContract:t}=await import('./workspace-contract-HKCMOMFE.js');await t({workspacePath:a}),i=true;}catch{i=false;}return {sync:r,contractSynced:i}}async function V(a$4={}){let r=p.resolve(a$4.workspacePath??process.cwd()),i=a(r);if(!i)throw new Error("No Workspai workspace found in current directory or parents");let t=[],o=[],l=false,d,f$2,m,y=Date.now();try{let{sync:e,contractSynced:s}=await O(i),n=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";t.push({name:"sync",status:n,durationMs:Date.now()-y,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${s?", contract synced":""}`:"workspace not registered in global registry; contract sync attempted"}),e.workspaceFound||o.push("workspace registry entry missing \u2014 run workspai create workspace or register manually");}catch(e){l=true,t.push({name:"sync",status:"fail",durationMs:Date.now()-y,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),o.push("workspace sync stage failed");}let w=Date.now();try{let e=await q({workspace:true,json:true,quiet:true,strict:a$4.strict===true,ci:a$4.strict!==true}),s=G(e),n=await f(i,a$1.doctor)??c(i,a$1.doctor);t.push({name:"doctor",status:s,durationMs:Date.now()-w,summary:s==="pass"?"doctor workspace passed":s==="warn"?"doctor workspace reported warnings":"doctor workspace did not pass",exitCode:e,evidencePath:n}),s==="fail"?o.push("doctor workspace gate failed"):s==="warn"&&o.push("doctor workspace reported warnings");}catch(e){l=true,t.push({name:"doctor",status:"fail",durationMs:Date.now()-w,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),o.push("doctor workspace stage failed");}if(a$4.skipAnalyze)t.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let s=await a$2({workspacePath:i,json:true,strict:a$4.strict===true});d=p.isAbsolute(s.enterpriseControls.evidencePath)?s.enterpriseControls.evidencePath:p.join(i,s.enterpriseControls.evidencePath);let n=s.summary.verdict==="blocked"?"fail":s.summary.verdict==="needs-attention"?"warn":"pass";t.push({name:"analyze",status:n,durationMs:Date.now()-e,summary:`analyze verdict: ${s.summary.verdict} (score ${s.summary.score}/100)`,evidencePath:d}),n==="fail"?o.push("analyze reported blocked verdict"):n==="warn"&&o.push("analyze reported needs-attention verdict");}catch(s){l=true,t.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${s instanceof Error?s.message:String(s)}`}),o.push("analyze stage failed");}}let h=Date.now();try{let e=await a$3({startPath:i,writeReport:true,skipVerify:a$4.skipVerify===true});f$2=e.evidencePath;let s=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";t.push({name:"readiness",status:s,durationMs:Date.now()-h,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),s==="fail"?o.push(...e.blockingReasons.map(n=>`readiness: ${n}`)):s==="warn"&&o.push(...e.gates.filter(n=>n.status==="warn").map(n=>`readiness warn: ${n.gate}: ${n.summary}`));}catch(e){l=true,t.push({name:"readiness",status:"fail",durationMs:Date.now()-h,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),o.push("readiness stage failed");}if(a$4.skipAutopilot)t.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),s=a$4.autopilotMode??"audit";try{let n=await c$1({workspacePath:i,mode:s,json:true,skipPipelineStages:true});m=n.artifacts.reportPath;let P=n.summary.verdict==="approved"?"pass":n.summary.verdict==="partial"?"warn":"fail";t.push({name:"autopilot",status:P,durationMs:Date.now()-e,summary:`autopilot ${s}: ${n.summary.verdict}`,exitCode:n.summary.exitCode,evidencePath:m}),P!=="pass"&&o.push(...n.blockingReasons.slice(0,5));}catch(n){l=true,t.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${n instanceof Error?n.message:String(n)}`}),o.push("autopilot release stage failed");}}let M=I(t),k=j(t,l),F=p.join(i,".workspai","reports","pipeline-last-run.json"),u={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:i,summary:{verdict:M,exitCode:k,stagesPassed:t.filter(e=>e.status==="pass").length,stagesWarn:t.filter(e=>e.status==="warn").length,stagesFailed:t.filter(e=>e.status==="fail").length},stages:t,blockingReasons:[...new Set(o)],artifacts:{reportPath:F,analyzeEvidencePath:d,readinessEvidencePath:f$2,autopilotEvidencePath:m}};if(a$4.writeReport!==false){let e$1=f$1(u,{commandId:"workspacePipeline",exitCode:k,generatedAt:u.generatedAt,blockers:u.blockingReasons,runId:e()});await g(i,".workspai/reports/pipeline-last-run.json",e$1);}if(a$4.writeReport!==false&&a$4.noAgentSync!==true&&process.env.RAPIDKIT_NO_AGENT_SYNC!=="1"&&a$4.agentSync!==false)try{let{syncWorkspaceAgentGrounding:e}=await import('./workspace-agent-sync-O4IA6VOA.js'),s=await e({workspacePath:i,write:true,refreshContext:true,strict:false});u.agentGrounding={indexPath:s.indexPath,writtenFiles:s.writtenFiles,blockers:s.blockers};}catch{}return u}async function ae(a){let r;try{r=await V(a);}catch(t){let o=t instanceof Error?t.message:String(t);a.json?console.log(JSON.stringify(c$2({operation:"pipeline",code:"pipeline.failed",message:o}),null,2)):console.log(c$3.red(`Pipeline failed: ${o}`)),process.exit(1);}if(a.json)console.log(JSON.stringify(r,null,2));else {console.log(c$3.bold.cyan(`
2
- \u{1F517} Workspai Governance Pipeline
3
- `)),console.log(c$3.bold(`Workspace: ${c$3.cyan(p.basename(r.workspacePath))}`)),console.log(c$3.gray(`Path: ${r.workspacePath}`)),console.log(c$3.white(`Verdict: ${r.summary.verdict} Exit: ${r.summary.exitCode} (${r.summary.stagesPassed} pass / ${r.summary.stagesWarn} warn / ${r.summary.stagesFailed} fail)`));for(let t of r.stages){let o=t.status==="pass"?c$3.green("PASS"):t.status==="warn"?c$3.yellow("WARN"):t.status==="skipped"?c$3.gray("SKIP"):c$3.red("FAIL");console.log(` - ${t.name}: ${o} ${t.summary}`);}if(r.blockingReasons.length>0){console.log(c$3.bold(`
4
- Blocking reasons:`));for(let t of r.blockingReasons.slice(0,8))console.log(c$3.gray(` \u2022 ${t}`));}console.log(c$3.gray(`
5
- Evidence: ${r.artifacts.reportPath}`)),r.agentGrounding?.writtenFiles.length&&console.log(c$3.gray(`Agent grounding: ${r.agentGrounding.writtenFiles.length} file(s) synced (INDEX + AGENTS.md + Copilot/Cursor/Claude hooks)`));}let i=N(r.summary.exitCode,a.strict===true);i!==0&&process.exit(i);}export{N as pipelineProcessExitCode,V as runPipeline,ae as runPipelineCommand};
@@ -1 +0,0 @@
1
- export{b as WORKSPACE_CONTRACT_PATH,d as WORKSPACE_CONTRACT_SCHEMA_VERSION,c as WORKSPACE_CONTRACT_VERIFY_REPORT_PATH,e as WORKSPACE_CONTRACT_VERIFY_SCHEMA_VERSION,f as WorkspaceContractVerificationError,h as buildWorkspaceContract,l as buildWorkspaceContractGraph,g as discoverProjectJsonFiles,k as readWorkspaceContract,j as syncWorkspaceContract,m as verifyWorkspaceContract,i as writeWorkspaceContract,n as writeWorkspaceContractVerifyEvidence}from'./chunk-WYFPXTTS.js';
@@ -1 +0,0 @@
1
- export{b as buildWorkspaceExplain,a as resolveWorkspaceExplainArtifactPath,c as writeWorkspaceExplainReport}from'./chunk-QZLIURER.js';export{e as WORKSPACE_MODEL_DIFF_REPORT_PATH}from'./chunk-FWRXA435.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-UQWOVV6V.js';
@@ -1 +0,0 @@
1
- export{a as WORKSPACE_EXPLAIN_SCHEMA_VERSION,b as WORKSPACE_EXPLAIN_TARGETS,e as isWorkspaceExplainReport,c as parseWorkspaceExplainTarget,d as resolveWorkspaceTraceTarget}from'./chunk-4LGXSBCN.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-UQWOVV6V.js';
@@ -1 +0,0 @@
1
- export{g as WORKSPACE_IMPACT_REPORT_PATH,f as WORKSPACE_IMPACT_SCHEMA_VERSION,e as WORKSPACE_MODEL_DIFF_REPORT_PATH,c as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,d as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,b as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,p as buildWorkspaceImpact,k as buildWorkspaceModelSnapshot,m as diffWorkspaceModel,j as hashWorkspaceModel,h as isGitDiffSource,i as parseGitDiffRef,o as workspaceVerificationPlan,q as writeWorkspaceImpact,n as writeWorkspaceModelDiff,l as writeWorkspaceModelSnapshot}from'./chunk-FWRXA435.js';
@@ -1 +0,0 @@
1
- import {a as a$2}from'./chunk-RIEF2DDX.js';import {q as q$2}from'./chunk-VFDM65IE.js';import {b as b$1,c}from'./chunk-QZLIURER.js';import {d}from'./chunk-YUATNVOT.js';import {a as a$3}from'./chunk-HMUKBW2S.js';import {k as k$1}from'./chunk-K4WNYXKK.js';import {f,g as g$1,h as h$1}from'./chunk-V3LRQZ36.js';import {k,l,m,n as n$1,p,q as q$1}from'./chunk-FWRXA435.js';import {j as j$1,e}from'./chunk-SXMTSV5M.js';import {a as a$1,e as e$1,f as f$1}from'./chunk-EFYHGCGX.js';import {n,q}from'./chunk-CVHMUSRX.js';import {j,m as m$1,n as n$2}from'./chunk-WYFPXTTS.js';import {g,b as b$2}from'./chunk-HDURFXW5.js';import {a,b,h,i,g as g$2,f as f$2}from'./chunk-N7DV5L7C.js';import se from'path';import ce from'fs-extra';function r(a,t){if(!a)throw new Error(`Workspace Intelligence run semantic violation: ${t}`)}function ee(a,t){return a.length===t.length&&a.every((d,l)=>d===t[l])}function te(a$2){b$2(a.intelligenceRun,a$2,"Workspace Intelligence run report"),r(a$2.chainSchemaVersion===a$1,`chainSchemaVersion must be ${a$1}`),r(a$2.artifactPath===a.intelligenceRun,`artifactPath must be ${a.intelligenceRun}`),r(a$2.preflight.length===g$2.length,`preflight must contain exactly ${g$2.length} entries`);for(let[o,i]of g$2.entries()){let s=a$2.preflight[o];r(s?.id===i,`preflight[${o}].id must be ${i}`),r(ee(s.artifacts,h[i]),`${i} preflight artifacts must match the runtime registry`),i==="sync"?r(s.status==="passed"&&s.result==="synchronized"||s.status==="failed"&&s.result==="failed","sync preflight status and result are incoherent"):r(s.status==="passed"&&(s.result==="created"||s.result==="reused")||s.status==="failed"&&s.result==="failed"||s.status==="skipped"&&s.result==="skipped","baseline preflight status and result are incoherent");}let t=a$2.preflight[1];r(a$2.baselineCreated===(t?.result==="created"),"baselineCreated must match the baseline preflight result"),r(a$2.stages.length===f$2.length,`stages must contain exactly ${f$2.length} canonical steps`);let d=a$2.preflight[0],l=d?.status==="failed";for(let[o,i$1]of f$2.entries()){let s=a$2.stages[o];r(s?.id===i$1,`stages[${o}].id must be ${i$1}`),r(ee(s.artifacts,i[i$1].produces),`${i$1} artifacts must match the runtime registry`),l&&r(s.status==="skipped",`${i$1} must be skipped after a hard failure`),s.status==="passed"?r(s.exitCode===0,`${i$1} passed stage must have exitCode 0`):s.status==="blocked"?r(s.exitCode!==0,`${i$1} blocked stage must have a non-zero exitCode`):s.status==="failed"?(r(s.exitCode===1,`${i$1} failed stage must have exitCode 1`),l=true):(r(s.exitCode===0,`${i$1} skipped stage must have exitCode 0`),r(s.durationMs===0,`${i$1} skipped stage must have durationMs 0`)),o===0&&((d?.status==="failed"||s.status==="failed")&&r(t?.status==="skipped","baseline must be skipped when sync or model fails"),t?.status==="skipped"&&r(d?.status==="failed"||s.status==="failed"||s.status==="skipped","baseline may be skipped only after an upstream failure"),t?.status!=="passed"&&(l=true));}let m=a$2.preflight.some(o=>o.status==="failed")||a$2.stages.some(o=>o.status==="failed"),E=a$2.stages.some(o=>o.status==="blocked"),n=m?"failed":E?"blocked":"passed",u=n==="failed"?1:n==="blocked"?2:0;r(a$2.status===n,`status must be ${n}`),r(a$2.exitCode===u,`exitCode must be ${u}`);}var le=a.intelligenceRun,de=b.intelligenceRun,ae=le;async function $e(a$4){let t=se.resolve(a$4.workspacePath),d$1=[],l$1=[],m$2=false,E=async(e,p)=>{let f=[...h[e]];if(m$2){d$1.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:f,message:"skipped because a required upstream operation failed"});return}let k=Date.now();try{let c=await p();d$1.push({id:e,status:"passed",result:c.result,durationMs:Date.now()-k,artifacts:f,message:c.message});}catch(c){m$2=true,d$1.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:f,message:c instanceof Error?c.message:String(c)});}},n$3=async(e,p)=>{let f=[...i[e].produces];if(m$2){l$1.push({id:e,status:"skipped",durationMs:0,artifacts:f,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();try{let c=await p(),b=c.exitCode??0;l$1.push({id:e,status:c.blocked||b!==0?"blocked":"passed",durationMs:Date.now()-k,artifacts:f,exitCode:b,message:c.message});}catch(c){m$2=true,l$1.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:f,exitCode:1,message:c instanceof Error?c.message:String(c)});}};await E("sync",async()=>{let e=await d(t,true),p=await j({workspacePath:t});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${p.contract.projects.length} projects`}});let u,o=()=>{if(!u)throw new Error("canonical workspace model is unavailable");return u};await n$3("model",async()=>(u=await n({workspacePath:t,includeEvidence:true}),await q(u,t),{message:`${u.summary.projectCount} projects modeled`}));let i$1=se.join(t,a.snapshot),s=false;await E("baseline",async()=>{if(!await ce.pathExists(i$1)){let e=await k({workspacePath:t,model:o()});return await l(e,t),s=true,{result:"created",message:"initial structural baseline created"}}return {result:"reused",message:"existing structural baseline reused"}}),await n$3("diff",async()=>{let e=await m({workspacePath:t,fromPath:a.snapshot,model:o()});return await n$1(e,t),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await n$3("impact",async()=>{let e=await p({workspacePath:t,fromPath:a.diff});return await q$1(e,t),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await n$3("doctor-evidence",async()=>{let e=await q$2({workspace:t,json:true,quiet:true});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await n$3("contract-evidence",async()=>{let e=await m$1({workspacePath:t,strict:true});return await n$2({workspacePath:t,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await n$3("analyze-evidence",async()=>{let e=await a$2({workspacePath:t,json:true,strict:false});return {blocked:e.summary.verdict==="blocked"||a$4.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||a$4.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await n$3("readiness-evidence",async()=>{let e=await a$3({startPath:t,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||a$4.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||a$4.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await n$3("verify",async()=>{let e$1=await f({workspacePath:t,fromImpactPath:a.impact});await g$1(e$1,t);let p=h$1(e$1,{strict:a$4.strict===true});return await j$1(t,e(e$1,p.passed)),{blocked:!p.passed,exitCode:p.exitCode,message:`${e$1.summary.verdict}; gate ${p.passed?"passed":"blocked"}`}}),await n$3("context",async()=>{u=await n({workspacePath:t,includeEvidence:true});let e=await e$1({workspacePath:t,model:u,agent:a$4.agent??"generic",includeEvidence:true});return await f$1(e,t),{message:`context grounded for ${e.agent}`}}),await n$3("agent-sync",async()=>({message:`${(await k$1({workspacePath:t,agent:a$4.agent??"generic",write:true,refreshContext:false,strict:false,preset:"enterprise"})).writtenFiles.length} grounding files written`})),await n$3("explain",async()=>{let e=await b$1({workspacePath:t,target:{kind:"release-blocked"}});return await c(e,t),{message:e.summary}});let re=l$1.some(e=>e.status==="blocked"),W=m$2?"failed":re?"blocked":"passed",ie=m$2?1:W==="blocked"?2:0,R={schemaVersion:de,chainSchemaVersion:a$1,generatedAt:new Date().toISOString(),workspacePath:t,baselineCreated:s,preflight:d$1,status:W,exitCode:ie,stages:l$1,artifactPath:ae};return te(R),await g(t,ae,R),R}export{le as WORKSPACE_INTELLIGENCE_RUN_REPORT_PATH,de as WORKSPACE_INTELLIGENCE_RUN_SCHEMA_VERSION,$e as runWorkspaceIntelligenceChain};
@@ -1,3 +0,0 @@
1
- import {b}from'./chunk-QZLIURER.js';import {d as d$1}from'./chunk-V3LRQZ36.js';import {c as c$1,e}from'./chunk-4LGXSBCN.js';import {c as c$2,b as b$2}from'./chunk-UQWOVV6V.js';import {d}from'./chunk-EFYHGCGX.js';import {k}from'./chunk-CVHMUSRX.js';import {c as c$3}from'./chunk-WYFPXTTS.js';import {f}from'./chunk-HDURFXW5.js';import {a as a$1}from'./chunk-LG6RFLPZ.js';import {a,c}from'./chunk-N7DV5L7C.js';import {r}from'./chunk-5XATWNME.js';import m from'path';import v from'readline';import b$1 from'fs-extra';var W=a.agentIndex,I=new Map(Object.keys(a).flatMap(e=>{let t=c[e];return t?[[a[e],t]]:[]}));function N(e,t){return e.kind!==t.kind?false:e.kind==="project"&&t.kind==="project"?e.project.toLowerCase()===t.project.toLowerCase():e.kind==="blocker"&&t.kind==="blocker"?e.blockerId===t.blockerId:e.kind==="trace"&&t.kind==="trace"?e.diffRef===t.diffRef:true}var L=[{name:"getWorkspaceModel",description:"Read workspace-model.json",inputSchema:{type:"object",properties:{}}},{name:"getEvidenceIndex",description:"Read agent reports INDEX.json",inputSchema:{type:"object",properties:{}}},{name:"getBlockers",description:"Aggregate blocking reasons from verify, explain, and contract-verify reports",inputSchema:{type:"object",properties:{}}},{name:"getSafeCommands",description:"Read safe commands from workspace-context-agent.json",inputSchema:{type:"object",properties:{}}},{name:"getProjectContext",description:"Read scoped project context from workspace-context-agent.json",inputSchema:{type:"object",properties:{project:{type:"string",description:"Optional project name; defaults to active scope"}}}},{name:"getArtifact",description:"Read one workspace-relative artifact path",inputSchema:{type:"object",properties:{relativePath:{type:"string"}},required:["relativePath"]}},{name:"listOperationalSkills",description:"Read workspace-skills-index.json",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceExplain",description:"Build or read workspace explain report",inputSchema:{type:"object",properties:{target:{type:"string",description:"release-blocked | project:<name> | blocker:<id> | trace:<diffRef> | <project>"}}}}];function M(e){let t=e.trim().replace(/\\/g,"/");return t.length>0&&!m.isAbsolute(t)&&!t.split("/").includes("..")&&(t.startsWith(".workspai/")||t.startsWith(".rapidkit/"))}async function l(e,t){if(!M(t))throw new Error(`Unsafe artifact path: ${t}`);let i=await f(e,t)??m.join(e,t);if(!await b$1.pathExists(i))return null;let r$1=await b$1.readJson(i),s=r(t),a=I.get(s);return a&&a$1(r$1,a,`MCP artifact ${s}`),r$1}async function J(e$1){let t=[],i=new Set,s=((await l(e$1,d$1))?.blockingReasons??[]).filter(n=>typeof n=="string"&&n.trim().length>0);if(s.length>0){t.push({artifact:d$1,reasons:s});for(let n of s)i.add(n);}let a=await l(e$1,c$2);if(e(a)){let n=(a.blockingReasons??[]).filter(o=>typeof o=="string"&&o.trim().length>0);if(n.length>0){t.push({artifact:c$2,reasons:n});for(let o of n)i.add(o);}}let c=await l(e$1,c$3),p=(c?.violations??[]).filter(n=>typeof n=="string"&&n.trim().length>0);if(p.length>0||String(c?.status??"").toLowerCase()==="failed"){let n=p.length>0?p:["Workspace contract verification failed"];t.push({artifact:c$3,reasons:n});for(let o of n)i.add(o);}return {blockingReasons:[...i],sources:t}}async function O(e$1,t,i){switch(t){case "getWorkspaceModel":return l(e$1,k);case "getEvidenceIndex":return l(e$1,W);case "getBlockers":return J(e$1);case "getSafeCommands":return {safeCommands:(await l(e$1,d))?.safeCommands??[]};case "getProjectContext":{let r=await l(e$1,d);if(!r)return null;let s=String(i.project??"").trim(),a=r.scope?.activeProject??void 0,c=s||a,p=Array.isArray(r.projects)?r.projects:[],n=c&&p.find(o=>typeof o.name=="string"&&o.name.toLowerCase()===c.toLowerCase());return {workspace:r.workspace??null,scope:r.scope??null,validation:r.validation??null,project:n??null,safeCommands:r.safeCommands??[]}}case "getArtifact":{let r=String(i.relativePath??"").trim();return l(e$1,r)}case "listOperationalSkills":return l(e$1,b$2);case "getWorkspaceExplain":{let r=String(i.target??"release-blocked").trim(),s=c$1(r);if(!s)throw new Error(`Invalid explain target: ${r}`);let a=await l(e$1,c$2);return e(a)&&N(a.target,s)?a:b({workspacePath:e$1,target:s})}default:throw new Error(`Unknown tool: ${t}`)}}function E(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,result:t})}
2
- `);}function w(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,error:{code:-32e3,message:t}})}
3
- `);}async function et(e){let t=m.resolve(e.workspacePath),i=v.createInterface({input:process.stdin,terminal:false});for await(let r of i){let s=r.trim();if(!s)continue;let a;try{a=JSON.parse(s);}catch{w(null,"Invalid JSON-RPC request");continue}let{id:c,method:p,params:n}=a;try{if(p==="initialize"){E(c,{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"workspai-workspace-mcp",version:"0.1.0"}});continue}if(p==="notifications/initialized")continue;if(p==="tools/list"){E(c,{tools:L.map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema}))});continue}if(p==="tools/call"){let o=String(n?.name??""),h=n?.arguments&&typeof n.arguments=="object"?n.arguments:{},A=await O(t,o,h);E(c,{content:[{type:"text",text:JSON.stringify(A,null,2)}],isError:A==null});continue}w(c,`Unsupported method: ${p??"unknown"}`);}catch(o){w(c,o instanceof Error?o.message:String(o));}}}async function nt(e,t,i={}){return O(m.resolve(e),t,i)}export{L as WORKSPACE_MCP_READ_TOOLS,nt as invokeMcpToolForTest,et as runWorkspaceMcpServe};
@@ -1 +0,0 @@
1
- export{k as WORKSPACE_MODEL_REPORT_PATH,j as WORKSPACE_MODEL_SCHEMA_VERSION,n as buildWorkspaceModel,o as buildWorkspaceModelCached,m as buildWorkspaceModelFacts,p as buildWorkspaceModelIncremental,l as validateWorkspaceModelStrict,q as writeWorkspaceModel}from'./chunk-CVHMUSRX.js';
@@ -1 +0,0 @@
1
- export{a as runWorkspaceStage}from'./chunk-QA5BGEQW.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-WPEEC5BX.js';
@@ -1 +0,0 @@
1
- import {a}from'./chunk-ZKAI3PJE.js';import {b as b$1,p}from'./chunk-CVHMUSRX.js';import {a as a$1}from'./chunk-LG6RFLPZ.js';import P from'fs';var w="workspace-watch-event.v1";function b(t){return a$1(t,"contracts/workspace-watch-event.v1.json","Workspace watch event"),t}function g(t){return `${t.from}\0${t.to}\0${t.kind}`}function f(t){return (t.graph?.edges??[]).map(r=>({from:r.from,to:r.to,kind:r.kind}))}function m(t){let o=[...a(t).entries()].sort((a,n)=>a[0].localeCompare(n[0])).map(([a,n])=>({id:a,hash:n})),c=f(t).map(g).sort((a,n)=>a.localeCompare(n));return b$1({projects:o,edges:c})}function R(t,r){let o=a(r),c=t?a(t):new Map,a$1=[],n=[];for(let[e,s]of o.entries())c.has(e)?c.get(e)!==s&&a$1.push(e):n.push(e);let d=[];for(let e of c.keys())o.has(e)||d.push(e);let i=new Map(t?f(t).map(e=>[g(e),e]):[]),l=new Map(f(r).map(e=>[g(e),e])),p=[];for(let[e,s]of l.entries())i.has(e)||p.push(s);let h=[];for(let[e,s]of i.entries())l.has(e)||h.push(s);let u=(e,s)=>g(e).localeCompare(g(s));return a$1.sort((e,s)=>e.localeCompare(s)),n.sort((e,s)=>e.localeCompare(s)),d.sort((e,s)=>e.localeCompare(s)),p.sort(u),h.sort(u),{changedProjects:a$1,addedProjects:n,removedProjects:d,edgesAdded:p,edgesRemoved:h}}var k=class{model=null;sequence=0;rebuild;now;constructor(r,o){this.rebuild=o?.rebuild??(()=>p({...r})),this.now=o?.now??(()=>new Date);}get currentModel(){return this.model}async start(){let r=Date.now(),{model:o}=await this.rebuild();return this.model=o,this.buildEvent("ready","initial",null,o,Date.now()-r)}async pulse(){let r=Date.now(),o=this.model,{model:c,mode:a}=await this.rebuild(),n=this.buildEvent(this.hasStructuralChange(o,c)?"changed":"unchanged",a,o,c,Date.now()-r);return this.model=c,n}hasStructuralChange(r,o){return r?m(r)!==m(o):true}buildEvent(r,o,c,a,n){let d=R(c,a),i=m(a),l=c?m(c)!==i:true;return b({schemaVersion:w,kind:r,sequence:this.sequence++,timestamp:this.now().toISOString(),mode:o,modelHash:i,modelHashChanged:l,changedProjects:d.changedProjects,addedProjects:d.addedProjects,removedProjects:d.removedProjects,graph:{nodeCount:a.graph?.nodes.length??0,edgeCount:a.graph?.edges.length??0,edgesAdded:d.edgesAdded,edgesRemoved:d.edgesRemoved},durationMs:n})}},C=new Set([".git",".hg",".svn","node_modules",".venv","venv","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),y=new Set(["reports","cache","tmp",".cache"]);function S(t){if(!t)return false;let r=t.split(/[\\/]/).filter(Boolean);if(r.some(o=>C.has(o)))return false;for(let o=0;o<r.length-1;o+=1)if((r[o]===".workspai"||r[o]===".rapidkit")&&y.has(r[o+1]))return false;return true}async function I(t){let r=new k(t.buildOptions,t.engineOptions),o=await r.start();if(t.emit(o),t.once)return;let c=t.debounceMs??250,a=t.selfWriteSuppressionMs??Math.max(400,c+150),n=null,d=false,i=false,l=0,p=async()=>{if(d){i=true;return}d=true;try{let e=await r.pulse();t.emit(e);}catch(e){t.emit(b({schemaVersion:w,kind:"error",sequence:-1,timestamp:new Date().toISOString(),mode:"full",modelHash:r.currentModel?m(r.currentModel):"",modelHashChanged:false,changedProjects:[],addedProjects:[],removedProjects:[],graph:{nodeCount:0,edgeCount:0,edgesAdded:[],edgesRemoved:[]},durationMs:0,error:e instanceof Error?e.message:String(e)}));}finally{d=false,l=Date.now()+a,i&&(i=false,p());}},h=e=>{S(e)&&(d||Date.now()<l||(n&&clearTimeout(n),n=setTimeout(()=>{n=null,p();},c)));};t.onProgress?.(`Watching ${t.workspacePath} for changes (Ctrl+C to stop).`);let u=P.watch(t.workspacePath,{recursive:true},(e,s)=>{typeof s=="string"?h(s):s&&h(Buffer.from(s).toString("utf8"));});await new Promise(e=>{let s=()=>{n&&clearTimeout(n),u.close(),e();};if(t.signal){if(t.signal.aborted){s();return}t.signal.addEventListener("abort",s,{once:true});}u.on("error",()=>s());});}export{w as WORKSPACE_WATCH_EVENT_SCHEMA_VERSION,k as WorkspaceWatchEngine,m as computeWatchModelHash,R as diffWatchModels,S as isWatchRelevantPath,I as runWorkspaceWatch};