workspai 0.43.0 → 0.44.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 (173) hide show
  1. package/README.md +26 -13
  2. package/contracts/agent-customization-pack.v1.json +1 -1
  3. package/contracts/autopilot-release.v1.json +204 -0
  4. package/contracts/cli-operation-result.v1.json +119 -0
  5. package/contracts/command-capabilities.v1.json +138 -0
  6. package/contracts/compatibility-matrix.v1.json +37 -0
  7. package/contracts/create-planner-capabilities.v1.json +156 -65
  8. package/contracts/doctor-project-scan.v2.json +60 -0
  9. package/contracts/doctor-remediation-plan.v1.json +19 -4
  10. package/contracts/doctor-remediation-plan.v2.json +7 -0
  11. package/contracts/doctor-workspace-cache.v2.json +82 -0
  12. package/contracts/extension-cli-compatibility.v1.json +47 -3
  13. package/contracts/infra-plan.v1.json +189 -0
  14. package/contracts/private-product-manifest.v1.json +155 -0
  15. package/contracts/product-factory-plan.v1.json +200 -0
  16. package/contracts/project-archive.v1.json +40 -0
  17. package/contracts/project-entry-capability.v1.json +127 -0
  18. package/contracts/published-contract-catalog.v1.json +334 -0
  19. package/contracts/runtime-command-surface.v1.json +239 -10
  20. package/contracts/version.v1.json +48 -0
  21. package/contracts/workspace-archive-capabilities.v1.json +90 -0
  22. package/contracts/workspace-archive-manifest.v1.json +107 -0
  23. package/contracts/workspace-archive-operation-result.v1.json +565 -0
  24. package/contracts/workspace-intelligence/agent-customization-pack-report.v1.json +98 -0
  25. package/contracts/workspace-intelligence/agent-hooks.v1.json +38 -0
  26. package/contracts/workspace-intelligence/agent-reports-index.v1.json +56 -0
  27. package/contracts/workspace-intelligence/mcp-design.v1.json +42 -0
  28. package/contracts/workspace-intelligence/workspace-context.v1.json +12 -0
  29. package/contracts/workspace-intelligence/workspace-explain.v1.json +1 -0
  30. package/contracts/workspace-intelligence-architecture.v1.json +723 -0
  31. package/contracts/workspace-intelligence-chain.v1.json +1194 -0
  32. package/contracts/workspace-list.v1.json +56 -0
  33. package/contracts/workspace-model-cache.v1.json +55 -0
  34. package/contracts/workspace-snapshot.v1.json +58 -0
  35. package/contracts/workspace-snapshot.v2.json +97 -0
  36. package/contracts/workspace-sync.v1.json +30 -0
  37. package/contracts/workspace-watch-event.v1.json +112 -0
  38. package/dist/analyze-6OCBM4ID.js +1 -0
  39. package/dist/{artifact-remediation-plan-5GJWPPRS.js → artifact-remediation-plan-Z7OCSME3.js} +3 -3
  40. package/dist/autopilot-release-LI2WJCEW.js +1 -0
  41. package/dist/{chunk-LZQNVH7D.js → chunk-2K3GYCPS.js} +1 -1
  42. package/dist/chunk-2QN6BMM7.js +2 -0
  43. package/dist/chunk-2QOWRBQD.js +1 -0
  44. package/dist/chunk-5AKYMAIL.js +1 -0
  45. package/dist/{chunk-RE773WOX.js → chunk-5PVEQ6CZ.js} +5 -5
  46. package/dist/{chunk-AFSZHLQT.js → chunk-7EIMPQR3.js} +1 -1
  47. package/dist/{chunk-3KXW53QI.js → chunk-7IHLTPZ6.js} +1 -1
  48. package/dist/chunk-7RIWU5TZ.js +1 -0
  49. package/dist/{chunk-T6OR6YOI.js → chunk-7UZVOYF5.js} +1 -1
  50. package/dist/chunk-B66A4TVP.js +1 -0
  51. package/dist/chunk-CL6TGI4Q.js +8 -0
  52. package/dist/chunk-FWJV7CCI.js +2 -0
  53. package/dist/chunk-J4AICQFB.js +1 -0
  54. package/dist/chunk-JICOD2GI.js +1 -0
  55. package/dist/{chunk-OJEWQO3Z.js → chunk-JP25YL3J.js} +17 -17
  56. package/dist/chunk-L2Q7B2OJ.js +1 -0
  57. package/dist/chunk-L3E6IRUQ.js +8 -0
  58. package/dist/chunk-LG6RFLPZ.js +1 -0
  59. package/dist/chunk-LGP6WXS2.js +4 -0
  60. package/dist/{chunk-VRDF2J46.js → chunk-M4VITK6X.js} +52 -50
  61. package/dist/chunk-NTXO7BMH.js +4 -0
  62. package/dist/{chunk-LPZFK3Y6.js → chunk-OW4UNG27.js} +65 -66
  63. package/dist/{chunk-LUP4U6EE.js → chunk-P424XYHP.js} +1 -1
  64. package/dist/chunk-P4SWTY5X.js +33 -0
  65. package/dist/chunk-TQEMLBAG.js +1 -0
  66. package/dist/chunk-TRMDODFM.js +13 -0
  67. package/dist/chunk-UNF72FTB.js +1 -0
  68. package/dist/chunk-V5JN4TDX.js +2 -0
  69. package/dist/chunk-VA5MRHKM.js +2 -0
  70. package/dist/chunk-XIVFLY6G.js +1 -0
  71. package/dist/chunk-YUX4YFGL.js +78 -0
  72. package/dist/{create-WRZO4HK2.js → create-DFAWAS5C.js} +1 -1
  73. package/dist/demo-kit-DZ7TPG7K.js +149 -0
  74. package/dist/doctor-PVSWDBJL.js +1 -0
  75. package/dist/{dotnet-webapi-clean-IPY3MCGQ.js → dotnet-webapi-clean-BYUUHX5Y.js} +20 -20
  76. package/dist/{gofiber-standard-N5N3QGH3.js → gofiber-standard-B6UK5GR7.js} +31 -31
  77. package/dist/{gogin-standard-LAWQTBWL.js → gogin-standard-BXU44VEM.js} +31 -31
  78. package/dist/index.d.ts +250 -24
  79. package/dist/index.js +218 -182
  80. package/dist/pipeline-ND734AJM.js +5 -0
  81. package/dist/{platform-capabilities-XAVU4HSM.js → platform-capabilities-YICBF4FA.js} +1 -1
  82. package/dist/{pythonRapidkitExec-3L3XJBSY.js → pythonRapidkitExec-UJYIB6FL.js} +1 -1
  83. package/dist/{springboot-standard-OZYF7ZM7.js → springboot-standard-PEHDKH2L.js} +27 -27
  84. package/dist/{workspace-PR6VZRBG.js → workspace-FQT3QIRS.js} +1 -1
  85. package/dist/workspace-agent-sync-ZYCPXTU3.js +1 -0
  86. package/dist/workspace-archive-EEGLHZDW.js +10 -0
  87. package/dist/workspace-context-WAGGJCDL.js +1 -0
  88. package/dist/{workspace-contract-XUGMCUSQ.js → workspace-contract-SEI4SNSG.js} +1 -1
  89. package/dist/workspace-explain-MVGGRCDN.js +1 -0
  90. package/dist/workspace-explain-contract-KT757JGQ.js +1 -0
  91. package/dist/{workspace-feedback-R6H4UFZB.js → workspace-feedback-RCB25NFO.js} +1 -1
  92. package/dist/{workspace-foundation-KGSV4E6D.js → workspace-foundation-KXDL6P6X.js} +1 -1
  93. package/dist/{workspace-history-CGCK2DJI.js → workspace-history-M4QQBIPB.js} +1 -1
  94. package/dist/workspace-intelligence-QOGD2TZS.js +1 -0
  95. package/dist/workspace-mcp-serve-CEFKEMYG.js +3 -0
  96. package/dist/{workspace-model-PNXXOGPO.js → workspace-model-GMSRBICO.js} +1 -1
  97. package/dist/workspace-registry-summary-S52SEJAG.js +1 -0
  98. package/dist/workspace-run-VC4OUPRF.js +1 -0
  99. package/dist/{workspace-verify-WSDUUTR5.js → workspace-verify-NP4GMFSV.js} +1 -1
  100. package/dist/workspace-watch-IIBH3Y25.js +1 -0
  101. package/docs/AI_FEATURES.md +67 -34
  102. package/docs/README.md +2 -1
  103. package/docs/commands-reference.md +26 -14
  104. package/docs/contracts/ARTIFACT_CATALOG.md +60 -36
  105. package/docs/contracts/README.md +3 -2
  106. package/docs/create-planner-capabilities.md +36 -18
  107. package/docs/workspace-operations.md +25 -0
  108. package/package.json +35 -13
  109. package/scripts/enterprise-package-smoke.mjs +40 -8
  110. package/scripts/prepack-enterprise.mjs +8 -0
  111. package/templates/kits/fastapi-ddd/.gitignore.j2 +11 -0
  112. package/templates/kits/fastapi-ddd/README.md.j2 +23 -18
  113. package/templates/kits/fastapi-ddd/common/env.example.j2 +2 -2
  114. package/templates/kits/fastapi-ddd/pyproject.toml.j2 +7 -7
  115. package/templates/kits/fastapi-ddd/src/app/config/__init__.py.j2 +1 -1
  116. package/templates/kits/fastapi-ddd/src/cli.py.j2 +6 -9
  117. package/templates/kits/fastapi-ddd/src/main.py.j2 +1 -1
  118. package/templates/kits/fastapi-standard/.gitignore.j2 +11 -0
  119. package/templates/kits/fastapi-standard/README.md.j2 +35 -30
  120. package/templates/kits/fastapi-standard/common/env.example.j2 +2 -2
  121. package/templates/kits/fastapi-standard/pyproject.toml.j2 +7 -7
  122. package/templates/kits/fastapi-standard/src/cli.py.j2 +7 -10
  123. package/templates/kits/fastapi-standard/src/main.py.j2 +1 -1
  124. package/templates/kits/fastapi-standard/src/routing/examples.py.j2 +1 -1
  125. package/templates/kits/fastapi-standard/tests/test_examples.py.j2 +1 -1
  126. package/templates/kits/nestjs-standard/.dockerignore.j2 +11 -0
  127. package/templates/kits/nestjs-standard/.eslintrc.js.j2 +25 -0
  128. package/templates/kits/nestjs-standard/.gitignore.j2 +22 -0
  129. package/templates/kits/nestjs-standard/.node-version.j2 +1 -0
  130. package/templates/kits/nestjs-standard/.nvmrc.j2 +1 -0
  131. package/templates/kits/nestjs-standard/.prettierrc.j2 +7 -0
  132. package/templates/kits/nestjs-standard/README.md.j2 +23 -18
  133. package/templates/kits/nestjs-standard/docs/README.md.j2 +2 -2
  134. package/templates/kits/nestjs-standard/jest.config.ts.j2 +1 -7
  135. package/templates/kits/nestjs-standard/package.json.j2 +1 -1
  136. package/templates/kits/nestjs-standard/src/config/configuration.ts.j2 +4 -4
  137. package/templates/kits/nestjs-standard/src/main.ts.j2 +1 -1
  138. package/templates/kits/nestjs-standard/src/modules/index.ts.j2 +1 -1
  139. package/templates/kits/nestjs-standard/tsconfig.build.json.j2 +1 -1
  140. package/templates/kits/nestjs-standard/tsconfig.json.j2 +1 -1
  141. package/dist/analyze-5BU4QIPK.js +0 -1
  142. package/dist/autopilot-release-QYUOVB26.js +0 -1
  143. package/dist/chunk-54XJNLYC.js +0 -13
  144. package/dist/chunk-5SWNSJGW.js +0 -1
  145. package/dist/chunk-753LOKFZ.js +0 -2
  146. package/dist/chunk-AAKUNWPR.js +0 -78
  147. package/dist/chunk-AQ4XZZC6.js +0 -1
  148. package/dist/chunk-CVTCPPEF.js +0 -1
  149. package/dist/chunk-DNAY5ALC.js +0 -1
  150. package/dist/chunk-EWYYLJQY.js +0 -2
  151. package/dist/chunk-LO4C4VXR.js +0 -4
  152. package/dist/chunk-LYC6AIF2.js +0 -2
  153. package/dist/chunk-NAAQMSO3.js +0 -1
  154. package/dist/chunk-NFUXULIF.js +0 -1
  155. package/dist/chunk-OL64GWQC.js +0 -9
  156. package/dist/chunk-PI5KUXDA.js +0 -7
  157. package/dist/chunk-SI3AQKIP.js +0 -1
  158. package/dist/chunk-VZKSNUEE.js +0 -2
  159. package/dist/chunk-WU4ZRRA5.js +0 -4
  160. package/dist/chunk-XEJD4KCV.js +0 -33
  161. package/dist/demo-kit-AJ5LIM5G.js +0 -149
  162. package/dist/doctor-MF3M3FS3.js +0 -1
  163. package/dist/pipeline-QCUHFWDY.js +0 -5
  164. package/dist/workspace-agent-sync-KTYF3HQR.js +0 -1
  165. package/dist/workspace-archive-GCZNI44O.js +0 -3
  166. package/dist/workspace-context-QUTOP2XV.js +0 -1
  167. package/dist/workspace-explain-JEONEGZZ.js +0 -1
  168. package/dist/workspace-explain-contract-DNS2YEL7.js +0 -1
  169. package/dist/workspace-intelligence-QJGVL37U.js +0 -1
  170. package/dist/workspace-mcp-serve-AK4MYEHQ.js +0 -3
  171. package/dist/workspace-registry-summary-RUJE6RPH.js +0 -1
  172. package/dist/workspace-run-Y7YMUIHX.js +0 -1
  173. package/dist/workspace-watch-AGPOJ74Q.js +0 -1
@@ -0,0 +1,33 @@
1
+ import {d as d$1,b as b$2,e,f as f$1}from'./chunk-V5JN4TDX.js';import {d as d$2}from'./chunk-UNF72FTB.js';import {b as b$1,f as f$2,j as j$1,k,h,i,l,m,n as n$1,o,p,q,r,t,v,x,s as s$1,u,w,y,z,A as A$1,B,C,D,E,F,G,a as a$2,H,I}from'./chunk-XIVFLY6G.js';import {n,k as k$1,b as b$4}from'./chunk-JICOD2GI.js';import {j}from'./chunk-2QN6BMM7.js';import {f,b as b$3,a as a$1}from'./chunk-FWJV7CCI.js';import {b,a}from'./chunk-5AKYMAIL.js';import s from'path';import f$3 from'fs-extra';var J=["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"];var lt="workspace-operational-skill.v1";function dt(e){if(typeof e!="string")return null;let t=e.trim();return !t||t.includes("/")||t.includes("..")?null:t}function Ke(e){let t=dt(e.skillId);if(!t)throw new Error(`Invalid skill id: ${e.skillId}`);return {schemaVersion:lt,skillId:t,canonicalPath:H(t),title:e.title,triggers:[...e.triggers].sort((r,n)=>r.localeCompare(n)),requiredReports:[...e.requiredReports].sort((r,n)=>r.localeCompare(n)),scopedProjects:[...e.scopedProjects??[]].sort((r,n)=>r.localeCompare(n)),verificationCommands:[...e.verificationCommands],answerContractSections:[...J],...e.promptStem?{promptStem:e.promptStem}:{},markdown:e.markdown}}var pt=b.skillsIndex;function qe(e){let t=[...e.skills].sort((n,l)=>n.skillId.localeCompare(l.skillId)),r=e.inputsHash??b$4({skillIds:t.map(n=>n.skillId),paths:t.map(n=>n.canonicalPath)});return {schemaVersion:pt,generatedAt:e.generatedAt,inputsHash:r,skills:t.map(n=>({skillId:n.skillId,path:n.canonicalPath,schemaVersion:n.schemaVersion,title:n.title}))}}var Ve=[a.agentIndex,d$1,d$2],ut=[{skillId:"workspai-diagnose-api-failure",title:"Diagnose API failure",triggers:["api failure","500 error","integration test failed","service unreachable"],objective:"Investigate a failing API or service using Workspai evidence before editing application code.",steps:[`Read \`${a.agentIndex}\` and identify fail/warn reports for the scoped project.`,`Read \`${a.doctor}\`, \`doctor-project-last-run.json\`, and project-scoped run evidence if present.`,"If a fix was requested, read `artifact-remediation-plan-last-run.json` for cross-artifact next steps, then `doctor-remediation-plan-last-run.json` for Doctor-specific file edits.","Map the failure to workspace vs project scope; cite exit codes and blocker messages.","Propose the smallest safe fix (config, env, dependency) with explicit verification commands."]},{skillId:"workspai-release-readiness",title:"Release readiness",triggers:["release","ship","production","readiness gate"],objective:"Assess whether this workspace is release-ready using governed Workspai gates.",steps:[`Read \`${a.readiness}\` and \`pipeline-last-run.json\`.`,`Read \`${a.verify}\` for verdict and blocking reasons.`,"Read `.workspai/reports/artifact-remediation-plan-last-run.json` when a Studio or agent repair path is needed.","List blocking gates first; never claim ready without cited report fields.","Provide one safe next command and a verification checklist."]},{skillId:"workspai-safe-schema-migration",title:"Safe schema migration",triggers:["migration","schema change","database migration","db migrate"],objective:"Plan and verify a schema migration with blast-radius awareness.",steps:["Identify affected projects from workspace model and dependency graph.","Run or review impact/verify evidence for transitive dependents.","Require project-scoped test/build commands before promoting the migration.","Document rollback and verification signals."]},{skillId:"workspai-dependency-upgrade",title:"Dependency upgrade",triggers:["upgrade dependency","bump package","security advisory","outdated deps"],objective:"Upgrade dependencies with graph-aware verification.",steps:["Scope the upgrade to the owning project from workspace model.","Check transitive dependents via workspace graph / impact reports.","Prefer workspace run test/build for affected projects.","Re-run `workspace verify` after evidence refresh."]},{skillId:"workspai-rename-contract",title:"Rename contract safely",triggers:["rename contract","rename event","breaking api","contract change"],objective:"Rename or change a shared contract with consumer awareness.",steps:["Read `.workspai/workspace.contract.json` for publishes/consumes/owns edges.","List all consumer projects before proposing renames.","Update contract file and regenerate workspace model.","Verify contract gate and integration tests for consumers."]}];function X(e){return `npx workspai ${e}`.trim()}function gt(e){let t=[`# ${e.template.title}`,"",`> Workspace: **${e.workspaceName}** \xB7 Skill: \`${e.template.skillId}\``,"","## Objective","",e.template.objective,"","## Triggers","",...e.template.triggers.map(r=>`- ${r}`),"","## Required evidence (read first)","",...Ve.map(r=>`- \`${r}\``),"","## Procedure","",...e.template.steps.map((r,n)=>`${n+1}. ${r}`),""];if(e.scopedProjects.length>0&&t.push("## Scoped projects","",...e.scopedProjects.map(r=>`- ${r}`),""),e.contractSummary&&t.push("## Contract context","",e.contractSummary,""),e.verificationCommands.length>0){t.push("## Verification commands (this workspace)","");for(let r of e.verificationCommands)t.push(`- \`${r}\``);t.push("");}return t.push("## Answer contract","","Return: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh stale evidence","","```bash",X("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
2
+ `)}function mt(e){return e?.safeCommands?.length?e.safeCommands.slice(0,8).map(t=>t.display):[X("workspace verify --json"),X("doctor workspace --json")]}function kt(e){return e?.projects?.length?e.projects.slice(0,12).map(r=>{let n=r.contracts?.owns?.join(", ")||"none",l=r.contracts?.publishes?.join(", ")||"none",p=r.contracts?.consumes?.join(", ")||"none";return `- **${r.slug}**: owns \`${n}\`; publishes \`${l}\`; consumes \`${p}\``}).join(`
3
+ `):void 0}function Ue(e){let t=e.model.workspace.name,r=e.model.projects.map(p=>p.name).sort(),n=mt(e.context??null),l=kt(e.contract??null);return ut.map(p=>{let u=gt({template:p,workspaceName:t,scopedProjects:r,verificationCommands:n,contractSummary:l});return Ke({skillId:p.skillId,title:p.title,triggers:p.triggers,requiredReports:[...Ve],scopedProjects:r,verificationCommands:n,promptStem:I[p.skillId],markdown:u})})}async function ze(e){let t=s.resolve(e.workspacePath),r=[],n=b$4({skills:e.skills.map(p=>({id:p.skillId,path:p.canonicalPath,hash:b$4({markdown:p.markdown})}))}),l=qe({generatedAt:e.generatedAt,skills:e.skills,inputsHash:n});if(e.write){for(let u of e.skills){let i=s.join(t,u.canonicalPath);await f$3.ensureDir(s.dirname(i)),await f$3.writeFile(i,u.markdown,"utf8"),r.push(u.canonicalPath);}let p=s.join(t,b$1);await f$3.ensureDir(s.dirname(p)),await f$3.writeJson(p,l,{spaces:2}),r.push(b$1);}return {skills:e.skills,index:l,writtenPaths:r}}function Fe(e){return ["## Operational skills (canonical)","","Read workspace-native playbooks from `.workspai/skills/` before generic repo scans. Legacy `.rapidkit/skills/` playbooks are read only when already present from older workspaces:","",...e.skills.map(r=>`- \`${r.path}\` \u2014 ${r.title} (\`${r.skillId}\`)`),"","Regenerate:","","```bash",X("workspace agent-sync --write --refresh-context"),"```",""].join(`
4
+ `)}var ft={"workspai-diagnose-api-failure":p,"workspai-release-readiness":t},xe="## Workspace verification (hydrated)";function ht(e){let t=[xe,"","Verification commands for this workspace:","",...e.verificationCommands.length?e.verificationCommands.map(r=>`- \`${r}\``):["- `npx workspai workspace verify --json`"]];return e.scopedProjects.length>0&&t.push("","Scoped projects:","",...e.scopedProjects.map(r=>`- ${r}`)),t.push(""),t.join(`
5
+ `)}async function Be(e){let t=s.resolve(e.workspacePath),r=[];for(let n of e.skills){let l=ft[n.skillId];if(!l)continue;let p=s.join(t,l);if(!await f$3.pathExists(p))continue;let u=await f$3.readFile(p,"utf8"),i=ht(n),b=u.includes(xe)?u.replace(new RegExp(`${xe}[\\s\\S]*$`),i.trimEnd()):`${u.trimEnd()}
6
+
7
+ ${i}`;e.write&&await f$3.writeFile(p,`${b.trimEnd()}
8
+ `,"utf8"),r.push(l);}return r}var At="workspai-agent-customization-pack-capabilities.v1";function Ye(){return {schemaVersion:At,presets:{minimal:{meaning:"Generate the portable grounding index, AGENTS.md, and provider-specific lightweight instructions.",requiredOutputs:[a.agentIndex,a.agentCustomizationPack,a.agents]},enterprise:{meaning:"Generate the full VS Code-native pack: instructions, prompts, skills, custom agents, and validation metadata.",requiredOutputs:[a.agentIndex,a.agentCustomizationPack,a.agents,l,p,B,".github/agents/workspai-advisor.agent.md",D,b$1]}},targets:{all:{meaning:"Generate every supported customization surface.",outputFamilies:["portable","vscode","copilot","cursor","claude"]},vscode:{meaning:"Generate VS Code-native customizations for Copilot Chat and agent workflows.",outputFamilies:["instructions","prompts","skills","agents","hooks"]},agents:{meaning:"Generate portable AGENTS.md grounding for any agent.",outputFamilies:["portable"]},copilot:{meaning:"Generate GitHub Copilot instructions, prompts, and skills.",outputFamilies:["instructions","prompts","skills"]},cursor:{meaning:"Generate Cursor rules.",outputFamilies:["rules"]},claude:{meaning:"Generate Claude Code grounding files.",outputFamilies:["rules","portable"]},codex:{meaning:"Use AGENTS.md and the report index as the Codex grounding layer.",outputFamilies:["portable"]},orca:{meaning:"Use AGENTS.md and the report index as the Orca/Grok grounding layer.",outputFamilies:["portable"]}},standardAnswerContract:[...J],requiredReports:$.map(e=>({path:e.relativePath,label:e.label,required:e.required})),strictRules:["Required reports must exist.","Generated report paths must stay inside the workspace root.","Generated customization text must be English-only.","Agent answers must not claim pass, ready, or healthy without cited evidence.","Commands must distinguish display guidance from execution requests.","Agent hook files must be advisory and disabled by default unless the user explicitly enables them.","MCP design artifacts must stay read-mostly until write tools have explicit approval boundaries."],outputKinds:["report","grounding","instruction","prompt","skill","skill-resource","operational-skill","skills-index","explain-report","agent","rule","hook","mcp-design"],pathLayers:{l1CanonicalRoots:[".workspai/reports/",`${a$2}/`],l2PrefixedMirrorRoots:[".github/",".cursor/",".claude/"],l3SharedIndustryFiles:["AGENTS.md",".github/copilot-instructions.md","CLAUDE.md"]}}}var wt=b.agentIndex,Pt=b.agentCustomizationPack,te=a.agentIndex,Z=a.agentCustomizationPack;var $=[{relativePath:d$1,label:"Agent context pack",required:true},{relativePath:b$1,label:"Operational skills index",required:true},{relativePath:a.model,label:"Workspace model graph",required:false},{relativePath:a.doctor,label:"Workspace doctor",required:false},{relativePath:".workspai/reports/doctor-project-last-run.json",label:"Project doctor",required:false},{relativePath:".workspai/reports/doctor-remediation-plan-last-run.json",label:"Doctor remediation plan",required:false},{relativePath:".workspai/reports/artifact-remediation-plan-last-run.json",label:"Artifact remediation plan",required:false},{relativePath:".workspai/reports/doctor-fix-result-last-run.json",label:"Doctor fix result",required:false},{relativePath:a.analyze,label:"Workspace analyze",required:false},{relativePath:".workspai/reports/pipeline-last-run.json",label:"Governance pipeline",required:false},{relativePath:a.readiness,label:"Release readiness",required:false},{relativePath:a.impact,label:"Workspace impact",required:false},{relativePath:a.verify,label:"Workspace verify",required:false},{relativePath:a.snapshot,label:"Workspace model snapshot",required:false},{relativePath:a.diff,label:"Workspace model diff",required:false},{relativePath:a.explain,label:"Workspace explain",required:false},{relativePath:a.contractVerify,label:"Workspace contract verify",required:false},{relativePath:a.history,label:"Workspace intelligence history",required:false}];function Rt(){let e=$.map(n=>n.relativePath),r=b$2().consumers.agents.canonicalReadOrder.filter(n=>n!==te&&e.includes(n));return [...new Set([...r,...e])]}function A(e){return `npx workspai ${e}`.trim()}function it(e){return e&&typeof e=="object"?e:null}function Ie(e,t=12){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0).slice(0,t):[]}function St(e){let t=Ie(e.blockers,12);if(t.length>0)return t;let r=Ie(e.blockingReasons,12);if(r.length>0)return r;let n=it(e.summary);return n&&Array.isArray(n.blockingReasons)?Ie(n.blockingReasons,12):[]}function Ct(e){for(let t of ["generatedAt","timestamp"]){let r=e[t];if(typeof r=="string"&&r.trim())return r.trim()}}function xt(e,t,r){if(!e)return true;let n=Date.parse(e);return Number.isFinite(n)?r.getTime()-n>t*60*60*1e3:true}function It(e){let t=e&&e.length>0?e:["all"];return t.includes("all")?new Set(["all","vscode","agents","copilot","cursor","claude","codex","orca"]):new Set(t)}function P(e,t){return e.has("all")||e.has(t)}function yt(e){return P(e,"copilot")||P(e,"vscode")}function Ot(e){return e??"enterprise"}function Et(e){return e===b$1?"skills-index":e.includes("workspace-explain-last-run.json")?"explain-report":(e.startsWith(`${a$2}/`)||e.startsWith(".rapidkit/skills/"))&&e.endsWith(".md")?"operational-skill":e.includes("hooks")||e===F||e===G?"hook":e.includes("mcp")||e===D||e===E?"mcp-design":e.endsWith(".json")?"report":e.includes("/instructions/")||e.endsWith("copilot-instructions.md")?"instruction":e.includes("/prompts/")?"prompt":e.includes("/skills/")&&e.endsWith("/SKILL.md")?"skill":e.includes("/skills/")?"skill-resource":e.includes("/agents/")?"agent":e.includes("/rules/")||e.endsWith(".mdc")?"rule":"grounding"}function _t(e){return e.startsWith(".github/")?["vscode","copilot"]:e.startsWith(".cursor/")?["cursor"]:e.startsWith(".claude/")||e==="CLAUDE.md"?["claude"]:e==="AGENTS.md"||e.startsWith(".rapidkit/")?["agents","codex","orca","vscode"]:e.startsWith(".vscode/")?["vscode"]:["agents"]}function bt(e,t){return Ye().presets[t].requiredOutputs.includes(e)}async function Tt(e,t){if(t)return t;let r=await f(e,k$1)??s.join(e,k$1);if(await f$3.pathExists(r))try{let n=await f$3.readJson(r);return b$3(k$1,n,r),n}catch{}return n({workspacePath:e,includeEvidence:true})}function vt(e){return e.length>0&&!s.isAbsolute(e)&&!e.split(/[\\/]+/).includes("..")}function Wt(e){return Object.fromEntries(["all","vscode","agents","copilot","cursor","claude","codex","orca"].map(r=>[r,{enabled:e.targets.includes("all")||e.targets.includes(r),outputs:e.outputs.filter(n=>n.targets.includes(r)).map(n=>n.path).sort()}]))}async function jt(e,t){try{if(!await f$3.pathExists(e))return {payload:null,exists:false,validity:"missing"};let r=await f$3.readJson(e),n=it(r);return n?a$1(t)?(b$3(t,n,e),{payload:n,exists:true,validity:"valid"}):{payload:n,exists:true,validity:"uncontracted"}:{payload:null,exists:true,validity:"invalid",validationError:"Artifact root must be a JSON object"}}catch(r){return {payload:null,exists:true,validity:"invalid",validationError:r instanceof Error?r.message:String(r)}}}async function Je(e){let t=e.now??new Date,r=e.staleAfterHours??24,n=[],l=[];for(let i of $){let b=await f(e.workspacePath,i.relativePath)??s.join(e.workspacePath,i.relativePath),R=await jt(b,i.relativePath),k=R.payload;R.validity==="invalid"?l.push(`Invalid evidence contract: ${i.relativePath}`):k&&l.push(...St(k)),n.push({path:i.relativePath,label:i.label,required:i.required,exists:R.exists,validity:R.validity,validationError:R.validationError,generatedAt:k?Ct(k):void 0,commandId:typeof k?.commandId=="string"?k.commandId:void 0,exitCode:typeof k?.exitCode=="number"?k.exitCode:void 0});}let p=[...new Set(l.map(i=>i.trim()).filter(Boolean))].slice(0,16),u=b$2();return {schemaVersion:wt,generatedAt:t.toISOString(),workspaceRoot:e.workspacePath,intelligenceChain:{schemaVersion:u.schemaVersion,contractPath:u.contractPath,currentStep:"agent-sync"},readOrder:Rt(),blockers:p,staleAfterHours:r,reports:n,refreshCommand:A("workspace agent-sync --write --refresh-context")}}function Xe(e){let t=["# Workspai agent grounding","","Cross-tool instructions for Copilot, Cursor, Claude Code, Codex, Grok, and other agents.","","## Read order (mandatory before workspace diagnosis)","",`1. \`${a.agentIndex}\` \u2014 latest blockers, timestamps, and report paths`,`2. \`${a.agentContext}\` \u2014 canonical agent context pack`,"3. Evidence artifacts listed in the index (doctor, analyze, pipeline, readiness, impact, verify)","","Do **not** full-repo scan until these reports are read or regenerated.","","## Regenerate intelligence","","```bash",A("workspace agent-sync --write --refresh-context"),A("workspace context --for-agent --json --write"),A("pipeline --json --write"),"```",""];if(e.index.blockers.length>0){t.push("## Current blockers","");for(let r of e.index.blockers.slice(0,12))t.push(`- ${r}`);t.push("");}if(e.context?.safeCommands?.length){t.push("## Safe commands (prefer these)","");for(let r of e.context.safeCommands.slice(0,10))t.push(`- \`${r.display}\` \u2014 ${r.description}`);t.push("");}return t.push("## Rules","","- Treat `.workspai/reports/*` as the source of truth for health, gates, and release posture.","- Prefer deterministic Workspai CLI commands over heuristic framework guesses.","- If evidence is missing or stale, run the refresh commands above before proposing fixes.","- Keep project-scoped advice aligned with the active project named in the context pack.",""),t.join(`
9
+ `)}function Nt(e){return ["# Workspai agent grounding","",`Generated: ${e.generatedAt}`,"",`This file is tool-agnostic. Synced agents should read it together with \`${a.agentIndex}\`.`,"","## Mandatory read order","",...e.readOrder.map((t,r)=>`${r+1}. \`${t}\``),"",e.blockers.length>0?"## Blockers":"",...e.blockers.length>0?e.blockers.map(t=>`- ${t}`):[],"","## Refresh","","```bash",e.refreshCommand,"```",""].filter(t=>t!=="").join(`
10
+ `)}function Lt(){return ["# Workspai workspace grounding","","Before answering workspace, release, or architecture questions:","","1. Read `AGENTS.md` (managed Workspai section).",`2. Read \`${a.agentIndex}\` and \`${a.agentContext}\`.`,"3. Use evidence reports before scanning the full repository.","","Regenerate stale intelligence:","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
11
+ `)}function Gt(){return ["## Claude Code","",`- Load \`${a.agentIndex}\` before diagnosing blockers.`,"- Use `.claude/rules/workspai-evidence.md` for scoped Workspai evidence rules.","- Treat `.claude/rules/rapidkit-evidence.md` as a legacy compatibility mirror.","- Refresh grounding with `npx workspai workspace agent-sync --write`.",""].join(`
12
+ `)}function Ze(){return ["---","description: Workspai workspace evidence and intelligence grounding","globs: []","alwaysApply: true","---","","Before proposing fixes in this workspace:","",`1. Read \`${a.agents}\` and \`${a.agentIndex}\`.`,`2. Read \`${a.agentContext}\`.`,"3. Prefer evidence in `.workspai/reports/*` over full-repo exploration.","","Refresh when stale:","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
13
+ `)}function Qe(){return ["---",'applyTo: ".workspai/**,**/.workspai/**,.rapidkit/**,**/.rapidkit/**"',"description: Workspai evidence and intelligence artifacts","---","","When working under `.workspai/` or legacy `.rapidkit/`:","","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.",`- Start from \`${a.agentIndex}\` for read order and blockers.`,"- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.",""].join(`
14
+ `)}function et(){return ["---",'applyTo: "**"',"description: Workspai workspace scope, evidence, and command discipline","---","","# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Scope rules","",`- Start from \`${a.agentIndex}\` and \`${a.agentContext}\`.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","- Do not translate unsupported stack requests into unrelated native kits.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
15
+ `)}function tt(){return ["# Workspai evidence","","Applies when reading or editing `.workspai/reports/*`.","","- Start from `INDEX.json`, then `workspace-context-agent.json`.","- Use report blockers as the primary fix target.","- Regenerate with `npx workspai workspace agent-sync --write`.",""].join(`
16
+ `)}function rt(){return ["---","description: Diagnose Workspai workspace blockers from evidence reports","---","","Diagnose this workspace using Workspai evidence only.","","Read:","",`- \`${a.agentIndex}\``,`- \`${a.agentContext}\``,"- Any fail/warn reports referenced in the index","","Return:","","1. Root cause grounded in report blockers","2. Smallest safe fix path (commands + file edits)","3. One verification command to prove recovery",""].join(`
17
+ `)}function Q(e){return ["---",`description: ${e.description}`,"---","",e.objective,"","Read first:","",`- \`${a.agentIndex}\``,`- \`${a.agentContext}\``,"- Any report referenced by the current blocker or task","","Return:","",...e.expectedOutput.map((t,r)=>`${r+1}. ${t}`),"","Use the standard Workspai answer contract: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
18
+ `)}function _(e){return ["# "+e.title,"",...e.lines,""].join(`
19
+ `)}function Dt(){return _({title:"MCP Tool Design",lines:["Workspai MCP is a future read-mostly bridge. Use the CLI reports today; do not assume a running MCP server exists.","","Candidate read tools:",`- \`getWorkspaceModel\` \u2014 read \`${a.model}\`.`,`- \`getEvidenceIndex\` \u2014 read \`${a.agentIndex}\`.`,"- `getBlockers` \u2014 derive current blockers from INDEX and gate reports.","- `getSafeCommands` \u2014 read safe commands from `workspace-context-agent.json`.","- `getProjectContext` \u2014 return one project-scoped slice of the workspace model.","- `getArtifact` \u2014 read one explicit artifact path inside the workspace root.",`- \`listOperationalSkills\` \u2014 read \`${a.skillsIndex}\`.`,"- `getWorkspaceExplain` \u2014 read/build workspace explain for release-blocked or project scope.","- `refreshWorkspaceIntelligence` \u2014 explicit user-approved refresh command only.","","Write or repair tools require explicit approval boundaries and are intentionally not part of the first read-mostly design."]})}function $t(e){return `${JSON.stringify({schemaVersion:"workspai-mcp-design.v1",generatedAt:e.generatedAt,workspaceRoot:e.workspacePath,status:"design-only",mode:"read-mostly",safety:{writeToolsEnabled:false,approvalRequiredForRefresh:true,artifactReadsMustStayInsideWorkspace:true},candidateTools:[{name:"getWorkspaceModel",reads:[a.model],mutates:false},{name:"getEvidenceIndex",reads:[a.agentIndex],mutates:false},{name:"getBlockers",reads:[a.agentIndex,a.verify,".workspai/reports/pipeline-last-run.json"],mutates:false},{name:"getSafeCommands",reads:[a.agentContext],mutates:false},{name:"getProjectContext",reads:[a.model,a.agentContext],mutates:false},{name:"getArtifact",reads:["requested workspace-relative artifact path"],mutates:false},{name:"listOperationalSkills",reads:[a.skillsIndex],mutates:false},{name:"getWorkspaceExplain",reads:[a.explain,a.verify,a.impact],mutates:false},{name:"refreshWorkspaceIntelligence",command:A("workspace agent-sync --write --refresh-context"),mutates:true,approvalRequired:true}]},null,2)}
20
+ `}function Ht(e){return `${JSON.stringify({schemaVersion:"workspai-agent-hooks.v1",generatedAt:e.generatedAt,workspaceRoot:e.workspacePath,enabledByDefault:false,mode:"advisory",hooks:[{name:"workspai-pre-tool-use-workspace-boundary",event:"PreToolUse",purpose:"Block or warn on state-changing commands outside the active workspace root.",defaultAction:"warn",rules:["Allow read-only commands.","Warn before write/delete commands outside workspaceRoot.","Never run destructive commands without explicit user approval."]},{name:"workspai-post-tool-use-verify-suggestion",event:"PostToolUse",purpose:"Suggest non-destructive verification commands after edits.",defaultAction:"suggest",commands:[A("doctor workspace"),A("workspace verify --strict --json")]},{name:"workspai-user-prompt-submit-scope-hint",event:"UserPromptSubmit",purpose:"Inject lightweight workspace scope and evidence index hints.",defaultAction:"inject-context-hint",reads:[a.agentIndex,a.agentContext]}]},null,2)}
21
+ `}function nt(e){let t=["---","name: workspai-workspace-intelligence","description: Use Workspai workspace intelligence reports to answer, repair, verify, and release with evidence","---","","# Workspai Workspace Intelligence","","Use this skill for workspace architecture, project lifecycle, blocker repair, release readiness, agent grounding, and CI evidence questions.","","## Decision flow","","1. Load `resources/scope-model.md`.",`2. Load \`${a.agentIndex}\`.`,`3. Load \`${a.agentContext}\`.`,`4. Load \`${a.skillsIndex}\` when operational playbooks are needed.`,"5. Load the smallest evidence report required for the task.","6. Answer with Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Rules","","- Prefer Workspai reports over full-repo scans.","- Never claim a gate passed without a cited report.","- Separate display commands from execution requests.","- Keep project-scoped fixes inside the active project unless workspace evidence says otherwise.",""];return e?.trim()&&t.push(e.trim(),""),t.join(`
22
+ `)}function ee(e){return ["---",`name: ${e.name}`,`description: ${e.description}`,`tools: [${e.tools.map(t=>`'${t}'`).join(", ")}]`,"---","",`You are the ${e.name} agent for Workspai Workspace Intelligence.`,"",`Mode: ${e.mode}.`,"",`Start every task by reading \`${a.agentIndex}\` and \`${a.agentContext}\`.`,"","Use this answer contract:","","- Scope","- Evidence","- Diagnosis","- Fix Plan","- Run","- Verify","- Assumptions","","Do not invent health, readiness, or policy status. Cite report paths and command outputs.",""].join(`
23
+ `)}function ot(){return ["---","name: workspai-grounding","description: Load Workspai workspace intelligence reports before diagnosing or changing code","---","","# Workspai grounding","","Use when the user asks about workspace health, release gates, doctor/pipeline failures, or project structure.","","## Workflow","",`1. Read \`${a.agentIndex}\``,`2. Read \`${a.agentContext}\``,"3. Read fail/warn evidence artifacts listed in the index","4. Propose the smallest safe fix with explicit verification commands","","## Refresh stale evidence","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
24
+ `)}async function d(e,t,r){return r?(await f$3.ensureDir(s.dirname(e)),await f$3.writeFile(e,t,"utf8"),"written"):"skipped"}async function ye(e){if(!e.write)return "skipped";let t=await f$3.pathExists(e.absolutePath)?await f$3.readFile(e.absolutePath,"utf8"):null,{upsertManagedAgentSection:r}=await import('./managed-agent-markers-AXUM75OE.js'),n=r(t,e.generatedBody),l=e.preamble?`${e.preamble.trimEnd()}
25
+
26
+ ${n}`:n;return await f$3.ensureDir(s.dirname(e.absolutePath)),await f$3.writeFile(e.absolutePath,l,"utf8"),"written"}function br(e){if(!e?.trim())return;let t=new Set(["all","vscode","agents","copilot","cursor","claude","codex","orca"]),r=e.split(",").map(n=>n.trim().toLowerCase()).filter(n=>t.has(n));return r.length>0?r:void 0}function Mt(e){let t=[...e.outputs].sort((n,l)=>n.path.localeCompare(l.path)),r=b$2();return {schemaVersion:Pt,generatedAt:e.generatedAt,workspaceRoot:e.workspacePath,preset:e.preset,targets:[...e.targets].sort(),sourceReports:e.index.reports.filter(n=>n.exists).map(n=>n.path).sort(),intelligenceChain:{schemaVersion:r.schemaVersion,contractPath:r.contractPath,currentStep:"agent-sync"},outputInventory:t,capabilityMatrix:Wt({targets:e.targets,outputs:t}),drift:{missingRequired:e.missingRequired,staleReports:e.staleReports,strictViolations:e.strictViolations},answerContract:["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"],refreshCommand:A(`workspace agent-sync --write --refresh-context --preset ${e.preset}`),experimental:{hooksEnabled:e.experimentalHooks,mcpReady:t.some(n=>n.kind==="mcp-design")}}}async function Tr(e$1){let t$1=s.resolve(e$1.workspacePath),r$1=new Date,n$2=e$1.staleAfterHours??24,l$1=It(e$1.targets),p$1=[...l$1].sort(),u$1=Ot(e$1.preset),i$1=e$1.write===true,b=e$1.strict===true,R,k$1=null,re;e$1.refreshContext&&(re=await n({workspacePath:t$1,includeEvidence:true}),k$1=await e({workspacePath:t$1,model:re,agent:e$1.agent??"generic",scope:e$1.scope,includeEvidence:true}),i$1&&(R=await f$1(k$1,t$1)));let S=await Je({workspacePath:t$1,staleAfterHours:n$2,now:r$1}),T=[],ne=[],oe=[],ie=[],c=(a,m)=>{a==="written"?ne.push(m):oe.push(m),ie.push({path:m,kind:Et(m),targets:_t(m),required:bt(m,u$1),status:a==="written"?"written":e$1.dryRun?"planned":"skipped"});};c(await d(s.join(t$1,te),`${JSON.stringify(S,null,2)}
27
+ `,i$1),te),c(await d(s.join(t$1,f$2),`${Nt(S)}
28
+ `,i$1),f$2);let se="",st=await Tt(t$1,re),ae=null;try{ae=(await j({workspacePath:t$1})).contract;}catch{ae=null;}let at=Ue({model:st,context:k$1,contract:ae}),ce=await ze({workspacePath:t$1,skills:at,generatedAt:r$1.toISOString(),write:i$1});for(let a of ce.skills)c(i$1?"written":"skipped",a.canonicalPath);if(c(i$1?"written":"skipped",b$1),se=Fe(ce.index),(P(l$1,"agents")||P(l$1,"vscode"))&&c(await ye({absolutePath:s.join(t$1,"AGENTS.md"),generatedBody:Xe({index:S,context:k$1}),write:i$1}),"AGENTS.md"),P(l$1,"claude")){let a=s.join(t$1,"CLAUDE.md");if(i$1){let{upsertManagedAgentSection:m}=await import('./managed-agent-markers-AXUM75OE.js'),g=await f$3.pathExists(a)?await f$3.readFile(a,"utf8"):"",h=m(g,Gt()),C=h.includes("@AGENTS.md")?h:`@AGENTS.md
29
+
30
+ ${h}`;await f$3.ensureDir(s.dirname(a)),await f$3.writeFile(a,C,"utf8"),ne.push("CLAUDE.md");}else oe.push("CLAUDE.md");c(await d(s.join(t$1,j$1),`${tt()}
31
+ `,i$1),j$1),c(await d(s.join(t$1,k),`${tt()}
32
+ `,i$1),k);}if(P(l$1,"cursor")&&(c(await d(s.join(t$1,h),Ze(),i$1),h),c(await d(s.join(t$1,i),Ze(),i$1),i)),yt(l$1)){if(c(await ye({absolutePath:s.join(t$1,".github/copilot-instructions.md"),generatedBody:Lt(),write:i$1}),".github/copilot-instructions.md"),c(await d(s.join(t$1,l),et(),i$1),l),c(await d(s.join(t$1,m),et(),i$1),m),c(await d(s.join(t$1,n$1),Qe(),i$1),n$1),c(await d(s.join(t$1,o),Qe(),i$1),o),c(await d(s.join(t$1,p),rt(),i$1),p),c(await d(s.join(t$1,q),rt(),i$1),q),u$1==="enterprise"){let a=[[r,Q({description:"Repair Workspai blockers with evidence and verification",objective:"Plan the smallest safe repair for the current Workspai blocker.",expectedOutput:["Blocker and affected workspace/project scope","Evidence paths and exact failing signals","Minimal fix plan","Human-run commands","Verification command and expected success signal"]})],[t,Q({description:"Assess Workspai release readiness from evidence",objective:"Assess whether this workspace is release-ready using Workspai gates.",expectedOutput:["Readiness verdict with cited reports","Blocking gates","Safe next command","Verification checklist"]})],[v,Q({description:"Onboard a project into Workspai Workspace Intelligence",objective:"Guide project onboarding using workspace model and create planner capabilities.",expectedOutput:["Target project scope","Native create, official generator, or existing lane","Safe commands","Post-onboarding verification"]})],[x,Q({description:"Adopt an existing project into Workspai governance",objective:"Adopt an existing project without changing its runtime behavior.",expectedOutput:["Detected stack and confidence","Adoption plan","Generated metadata expectations","Doctor and workspace model verification"]})]];for(let[g,h]of a)c(await d(s.join(t$1,g),h,i$1),g);let m=[[s$1,a[0][1]],[u,a[1][1]],[w,a[2][1]],[y,a[3][1]]];for(let[g,h]of m)c(await d(s.join(t$1,g),h,i$1),g);if(e$1.hydratePrompts===true)for(let g of await Be({workspacePath:t$1,skills:ce.skills,write:i$1}))c(i$1?"written":"skipped",g);}if(c(await d(s.join(t$1,z),ot(),i$1),z),c(await d(s.join(t$1,A$1),ot(),i$1),A$1),u$1==="enterprise"){c(await d(s.join(t$1,B),nt(se),i$1),B),c(await d(s.join(t$1,C),nt(se),i$1),C);let a=[["artifact-map.md",_({title:"Artifact Map",lines:$.map(g=>`- \`${g.relativePath}\` \u2014 ${g.label}`)})],["command-map.md",_({title:"Command Map",lines:["- `npx workspai workspace agent-sync --write --refresh-context` \u2014 refresh agent grounding.","- `npx workspai workspace model --json --write` \u2014 refresh workspace model.","- `npx workspai doctor workspace` \u2014 refresh health evidence.","- `npx workspai workspace verify --strict --json` \u2014 verify release gates."]})],["scope-model.md",_({title:"Scope Model",lines:["- Workspace scope is the default source of truth.","- Project scope is selected only when the active task targets a specific project.","- Always name the workspace and project when giving repair or lifecycle advice."]})],["runtime-support.md",_({title:"Runtime Support",lines:["- Native create is available only for Workspai-owned scaffold contracts.","- Unsupported stacks should use the official lane when a stable ecosystem generator exists.","- Existing projects should use the existing lane when native create is unavailable."]})],["create-planner-capabilities.md",_({title:"Create Planner Capabilities",lines:["- Use `contracts/create-planner-capabilities.v1.json` to decide native, official, or existing.","- Do not map PHP, WordPress, Laravel, Rails, or Symfony requests to unrelated native kits.","- Explain unsupported native create requests and guide users to adopt/import."]})],["mcp-tools.md",Dt()]];for(let[g,h]of a){let C$1=`${s.dirname(B)}/resources/${g}`;c(await d(s.join(t$1,C$1),h,i$1),C$1);let Ee=`${s.dirname(C)}/resources/${g}`;c(await d(s.join(t$1,Ee),h,i$1),Ee);}let m=[["workspai-advisor.agent.md",ee({name:"Workspai Advisor",description:"Read-only workspace and project guidance using Workspai evidence",mode:"read-only",tools:["search","read"]})],["workspai-repair.agent.md",ee({name:"Workspai Repair",description:"Turn Workspai blockers into minimal fixes and verification steps",mode:"repair",tools:["search","read","edit"]})],["workspai-release.agent.md",ee({name:"Workspai Release",description:"Assess readiness, governance gates, and release safety from evidence",mode:"release",tools:["search","read"]})],["workspai-project-onboarder.agent.md",ee({name:"Workspai Project Onboarder",description:"Guide create, import, and adopt flows with Workspai contracts",mode:"onboard",tools:["search","read","edit"]})]];for(let[g,h]of m){let C=`.github/agents/${g}`;c(await d(s.join(t$1,C),h,i$1),C);}}}if(u$1==="enterprise"){let a=$t({workspacePath:t$1,generatedAt:S.generatedAt});b$3(D,JSON.parse(a)),c(await d(s.join(t$1,D),a,i$1),D),c(await d(s.join(t$1,E),a,i$1),E);}if(u$1==="enterprise"&&e$1.experimentalHooks===true){let a=Ht({workspacePath:t$1,generatedAt:S.generatedAt});b$3(F,JSON.parse(a)),c(await d(s.join(t$1,F),a,i$1),F),c(await d(s.join(t$1,G),a,i$1),G);}(P(l$1,"codex")||P(l$1,"orca"))&&(P(l$1,"agents")||c(await ye({absolutePath:s.join(t$1,"AGENTS.md"),generatedBody:Xe({index:S,context:k$1}),write:i$1}),"AGENTS.md"));let le=i$1?await Je({workspacePath:t$1,staleAfterHours:n$2,now:r$1}):S,H=le.reports.filter(a=>a.required&&!a.exists).map(a=>a.path),M=le.reports.filter(a=>a.exists&&xt(a.generatedAt,n$2,r$1)).map(a=>a.path);if(b){H.length>0&&T.push(`Missing required reports: ${H.join(", ")}`),M.length>0&&T.push(`Stale reports (>${n$2}h): ${M.join(", ")}`);let a=ie.map(m=>m.path).filter(m=>!vt(m));a.length>0&&T.push(`Unsafe generated output paths: ${a.join(", ")}`);}let Oe=Mt({workspacePath:t$1,generatedAt:r$1.toISOString(),preset:u$1,targets:p$1,index:le,outputs:[...ie,{path:Z,kind:"report",targets:["agents","vscode","copilot","codex","orca"],required:true,status:i$1?"written":e$1.dryRun?"planned":"skipped"}],missingRequired:H,staleReports:M,strictViolations:T,experimentalHooks:e$1.experimentalHooks===true});return c(await d(s.join(t$1,Z),`${JSON.stringify(Oe,null,2)}
33
+ `,i$1),Z),{workspacePath:t$1,indexPath:s.join(t$1,te),packPath:s.join(t$1,Z),pack:Oe,contextPath:R,writtenFiles:ne,skippedFiles:oe,blockers:S.blockers,missingRequired:H,staleReports:M,strictViolations:T}}export{lt as a,pt as b,wt as c,Pt as d,te as e,Z as f,$ as g,Rt as h,Je as i,br as j,Tr as k,At as l};
@@ -0,0 +1 @@
1
+ import o from'path';import {execa}from'execa';var _=["GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_COMMON_DIR","GIT_CONFIG","GIT_CONFIG_COUNT","GIT_DIR","GIT_GRAFT_FILE","GIT_INDEX_FILE","GIT_NAMESPACE","GIT_OBJECT_DIRECTORY","GIT_PREFIX","GIT_QUARANTINE_PATH","GIT_REPLACE_REF_BASE","GIT_SHALLOW_FILE","GIT_WORK_TREE"];function I(e=process.env){let t={...e};for(let n of _)delete t[n];for(let n of Object.keys(t))(n.startsWith("GIT_CONFIG_KEY_")||n.startsWith("GIT_CONFIG_VALUE_"))&&delete t[n];return t}async function s(e){try{let t=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,env:I()});return t.stdout.trim()?o.resolve(e,t.stdout.trim()):null}catch{return null}}async function c(e){return await s(e)!==null}export{I as a,c as b};
@@ -0,0 +1,13 @@
1
+ import {a as a$1}from'./chunk-JEI6BTZI.js';import {d as d$1,b}from'./chunk-UNF72FTB.js';import {g}from'./chunk-VA5MRHKM.js';import {a}from'./chunk-J4AICQFB.js';import {c,e,d}from'./chunk-XIVFLY6G.js';import {n}from'./chunk-JICOD2GI.js';import {j as j$1,a as a$2}from'./chunk-2QN6BMM7.js';import {g as g$1,b as b$1}from'./chunk-FWJV7CCI.js';import {a as a$3}from'./chunk-LG6RFLPZ.js';import j from'path';import W from'fs-extra';function G(e$1){switch(e$1){case "why":return d;case "trace":return e;default:return c}}async function P(e,n,o){try{if(!await W.pathExists(e))return null;let r=await W.readJson(e);return n?b$1(n,r,e):o&&a$3(r,o,e),r}catch(r){if((n||o)&&await W.pathExists(e))throw r;return null}}function z(e,n){if(!e)return null;let o=n.trim().toLowerCase();return e.projects.find(r=>r.slug.toLowerCase()===o||r.relativePath.toLowerCase()===o)??null}function J(e,n,o){let r=o.trim().toLowerCase(),t=(e.graph?.nodes.map(a=>a.id)??e.projects.map(a=>a.name)).find(a=>a.toLowerCase()===r);if(t)return t;let d=e.projects.find(a=>[a.name,a.path,j.basename(a.path)].filter(u=>u.trim().length>0).some(u=>u.toLowerCase()===r));if(d)return d.name;let c=z(n,o);if(c){let a=e.projects.find(u=>u.path===c.relativePath||u.path.endsWith(`/${c.relativePath}`));if(a)return a.name}return o}function X(e,n){if(!e)return [];let o=n.trim().toLowerCase(),r=new Set;for(let l of e.projects){l.contracts.dependsOn?.some(t=>t.toLowerCase()===o)&&r.add(l.slug);for(let t of l.contracts.consumes??[])for(let d of e.projects)d.contracts.publishes?.includes(t)&&d.slug===o&&r.add(l.slug);}return [...r].sort()}function Y(e,n){if(!e)return [];let o=n.trim().toLowerCase();return e.steps.filter(r=>r.scope==="project"&&r.project?.toLowerCase()===o&&r.command?.display).map(r=>r.command.display).slice(0,8)}function p(e,n,o){return {id:e,title:n,body:o.trim()}}async function me(e){let n$1=j.resolve(e.workspacePath),o=(e.now??new Date).toISOString(),r=e.model??await n({workspacePath:n$1,includeEvidence:true}),l=e.contract;if(l===void 0)try{l=(await j$1({workspacePath:n$1})).contract;}catch{l=null;}let t=e.verify;t===void 0&&(t=await P(j.join(n$1,d$1),d$1));let d=e.impact;if(d===void 0&&(d=await P(j.join(n$1,g),g)),e.target.kind==="release-blocked"){let s=t?.blockingReasons??[],i=(r.summary?.projectCount??r.projects.length)===0,g=[p("verdict",i?"Workspace scaffold posture":"Release verdict",t?i?`Scaffold posture: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Freshness: **${t.freshness.verdict}**. No registered projects yet \u2014 release gates apply after the first project is added.`:`Verdict: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Risk: **${t.impact.risk}**. Freshness: **${t.freshness.verdict}**.`:"No workspace verify report found. Run `npx workspai workspace verify --json --write` first."),p("blockers",i?"Pre-project signals":"Blocking reasons",s.length?s.map(h=>`- ${h}`).join(`
2
+ `):i?"No pre-project signals in the latest verify report.":"No blocking reasons in the latest verify report.")];return t?.resolutionHints?.length&&g.push(p("resolution","Resolution hints",t.resolutionHints.map(h=>`- **${h.blockerId}** (${h.resolutionClass}): ${h.commandRetryHint??h.fixHints[0]?.detail??"See fix hints"}`).join(`
3
+ `))),{schemaVersion:a,generatedAt:o,workspacePath:n$1,target:e.target,summary:t?i?b(s.length,t.summary.verdict):`Release blocked: ${t.summary.verdict} with ${s.length} blocking reason(s).`:"Release posture unknown \u2014 verify report missing.",sections:g,releaseRisk:t?.impact.risk,blockingReasons:s,resolutionHints:t?.resolutionHints}}if(e.target.kind==="blocker"){let s=e.target,m=t?.resolutionHints?.find(g=>g.blockerId===s.blockerId),i=t?.blockingReasons.find(g=>g.includes(s.blockerId))??t?.blockingReasons[0];return {schemaVersion:a,generatedAt:o,workspacePath:n$1,target:s,summary:m?`Blocker ${s.blockerId}: ${m.resolutionClass}`:`Blocker ${s.blockerId} (no structured hint)`,sections:[p("reason","Blocking signal",i??"No matching blocking reason in verify."),p("hint","Resolution class",m?`${m.resolutionClass}
4
+
5
+ ${m.commandRetryHint??""}
6
+
7
+ ${m.fixHints.map(g=>`- ${g.detail}`).join(`
8
+ `)}`:"Run workspace verify to emit resolutionHints for this blocker.")],blockingReasons:i?[i]:[],resolutionHints:m?[m]:[]}}if(e.target.kind==="trace"){let s=j.isAbsolute(e.target.diffRef)?e.target.diffRef:j.join(n$1,e.target.diffRef),m=await P(s,void 0,"contracts/workspace-intelligence/workspace-model-diff.v1.json"),i=m?.summary?.changedProjects??[...new Set((m?.changes??[]).map(f=>f.project).filter(Boolean))],h=(r.summary?.projectCount??r.projects.length)===0,T=d?.transitiveImpact?.map(f=>`${f.project?.name??f.target} (d${f.distance??0}, via ${f.via??"\u2014"})`)??[],y=t?.affectedSubgraph;return {schemaVersion:a,generatedAt:o,workspacePath:n$1,target:e.target,summary:i?.length?`Trace from ${i.length} changed project(s) through blast radius to gate coverage.`:h?"Trace: workspace scaffold baseline \u2014 no project changes in the latest diff.":"Trace: diff baseline present with no project changes.",sections:[p("origin","Change origin",i?.length?i.map(f=>`- ${f}`).join(`
9
+ `):"No changed projects in diff."),p("blast-radius","Transitive impact",T.length?T.map(f=>`- ${f}`).join(`
10
+ `):"No transitive impact report."),p("gate","Subgraph gate",y?`Directly changed: ${y.directlyChanged}; transitive dependents: ${y.transitiveDependents}; covered: ${y.covered}; uncovered: ${y.uncovered}; unverifiable: ${y.unverifiable}.`:"No verify subgraph coverage available.")],releaseRisk:d?.summary?.risk??t?.impact.risk,blockingReasons:t?.blockingReasons}}let c=e.target.project,a$2=J(r,l,c),u=r.graph,k=u?a$1(u,a$2):{found:false,centrality:null,directDependents:[],transitiveDependents:[]},w=z(l,c),E=X(l,c),b$1=Y(t,c),v=r.projects.find(s=>s.name.toLowerCase()===c.toLowerCase()),x=[p("overview","Project overview",v?`${v.name} (${v.frameworkDisplayName}, ${v.runtime}) at \`${v.path}\`.`:`Project **${c}** ${k.found?"exists in graph":"not found in workspace model"}.`),p("consumers","Consumers / dependents",[`Direct dependents: ${k.directDependents.join(", ")||"none"}`,`Contract consumers: ${E.join(", ")||"none"}`,`Transitive dependents (blast radius): ${k.transitiveDependents.length}`].join(`
11
+ `)),p("contracts","Critical contracts",w?[`Owns: ${w.contracts?.owns?.join(", ")||"none"}`,`Publishes: ${w.contracts.publishes.join(", ")||"none"}`,`Consumes: ${w.contracts.consumes.join(", ")||"none"}`,`APIs: ${w.contracts.apis.map(s=>s.name).join(", ")||"none"}`].join(`
12
+ `):"No workspace.contract.json entry for this project."),p("verification","Required verification",b$1.length?b$1.map(s=>`- ${s}`).join(`
13
+ `):"- `npx workspai workspace verify --json`\n- Project test/build via `workspace run` when configured")];k.centrality&&x.push(p("centrality","Graph centrality",`fanIn ${k.centrality.fanIn}, fanOut ${k.centrality.fanOut}, reach ${k.centrality.reach}, hotspot ${k.centrality.isHotspot?"yes":"no"}.`));let I=c.trim().toLowerCase(),A=s=>s.project?.name?.toLowerCase()===I||s.target.toLowerCase()===I,S=d?.affectedProjects?.find(A)?.risk??d?.transitiveImpact?.find(A)?.risk??t?.impact.risk??"unknown";return {schemaVersion:a,generatedAt:o,workspacePath:n$1,target:e.target,summary:`${c}: ${E.length} consumer(s), release risk **${S}**.`,sections:x,releaseRisk:String(S)}}async function fe(e,n,o="explain"){let r=G(o);return await g$1(n,r,a$2(e)),r}export{G as a,me as b,fe as c};
@@ -0,0 +1 @@
1
+ import {c as c$1}from'./chunk-B66A4TVP.js';import {a as a$2,b as b$2}from'./chunk-PYCJWW4B.js';import {b as b$1,c,d}from'./chunk-7IHLTPZ6.js';import {j,a as a$1,o,g as g$1,d as d$1,p,f as f$1}from'./chunk-VA5MRHKM.js';import {n,b as b$3}from'./chunk-JICOD2GI.js';import {a as a$3}from'./chunk-2QN6BMM7.js';import {f,g}from'./chunk-FWJV7CCI.js';import {a as a$4}from'./chunk-LG6RFLPZ.js';import {b,a}from'./chunk-5AKYMAIL.js';import m from'path';import v from'fs-extra';var re="rapidkit-blocker-resolution-v1";function ie(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return b$3({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function me(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 ge(e){let t=me(e.reason),r=ie({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:re,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 ne(e){return Array.from(new Set(e.blockingReasons.map(r=>r.trim()).filter(Boolean))).slice(0,12).map((r,s)=>ge({reason:r,blockerId:`blocker-${s+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function ke(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=>ke(t))}function oe(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 Ge(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 ce=b.verify,T=a.verify;function ye(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ae(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 n=s.transitiveImpact.reduce((a,l)=>Math.max(a,l.distance??0),0);s.summary.blastRadius.maxDistance!==n&&i.push("blastRadius.maxDistance does not match transitive impact distances");let g=s.diff.currentModel.graph?.edges.length??0;if(s.summary.blastRadius.graphEdges!==g&&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 ve(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 be(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 we(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 C(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function Re(e){let t=C(e.healthScore),r=typeof t?.errors=="number"?t.errors:0,s=typeof t?.percent=="number"?t.percent:void 0;return r>0?{status:"fail",message:`Doctor evidence reports ${r} error(s).`}:typeof s=="number"&&s<70?{status:"warn",message:`Doctor health score is ${s}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function Ce(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 We(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 xe(e){let t=C(e.summary);if(t?.blocking===true||e.blocking===true)return {status:"fail",message:"Analyze evidence reports blocking findings."};let s=typeof t?.status=="string"?t.status:void 0;return s==="warn"||s==="warning"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is present."}}function je(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 Ae(e,t){let r=await f(e,".workspai/reports/doctor-remediation-plan-last-run.json");if(!r)return false;try{let s=C(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let n=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!n||!t)return true;let g=Date.parse(n),a=Date.parse(t);return !Number.isFinite(g)||!Number.isFinite(a)?true:g>=a}catch{return false}}function Ee(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Se(e){let t=C(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 Pe(e,t,r){let s=Ee(t),i=c$1(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let n=i.stage;if(s&&n!==s)return {status:"missing",message:`Workspace run evidence is for stage "${n}", expected "${s}".`};let g=Array.isArray(i.projects)?i.projects:[],a=t.project?.toLowerCase();if(!a)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let l=g.find(d=>{let p=C(d);if(!p)return false;let c=typeof p.projectName=="string"?p.projectName.toLowerCase():"",o=["projectPath","relativePath","path"].map(f=>p[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return c===a||o.some(f=>f.endsWith(`/${a}`)||f===a)});if(l){let d=R(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(d)return {status:"fail",message:d};let p=C(l),c=typeof p?.status=="string"?p.status:"unknown";return c==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:c==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:c==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${c} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function R(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}).`}async function Ie(e,t,r,s){let i=we(e,t),n=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 g=i?await f(t,n??""):null;if(!i||!g)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:n,message:n?`Missing evidence report: ${n}`:"No evidence mapping exists for this command."};let a=C(await v.readJson(g));if(!a)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:n,message:"Evidence report is not a JSON object."};let l;if(e.id==="workspace.doctor"){let d=R(a.generatedAt,s,"Doctor evidence");d?l={status:"fail",message:d}:l=Re(a);}else if(e.id==="workspace.readiness"){let d=R(a.generatedAt,s,"Release readiness evidence");d?l={status:"fail",message:d}:l=Ce(a);}else if(e.id==="workspace.contract.verify"){let d=R(a.generatedAt,s,"Workspace contract verify evidence");d?l={status:"fail",message:d}:l=We(a);}else if(e.id==="workspace.analyze"){let d=R(a.generatedAt,s,"Analyze evidence");d?l={status:"fail",message:d}:l=xe(a);}else if(e.id==="workspace.pipeline"){let d=R(a.generatedAt,s,"Pipeline evidence");d?l={status:"fail",message:d}:l=Se(a);}else if(e.id==="workspace.doctor-fix"){let d=a.schemaVersion==="rapidkit-doctor-fix-result-v1"?a:a.fixResult,p=C(d),c=typeof p?.generatedAt=="string"?p.generatedAt:void 0,o=R(c,s,"Doctor fix result");o?l={status:"fail",message:o}:await Ae(t,c)?l={status:"skipped",message:"No current doctor remediation steps are pending."}:l=je(a);}else if(e.id.startsWith("project."))l=Pe(a,e,s);else {let d=R(a.generatedAt,s,"Evidence report");d?l={status:"fail",message:d}:l={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:l.status,required:e.required,evidencePath:n,message:l.message}}function Ve(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(c=>c.status==="pass").length,s=e.filter(c=>c.status==="warn").length,i=e.filter(c=>c.status==="fail").length,n=e.filter(c=>c.status==="missing").length,g=e.filter(c=>c.status==="skipped").length,a=e.filter(c=>c.required&&(c.status==="fail"||c.status==="missing")).map(c=>`${c.id}: ${c.message}`),l=e.filter(c=>c.required&&c.status==="missing").length,d="ready",p=0;return a.length>0||t.blockingReasons.length>0?(d="blocked",p=2):(s>0||l>0||t.needsAttention)&&(d="needs-attention",p=1),{verdict:d,exitCode:p,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:n,stepsSkipped:g}}function $e(e,t){let r=x(e.affectedProjects.map(o=>o.project?.name).filter(o=>typeof o=="string")),s=new Set(r.map(o=>o.toLowerCase())),i=x(e.transitiveImpact.map(o=>o.project?.name).filter(o=>typeof o=="string").filter(o=>!s.has(o.toLowerCase()))),n=new Map;for(let o of t){if(o.scope!=="project"||!o.project)continue;let f=o.project.toLowerCase(),h=n.get(f)??[];h.push(o),n.set(f,h);}let g=[],a=[],l=[],d=[],p=false,c=(o,f)=>{let h=n.get(o.toLowerCase())??[];if(h.length===0){l.push(o);return}let j=h.filter(k=>k.status==="fail"),b=h.filter(k=>k.status==="missing"),A=b.filter(k=>k.required),E=h.some(k=>k.status==="pass"||k.status==="warn");if(j.length>0){a.push(o),d.push(`graph.subgraph.${o}: ${f} has failed verification evidence (${j.map(k=>k.id).join(", ")}).`);return}if(A.length>0){a.push(o),d.push(`graph.subgraph.${o}: ${f} has missing required verification evidence (${A.map(k=>k.id).join(", ")}).`);return}if(b.length>0){a.push(o),p=true;return}if(E){g.push(o);return}l.push(o);};for(let o of r)c(o,"directly-changed");for(let o of i)c(o,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:x(g),uncovered:x(a),unverifiable:x(l)},blockingReasons:d,needsAttention:p}}function x(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Fe(e){let t=m.resolve(e.workspacePath);if(e.fromImpactPath){let n=ye(t,e.fromImpactPath);return {impact:await ae(n),fromImpactRef:m.relative(t,n).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g$1);if(await v.pathExists(r))return {impact:await ae(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.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 Oe(e,t){if(t)return e.generatedAt}async function lt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Fe(e),n$1=r.diff.currentModel,g=i?await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):n$1,a=[];i&&j(g)!==r.diff.toHash&&a.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let l=r.diff.git;if(i&&l?.available){let u=a$1(t,{ref:l.ref}),pe=r.diff.changes.filter(y=>y.type.startsWith("git.")).map(y=>`${y.type}:${y.target.replace(/^git:/,"")}`).sort(),fe=[...u.changedFiles.map(y=>`git.file.changed:${y}`),...u.untrackedFiles.map(y=>`git.untracked:${y}`),...u.deletedFiles.map(y=>`git.deleted:${y}`)].sort();(!u.available||u.commit!==l.commit||JSON.stringify(fe)!==JSON.stringify(pe))&&a.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let d$1=Oe(r,i),p=ve([...o(),...r.verificationPlan]).filter(u=>be(e.scope,u)),c$1=[];for(let u of p)c$1.push(await Ie(u,t,n$1.contracts.exists===true,d$1));let o$1=$e(r,c$1),f=a$2(n$1.graph??{nodes:[],edges:[]}),h=b$1(n$1),j$1=await _e(t),b=c(h,j$1?.freshness?.projectHashes),A={verdict:b.verdict,baseline:b.baseline,changed:b.changed,added:b.added,removed:b.removed,projectHashes:d(h)},E=b$2(f),k=n$1.policies?.mode??"warn",V=await Be(n$1,t),$=De(k,V),W=Ve(c$1,{blockingReasons:[...o$1.blockingReasons,...E,...$.blockingReasons,...a],needsAttention:o$1.needsAttention||$.needsAttention}),de=c$1.filter(u=>u.status==="missing"&&u.evidencePath).map(u=>u.evidencePath),S=[...c$1.filter(u=>u.required&&(u.status==="fail"||u.status==="missing")).map(u=>`${u.id}: ${u.message}`),...o$1.blockingReasons,...E,...$.blockingReasons,...a],le=V.filter(u=>u.severity==="error").length,ue=n$1.summary?.projectCount??n$1.projects.length,L=oe({projectCount:ue,verdict:W.verdict,exitCode:W.exitCode,blockingReasons:S,policyErrorCount:le});W.verdict=L.verdict,W.exitCode=L.exitCode;let K=S.length>0?ne({blockingReasons:S,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:T}):[];return {schemaVersion:ce,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:W,steps:c$1,missingEvidence:de,blockingReasons:S,...K.length>0?{resolutionHints:K}:{},verificationPlan:p,affectedSubgraph:o$1.subgraph,graphIntegrity:f,freshness:A,policyMode:k,policyViolations:V}}async function Be(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 n of i.violations)typeof n=="string"&&n.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:n});}}catch{}return r.sort((i,n)=>i.source!==n.source?i.source.localeCompare(n.source):i.code!==n.code?i.code.localeCompare(n.code):i.message.localeCompare(n.message))}function De(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 _e(e){let t=m.join(e,T);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ce?r:null}catch{return null}}async function ut(e,t){return g(t,T,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 pt(e,t){return Me(e,t).exitCode}export{re as a,Ge as b,ce as c,T as d,$e as e,lt as f,ut as g,Me as h,pt as i};
@@ -0,0 +1,2 @@
1
+ import {n,d as d$1,e}from'./chunk-JICOD2GI.js';import {a as a$1}from'./chunk-2QN6BMM7.js';import {g}from'./chunk-FWJV7CCI.js';import {b,a,f,c}from'./chunk-5AKYMAIL.js';import $ from'path';var M="workspai-workspace-intelligence-chain-v1",L="contracts/workspace-intelligence-chain.v1.json";function j(){let e=a,t=f,n=[{id:"model",ordinal:1,phase:"understand",label:"Model",command:[...t.model.command],consumes:["workspace markers","project metadata","registry","contract","policies"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules","existing-evidence"],consumesArtifacts:[],produces:[...t.model.produces],dependsOn:[],exitPolicy:"stop-on-error",purpose:"Build the canonical current model of the software system."},{id:"diff",ordinal:2,phase:"change",label:"Diff",command:[...t.diff.command],consumes:[e.model,e.snapshot],inputRefs:["changes","model-baseline"],consumesArtifacts:[e.model,e.snapshot],produces:[...t.diff.produces],dependsOn:["model"],exitPolicy:"stop-on-error",purpose:"Describe structural change against the selected baseline."},{id:"impact",ordinal:3,phase:"change",label:"Impact",command:[...t.impact.command],consumes:[e.model,e.diff],inputRefs:[],consumesArtifacts:[e.model,e.diff],produces:[...t.impact.produces],dependsOn:["diff"],exitPolicy:"stop-on-error",purpose:"Calculate transitive blast radius over the workspace graph."},{id:"doctor-evidence",ordinal:4,phase:"evidence",label:"Doctor Evidence",command:[...t["doctor-evidence"].command],consumes:["workspace runtime and project health signals"],inputRefs:["projects-repositories","runtime-dependencies","existing-evidence"],consumesArtifacts:[],produces:[...t["doctor-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh health evidence after the impact artifact exists."},{id:"contract-evidence",ordinal:5,phase:"evidence",label:"Contract Evidence",command:[...t["contract-evidence"].command],consumes:[".workspai/workspace.contract.json"],inputRefs:["workspace-rules"],consumesArtifacts:[],produces:[...t["contract-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh structural contract evidence without hiding failed verdicts."},{id:"analyze-evidence",ordinal:6,phase:"evidence",label:"Analyze Evidence",command:[...t["analyze-evidence"].command],consumes:[e.model,"workspace runtime and dependency signals"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules"],consumesArtifacts:[e.model],produces:[...t["analyze-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh analysis evidence required by the release-readiness gate."},{id:"readiness-evidence",ordinal:7,phase:"evidence",label:"Readiness Evidence",command:[...t["readiness-evidence"].command],consumes:["doctor, analysis, runtime, and release signals"],inputRefs:["runtime-dependencies","existing-evidence"],consumesArtifacts:[e.doctor,e.contractVerify,e.analyze],produces:[...t["readiness-evidence"].produces],dependsOn:["doctor-evidence","contract-evidence","analyze-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh release-readiness evidence before the definitive gate."},{id:"verify",ordinal:8,phase:"gate",label:"Verify",command:[...t.verify.command],consumes:[e.impact,e.doctor,e.contractVerify,e.readiness],inputRefs:[],consumesArtifacts:[e.impact,e.doctor,e.contractVerify,e.readiness],produces:[...t.verify.produces],dependsOn:["impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Emit the definitive evidence-backed workspace gate."},{id:"context",ordinal:9,phase:"ground",label:"Agent Context",command:[...t.context.command],consumes:[e.model,e.impact,e.verify],inputRefs:[],consumesArtifacts:[e.model,e.impact,e.verify],produces:[...t.context.produces],dependsOn:["verify"],exitPolicy:"stop-on-error",purpose:"Build compact agent context from the same verified evidence."},{id:"agent-sync",ordinal:10,phase:"distribute",label:"Agent Grounding",command:[...t["agent-sync"].command],consumerArgs:{vscode:["--target","vscode"]},consumes:[e.agentContext],inputRefs:[],consumesArtifacts:[e.agentContext],produces:[...t["agent-sync"].produces],dependsOn:["context"],exitPolicy:"stop-on-error",purpose:"Distribute one context into portable agent and IDE surfaces."},{id:"explain",ordinal:11,phase:"explain",label:"Explain",command:[...t.explain.command],consumes:[e.verify,e.impact],inputRefs:[],consumesArtifacts:[e.verify,e.impact],produces:[...t.explain.produces],dependsOn:["verify"],exitPolicy:"continue-on-structured-verdict",purpose:"Translate evidence and blockers into a human and agent-readable narrative."}];return {schemaVersion:M,name:"Workspace Intelligence Chain",contractPath:L,invariant:"Every consumer must preserve step identity, dependencies, artifact flow, and verdict semantics; presentation may change, chain meaning may not.",invariants:["Missing or unreadable input is unknown or unavailable; it must not be presented as verified absence.","Freshness and provenance travel with evidence and must not be discarded by projections.","The current graph is a workspace dependency graph, not a complete cross-language symbol or call graph.","Simple and standard presentations summarize the contract; their contractRefs must preserve complete traceability.","Conditional provider outputs must be resolved through their dedicated inventory contract.","Auxiliary capabilities expose or refresh intelligence but are not mandatory execution-chain steps.","Canonical step commands are stage-pure: they must not implicitly execute a downstream chain step or regenerate an upstream artifact.","Canonical JSON artifacts must satisfy their registered schema both when produced and when consumed across CLI, MCP, IDE, and CI trust boundaries.","Schema validity is necessary but not sufficient: hashes, embedded models, summaries, counts, graph statistics, and artifact references must remain semantically coherent.","Persisted impact evidence must be rejected as stale when the current workspace model or Git observation no longer matches its embedded diff.","Canonical artifact replacement must be atomic and workspace-contained; an interrupted or denied write must preserve the last valid artifact.","Concurrent history updates must be serialized without silently dropping entries, and invalid history must never be overwritten as if it were absent.","The canonical global registry is ~/.workspai/workspaces.json; ~/.rapidkit/workspaces.json is a non-authoritative compatibility mirror for legacy consumers and must not diverge after a CLI registry mutation."],semantics:{workspace:"The governed operating boundary that relates one or more projects and repositories to shared metadata, policies, contracts, evidence, and consumers.",repository:"A source-control boundary that may contain one or more projects and may live inside or outside the workspace root.",project:"A discoverable build or runtime unit with its own path, metadata or observable manifests, command capabilities, and evidence.",evidence:"A sourced observation or generated verification result with provenance and freshness; evidence may be consumed by a later run.",artifact:"A durable generated file that another command or consumer can read without parsing terminal prose.",gate:"A structured verdict with reasons and exit semantics derived from current evidence."},workspaceLifecycle:{ingestionRoutes:[{id:"create",label:"Create",commands:["create workspace","create project"],result:"Create a workspace or supported project and write canonical Workspai metadata."},{id:"adopt",label:"Adopt",commands:["adopt"],result:"Register an existing project in place without requiring source relocation."},{id:"import",label:"Import",commands:["import","workspace import"],result:"Attach an existing project or repository path to the workspace inventory."}],durableState:[{id:"workspace-identity",paths:[".workspai-workspace",".workspai/workspace.json"],purpose:"Identify the workspace boundary, profile, and canonical root."},{id:"project-inventory",paths:[".workspai/project.json",".workspai/context.json",".workspai/adopt.json","~/.workspai/workspaces.json","~/.rapidkit/workspaces.json (legacy compatibility mirror)"],purpose:"Record native, adopted, imported, and globally registered project locations while preserving a non-authoritative mirror for legacy extension discovery."},{id:"governance",paths:[".workspai/policies.yml",".workspai/workspace.contract.json"],purpose:"Define workspace policy and explicit structural relationships."},{id:"graph-overrides",paths:[".workspai/workspace-graph.overrides.json"],purpose:"Provide explicit dependency edges that override inferred relationships."}],rule:"Create, adopt, and import are ingestion routes, not intelligence facts. Their durable state becomes observable input to Model."},runtimeRegistry:{authority:"contracts/workspace-intelligence-runtime-registry.ts",artifacts:Object.entries(a).map(([r,a])=>({id:r,path:a,schemaVersion:b[r],schemaContract:c[r]}))},boundaries:{inputs:[{id:"projects-repositories",label:"Projects and repositories",sources:["projects","repositories","services","modules","imported paths"],entersAt:"model"},{id:"runtime-dependencies",label:"Runtime and dependencies",sources:["runtime manifests","lockfiles","scripts","framework markers","package dependencies","supported source imports (currently bounded JavaScript and TypeScript scanning)"],entersAt:"model"},{id:"workspace-rules",label:"Workspace rules",sources:["workspace markers","registry","project metadata","contracts","policies","ownership","graph overrides"],entersAt:"model"},{id:"changes",label:"Changes",sources:["repository state","git state","model baseline","workspace diff"],entersAt:"diff"},{id:"model-baseline",label:"Explicit model baseline",sources:[e.snapshot],entersAt:"diff"},{id:"existing-evidence",label:"Existing evidence",sources:["doctor reports","analysis reports","contract verification","release readiness","pipeline results","tests and runtime evidence","previous intelligence artifacts"],entersAt:"doctor-evidence"}],outputs:[{id:"understanding",label:"System understanding",artifacts:[e.model,e.diff,e.impact],producedBy:["model","diff","impact"],inventory:"complete-for-chain"},{id:"governance-evidence",label:"Governance evidence",artifacts:[e.doctor,e.contractVerify,e.analyze,e.readiness,e.verify,e.history],producedBy:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify"],inventory:"complete-for-chain"},{id:"agent-grounding",label:"Agent grounding",artifacts:[e.agentContext,e.agentIndex,e.agentCustomizationPack,e.skillsIndex,e.agents],producedBy:["context","agent-sync"],inventory:"canonical-minimum",inventoryContract:"contracts/agent-customization-pack.v1.json"},{id:"explanations",label:"Explainable decisions",artifacts:[e.explain],producedBy:["explain"],inventory:"complete-for-chain"}],consumers:[{id:"developers",label:"Developers",channels:["CLI","reports","AGENTS.md"]},{id:"ci",label:"CI",channels:["JSON artifacts","exit codes","release gates"]},{id:"ides",label:"IDEs",channels:["synced contracts","extension","agent context"]},{id:"ai-agents",label:"AI agents",channels:["INDEX.json","context","skills","MCP"]}]},deliveryChannels:[{id:"artifacts",carries:["reports","models","context","grounding","skills"],authority:"canonical"},{id:"json-stdout",carries:["structured command results"],authority:"projection"},{id:"human-cli",carries:["summaries","diagnostics","next actions"],authority:"projection"},{id:"exit-codes",carries:["gate and command status"],authority:"projection"},{id:"watch-events",carries:["incremental workspace change events"],authority:"projection"},{id:"mcp",carries:["read-mostly access to current workspace artifacts"],authority:"projection"}],feedback:{from:["developers","ci","ides","ai-agents"],signals:["source commits","dependency updates","policy and contract edits","repairs","test and runtime results","agent action outcomes"],reentersThrough:["projects-repositories","runtime-dependencies","workspace-rules","changes","existing-evidence"],rule:"Consumer actions are not silently treated as truth. They re-enter as observable changes or evidence and must be modeled and verified again."},auxiliaryCapabilities:[{id:"graph",commands:["workspace graph emit","workspace graph explain","workspace graph dot","workspace graph mermaid"],reads:[`${e.model}#graph`],role:"Inspect or render the graph already embedded in the workspace model.",chainStep:false},{id:"watch",commands:["workspace watch"],reads:["workspace inputs",e.model],role:"Refresh the model incrementally and emit deterministic change events.",chainStep:false},{id:"mcp",commands:["workspace mcp serve"],reads:["workspace evidence artifacts"],role:"Expose read-mostly workspace evidence to compatible clients.",chainStep:false}],presentations:{simple:{layers:["inputs","intelligence","outputs","consumers"],nodes:[{id:"input-layer",kind:"inputs",label:"Input Layer",summary:"Projects \xB7 Repositories \xB7 Dependencies \xB7 Changes",contractRefs:["projects-repositories","runtime-dependencies","workspace-rules","changes","model-baseline","existing-evidence"]},{id:"workspace-intelligence",kind:"intelligence",label:"Workspace Intelligence",summary:"Model \xB7 Graph \xB7 Impact \xB7 Verify",contractRefs:n.map(r=>r.id)},{id:"agent-grounding",kind:"outputs",label:"Agent Grounding",summary:"AGENTS.md \xB7 Skills \xB7 Context",contractRefs:["agent-grounding"]},{id:"evidence-and-decisions",kind:"outputs",label:"Evidence Contracts",summary:"Reports \xB7 Artifacts \xB7 Gates",contractRefs:["understanding","governance-evidence","explanations"]},{id:"shared-consumers",kind:"consumers",label:"Shared Consumers",summary:"Developers \xB7 CI \xB7 IDEs \xB7 AI agents",contractRefs:["developers","ci","ides","ai-agents"]}],rule:"Use concrete user-facing language for first-contact explanations. Every input, output, consumer, and chain step must remain traceable through contractRefs even when details are summarized."},standard:{phases:["understand","change","evidence","gate","ground","distribute","explain"],nodes:[{id:"understand",label:"Understand",question:"What exists in the current workspace?",stepRefs:["model"]},{id:"change",label:"Change",question:"What changed, and what can it affect?",stepRefs:["diff","impact"]},{id:"evidence",label:"Evidence",question:"What health, contract, and readiness facts were observed?",stepRefs:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"]},{id:"gate",label:"Gate",question:"Is the current state acceptable and trustworthy?",stepRefs:["verify"]},{id:"ground",label:"Ground",question:"What should an agent know before acting?",stepRefs:["context"]},{id:"distribute",label:"Distribute",question:"Which durable agent and IDE surfaces receive that context?",stepRefs:["agent-sync"]},{id:"explain",label:"Explain",question:"Why did the system reach this result or verdict?",stepRefs:["explain"]}],rule:"Use for architecture education and product surfaces. Every phase must appear once and in order."},advanced:{steps:n.map(r=>r.id),requiredFields:["command","inputRefs","consumesArtifacts","produces","dependsOn","exitPolicy","purpose"],rule:"Use for implementers, adapters, IDEs, and CI. Preserve every step and its artifact and verdict semantics."}},steps:n,diagram:{direction:"TB",nodes:n.map(({id:r,label:a,phase:o})=>({id:r,label:a,phase:o})),edges:n.flatMap(r=>r.dependsOn.map(a=>({from:a,to:r.id,meaning:"required before"})))},consumers:{agents:{canonicalReadOrder:[e.agentIndex,e.agentContext,e.verify,e.impact,e.explain,e.model,e.agentCustomizationPack,e.skillsIndex],entrypoints:[e.agents,".workspai/AGENT-GROUNDING.md"],rule:"Agents must cite current artifacts, preserve verified versus inferred status, and re-run the producing step when evidence is missing or stale."},ideAndCi:{requiredArtifacts:[e.model,e.impact,e.verify],rule:"IDEs and CI must consume structured artifacts and verdict exit semantics rather than parse human help or terminal prose."},docsAndDiagrams:{rule:"Documentation and diagrams must derive labels, ordering, and edges from this contract and must not invent implemented steps."}}}}var F=b.agentContext,D=a.agentContext;function G(e){if(typeof e!="string"||!e.trim()||e==="true")return "generic";let t=e.trim().toLowerCase();return t==="codex"||t==="claude"||t==="cursor"||t==="orca"?t:"generic"}function R(e){return `npx --yes --package workspai workspai ${e}`.trim()}function S(e){return `npx workspai ${e}`.trim()}function d(e){return {id:e.id,scope:e.scope,display:S(e.args),execute:R(e.args),description:e.description,...e.project?{project:e.project}:{},freshness:d$1({id:`command.${e.id}`,label:`${e.id} command`,scope:"command",value:{display:S(e.args),execute:R(e.args)},...e.project?{project:e.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:e.generatedAt,now:e.now,sourceArtifact:a.model,sourcePath:`safeCommands.${e.id}`,reason:"Safe command surfaces are derived from workspace model command capabilities."}}).freshness}}function I(e,t){return `workspace run ${t} --scope project:${e.name}`}function V(e){return (e.startsWith("project:")?e.slice(8):e).trim().toLowerCase()}function z(e){return [e.name,e.path,$.basename(e.path),e.absolutePath].filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim().toLowerCase())}function q(e,t,n){let r={generatedAt:e.generatedAt,now:n},a=[d({id:"workspace.model",scope:"workspace",args:"workspace model --json",description:"Read the canonical workspace intelligence model.",...r}),d({id:"workspace.doctor",scope:"workspace",args:"doctor workspace --json",description:"Check workspace health before claiming verification.",...r}),d({id:"workspace.pipeline",scope:"workspace",args:"pipeline --json",description:"Run the governed sync, doctor, analyze, readiness, and autopilot loop.",...r}),d({id:"workspace.contract.verify",scope:"workspace",args:"workspace contract verify --json",description:"Verify workspace contract and dependency edges.",...r}),d({id:"workspace.verify",scope:"workspace",args:"workspace verify --json",description:"Evaluate evidence freshness and verification gates before release decisions.",...r})],o=t?[t]:e.projects;for(let i of o)i.commands.fleetStages.includes("test")&&a.push(d({id:`project.${i.name}.test`,scope:"project",project:i.name,args:I(i,"test"),description:`Run tests for ${i.name} through workspace orchestration.`,...r})),i.commands.fleetStages.includes("build")&&a.push(d({id:`project.${i.name}.build`,scope:"project",project:i.name,args:I(i,"build"),description:`Build ${i.name} through workspace orchestration.`,...r}));return a}function H(e){return e.commands.fleetStages.filter(t=>t==="test"||t==="build").map(t=>`workspace run ${t}`)}function K(e,t){if(!t?.startsWith("project:"))return;let n=V(t);if(n)return e.projects.find(r=>z(r).includes(n))}function B(e,t,n){let r=[...e.validation?.issues??[]];t?.startsWith("project:")&&!n&&r.push({severity:"error",code:"context.scope.project.missing",message:`Requested project scope was not found: ${t}`,target:t});let a=r.filter(i=>i.severity==="error").length,o=r.filter(i=>i.severity==="warning").length;return {status:a>0?"failed":o>0?"warning":"passed",errors:a,warnings:o,issues:r}}function U(e){let t=[],n=[];for(let[r,a]of Object.entries(e.evidence))a?.exists?t.push(`${r}: ${a.path}`):n.push(r);return {available:t.sort(),missing:n.sort()}}function J(e){let t=e.summary.projectCount,n=e.summary.runtimes.length?`${e.summary.runtimes.join(", ")} runtime coverage`:"no runtime coverage",r=e.identity.surfaces.length?e.identity.surfaces.join(", "):"no detected surfaces";return `${e.workspace.name} is a ${e.identity.workspaceType} with ${t} project${t===1?"":"s"}, ${n}, and ${r}.`}function X(e){let t=["Do not claim a command passed unless a report or command output proves it.","Do not infer secrets or environment values from file names.","Do not change project scope without checking the selected project."];return e.contracts.exists||t.push("Workspace contract is missing; dependency and API edges may be incomplete."),e.summary.observedProjects>0&&t.push("Some projects are observed rather than first-class; command support may be partial."),t}async function ce(e$1){let t=e$1.model??await n({workspacePath:e$1.workspacePath,includeEvidence:e$1.includeEvidence===true,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),n$1=G(e$1.agent),r=K(t,e$1.scope),a$1=B(t,e$1.scope,r);if(e$1.strict===true&&a$1.status!=="passed"){let s=a$1.issues.map(p=>`${p.severity}:${p.code}:${p.target}`).join(", ");throw new Error(`Workspace context strict validation failed: ${s}`)}let o=e$1.now??new Date,i=t.facts??[],W=new Set((r?[r]:t.projects).map(s=>s.name)),h=i.filter(s=>s.project?W.has(s.project):true),P=(r?[r]:t.projects).map(s=>{let p=h.filter(O=>O.project===s.name);return {name:s.name,path:s.path,kind:s.kind,runtime:s.runtime,framework:s.frameworkDisplayName,...s.generator?{generator:s.generator}:{},createCapability:s.createCapability,supportTier:s.supportTier,safeCommands:H(s),importantFiles:s.importantFiles,facts:p}}),m=U(t),y=J(t),v=q(t,r,o),T=v.map(s=>d$1({id:`context.command.${s.id}`,label:`${s.id} safe command`,scope:"command",value:{display:s.display,execute:s.execute,scope:s.scope},...s.project?{project:s.project}:{},freshness:{kind:"derived",category:"structure",generatedAt:t.generatedAt,now:o,sourceArtifact:a.agentContext,sourcePath:`safeCommands.${s.id}`,reason:"Context safe commands are derived from workspace model command capabilities."}})),k=[...h,...T],u=e({facts:k,generatedAt:o.toISOString(),now:o}),g=j();return {schemaVersion:F,generatedAt:o.toISOString(),agent:n$1,workspaceSummary:y,modelRef:a.model,intelligenceChain:{schemaVersion:g.schemaVersion,contractPath:g.contractPath,currentStep:"context",canonicalReadOrder:[...g.consumers.agents.canonicalReadOrder]},workspace:{name:t.workspace.name,root:t.workspace.root,type:t.identity.workspaceType,...t.workspace.profile?{profile:t.workspace.profile}:{}},scope:{requested:e$1.scope??"workspace",...r?{activeProject:r.name}:{}},projects:P,safeCommands:v,facts:k,factFreshness:u,evidence:m,policies:{mode:t.policies.mode,source:t.policies.source},contracts:{exists:t.contracts.exists,path:t.contracts.workspaceContractPath},validation:a$1,agentInstructions:[`Read \`${a.agentIndex}\` first, then this context pack and linked evidence reports.`,"Use this context as the workspace source of truth before inspecting random files.","Prefer workspace-level evidence over generic framework assumptions.","Use `display` commands when explaining steps to a human.","Use `execute` commands when launching commands from automation or tooling.","Treat `facts[].freshness.verifyBeforeUse` as a hard refresh requirement before using that fact in advice, fixes, or release decisions.","Do not carry extracted facts beyond their freshness contract; re-read or regenerate evidence when the contract says stale, unknown, live, or verify-before-use.","Keep project-scoped advice tied to the active project scope.","Regenerate stale grounding with `npx workspai workspace agent-sync --write --refresh-context`."],unsafeAssumptions:[...X(t),...u.verifyBeforeUseFacts>0?[`${u.verifyBeforeUseFacts} fact(s) require verification before use; do not treat them as durable workspace structure.`]:[]],humanSummary:[y,`Evidence available: ${m.available.length}. Missing evidence groups: ${m.missing.join(", ")||"none"}.`,r?`Active project scope: ${r.name} (${r.frameworkDisplayName}).`:"Scope: whole workspace."].join(`
2
+ `)}}async function de(e,t){return g(t,D,a$1(e))}export{M as a,j as b,F as c,D as d,ce as e,de as f};
@@ -0,0 +1,2 @@
1
+ import {n,k,j}from'./chunk-JICOD2GI.js';import {a as a$2}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {a as a$1}from'./chunk-2QN6BMM7.js';import {g as g$1}from'./chunk-FWJV7CCI.js';import {a as a$3}from'./chunk-LG6RFLPZ.js';import {b,a}from'./chunk-5AKYMAIL.js';import ke from'crypto';import k$1 from'path';import L from'fs-extra';import {spawnSync}from'child_process';function fe(){let e={...process.env};return delete e.GIT_DIR,delete e.GIT_WORK_TREE,delete e.GIT_INDEX_FILE,delete e.GIT_PREFIX,e}function F(e,t){let o=spawnSync("git",t,{cwd:e,env:fe(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});return o.status!==0?{ok:false,stdout:""}:{ok:true,stdout:(o.stdout??"").trim()}}function ue(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return [".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(o=>t.startsWith(o))}function ge(e){let t=[],o=[],r=[];for(let l of e.split(`
2
+ `)){if(!l.trim())continue;let a=l.slice(0,2),i=l.slice(3).trim();if(i&&!ue(i)){if(a==="??"){o.push(i);continue}a.includes("D")&&r.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(o)].sort(),deletedFiles:[...new Set(r)].sort()}}function Y(e,t){let o={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=F(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return o;let l=F(e,["rev-parse","--abbrev-ref","HEAD"]),a=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"]),c=ge(i.stdout),m=c.changedFiles.length>0||c.untrackedFiles.length>0||c.deletedFiles.length>0;return {available:true,branch:l.ok?l.stdout:void 0,commit:a.ok?a.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:c.changedFiles,untrackedFiles:c.untrackedFiles,deletedFiles:c.deletedFiles}}var re=b.snapshot,K=b.diff,T=a.snapshot,oe=a.diff,he=b.impact,we=a.impact;function ne(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function ye(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function V(e){if(Array.isArray(e))return e.map(t=>V(t));if(e&&typeof e=="object"){let t={};for(let o of Object.keys(e).sort())t[o]=V(e[o]);return t}return e}function g(e){return JSON.stringify(V(e))}function I(e){let{runId:t,evidence:o,facts:r,factFreshness:l,projects:a,...i}=e,c=a.map(p=>{let{evidence:f,...h}=p;return h}),m={...i,generatedAt:"<ignored>",projects:c,graph:e.graph?{...e.graph,generatedAt:"<ignored>"}:void 0,validation:e.validation?{...e.validation,issues:e.validation.issues.map(p=>({...p})).sort((p,f)=>{let h=`${p.severity}:${p.code}:${p.target}:${p.message}`,b=`${f.severity}:${f.code}:${f.target}:${f.message}`;return h.localeCompare(b)})}:void 0};return ke.createHash("sha256").update(g(m)).digest("hex")}function Xe(e){return I(e)}function ae(e,t){return k$1.isAbsolute(t)?t:k$1.join(e,t)}async function We(e){let t=await L.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let o=t;if(o.schemaVersion===re){a$3(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=o;if(!r.model||r.model.schemaVersion!==j)throw new Error(`Invalid workspace model snapshot: ${e}`);let l=I(r.model);if(r.modelHash!==l)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:r.model,hash:r.modelHash}}if(o.schemaVersion===j){a$3(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=o;return {model:r,hash:I(r)}}throw o.schemaVersion===K?new Error(`workspace diff --from received a diff report (${k$1.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${T}. To analyze an existing diff report, run: npx workspai workspace impact --from ${k$1.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(o.schemaVersion)}`)}async function ve(e){let t=await L.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let o=t;if(o.schemaVersion!==K)return null;a$3(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=o;if(!r.currentModel||r.currentModel.schemaVersion!==j||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==I(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Ye(e){let t=e.model??await n({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:re,generatedAt:(e.now??new Date).toISOString(),modelHash:I(t),modelRef:k,model:t}}async function Qe(e,t){return g$1(t,T,a$1(e))}function x(e){return {name:e.name,path:e.path,kind:e.kind,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function w(e,t){e.push(t);}function be(e,t){let o=[],r=["name","profile","type"],l=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let a of r){let i=e.workspace[a],c=t.workspace[a];g(i)!==g(c)&&w(o,{type:"workspace.changed",severity:"info",target:`workspace.${a}`,message:`Workspace metadata field changed: ${String(a)}`,before:i,after:c});}for(let a of l){let i=e.identity[a],c=t.identity[a];g(i)!==g(c)&&w(o,{type:"workspace.changed",severity:"info",target:`identity.${a}`,message:`Workspace identity field changed: ${String(a)}`,before:i,after:c});}return g(e.policies)!==g(t.policies)&&w(o,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),g(e.evidence)!==g(t.evidence)&&w(o,{type:"workspace.changed",severity:"info",target:"evidence",message:"Workspace evidence summary changed.",before:e.evidence,after:t.evidence}),g(e.discovery)!==g(t.discovery)&&w(o,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&w(o,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),o}function je(e,t){let o=e.validation??null,r=t.validation??null;return g(o)===g(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:o,after:r}]}function Me(e,t){let o=[],r=new Map(e.projects.map(a=>[a.path,a])),l=new Map(t.projects.map(a=>[a.path,a]));for(let[a,i]of l.entries()){let c=r.get(a);if(!c){w(o,{type:"project.added",severity:"info",target:a,message:`Project added: ${i.name}`,after:x(i)});continue}let m=x(c),p=x(i);if(g(m)!==g(p)){let f=c.runtime!==i.runtime||c.framework!==i.framework;w(o,{type:"project.changed",severity:f?"warning":"info",target:a,message:`Project changed: ${i.name}`,before:m,after:p});}}for(let[a,i]of r.entries())l.has(a)||w(o,{type:"project.removed",severity:"warning",target:a,message:`Project removed: ${i.name}`,before:x(i)});return o.sort((a,i)=>`${a.type}:${a.target}`.localeCompare(`${i.type}:${i.target}`))}async function Ie(e){let t=k$1.resolve(e.workspacePath),o=ne(e.fromPath),r=o?ye(e.fromPath):void 0,l=e.fromPath;if(o){let u=k$1.join(t,T);if(!await L.pathExists(u))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");l=T;}let a=ae(t,l),i=await We(a),c=e.model??await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=I(c),p=[...be(i.model,c),...Me(i.model,c),...je(i.model,c)],f;e.includeGitObservation!==false&&(f=e.gitObservation??Y(t,{ref:r}),f.available&&Ee(p,f,c));let h=p.filter(u=>u.type.startsWith("git.")).length,b=i.hash!==m,W=o?`git:${r??"HEAD"}`:k$1.relative(t,a).split(k$1.sep).join("/");return {schemaVersion:K,generatedAt:(e.now??new Date).toISOString(),fromRef:W,toRef:k,fromHash:i.hash,toHash:m,summary:{changed:b||h>0,addedProjects:p.filter(u=>u.type==="project.added").length,removedProjects:p.filter(u=>u.type==="project.removed").length,changedProjects:p.filter(u=>u.type==="project.changed").length,workspaceChanges:p.filter(u=>u.type==="workspace.changed").length,validationChanges:p.filter(u=>u.type==="validation.changed").length,gitChangedFiles:h},git:f?.available?Se(f,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:p,currentModel:c}}async function Ze(e,t){return g$1(t,oe,a$1(e))}function P(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Q(e){return e.reduce((t,o)=>P(o)>P(t)?o:t,"none")}var N=["none","low","medium","high","critical"];function Pe(e){let t=Math.max(1,P(e)-1);return N[t]}function Re(e){let t=Math.min(N.length-1,P(e)+1);return N[t]}function Z(e){return e.join(" ")}function y(e,t,o,r){return {id:e,label:t,scope:r.scope,project:r.project,display:Z(["npx","workspai",...o]),execute:Z(["npx","--yes","--package","workspai","workspai",...o]),required:r.required!==false}}function ee(e){let t=`project:${e.name}`,o=e.commands.fleetStages;return [y(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("init")}),y(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("test")}),y(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("build")}),y(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:o.includes("start")})]}function _(){return [y("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),y("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),y("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),y("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),y("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),y("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Ce(e,t){let o=t.split(k$1.sep).join("/");return e.projects.filter(l=>{let a=l.path.split(k$1.sep).join("/");return o===a||o.startsWith(`${a}/`)}).sort((l,a)=>a.path.length-l.path.length)[0]}function Ee(e,t,o){let r=new Set(e.map(a=>a.target)),l=(a,i)=>{let c=i.split(k$1.sep).join("/"),m=`git:${c}`;if(r.has(m))return;let p=Ce(o,c),f=p?`${p.name} (${p.path})`:"workspace";w(e,{type:a,severity:a==="git.deleted"?"warning":"info",target:m,message:`Git ${a==="git.untracked"?"untracked":a==="git.deleted"?"deleted":"changed"} file affects ${f}: ${c}`,after:{path:c,project:p?.name,projectPath:p?.path}}),r.add(m);};for(let a of t.changedFiles)l("git.file.changed",a);for(let a of t.untrackedFiles)l("git.untracked",a);for(let a of t.deletedFiles)l("git.deleted",a);}function Se(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Oe(e){let t=new Set,o=[];for(let r of e){let l=`${r.scope}:${r.project??""}:${r.display}`;t.has(l)||(t.add(l),o.push(r));}return o}function Ae(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function $e(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function De(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(o=>o.severity==="critical"?false:o.type.startsWith("git.")||o.type==="validation.changed")?e.risk:P(e.risk)>=P("high")||e.risk==="medium"?"low":e.risk}function te(e,t){if(!e||e==="workspace")return true;let o=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,k$1.basename(t.path),t.absolutePath].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim().toLowerCase()).includes(o)}function Fe(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(o=>o.project?.name??o.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function et(e){let t=k$1.resolve(e.workspacePath),o=ne(e.fromPath),r=e.diff;if(!r&&!o){let n=ae(t,e.fromPath);r=await ve(n)??void 0;}r||(r=await Ie({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let l=new Map(r.currentModel.projects.map(n=>[n.path,n])),a=new Map(r.currentModel.projects.map(n=>[n.name,n])),i=r.changes.filter(n=>n.type.startsWith("project.")),c$1=new Map;for(let n of i){let d=(l.get(n.target)??(typeof n.before?.name=="string"?a.get(n.before.name):void 0))?.path??n.target,v=c$1.get(d)??[];v.push(n),c$1.set(d,v);}let m=[];for(let[n,s]of c$1.entries()){let d=l.get(n);if(d&&!te(e.scope,d))continue;let v=Q(s.map(Ae)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):n);m.push({id:`project:${C}`,scope:"project",target:n,title:`Project impact: ${C}`,summary:s.map(j=>j.message).join(" "),risk:v,reasons:s.map(j=>`${j.type}: ${j.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?ee(d):_()});}let p=r.currentModel.graph,f=p?a$2(p):void 0,h=new Set(m.map(n=>n.project?.name).filter(n=>typeof n=="string")),b=new Map;for(let n of m)if(n.project?.name){let s=f?.byId.get(n.project.name);s&&(n.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(n.risk=Re(n.risk),n.reasons=[...n.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),n.origin="direct",n.distance=0,b.set(n.project.name,n.risk);}let W=[],u=0;if(p&&h.size>0){let n=c(p,h);for(let s of n.values()){if(s.distance===0||h.has(s.id))continue;let d=a.get(s.id);if(d&&!te(e.scope,d))continue;let v=s.path[0],C=s.path[s.path.length-2]??v,j=b.get(v)??"medium",pe=Pe(j),M=f?.byId.get(s.id);u=Math.max(u,s.distance),W.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${v}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:pe,reasons:[`graph.dependent: depends on ${C}${s.via?` via ${s.via}`:""} (path ${s.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?ee(d):_(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...M?{centrality:{fanIn:M.fanIn,fanOut:M.fanOut,reach:M.reach,betweenness:M.betweenness,isHotspot:M.isHotspot}}:{}});}}W.sort((n,s)=>n.target.localeCompare(s.target));let se=f?f.hotspots.flatMap(n=>{let s=f.byId.get(n);return s?[{project:n,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],ie=r.changes.filter(n=>!n.type.startsWith("project.")),B=r.currentModel.summary?.projectCount??r.currentModel.projects.length,R=ie.map(n=>({id:`workspace:${n.target}`,scope:"workspace",target:n.target,title:`Workspace impact: ${n.target}`,summary:n.message,risk:$e(n,{projectCount:B}),reasons:[`${n.type}: ${n.message}`],verification:_()})),q=Oe([...m.flatMap(n=>n.verification),...W.flatMap(n=>n.verification),...R.flatMap(n=>n.verification),...r.summary.changed?_():[]]).filter(n=>n.required),ce=Q([...m.map(n=>n.risk),...W.map(n=>n.risk),...R.map(n=>n.risk)]),z=De({risk:ce,affectedProjects:m.length,projectCount:B,changes:r.changes}),J={changed:r.summary.changed,risk:z,affectedProjects:m.length,workspaceItems:R.length,recommendedCommands:q.length,blastRadius:{directlyAffected:m.length,transitivelyAffected:W.length,maxDistance:u,graphEdges:p?.edges.length??0}};return {schemaVersion:he,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:oe,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:J,affectedProjects:m.sort((n,s)=>n.target.localeCompare(s.target)),transitiveImpact:W,criticalPathHotspots:se,workspaceImpact:R.sort((n,s)=>n.target.localeCompare(s.target)),verificationPlan:q,agentBrief:Fe({changed:J.changed,risk:z,affectedProjects:m,workspaceImpact:R}),diff:r}}async function tt(e,t){return g$1(t,we,a$1(e))}export{Y as a,re as b,K as c,T as d,oe as e,he as f,we as g,ne as h,ye as i,Xe as j,Ye as k,Qe as l,Ie as m,Ze as n,_ as o,et as p,tt as q};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-5AKYMAIL.js';var r=".workspai/skills";var e=a$1.skillsIndex,a=a$1.explain,_=".workspai/reports/workspace-why-last-run.json",c=".workspai/reports/workspace-trace-last-run.json",O=".workspai/AGENT-GROUNDING.md",P=".rapidkit/AGENT-GROUNDING.md",I=".cursor/rules/workspai-grounding.mdc",A=".cursor/rules/rapidkit-grounding.mdc",T=".claude/rules/workspai-evidence.md",E=".claude/rules/rapidkit-evidence.md",R=".github/instructions/workspai-workspace.instructions.md",L=".github/instructions/rapidkit-workspace.instructions.md",d=".github/instructions/workspai-evidence.instructions.md",S=".github/instructions/rapidkit-evidence.instructions.md",C=".github/prompts/workspai-diagnose.prompt.md",k=".github/prompts/rapidkit-diagnose.prompt.md",l=".github/prompts/workspai-repair.prompt.md",m=".github/prompts/rapidkit-repair.prompt.md",N=".github/prompts/workspai-release-readiness.prompt.md",u=".github/prompts/rapidkit-release-readiness.prompt.md",g=".github/prompts/workspai-project-onboard.prompt.md",K=".github/prompts/rapidkit-project-onboard.prompt.md",G=".github/prompts/workspai-adopt-project.prompt.md",w=".github/prompts/rapidkit-adopt-project.prompt.md",x=".github/skills/workspai-grounding/SKILL.md",H=".github/skills/rapidkit-grounding/SKILL.md",D=".github/skills/workspai-workspace-intelligence/SKILL.md",W=".github/skills/rapidkit-workspace-intelligence/SKILL.md",h=".workspai/reports/workspai-mcp-design.json",U=".workspai/reports/rapidkit-mcp-design.json",b=".vscode/workspai-agent-hooks.json",Y=".vscode/rapidkit-agent-hooks.json";function M(t){let s=t.trim();if(!s||s.includes("..")||s.includes("/"))throw new Error(`Invalid operational skill id: ${t}`);return `${r}/${s}.md`}var f={"workspai-diagnose-api-failure":"workspai-diagnose","workspai-release-readiness":"workspai-release-readiness","workspai-safe-schema-migration":"workspai-safe-schema-migration","workspai-dependency-upgrade":"workspai-dependency-upgrade","workspai-rename-contract":"workspai-rename-contract"};export{H as A,D as B,W as C,h as D,U as E,b as F,Y as G,M as H,f as I,r as a,e as b,a as c,_ as d,c as e,O as f,P as g,I as h,A as i,T as j,E as k,R as l,L as m,d as n,S as o,C as p,k as q,l as r,m as s,N as t,u,g as v,K as w,G as x,w as y,x as z};