workspai 0.66.0 → 0.68.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 (149) hide show
  1. package/README.md +24 -22
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
  3. package/contracts/extension-cli-compatibility.v1.json +4 -0
  4. package/contracts/published-contract-catalog.v1.json +20 -0
  5. package/contracts/runtime-command-surface.v1.json +55 -2
  6. package/contracts/workspace-activity-board.v1.json +120 -0
  7. package/contracts/workspace-activity-event.v1.json +31 -1
  8. package/contracts/workspace-activity-monitor-fleet.v1.json +18 -0
  9. package/contracts/workspace-activity-monitor-snapshot.v1.json +194 -0
  10. package/contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json +196 -0
  11. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +1 -0
  12. package/contracts/workspace-intelligence-architecture.v1.json +17 -0
  13. package/contracts/workspace-intelligence-chain.v1.json +17 -0
  14. package/dist/analyze-JDEWUBC6.js +1 -0
  15. package/dist/{artifact-remediation-plan-M2XBS2IU.js → artifact-remediation-plan-I7IKC5MR.js} +1 -1
  16. package/dist/autopilot-release-OELUFNLL.js +1 -0
  17. package/dist/capabilities-command-RAAYENQ6.js +1 -0
  18. package/dist/chunk-25AWHAB5.js +2 -0
  19. package/dist/{chunk-QGAPGZPL.js → chunk-2C5XJBYI.js} +1 -1
  20. package/dist/{chunk-PJPS7CNH.js → chunk-2KX6KHEC.js} +1 -1
  21. package/dist/{chunk-JZJBA2V2.js → chunk-2MTJWPQ4.js} +1 -1
  22. package/dist/chunk-3BMYMZQB.js +1 -0
  23. package/dist/{chunk-VA5VSOBL.js → chunk-3KU3YUWD.js} +1 -1
  24. package/dist/{chunk-UPIPSSXY.js → chunk-3NF3M3RE.js} +1 -1
  25. package/dist/chunk-3OGPTLI2.js +1 -0
  26. package/dist/{chunk-EHH4SKVH.js → chunk-3XF7O66C.js} +3 -3
  27. package/dist/{chunk-WTWRSEOW.js → chunk-3Z4SVBMR.js} +1 -1
  28. package/dist/{chunk-NVND4727.js → chunk-46QH3ZVI.js} +1 -1
  29. package/dist/{chunk-XQFWUM2P.js → chunk-4WVOAX2V.js} +1 -1
  30. package/dist/{chunk-727IQFGN.js → chunk-5ME4W4LN.js} +1 -1
  31. package/dist/{chunk-IVF6NEHS.js → chunk-5OV2WXAR.js} +1 -1
  32. package/dist/{chunk-R2M5OJOK.js → chunk-5XUAAQSV.js} +2 -2
  33. package/dist/{chunk-IIFFEEMX.js → chunk-5YZ2W57R.js} +1 -1
  34. package/dist/{chunk-B4IVVTMQ.js → chunk-64XWHDZ3.js} +1 -1
  35. package/dist/{chunk-AP4PV6WJ.js → chunk-6E2Y3XGT.js} +1 -1
  36. package/dist/{chunk-4XEH3WNV.js → chunk-7DDEMDG2.js} +1 -1
  37. package/dist/{chunk-YX5VWPR5.js → chunk-7DZNZ3GM.js} +1 -1
  38. package/dist/{chunk-OI2VOU6S.js → chunk-BG6IX6HA.js} +1 -1
  39. package/dist/{chunk-6JX56VAL.js → chunk-BHM6RHTA.js} +1 -1
  40. package/dist/chunk-BMAFHX6A.js +1 -0
  41. package/dist/{chunk-3NM3JAZW.js → chunk-BUYLM6QV.js} +1 -1
  42. package/dist/{chunk-GAYK3WGV.js → chunk-C2VTO5WT.js} +1 -1
  43. package/dist/chunk-CPR2CMOY.js +1 -0
  44. package/dist/{chunk-PD7Y6HIM.js → chunk-CSZPE637.js} +1 -1
  45. package/dist/{chunk-5OA33JH2.js → chunk-D5LLTUTY.js} +1 -1
  46. package/dist/{chunk-3H5ACWWZ.js → chunk-DFVG4DDZ.js} +1 -1
  47. package/dist/{chunk-5XGR3LRI.js → chunk-EHLGPLIU.js} +1 -1
  48. package/dist/{chunk-334J2KIP.js → chunk-FPDH3N3A.js} +1 -1
  49. package/dist/{chunk-D4UHRJAP.js → chunk-FX5J6JCK.js} +1 -1
  50. package/dist/{chunk-DUBOKZMA.js → chunk-GVQKAINC.js} +12 -12
  51. package/dist/{chunk-XESFJN52.js → chunk-IKUFNK46.js} +1 -1
  52. package/dist/{chunk-AXUA7PFV.js → chunk-IXXQMD34.js} +1 -1
  53. package/dist/{chunk-HJLGXFMK.js → chunk-JYMO7QXQ.js} +1 -1
  54. package/dist/{chunk-JRP6WP5C.js → chunk-KDY4X7SQ.js} +1 -1
  55. package/dist/{chunk-L5Q2S5GY.js → chunk-KFTJVVJR.js} +1 -1
  56. package/dist/{chunk-SX6A656X.js → chunk-KY2GOSO5.js} +1 -1
  57. package/dist/chunk-LDBULT2T.js +4 -0
  58. package/dist/{chunk-VQOWB26M.js → chunk-LEOFD3W5.js} +1 -1
  59. package/dist/{chunk-L5CCIIF2.js → chunk-N5HPMATQ.js} +1 -1
  60. package/dist/{chunk-2PACEMNE.js → chunk-OFYY4725.js} +1 -1
  61. package/dist/{chunk-O37UBRMX.js → chunk-P3622IM5.js} +1 -1
  62. package/dist/{chunk-TABXSDTR.js → chunk-PKKSRXUS.js} +1 -1
  63. package/dist/{chunk-ZQH2I5RQ.js → chunk-Q7UGDNSM.js} +1 -1
  64. package/dist/{chunk-HLWDIIWL.js → chunk-QMQBX3RV.js} +1 -1
  65. package/dist/{chunk-TTHO4MFC.js → chunk-RVAOJOXA.js} +1 -1
  66. package/dist/{chunk-H5RJCS5E.js → chunk-SLFOUSRW.js} +1 -1
  67. package/dist/{chunk-7FF5EOIO.js → chunk-TCLKGPXF.js} +1 -1
  68. package/dist/chunk-TMRCPT7S.js +1 -0
  69. package/dist/{chunk-EP4CUWOO.js → chunk-VIN7NJW3.js} +1 -1
  70. package/dist/chunk-W37NOQVG.js +1 -0
  71. package/dist/chunk-W5VKBDSD.js +157 -0
  72. package/dist/{chunk-UOCERSAN.js → chunk-WRZSQDZV.js} +1 -1
  73. package/dist/{chunk-ECLMYTWT.js → chunk-Y4Z6CEII.js} +1 -1
  74. package/dist/{chunk-6UNATTB7.js → chunk-ZGHJIQXL.js} +1 -1
  75. package/dist/{create-SOLLXXAB.js → create-U5PQHOZ4.js} +1 -1
  76. package/dist/{demo-kit-5UQH2OXC.js → demo-kit-RKTHTXHJ.js} +1 -1
  77. package/dist/{doctor-NQ5PUCUP.js → doctor-D7YI7LSA.js} +1 -1
  78. package/dist/{dotnet-webapi-clean-YEHYIGOT.js → dotnet-webapi-clean-XL4IBUQV.js} +1 -1
  79. package/dist/{goal-lifecycle-IPNY7KNR.js → goal-lifecycle-BMS6GSIU.js} +1 -1
  80. package/dist/{goal-pack-2WV3EA4Y.js → goal-pack-RBSVQMMX.js} +1 -1
  81. package/dist/{gofiber-standard-C44IIQYH.js → gofiber-standard-OHHMCNMJ.js} +1 -1
  82. package/dist/{gogin-standard-X7VKACVR.js → gogin-standard-BAZXPOKL.js} +1 -1
  83. package/dist/index.d.ts +14 -2
  84. package/dist/index.js +129 -129
  85. package/dist/live-command-GNAASZ7U.js +15 -0
  86. package/dist/{pipeline-MIMENSI7.js → pipeline-QOMXH2EK.js} +1 -1
  87. package/dist/{project-agent-entry-OWLJ3IHQ.js → project-agent-entry-MH7364BE.js} +1 -1
  88. package/dist/{project-intelligence-lens-I67EO6AE.js → project-intelligence-lens-ZCCHUKVI.js} +1 -1
  89. package/dist/{project-test-coverage-OPDVSFPH.js → project-test-coverage-JPWTBSSJ.js} +1 -1
  90. package/dist/{rust-axum-JKZTZDRZ.js → rust-axum-CCJ6UCBW.js} +1 -1
  91. package/dist/{springboot-standard-PI4FLTAN.js → springboot-standard-M5JQEJML.js} +1 -1
  92. package/dist/{verified-goal-46JWNCDY.js → verified-goal-XUXU2X5H.js} +1 -1
  93. package/dist/{workspace-KO37XHF6.js → workspace-B33BFZZ3.js} +1 -1
  94. package/dist/{workspace-agent-sync-32FIJQBH.js → workspace-agent-sync-T3MJO2MX.js} +1 -1
  95. package/dist/{workspace-archive-6R5DRNZW.js → workspace-archive-NOSGRKRZ.js} +1 -1
  96. package/dist/{workspace-context-JKRPX775.js → workspace-context-KOCEP4MJ.js} +1 -1
  97. package/dist/{workspace-contract-4T3NYNK5.js → workspace-contract-MQ3QE52V.js} +1 -1
  98. package/dist/workspace-explain-DTFCKYXK.js +1 -0
  99. package/dist/workspace-explain-contract-WMREJWHF.js +1 -0
  100. package/dist/{workspace-feedback-6VQ7T4CR.js → workspace-feedback-3YLIUFQ7.js} +1 -1
  101. package/dist/{workspace-foundation-GHWO3BZU.js → workspace-foundation-O7O3QIS4.js} +1 -1
  102. package/dist/{workspace-graph-stream-PTVS47NJ.js → workspace-graph-stream-XTGGBD7D.js} +1 -1
  103. package/dist/workspace-graph-token-efficiency-5LJKQU2J.js +1 -0
  104. package/dist/{workspace-history-M2K4M2JY.js → workspace-history-7HDZZ4G5.js} +1 -1
  105. package/dist/{workspace-intelligence-PJIPTXL3.js → workspace-intelligence-TFEQBPUP.js} +1 -1
  106. package/dist/workspace-intelligence-benchmark-PLVUBGWO.js +1 -0
  107. package/dist/workspace-intelligence-evaluation-OJIQS5SN.js +1 -0
  108. package/dist/{workspace-intelligence-runner-M47QR3JM.js → workspace-intelligence-runner-6ZAV6RO4.js} +1 -1
  109. package/dist/{workspace-intelligence-runtime-registry-FFGQF4A7.js → workspace-intelligence-runtime-registry-UKFB3BI7.js} +1 -1
  110. package/dist/{workspace-knowledge-graph-V2EAYDCL.js → workspace-knowledge-graph-AUXYL3L6.js} +1 -1
  111. package/dist/{workspace-knowledge-graph-contract-VANN7RCA.js → workspace-knowledge-graph-contract-X52KXBXJ.js} +1 -1
  112. package/dist/{workspace-knowledge-graph-query-RASPF7FS.js → workspace-knowledge-graph-query-A7TKONWY.js} +1 -1
  113. package/dist/workspace-knowledge-graph-snapshot-GPBDAKAU.js +1 -0
  114. package/dist/{workspace-mcp-serve-YRORNE4P.js → workspace-mcp-serve-TDUXJUAA.js} +1 -1
  115. package/dist/{workspace-model-VSVKLX7M.js → workspace-model-GVXNLSQM.js} +1 -1
  116. package/dist/{workspace-onboarding-2VMJZVLZ.js → workspace-onboarding-ECZ2KJ2A.js} +1 -1
  117. package/dist/{workspace-readme-6X3GLTBM.js → workspace-readme-6N5Y2ZSJ.js} +1 -1
  118. package/dist/{workspace-registry-summary-QVSJKKTX.js → workspace-registry-summary-5SFBTRGQ.js} +1 -1
  119. package/dist/{workspace-repair-engine-WSKV3Q4V.js → workspace-repair-engine-CKJCTWKX.js} +1 -1
  120. package/dist/workspace-run-ZZ5WHL7W.js +1 -0
  121. package/dist/{workspace-verify-EJCSOBIK.js → workspace-verify-D3QTMAUI.js} +1 -1
  122. package/dist/{workspace-watch-JTIFBF4Z.js → workspace-watch-XYJEW2Z2.js} +1 -1
  123. package/docs/DEVELOPMENT.md +19 -0
  124. package/docs/README.md +19 -16
  125. package/docs/ci-workflows.md +1 -1
  126. package/docs/commands-reference.md +20 -2
  127. package/docs/contracts/ARTIFACT_CATALOG.md +1 -0
  128. package/docs/contracts/README.md +3 -0
  129. package/docs/workspace-intelligence-benchmark.md +82 -0
  130. package/docs/workspace-knowledge-graph.md +1 -0
  131. package/docs/workspace-live-activity.md +29 -5
  132. package/package.json +4 -2
  133. package/dist/analyze-UJQWGNM2.js +0 -1
  134. package/dist/autopilot-release-U6F4M2BQ.js +0 -1
  135. package/dist/capabilities-command-XUKPO25Z.js +0 -1
  136. package/dist/chunk-5TY74LLW.js +0 -2
  137. package/dist/chunk-5U4L6VF2.js +0 -1
  138. package/dist/chunk-C4S22E6S.js +0 -1
  139. package/dist/chunk-H7MRINGP.js +0 -1
  140. package/dist/chunk-JC4XSU7G.js +0 -1
  141. package/dist/chunk-MZ7U4BIQ.js +0 -157
  142. package/dist/chunk-UTV4DTNM.js +0 -1
  143. package/dist/live-command-Q6E45N7S.js +0 -18
  144. package/dist/workspace-explain-MOGL4GEA.js +0 -1
  145. package/dist/workspace-explain-contract-W2E6LF4Q.js +0 -1
  146. package/dist/workspace-graph-token-efficiency-Z5JD5NHI.js +0 -1
  147. package/dist/workspace-intelligence-evaluation-GONCRE6O.js +0 -1
  148. package/dist/workspace-knowledge-graph-snapshot-5YIG6EMG.js +0 -1
  149. package/dist/workspace-run-3BXKTLVL.js +0 -1
@@ -7,6 +7,7 @@ workspai live [target]
7
7
  workspai live --global [--max-scopes <count>]
8
8
  workspai live --run <run-id>
9
9
  workspai live --once --json
10
+ workspai live --once --json --projection monitor|board
10
11
  workspai live --no-motion --no-color
11
12
  workspai live --ascii|--accessible|--classic
12
13
  workspai live --capture <file.svg> [--capture-preset github|linkedin|x|square|wide]
@@ -22,6 +23,10 @@ Inspector, a deduplicated multi-workspace Fleet Cockpit, deterministic
22
23
  redacted-by-default SVG capture, durable replay, responsive compaction and
23
24
  changed-row rendering. Use `--accessible` for stable screen-reader output or
24
25
  `--classic` for the compatibility line view.
26
+ `--projection board` exposes the same bounded renderer-neutral run/node/edge
27
+ model used by the terminal and SVG adapters, so IDE and web consumers do not
28
+ need to reconstruct topology from raw events. The default `monitor` projection
29
+ is backward compatible.
25
30
  See [Workspai Live Activity](./workspace-live-activity.md).
26
31
 
27
32
  Human-readable CLI syntax for the Workspai CLI. The machine-complete command,
@@ -261,20 +266,33 @@ they never write facts back into the authorizing model during the same run.
261
266
 
262
267
  `workspace graph search <query> --limit <n> --json` returns bounded entities,
263
268
  one-hop relations, related entity summaries, and portable proofs instead of the
264
- complete graph. Ranking is deterministic and offline: it removes natural-language
269
+ complete graph. New responses also expose `graphSourceHash`, allowing IDE and
270
+ agent activity consumers to correlate returned entity/proof IDs only with the
271
+ exact Graph revision that authored them. Ranking is deterministic and offline: it removes natural-language
265
272
  stopwords, weights rarer graph terms more strongly, and prefers exact labels and
266
273
  identities. `workspace graph benchmark <query> --limit <n> --json` compares
267
274
  that retrieval payload with the readable proof-indexed corpus using a labelled
268
275
  `characters / 4` estimate. It measures payload reduction only; it does not
269
276
  assert equivalent answer quality or model-specific billing savings.
270
277
 
278
+ `workspace graph benchmark-suite agent-core.v1 --write --json` runs five fixed,
279
+ repository-neutral scenarios covering architecture, ownership, interfaces,
280
+ change safety, and delivery. It reads the proof corpus once, reports median and
281
+ p95 bounded retrieval sizes, and writes
282
+ `.workspai/reports/workspace-intelligence-benchmark-last-run.json`. If a
283
+ finalized `workspace eval` report exists, its usage and verified outcome are
284
+ attached under a separate provenance classification. Pass `--from
285
+ <baseline-evaluation>` only for a task-aligned comparison. A measured reduction
286
+ is emitted only when both runs use measured token sources and have comparable
287
+ verified outcomes. See [Workspace Intelligence Benchmark](./workspace-intelligence-benchmark.md).
288
+
271
289
  Add `--scope project:<name>` to retrieve project-owned facts plus
272
290
  workspace-level shared entities proven to be connected to that project. The
273
291
  `search` mode also accepts `--kind <entity-kind>` so agents can retrieve a
274
292
  precise semantic surface such as `runtime-unit`, `endpoint`, or `owner`. The
275
293
  agent projection reports explicit omission budgets for relations, related
276
294
  entities, proofs, aliases, attributes, and proof references. Read-oriented
277
- `search`, `entities`, `evidence`, `path`, and `benchmark` modes reuse the
295
+ `search`, `entities`, `evidence`, `path`, `benchmark`, and `benchmark-suite` modes reuse the
278
296
  persisted graph only when its model binding, proofs, project scopes, and live
279
297
  Git/Merkle input fingerprint still match. `--refresh-graph` bypasses that
280
298
  compatible snapshot and rebuilds from current sources.
@@ -137,6 +137,7 @@ Entries beginning with `reports/` are relative to `.workspai/`; paths such as
137
137
  | `workspace snapshot` | `workspace-model-snapshot.json` | `workspace-model-snapshot.v1` | `contracts/workspace-intelligence/workspace-model-snapshot.v1.json` |
138
138
  | `workspace diff` | `workspace-model-diff-last-run.json` | `workspace-model-diff.v1` | `contracts/workspace-intelligence/workspace-model-diff.v1.json` |
139
139
  | `workspace impact --from <diff>` | `workspace-impact-last-run.json` | `workspace-impact.v1` | `contracts/workspace-intelligence/workspace-impact.v1.json` |
140
+ | `workspace graph benchmark-suite --write` | `workspace-intelligence-benchmark-last-run.json` | `workspace-intelligence-benchmark.v1` | `contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json` |
140
141
  | `analyze --json` | `analyze-last-run.json` | `rapidkit-analyze-v1` | `contracts/analyze-last-run.v1.json` |
141
142
  | `workspace verify` | `workspace-verify-last-run.json` | `workspace-verify.v1` | `contracts/workspace-intelligence/workspace-verify.v1.json` |
142
143
  | `workspace context --write` | `workspace-context-agent.json` | `workspace-context.v1` | `contracts/workspace-intelligence/workspace-context.v1.json` |
@@ -97,6 +97,8 @@ Published under `../../contracts/` (not duplicated in this folder):
97
97
  - `infra-plan.v1.json`, `private-product-manifest.v1.json`, and `product-factory-plan.v1.json` — infrastructure and product planning payloads
98
98
  - `workspace-model-cache.v1.json`, `workspace-watch-event.v1.json`, `doctor-project-scan.v2.json`, and `doctor-workspace-cache.v2.json` — cache/watch/diagnostic support contracts
99
99
  - `workspace-activity-event.v1.json` — local-first run/block/operation/touch stream consumed by `workspai live`; observational only, never Evidence/Decision authority
100
+ - `workspace-activity-monitor-snapshot.v1.json` and `workspace-activity-monitor-fleet.v1.json` — deterministic local and bounded fleet projections
101
+ - `workspace-activity-board.v1.json` — renderer-neutral bounded Live projection for terminal, SVG, IDE and web consumers, with optional provenance-backed references to canonical artifacts and revision-bound Graph evidence
100
102
 
101
103
  Workspace intelligence (`../../contracts/workspace-intelligence/`):
102
104
 
@@ -108,6 +110,7 @@ Workspace intelligence (`../../contracts/workspace-intelligence/`):
108
110
  - `workspace-knowledge-graph-change-overlay.v1.json` — proposed/change-set facts and relations without mutating the base graph
109
111
  - `workspace-knowledge-search.v1.json` — bounded ranked retrieval for CLI, MCP, IDE, and agent consumers
110
112
  - `workspace-graph-token-efficiency.v1.json` — reproducible corpus-versus-retrieval payload measurement
113
+ - `workspace-intelligence-benchmark.v1.json` — fixed multi-scenario retrieval benchmark with separately classified measured evaluation evidence
111
114
  - `model-usage-event.v1.json` — privacy-bounded model, tool, milestone, and verified-outcome events with explicit measurement provenance
112
115
  - `workspace-intelligence-evaluation.v1.json` — live/final token, cost, latency, activity, and verified-outcome evaluation
113
116
  - `workspace-intelligence-evaluation-comparison.v1.json` — task-aligned comparison of two completed evaluation strategies
@@ -0,0 +1,82 @@
1
+ # Workspace Intelligence Benchmark
2
+
3
+ Workspai exposes two deliberately separate measurement lanes:
4
+
5
+ 1. deterministic retrieval-payload estimates from the Workspace Knowledge Graph;
6
+ 2. observed model/tool usage and verified outcomes recorded by `workspace eval`.
7
+
8
+ They are combined in one report for presentation, but their provenance is never
9
+ collapsed into one unsupported “tokens saved” claim.
10
+
11
+ ## Run the fixed suite
12
+
13
+ ```bash
14
+ npx workspai workspace graph benchmark-suite agent-core.v1 --json
15
+ npx workspai workspace graph benchmark-suite agent-core.v1 --write --json
16
+ ```
17
+
18
+ The `agent-core.v1` suite runs five stable scenario categories:
19
+
20
+ - architecture and runtime discovery;
21
+ - dependency and ownership discovery;
22
+ - interface and contract discovery;
23
+ - change-safety and verification discovery;
24
+ - build and delivery discovery.
25
+
26
+ For each category, Workspai selects the first evidence-backed entity from a
27
+ published kind priority (then stable entity ID), records that target ID/kind,
28
+ and queries its unique real label (or stable identity key when labels collide).
29
+ The scenario passes only when that exact target entity is retrieved. This keeps
30
+ the benchmark applicable to arbitrary architectures without hiding a
31
+ repository-specific query or pretending that an irrelevant fixed phrase
32
+ measures retrieval quality.
33
+
34
+ The suite is offline, deterministic, bounded, and repository-neutral. It reads
35
+ the proof-indexed source corpus once and applies the same retrieval limit to
36
+ every scenario. The report contains per-scenario results plus median and p95
37
+ retrieval sizes. Empty scenarios remain visible as `empty`; they are never
38
+ silently removed from the denominator.
39
+
40
+ With `--write`, the artifact is:
41
+
42
+ ```text
43
+ .workspai/reports/workspace-intelligence-benchmark-last-run.json
44
+ contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json
45
+ ```
46
+
47
+ ## Add measured model evidence
48
+
49
+ Finalize a task evaluation first:
50
+
51
+ ```bash
52
+ npx workspai workspace eval init repair-readiness workspace-intelligence --json
53
+ # record provider/tool/outcome events through workspace eval record --json
54
+ npx workspai workspace eval report --json
55
+ npx workspai workspace graph benchmark-suite agent-core.v1 --write --json
56
+ ```
57
+
58
+ The benchmark classifies evaluation provenance as `measured`, `mixed`,
59
+ `estimated`, or `unavailable`. Provider-reported and tokenizer-counted calls are
60
+ measured. Estimated and unavailable calls remain explicitly labelled.
61
+
62
+ For a baseline comparison:
63
+
64
+ ```bash
65
+ npx workspai workspace graph benchmark-suite agent-core.v1 \
66
+ --from .workspai/reports/baseline-evaluation.json \
67
+ --write --json
68
+ ```
69
+
70
+ `trustedMeasuredReductionPercent` is non-null only when:
71
+
72
+ - current and baseline task IDs match;
73
+ - both outcomes are verified and comparable;
74
+ - every model call in both runs is provider-reported or tokenizer-counted.
75
+
76
+ ## Claim boundary
77
+
78
+ The graph lane estimates JSON retrieval payload size using `characters / 4`
79
+ against readable proof-source text. It does not prove equivalent answer quality,
80
+ model billing savings, or task completion. The evaluation lane can report real
81
+ usage only to the precision supplied by its recorded source. Verified task
82
+ success remains a separate required outcome signal.
@@ -82,6 +82,7 @@ A simplified response looks like this:
82
82
  ```json
83
83
  {
84
84
  "schemaVersion": "workspace-knowledge-search.v1",
85
+ "graphSourceHash": "<canonical-model-structural-sha256>",
85
86
  "query": "billing database",
86
87
  "projectId": "billing",
87
88
  "totalMatches": 23,
@@ -26,6 +26,7 @@ workspai live --global --max-scopes 20 --max-runs 20
26
26
  workspai live --run <run-id>
27
27
  workspai live --once
28
28
  workspai live --once --json
29
+ workspai live --once --json --projection board
29
30
  workspai live --refresh-ms 500 --max-runs 10
30
31
  workspai live --no-motion --no-color
31
32
  workspai live --ascii
@@ -43,6 +44,25 @@ projected activity changes. `--global` discovers bounded machine-local activity
43
44
  channels and produces one fleet view across projects and workspaces; it cannot
44
45
  be combined with `target`.
45
46
 
47
+ JSON defaults to the backward-compatible monitor projection. Use
48
+ `--projection board` for the public `workspace-activity-board.v1` projection
49
+ consumed by IDE, browser, dashboard and capture adapters. It contains bounded
50
+ runs, nodes, edges, selection, counters and diagnostics; consumers must not
51
+ infer verification success from activity state.
52
+
53
+ Board runs and stages may also expose bounded `evidenceBindings`. Each binding
54
+ declares a typed reference (`artifact`, `graph-entity`, `graph-relation`,
55
+ `proof`, or `project`), its role, and authoritative/observed provenance. Graph
56
+ identities can carry the exact `graphSourceHash` needed for revision-safe
57
+ overlays. Artifact publications receive authoritative output bindings
58
+ automatically. They are attributed to a stage only when the producer names the
59
+ stage or exactly one non-root stage is active; concurrent/ambiguous execution
60
+ never receives a guessed link.
61
+
62
+ Bindings are navigation and correlation references, not verification claims.
63
+ An IDE must resolve the artifact and validate its contract, integrity and
64
+ freshness before presenting a verified outcome or drawing a Graph edge.
65
+
46
66
  `--capture` writes an atomic, deterministic SVG from the same Activity Board
47
67
  Model used by the terminal and exits. Captures are redacted by default: local
48
68
  scope, project, run and command-argument details are replaced while semantic
@@ -112,9 +132,9 @@ readers and captured output. `--classic` preserves the compatibility renderer.
112
132
  The implementation intentionally keeps this pipeline renderer-independent:
113
133
 
114
134
  ```text
115
- workspace-activity-event.v1
135
+ workspace-activity-event.v1 (optional provenance-backed evidence bindings)
116
136
  -> deterministic monitor snapshot
117
- -> Activity Board Model (runs, nodes, edges, selection, counters)
137
+ -> workspace-activity-board.v1 (runs, nodes, edges, selection, counters)
118
138
  -> terminal + deterministic SVG adapters today / web and IDE adapters later
119
139
  ```
120
140
 
@@ -153,12 +173,16 @@ Every NDJSON line conforms to:
153
173
 
154
174
  ```text
155
175
  contracts/workspace-activity-event.v1.json
176
+ contracts/workspace-activity-monitor-snapshot.v1.json
177
+ contracts/workspace-activity-monitor-fleet.v1.json
178
+ contracts/workspace-activity-board.v1.json
156
179
  ```
157
180
 
158
181
  The stream contains run, block, attempt, origin, declared-edge, operation,
159
- touch, artifact and warning data. Blueprint edges are explicit `sequence`, `parallel`, `gate` or
160
- `handoff` relations; older journals without declared edges receive a
161
- deterministic sequential projection for compatibility.
182
+ touch, artifact, evidence-binding and warning data. Blueprint edges are
183
+ explicit `sequence`, `parallel`, `gate` or `handoff` relations; older journals
184
+ without declared edges or evidence bindings receive a deterministic compatible
185
+ projection without fabricated links.
162
186
  Stable semantic block IDs describe architecture stages rather than source line
163
187
  numbers or function names.
164
188
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspai",
3
- "version": "0.66.0",
3
+ "version": "0.68.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": [
@@ -116,6 +116,7 @@
116
116
  "test:scenarios:docker": "bash scripts/scenario-matrix.sh",
117
117
  "test:runtime-matrix": "node scripts/runtime-acceptance-matrix.mjs",
118
118
  "test:runtime-contract": "node scripts/runtime-acceptance-matrix.mjs --contract-only",
119
+ "prepush:test:runtime-contract": "node scripts/run-cached-prepush-gate.mjs runtime-contract",
119
120
  "test:runtime-matrix:full": "node scripts/runtime-acceptance-matrix.mjs --full",
120
121
  "test:real-world": "node scripts/real-world-qualification.mjs",
121
122
  "test:real-world:enterprise": "node scripts/enterprise-workspace-qualification.mjs",
@@ -141,6 +142,7 @@
141
142
  "smoke:frontend-generators:network": "tsup && node scripts/smoke-frontend-generators.mjs --execute",
142
143
  "smoke:official-generators": "tsup && node scripts/smoke-official-generators.mjs",
143
144
  "smoke:official-generators:no-build": "node scripts/smoke-official-generators.mjs",
145
+ "prepush:smoke:official-generators": "node scripts/run-cached-prepush-gate.mjs official-generators-contract",
144
146
  "smoke:official-generators:network": "tsup && node scripts/smoke-official-generators.mjs --execute",
145
147
  "check:generator-smoke-coverage": "node scripts/check-generator-smoke-coverage.mjs",
146
148
  "sync:contracts": "node scripts/sync-contracts.mjs",
@@ -151,7 +153,7 @@
151
153
  "size-check:no-build": "size-limit",
152
154
  "bench": "npx tsx scripts/benchmarks.ts",
153
155
  "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 check:doctor-capabilities && corepack npm run test:runtime-contract && corepack npm run security && corepack npm run validate:docs && corepack npm run check:generator-smoke-coverage && corepack npm run smoke:official-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",
154
- "quality:push": "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 build && corepack npm run test:no-build && corepack npm run size-check:no-build && corepack npm run check:workspace-intelligence-runtime && corepack npm run check:workspace-intelligence-adversarial && corepack npm run check:doctor-capabilities && corepack npm run test:runtime-contract && corepack npm run validate:docs && corepack npm run check:generator-smoke-coverage && corepack npm run smoke:official-generators:no-build && corepack npm run contracts:check:local && corepack npm run validate:contracts:tests",
156
+ "quality:push": "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 build && corepack npm run test:no-build && corepack npm run size-check:no-build && corepack npm run check:workspace-intelligence-runtime && corepack npm run check:workspace-intelligence-adversarial && corepack npm run check:doctor-capabilities && corepack npm run prepush:test:runtime-contract && corepack npm run validate:docs && corepack npm run check:generator-smoke-coverage && corepack npm run prepush:smoke:official-generators && corepack npm run contracts:check:local && corepack npm run validate:contracts:tests",
155
157
  "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",
156
158
  "release:dry": "bash scripts/release.sh --no-publish --yes --allow-dirty",
157
159
  "release:patch": "bash scripts/release.sh patch",
@@ -1 +0,0 @@
1
- export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-EP4CUWOO.js';
@@ -1 +0,0 @@
1
- export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-IIFFEEMX.js';
@@ -1 +0,0 @@
1
- export{b as runDoctorCapabilities}from'./chunk-3H5ACWWZ.js';
@@ -1,2 +0,0 @@
1
- import {e,i,h as h$1,g as g$1,f,a}from'./chunk-UTV4DTNM.js';import E from'crypto';import k from'fs';import m from'path';var s=null,h=/(?:authorization|cookie|credential|password|passwd|secret|token|api[-_]?key)/i;function R(t,e){return e.WORKSPAI_ACTIVITY_DISABLE==="1"||(e.VITEST==="true"||e.VITEST==="1"||e.NODE_ENV==="test")&&e.WORKSPAI_ACTIVITY_FORCE!=="1"?true:t[0]==="live"}function g(t,e="",n=0){if(h.test(e))return "[REDACTED]";if(n>4)return "[TRUNCATED]";if(t!==void 0){if(t===null||typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return u(t);if(Array.isArray(t))return t.slice(0,100).map(o=>g(o,e,n+1));if(t instanceof Error)return {name:t.name,message:u(t.message)};if(typeof t=="object"){let o={};for(let[r,i]of Object.entries(t).slice(0,100))o[r]=g(i,r,n+1);return o}return String(t)}}function u(t){let e=t;for(let n of s?.sensitiveValues??[])n.length>=3&&(e=e.split(n).join("[REDACTED]"));if(e=e.replace(/((?:authorization|cookie|credential|password|passwd|secret|token|api[-_]?key)\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/gi,"$1[REDACTED]"),e=e.replace(/\bBearer\s+[^\s,;]+/gi,"Bearer [REDACTED]"),s){let n=s.resolvedScope.observationRootPath,o=[n,s.resolvedScope.rootPath].sort((r,i)=>i.length-r.length);for(let r of new Set(o))e=e.split(r).join("."),m.sep==="\\"&&(e=e.split(r.replaceAll("\\","/")).join("."));e=e.replace(/(^|[\s("'=])((?:[A-Za-z]:[\\/]|\/)(?!\/)[^\s"',;)\]}]+)/g,(r,i,a)=>`${i}${g$1(n,a)}`);}return e.length>2e3?`${e.slice(0,2e3)}\u2026`:e}function S(t,e){return t.startsWith("-")?h.test(t)?true:e.some(o=>/^(?:set|add|update|rotate)-(?:api-)?(?:key|token|secret|password)$/i.test(o))&&/^--?key$/i.test(t):false}function w(t){let e=[],n=false;for(let o of t){if(n){o.length>0&&e.push(o),n=false;continue}let r=o.indexOf("="),i=r>=0?o.slice(0,r):o;if(S(i,t))if(r>=0){let a=o.slice(r+1);a.length>0&&e.push(a);}else n=true;}return [...new Set(e)]}function P(t,e){let n=false;return t.map(o=>{if(n)return n=false,"[REDACTED]";let r=o.indexOf("="),i=r>=0?o.slice(0,r):o;return S(i,t)?r>=0?`${i}=[REDACTED]`:(n=true,o):m.isAbsolute(o)?g$1(e,o):o.length>300?`${o.slice(0,300)}\u2026`:o})}function T(t){if(t)return g(t)}function l(t){if(!s||s.finalized)return null;let e;if(t.blockId&&t.kind.startsWith("block.")&&t.kind!=="block.planned"){let i=s.blockAttempts.get(t.blockId)??0,a=s.blockStatuses.get(t.blockId);t.kind==="block.started"?e=a==="running"?Math.max(1,i):i+1:(t.kind!=="block.skipped"||i>0)&&(e=Math.max(1,i));}let n={schemaVersion:a,eventId:E.randomUUID(),sequence:++s.sequence,timestamp:new Date().toISOString(),runId:s.runId,...s.parentRunId?{parentRunId:s.parentRunId}:{},scope:s.resolvedScope.scope,...t,origin:f(s.resolvedScope),...e!==void 0?{attempt:e}:{},component:u(t.component),message:u(t.message),...t.target?{target:{...t.target,...t.target.locator?{locator:u(t.target.locator)}:{},...t.target.operation?{operation:u(t.target.operation)}:{}}}:{},...t.attributes?{attributes:T(t.attributes)}:{}},o=`${JSON.stringify(n)}
2
- `,r=false;for(let i of s.fds)try{k.writeSync(i,o),r=true;}catch{}return r&&n.blockId&&n.kind.startsWith("block.")&&(s.blockStatuses.set(n.blockId,n.status),n.attempt!==void 0&&s.blockAttempts.set(n.blockId,n.attempt)),r?n:null}function O(t){let e$1=t.env??process.env;if(!R(t.command,e$1)){D(1,"Previous in-process activity run was superseded.");try{let n=e(t.cwd,{env:e$1}),r=[n.statePath,...n.mirrorStatePaths].map(c=>{let p=m.join(c,"runs");return k.mkdirSync(p,{recursive:true,mode:448}),i(p,{maxRuns:h$1-1}),m.join(p,`${t.runId}.ndjson`)}),i$1=[];try{for(let c of r)i$1.push(k.openSync(c,"a",384));}catch(c){for(let p of i$1)try{k.closeSync(p);}catch{}throw c}let a=w(t.command),d=P(t.command,n.observationRootPath);s={runId:t.runId,...t.parentRunId?{parentRunId:t.parentRunId}:{},command:d,sensitiveValues:a,startedAtMs:Date.now(),sequence:0,fds:i$1,journalPaths:r,resolvedScope:n,...t.blueprint?.nodes[0]?.id?{rootBlockId:t.blueprint.nodes[0].id}:{},blockStatuses:new Map,blockAttempts:new Map,finalized:false},l({kind:"run.started",status:"running",component:"cli",message:d.length>0?`workspai ${d.join(" ")}`:"workspai",attributes:{command:d,rapidkitVersion:t.rapidkitVersion,pid:process.pid,blueprintId:t.blueprint?.id,blueprintVersion:t.blueprint?.version}});for(let c of t.blueprint?.nodes??[])l({kind:"block.planned",status:"planned",component:"cli",blockId:c.id,parentSpanId:c.parentId,message:c.label,attributes:{order:c.order,layoutHint:c.layoutHint,group:c.group}});for(let c of t.blueprint?.edges??[])l({kind:"edge.declared",status:"planned",component:"cli",message:`${c.from} -> ${c.to}`,edge:{id:c.id,fromBlockId:c.from,toBlockId:c.to,kind:c.kind},attributes:{order:c.order}});s.rootBlockId&&l({kind:"block.started",status:"running",component:"cli",blockId:s.rootBlockId,message:t.blueprint?.nodes[0]?.label??"Workspai command"});}catch{s=null;}}}function j(t){return l(t)}function K(t){let e=t.status==="planned"?"block.planned":t.status==="running"?t.progress?"block.progress":"block.started":t.status==="succeeded"?"block.completed":t.status==="failed"?"block.failed":t.status==="blocked"?"block.blocked":t.status==="skipped"?"block.skipped":"block.progress";return l({kind:e,status:t.status,component:t.component??"cli",blockId:t.blockId,message:t.message,...t.progress?{progress:t.progress}:{},...t.attributes?{attributes:t.attributes}:{}})}function L(t){let e=s?g$1(s.resolvedScope.observationRootPath,m.resolve(t.workspacePath,t.relativePath)):t.relativePath.replaceAll("\\","/");return l({kind:"artifact.published",status:"succeeded",component:"artifact-store",message:`Published ${e}`,target:{kind:"artifact",locator:e,operation:t.operation??"publish",provenance:"authoritative"}})}function U(t){if(!s)return null;let e=g$1(s.resolvedScope.observationRootPath,t.targetPath);return l({kind:t.status==="planned"?"touch.planned":"touch.observed",status:t.status??"succeeded",component:"filesystem",message:t.message??`${t.operation} ${e}`,target:{kind:"file",locator:e,operation:t.operation,provenance:t.provenance??"authoritative"}})}function D(t,e){if(!s||s.finalized)return;let n=s,o=Date.now()-n.startedAtMs;for(let[r,i]of [...n.blockStatuses.entries()]){if(r===n.rootBlockId||i!=="planned"&&i!=="running")continue;let a=i==="running",d=t===130||t===143;l({kind:a?t===0?"block.completed":d?"block.blocked":"block.failed":"block.skipped",status:a?t===0?"succeeded":d?"cancelled":"failed":"skipped",component:"cli",blockId:r,message:a?t===0?"Stage completed with command":e??`Stage interrupted by command exit ${t}`:"Stage was not entered",durationMs:o,attributes:{finalizedByRun:true}});}n.rootBlockId&&l({kind:t===0?"block.completed":t===130||t===143?"block.blocked":"block.failed",status:t===0?"succeeded":t===130||t===143?"cancelled":"failed",component:"cli",blockId:n.rootBlockId,message:e??(t===0?"Command completed":`Command exited with code ${t}`),durationMs:o}),l({kind:t===0?"run.completed":t===130||t===143?"run.cancelled":"run.failed",status:t===0?"succeeded":t===130||t===143?"cancelled":"failed",component:"cli",message:e??(t===0?"CLI run completed":`CLI run exited with code ${t}`),durationMs:o,attributes:{exitCode:t}}),n.finalized=true;for(let r of n.fds)try{k.closeSync(r);}catch{}s=null;}export{O as a,j as b,K as c,L as d,U as e,D as f};
@@ -1 +0,0 @@
1
- import {f}from'./chunk-6UNATTB7.js';var o="model-usage-event.v1",s=f.evaluationLive,a="workspace-intelligence-evaluation-comparison.v1",i=["provider-reported","tokenizer-counted","estimated","unavailable"];export{o as a,s as b,a as c,i as d};
@@ -1 +0,0 @@
1
- import {e,i,p,f as f$1,g}from'./chunk-6UNATTB7.js';var l="workspai-workspace-intelligence-chain-v1",u="contracts/workspace-intelligence-chain.v1.json";function f(){let e$1=e,t=p,s=[{id:"model",ordinal:1,phase:"understand",label:"Model",command:[...t.model.command],consumes:["workspace markers","project metadata","registry","contract","policies"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules","existing-evidence"],consumesArtifacts:[],produces:[...t.model.produces],dependsOn:[],exitPolicy:"stop-on-error",purpose:"Build the canonical current model and its structurally bound, derived Knowledge Graph."},{id:"diff",ordinal:2,phase:"change",label:"Diff",command:[...t.diff.command],consumes:[e$1.model,e$1.snapshot],inputRefs:["changes","model-baseline"],consumesArtifacts:[e$1.model,e$1.snapshot],produces:[...t.diff.produces],dependsOn:["model"],exitPolicy:"stop-on-error",purpose:"Describe structural change against the selected baseline."},{id:"impact",ordinal:3,phase:"change",label:"Impact",command:[...t.impact.command],consumes:[e$1.model,e$1.diff],inputRefs:[],consumesArtifacts:[e$1.model,e$1.diff],produces:[...t.impact.produces],dependsOn:["diff"],exitPolicy:"stop-on-error",purpose:"Calculate transitive blast radius over the workspace graph."},{id:"doctor-evidence",ordinal:4,phase:"evidence",label:"Doctor Evidence",command:[...t["doctor-evidence"].command],consumes:["workspace runtime and project health signals"],inputRefs:["projects-repositories","runtime-dependencies","existing-evidence"],consumesArtifacts:[],produces:[...t["doctor-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh health evidence after the impact artifact exists."},{id:"contract-evidence",ordinal:5,phase:"evidence",label:"Contract Evidence",command:[...t["contract-evidence"].command],consumes:[i.workspaceContract],inputRefs:["workspace-rules"],consumesArtifacts:[],produces:[...t["contract-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh structural contract evidence without hiding failed verdicts."},{id:"analyze-evidence",ordinal:6,phase:"evidence",label:"Analyze Evidence",command:[...t["analyze-evidence"].command],consumes:[e$1.model,"workspace runtime and dependency signals"],inputRefs:["projects-repositories","runtime-dependencies","workspace-rules"],consumesArtifacts:[e$1.model],produces:[...t["analyze-evidence"].produces],dependsOn:["impact"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh analysis evidence required by the release-readiness gate."},{id:"readiness-evidence",ordinal:7,phase:"evidence",label:"Readiness Evidence",command:[...t["readiness-evidence"].command],consumes:["doctor, analysis, runtime, and release signals"],inputRefs:["runtime-dependencies","existing-evidence"],consumesArtifacts:[e$1.doctor,e$1.contractVerify,e$1.analyze],produces:[...t["readiness-evidence"].produces],dependsOn:["doctor-evidence","contract-evidence","analyze-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Refresh release-readiness evidence before the definitive gate."},{id:"verify",ordinal:8,phase:"gate",label:"Verify",command:[...t.verify.command],consumes:[e$1.impact,e$1.doctor,e$1.contractVerify,e$1.readiness],inputRefs:[],consumesArtifacts:[e$1.impact,e$1.doctor,e$1.contractVerify,e$1.readiness],produces:[...t.verify.produces],dependsOn:["impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"],exitPolicy:"continue-on-structured-verdict",purpose:"Emit the definitive evidence-backed workspace gate."},{id:"context",ordinal:9,phase:"ground",label:"Agent Context",command:[...t.context.command],consumes:[e$1.model,e$1.impact,e$1.verify],inputRefs:[],consumesArtifacts:[e$1.model,e$1.impact,e$1.verify],produces:[...t.context.produces],dependsOn:["verify"],exitPolicy:"stop-on-error",purpose:"Build compact agent context from the same verified evidence."},{id:"agent-sync",ordinal:10,phase:"distribute",label:"Agent Grounding",command:[...t["agent-sync"].command],consumerArgs:{vscode:["--target","vscode"]},consumes:[e$1.agentContext],inputRefs:[],consumesArtifacts:[e$1.agentContext],produces:[...t["agent-sync"].produces],dependsOn:["context"],exitPolicy:"stop-on-error",purpose:"Distribute one context into portable agent and IDE surfaces."},{id:"explain",ordinal:11,phase:"explain",label:"Explain",command:[...t.explain.command],consumes:[e$1.verify,e$1.impact],inputRefs:[],consumesArtifacts:[e$1.verify,e$1.impact],produces:[...t.explain.produces],dependsOn:["verify"],exitPolicy:"continue-on-structured-verdict",purpose:"Translate evidence and blockers into a human and agent-readable narrative."}];return {schemaVersion:l,name:"Workspace Intelligence Chain",contractPath:u,invariant:"Every consumer must preserve step identity, dependencies, artifact flow, and verdict semantics; presentation may change, chain meaning may not.",invariants:["Missing or unreadable input is unknown or unavailable; it must not be presented as verified absence.","Freshness and provenance travel with evidence and must not be discarded by projections.","The current graph is an evidence-backed workspace knowledge graph with bounded source intelligence, not a complete cross-language symbol or call graph.","Simple and standard presentations summarize the contract; their contractRefs must preserve complete traceability.","Conditional provider outputs must be resolved through their dedicated inventory contract.","Auxiliary capabilities expose or refresh intelligence but are not mandatory execution-chain steps.","Canonical step commands are stage-pure: they must not implicitly execute a downstream chain step or regenerate an upstream artifact.","Canonical JSON artifacts must satisfy their registered schema both when produced and when consumed across CLI, MCP, IDE, and CI trust boundaries.","Schema validity is necessary but not sufficient: hashes, embedded models, summaries, counts, graph statistics, and artifact references must remain semantically coherent.","Persisted impact evidence must be rejected as stale when the current workspace model or Git observation no longer matches its embedded diff.","Canonical artifact replacement must be atomic and workspace-contained; an interrupted or denied write must preserve the last valid artifact.","Concurrent history updates must be serialized without silently dropping entries, and invalid history must never be overwritten as if it were absent.","The canonical global registry is ~/.workspai/workspaces.json; ~/.rapidkit/workspaces.json is a non-authoritative compatibility mirror for legacy consumers and must not diverge after a CLI registry mutation."],semantics:{workspace:"The governed operating boundary that relates one or more projects and repositories to shared metadata, policies, contracts, evidence, and consumers.",repository:"A source-control boundary that may contain one or more projects and may live inside or outside the workspace root.",project:"A discoverable build or runtime unit with its own path, metadata or observable manifests, command capabilities, and evidence.",evidence:"A sourced observation or generated verification result with provenance and freshness; evidence may be consumed by a later run.",artifact:"A durable generated file that another command or consumer can read without parsing terminal prose.",gate:"A structured verdict with reasons and exit semantics derived from current evidence."},workspaceLifecycle:{ingestionRoutes:[{id:"create",label:"Create",commands:["create workspace","create project"],result:"Create a workspace or supported project and write canonical Workspai metadata."},{id:"adopt",label:"Adopt",commands:["adopt"],result:"Register an existing project in place without requiring source relocation."},{id:"import",label:"Import",commands:["import","workspace import"],result:"Attach an existing project or repository path to the workspace inventory."}],durableState:[{id:"workspace-identity",paths:[".workspai-workspace",".workspai/workspace.json"],purpose:"Identify the workspace boundary, profile, and canonical root."},{id:"project-inventory",paths:[".workspai/project.json",".workspai/context.json",".workspai/adopt.json","~/.workspai/workspaces.json","~/.rapidkit/workspaces.json (legacy compatibility mirror)"],purpose:"Record native, adopted, imported, and globally registered project locations while preserving a non-authoritative mirror for legacy extension discovery."},{id:"governance",paths:[".workspai/policies.yml",i.workspaceContract],purpose:"Define workspace policy and explicit structural relationships."},{id:"graph-overrides",paths:[".workspai/workspace-graph.overrides.json"],purpose:"Provide explicit dependency edges that override inferred relationships."}],rule:"Create, adopt, and import are ingestion routes, not intelligence facts. Their durable state becomes observable input to Model."},runtimeRegistry:{authority:"contracts/workspace-intelligence-runtime-registry.ts",artifacts:Object.entries(e).map(([r,a])=>({id:r,path:a,schemaVersion:f$1[r],schemaContract:g[r]}))},executionEnvelope:{rule:"Sync and baseline resolution are deterministic execution prerequisites, not canonical intelligence stages; every run reports them separately and preserves the exact canonical stage sequence.",operations:[{id:"sync",executionPoint:"before:model",artifacts:[i.workspaceContract,i.workspaceRegistry],failurePolicy:"stop-and-report",purpose:"Reconcile portable workspace inventory and contract inputs before modeling."},{id:"baseline",executionPoint:"after:model-before:diff",artifacts:[e$1.snapshot],failurePolicy:"stop-and-report",purpose:"Create an initial structural baseline when absent or reuse the existing baseline before Diff."}],report:{artifact:e$1.intelligenceRun,schemaVersion:f$1.intelligenceRun,invariant:"The report must preserve exact preflight and stage order, registry-owned artifacts, failure propagation, and aggregate status/exit semantics."}},boundaries:{inputs:[{id:"projects-repositories",label:"Projects and repositories",sources:["projects","repositories","services","modules","imported paths"],entersAt:"model"},{id:"runtime-dependencies",label:"Runtime and dependencies",sources:["runtime manifests","lockfiles","scripts","framework markers","package dependencies","bounded multi-language source observations for supported file extensions"],entersAt:"model"},{id:"workspace-rules",label:"Workspace rules",sources:["workspace markers","registry","project metadata","contracts","policies","ownership","graph overrides"],entersAt:"model"},{id:"changes",label:"Changes",sources:["repository state","git state","model baseline","workspace diff"],entersAt:"diff"},{id:"model-baseline",label:"Explicit model baseline",sources:[e$1.snapshot],entersAt:"diff"},{id:"existing-evidence",label:"Existing evidence",sources:["doctor reports","analysis reports","contract verification","release readiness","pipeline results","tests and runtime evidence","previous intelligence artifacts"],entersAt:"doctor-evidence"}],outputs:[{id:"understanding",label:"System understanding",artifacts:[e$1.model,e$1.knowledgeGraph,e$1.diff,e$1.impact],producedBy:["model","diff","impact"],inventory:"complete-for-chain"},{id:"governance-evidence",label:"Governance evidence",artifacts:[e$1.doctor,e$1.contractVerify,e$1.analyze,e$1.readiness,e$1.verify,e$1.history],producedBy:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify"],inventory:"complete-for-chain"},{id:"agent-grounding",label:"Agent grounding",artifacts:[e$1.agentContext,e$1.agentIndex,e$1.agentCustomizationPack,e$1.skillsIndex,e$1.agents],producedBy:["context","agent-sync"],inventory:"canonical-minimum",inventoryContract:"contracts/agent-customization-pack.v1.json"},{id:"explanations",label:"Explainable decisions",artifacts:[e$1.explain],producedBy:["explain"],inventory:"complete-for-chain"}],consumers:[{id:"developers",label:"Developers",channels:["CLI","reports","AGENTS.md"]},{id:"ci",label:"CI",channels:["JSON artifacts","exit codes","release gates"]},{id:"ides",label:"IDEs",channels:["synced contracts","extension","agent context"]},{id:"ai-agents",label:"AI agents",channels:["INDEX.json","context","skills","MCP"]}]},deliveryChannels:[{id:"artifacts",carries:["reports","models","context","grounding","skills"],authority:"canonical"},{id:"json-stdout",carries:["structured command results"],authority:"projection"},{id:"human-cli",carries:["summaries","diagnostics","next actions"],authority:"projection"},{id:"exit-codes",carries:["gate and command status"],authority:"projection"},{id:"watch-events",carries:["incremental workspace change events"],authority:"projection"},{id:"mcp",carries:["read-mostly access to current workspace artifacts"],authority:"projection"}],feedback:{from:["developers","ci","ides","ai-agents"],signals:["source commits","dependency updates","policy and contract edits","repairs","test and runtime results","agent action outcomes"],reentersThrough:["projects-repositories","runtime-dependencies","workspace-rules","changes","existing-evidence"],rule:"Consumer actions are not silently treated as truth. They re-enter as observable changes or evidence and must be modeled and verified again."},auxiliaryCapabilities:[{id:"graph",commands:["workspace graph emit","workspace graph explain","workspace graph entities","workspace graph evidence","workspace graph path","workspace graph search","workspace graph benchmark","workspace graph overlay","workspace graph dot","workspace graph mermaid","workspace graph jsonld","workspace graph graphml","workspace graph gexf"],reads:[e$1.model,e$1.knowledgeGraph],role:"Query the proof-backed graph derived from the canonical workspace model.",chainStep:false},{id:"evaluation",commands:["workspace eval init","workspace eval record","workspace eval status","workspace eval report","workspace eval compare"],reads:[e$1.evaluationLive,e$1.evaluationLastRun],produces:[e$1.evaluationLive,e$1.evaluationLastRun],role:"Measure model usage, activity, cost provenance, and verified outcomes without storing prompt or response bodies.",chainStep:false},{id:"watch",commands:["workspace watch"],reads:["workspace inputs",e$1.model],role:"Refresh the model incrementally and emit deterministic change events.",chainStep:false},{id:"mcp",commands:["workspace mcp serve"],reads:["workspace evidence artifacts"],role:"Expose read-mostly workspace evidence to compatible clients.",chainStep:false}],presentations:{simple:{layers:["inputs","intelligence","outputs","consumers"],nodes:[{id:"input-layer",kind:"inputs",label:"Input Layer",summary:"Projects \xB7 Repositories \xB7 Dependencies \xB7 Changes",contractRefs:["projects-repositories","runtime-dependencies","workspace-rules","changes","model-baseline","existing-evidence"]},{id:"workspace-intelligence",kind:"intelligence",label:"Workspace Intelligence",summary:"Model \xB7 Graph \xB7 Impact \xB7 Verify",contractRefs:s.map(r=>r.id)},{id:"agent-grounding",kind:"outputs",label:"Agent Grounding",summary:"AGENTS.md \xB7 Skills \xB7 Context",contractRefs:["agent-grounding"]},{id:"evidence-and-decisions",kind:"outputs",label:"Evidence Contracts",summary:"Reports \xB7 Artifacts \xB7 Gates",contractRefs:["understanding","governance-evidence","explanations"]},{id:"shared-consumers",kind:"consumers",label:"Shared Consumers",summary:"Developers \xB7 CI \xB7 IDEs \xB7 AI agents",contractRefs:["developers","ci","ides","ai-agents"]}],rule:"Use concrete user-facing language for first-contact explanations. Every input, output, consumer, and chain step must remain traceable through contractRefs even when details are summarized."},standard:{phases:["understand","change","evidence","gate","ground","distribute","explain"],nodes:[{id:"understand",label:"Understand",question:"What exists in the current workspace?",stepRefs:["model"]},{id:"change",label:"Change",question:"What changed, and what can it affect?",stepRefs:["diff","impact"]},{id:"evidence",label:"Evidence",question:"What health, contract, and readiness facts were observed?",stepRefs:["doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence"]},{id:"gate",label:"Gate",question:"Is the current state acceptable and trustworthy?",stepRefs:["verify"]},{id:"ground",label:"Ground",question:"What should an agent know before acting?",stepRefs:["context"]},{id:"distribute",label:"Distribute",question:"Which durable agent and IDE surfaces receive that context?",stepRefs:["agent-sync"]},{id:"explain",label:"Explain",question:"Why did the system reach this result or verdict?",stepRefs:["explain"]}],rule:"Use for architecture education and product surfaces. Every phase must appear once and in order."},advanced:{steps:s.map(r=>r.id),requiredFields:["command","inputRefs","consumesArtifacts","produces","dependsOn","exitPolicy","purpose"],rule:"Use for implementers, adapters, IDEs, and CI. Preserve every step and its artifact and verdict semantics."}},steps:s,diagram:{direction:"TB",nodes:s.map(({id:r,label:a,phase:p})=>({id:r,label:a,phase:p})),edges:s.flatMap(r=>r.dependsOn.map(a=>({from:a,to:r.id,meaning:"required before"})))},consumers:{agents:{canonicalReadOrder:[e$1.agentIndex,i.goalIndex,i.goalPackLastRun,e$1.agentContext,e$1.skillsIndex,e$1.verify,e$1.impact,e$1.explain],entrypoints:[e$1.agents,".workspai/AGENT-GROUNDING.md"],rule:"Agents must cite current artifacts, preserve verified versus inferred status, and re-run the producing step when evidence is missing or stale."},ideAndCi:{requiredArtifacts:[e$1.model,e$1.knowledgeGraph,e$1.impact,e$1.verify],rule:"IDEs and CI must consume structured artifacts and verdict exit semantics rather than parse human help or terminal prose."},docsAndDiagrams:{rule:"Documentation and diagrams must derive labels, ordering, and edges from this contract and must not invent implemented steps."}}}}export{l as a,f as b};
@@ -1 +0,0 @@
1
- import {f}from'./chunk-JC4XSU7G.js';import s from'path';import p from'fs-extra';var b=4,w="workspace-graph-token-efficiency.v1";function k(e){return Math.ceil(e/b)}function y(e,t){let r=s.resolve(e,t),o=s.relative(e,r);return !o||o.startsWith("..")||s.isAbsolute(o)?null:r}async function C(e){let t=new Map,r=[s.join(e,".workspai","workspace.contract.json"),s.join(e,".rapidkit","workspace.contract.json")];for(let o of r)if(await p.pathExists(o))try{let a=await p.readJson(o);for(let n of a.projects??[])typeof n.relativePath=="string"&&typeof n.externalPath=="string"&&s.isAbsolute(n.externalPath)&&t.set(n.relativePath.replace(/\\/g,"/").replace(/\/$/,""),n.externalPath);break}catch{}return t}function P(e,t,r){if(!t||s.isAbsolute(t))return null;let o=s.resolve(e),a=t.replace(/\\/g,"/");for(let[n,i]of [...r.entries()].sort(([u],[h])=>h.length-u.length))if(a.startsWith(`${n}/`))return y(i,a.slice(n.length+1));return y(o,a)}async function S(e){let t=s.resolve(e.workspacePath),r=f(e.graph,{query:e.query,...e.kind?{kind:e.kind}:{},...e.projectId?{projectId:e.projectId}:{},limit:e.limit,projection:"agent"}),o=[...new Set(e.graph.proofs.map(l=>l.artifact))].sort(),a=[],n=await C(t),i=0,u=0;for(let l of o){let f=P(t,l,n);if(!f){a.push(l);continue}try{let v=await p.readFile(f,"utf8");i+=v.length,u+=1;}catch{a.push(l);}}let h=JSON.stringify(r).length,c=k(i),d=k(h),g=Math.max(0,c-d);return {schemaVersion:w,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,query:e.query,graph:{schemaVersion:e.graph.schemaVersion,sourceArtifact:e.graph.source.artifact,sourceHash:e.graph.source.hash,entityCount:e.graph.entities.length,relationCount:e.graph.relations.length,proofCount:e.graph.proofs.length},methodology:{id:"indexed-corpus-vs-bounded-retrieval.v1",estimated:true,charsPerToken:b,claimBoundary:"Measures retrieval payload reduction against readable proof-source text; it does not claim equivalent answer quality or model-specific billing savings."},corpus:{artifactCount:u,characterCount:i,estimatedTokens:c,unreadableArtifacts:a},retrieval:{matchCount:r.entities.length,characterCount:h,estimatedTokens:d,truncated:r.truncated,payload:r},savings:{estimatedTokensAvoided:g,reductionRatio:d===0?0:Number((c/d).toFixed(2)),reductionPercent:c===0?0:Number((g/c*100).toFixed(2))}}}export{w as a,S as b};
@@ -1 +0,0 @@
1
- var Z="workspace-knowledge-search.v1";function b(e){return e.trim().toLowerCase()}var V=new WeakMap;function A(e){let t=V.get(e);if(t)return t;let s=new Map(e.relations.map(a=>[a.id,a])),o=new Map(e.entities.map(a=>[a.id,a])),r=new Map(e.proofs.map(a=>[a.id,a])),i=new Map,d=new Map,h=(a,p)=>{let g=d.get(a)??[];g.push(p),d.set(a,g);};for(let a of e.entities){let p=[a.id,a.label,a.identity.key,...a.kind==="project"&&a.projectId?[a.projectId]:[],...a.identity.aliases];for(let g of new Set(p.map(b))){let w=i.get(g)??[];w.push(a),i.set(g,w);}}for(let a of e.relations)h(a.from,{from:a.from,to:a.to,relationId:a.id,kind:a.kind,direction:"forward",proofIds:a.proofIds}),h(a.to,{from:a.to,to:a.from,relationId:a.id,kind:a.kind,direction:"reverse",proofIds:a.proofIds});for(let a of i.values())a.sort((p,g)=>p.id.localeCompare(g.id));for(let a of d.values())a.sort((p,g)=>p.to.localeCompare(g.to)||p.relationId.localeCompare(g.relationId));let l={entitiesById:o,relationsById:s,entitiesByAlias:i,proofsById:r,adjacency:d};return V.set(e,l),l}function O(e,t){let s=A(e),o=s.relationsById.get(t);if(o)return {found:true,targetType:"relation",relation:o};let r=b(t),i=s.entitiesByAlias.get(r)??[];return i.length===1?{found:true,targetType:"entity",entity:i[0]}:{found:false,query:t,candidates:i.map(d=>d.id).sort()}}function ye(e,t){let s=O(e,t);if(!s.found)return {query:t,found:false,target:null,proofs:[],candidates:s.candidates};let o=s.targetType==="entity"?s.entity:s.relation,r=new Set(o.proofIds);return {query:t,found:true,target:o,candidates:[],proofs:[...r].map(i=>A(e).proofsById.get(i)).filter(i=>!!i).sort((i,d)=>i.id.localeCompare(d.id))}}function ke(e,t,s){let o=O(e,t),r=O(e,s);if(!o.found||o.targetType!=="entity"||!r.found||r.targetType!=="entity")return {from:t,to:s,found:false,resolvedFrom:o.found&&o.targetType==="entity"?o.entity.id:null,resolvedTo:r.found&&r.targetType==="entity"?r.entity.id:null,entityPath:[],hops:[],proofs:[]};let i=A(e),d=[o.entity.id],h=new Map,l=new Set(d),a=0;for(;a<d.length&&!l.has(r.entity.id);){let u=d[a++];for(let y of i.adjacency.get(u)??[])l.has(y.to)||(l.add(y.to),h.set(y.to,y),d.push(y.to));}if(!l.has(r.entity.id))return {from:t,to:s,found:false,resolvedFrom:o.entity.id,resolvedTo:r.entity.id,entityPath:[],hops:[],proofs:[]};let p=[],g=r.entity.id;for(;g!==o.entity.id;){let u=h.get(g);if(!u)break;p.push(u),g=u.from;}p.reverse();let w=new Set(p.flatMap(u=>u.proofIds));return {from:t,to:s,found:true,resolvedFrom:o.entity.id,resolvedTo:r.entity.id,entityPath:[o.entity.id,...p.map(u=>u.to)],hops:p,proofs:[...w].map(u=>i.proofsById.get(u)).filter(u=>!!u).sort((u,y)=>u.id.localeCompare(y.id))}}function we(e,t,s){return e.entities.filter(o=>(!t||o.kind===t)&&(!s||o.projectId===s)).sort((o,r)=>o.kind.localeCompare(r.kind)||o.label.localeCompare(r.label))}var m={relations:12,relatedEntities:12,proofs:8,proofIdsPerItem:4,aliasesPerEntity:8,attributeArrayItems:8,attributeStringCharacters:256};function J(e){let t=[],s=new Set;for(let o=0;o<m.proofIdsPerItem&&t.length<m.proofs;o+=1)for(let r of e){let i=r.proofIds[o];if(!(!i||s.has(i))&&(s.add(i),t.push(i),t.length>=m.proofs))break}return t}function ee(e,t,s){let o=e.identity.aliases.slice(0,m.aliasesPerEntity);s.aliases+=e.identity.aliases.length-o.length;let r=Object.fromEntries(Object.entries(e.attributes).map(([d,h])=>{if(Array.isArray(h)){let l=h.slice(0,m.attributeArrayItems);return s.attributeValues+=h.length-l.length,[d,l]}return typeof h=="string"&&h.length>m.attributeStringCharacters?(s.attributeValues+=1,[d,h.slice(0,m.attributeStringCharacters)]):[d,h]})),i=e.proofIds.filter(d=>t.has(d)).slice(0,m.proofIdsPerItem);return s.proofReferences+=e.proofIds.length-i.length,{...e,identity:{...e.identity,aliases:o},attributes:r,proofIds:i}}function te(e){let t=Object.values(e.attributes).flatMap(s=>Array.isArray(s)?s:[s]);return [e.id,e.kind,e.label,e.projectId??"",e.identity.key,...e.identity.aliases,...t.map(s=>String(s??""))].join(" ").toLowerCase()}var ne=new Set(["a","an","and","are","as","at","be","been","being","by","can","check","could","did","do","does","find","for","from","give","had","has","have","how","i","in","into","is","it","its","may","might","of","on","or","our","show","should","that","the","their","them","then","there","these","they","this","those","tell","to","was","we","were","what","when","where","which","who","why","will","with","would","you","your"]),oe=new Map([["authenticate","auth"],["authenticated","auth"],["authentication","auth"],["authorization","auth"],["authorizing","auth"],["config","configuration"],["configs","configuration"],["dependencies","dependency"],["diagnostics","diagnostic"],["reliable","reliability"],["tested","test"],["testing","test"],["tests","test"],["verification","verify"],["verified","verify"],["verifies","verify"],["verifying","verify"]]);function M(e){let t=s=>b(s).replace(/\bc\+\+/gu," cplusplus ").replace(/\bc#/gu," csharp ").split(/[^a-z0-9]+/u).filter(o=>o.length>1||o==="c"||o==="r").map(o=>oe.get(o)??o);return [...new Set([...t(e),...t(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"))])]}function se(e){let t=b(e.label),s=b(e.identity.key),o=e.identity.aliases.map(b),r=te(e);return {entity:e,label:t,identity:s,aliases:o,haystack:r,labelTokens:new Set(M(e.label)),identityTokens:new Set(M(e.identity.key)),aliasTokens:new Set(e.identity.aliases.flatMap(M)),allTokens:new Set(M(r))}}function S(e,t){return e.has(t)||t.length>=3&&[...e].some(s=>s.startsWith(t))}function U(e,t){return S(e.labelTokens,t)||S(e.identityTokens,t)||S(e.aliasTokens,t)||S(e.allTokens,t)}function ae(e,t,s,o){let{label:r,identity:i,aliases:d,haystack:h}=e,l=0;(r===t||i===t||d.includes(t))&&(l+=1e4),(r.startsWith(t)||i.startsWith(t))&&(l+=250),h.includes(t)&&(l+=100);let a=0;for(let p of s){let g=o.get(p)??1,w=S(e.labelTokens,p),u=S(e.identityTokens,p),y=S(e.aliasTokens,p),f=U(e,p);f&&(a+=1),r===p?l+=80*g:w&&(l+=36*g),u&&(l+=24*g),y&&(l+=20*g),f&&(l+=10*g);}return s.length>0&&(l+=a/s.length*120),l}function re(e,t){let s=new Set;for(let o of t){let r=e.allTokens.has(o)?o:void 0,i=r===void 0&&o.length>=3?[...e.allTokens].find(h=>h.startsWith(o)&&!s.has(h)):void 0,d=r??i;d&&!s.has(d)&&s.add(d);}return s.size}var ie=new Map([["c","c"],["clojure","clojure"],["cplusplus","cpp"],["cpp","cpp"],["typescript","typescript"],["ts","typescript"],["javascript","javascript"],["js","javascript"],["nodejs","javascript"],["python","python"],["py","python"],["go","go"],["golang","go"],["csharp","csharp"],["ada","ada"],["assembly","assembly"],["asm","assembly"],["cuda","cuda"],["dotnet","csharp"],["dart","dart"],["elixir","elixir"],["fsharp","fsharp"],["fortran","fortran"],["java","java"],["kotlin","kotlin"],["hlsl","hlsl"],["llvmir","llvm-ir"],["mlir","mlir"],["lua","lua"],["php","php"],["r","r"],["ruby","ruby"],["rust","rust"],["tablegen","tablegen"],["scala","scala"],["svelte","svelte"],["swift","swift"],["vue","vue"]]);function ce(e){return new Set(e.map(t=>ie.get(t)).filter(t=>!!t))}function F(e){let t=e.attributes.language;return typeof t=="string"?b(t):null}function le(e){return {project:1e3,service:900,api:900,package:850,endpoint:800,container:700,deployment:700,environment:650,pipeline:600,"test-suite":550,owner:500,decision:450,document:400}[e.kind]??0}function de(e,t){let s=t.has("language")||t.has("languages"),o=t.has("binding")||t.has("bindings")||t.has("bridge")||t.has("bridges"),r=t.has("dependency")||t.has("dependencies")||t.has("depends"),i=t.has("core")||t.has("runtime"),d=t.has("owner")||t.has("owners")||t.has("ownership")||t.has("maintainer"),h=t.has("ci")||t.has("pipeline")||t.has("pipelines")||t.has("workflow"),l=t.has("deploy")||t.has("deployment")||t.has("infrastructure")||t.has("container"),a=t.has("doc")||t.has("docs")||t.has("document")||t.has("documentation"),p=t.has("service")||t.has("services")||t.has("api")||t.has("rpc"),g=t.has("schema")||t.has("schemas")||t.has("message")||t.has("protobuf")||t.has("proto")||t.has("contract"),w=typeof e.attributes.mechanism=="string"?b(e.attributes.mechanism):"",u=typeof e.attributes.specification=="string"?b(e.attributes.specification):"",y=b(e.label),f=0;if(s&&e.kind==="language"){let v=typeof e.attributes.fileCount=="number"?e.attributes.fileCount:0;f+=900+Math.min(v,1e4)/10;}return o&&e.kind==="protocol"&&(f+=800),r&&e.kind==="package"&&(f+=650),i&&e.kind==="package"&&/(?:^|[_-])core(?:$|[_-])/u.test(y)&&(f+=700),i&&e.kind==="protocol"&&w.includes("core")&&(f+=300),d&&e.kind==="owner"&&(f+=850),h&&e.kind==="pipeline"&&(f+=800),l&&["deployment","container","environment"].includes(e.kind)&&(f+=775),a&&["document","decision"].includes(e.kind)&&(f+=725),p&&["api","endpoint","service"].includes(e.kind)&&(f+=700),g&&(e.kind==="schema"||(e.kind==="api"||e.kind==="protocol")&&(u.includes("protobuf")||w.includes("protobuf")))&&(f+=750),f}function pe(e){return [e.has("language")||e.has("languages"),e.has("binding")||e.has("bindings")||e.has("bridge")||e.has("bridges"),e.has("dependency")||e.has("dependencies")||e.has("depends"),e.has("core")||e.has("runtime"),e.has("owner")||e.has("ownership")||e.has("maintainer"),e.has("ci")||e.has("pipeline")||e.has("workflow"),e.has("deploy")||e.has("deployment")||e.has("infrastructure"),e.has("doc")||e.has("docs")||e.has("documentation"),e.has("service")||e.has("api")||e.has("rpc"),e.has("schema")||e.has("protobuf")||e.has("proto")||e.has("contract")].filter(Boolean).length>=3}function me(e,t){let s=b(t.query),o=[...new Set(M(t.query))],r=new Set(M(t.projectId??"")),i=t.projectId?o.filter(n=>!r.has(n)):o,d=!!(t.projectId&&o.length>0&&i.length===0),h=i.filter(n=>!ne.has(n)),l=h.length>0?h:i,a=ce(l),p=new Set(l),g=pe(p),w=l.length<=1?l.length:Math.min(2,Math.ceil(l.length/3)),u=t.minimumTermMatches===void 0?w:Math.min(w,Math.max(1,Math.trunc(t.minimumTermMatches))),y=Math.max(1,Math.min(Math.trunc(t.limit??12),100)),f=Math.max(0,Math.min(Math.trunc(t.relationsPerEntity??4),20)),v=new Set;if(t.projectId){let n=new Set(e.entities.filter(c=>c.kind==="project"&&(c.projectId===t.projectId||c.label===t.projectId)).map(c=>c.id));for(let c of e.relations)n.has(c.from)&&v.add(c.to),n.has(c.to)&&v.add(c.from);}let x=e.entities.filter(n=>(!t.kind||n.kind===t.kind)&&(!t.projectId||n.projectId===t.projectId||n.projectId===void 0&&v.has(n.id))).map(se),Q=new Map(l.map(n=>{let c=x.filter(k=>U(k,n)).length;return [n,Math.log((x.length+1)/(c+1))+1]})),j=x.map(n=>{let c=re(n,l),k=F(n.entity),I=k&&a.has(k)?400:0,K=de(n.entity,p);return {entity:n.entity,matchedTerms:c,intentScore:K,score:d?le(n.entity):ae(n,s,l,Q)+I+K}}).filter(n=>{let c=F(n.entity);return (a.size===0||c===null||a.has(c))&&(s.length===0||n.score>0&&(d||n.matchedTerms>=u||n.intentScore>0&&(g||l.length<=2)))}).sort((n,c)=>c.score-n.score||n.entity.kind.localeCompare(c.entity.kind)||n.entity.label.localeCompare(c.entity.label)),E=(g?(()=>{let n=[],c=[],k=new Map,I=new Set;for(let K of j){let z=k.get(K.entity.kind)??0,q=b(K.entity.label);z<2&&!I.has(q)?(n.push(K),k.set(K.entity.kind,z+1),I.add(q)):c.push(K);}return [...n,...c]})():j).slice(0,y).map(n=>n.entity),P=new Set(E.map(n=>n.id)),G=new Map,B=e.relations.filter(n=>{if(!(P.has(n.from)||P.has(n.to)))return false;let k=P.has(n.from)?n.from:n.to,I=G.get(k)??0;return I>=f?false:(G.set(k,I+1),true)}),W=t.projection==="agent",T=W?B.slice(0,m.relations):B,D=A(e),_=[...new Set(T.flatMap(n=>[n.from,n.to]).filter(n=>!P.has(n)))].map(n=>D.entitiesById.get(n)).filter(n=>!!n).map(({id:n,kind:c,label:k,projectId:I})=>({id:n,kind:c,label:k,...I?{projectId:I}:{}})).sort((n,c)=>n.kind.localeCompare(c.kind)||n.label.localeCompare(c.label)),H=W?_.slice(0,m.relatedEntities):_,L=new Set([...E.flatMap(n=>n.proofIds),...T.flatMap(n=>n.proofIds)]),$=W?J([...E,...T]):[...L],C=new Set($),R={entities:j.length-E.length,relations:B.length-T.length,relatedEntities:_.length-H.length,proofs:L.size-C.size,proofReferences:0,aliases:0,attributeValues:0},N=W?E.map(n=>ee(n,C,R)):E,Y=W?T.map(n=>{let c=n.proofIds.filter(k=>C.has(k)).slice(0,m.proofIdsPerItem);return R.proofReferences+=n.proofIds.length-c.length,{...n,proofIds:c}}):T,X=[...C].map(n=>D.proofsById.get(n)).filter(n=>!!n).sort((n,c)=>n.id.localeCompare(c.id));return {schemaVersion:Z,query:t.query,kind:t.kind??null,...t.projectId?{projectId:t.projectId}:{},limit:y,totalMatches:j.length,truncated:j.length>N.length||W&&Object.values(R).some(n=>n>0),entities:N,relatedEntities:H,relations:Y,proofs:X,...W?{budget:{mode:"agent",limits:{...m},omitted:R}}:{}}}export{Z as a,O as b,ye as c,ke as d,we as e,me as f};