workspai 0.45.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +307 -532
  2. package/contracts/agent-customization-pack.v1.json +6 -1
  3. package/contracts/bootstrap-compliance.v1.json +14 -0
  4. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +8 -0
  5. package/contracts/extension-cli-compatibility.v1.json +9 -2
  6. package/contracts/mirror-ops.v1.json +16 -0
  7. package/contracts/published-contract-catalog.v1.json +38 -1
  8. package/contracts/runtime-command-surface.v1.json +190 -7
  9. package/contracts/transparency-evidence.v1.json +13 -0
  10. package/contracts/workspace-archive-capabilities.v1.json +17 -6
  11. package/contracts/workspace-contract.v1.json +78 -0
  12. package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +4 -0
  13. package/contracts/workspace-intelligence/workspace-context.v1.json +20 -0
  14. package/contracts/workspace-intelligence/workspace-graph-token-efficiency.v1.json +72 -0
  15. package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +212 -0
  16. package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +200 -0
  17. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +260 -0
  18. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +60 -0
  19. package/contracts/workspace-intelligence-architecture.v1.json +7 -4
  20. package/contracts/workspace-intelligence-chain.v1.json +51 -4
  21. package/contracts/workspace-share-bundle.v1.json +16 -0
  22. package/dist/analyze-UVXPRGYZ.js +1 -0
  23. package/dist/artifact-remediation-plan-EPALZ2LC.js +3 -0
  24. package/dist/autopilot-release-5BQ6F5L2.js +1 -0
  25. package/dist/chunk-22NJ2ZMG.js +2 -0
  26. package/dist/{chunk-XIVFLY6G.js → chunk-2GHUZDYA.js} +1 -1
  27. package/dist/chunk-2TEDAKP6.js +2 -0
  28. package/dist/chunk-52PBRX7F.js +1 -0
  29. package/dist/chunk-6SWRNA47.js +4 -0
  30. package/dist/chunk-76YOPAOT.js +1 -0
  31. package/dist/chunk-7VLCK5JW.js +1 -0
  32. package/dist/{chunk-DXPU4DDV.js → chunk-BSRVO52Y.js} +92 -78
  33. package/dist/chunk-COARSXRC.js +1 -0
  34. package/dist/chunk-CV5HKU4P.js +1 -0
  35. package/dist/chunk-CW7PGBIQ.js +13 -0
  36. package/dist/{chunk-KU4S7RCM.js → chunk-DV6GJD4K.js} +1 -1
  37. package/dist/chunk-EYJ2CQSK.js +1 -0
  38. package/dist/chunk-FB7SCXAZ.js +1 -0
  39. package/dist/chunk-FPJNWPKU.js +1 -0
  40. package/dist/{chunk-JP25YL3J.js → chunk-FTY7GGXJ.js} +2 -2
  41. package/dist/chunk-FXQJX34Z.js +1 -0
  42. package/dist/{chunk-J4AICQFB.js → chunk-HSGFUKCN.js} +1 -1
  43. package/dist/{chunk-OOOPYUL2.js → chunk-ITCAMC2E.js} +1 -1
  44. package/dist/chunk-KB44JP4M.js +2 -0
  45. package/dist/{chunk-WANW4QA4.js → chunk-KZZ36CK5.js} +1 -1
  46. package/dist/chunk-LNRAB7UY.js +1 -0
  47. package/dist/chunk-MEMHNE7Y.js +80 -0
  48. package/dist/chunk-MER6ZBN2.js +13 -0
  49. package/dist/chunk-NOFM7MNA.js +2 -0
  50. package/dist/chunk-NRYS4CLR.js +2 -0
  51. package/dist/chunk-OA537ZQ5.js +1 -0
  52. package/dist/chunk-PBHP6JNY.js +8 -0
  53. package/dist/chunk-QDWYIRHR.js +8 -0
  54. package/dist/chunk-RWRLFSKW.js +2 -0
  55. package/dist/chunk-SK6XRKGG.js +1 -0
  56. package/dist/chunk-THIOE2PB.js +2 -0
  57. package/dist/chunk-TNQI5VCW.js +36 -0
  58. package/dist/chunk-TWNFECMN.js +2 -0
  59. package/dist/{chunk-2QOWRBQD.js → chunk-U5EZHZBX.js} +1 -1
  60. package/dist/{chunk-K63BSU56.js → chunk-VBSQ7MF6.js} +62 -51
  61. package/dist/chunk-WDKNMTJQ.js +1 -0
  62. package/dist/chunk-YCL3I2JO.js +2 -0
  63. package/dist/chunk-ZDN7RHXJ.js +1 -0
  64. package/dist/chunk-ZM5NQ5Z2.js +1 -0
  65. package/dist/{create-KFR6FLRT.js → create-7JKJDAQV.js} +1 -1
  66. package/dist/doctor-PGPNIS76.js +1 -0
  67. package/dist/{dotnet-webapi-clean-BYUUHX5Y.js → dotnet-webapi-clean-6TVFBTVI.js} +20 -20
  68. package/dist/{gofiber-standard-B6UK5GR7.js → gofiber-standard-2BL7GWZB.js} +1 -1
  69. package/dist/{gogin-standard-BXU44VEM.js → gogin-standard-XGP3KBXA.js} +1 -1
  70. package/dist/index.d.ts +112 -16
  71. package/dist/index.js +198 -195
  72. package/dist/pipeline-IB6ILJSV.js +5 -0
  73. package/dist/{platform-capabilities-YICBF4FA.js → platform-capabilities-2B4QMZXE.js} +1 -1
  74. package/dist/{pythonRapidkitExec-UJYIB6FL.js → pythonRapidkitExec-CVCIK225.js} +1 -1
  75. package/dist/{springboot-standard-PEHDKH2L.js → springboot-standard-JJNUID6M.js} +6 -6
  76. package/dist/workspace-H3QXBFGB.js +1 -0
  77. package/dist/{workspace-agent-sync-G5YVI3BJ.js → workspace-agent-sync-C7SG2Z5W.js} +1 -1
  78. package/dist/workspace-archive-P76EDIUG.js +10 -0
  79. package/dist/{workspace-context-E3UFWL5X.js → workspace-context-BKQBKA4C.js} +1 -1
  80. package/dist/workspace-contract-RPQQBQXR.js +1 -0
  81. package/dist/workspace-dependency-graph-23BI2HG7.js +1 -0
  82. package/dist/workspace-explain-WVN7JH3U.js +1 -0
  83. package/dist/workspace-explain-contract-SEFTVF6J.js +1 -0
  84. package/dist/{workspace-feedback-YY6WQPWQ.js → workspace-feedback-WAID3IOE.js} +1 -1
  85. package/dist/{workspace-foundation-3C2DLCVI.js → workspace-foundation-5OOJEO2D.js} +1 -1
  86. package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +1 -0
  87. package/dist/{workspace-history-VF3CHDYQ.js → workspace-history-C6OP3IAQ.js} +1 -1
  88. package/dist/workspace-intelligence-VKDL3H2J.js +1 -0
  89. package/dist/workspace-intelligence-runner-LVALAZY7.js +1 -0
  90. package/dist/workspace-knowledge-graph-FE2NTZKV.js +1 -0
  91. package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +1 -0
  92. package/dist/workspace-knowledge-graph-query-VOSPPH4W.js +1 -0
  93. package/dist/workspace-mcp-serve-KT2I676Z.js +3 -0
  94. package/dist/workspace-model-S33CIB2R.js +1 -0
  95. package/dist/workspace-model-hash-MHXK5MEI.js +1 -0
  96. package/dist/workspace-python-engine-state-2MLKJYQG.js +2 -0
  97. package/dist/workspace-registry-summary-A3YDL63D.js +1 -0
  98. package/dist/workspace-run-M4LNJILC.js +1 -0
  99. package/dist/{workspace-verify-ZNT6JX7D.js → workspace-verify-ZGH3NXAH.js} +1 -1
  100. package/dist/workspace-watch-EVBJTMV7.js +1 -0
  101. package/docs/AI_DYNAMIC_INTEGRATION.md +73 -432
  102. package/docs/AI_EXAMPLES.md +37 -395
  103. package/docs/AI_FEATURES.md +76 -465
  104. package/docs/AI_QUICKSTART.md +49 -209
  105. package/docs/DEVELOPMENT.md +5 -5
  106. package/docs/From Code to Shared Understanding.png +0 -0
  107. package/docs/GLOSSARY.md +60 -0
  108. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +91 -9
  109. package/docs/OPTIMIZATION_GUIDE.md +19 -51
  110. package/docs/PACKAGE_MANAGER_POLICY.md +4 -1
  111. package/docs/README.md +91 -42
  112. package/docs/SECURITY.md +13 -6
  113. package/docs/SETUP.md +6 -3
  114. package/docs/UTILITIES.md +8 -20
  115. package/docs/WORKSPACE_MARKER_SPEC.md +27 -20
  116. package/docs/ci-workflows.md +19 -5
  117. package/docs/commands-reference.md +88 -13
  118. package/docs/config-file-guide.md +67 -246
  119. package/docs/contracts/ARTIFACT_CATALOG.md +78 -36
  120. package/docs/contracts/CLI_LOG_EVENT_STREAM.md +1 -1
  121. package/docs/contracts/README.md +48 -9
  122. package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +4 -4
  123. package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +14 -10
  124. package/docs/creating-workspaces-and-projects.md +649 -0
  125. package/docs/doctor-command.md +5 -4
  126. package/docs/examples/ci-agent-grounding.yml +16 -10
  127. package/docs/from-code-to-shared-understanding.md +69 -38
  128. package/docs/graph-benchmark-methodology.md +121 -0
  129. package/docs/workspace-intelligence-runner.md +186 -0
  130. package/docs/workspace-knowledge-graph.md +295 -0
  131. package/docs/workspace-operations.md +78 -11
  132. package/docs/workspace-run.md +4 -1
  133. package/package.json +10 -8
  134. package/rapidkit.config.example.cjs +5 -5
  135. package/scripts/enforce-package-manager.cjs +1 -1
  136. package/scripts/prepack-enterprise.mjs +4 -0
  137. package/workspai.config.example.cjs +12 -47
  138. package/dist/analyze-YLV7NVLF.js +0 -1
  139. package/dist/artifact-remediation-plan-WLZGROUU.js +0 -3
  140. package/dist/autopilot-release-YBN3SWAA.js +0 -1
  141. package/dist/chunk-2K3GYCPS.js +0 -1
  142. package/dist/chunk-42G2OK64.js +0 -1
  143. package/dist/chunk-5AKYMAIL.js +0 -1
  144. package/dist/chunk-5GNT4RJI.js +0 -8
  145. package/dist/chunk-5PVEQ6CZ.js +0 -13
  146. package/dist/chunk-6AA3WWQZ.js +0 -2
  147. package/dist/chunk-6ZENXBMG.js +0 -33
  148. package/dist/chunk-7RIWU5TZ.js +0 -1
  149. package/dist/chunk-7UZVOYF5.js +0 -2
  150. package/dist/chunk-BJLE5CH7.js +0 -4
  151. package/dist/chunk-G3H5R3RR.js +0 -1
  152. package/dist/chunk-HYJK7W3B.js +0 -1
  153. package/dist/chunk-IMUU5Q2V.js +0 -13
  154. package/dist/chunk-KPPGZCUW.js +0 -78
  155. package/dist/chunk-LCRROMRR.js +0 -2
  156. package/dist/chunk-LG6RFLPZ.js +0 -1
  157. package/dist/chunk-P424XYHP.js +0 -1
  158. package/dist/chunk-P7SCWJFG.js +0 -8
  159. package/dist/chunk-QWU2CZBG.js +0 -2
  160. package/dist/chunk-V2H2KRMZ.js +0 -1
  161. package/dist/chunk-XZGVNGRB.js +0 -1
  162. package/dist/chunk-ZWO6K24C.js +0 -2
  163. package/dist/doctor-YJDM5XBH.js +0 -1
  164. package/dist/imported-projects-registry-FOIE27WT.js +0 -1
  165. package/dist/pipeline-FEDYO3IA.js +0 -5
  166. package/dist/workspace-PLXOO6ST.js +0 -1
  167. package/dist/workspace-archive-EEGLHZDW.js +0 -10
  168. package/dist/workspace-contract-LQJDZV36.js +0 -1
  169. package/dist/workspace-explain-G74ZIF23.js +0 -1
  170. package/dist/workspace-explain-contract-KT757JGQ.js +0 -1
  171. package/dist/workspace-intelligence-3GG7GEDQ.js +0 -1
  172. package/dist/workspace-mcp-serve-MJMUV4RY.js +0 -3
  173. package/dist/workspace-model-NG45SRM5.js +0 -1
  174. package/dist/workspace-python-engine-state-MTWIIZPY.js +0 -2
  175. package/dist/workspace-registry-summary-JM2XY52C.js +0 -1
  176. package/dist/workspace-run-WEQYIERE.js +0 -1
  177. package/dist/workspace-watch-W47T4RX2.js +0 -1
@@ -0,0 +1,295 @@
1
+ # Workspace Knowledge Graph
2
+
3
+ Most code graphs answer questions about one repository. Workspai connects code,
4
+ APIs, infrastructure, delivery, documentation, ownership, tests, and runtime
5
+ configuration across a whole workspace—and records why every relationship is
6
+ believed.
7
+
8
+ The graph is local-first and deterministic. Building it does not require an
9
+ LLM, a hosted service, embeddings, or a graph database.
10
+
11
+ ## Why this is useful
12
+
13
+ A repository graph can tell you that function A calls function B. A workspace
14
+ question is usually wider:
15
+
16
+ > If we change this endpoint, which project consumes it, which deployment ships
17
+ > it, which tests cover it, which document describes it, and which release gate
18
+ > can stop it?
19
+
20
+ Workspai keeps those domains in one proof-carrying representation. The graph is
21
+ not the final product screen; it is the shared knowledge layer behind impact,
22
+ verification, context, MCP, IDE, CI, and agent workflows.
23
+
24
+ | If you are… | The graph helps you… |
25
+ | -------------------- | ------------------------------------------------------------------------------------------ |
26
+ | A developer | find the implementation, nearby dependencies, tests, and evidence without repo-wide search |
27
+ | A tech lead | inspect cross-project boundaries, owners, contracts, and change paths |
28
+ | An AI coding agent | retrieve question-sized context and verify every returned claim |
29
+ | A CI/release system | consume versioned JSON, source hashes, quality diagnostics, and deterministic exits |
30
+ | An IDE or MCP client | offer the same system understanding without rebuilding a private index |
31
+
32
+ ## What makes it a workspace graph
33
+
34
+ Workspai does not stop at files, imports, functions, and classes. Repository
35
+ structure is one provider domain alongside APIs, containers, infrastructure,
36
+ pipelines, documents, decisions, ownership, tests, environments, and authored
37
+ workspace contracts.
38
+
39
+ That distinction matters when the answer crosses repositories. The canonical
40
+ Workspace Model remains the source of truth; the Knowledge Graph is its rich,
41
+ queryable, evidence-backed representation. AI is a consumer, never a requirement
42
+ for building the graph.
43
+
44
+ ## Try it in two minutes
45
+
46
+ Run from a Workspai workspace:
47
+
48
+ ```bash
49
+ npx workspai workspace model --write --json
50
+ npx workspai workspace graph search "authentication endpoint" --limit 12 --json
51
+ ```
52
+
53
+ Useful follow-up questions:
54
+
55
+ ```bash
56
+ # What APIs and endpoints exist?
57
+ npx workspai workspace graph entities endpoint --json
58
+
59
+ # Why does Workspai believe this entity exists?
60
+ npx workspai workspace graph evidence "GET /users" --json
61
+
62
+ # How are two services, files, or APIs connected?
63
+ npx workspai workspace graph path frontend-api "GET /users" --json
64
+
65
+ # What changed since a saved graph revision?
66
+ npx workspai workspace graph overlay --from previous-graph.json --json
67
+ ```
68
+
69
+ For agents and MCP clients, prefer bounded search over loading the complete
70
+ graph:
71
+
72
+ ```bash
73
+ npx workspai workspace graph search "billing database" --limit 12 --json
74
+ ```
75
+
76
+ A simplified response looks like this:
77
+
78
+ ```json
79
+ {
80
+ "schemaVersion": "workspace-knowledge-search.v1",
81
+ "query": "billing database",
82
+ "totalMatches": 23,
83
+ "truncated": true,
84
+ "entities": [{ "kind": "database", "label": "billing-db", "proofIds": ["proof:..."] }],
85
+ "relations": [{ "kind": "reads-from", "from": "service:billing", "to": "database:billing-db" }],
86
+ "proofs": [{ "provider": "compose", "artifact": "infra/compose.yml", "trust": "authoritative" }]
87
+ }
88
+ ```
89
+
90
+ The response is intentionally bounded. `totalMatches` tells the consumer more
91
+ results exist, `truncated` prevents silent omission, and every returned claim can
92
+ be traced through `proofIds`.
93
+
94
+ ## Pick the command by question
95
+
96
+ | You want to know… | Use |
97
+ | ---------------------------------------------------- | ------------------------------------------------------ |
98
+ | What is relevant to a natural-language question? | `workspace graph search <query> --limit <n> --json` |
99
+ | Which entities of one type exist? | `workspace graph entities <kind> --json` |
100
+ | Why does Workspai believe an item exists? | `workspace graph evidence <entity-or-relation> --json` |
101
+ | How are two things connected? | `workspace graph path <from> <to> --json` |
102
+ | What changed between graph revisions? | `workspace graph overlay --from <graph.json> --json` |
103
+ | What is the full portable graph? | `workspace graph emit --json` |
104
+ | How much retrieval payload did one query avoid? | `workspace graph benchmark <query> --limit <n> --json` |
105
+ | How should an MCP-compatible agent retrieve context? | `workspace mcp serve` → `searchWorkspaceGraph` |
106
+
107
+ ## What it models
108
+
109
+ The current graph can represent:
110
+
111
+ - workspaces, projects, services, packages, modules, files, and symbols;
112
+ - APIs, endpoints, schemas, events, queues, and databases;
113
+ - containers, deployments, environments, pipelines, and infrastructure;
114
+ - documentation, architecture decisions, tests, and owners.
115
+
116
+ Relations include `contains`, `imports`, `depends-on`, `calls`, `exposes`,
117
+ `implements`, `reads-from`, `writes-to`, `publishes`, `consumes`, `deploys`,
118
+ `documents`, `decided-by`, `tests`, and `owns`.
119
+
120
+ Every entity and relation carries portable proof references. A proof records its
121
+ provider, source artifact, optional pointer/line, content hash, freshness,
122
+ derivation, trust, and confidence. Secret values and machine-local absolute
123
+ paths are excluded from the portable graph contract.
124
+
125
+ ## Model first, graph second
126
+
127
+ The canonical direction is one-way:
128
+
129
+ ```text
130
+ Workspace sources
131
+
132
+ Canonical Workspace Model + project topology
133
+
134
+ Evidence-backed Workspace Knowledge Graph
135
+
136
+ CLI queries · Context · MCP · Agents · IDEs · CI
137
+ ```
138
+
139
+ The graph does not rewrite or replace the canonical Workspace Model. It is a
140
+ derived representation bound to an exact model revision by SHA-256. Context and
141
+ MCP consumers reject a graph whose source hash no longer matches the model.
142
+
143
+ The model also contains a smaller project dependency graph. That projection is
144
+ used for impact, blast radius, verify, explain, watch, and affected fleet runs.
145
+ The richer Knowledge Graph is used for proof-backed retrieval and cross-domain
146
+ understanding.
147
+
148
+ ## Sources and providers
149
+
150
+ The current CLI uses bounded providers for:
151
+
152
+ - workspace/project foundations and service contracts;
153
+ - language-neutral source structure and package manifests;
154
+ - OpenAPI, GraphQL, Protobuf, and AsyncAPI interfaces;
155
+ - Docker/Compose, Kubernetes, Terraform, and CI workflows;
156
+ - README/docs, ADRs, tests, and CODEOWNERS.
157
+
158
+ Providers emit facts and proofs. The graph engine owns stable identity,
159
+ deduplication, typed relations, reconciliation, quality metrics, diagnostics,
160
+ and deterministic ordering. Regex-backed source observations are explicitly
161
+ marked as observed/medium-confidence; authored contracts remain authoritative.
162
+
163
+ ## Outputs and consumers
164
+
165
+ `workspace model --write` publishes these two artifacts atomically:
166
+
167
+ ```text
168
+ .workspai/reports/workspace-model.json
169
+ .workspai/reports/workspace-knowledge-graph.json
170
+ ```
171
+
172
+ The Knowledge Graph is consumed by:
173
+
174
+ - `workspace graph search|entities|evidence|path|overlay`;
175
+ - `workspace context`, which validates the model hash and publishes graph
176
+ availability and query commands;
177
+ - `workspace agent-sync`, which places it in the evidence index and generated
178
+ agent/MCP instructions;
179
+ - `workspace mcp serve`, through `getWorkspaceKnowledgeGraph`,
180
+ `searchWorkspaceGraph`, `queryWorkspaceEntities`,
181
+ `getWorkspaceGraphEvidence`, and `findWorkspaceGraphPath`;
182
+ - `workspace contract graph`, which exposes the contract projection, project
183
+ topology, rich graph, and quality summary in one response.
184
+
185
+ The complete graph is an interchange artifact, not a prompt. Agents should
186
+ start with `INDEX.json`, use bounded search, then retrieve evidence or a path
187
+ for the selected result.
188
+
189
+ ## AI tool output locations
190
+
191
+ `workspace agent-sync --write --preset enterprise` generates native surfaces
192
+ without changing project source:
193
+
194
+ | Consumer | Canonical output |
195
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
196
+ | Cross-tool/Codex | `AGENTS.md`, `.workspai/reports/INDEX.json` |
197
+ | Claude Code | `CLAUDE.md`, `.claude/rules/workspai-evidence.md` |
198
+ | GitHub Copilot/VS Code | `.github/copilot-instructions.md`, `.github/instructions/workspai-*.instructions.md`, `.github/agents/workspai-*.agent.md`, `.github/prompts/workspai-*.prompt.md` |
199
+ | Cursor | `.cursor/rules/workspai-grounding.mdc` |
200
+ | MCP clients | `.workspai/reports/workspai-mcp-design.json`, `workspace mcp serve` |
201
+
202
+ Files named `rapidkit-*` are compatibility aliases for older consumers. They
203
+ must stay narrowly scoped and must not duplicate an always-applied canonical
204
+ rule.
205
+
206
+ ### Avoiding duplicate AI instructions
207
+
208
+ Canonical Workspai rules are the only always-applied surfaces. Legacy RapidKit
209
+ aliases point to the canonical files and apply only to `.rapidkit/**`. This
210
+ prevents two equivalent instruction files from being injected into one prompt.
211
+
212
+ The recommended read order is:
213
+
214
+ 1. `AGENTS.md` for stable workspace policy and navigation;
215
+ 2. `.workspai/reports/INDEX.json` for artifact discovery and freshness;
216
+ 3. `workspace graph search` or `searchWorkspaceGraph` for question-sized facts;
217
+ 4. `workspace graph evidence|path` when a claim needs proof;
218
+ 5. the complete model or graph only for export, audit, or whole-system analysis.
219
+
220
+ ## Performance and scale
221
+
222
+ Graph construction inventories each project once per build and caps the number
223
+ of scanned files. Providers reuse the same in-memory inventory and content
224
+ hashes. Query indexes are cached per immutable graph object; replacing the graph
225
+ is the invalidation boundary. `workspace model --cache` and `--incremental`
226
+ avoid unnecessary model/project work when inputs are unchanged.
227
+
228
+ Use full graph export for interchange or offline analysis. Use bounded search
229
+ for interactive agents. The latter keeps response size proportional to the
230
+ question instead of workspace size.
231
+
232
+ ## Measuring retrieval payload reduction
233
+
234
+ Workspai does not publish an unqualified “N× fewer tokens” claim. Such a claim
235
+ depends on the workspace, query, tokenizer, model, answer-quality target, and
236
+ baseline.
237
+
238
+ Measure the current workspace instead:
239
+
240
+ ```bash
241
+ npx workspai workspace graph benchmark "authentication endpoint" --limit 12 --json
242
+ ```
243
+
244
+ The report compares the readable, proof-indexed source corpus with the bounded
245
+ search payload using a clearly labelled `characters / 4` token estimate. It
246
+ reports corpus size, retrieval size, estimated ratio, percentage reduction,
247
+ unreadable artifacts, query, limit, graph counts, and the exact source-model
248
+ SHA-256 needed to reproduce the run.
249
+
250
+ This proves **retrieval payload reduction**, not equivalent answer quality,
251
+ model-specific billing savings, or universal token savings. A publishable
252
+ cross-project claim additionally requires pinned source revisions, fixed
253
+ queries, a real tokenizer, repeated runs, and answer-quality evaluation.
254
+
255
+ In the current 16-project development fixture, the query `api endpoint` with
256
+ `--limit 8` returned 8 entities and 9 proofs. The compact retrieval was 2,812
257
+ estimated tokens versus 134,105 estimated tokens in 392 readable proof-source
258
+ artifacts: an observed 47.69× / 97.9% payload reduction. This is a transparent
259
+ fixture result, not a headline claim for every workspace.
260
+
261
+ See [Graph Benchmark Methodology](./graph-benchmark-methodology.md) for formulas,
262
+ reproduction rules, realistic baselines, and the gate required before publishing
263
+ a general performance claim.
264
+
265
+ ## Current boundaries
266
+
267
+ - The CLI graph is intentionally file-backed; a graph database is not required.
268
+ - Text search is deterministic lexical retrieval, not embedding similarity.
269
+ - Compiler/LSP-grade symbol resolution belongs in deeper language providers.
270
+ - Missing project edges mean “relationship not proven,” not “projects are
271
+ independent.” Author service contracts or provide API/package/runtime
272
+ evidence to close that gap.
273
+ - The standalone `@workspai/graph` package remains unpublished while its public
274
+ contracts and conformance gates are developed.
275
+
276
+ ## When the graph looks incomplete
277
+
278
+ Workspai does not invent relationships. If projects appear as disconnected
279
+ nodes, check the following in order:
280
+
281
+ 1. run `workspace sync --json` and regenerate the model;
282
+ 2. declare `dependsOn`, APIs, published events, and consumed events in the
283
+ workspace/project contracts;
284
+ 3. confirm package manifests, OpenAPI/AsyncAPI/GraphQL/Protobuf documents,
285
+ Compose/Kubernetes/Terraform files, and CI definitions are inside registered
286
+ project paths;
287
+ 4. inspect `graph.quality`, `providers`, and `diagnostics` before treating a
288
+ missing edge as proof of independence.
289
+
290
+ An absent edge means “not proven by current evidence,” not “no dependency
291
+ exists.”
292
+
293
+ For schemas and machine contracts, see the
294
+ [Artifact Catalog](./contracts/ARTIFACT_CATALOG.md). For the full command
295
+ surface, see [Commands Reference](./commands-reference.md).
@@ -7,7 +7,9 @@ Command syntax: [commands-reference.md](./commands-reference.md).
7
7
  ## Import and adoption
8
8
 
9
9
  Use `import` to copy or clone an existing project into a Workspai workspace.
10
- Use `adopt` when the project must stay where it already lives but should become visible to RapidKit and Workspai workspace intelligence.
10
+ Use `adopt` when the project must stay where it already lives but should become
11
+ visible to Workspai Workspace Intelligence. Core module commands remain limited
12
+ to projects whose existing RapidKit metadata identifies a module-enabled kit.
11
13
 
12
14
  ```bash
13
15
  npx workspai import ../orders-api
@@ -20,24 +22,24 @@ npx workspai adopt --json
20
22
  ### Import behavior
21
23
 
22
24
  - Local folders are copied; git sources are cloned with shallow history.
23
- - Outside any workspace (no `--workspace`), Workspai auto-creates/reuses the managed workspace at `~/.workspai/workspaces/workspai`.
24
- - Existing workspaces under `~/rapidkit/workspaces/*` and `~/Workspai/rapidkits/*` remain registered after upgrade.
25
+ - Outside any workspace (no `--workspace`), Workspai creates or reuses the managed `workspai` workspace. New defaults use `~/.workspai/workspaces/workspai`; valid legacy candidates under `~/rapidkit/workspaces/workspai` and `~/Workspai/rapidkits/workspai` can still be reused.
26
+ - Existing workspaces under legacy managed roots remain registered after upgrade.
25
27
  - CLI prints a next-step `cd ...` hint (`suggestedCdCommand` in JSON mode).
26
28
  - Failed workspace sync rolls back imported files and registry entries.
27
29
 
28
30
  ### Adopt behavior
29
31
 
30
32
  - Source files are not moved or copied.
31
- - Default workspace resolution matches import (`workspai` under `~/.workspai/workspaces/`).
33
+ - Default workspace resolution matches import, including canonical creation and valid legacy managed-default reuse.
32
34
  - Writes `.workspai/project.json`, `.workspai/adopt.json`, and `.workspai/adopt-readiness.json`.
33
35
  - Registry and contract sync include adopted projects for `workspace model`, `workspace context`, Dashboard, and agents.
34
36
  - `--dry-run --json` previews detection without writing metadata.
35
37
 
36
38
  ### JSON output (`--json`)
37
39
 
38
- - `workspacePath`, `workspaceResolution` (`explicit` | `nearest` | `default-auto`)
39
- - `defaultWorkspaceCreated`, `suggestedCdCommand`
40
- - `importedProject` or `adoptedProject` (`name`, `path`, `stack`, `runtime`, `framework`, `supportTier`, `moduleSupport`, `confidence`, `source`)
40
+ - Import returns `workspacePath`, `workspaceResolution`, `defaultWorkspaceCreated`, `suggestedCdCommand`, and `importedProject`. The imported project includes its `source`.
41
+ - Adopt returns `workspacePath`, `workspaceResolution`, `defaultWorkspaceCreated`, `wouldCreateDefaultWorkspace`, `dryRun`, and `adoptedProject`.
42
+ - Project results include detected `name`, `path`, `stack`, `runtime`, `framework`, `supportTier`, `moduleSupport`, and `confidence` where available.
41
43
 
42
44
  Imported projects receive `.workspai/import-readiness.json`. Adopted projects add frontend-aware detection for Next.js, React, Vite, Vue, Angular, SvelteKit, Nuxt, Astro, Remix, and Solid.
43
45
 
@@ -92,6 +94,55 @@ npx workspai workspace contract graph
92
94
 
93
95
  Contract file: `.workspai/workspace.contract.json`. Verification checks schema, duplicate slugs, port collisions, and unknown dependencies.
94
96
 
97
+ `workspace contract graph --json` preserves its original `nodes`, `edges`, and
98
+ summary fields for existing consumers, and now adds an evidence-backed
99
+ `dependencyGraph` using the public `workspace-dependency-graph.v1` contract. It
100
+ discovers package/workspace dependencies and supported cross-project imports,
101
+ records relationship provenance and confidence, and reports graph coverage,
102
+ orphans, hotspots, and cycles. Project nodes also expose safe package metadata,
103
+ public environment-template keys, command capabilities, key manifests,
104
+ entrypoints, API specifications, infrastructure, documentation, and an
105
+ operational verification profile. Environment values are never emitted.
106
+
107
+ The same response also exposes `knowledgeGraph` under the public
108
+ `workspace-knowledge-graph.v1` contract. It is a provider-neutral,
109
+ proof-carrying view spanning source structure, packages, service and API
110
+ contracts, infrastructure, delivery pipelines, docs/ADRs, ownership, tests,
111
+ runtime resources, and safe configuration keys. Use the dedicated query and
112
+ change-overlay surfaces when the full document is larger than a human needs:
113
+
114
+ ```bash
115
+ npx workspai workspace graph entities endpoint --json
116
+ npx workspai workspace graph search "authentication endpoint" --limit 12 --json
117
+ npx workspai workspace graph benchmark "authentication endpoint" --limit 12 --json
118
+ npx workspai workspace graph evidence "GET /users" --json
119
+ npx workspai workspace graph path frontend-api "GET /users" --json
120
+ npx workspai workspace graph emit --json > .workspai/reports/knowledge-baseline.json
121
+ npx workspai workspace graph overlay --from .workspai/reports/knowledge-baseline.json --json
122
+ ```
123
+
124
+ The Model step persists the same projection to
125
+ `.workspai/reports/workspace-knowledge-graph.json`. It is registered in the
126
+ artifact contract registry and agent report index, required by the unified
127
+ runner's Model stage, referenced from `workspace-context-agent.json`, and
128
+ queryable through the read-mostly MCP server. This keeps CLI, CI, IDE and agent
129
+ consumers on one contract revision without injecting the full graph into every
130
+ agent prompt.
131
+
132
+ The overlay follows
133
+ `workspace-knowledge-graph-change-overlay.v1`: graph revisions are identified
134
+ by content-derived fingerprints (timestamps do not create false changes), and
135
+ changed artifacts are portable proof paths rather than machine-local absolute
136
+ paths. Proof additions, removals, and content-hash changes are first-class
137
+ overlay changes, so a source edit is visible even when the entity and relation
138
+ shape remains stable. The builder performs one bounded inventory pass per project and reuses
139
+ in-memory content hashes; query indexes live only for the immutable graph
140
+ instance, so replacing the graph is the invalidation boundary.
141
+
142
+ Direction is explicit: legacy `edges` remain producer-to-consumer for backward
143
+ compatibility; `dependencyGraph.edges` use consumer-to-dependency semantics so
144
+ impact and blast-radius consumers share one canonical interpretation.
145
+
95
146
  Workspai keeps the contract alive during `create project` and `workspace sync` without overwriting manual API/event/owner declarations.
96
147
 
97
148
  On a freshly cloned or moved workspace, `workspace sync` also repairs the
@@ -115,16 +166,24 @@ Export excludes dependency folders, build output, git history, logs, `.env`, and
115
166
 
116
167
  Archive export, verification, and hydrate stream file payloads instead of loading the workspace into memory. Exports use ZIP64, so multi-gigabyte workspaces and archives with more than 65,535 files are supported. Stored ZIP entries are the default; use `--archive-compression deflate` when transfer size matters more than export CPU time.
117
168
 
118
- Workspace size is unrestricted by default. For untrusted remote archives, optional operational budgets can be set without imposing a product-wide workspace limit:
169
+ Remote archives are protected by secure defaults: 5 GB maximum download, 20 GB
170
+ maximum expanded payload, 200,000 entries, per-entry and compression-ratio
171
+ guards, and a five-minute timeout. Public HTTPS destinations are accepted;
172
+ loopback, private, link-local, and private redirect destinations are rejected.
173
+ Budgets can be lowered or explicitly raised for a controlled workflow:
119
174
 
120
175
  ```bash
121
176
  npx workspai workspace hydrate https://example.test/team.zip \
122
177
  --output ./team-workspace \
123
- --max-download-size 100gb \
124
- --max-expanded-size 500gb \
125
- --download-timeout-ms 21600000
178
+ --max-download-size 2gb \
179
+ --max-expanded-size 8gb \
180
+ --download-timeout-ms 120000
126
181
  ```
127
182
 
183
+ For a reviewed archive served from a private development network, opt in with
184
+ `--allow-private-network`. Never use that flag for user-controlled URLs in CI
185
+ or agent services.
186
+
128
187
  IDE, CI, and AI consumers can discover archive behavior from
129
188
  `contracts/workspace-archive-capabilities.v1.json`. The embedded manifest and every successful
130
189
  `--json` operation result are runtime-validated against
@@ -162,12 +221,20 @@ Artifacts:
162
221
  | `import` | Workspace ingestion | Rollback-safe sync |
163
222
  | `adopt` | Workspace adoption | In-place linking + registry sync |
164
223
  | `workspace model/context/diff/impact/verify` | Workspace intelligence | Model, context packs, blast radius |
224
+ | `workspace intelligence run` | Workspace intelligence | Canonical contract-backed chain and strict gate |
165
225
  | `snapshot` | Workspace recovery | Metadata or full snapshots |
166
226
  | `project archive/restore/delete` | Project lifecycle | Safe delete with confirmation |
167
227
  | `doctor` / `doctor workspace` / `doctor project` | Wrapper health | Host, workspace, and project scopes |
168
228
  | `workspace run` | Workspace orchestrator | Fleet stage execution |
169
229
  | `infra` | Workspace sidecar | Contract-driven local dependencies |
170
230
 
231
+ The unified intelligence runner keeps `sync` and baseline resolution in a
232
+ separate two-entry execution envelope and emits exactly 11 canonical stages.
233
+ Exit `2` means the evidence gate blocked readiness after successful execution;
234
+ exit `1` means a hard runtime failure. Read the complete
235
+ [Unified Workspace Intelligence Runner contract](./workspace-intelligence-runner.md)
236
+ before consuming its report from CI, IDE, or agent integrations.
237
+
171
238
  ## Verification evidence freshness
172
239
 
173
240
  `workspace verify` treats evidence as release-gate material, not just as a file
@@ -11,7 +11,10 @@ npx workspai workspace run test --affected --blast-radius
11
11
  npx workspai workspace run build --json --max-workers 8
12
12
  ```
13
13
 
14
- `--blast-radius` uses `.workspai/workspace.contract.json` (and legacy `.rapidkit/workspace-dependency-graph.json` as fallback) to expand direct `dependsOn` and publish/consume event relationships.
14
+ `--blast-radius` resolves the canonical or legacy workspace contract first, then
15
+ `.workspai/workspace-dependency-graph.json`, and finally the legacy
16
+ `.rapidkit/workspace-dependency-graph.json` fallback. It expands direct
17
+ `dependsOn` and publish/consume event relationships.
15
18
 
16
19
  ## Supported runtimes
17
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspai",
3
- "version": "0.45.0",
3
+ "version": "0.47.0",
4
4
  "type": "module",
5
5
  "description": "Open-source workspace intelligence CLI for software systems: create, adopt, govern, verify, and align polyglot workspaces for humans, CI, IDEs, and AI agents.",
6
6
  "keywords": [
@@ -64,8 +64,8 @@
64
64
  "access": "public"
65
65
  },
66
66
  "scripts": {
67
- "preinstall": "node scripts/enforce-package-manager.cjs",
68
67
  "postinstall": "node scripts/check-cli-resolution.cjs",
68
+ "check:package-manager": "node scripts/enforce-package-manager.cjs",
69
69
  "sync-kits": "bash scripts/sync-kits.sh",
70
70
  "sync:kits": "corepack npm run sync-kits",
71
71
  "build": "tsup",
@@ -77,7 +77,8 @@
77
77
  "prepare": "node scripts/prepare-husky.mjs",
78
78
  "test:e2e:first-install": "bash scripts/e2e-first-install.sh",
79
79
  "test:e2e:user-first-install": "bash scripts/e2e-user-first-install.sh",
80
- "test": "vitest run",
80
+ "test:prebuild": "tsup",
81
+ "test": "corepack npm run test:prebuild && vitest run",
81
82
  "test:drift": "node scripts/run-drift-guard.mjs",
82
83
  "benchmark:intelligence": "vitest run src/__tests__/workspace-intelligence-benchmark.test.ts",
83
84
  "sync:shared-contracts": "node scripts/sync-shared-contracts.mjs",
@@ -90,7 +91,7 @@
90
91
  "validate:contracts": "corepack npm run check:shared-contracts && vitest run src/__tests__/contracts/",
91
92
  "test:parity-contract": "corepack npm run check:shared-contracts && vitest run src/__tests__/contracts/import-stack-parity.snapshot.test.ts",
92
93
  "test:watch": "vitest",
93
- "test:coverage": "vitest run --coverage",
94
+ "test:coverage": "vitest run --coverage --reporter=default --reporter=json --outputFile.json=test-results/vitest.json",
94
95
  "test:prepare-embeddings": "node scripts/prepare-mock-embeddings.mjs",
95
96
  "generate-embeddings": "npx tsx src/ai/generate-embeddings.ts",
96
97
  "verify:package-cli": "node scripts/verify-package-cli.mjs",
@@ -111,10 +112,10 @@
111
112
  "format": "prettier --write \"src/**/*.ts\"",
112
113
  "format:check": "prettier --check \"src/**/*.ts\"",
113
114
  "typecheck": "tsc --noEmit",
114
- "validate": "corepack npm run typecheck && corepack npm run lint && corepack npm run format:check && corepack npm test",
115
+ "validate": "corepack npm run check:package-manager && corepack npm run typecheck && corepack npm run lint && corepack npm run format:check && corepack npm test",
115
116
  "security": "corepack npm audit --audit-level=moderate",
116
117
  "security:fix": "corepack npm audit fix",
117
- "metrics": "npx tsx scripts/metrics.ts",
118
+ "metrics": "tsx scripts/metrics.ts",
118
119
  "validate:docs-examples": "node scripts/validate-doc-examples.mjs",
119
120
  "check:markdown-links": "node scripts/check-markdown-links.mjs",
120
121
  "check:docs-drift": "node scripts/docs-drift-guard.mjs",
@@ -128,13 +129,13 @@
128
129
  "analyze": "corepack npm run build && node scripts/analyze-dist.mjs",
129
130
  "size-check": "corepack npm run build && size-limit",
130
131
  "bench": "npx tsx scripts/benchmarks.ts",
131
- "quality": "corepack npm run typecheck && corepack npm run lint && corepack npm run format:check && corepack npm test && corepack npm run size-check && corepack npm run check:workspace-intelligence-runtime && corepack npm run check:workspace-intelligence-adversarial && corepack npm run security && corepack npm run validate:docs && corepack npm run smoke:frontend-generators && corepack npm run check:contracts && corepack npm run check:shared-contracts && corepack npm run check:parity-snapshot && corepack npm run check:agent-customization-drift",
132
+ "quality": "corepack npm run check:package-manager && corepack npm run typecheck && corepack npm run lint && corepack npm run format:check && corepack npm test && corepack npm run size-check && corepack npm run check:workspace-intelligence-runtime && corepack npm run check:workspace-intelligence-adversarial && corepack npm run security && corepack npm run validate:docs && corepack npm run smoke:frontend-generators && corepack npm run check:contracts && corepack npm run check:shared-contracts && corepack npm run check:parity-snapshot && corepack npm run check:agent-customization-drift",
132
133
  "act-matrix": "act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P macos-latest=ghcr.io/catthehacker/ubuntu:act-22.04 -P windows-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false -j build-test-matrix",
133
134
  "release:dry": "bash scripts/release.sh --no-publish --yes --allow-dirty",
134
135
  "release:patch": "bash scripts/release.sh patch",
135
136
  "release:minor": "bash scripts/release.sh minor",
136
137
  "release:major": "bash scripts/release.sh major",
137
- "check": "corepack npm run check:windows-registry && corepack npm run typecheck && corepack npm run lint && corepack npm run format:check",
138
+ "check": "corepack npm run check:package-manager && corepack npm run check:windows-registry && corepack npm run typecheck && corepack npm run lint && corepack npm run format:check && corepack npm run test:coverage && corepack npm run metrics",
138
139
  "ci": "corepack npm run quality",
139
140
  "contracts:sync": "corepack npm run sync:contracts && corepack npm run sync:shared-contracts",
140
141
  "contracts:check": "corepack npm run check:contracts && corepack npm run check:shared-contracts && corepack npm run check:parity-snapshot && corepack npm run check:generated-contracts && corepack npm run check:agent-customization-drift",
@@ -157,6 +158,7 @@
157
158
  "openai": "^6.22.0",
158
159
  "ora": "^8.0.1",
159
160
  "validate-npm-package-name": "^5.0.1",
161
+ "yaml": "^2.9.0",
160
162
  "yauzl": "^3.4.0",
161
163
  "yazl": "^3.3.1"
162
164
  },
@@ -19,9 +19,9 @@ module.exports = {
19
19
  // Default author name for new workspaces
20
20
  defaultAuthor: 'Your Name or Team',
21
21
 
22
- // Default Python version to use
23
- // Options: '3.10' | '3.11' | '3.12'
24
- pythonVersion: '3.10',
22
+ // Optional version pin. Python 3.10 is the minimum supported version.
23
+ // Omit this setting to let Workspai detect and select an installed version.
24
+ // pythonVersion: '3.10',
25
25
 
26
26
  // Default installation method for RapidKit Core
27
27
  // Options: 'poetry' | 'venv' | 'pipx'
@@ -53,10 +53,10 @@ module.exports = {
53
53
 
54
54
  // Example usage:
55
55
  // npx workspai my-workspace
56
- // -> Uses config: author='Your Name or Team', pythonVersion='3.10', installMethod='poetry'
56
+ // -> Uses config: author='Your Name or Team', installMethod='poetry'; Python is auto-detected
57
57
  //
58
58
  // npx workspai my-workspace --author "Different Author"
59
- // -> Overrides: author='Different Author', but still uses pythonVersion='3.10', installMethod='poetry'
59
+ // -> Overrides author; installMethod remains 'poetry' and Python is auto-detected
60
60
  //
61
61
  // npx workspai create project my-api
62
62
  // -> Uses config: defaultKit='fastapi.standard', adds default modules
@@ -4,7 +4,7 @@ const userAgent = process.env.npm_config_user_agent || '';
4
4
  const usingNpm = userAgent.startsWith('npm/');
5
5
 
6
6
  if (!usingNpm) {
7
- console.error('Workspai uses npm as the only supported package manager for development.');
7
+ console.error('Workspai uses npm as the only supported package manager for development.');
8
8
  console.error('Please run: npm install');
9
9
  process.exit(1);
10
10
  }
@@ -33,6 +33,10 @@ if (!fs.existsSync(tsupCli)) {
33
33
  fail(`missing tsup CLI at ${tsupCli}; run npm ci before packaging`);
34
34
  }
35
35
 
36
+ runNode(
37
+ ['scripts/generate-shared-contracts.mjs', '--check'],
38
+ 'checking generated contracts, including extension CLI compatibility'
39
+ );
36
40
  runNode([tsupCli], 'building dist');
37
41
  runNode(['scripts/prepare-mock-embeddings.mjs'], 'preparing packaged embeddings');
38
42
  runNode(['scripts/verify-package-cli.mjs'], 'verifying bundled CLI command ownership');