workspai 0.46.0 → 0.47.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 (130) hide show
  1. package/README.md +61 -12
  2. package/contracts/agent-customization-pack.v1.json +6 -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 +7 -1
  6. package/contracts/mirror-ops.v1.json +16 -0
  7. package/contracts/published-contract-catalog.v1.json +31 -0
  8. package/contracts/runtime-command-surface.v1.json +149 -1
  9. package/contracts/transparency-evidence.v1.json +13 -0
  10. package/contracts/workspace-contract.v1.json +78 -0
  11. package/contracts/workspace-intelligence/workspace-context.v1.json +20 -0
  12. package/contracts/workspace-intelligence/workspace-graph-token-efficiency.v1.json +72 -0
  13. package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +6 -1
  14. package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +200 -0
  15. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +260 -0
  16. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +60 -0
  17. package/contracts/workspace-intelligence-architecture.v1.json +6 -3
  18. package/contracts/workspace-intelligence-chain.v1.json +14 -3
  19. package/contracts/workspace-share-bundle.v1.json +16 -0
  20. package/dist/analyze-UVXPRGYZ.js +1 -0
  21. package/dist/artifact-remediation-plan-EPALZ2LC.js +3 -0
  22. package/dist/autopilot-release-5BQ6F5L2.js +1 -0
  23. package/dist/chunk-22NJ2ZMG.js +2 -0
  24. package/dist/{chunk-UQWOVV6V.js → chunk-2GHUZDYA.js} +1 -1
  25. package/dist/chunk-2TEDAKP6.js +2 -0
  26. package/dist/chunk-6SWRNA47.js +4 -0
  27. package/dist/chunk-76YOPAOT.js +1 -0
  28. package/dist/chunk-7VLCK5JW.js +1 -0
  29. package/dist/{chunk-J5PIZCAU.js → chunk-BSRVO52Y.js} +1 -1
  30. package/dist/chunk-COARSXRC.js +1 -0
  31. package/dist/chunk-CV5HKU4P.js +1 -0
  32. package/dist/chunk-CW7PGBIQ.js +13 -0
  33. package/dist/{chunk-WPEEC5BX.js → chunk-DV6GJD4K.js} +1 -1
  34. package/dist/chunk-FB7SCXAZ.js +1 -0
  35. package/dist/{chunk-4LGXSBCN.js → chunk-HSGFUKCN.js} +1 -1
  36. package/dist/{chunk-ZKAI3PJE.js → chunk-ITCAMC2E.js} +1 -1
  37. package/dist/chunk-KB44JP4M.js +2 -0
  38. package/dist/{chunk-QA5BGEQW.js → chunk-KZZ36CK5.js} +1 -1
  39. package/dist/chunk-LNRAB7UY.js +1 -0
  40. package/dist/{chunk-VFDM65IE.js → chunk-MEMHNE7Y.js} +22 -22
  41. package/dist/chunk-NOFM7MNA.js +2 -0
  42. package/dist/chunk-NRYS4CLR.js +2 -0
  43. package/dist/chunk-OA537ZQ5.js +1 -0
  44. package/dist/chunk-PBHP6JNY.js +8 -0
  45. package/dist/chunk-QDWYIRHR.js +8 -0
  46. package/dist/chunk-RWRLFSKW.js +2 -0
  47. package/dist/chunk-SK6XRKGG.js +1 -0
  48. package/dist/chunk-THIOE2PB.js +2 -0
  49. package/dist/chunk-TNQI5VCW.js +36 -0
  50. package/dist/chunk-TWNFECMN.js +2 -0
  51. package/dist/{chunk-6IIZJQLV.js → chunk-U5EZHZBX.js} +1 -1
  52. package/dist/{chunk-YUATNVOT.js → chunk-VBSQ7MF6.js} +19 -19
  53. package/dist/chunk-WDKNMTJQ.js +1 -0
  54. package/dist/chunk-YCL3I2JO.js +2 -0
  55. package/dist/chunk-ZDN7RHXJ.js +1 -0
  56. package/dist/chunk-ZM5NQ5Z2.js +1 -0
  57. package/dist/{create-WCV3L6XH.js → create-7JKJDAQV.js} +1 -1
  58. package/dist/{doctor-5BWM2EMJ.js → doctor-PGPNIS76.js} +1 -1
  59. package/dist/index.d.ts +33 -12
  60. package/dist/index.js +317 -317
  61. package/dist/pipeline-IB6ILJSV.js +5 -0
  62. package/dist/{workspace-7OXW5YTJ.js → workspace-H3QXBFGB.js} +1 -1
  63. package/dist/{workspace-agent-sync-O4IA6VOA.js → workspace-agent-sync-C7SG2Z5W.js} +1 -1
  64. package/dist/{workspace-archive-H74NBBNW.js → workspace-archive-P76EDIUG.js} +1 -1
  65. package/dist/{workspace-context-R7IPUBPG.js → workspace-context-BKQBKA4C.js} +1 -1
  66. package/dist/workspace-contract-RPQQBQXR.js +1 -0
  67. package/dist/workspace-dependency-graph-23BI2HG7.js +1 -0
  68. package/dist/workspace-explain-WVN7JH3U.js +1 -0
  69. package/dist/{workspace-explain-contract-SVFJAAEI.js → workspace-explain-contract-SEFTVF6J.js} +1 -1
  70. package/dist/{workspace-feedback-REOS36ZZ.js → workspace-feedback-WAID3IOE.js} +1 -1
  71. package/dist/{workspace-foundation-KXT4QI5O.js → workspace-foundation-5OOJEO2D.js} +1 -1
  72. package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +1 -0
  73. package/dist/{workspace-history-OGOVSKZG.js → workspace-history-C6OP3IAQ.js} +1 -1
  74. package/dist/workspace-intelligence-VKDL3H2J.js +1 -0
  75. package/dist/workspace-intelligence-runner-LVALAZY7.js +1 -0
  76. package/dist/workspace-knowledge-graph-FE2NTZKV.js +1 -0
  77. package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +1 -0
  78. package/dist/workspace-knowledge-graph-query-VOSPPH4W.js +1 -0
  79. package/dist/workspace-mcp-serve-KT2I676Z.js +3 -0
  80. package/dist/workspace-model-S33CIB2R.js +1 -0
  81. package/dist/workspace-model-hash-MHXK5MEI.js +1 -0
  82. package/dist/{workspace-registry-summary-SZ46R5PD.js → workspace-registry-summary-A3YDL63D.js} +1 -1
  83. package/dist/workspace-run-M4LNJILC.js +1 -0
  84. package/dist/{workspace-verify-MFQ7IXGD.js → workspace-verify-ZGH3NXAH.js} +1 -1
  85. package/dist/workspace-watch-EVBJTMV7.js +1 -0
  86. package/docs/AI_DYNAMIC_INTEGRATION.md +73 -428
  87. package/docs/AI_EXAMPLES.md +37 -395
  88. package/docs/AI_FEATURES.md +76 -456
  89. package/docs/AI_QUICKSTART.md +49 -212
  90. package/docs/GLOSSARY.md +60 -0
  91. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +68 -7
  92. package/docs/README.md +63 -41
  93. package/docs/commands-reference.md +51 -4
  94. package/docs/config-file-guide.md +6 -2
  95. package/docs/contracts/ARTIFACT_CATALOG.md +67 -37
  96. package/docs/contracts/README.md +44 -8
  97. package/docs/graph-benchmark-methodology.md +121 -0
  98. package/docs/workspace-knowledge-graph.md +295 -0
  99. package/docs/workspace-operations.md +49 -0
  100. package/package.json +2 -1
  101. package/dist/analyze-BEBEZSZK.js +0 -1
  102. package/dist/artifact-remediation-plan-FFQSESAM.js +0 -3
  103. package/dist/autopilot-release-WUR4CQIT.js +0 -1
  104. package/dist/chunk-2G7FASAO.js +0 -2
  105. package/dist/chunk-4EPHWD27.js +0 -8
  106. package/dist/chunk-CVHMUSRX.js +0 -1
  107. package/dist/chunk-DIPD72H4.js +0 -2
  108. package/dist/chunk-EFYHGCGX.js +0 -2
  109. package/dist/chunk-FWRXA435.js +0 -2
  110. package/dist/chunk-HDURFXW5.js +0 -2
  111. package/dist/chunk-HMUKBW2S.js +0 -4
  112. package/dist/chunk-K4WNYXKK.js +0 -33
  113. package/dist/chunk-LG6RFLPZ.js +0 -1
  114. package/dist/chunk-N7DV5L7C.js +0 -1
  115. package/dist/chunk-PRBVYW3T.js +0 -1
  116. package/dist/chunk-QZLIURER.js +0 -13
  117. package/dist/chunk-RIEF2DDX.js +0 -8
  118. package/dist/chunk-SXMTSV5M.js +0 -1
  119. package/dist/chunk-SXPY523X.js +0 -1
  120. package/dist/chunk-V3LRQZ36.js +0 -1
  121. package/dist/chunk-WYFPXTTS.js +0 -2
  122. package/dist/pipeline-ORIWVVYM.js +0 -5
  123. package/dist/workspace-contract-HKCMOMFE.js +0 -1
  124. package/dist/workspace-explain-GOPQYTPQ.js +0 -1
  125. package/dist/workspace-intelligence-7IESQSXY.js +0 -1
  126. package/dist/workspace-intelligence-runner-6GJ5M4HB.js +0 -1
  127. package/dist/workspace-mcp-serve-FRVWBO36.js +0 -3
  128. package/dist/workspace-model-PPYX7B4S.js +0 -1
  129. package/dist/workspace-run-V3KKHTVF.js +0 -1
  130. package/dist/workspace-watch-SOPZHRWA.js +0 -1
@@ -1,8 +0,0 @@
1
- import {f as f$2,e}from'./chunk-T3GJ7YVG.js';import {a as a$1,b as b$2}from'./chunk-22DT744Z.js';import {h,i}from'./chunk-4KUIFXHM.js';import {g}from'./chunk-HDURFXW5.js';import {a as a$2}from'./chunk-GZTYAEWX.js';import {a,b as b$1}from'./chunk-N7DV5L7C.js';import {f as f$1,o as o$1,p as p$1}from'./chunk-5XATWNME.js';import b from'fs';import p from'path';import o from'chalk';var H=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function D(e){try{return await b.promises.access(e,b.constants.F_OK),true}catch{return false}}async function P(e){try{let n=JSON.parse(await b.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function L(e){try{return await b.promises.readFile(e,"utf-8")}catch{return ""}}function K(e){return a$1(e)}async function B(e,n){return await N([...p$1(e,"project.json"),...p$1(e,"context.json")])?true:b$2(e)?false:p.resolve(e)===p.resolve(n)?h(e).length>0:h(e).length>0}async function U(e){let n=await a$2(e,{skipDirs:H,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:B});return n.length>0?n:b$2(e)?[]:h(e).length>0?[e]:[]}function V(e,n){return p.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await D(p.join(e,t)))return true;return false}async function N(e){for(let n of e)if(await D(n))return true;return false}async function M(e){for(let n of e){let t=await P(n);if(t)return t}return null}async function q(e){return A(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function Q(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await P(p.join(e,"package.json")),r=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof r.test=="string"&&r.test.trim().length>0}async function X(e){let n=await P(p.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,r,s,a){return {id:e,severity:n,target:t,title:r,detail:s,remediation:a}}function Y(e){let n=e.reduce((t,r)=>r.severity==="fail"?t+28:r.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function Z(e,n){let t=await M(p$1(n,"project.json")),r=i(n,t),s=h(n),a=r.runtime==="unknown"?s[0]||"unknown":r.runtime,i$1=V(e,n),l=i$1,u=await X(n),g=await N([...p$1(n,"project.json"),...p$1(n,"context.json")]),d=await Q(n),h$1=await A(n,["Dockerfile","dockerfile"]),k=await A(n,[".env.example","env.example","config/env.example"]),z=await A(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),C=await q(n),m=[];return r.key==="unknown"&&m.push(f("project.stack.unknown","fail",l,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),g||m.push(f("project.marker.missing","warn",l,"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.")),d||m.push(f("project.tests.missing","warn",l,"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.")),k||m.push(f("project.env.example.missing","info",l,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),z||m.push(f("project.ci.missing","warn",l,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),C||m.push(f("project.health.missing","info",l,"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$1||m.push(f("project.container.missing","info",l,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:p.basename(n),path:n,relativePath:i$1,runtime:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:g,hasTests:d,hasDockerfile:h$1,hasEnvExample:k,hasCiConfig:z,hasHealthEndpoint:C,scripts:u,findings:m,score:Y(m)}}function ee(e){return e.name.toLowerCase()}async function ne(e){let n=new Map(e.map(s=>[ee(s),s])),t=[];for(let s of e){let a=await P(p.join(s.path,"package.json")),i={...a?.dependencies??{},...a?.devDependencies??{},...a?.peerDependencies??{}};for(let u of Object.keys(i)){let g=u.replace(/^@[^/]+\//,"").toLowerCase(),d=n.get(g);d&&d.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:d.relativePath,kind:"package"});}let l=await L(p.join(s.path,"pyproject.toml"));for(let u of e)u.relativePath!==s.relativePath&&l.includes(u.name)&&t.push({from:s.relativePath,to:u.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(s=>{let a=`${s.from}\0${s.to}\0${s.kind}`;return r.has(a)?false:(r.add(a),true)})}function te(e,n){let t=new Map;for(let r of e)t.set(r.relativePath,{project:r.relativePath,directDependents:0,directDependencies:0});for(let r of n){let s=t.get(r.from),a=t.get(r.to);s&&(s.directDependencies+=1),a&&(a.directDependents+=1);}return Array.from(t.values()).sort((r,s)=>s.directDependents-r.directDependents||s.directDependencies-r.directDependencies)}async function re(e){let n=await M(o$1(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function se(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 oe(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.hasGraph||n.push("Create `.workspai/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ke(e$1={}){let n=p.resolve(e$1.workspacePath||process.cwd());if(!await D(n))throw new Error(`Workspace path does not exist: ${n}`);let t=K(n)??n,r=f$1(t),s=await re(t),a$1=await U(t),i=await Promise.all(a$1.map(c=>Z(t,c))),l=await ne(i),u=te(i,l),g$1=[];r||g$1.push(f("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.")),i.length===0&&g$1.push(f("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 d=[...g$1,...i.flatMap(c=>c.findings)],h=se(d),k={};for(let c of i)k[c.runtime]=(k[c.runtime]||0)+1;let z=i.length>0?Math.round(i.reduce((c,y)=>c+y.score,0)/i.length):0,C=g$1.reduce((c,y)=>c+(y.severity==="fail"?20:y.severity==="warn"?8:2),0),m=Math.max(0,z-C),O=i.length===0&&h.fail===0&&d.length>0&&d.every(c=>c.id==="workspace.projects.missing"&&c.severity==="warn"),J=h.fail>0||e$1.strict&&h.warn>0&&!O?"blocked":h.warn>0?"needs-attention":"ready",w={schemaVersion:b$1.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:s,summary:{score:m,verdict:J,projectCount:i.length,runtimeCount:Object.keys(k).length,findings:h},runtimes:k,projects:i,dependencyGraph:{status:l.length>0?"generated":"empty",edges:l,topImpactedProjects:u.slice(0,5)},findings:d,nextActions:oe({findings:d,projectCount:i.length,hasGraph:l.length>0,workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:a.analyze}};if(e$1.output&&(await b.promises.mkdir(p.dirname(p.resolve(e$1.output)),{recursive:true}),await b.promises.writeFile(p.resolve(e$1.output),`${JSON.stringify(w,null,2)}
2
- `)),!e$1.output&&r){let c=f$2(w,{commandId:"workspaceAnalyze",exitCode:w.summary.verdict==="blocked"?2:w.summary.verdict==="needs-attention"?1:0,generatedAt:w.generatedAt,blockers:w.findings.filter(y=>y.severity==="fail").map(y=>y.title).slice(0,12),runId:e()});await g(t,a.analyze,c);}return w}function we(e){let n=e.summary.verdict==="ready"?o.green:e.summary.verdict==="needs-attention"?o.yellow:o.red;if(console.log(o.bold(`
3
- Workspai Workspace Analysis
4
- `)),console.log(o.cyan("Workspace:"),e.workspacePath),console.log(o.cyan("Profile:"),e.profile||"not configured"),console.log(o.cyan("Score:"),`${e.summary.score}/100`),console.log(o.cyan("Verdict:"),n(e.summary.verdict)),console.log(o.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(o.bold(`
5
- Projects`));for(let t of e.projects){let r=t.score>=85?o.green("pass"):t.score>=65?o.yellow("watch"):o.red("risk");console.log(` ${t.relativePath} ${o.gray(`${t.runtime}/${t.framework}`)} ${r} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(o.bold(`
6
- Dependency Graph`)),console.log(o.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(o.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(o.bold(`
7
- Top Findings`));for(let t of e.findings.slice(0,8)){let r=t.severity==="fail"?o.red:t.severity==="warn"?o.yellow:o.gray;console.log(` ${r(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(o.gray(` ${t.remediation}`));}}console.log(o.bold(`
8
- Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(o.gray(` - ${t}`));console.log();}export{ke as a,we as b};
@@ -1 +0,0 @@
1
- import {f,e,g}from'./chunk-HDURFXW5.js';import {b,a as a$1}from'./chunk-N7DV5L7C.js';import k from'fs-extra';var y=b.history,a=a$1.history,d=50;function A(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.generatedAt!="string"?null:e.kind==="agent-action"?typeof e.actionId!="string"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"agent-action",generatedAt:e.generatedAt,actionId:e.actionId,scope:typeof e.scope=="string"?e.scope:"workspace",summary:e.summary,outcome:e.outcome,...typeof e.evidenceSha256=="string"?{evidenceSha256:e.evidenceSha256}:{}}:e.kind==="doctor-fix"?e.scope!=="workspace"&&e.scope!=="project"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"doctor-fix",generatedAt:e.generatedAt,scope:e.scope,summary:e.summary,outcome:e.outcome,applied:typeof e.applied=="number"?e.applied:0,failed:typeof e.failed=="number"?e.failed:0,skipped:typeof e.skipped=="number"?e.skipped:0,remainingBlockers:typeof e.remainingBlockers=="number"?e.remainingBlockers:0}:typeof e.verdict!="string"||typeof e.risk!="string"||typeof e.gatePassed!="boolean"?null:{kind:"verify",generatedAt:e.generatedAt,verdict:e.verdict,risk:String(e.risk),affectedProjects:typeof e.affectedProjects=="number"?e.affectedProjects:0,freshness:e.freshness??"unknown",gatePassed:e.gatePassed,blockingReasons:typeof e.blockingReasons=="number"?e.blockingReasons:0,policyViolations:typeof e.policyViolations=="number"?e.policyViolations:0}}function S(t,e){return {kind:"verify",generatedAt:t.generatedAt,verdict:t.summary.verdict,risk:t.impact.risk,affectedProjects:t.impact.affectedProjects,freshness:t.freshness.verdict,gatePassed:e,blockingReasons:t.blockingReasons.length,policyViolations:t.policyViolations.length}}function F(t){return {kind:"agent-action",generatedAt:t.generatedAt,actionId:t.actionId,scope:t.scope,summary:t.summary,outcome:t.outcome,...t.evidenceSha256?{evidenceSha256:t.evidenceSha256}:{}}}function V(t,e){let o=t.appliedFixes.filter(i=>i.outcome==="applied").length,r=t.appliedFixes.filter(i=>i.outcome==="failed").length,n=t.appliedFixes.filter(i=>i.outcome==="skipped").length,s=t.appliedFixes.filter(i=>i.outcome==="guidance").length,c=t.remainingBlockers.length,g=r>0||c>0?"failed":"ok";return {kind:"doctor-fix",generatedAt:t.generatedAt,scope:e,summary:`${o} applied, ${r} failed, ${n} skipped, ${s} guidance, ${c} blocker(s) remaining`,outcome:g,applied:o,failed:r,skipped:n,remainingBlockers:c}}async function E(t){let e=await f(t,a);try{if(!e||!await k.pathExists(e))return null;let o=await k.readJson(e);return o?.schemaVersion!==y||!Array.isArray(o.entries)?null:{schemaVersion:y,retention:typeof o.retention=="number"?o.retention:d,entries:o.entries.map(r=>A(r)).filter(r=>r!=null)}}catch{return null}}function x(t,e,o=d){let r=Math.max(1,Math.floor(o)),n=[...t?.entries??[],e],s=n.slice(Math.max(0,n.length-r));return {schemaVersion:y,retention:r,entries:s}}async function v(t,e$1,o){return e(t,a,async()=>{let r=await f(t,a),n=await E(t);if(r&&!n)throw new Error(`Workspace history is unreadable or invalid; refusing to overwrite: ${r}`);let s=x(n,e$1,o?.retention??d);return await g(t,a,s),s})}export{y as a,a as b,d as c,A as d,S as e,F as f,V as g,E as h,x as i,v as j};
@@ -1 +0,0 @@
1
- import {a as a$1}from'./chunk-A5FBGRJA.js';import {b as b$1,k}from'./chunk-WYFPXTTS.js';import {f as f$1,g}from'./chunk-HDURFXW5.js';import {o}from'./chunk-5XATWNME.js';import {r,p}from'./chunk-EYJ2CQSK.js';import a from'path';import {existsSync}from'fs';import u from'fs-extra';var f=".workspai/workspace-registry.v1.json",w="workspace-registry.v1";function x(r){return {slug:r.slug,relativePath:r.relativePath,framework:r.framework,kit:r.kit,source:r.source}}async function A(r){let e=o(r,"workspace.json").find(t=>existsSync(t));if(!e)return {exists:false,legacyProjectCount:0};try{let t=await u.readJson(e),c=Array.isArray(t.projects)?t.projects.length:0,o=typeof t.workspace_name=="string"&&t.workspace_name.trim()||typeof t.name=="string"&&t.name.trim()||a.basename(r);return {exists:true,manifestPath:e,workspaceName:o,profile:typeof t.profile=="string"?t.profile:void 0,legacyProjectCount:c}}catch{return {exists:true,manifestPath:e,legacyProjectCount:0,workspaceName:a.basename(r)}}}async function b(r$1){let e=a$1(r$1);for(let t of r())if(await u.pathExists(t))try{let o=((await u.readJson(t)).workspaces||[]).find(s=>a$1(s.path)===e);if(o)return {exists:true,projectCount:Array.isArray(o.projects)?o.projects.length:0,registryPath:t}}catch{continue}return {exists:false,projectCount:0,registryPath:a.join(p(),"workspaces.json")}}async function E(r,e){let t=a.resolve(r),c=await f$1(t,b$1),o=await A(t),s=await b(t),i=e?.contract!==void 0||!!c,n=[];if(e?.contract)n=e.contract.projects||[];else if(i)try{let{contract:d}=await k({workspacePath:t});n=d.projects||[];}catch{n=[];}let S={contract:{exists:i,projectCount:n.length,path:b$1},globalRegistry:{exists:s.exists,projectCount:s.projectCount,path:s.registryPath},legacyWorkspaceJson:{exists:o.exists,projectCount:o.legacyProjectCount,path:o.manifestPath?a.relative(t,o.manifestPath):void 0}},p="none",m=[],y=0;return i?(p="workspace.contract.json",m=n.map(x),y=m.length):s.projectCount>0?(p="global-registry",y=s.projectCount):o.legacyProjectCount>0&&(p="legacy-workspace.json",y=o.legacyProjectCount),{contractExists:i,summary:{schemaVersion:w,kind:"rapidkit.workspace.registry",workspacePath:t,workspaceName:o.workspaceName||a.basename(t),profile:o.profile,projectCount:y,authority:p,contractPath:b$1,projects:m,sources:S}}}async function Y(r){let e=await f$1(r,f);if(!e)return null;try{let t=await u.readJson(e);return t?.schemaVersion!==w?null:t}catch{return null}}async function D(r,e){let t=await _(r,e);return await g(r,f,t),t}async function _(r,e){return {...(await E(r,{contract:e?.contract})).summary,generatedAt:(e?.now??new Date).toISOString(),registrySummaryPath:f}}function H(r,e=""){return r.projectCount>0?r.authority==="workspace.contract.json"?`${r.projectCount} project(s) registered in workspace contract${e}.`:r.authority==="global-registry"?`${r.projectCount} project(s) registered in global workspace registry${e}.`:`${r.projectCount} project(s) registered in legacy workspace manifest${e}.`:`Workspace state exists, but no projects are registered yet${e}.`}export{f as a,w as b,E as c,Y as d,D as e,_ as f,H as g};
@@ -1 +0,0 @@
1
- import {b as b$2,c,d}from'./chunk-ZKAI3PJE.js';import {a as a$2,b as b$3}from'./chunk-PYCJWW4B.js';import {p,j,a as a$1,o,g as g$1,d as d$1,f as f$1}from'./chunk-FWRXA435.js';import {c as c$1}from'./chunk-WPEEC5BX.js';import {n,b as b$4}from'./chunk-CVHMUSRX.js';import {a as a$3}from'./chunk-WYFPXTTS.js';import {f,g}from'./chunk-HDURFXW5.js';import {a as a$4}from'./chunk-LG6RFLPZ.js';import {b as b$1,a,c as c$2}from'./chunk-N7DV5L7C.js';import m from'path';import v from'fs-extra';var oe="rapidkit-blocker-resolution-v1";function ae(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return b$4({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function ge(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function ke(e){let t=ge(e.reason),r=ae({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",studioActionId:"run-analyze"}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:oe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function ce(e){return Array.from(new Set(e.blockingReasons.map(r=>r.trim()).filter(Boolean))).slice(0,12).map((r,s)=>ke({reason:r,blockerId:`blocker-${s+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function ye(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function he(e){return e.length===0||e.every(t=>ye(t))}function de(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&he(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Ue(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ue=b$1.verify,z=a.verify;function ve(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function le(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f$1)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$4(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$4(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let o=s.transitiveImpact.reduce((u,d)=>Math.max(u,d.distance??0),0);s.summary.blastRadius.maxDistance!==o&&i.push("blastRadius.maxDistance does not match transitive impact distances");let k=s.diff.currentModel.graph?.edges.length??0;if(s.summary.blastRadius.graphEdges!==k&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==j(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function be(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function we(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function Re(e,t){if(e.id==="workspace.doctor")return m.join(t,a.doctor);if(e.id==="workspace.contract.verify")return m.join(t,a.contractVerify);if(e.id==="workspace.readiness")return m.join(t,a.readiness);if(e.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function b(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function Ce(e){let t=b(e.healthScore),r=b(e.summary),s=typeof t?.errors=="number"?t.errors:0,i=typeof t?.percent=="number"?t.percent:void 0;return s>0||r?.hasSystemErrors===true?{status:"fail",message:`Doctor evidence reports ${s} error(s).`}:typeof i=="number"&&i<70?{status:"warn",message:`Doctor health score is ${i}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function Ae(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function Ee(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function Se(e){let t=b(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function We(e){let t=e.schemaVersion==="rapidkit-doctor-fix-result-v1"?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function je(e,t){let r=await f(e,".workspai/reports/doctor-remediation-plan-last-run.json");if(!r)return false;try{let s=b(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let o=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!o||!t)return true;let k=Date.parse(o),u=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(u)?true:k>=u}catch{return false}}function xe(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Pe(e){let t=b(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function Ie(e,t,r){let s=xe(t),i=c$1(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let o=i.stage;if(s&&o!==s)return {status:"missing",message:`Workspace run evidence is for stage "${o}", expected "${s}".`};let k=Array.isArray(i.projects)?i.projects:[],u=t.project?.toLowerCase();if(!u)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=k.find(g=>{let c=b(g);if(!c)return false;let n=typeof c.projectName=="string"?c.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(f=>c[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return n===u||a.some(f=>f.endsWith(`/${u}`)||f===u)});if(d){let g=C(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(g)return {status:"fail",message:g};let c=b(d),n=typeof c?.status=="string"?c.status:"unknown";return n==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:n==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:n==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${n} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function C(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function Ve(e){if(e.id==="workspace.doctor")return c$2.doctor;if(e.id==="workspace.readiness")return c$2.readiness;if(e.id==="workspace.contract.verify")return c$2.contractVerify;if(e.id==="workspace.analyze")return c$2.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function $e(e,t,r,s){let i=Re(e,t),o=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let k=i?await f(t,o??""):null;if(!i||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:o,message:o?`Missing evidence report: ${o}`:"No evidence mapping exists for this command."};let u;try{u=await v.readJson(k);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=b(u);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:"Evidence report is not a JSON object."};let g=Ve(e);if(g)try{a$4(d,g,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=C(d.generatedAt,s,"Doctor evidence");n?c={status:"fail",message:n}:c=Ce(d);}else if(e.id==="workspace.readiness"){let n=C(d.generatedAt,s,"Release readiness evidence");n?c={status:"fail",message:n}:c=Ae(d);}else if(e.id==="workspace.contract.verify"){let n=C(d.generatedAt,s,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=Ee(d);}else if(e.id==="workspace.analyze"){let n=C(d.generatedAt,s,"Analyze evidence");n?c={status:"fail",message:n}:c=Se(d);}else if(e.id==="workspace.pipeline"){let n=C(d.generatedAt,s,"Pipeline evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion==="rapidkit-doctor-fix-result-v1"?d:d.fixResult,a=b(n),f=typeof a?.generatedAt=="string"?a.generatedAt:void 0,y=C(f,s,"Doctor fix result");y?c={status:"fail",message:y}:await je(t,f)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=We(d);}else if(e.id.startsWith("project."))c=Ie(d,e,s);else {let n=C(d.generatedAt,s,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:o,message:c.message}}function Fe(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,o=e.filter(n=>n.status==="missing").length,k=e.filter(n=>n.status==="skipped").length,u=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,g="ready",c=0;return u.length>0||t.blockingReasons.length>0?(g="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(g="needs-attention",c=1),{verdict:g,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:o,stepsSkipped:k}}function Oe(e,t){let r=W(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),s=new Set(r.map(a=>a.toLowerCase())),i=W(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!s.has(a.toLowerCase()))),o=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let f=a.project.toLowerCase(),y=o.get(f)??[];y.push(a),o.set(f,y);}let k=[],u=[],d=[],g=[],c=false,n=(a,f)=>{let y=o.get(a.toLowerCase())??[];if(y.length===0){d.push(a);return}let j=y.filter(p=>p.status==="fail"),w=j.filter(p=>p.required),x=y.filter(p=>p.status==="missing"),A=x.filter(p=>p.required),P=y.some(p=>p.status==="pass"||p.status==="warn");if(w.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has failed verification evidence (${w.map(p=>p.id).join(", ")}).`);return}if(j.length>0){u.push(a),c=true;return}if(A.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has missing required verification evidence (${A.map(p=>p.id).join(", ")}).`);return}if(x.length>0){u.push(a),c=true;return}if(P){k.push(a);return}d.push(a);};for(let a of r)n(a,"directly-changed");for(let a of i)n(a,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:W(k),uncovered:W(u),unverifiable:W(d)},blockingReasons:g,needsAttention:c}}function W(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Be(e){let t=m.resolve(e.workspacePath);if(e.fromImpactPath){let o=ve(t,e.fromImpactPath);return {impact:await le(o),fromImpactRef:m.relative(t,o).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g$1);if(await v.pathExists(r))return {impact:await le(r),fromImpactRef:g$1,impactFromDisk:true};let s=m.join(t,d$1);if(await v.pathExists(s))return {impact:await p({workspacePath:t,fromPath:d$1,scope:e.scope,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),fromImpactRef:d$1,impactFromDisk:false};let i=await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {impact:{schemaVersion:f$1,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",diffRef:a.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:i.graph?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:b$1.diff,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",toRef:a.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function _e(e,t){if(t)return e.generatedAt}async function ft(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Be(e),o$1=r.diff.currentModel,k=i?await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):o$1,u=[];if(i){let l=await p({workspacePath:t,fromPath:r.diff.fromRef,diff:r.diff,scope:e.scope,now:e.now}),B=[r.affectedProjects,r.transitiveImpact,r.verificationPlan],_=[l.affectedProjects,l.transitiveImpact,l.verificationPlan];JSON.stringify(B)!==JSON.stringify(_)&&u.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&j(k)!==r.diff.toHash&&u.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$1=r.diff.git;if(i&&d$1?.available){let l=a$1(t,{ref:d$1.ref}),B=r.diff.changes.filter(h=>h.type.startsWith("git.")).map(h=>`${h.type}:${h.target.replace(/^git:/,"")}`).sort(),_=[...l.changedFiles.map(h=>`git.file.changed:${h}`),...l.untrackedFiles.map(h=>`git.untracked:${h}`),...l.deletedFiles.map(h=>`git.deleted:${h}`)].sort();(!l.available||l.commit!==d$1.commit||JSON.stringify(_)!==JSON.stringify(B))&&u.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let g=_e(r,i),c$1=be([...o(),...r.verificationPlan]).filter(l=>we(e.scope,l)),n$1=[];for(let l of c$1)n$1.push(await $e(l,t,o$1.contracts.exists===true,g));let a=Oe(r,n$1),f=a$2(o$1.graph??{nodes:[],edges:[]}),y=b$2(o$1),j$1=await Ne(t),w=c(y,j$1?.freshness?.projectHashes),x={verdict:w.verdict,baseline:w.baseline,changed:w.changed,added:w.added,removed:w.removed,projectHashes:d(y)},A=b$3(f),P=o$1.policies?.mode??"warn",p$1=await De(o$1,t),O=He(P,p$1),E=Fe(n$1,{blockingReasons:[...a.blockingReasons,...A,...O.blockingReasons,...u],needsAttention:a.needsAttention||O.needsAttention}),fe=n$1.filter(l=>l.status==="missing"&&l.evidencePath).map(l=>l.evidencePath),I=[...n$1.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),...a.blockingReasons,...A,...O.blockingReasons,...u],pe=p$1.filter(l=>l.severity==="error").length,me=o$1.summary?.projectCount??o$1.projects.length,J=de({projectCount:me,verdict:E.verdict,exitCode:E.exitCode,blockingReasons:I,policyErrorCount:pe});E.verdict=J.verdict,E.exitCode=J.exitCode;let G=I.length>0?ce({blockingReasons:I,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:z}):[];return {schemaVersion:ue,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:E,steps:n$1,missingEvidence:fe,blockingReasons:I,...G.length>0?{resolutionHints:G}:{},verificationPlan:c$1,affectedSubgraph:a.subgraph,graphIntegrity:f,freshness:x,policyMode:P,policyViolations:p$1}}async function De(e,t){let r=[];for(let i of e.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await f(t,a.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let o of i.violations)typeof o=="string"&&o.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:o});}}catch{}return r.sort((i,o)=>i.source!==o.source?i.source.localeCompare(o.source):i.code!==o.code?i.code.localeCompare(o.code):i.message.localeCompare(o.message))}function He(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function Ne(e){let t=m.join(e,z);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ue?r:null}catch{return null}}async function pt(e,t){return g(t,z,a$3(e))}function Me(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function mt(e,t){return Me(e,t).exitCode}export{oe as a,Ue as b,ue as c,z as d,Oe as e,ft as f,pt as g,Me as h,mt as i};
@@ -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{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};