workspai 0.43.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 (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +624 -0
  3. package/contracts/agent-customization-pack.v1.json +229 -0
  4. package/contracts/analyze-last-run.v1.json +106 -0
  5. package/contracts/artifact-remediation-plan.v1.json +163 -0
  6. package/contracts/backend-import-stack-parity.snapshot.json +37 -0
  7. package/contracts/cli-log-event.v1.json +51 -0
  8. package/contracts/create-planner-capabilities.v1.json +251 -0
  9. package/contracts/doctor-project-evidence.v1.json +304 -0
  10. package/contracts/doctor-remediation-plan.v1.json +496 -0
  11. package/contracts/doctor-workspace-evidence.v1.json +315 -0
  12. package/contracts/extension-cli-compatibility.v1.json +26 -0
  13. package/contracts/infra-stack.v1.json +305 -0
  14. package/contracts/module-layout.v1.json +34 -0
  15. package/contracts/module-support.v1.json +20 -0
  16. package/contracts/pipeline-last-run.v1.json +80 -0
  17. package/contracts/release-readiness.v1.json +60 -0
  18. package/contracts/runtime-command-surface.v1.json +364 -0
  19. package/contracts/workspace-intelligence/agent-action-outcome.v1.json +38 -0
  20. package/contracts/workspace-intelligence/blocker-resolution.v1.json +65 -0
  21. package/contracts/workspace-intelligence/doctor-fix-result.v1.json +44 -0
  22. package/contracts/workspace-intelligence/fact-freshness.v1.json +58 -0
  23. package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +115 -0
  24. package/contracts/workspace-intelligence/workspace-context.v1.json +142 -0
  25. package/contracts/workspace-intelligence/workspace-contract-verify.v1.json +51 -0
  26. package/contracts/workspace-intelligence/workspace-dependency-graph.v1.json +152 -0
  27. package/contracts/workspace-intelligence/workspace-explain.v1.json +31 -0
  28. package/contracts/workspace-intelligence/workspace-impact.v1.json +114 -0
  29. package/contracts/workspace-intelligence/workspace-intelligence-history.v1.json +40 -0
  30. package/contracts/workspace-intelligence/workspace-model-diff.v1.json +105 -0
  31. package/contracts/workspace-intelligence/workspace-model-snapshot.v1.json +36 -0
  32. package/contracts/workspace-intelligence/workspace-model.v1.json +135 -0
  33. package/contracts/workspace-intelligence/workspace-operational-skill.v1.json +37 -0
  34. package/contracts/workspace-intelligence/workspace-skills-index.v1.json +27 -0
  35. package/contracts/workspace-intelligence/workspace-verify.v1.json +213 -0
  36. package/contracts/workspace-registry.v1.json +83 -0
  37. package/contracts/workspace-run-last.v1.json +112 -0
  38. package/data/modules-embeddings.json +16953 -0
  39. package/dist/analyze-5BU4QIPK.js +1 -0
  40. package/dist/artifact-remediation-plan-5GJWPPRS.js +3 -0
  41. package/dist/autopilot-release-QYUOVB26.js +1 -0
  42. package/dist/chunk-22DT744Z.js +1 -0
  43. package/dist/chunk-2E6WGUN6.js +1 -0
  44. package/dist/chunk-2FIX2MDC.js +1 -0
  45. package/dist/chunk-3KXW53QI.js +1 -0
  46. package/dist/chunk-3ZK2GU7C.js +1 -0
  47. package/dist/chunk-4KUIFXHM.js +5 -0
  48. package/dist/chunk-54XJNLYC.js +13 -0
  49. package/dist/chunk-5SWNSJGW.js +1 -0
  50. package/dist/chunk-5XATWNME.js +1 -0
  51. package/dist/chunk-753LOKFZ.js +2 -0
  52. package/dist/chunk-7YHK5NM3.js +2 -0
  53. package/dist/chunk-A5FBGRJA.js +1 -0
  54. package/dist/chunk-AAKUNWPR.js +78 -0
  55. package/dist/chunk-AFSZHLQT.js +1 -0
  56. package/dist/chunk-AQ4XZZC6.js +1 -0
  57. package/dist/chunk-CVTCPPEF.js +1 -0
  58. package/dist/chunk-DNAY5ALC.js +1 -0
  59. package/dist/chunk-EWYYLJQY.js +2 -0
  60. package/dist/chunk-GSWPGELT.js +2 -0
  61. package/dist/chunk-GZTYAEWX.js +1 -0
  62. package/dist/chunk-HTYMXMQM.js +1 -0
  63. package/dist/chunk-IBJEQHJR.js +205 -0
  64. package/dist/chunk-ICGWHIMK.js +1 -0
  65. package/dist/chunk-JEI6BTZI.js +3 -0
  66. package/dist/chunk-JHC6SCJC.js +1 -0
  67. package/dist/chunk-LO4C4VXR.js +4 -0
  68. package/dist/chunk-LPZFK3Y6.js +920 -0
  69. package/dist/chunk-LUP4U6EE.js +1 -0
  70. package/dist/chunk-LYC6AIF2.js +2 -0
  71. package/dist/chunk-LZQNVH7D.js +1 -0
  72. package/dist/chunk-NAAQMSO3.js +1 -0
  73. package/dist/chunk-NFUXULIF.js +1 -0
  74. package/dist/chunk-OCGZNSOE.js +1 -0
  75. package/dist/chunk-OJEWQO3Z.js +33 -0
  76. package/dist/chunk-OL64GWQC.js +9 -0
  77. package/dist/chunk-PI5KUXDA.js +7 -0
  78. package/dist/chunk-PYCJWW4B.js +1 -0
  79. package/dist/chunk-RE773WOX.js +13 -0
  80. package/dist/chunk-RO73VVHW.js +2 -0
  81. package/dist/chunk-S5KTATOU.js +1 -0
  82. package/dist/chunk-SI3AQKIP.js +1 -0
  83. package/dist/chunk-T3GJ7YVG.js +1 -0
  84. package/dist/chunk-T6OR6YOI.js +2 -0
  85. package/dist/chunk-VRDF2J46.js +653 -0
  86. package/dist/chunk-VZKSNUEE.js +2 -0
  87. package/dist/chunk-WU4ZRRA5.js +4 -0
  88. package/dist/chunk-XEJD4KCV.js +33 -0
  89. package/dist/chunk-XZGVNGRB.js +1 -0
  90. package/dist/chunk-Y45WZR5N.js +5 -0
  91. package/dist/create-WRZO4HK2.js +1 -0
  92. package/dist/demo-kit-AJ5LIM5G.js +149 -0
  93. package/dist/doctor-MF3M3FS3.js +1 -0
  94. package/dist/dotnet-webapi-clean-IPY3MCGQ.js +425 -0
  95. package/dist/gofiber-standard-N5N3QGH3.js +1397 -0
  96. package/dist/gogin-standard-LAWQTBWL.js +1459 -0
  97. package/dist/imported-projects-registry-FOIE27WT.js +1 -0
  98. package/dist/index.d.ts +141 -0
  99. package/dist/index.js +454 -0
  100. package/dist/managed-agent-markers-AXUM75OE.js +8 -0
  101. package/dist/module-layout-NZ43RSC5.js +1 -0
  102. package/dist/pipeline-QCUHFWDY.js +5 -0
  103. package/dist/platform-capabilities-XAVU4HSM.js +1 -0
  104. package/dist/pythonRapidkitExec-3L3XJBSY.js +1 -0
  105. package/dist/springboot-standard-OZYF7ZM7.js +697 -0
  106. package/dist/workspace-PR6VZRBG.js +1 -0
  107. package/dist/workspace-agent-sync-KTYF3HQR.js +1 -0
  108. package/dist/workspace-archive-GCZNI44O.js +3 -0
  109. package/dist/workspace-context-QUTOP2XV.js +1 -0
  110. package/dist/workspace-contract-XUGMCUSQ.js +1 -0
  111. package/dist/workspace-explain-JEONEGZZ.js +1 -0
  112. package/dist/workspace-explain-contract-DNS2YEL7.js +1 -0
  113. package/dist/workspace-feedback-R6H4UFZB.js +1 -0
  114. package/dist/workspace-foundation-KGSV4E6D.js +1 -0
  115. package/dist/workspace-graph-2A5THUCI.js +1 -0
  116. package/dist/workspace-history-CGCK2DJI.js +1 -0
  117. package/dist/workspace-intelligence-QJGVL37U.js +1 -0
  118. package/dist/workspace-marker-SMBC3Z2Q.js +1 -0
  119. package/dist/workspace-mcp-serve-AK4MYEHQ.js +3 -0
  120. package/dist/workspace-model-PNXXOGPO.js +1 -0
  121. package/dist/workspace-python-engine-state-MTWIIZPY.js +2 -0
  122. package/dist/workspace-registry-summary-RUJE6RPH.js +1 -0
  123. package/dist/workspace-run-Y7YMUIHX.js +1 -0
  124. package/dist/workspace-verify-WSDUUTR5.js +1 -0
  125. package/dist/workspace-watch-AGPOJ74Q.js +1 -0
  126. package/docs/AI_DYNAMIC_INTEGRATION.md +440 -0
  127. package/docs/AI_EXAMPLES.md +419 -0
  128. package/docs/AI_FEATURES.md +460 -0
  129. package/docs/AI_QUICKSTART.md +245 -0
  130. package/docs/DEVELOPMENT.md +90 -0
  131. package/docs/From Code to Shared Understanding.png +0 -0
  132. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +170 -0
  133. package/docs/OPTIMIZATION_GUIDE.md +504 -0
  134. package/docs/PACKAGE_MANAGER_POLICY.md +25 -0
  135. package/docs/README.md +125 -0
  136. package/docs/SECURITY.md +63 -0
  137. package/docs/SETUP.md +107 -0
  138. package/docs/UTILITIES.md +221 -0
  139. package/docs/WORKSPACE_MARKER_SPEC.md +276 -0
  140. package/docs/ci-workflows.md +59 -0
  141. package/docs/commands-reference.md +172 -0
  142. package/docs/config-file-guide.md +299 -0
  143. package/docs/contracts/ARTIFACT_CATALOG.md +333 -0
  144. package/docs/contracts/CLI_LOG_EVENT_STREAM.md +123 -0
  145. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +138 -0
  146. package/docs/contracts/NAMING_AND_COEXISTENCE.md +60 -0
  147. package/docs/contracts/README.md +86 -0
  148. package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +98 -0
  149. package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +75 -0
  150. package/docs/contracts/rapidkit-cli-contracts.json +239 -0
  151. package/docs/create-planner-capabilities.md +81 -0
  152. package/docs/doctor-command.md +467 -0
  153. package/docs/examples/ci-agent-grounding.yml +65 -0
  154. package/docs/from-code-to-shared-understanding.md +45 -0
  155. package/docs/governance-policy.enterprise.example.json +40 -0
  156. package/docs/mirror-config.enterprise.example.json +60 -0
  157. package/docs/policies.workspace.example.yml +23 -0
  158. package/docs/workspace-operations.md +160 -0
  159. package/docs/workspace-run.md +104 -0
  160. package/package.json +179 -0
  161. package/rapidkit.config.example.cjs +62 -0
  162. package/scripts/check-agent-customization-drift.mjs +78 -0
  163. package/scripts/check-cli-resolution.cjs +72 -0
  164. package/scripts/enforce-package-manager.cjs +10 -0
  165. package/scripts/enterprise-package-smoke.mjs +463 -0
  166. package/scripts/prepack-enterprise.mjs +43 -0
  167. package/templates/generator.js +179 -0
  168. package/templates/kits/fastapi-ddd/README.md.j2 +117 -0
  169. package/templates/kits/fastapi-ddd/common/env.example.j2 +10 -0
  170. package/templates/kits/fastapi-ddd/env.example.j2 +1 -0
  171. package/templates/kits/fastapi-ddd/pyproject.toml.j2 +64 -0
  172. package/templates/kits/fastapi-ddd/src/__init__.py.j2 +3 -0
  173. package/templates/kits/fastapi-ddd/src/app/__init__.py.j2 +11 -0
  174. package/templates/kits/fastapi-ddd/src/app/application/__init__.py.j2 +5 -0
  175. package/templates/kits/fastapi-ddd/src/app/application/interfaces.py.j2 +43 -0
  176. package/templates/kits/fastapi-ddd/src/app/application/use_cases/__init__.py.j2 +6 -0
  177. package/templates/kits/fastapi-ddd/src/app/application/use_cases/health.py.j2 +14 -0
  178. package/templates/kits/fastapi-ddd/src/app/application/use_cases/notes.py.j2 +24 -0
  179. package/templates/kits/fastapi-ddd/src/app/config/__init__.py.j2 +16 -0
  180. package/templates/kits/fastapi-ddd/src/app/domain/__init__.py.j2 +3 -0
  181. package/templates/kits/fastapi-ddd/src/app/domain/models/__init__.py.j2 +6 -0
  182. package/templates/kits/fastapi-ddd/src/app/domain/models/health.py.j2 +16 -0
  183. package/templates/kits/fastapi-ddd/src/app/domain/models/note.py.j2 +27 -0
  184. package/templates/kits/fastapi-ddd/src/app/infrastructure/__init__.py.j2 +5 -0
  185. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/__init__.py.j2 +6 -0
  186. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/health.py.j2 +17 -0
  187. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/notes.py.j2 +28 -0
  188. package/templates/kits/fastapi-ddd/src/app/main.py.j2 +61 -0
  189. package/templates/kits/fastapi-ddd/src/app/presentation/__init__.py.j2 +3 -0
  190. package/templates/kits/fastapi-ddd/src/app/presentation/api/__init__.py.j2 +5 -0
  191. package/templates/kits/fastapi-ddd/src/app/presentation/api/dependencies/__init__.py.j2 +19 -0
  192. package/templates/kits/fastapi-ddd/src/app/presentation/api/router.py.j2 +10 -0
  193. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/__init__.py.j2 +5 -0
  194. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/health.py.j2 +27 -0
  195. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/notes.py.j2 +50 -0
  196. package/templates/kits/fastapi-ddd/src/app/shared/__init__.py.j2 +5 -0
  197. package/templates/kits/fastapi-ddd/src/app/shared/result.py.j2 +28 -0
  198. package/templates/kits/fastapi-ddd/src/cli.py.j2 +170 -0
  199. package/templates/kits/fastapi-ddd/src/main.py.j2 +35 -0
  200. package/templates/kits/fastapi-ddd/src/modules/__init__.py.j2 +3 -0
  201. package/templates/kits/fastapi-ddd/src/routing/__init__.py.j2 +13 -0
  202. package/templates/kits/fastapi-ddd/src/routing/health.py.j2 +7 -0
  203. package/templates/kits/fastapi-ddd/src/routing/notes.py.j2 +7 -0
  204. package/templates/kits/fastapi-ddd/tests/__init__.py.j2 +1 -0
  205. package/templates/kits/fastapi-ddd/tests/test_app_factory.py.j2 +22 -0
  206. package/templates/kits/fastapi-ddd/tests/test_health.py.j2 +17 -0
  207. package/templates/kits/fastapi-ddd/tests/test_notes.py.j2 +27 -0
  208. package/templates/kits/fastapi-standard/README.md.j2 +140 -0
  209. package/templates/kits/fastapi-standard/common/env.example.j2 +10 -0
  210. package/templates/kits/fastapi-standard/env.example.j2 +1 -0
  211. package/templates/kits/fastapi-standard/pyproject.toml.j2 +64 -0
  212. package/templates/kits/fastapi-standard/src/__init__.py.j2 +3 -0
  213. package/templates/kits/fastapi-standard/src/cli.py.j2 +171 -0
  214. package/templates/kits/fastapi-standard/src/main.py.j2 +66 -0
  215. package/templates/kits/fastapi-standard/src/modules/__init__.py.j2 +3 -0
  216. package/templates/kits/fastapi-standard/src/routing/__init__.py.j2 +16 -0
  217. package/templates/kits/fastapi-standard/src/routing/examples.py.j2 +71 -0
  218. package/templates/kits/fastapi-standard/src/routing/health.py.j2 +22 -0
  219. package/templates/kits/fastapi-standard/tests/__init__.py.j2 +1 -0
  220. package/templates/kits/fastapi-standard/tests/test_examples.py.j2 +29 -0
  221. package/templates/kits/fastapi-standard/tests/test_health.py.j2 +17 -0
  222. package/templates/kits/nestjs-standard/Dockerfile.j2 +41 -0
  223. package/templates/kits/nestjs-standard/README.md.j2 +134 -0
  224. package/templates/kits/nestjs-standard/docker-compose.yml.j2 +94 -0
  225. package/templates/kits/nestjs-standard/docs/README.md.j2 +15 -0
  226. package/templates/kits/nestjs-standard/env.example.j2 +18 -0
  227. package/templates/kits/nestjs-standard/eslint.config.cjs.j2 +9 -0
  228. package/templates/kits/nestjs-standard/jest.config.ts.j2 +28 -0
  229. package/templates/kits/nestjs-standard/nest-cli.json.j2 +10 -0
  230. package/templates/kits/nestjs-standard/package.json.j2 +101 -0
  231. package/templates/kits/nestjs-standard/src/app.controller.ts.j2 +14 -0
  232. package/templates/kits/nestjs-standard/src/app.module.ts.j2 +26 -0
  233. package/templates/kits/nestjs-standard/src/app.service.ts.j2 +16 -0
  234. package/templates/kits/nestjs-standard/src/auth/auth.controller.ts.j2 +20 -0
  235. package/templates/kits/nestjs-standard/src/auth/auth.module.ts.j2 +13 -0
  236. package/templates/kits/nestjs-standard/src/auth/auth.service.ts.j2 +6 -0
  237. package/templates/kits/nestjs-standard/src/auth/entities/token.entity.ts.j2 +3 -0
  238. package/templates/kits/nestjs-standard/src/auth/entities/user.entity.ts.j2 +3 -0
  239. package/templates/kits/nestjs-standard/src/auth/entities/webauthn.entity.ts.j2 +3 -0
  240. package/templates/kits/nestjs-standard/src/config/configuration.ts.j2 +85 -0
  241. package/templates/kits/nestjs-standard/src/config/index.ts.j2 +2 -0
  242. package/templates/kits/nestjs-standard/src/config/validation.ts.j2 +21 -0
  243. package/templates/kits/nestjs-standard/src/examples/dto/create-note.dto.ts.j2 +11 -0
  244. package/templates/kits/nestjs-standard/src/examples/examples.controller.ts.j2 +24 -0
  245. package/templates/kits/nestjs-standard/src/examples/examples.module.ts.j2 +10 -0
  246. package/templates/kits/nestjs-standard/src/examples/examples.service.ts.j2 +33 -0
  247. package/templates/kits/nestjs-standard/src/main.ts.j2 +53 -0
  248. package/templates/kits/nestjs-standard/src/modules/index.ts.j2 +25 -0
  249. package/templates/kits/nestjs-standard/test/app.controller.spec.ts.j2 +24 -0
  250. package/templates/kits/nestjs-standard/test/app.e2e-spec.ts.j2 +60 -0
  251. package/templates/kits/nestjs-standard/test/examples.controller.spec.ts.j2 +28 -0
  252. package/templates/kits/nestjs-standard/test/jest-e2e.json.j2 +15 -0
  253. package/templates/kits/nestjs-standard/tsconfig.build.json.j2 +12 -0
  254. package/templates/kits/nestjs-standard/tsconfig.json.j2 +26 -0
  255. package/workspai.config.example.cjs +62 -0
@@ -0,0 +1,333 @@
1
+ # Workspai CLI Artifact Catalog
2
+
3
+ Canonical map of **on-disk artifacts** produced by Workspai CLI commands. Dashboards, VS Code extension, and CI should read paths listed here — not infer from legacy fields (e.g. `workspace.json.projects`).
4
+
5
+ ## Authority layers (identity)
6
+
7
+ | Artifact | Path | Writer | Reader purpose |
8
+ | ------------------ | -------------------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------- |
9
+ | Workspace manifest | `.workspai/workspace.json` | `create workspace`, `foundation ensure`, `bootstrap` (profile) | Profile, engine, bootstrap metadata — **not** project list |
10
+ | Workspace contract | `.workspai/workspace.contract.json` | `workspace sync`, `workspace contract *`, import/adopt | Operational project registry (ports, contracts) |
11
+ | Registry summary | `.workspai/workspace-registry.v1.json` | `workspace sync`, contract sync, `registry status --refresh` | **Canonical** project count + authority for UI/CI |
12
+ | Workspace marker | `.workspai-workspace` | `create workspace`, `foundation ensure` | Root detection |
13
+
14
+ Legacy `.rapidkit-workspace` and `.rapidkit/*` paths are read as fallback for
15
+ older workspaces. New Workspai CLI writes target `.workspai-workspace` and
16
+ `.workspai/*`. Workspace archive hydrate also normalizes legacy archive entries
17
+ to canonical Workspai paths on restore.
18
+
19
+ ## Naming conventions
20
+
21
+ | Pattern | Meaning | Examples |
22
+ | ----------------- | -------------------------------------- | ------------------------------------------------------------ |
23
+ | `*-last-run.json` | Latest gate/run evidence | `doctor-last-run.json`, `pipeline-last-run.json` |
24
+ | `*.latest.json` | Rolling alias + timestamped siblings | `bootstrap-compliance.latest.json`, `mirror-ops.latest.json` |
25
+ | Static state | Current model/state (not a single run) | `workspace-model.json`, `workspace.contract.json` |
26
+
27
+ ## Governance evidence loop
28
+
29
+ | Command | Primary artifact | Schema version | JSON Schema |
30
+ | ------------------------ | --------------------------------------------------------- | ------------------------------- | ------------------------------------------------------------ |
31
+ | `doctor workspace` | `.workspai/reports/doctor-last-run.json` | `doctor-workspace-evidence-v1` | `contracts/doctor-workspace-evidence.v1.json` |
32
+ | `doctor project` | `.workspai/reports/doctor-project-last-run.json` | `doctor-project-evidence-v1` | `contracts/doctor-project-evidence.v1.json` |
33
+ | `doctor * --plan` | `.workspai/reports/doctor-remediation-plan-last-run.json` | `doctor-remediation-plan-v2` | `contracts/doctor-remediation-plan.v1.json` |
34
+ | `doctor * --fix/--apply` | `.workspai/reports/doctor-fix-result-last-run.json` | `rapidkit-doctor-fix-result-v1` | `contracts/workspace-intelligence/doctor-fix-result.v1.json` |
35
+ | `workspace remediation-plan --write` | `.workspai/reports/artifact-remediation-plan-last-run.json` | `artifact-remediation-plan-v1` | `contracts/artifact-remediation-plan.v1.json` |
36
+ | `analyze` | `.workspai/reports/analyze-last-run.json` | `rapidkit-analyze-v1` | `contracts/analyze-last-run.v1.json` |
37
+ | `readiness` | `.workspai/reports/release-readiness-last-run.json` | `release-readiness-v1` | `contracts/release-readiness.v1.json` |
38
+ | `pipeline` | `.workspai/reports/pipeline-last-run.json` | `rapidkit-pipeline-v1` | `contracts/pipeline-last-run.v1.json` |
39
+ | `autopilot release` | `.workspai/reports/autopilot-release-last-run.json` | `autopilot-release-v1` | — |
40
+ | | `.workspai/reports/autopilot-release.json` | (alias, same payload) | — |
41
+
42
+ Side/cache (not gates): `.workspai/reports/doctor-workspace-cache.json` (`doctor-workspace-cache-v2`).
43
+
44
+ Doctor Studio handoff:
45
+ `doctor-remediation-plan-v2` (`contracts/doctor-remediation-plan.v1.json`) is emitted in JSON
46
+ responses and persisted to `.workspai/reports/doctor-remediation-plan-last-run.json` by
47
+ `doctor workspace|project --plan`, `--fix`, and `--apply` so IDEs can render approved commands,
48
+ typed file edits, diff previews, ordered phases, step dependencies, rollback, and verification
49
+ steps without inferring them. `doctor-fix-result-last-run.json` records the approved execution
50
+ outcome, and fix/apply runs append a `kind: doctor-fix` entry to
51
+ `workspace-intelligence-history.json`.
52
+
53
+ Artifact remediation handoff:
54
+ `artifact-remediation-plan-v1` (`contracts/artifact-remediation-plan.v1.json`) is emitted by
55
+ `workspace remediation-plan --json` and persisted with `--write`. Add `--ci` to produce
56
+ CI-oriented verify commands where the underlying command supports stricter gates. It is the cross-card Studio
57
+ handoff for governance artifacts outside Doctor: Bootstrap compliance, Analyze, Readiness,
58
+ Pipeline, Workspace Run, Workspace Verify, and Doctor plan bridging. Consumers should ask npm for
59
+ this plan before inventing per-card repair logic. The plan carries ordered actions, safe file
60
+ operations where deterministic, refresh/verify commands, risk, approval state, and rollback
61
+ strategy.
62
+
63
+ When `doctor project` runs inside a workspace, the workspace report remains the canonical
64
+ governance artifact and Doctor mirrors `doctor-project-last-run.json`,
65
+ `doctor-remediation-plan-last-run.json`, and `doctor-fix-result-last-run.json` into the scoped
66
+ project's `.workspai/reports/` directory. This keeps Studio, agents, and project-local operators on
67
+ the same evidence without losing the workspace source of truth.
68
+
69
+ ## Workspace intelligence
70
+
71
+ | Command | Artifact | Schema | Contract file |
72
+ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- | ------------------------------------------------------------------------- |
73
+ | `workspace model --write` | `workspace-model.json` | `workspace-model.v1` | `contracts/workspace-intelligence/workspace-model.v1.json` |
74
+ | `workspace snapshot` | `workspace-model-snapshot.json` | `workspace-model-snapshot.v1` | `workspace-model-snapshot.v1.json` |
75
+ | `workspace diff` | `workspace-model-diff-last-run.json` | `workspace-model-diff.v1` | `workspace-model-diff.v1.json` |
76
+ | `workspace impact --from <diff>` | `workspace-impact-last-run.json` | `workspace-impact.v1` | `workspace-impact.v1.json` |
77
+ | `workspace verify` | `workspace-verify-last-run.json` | `workspace-verify.v1` | `workspace-verify.v1.json` |
78
+ | `workspace context --write` | `workspace-context-agent.json` | `workspace-context.v1` | `workspace-context.v1.json` |
79
+ | `workspace agent-sync --write` | `reports/INDEX.json`, `reports/agent-customization-pack.json`, `reports/workspai-mcp-design.json`, `reports/workspace-skills-index.json`, `.workspai/skills/*.md`, `.workspai/AGENT-GROUNDING.md`, `AGENTS.md`, Copilot/Cursor/Claude/VS Code agent surfaces | `rapidkit-agent-customization-pack.v1` | `contracts/agent-customization-pack.v1.json` |
80
+ | `workspace explain --write` | `workspace-explain-last-run.json` | `workspace-explain.v1` | `contracts/workspace-intelligence/workspace-explain.v1.json` |
81
+ | `workspace feedback record` / `doctor * --fix` | `workspace-intelligence-history.json` (`kind: agent-action`, `doctor-fix`) | `workspace-intelligence-history.v1` | `contracts/workspace-intelligence/workspace-intelligence-history.v1.json` |
82
+
83
+ **CLI semantics:** `workspace diff --from` expects a **model or snapshot** baseline. `workspace impact --from` expects a **diff report**.
84
+
85
+ ### Dependency graph (`workspace-dependency-graph.v1`)
86
+
87
+ The dependency graph is the first-class structure that promotes inter-project
88
+ relationships out of `workspace run`'s private logic into one versioned source
89
+ of truth consumed by `impact` (transitive blast radius), `verify`
90
+ (subgraph-scoped gating), `run --blast-radius`, and risk weighting.
91
+
92
+ | Field | Meaning |
93
+ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
94
+ | `nodes` | Projects in the workspace (`id`, workspace-relative `path`). |
95
+ | `edges` | Directed `from → to` relationships (`from` depends on `to`). Each edge carries a typed `kind`, a `source` (provenance), a `confidence` bucket, and `evidence` (the files that justify it). |
96
+ | `stats` | Counts (`nodeCount`, `edgeCount`, per-source edge counts) and `hasCycle` for the integrity gate. |
97
+
98
+ Edge `kind` ∈ `code-import`, `package-dep`, `event-pub-sub`, `service-dependsOn`,
99
+ `shared-resource`. Edge `source` ∈ `inferred`, `contract`, `manual` (`manual`/`contract`
100
+ are authoritative and override an `inferred` edge of the same kind between the same
101
+ nodes). Canonical source: `src/contracts/workspace-dependency-graph-contract.ts`;
102
+ JSON Schema: `contracts/workspace-intelligence/workspace-dependency-graph.v1.json`.
103
+
104
+ **Inference engine.** The graph is derived deterministically by
105
+ `src/workspace-dependency-graph.ts` (`inferWorkspaceDependencyGraph`) from multiple
106
+ sources: package manifests (`package.json` deps, `pyproject.toml` path deps, `go.mod`
107
+ replace → `package-dep`), cross-boundary JS/TS source imports (`code-import`), the
108
+ workspace contract (`dependsOn` → `service-dependsOn`, matched `publishes`/`consumes`
109
+ → `event-pub-sub`, env↔port references → `shared-resource`), and an optional manual
110
+ override file. Node/edge ordering and `hashDependencyGraph` are stable, so the graph is
111
+ embedded as a first-class field of `workspace-model.v1` (`model.graph`) on every
112
+ `buildWorkspaceModel` run; `hashModel` normalizes the embedded `graph.generatedAt` so the
113
+ structural graph participates in the model hash without causing timestamp drift.
114
+ (`model.graph` is additive/optional for pre-graph readers.)
115
+
116
+ **Manual overrides.** `.workspai/workspace-graph.overrides.json` (`{ "edges": [{ "from",
117
+ "to", "kind", "evidence" }] }`) declares authoritative edges that win over inference for
118
+ the same `(from, to, kind)`.
119
+
120
+ **Graph-aware impact.** `workspace impact` consumes the graph for a true transitive
121
+ blast radius: alongside `affectedProjects` (directly changed) it emits `transitiveImpact[]`
122
+ — projects reached only through the graph, each with `origin: 'transitive'`, `distance`,
123
+ the shortest dependency `path`, and `via` (edge kind). `summary.blastRadius`
124
+ (`directlyAffected`, `transitivelyAffected`, `maxDistance`, `graphEdges`) summarizes the
125
+ reach. Both arrays feed the `verificationPlan`.
126
+
127
+ **Graph-aware verify.** `workspace verify` gates the **whole affected subgraph**, not just
128
+ the changed node. `affectedSubgraph` (`directlyChanged`, `transitiveDependents`, `covered`,
129
+ `uncovered`, `unverifiable`) records coverage per project: a dependent with failed or
130
+ missing-required verification evidence becomes a `graph.subgraph.<project>` blocking reason;
131
+ missing non-required evidence escalates the verdict to `needs-attention`; a dependent with no
132
+ applicable verification command is `unverifiable` (informational, never blocking).
133
+
134
+ **Centrality-weighted risk.** `workspace impact` computes graph centrality
135
+ (`fanIn`/`fanOut`/`reach`/`betweenness`) per project; each impact item carries `centrality`,
136
+ a directly-changed critical-path hotspot escalates its risk one level, and the report lists
137
+ `criticalPathHotspots[]` (ranked by reach then betweenness). Canonical source:
138
+ `src/workspace-graph-centrality.ts` (`computeGraphCentrality`).
139
+
140
+ **Graph integrity gate.** `workspace verify` emits `graphIntegrity` (`ok`, `cycles`,
141
+ `danglingEdges`, `orphans`, `stats`). Cycles and dangling edges are blocking
142
+ (`graph.integrity.cycle` / `graph.integrity.dangling` reasons); orphans are informational.
143
+ Canonical source: `src/workspace-graph-integrity.ts` (`checkGraphIntegrity`).
144
+
145
+ **Watch / daemon mode.** `workspace watch [--json] [--once]` keeps the model + graph in
146
+ memory and streams `workspace-watch-event.v1` records (`ready`/`changed`/`unchanged`/`error`)
147
+ on each settled change, driven by graph-aware incremental rebuilds. Events carry changed/added/
148
+ removed projects, graph edge deltas, structural `modelHash`, and `mode`/`durationMs`. Canonical
149
+ source: `src/workspace-watch.ts`.
150
+
151
+ **Health/impact history.** Each `workspace verify` run appends a compact record to
152
+ `.workspai/reports/workspace-intelligence-history.json` (`workspace-intelligence-history.v1`),
153
+ a ring buffer capped at the 50 most-recent entries (verdict, risk, freshness, gate, counts).
154
+ Canonical source: `src/workspace-history.ts`.
155
+
156
+ **Verify gate + policy violations.** `workspace verify --json` emits a `gate`
157
+ object (`passed`, `mode`, `exitCode`, `reasons`) from `evaluateWorkspaceVerifyGate` — the
158
+ definitive pre-action gate (default fails on `blocked`; `--strict` also fails on
159
+ `needs-attention` and `stale` freshness). It also emits `policyMode` + `policyViolations[]`
160
+ (model validation issues + contract `violations`); in `enforce` mode error-severity violations
161
+ block, in `warn` mode they escalate to needs-attention.
162
+
163
+ **Graph-aware freshness.** `workspace verify` emits a `freshness` block
164
+ (`verdict: fresh|stale|unknown`, `changed`/`added`/`removed`, `projectHashes`). Each project's
165
+ `transitiveInputsHash` chains its own content hash with its transitive dependencies' hashes, so
166
+ a dependency change makes every dependent stale deterministically. The verdict compares against
167
+ the previously written verify report. Canonical source: `src/workspace-graph-freshness.ts`.
168
+
169
+ **Graph command surface.** `workspace graph` emits the graph plus integrity + hotspots;
170
+ `workspace graph explain <project>` returns centrality and direct/transitive relationships;
171
+ `workspace graph dot|mermaid` render deterministic visualizations. Canonical source:
172
+ `src/workspace-graph.ts`. The `graph` subcommand is part of `WORKSPACE_SUBCOMMANDS` and is
173
+ published via `runtime-command-surface.v1` for IDE/CI capability detection.
174
+
175
+ ### Model cache (`workspace-model-cache.v1`)
176
+
177
+ On-disk path: `.workspai/cache/workspace-model.v1.json`. Opt-in (`workspace model --cache`)
178
+ cache keyed by `inputsHash` — a deterministic fingerprint of the project set, per-project
179
+ manifest contents, workspace files (contract/workspace.json/policies), build flags, and CLI
180
+ version. On a hit the stored model is returned byte-for-byte; on a miss it is rebuilt and
181
+ rewritten. Canonical source: `src/workspace-model-cache.ts` (`computeModelInputsHash`,
182
+ `buildWorkspaceModelCached`). Granularity is manifest/project-set level, not per-source-file.
183
+
184
+ The envelope also stores per-project signatures (`computeProjectSignatures`: manifest hashes +
185
+ a source fingerprint of `path:size:mtime`) and workspace-file signatures, powering
186
+ `workspace model --incremental` (`buildWorkspaceModelIncremental`): unchanged project models are
187
+ reused and the dependency graph re-infers only edges incident to changed projects
188
+ (`inferWorkspaceDependencyGraphIncremental`). It falls back to a full rebuild on workspace-file
189
+ changes or project renames, and rescans code-imports fully when the node set changes. Reported
190
+ modes: `full` / `incremental` / `unchanged`.
191
+
192
+ ### Freshness metadata (`rapidkit-freshness-metadata-v1`)
193
+
194
+ Intelligence reports carry a shared freshness envelope so any consumer (CLI
195
+ `workspace verify`, Workspai, CI) can detect staleness **without** re-running the
196
+ whole chain:
197
+
198
+ | Field | Meaning |
199
+ | ------------- | ----------------------------------------------------------------------------------------------------------------------- |
200
+ | `generatedAt` | ISO-8601 timestamp the report was produced. |
201
+ | `inputsHash` | Stable sha256 of the inputs that produced the report. If a freshly recomputed inputs hash differs, the report is stale. |
202
+
203
+ Canonical source: `src/contracts/freshness-metadata-contract.ts`
204
+ (`computeInputsHash`, `buildFreshnessMetadata`, `assessFreshness`). Verdicts:
205
+ `fresh` (hashes match), `stale` (hashes differ), `unknown` (either side missing,
206
+ e.g. legacy reports).
207
+
208
+ ### Fact freshness (`rapidkit-fact-freshness-v1`)
209
+
210
+ Artifact-level freshness answers "is this report still valid?" Fact-level freshness answers
211
+ "may an agent safely remember this specific claim?" `workspace model` and
212
+ `workspace context --for-agent --write` now emit `facts[]` plus a `factFreshness` summary so
213
+ agents, Workspai, and CI can distinguish durable structure from perishable evidence.
214
+
215
+ | Kind | Meaning |
216
+ | ------------------- | ------------------------------------------------------------------------ |
217
+ | `durable` | Structural configuration such as workspace identity or policy mode |
218
+ | `derived` | Inferred structure such as project count, runtime, framework, commands |
219
+ | `evidence-backed` | A fact backed by a report that can expire or become stale |
220
+ | `live` | Runtime state that must be re-observed quickly |
221
+ | `verify-before-use` | Missing, stale, or release-sensitive fact that must be regenerated first |
222
+
223
+ Every fact carries `category` (`structure`, `verification`, `state`), `generatedAt`,
224
+ `ttlSeconds`, `status`, `verifyBeforeUse`, `sourceArtifact`, optional `sourcePath`, and a
225
+ stable `inputsHash` for the fact value. Consumers must treat `verifyBeforeUse: true` as a hard
226
+ refresh boundary before advice, edits, or release decisions. Canonical source:
227
+ `src/contracts/fact-freshness-contract.ts`; JSON Schema:
228
+ `contracts/workspace-intelligence/fact-freshness.v1.json`.
229
+
230
+ ### Run correlation (`runId`)
231
+
232
+ When a command runs through the CLI with the structured log stream active, the
233
+ persisted intelligence artifacts (`workspace-model.json`, `workspace-model-snapshot.json`,
234
+ `workspace-model-diff-last-run.json`, `workspace-impact*.json`, `workspace-context-agent.json`)
235
+ carry a top-level `runId`. It matches the `runId` on the `cli-log-event.v1` stream
236
+ (`run.started`/`progress`/`run.completed`), so a consumer can tie an on-disk report
237
+ to the exact run that produced it. `runId` is added at write time only and is
238
+ ignored by `modelHash`/diff comparisons, so deterministic hashing is unaffected.
239
+ Canonical source: `src/observability/run-correlation.ts` (`attachRunCorrelation`).
240
+
241
+ ## Operational / platform
242
+
243
+ | Command | Artifact | Notes |
244
+ | -------------------------------- | ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------- |
245
+ | `workspace run` | `workspace-run-last.json` | `workspace-run-v1` (multi-stage: `stages.test`, `stages.build`, …) | `contracts/workspace-run-last.v1.json` |
246
+ | `autopilot release` (run stages) | same `workspace-run-last.json` | Autopilot publishes test/build into aggregate (no separate `autopilot-workspace-run-*.json`) | — |
247
+ | `bootstrap` | `bootstrap-compliance-{ts}.json`, `bootstrap-compliance.latest.json` | |
248
+ | `mirror status` | `mirror-ops-{ts}.json`, `mirror-ops.latest.json` | |
249
+ | `mirror` (transparency) | `transparency-evidence-{ts}.json`, `transparency-evidence.latest.json` | |
250
+ | `infra plan` | `infra-plan.json` | `rapidkit.infra-plan.v1` |
251
+ | `workspace archive` | `archive-manifest.json` | Root `.workspai/`, handoff |
252
+ | `workspace share` | `reports/share-bundle.json` (default) | Aggregation bundle |
253
+ | `import` / `adopt` | `{project}/.workspai/import-readiness.json` | Per project |
254
+ | `workspace contract verify` | `workspace-contract-verify-last-run.json` | CLI verify cache |
255
+
256
+ ## Static capability contracts
257
+
258
+ | Contract | Schema version | Consumer purpose |
259
+ | ----------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------ |
260
+ | `contracts/runtime-command-surface.v1.json` | `rapidkit-runtime-command-surface-v1` | Runtime commands, scaffold kits, and create planner summary |
261
+ | `contracts/create-planner-capabilities.v1.json` | `rapidkit-create-planner-capabilities-v1` | Native create, external-create-adopt, and adopt-only lanes for CLI, CI, VS Code, and AI planners |
262
+
263
+ ## Observability stream (not on-disk)
264
+
265
+ Separate from the on-disk artifacts above, Workspai CLI emits a structured
266
+ **NDJSON log stream on stderr** when `--log-format json` (or `RAPIDKIT_LOG_FORMAT=json`)
267
+ is set. This is the deterministic progress/outcome channel for IDEs and CI.
268
+
269
+ | Stream | Schema version | Contract file | Doc |
270
+ | ----------------------- | ------------------ | --------------------------------- | ---------------------------------------------------- |
271
+ | CLI log events (stderr) | `cli-log-event-v1` | `contracts/cli-log-event.v1.json` | [CLI_LOG_EVENT_STREAM.md](./CLI_LOG_EVENT_STREAM.md) |
272
+
273
+ **Channel rule:** command **results** go to stdout (`--json`); **progress/lifecycle**
274
+ events go to stderr (`--log-format json`). The two never mix.
275
+
276
+ ## Registry commands
277
+
278
+ | Command | Output |
279
+ | ------------------------------------------------ | -------------------------------------------------------------------------------- |
280
+ | `workspace sync [--json]` | Updates contract + `workspace-registry.v1.json`; JSON includes `registrySummary` |
281
+ | `workspace registry status [--refresh] [--json]` | Reads or publishes registry summary |
282
+
283
+ ## Project-scoped reports
284
+
285
+ Under `{project}/.workspai/reports/` when commands run at project scope (e.g. project doctor). Workspace-level reports stay under `{workspace}/.workspai/reports/`.
286
+
287
+ ## Consumer rules
288
+
289
+ 1. **Project count:** read `workspace-registry.v1.json` (or run `workspace registry status --json`).
290
+ 2. **Release gates:** follow chain doctor → analyze → readiness → verify → autopilot; use `pipeline-last-run.json` for orchestration summary.
291
+ 3. **Do not** use `workspace.json.projects` (removed in schema 1.0).
292
+ 4. Prefer `schemaVersion` constants in each artifact; legacy `v1` on readiness is accepted when reading old reports.
293
+ 5. **Agent customization:** read `.workspai/reports/agent-customization-pack.json` first for generated surfaces, then `.workspai/reports/INDEX.json` and `workspace-context-agent.json`; regenerate with `workspace agent-sync --write --refresh-context --preset enterprise`.
294
+
295
+ ## Agent customization files (repo hooks)
296
+
297
+ Written by `workspace agent-sync --write --refresh-context --preset enterprise` (and by default after `workspace context --for-agent --write`):
298
+
299
+ | Path | Consumer |
300
+ | ----------------------------------------------------------------------- | -------------------------------------------------------------- |
301
+ | `AGENTS.md` | Copilot, Cursor, Claude Code, Codex, Grok (open standard) |
302
+ | `.github/copilot-instructions.md` | GitHub Copilot / VS Code Chat |
303
+ | `.github/instructions/workspai-workspace.instructions.md` | Copilot workspace scope and command discipline |
304
+ | `.github/instructions/workspai-evidence.instructions.md` | Copilot scoped `.workspai/**` and compatibility evidence rules |
305
+ | `.github/prompts/workspai-diagnose.prompt.md` | Copilot prompt library |
306
+ | `.github/prompts/workspai-repair.prompt.md` | Copilot repair workflow prompt |
307
+ | `.github/prompts/workspai-release-readiness.prompt.md` | Copilot release readiness workflow prompt |
308
+ | `.github/prompts/workspai-project-onboard.prompt.md` | Copilot project onboarding workflow prompt |
309
+ | `.github/prompts/workspai-adopt-project.prompt.md` | Copilot adopt/import workflow prompt |
310
+ | `.github/skills/workspai-grounding/SKILL.md` | Copilot skills |
311
+ | `.github/skills/workspai-workspace-intelligence/SKILL.md` | Enterprise Workspace Intelligence skill |
312
+ | `.github/skills/workspai-workspace-intelligence/resources/mcp-tools.md` | Future MCP tool design reference |
313
+ | `.github/agents/workspai-advisor.agent.md` | Read-only workspace advisor agent |
314
+ | `.github/agents/workspai-repair.agent.md` | Blocker repair agent |
315
+ | `.github/agents/workspai-release.agent.md` | Release safety agent |
316
+ | `.github/agents/workspai-project-onboarder.agent.md` | Project onboarding agent |
317
+ | `.cursor/rules/workspai-grounding.mdc` | Cursor always-on rule |
318
+ | `CLAUDE.md` | Claude Code (imports `@AGENTS.md`) |
319
+ | `.claude/rules/workspai-evidence.md` | Claude Code scoped evidence rule |
320
+ | `.claude/rules/rapidkit-evidence.md` | Legacy Claude Code scoped evidence mirror |
321
+ | `.workspai/AGENT-GROUNDING.md` | Tool-agnostic operator doc |
322
+ | `.workspai/reports/agent-customization-pack.json` | Versioned output inventory, target matrix, drift state |
323
+ | `.workspai/reports/workspai-mcp-design.json` | Read-mostly MCP-ready design manifest |
324
+ | `.vscode/workspai-agent-hooks.json` | Optional advisory VS Code agent hooks (`--experimental-hooks`) |
325
+
326
+ Some `rapidkit-*` prompt, skill, Cursor, MCP-design, and hook paths remain available for older consumers during the rebrand window. New consumers should use the `workspai-*` paths first.
327
+
328
+ ## See also
329
+
330
+ - [README.md](./README.md)
331
+ - [COMMAND_OWNERSHIP_MATRIX.md](./COMMAND_OWNERSHIP_MATRIX.md)
332
+ - [CLI_LOG_EVENT_STREAM.md](./CLI_LOG_EVENT_STREAM.md)
333
+ - [commands-reference.md](../commands-reference.md)
@@ -0,0 +1,123 @@
1
+ # Workspai CLI Log Event Stream (`cli-log-event.v1`)
2
+
3
+ Structured NDJSON observability stream emitted by Workspai CLI so IDEs (Workspai),
4
+ CI, and agents can track command progress and outcome **without scraping human
5
+ terminal text**.
6
+
7
+ - **Schema version:** `cli-log-event-v1`
8
+ - **JSON Schema:** [`contracts/cli-log-event.v1.json`](../../contracts/cli-log-event.v1.json)
9
+ - **TypeScript contract:** `src/contracts/cli-log-event-contract.ts` (single runtime
10
+ source of `CLI_LOG_LEVELS`, `CLI_LOG_EVENT_KINDS`, `CLI_LOG_EVENT_REQUIRED_FIELDS`)
11
+ - **Drift guard:** `src/__tests__/contracts/cli-log-event-contract.test.ts` pins the
12
+ TypeScript contract to the JSON schema so the two can never diverge silently.
13
+
14
+ ## Channel separation (critical)
15
+
16
+ Workspai keeps two machine-readable channels strictly separate:
17
+
18
+ | Channel | Flag | Content |
19
+ | ------- | ---- | ------- |
20
+ | **stdout** | `--json` | The command **result** payload (e.g. workspace model, analyze report). One JSON document. |
21
+ | **stderr** | `--log-format json` (or `--log-json`, or `RAPIDKIT_LOG_FORMAT=json`) | The **NDJSON log stream** — one `cli-log-event.v1` object per line. |
22
+
23
+ Because the two channels are independent, a consumer can request structured
24
+ progress (`--log-format json`) **and** a structured result (`--json`) at the same
25
+ time without corrupting either stream.
26
+
27
+ ## Activation
28
+
29
+ Any of the following enables the stream:
30
+
31
+ ```bash
32
+ workspai workspace model --json --log-format json
33
+ RAPIDKIT_LOG_FORMAT=json workspai workspace verify --json
34
+ workspai doctor workspace --log-json
35
+ ```
36
+
37
+ In text mode (the default) no structured log events are written to stderr.
38
+
39
+ ### Flag normalization (why it works for every command)
40
+
41
+ `--log-format json` / `--log-json` are **not** registered as per-command options. On
42
+ startup the CLI resolves the requested format once, makes it sticky via
43
+ `RAPIDKIT_LOG_FORMAT=json`, and strips the observability flags from `process.argv`
44
+ before any command parser runs. This guarantees the stream works uniformly for
45
+ commander-parsed commands (e.g. `workspace model`), manually handled commands
46
+ (e.g. `create`), and delegated child CLIs (which inherit the env var) — without a
47
+ command ever rejecting the flag as an "unknown option". The result flag (`--json`)
48
+ is preserved, so the stdout result and the stderr stream stay independent.
49
+
50
+ ## Workspace intelligence phase events
51
+
52
+ Every workspace intelligence subcommand (`model`, `snapshot`, `diff`, `impact`,
53
+ `verify`, `context`, `agent-sync`) emits at least a `progress` event when the
54
+ stream is active:
55
+
56
+ ```json
57
+ { "event": "progress", "component": "workspace",
58
+ "metadata": { "phase": "workspace.model", "action": "model", "status": "started" } }
59
+ ```
60
+
61
+ The terminal outcome is always covered by the run lifecycle (`run.completed` /
62
+ `run.failed`), so a consumer can settle UI state deterministically.
63
+
64
+ ## Event shape
65
+
66
+ Each stderr line is a single JSON object:
67
+
68
+ ```json
69
+ {
70
+ "schemaVersion": "cli-log-event-v1",
71
+ "runId": "5f1d…",
72
+ "timestamp": "2026-06-22T13:59:01.123Z",
73
+ "level": "info",
74
+ "event": "run.started",
75
+ "component": "cli",
76
+ "message": "CLI run started",
77
+ "command": ["workspace", "model"],
78
+ "metadata": { "cwd": "/path/to/workspace", "rapidkitVersion": "0.38.0" }
79
+ }
80
+ ```
81
+
82
+ ### Fields
83
+
84
+ | Field | Required | Notes |
85
+ | ----- | -------- | ----- |
86
+ | `schemaVersion` | yes | Always `cli-log-event-v1`. |
87
+ | `runId` | yes | Stable UUID for the whole CLI invocation; correlates every event in one run. |
88
+ | `timestamp` | yes | ISO-8601 date-time. |
89
+ | `level` | yes | `debug` \| `info` \| `warn` \| `error`. |
90
+ | `event` | yes | `log` \| `progress` \| `run.started` \| `run.completed` \| `run.failed`. |
91
+ | `component` | yes | Emitting component (e.g. `cli`, `create`). |
92
+ | `message` | yes | Human-readable message. |
93
+ | `command` | no | Command argv (observability flags stripped). |
94
+ | `metadata` | no | Sanitized key/value context (e.g. `exitCode`, `cwd`, `rapidkitVersion`). |
95
+
96
+ ## Run lifecycle events
97
+
98
+ Every invocation that runs through the CLI run context emits a deterministic
99
+ lifecycle, keyed by a shared `runId`:
100
+
101
+ 1. `run.started` — emitted on initialization (`level: info`).
102
+ 2. `run.completed` — emitted on exit code `0` (`level: info`, `metadata.exitCode: 0`).
103
+ 3. `run.failed` — emitted on any non-zero exit (`level: error`, `metadata.exitCode: <n>`).
104
+
105
+ `run.completed` / `run.failed` are guaranteed even when a command calls
106
+ `process.exit()`, because the CLI installs a process-exit hook that finalizes the
107
+ run context.
108
+
109
+ ## Consumer guidance (IDE / CI)
110
+
111
+ 1. Spawn with `--log-format json` to receive progress; parse stderr line-by-line.
112
+ 2. Treat a line as an event only if it parses as JSON and matches the schema
113
+ (`schemaVersion === 'cli-log-event-v1'`). Ignore non-matching lines.
114
+ 3. Use `runId` to group events; show progress on `progress`/`log`, settle UI state
115
+ on `run.completed` / `run.failed`.
116
+ 4. Read the command **result** from stdout `--json`, not from the log stream.
117
+ 5. Workspai consumes this stream via `src/core/cliLogEventContract.ts`
118
+ (`parseCliLogEventLine`) to drive deterministic progress and evidence refresh.
119
+
120
+ ## See also
121
+
122
+ - [ARTIFACT_CATALOG.md](./ARTIFACT_CATALOG.md) — on-disk artifacts produced by commands
123
+ - [COMMAND_OWNERSHIP_MATRIX.md](./COMMAND_OWNERSHIP_MATRIX.md)
@@ -0,0 +1,138 @@
1
+ # Command Ownership Matrix
2
+
3
+ This document defines which layer owns command execution in Workspai CLI (`workspai`) versus RapidKit Core (`rapidkit-core`) to prevent runtime conflicts.
4
+
5
+ ## Goals
6
+
7
+ - Keep project bootstrapping reliable across Python / Node / Go projects.
8
+ - Avoid conflicting behavior between wrapper and core CLIs.
9
+ - Make delegation behavior explicit and testable.
10
+
11
+ ## Ownership Rules
12
+
13
+ ### 1) Wrapper-owned commands (never forward to core)
14
+
15
+ These commands are implemented and orchestrated by Workspai CLI:
16
+
17
+ - `readiness`
18
+ - `autopilot`
19
+ - `pipeline`
20
+ - `doctor`
21
+ - `import`
22
+ - `adopt`
23
+ - `snapshot`
24
+ - `workspace`
25
+ - `bootstrap`
26
+ - `setup`
27
+ - `cache`
28
+ - `mirror`
29
+ - `ai`
30
+ - `analyze`
31
+ - `config`
32
+ - `product`
33
+ - `infra`
34
+ - `commands`
35
+ - `shell activate`
36
+
37
+ Reason: workspace-level policy, registry, and platform orchestration live in npm wrapper.
38
+
39
+ ### 1.1) Wrapper-owned scoped commands
40
+
41
+ These scoped commands are implemented and orchestrated by Workspai CLI:
42
+
43
+ - `project commands`
44
+ - `project archives`
45
+ - `project archive`
46
+ - `project restore`
47
+ - `project delete`
48
+
49
+ Reason: these are workspace project lifecycle and capability operations with
50
+ archive manifests, safety snapshots, workspace registry side effects, and
51
+ runtime-aware command discovery.
52
+
53
+ `project detect` remains Core-owned because it is the stable machine-readable
54
+ contract used by wrappers to detect Python RapidKit projects.
55
+
56
+ `commands --scope project` is also wrapper-owned. It reports the effective
57
+ project command capability matrix for the currently selected project without
58
+ delegating to Core.
59
+
60
+ ### 2) Wrapper-orchestrated project commands
61
+
62
+ These commands are handled by npm wrapper first (runtime-aware + fallback-aware)
63
+ when the project capability matrix marks them as runtime-supported:
64
+
65
+ - `init`
66
+ - `dev`
67
+ - `start`
68
+ - `build`
69
+ - `test`
70
+ - `lint`
71
+ - `format`
72
+ - `help`
73
+
74
+ Reason: generated projects can be Python, Node/NestJS, Go/Fiber, Go/Gin, or
75
+ Spring Boot. Runtime commands must run through the selected project's adapter,
76
+ not through a hard-coded global assumption.
77
+
78
+ ### 3) Core module/template commands
79
+
80
+ These commands are supported only when the selected project is Core-backed
81
+ and has module/template support:
82
+
83
+ - `add`
84
+ - `modules`
85
+ - `upgrade`
86
+ - `diff`
87
+ - `merge`
88
+ - `reconcile`
89
+ - `rollback`
90
+ - `uninstall`
91
+ - `checkpoint`
92
+ - `snapshot`
93
+ - `optimize`
94
+
95
+ Dispatch policy:
96
+
97
+ - FastAPI / NestJS Core-backed project → supported and delegated to Core.
98
+ - Go / Spring Boot / ASP.NET Core npm-owned project → blocked with a capability explanation.
99
+ - Unknown project → blocked until project metadata is present.
100
+
101
+ ### 4) Global engine/catalog commands
102
+
103
+ These commands are not project-specific even when run inside a project:
104
+
105
+ - `create`
106
+ - `list`
107
+ - `info`
108
+ - `frameworks`
109
+ - `license`
110
+
111
+ `create` remains npm-owned so the wrapper can orchestrate multi-language
112
+ workspace/project generation. The other commands may delegate to Core as engine
113
+ catalog operations.
114
+
115
+ ## Dynamic Project Capability Model
116
+
117
+ A pure-core or pure-wrapper model causes regressions in mixed-language workspaces. Hybrid ownership keeps Python compatibility while letting npm wrapper enforce workspace policy and resilient cross-platform fallback behavior.
118
+
119
+ The npm wrapper resolves project capabilities from `.workspai/project.json`,
120
+ `.workspai/context.json`, legacy `.rapidkit/*` metadata, and framework/runtime markers. Users and tools can
121
+ inspect the effective command surface with:
122
+
123
+ - `workspai project commands`
124
+ - `workspai project commands --json`
125
+ - `workspai commands --scope project --json`
126
+
127
+ This capability model is the canonical bridge between npm-owned kits and
128
+ Core-backed kits. Adding a future language or framework should update the
129
+ project metadata and runtime detector first, then the capability matrix follows
130
+ without widening the Core/global command surface.
131
+
132
+ ## Guard Rails
133
+
134
+ - `shouldForwardToCore()` must return `false` for wrapper-owned and wrapper-orchestrated project commands.
135
+ - `project commands` and `commands --scope project` must never forward to Core.
136
+ - Core module/template commands must be blocked for npm-owned projects that set `module_support: false`.
137
+ - Tests must assert forwarding boundary rules.
138
+ - Changes to ownership should update this file and tests together.