workspai 0.66.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +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 +114 -0
  7. package/contracts/workspace-activity-monitor-fleet.v1.json +18 -0
  8. package/contracts/workspace-activity-monitor-snapshot.v1.json +161 -0
  9. package/contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json +196 -0
  10. package/contracts/workspace-intelligence-architecture.v1.json +17 -0
  11. package/contracts/workspace-intelligence-chain.v1.json +17 -0
  12. package/dist/analyze-IC2KRVCG.js +1 -0
  13. package/dist/{artifact-remediation-plan-M2XBS2IU.js → artifact-remediation-plan-GFFHC2ZU.js} +1 -1
  14. package/dist/autopilot-release-RECEZAZI.js +1 -0
  15. package/dist/capabilities-command-X4WZIJNR.js +1 -0
  16. package/dist/{chunk-TTHO4MFC.js → chunk-2M62CU3O.js} +1 -1
  17. package/dist/{chunk-JZJBA2V2.js → chunk-2MTJWPQ4.js} +1 -1
  18. package/dist/chunk-2MVIRJJR.js +1 -0
  19. package/dist/chunk-2RPFCBS4.js +1 -0
  20. package/dist/{chunk-O37UBRMX.js → chunk-3O7LZPKA.js} +1 -1
  21. package/dist/chunk-3OGPTLI2.js +1 -0
  22. package/dist/{chunk-3H5ACWWZ.js → chunk-4RV4JVGR.js} +1 -1
  23. package/dist/{chunk-XQFWUM2P.js → chunk-4WVOAX2V.js} +1 -1
  24. package/dist/{chunk-L5CCIIF2.js → chunk-5EVDW7JM.js} +1 -1
  25. package/dist/{chunk-727IQFGN.js → chunk-5ME4W4LN.js} +1 -1
  26. package/dist/{chunk-DUBOKZMA.js → chunk-6254CWUY.js} +12 -12
  27. package/dist/{chunk-AP4PV6WJ.js → chunk-6E2Y3XGT.js} +1 -1
  28. package/dist/{chunk-ZQH2I5RQ.js → chunk-ARUFY5W3.js} +1 -1
  29. package/dist/{chunk-IIFFEEMX.js → chunk-BHFRP7TV.js} +1 -1
  30. package/dist/{chunk-6JX56VAL.js → chunk-BHM6RHTA.js} +1 -1
  31. package/dist/{chunk-VA5VSOBL.js → chunk-BRYJTW6S.js} +1 -1
  32. package/dist/{chunk-3NM3JAZW.js → chunk-BUYLM6QV.js} +1 -1
  33. package/dist/chunk-CPR2CMOY.js +1 -0
  34. package/dist/{chunk-2PACEMNE.js → chunk-CZVT7T2X.js} +1 -1
  35. package/dist/{chunk-7FF5EOIO.js → chunk-EHCKITR4.js} +1 -1
  36. package/dist/{chunk-UPIPSSXY.js → chunk-ENZPM52J.js} +1 -1
  37. package/dist/{chunk-334J2KIP.js → chunk-FPDH3N3A.js} +1 -1
  38. package/dist/{chunk-D4UHRJAP.js → chunk-FX5J6JCK.js} +1 -1
  39. package/dist/{chunk-HJLGXFMK.js → chunk-GIQ4SDRJ.js} +1 -1
  40. package/dist/{chunk-WTWRSEOW.js → chunk-H77ZNH5O.js} +1 -1
  41. package/dist/{chunk-EHH4SKVH.js → chunk-HQLBO23O.js} +3 -3
  42. package/dist/{chunk-AXUA7PFV.js → chunk-HYE5UHPV.js} +1 -1
  43. package/dist/{chunk-XESFJN52.js → chunk-IKUFNK46.js} +1 -1
  44. package/dist/{chunk-YX5VWPR5.js → chunk-IQQMFRWM.js} +1 -1
  45. package/dist/{chunk-PD7Y6HIM.js → chunk-JCGSIDMC.js} +1 -1
  46. package/dist/{chunk-4XEH3WNV.js → chunk-KENOAC2Q.js} +1 -1
  47. package/dist/{chunk-QGAPGZPL.js → chunk-KQ2TMI26.js} +1 -1
  48. package/dist/{chunk-OI2VOU6S.js → chunk-N4QFNOAI.js} +1 -1
  49. package/dist/{chunk-5XGR3LRI.js → chunk-OCNPOYMA.js} +1 -1
  50. package/dist/{chunk-VQOWB26M.js → chunk-PSYQ6IJA.js} +1 -1
  51. package/dist/{chunk-HLWDIIWL.js → chunk-QMQBX3RV.js} +1 -1
  52. package/dist/{chunk-H5RJCS5E.js → chunk-SLFOUSRW.js} +1 -1
  53. package/dist/chunk-SRLWHOLF.js +1 -0
  54. package/dist/chunk-SVYY55IS.js +157 -0
  55. package/dist/{chunk-JRP6WP5C.js → chunk-THIG2YQP.js} +1 -1
  56. package/dist/{chunk-PJPS7CNH.js → chunk-TP7VKEUF.js} +1 -1
  57. package/dist/{chunk-IVF6NEHS.js → chunk-VI4ZRAY6.js} +1 -1
  58. package/dist/{chunk-EP4CUWOO.js → chunk-VWBMDGPY.js} +1 -1
  59. package/dist/{chunk-GAYK3WGV.js → chunk-XDPTAV2T.js} +1 -1
  60. package/dist/{chunk-R2M5OJOK.js → chunk-Y35VLVF6.js} +1 -1
  61. package/dist/{chunk-ECLMYTWT.js → chunk-Y4Z6CEII.js} +1 -1
  62. package/dist/{chunk-UOCERSAN.js → chunk-YYY2WXOH.js} +1 -1
  63. package/dist/{chunk-6UNATTB7.js → chunk-ZGHJIQXL.js} +1 -1
  64. package/dist/chunk-ZI2E7P6O.js +4 -0
  65. package/dist/{create-SOLLXXAB.js → create-72ITVZXV.js} +1 -1
  66. package/dist/{doctor-NQ5PUCUP.js → doctor-CVYUESRQ.js} +1 -1
  67. package/dist/{goal-lifecycle-IPNY7KNR.js → goal-lifecycle-H55AGFCB.js} +1 -1
  68. package/dist/{goal-pack-2WV3EA4Y.js → goal-pack-6OBZOPCD.js} +1 -1
  69. package/dist/index.d.ts +14 -2
  70. package/dist/index.js +129 -129
  71. package/dist/live-command-5VXPR43F.js +15 -0
  72. package/dist/{pipeline-MIMENSI7.js → pipeline-SKYOXWHW.js} +1 -1
  73. package/dist/{project-agent-entry-OWLJ3IHQ.js → project-agent-entry-5IUBEREI.js} +1 -1
  74. package/dist/{project-intelligence-lens-I67EO6AE.js → project-intelligence-lens-LQCN65P2.js} +1 -1
  75. package/dist/{project-test-coverage-OPDVSFPH.js → project-test-coverage-KD4LLFGV.js} +1 -1
  76. package/dist/{verified-goal-46JWNCDY.js → verified-goal-HN7G532B.js} +1 -1
  77. package/dist/{workspace-KO37XHF6.js → workspace-5W7FYGDQ.js} +1 -1
  78. package/dist/{workspace-agent-sync-32FIJQBH.js → workspace-agent-sync-OZCDQORK.js} +1 -1
  79. package/dist/{workspace-archive-6R5DRNZW.js → workspace-archive-NOSGRKRZ.js} +1 -1
  80. package/dist/{workspace-context-JKRPX775.js → workspace-context-L65BR5L6.js} +1 -1
  81. package/dist/{workspace-contract-4T3NYNK5.js → workspace-contract-JYHNEJPV.js} +1 -1
  82. package/dist/workspace-explain-SUBK6FLO.js +1 -0
  83. package/dist/workspace-explain-contract-WMREJWHF.js +1 -0
  84. package/dist/{workspace-feedback-6VQ7T4CR.js → workspace-feedback-MWGCT5R2.js} +1 -1
  85. package/dist/{workspace-foundation-GHWO3BZU.js → workspace-foundation-VIB3PXNH.js} +1 -1
  86. package/dist/{workspace-graph-stream-PTVS47NJ.js → workspace-graph-stream-45JHE4MG.js} +1 -1
  87. package/dist/workspace-graph-token-efficiency-NPECU6Y5.js +1 -0
  88. package/dist/{workspace-history-M2K4M2JY.js → workspace-history-JKW3VJO3.js} +1 -1
  89. package/dist/{workspace-intelligence-PJIPTXL3.js → workspace-intelligence-3C47PK4L.js} +1 -1
  90. package/dist/workspace-intelligence-benchmark-SRDIHX3X.js +1 -0
  91. package/dist/workspace-intelligence-evaluation-OJIQS5SN.js +1 -0
  92. package/dist/{workspace-intelligence-runner-M47QR3JM.js → workspace-intelligence-runner-OWN5ZI6W.js} +1 -1
  93. package/dist/{workspace-intelligence-runtime-registry-FFGQF4A7.js → workspace-intelligence-runtime-registry-UKFB3BI7.js} +1 -1
  94. package/dist/{workspace-knowledge-graph-V2EAYDCL.js → workspace-knowledge-graph-AKG5NUU6.js} +1 -1
  95. package/dist/{workspace-knowledge-graph-contract-VANN7RCA.js → workspace-knowledge-graph-contract-X52KXBXJ.js} +1 -1
  96. package/dist/{workspace-knowledge-graph-query-RASPF7FS.js → workspace-knowledge-graph-query-DXA4CROE.js} +1 -1
  97. package/dist/workspace-knowledge-graph-snapshot-SNI5K2RL.js +1 -0
  98. package/dist/{workspace-mcp-serve-YRORNE4P.js → workspace-mcp-serve-PK226GMV.js} +1 -1
  99. package/dist/{workspace-model-VSVKLX7M.js → workspace-model-R4ISKDB2.js} +1 -1
  100. package/dist/{workspace-onboarding-2VMJZVLZ.js → workspace-onboarding-Y5RPEFUD.js} +1 -1
  101. package/dist/{workspace-readme-6X3GLTBM.js → workspace-readme-PL5V3UDH.js} +1 -1
  102. package/dist/{workspace-registry-summary-QVSJKKTX.js → workspace-registry-summary-STGUGROG.js} +1 -1
  103. package/dist/{workspace-repair-engine-WSKV3Q4V.js → workspace-repair-engine-FNLL5ZDK.js} +1 -1
  104. package/dist/workspace-run-GFBFGUFM.js +1 -0
  105. package/dist/{workspace-verify-EJCSOBIK.js → workspace-verify-AXVX3PF3.js} +1 -1
  106. package/dist/{workspace-watch-JTIFBF4Z.js → workspace-watch-RLBEJKXE.js} +1 -1
  107. package/docs/DEVELOPMENT.md +19 -0
  108. package/docs/README.md +19 -16
  109. package/docs/ci-workflows.md +1 -1
  110. package/docs/commands-reference.md +17 -1
  111. package/docs/contracts/ARTIFACT_CATALOG.md +1 -0
  112. package/docs/contracts/README.md +3 -0
  113. package/docs/workspace-intelligence-benchmark.md +82 -0
  114. package/docs/workspace-live-activity.md +11 -1
  115. package/package.json +4 -2
  116. package/dist/analyze-UJQWGNM2.js +0 -1
  117. package/dist/autopilot-release-U6F4M2BQ.js +0 -1
  118. package/dist/capabilities-command-XUKPO25Z.js +0 -1
  119. package/dist/chunk-5U4L6VF2.js +0 -1
  120. package/dist/chunk-C4S22E6S.js +0 -1
  121. package/dist/chunk-H7MRINGP.js +0 -1
  122. package/dist/chunk-JC4XSU7G.js +0 -1
  123. package/dist/chunk-MZ7U4BIQ.js +0 -157
  124. package/dist/live-command-Q6E45N7S.js +0 -18
  125. package/dist/workspace-explain-MOGL4GEA.js +0 -1
  126. package/dist/workspace-explain-contract-W2E6LF4Q.js +0 -1
  127. package/dist/workspace-graph-token-efficiency-Z5JD5NHI.js +0 -1
  128. package/dist/workspace-intelligence-evaluation-GONCRE6O.js +0 -1
  129. package/dist/workspace-knowledge-graph-snapshot-5YIG6EMG.js +0 -1
  130. 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,
@@ -268,13 +273,24 @@ that retrieval payload with the readable proof-indexed corpus using a labelled
268
273
  `characters / 4` estimate. It measures payload reduction only; it does not
269
274
  assert equivalent answer quality or model-specific billing savings.
270
275
 
276
+ `workspace graph benchmark-suite agent-core.v1 --write --json` runs five fixed,
277
+ repository-neutral scenarios covering architecture, ownership, interfaces,
278
+ change safety, and delivery. It reads the proof corpus once, reports median and
279
+ p95 bounded retrieval sizes, and writes
280
+ `.workspai/reports/workspace-intelligence-benchmark-last-run.json`. If a
281
+ finalized `workspace eval` report exists, its usage and verified outcome are
282
+ attached under a separate provenance classification. Pass `--from
283
+ <baseline-evaluation>` only for a task-aligned comparison. A measured reduction
284
+ is emitted only when both runs use measured token sources and have comparable
285
+ verified outcomes. See [Workspace Intelligence Benchmark](./workspace-intelligence-benchmark.md).
286
+
271
287
  Add `--scope project:<name>` to retrieve project-owned facts plus
272
288
  workspace-level shared entities proven to be connected to that project. The
273
289
  `search` mode also accepts `--kind <entity-kind>` so agents can retrieve a
274
290
  precise semantic surface such as `runtime-unit`, `endpoint`, or `owner`. The
275
291
  agent projection reports explicit omission budgets for relations, related
276
292
  entities, proofs, aliases, attributes, and proof references. Read-oriented
277
- `search`, `entities`, `evidence`, `path`, and `benchmark` modes reuse the
293
+ `search`, `entities`, `evidence`, `path`, `benchmark`, and `benchmark-suite` modes reuse the
278
294
  persisted graph only when its model binding, proofs, project scopes, and live
279
295
  Git/Merkle input fingerprint still match. `--refresh-graph` bypasses that
280
296
  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
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.
@@ -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,12 @@ 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
+
46
53
  `--capture` writes an atomic, deterministic SVG from the same Activity Board
47
54
  Model used by the terminal and exits. Captures are redacted by default: local
48
55
  scope, project, run and command-argument details are replaced while semantic
@@ -114,7 +121,7 @@ The implementation intentionally keeps this pipeline renderer-independent:
114
121
  ```text
115
122
  workspace-activity-event.v1
116
123
  -> deterministic monitor snapshot
117
- -> Activity Board Model (runs, nodes, edges, selection, counters)
124
+ -> workspace-activity-board.v1 (runs, nodes, edges, selection, counters)
118
125
  -> terminal + deterministic SVG adapters today / web and IDE adapters later
119
126
  ```
120
127
 
@@ -153,6 +160,9 @@ Every NDJSON line conforms to:
153
160
 
154
161
  ```text
155
162
  contracts/workspace-activity-event.v1.json
163
+ contracts/workspace-activity-monitor-snapshot.v1.json
164
+ contracts/workspace-activity-monitor-fleet.v1.json
165
+ contracts/workspace-activity-board.v1.json
156
166
  ```
157
167
 
158
168
  The stream contains run, block, attempt, origin, declared-edge, operation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspai",
3
- "version": "0.66.0",
3
+ "version": "0.67.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 +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};
@@ -1,157 +0,0 @@
1
- import {g,b,i as i$1,d as d$2,e as e$1,f}from'./chunk-TTHO4MFC.js';import {c}from'./chunk-334J2KIP.js';import {c as c$1}from'./chunk-X7FYEKLI.js';import {d as d$3,b as b$1,a as a$1}from'./chunk-3RBUSW7H.js';import {a}from'./chunk-AFIFZTOY.js';import {d as d$1}from'./chunk-EWZZUQBR.js';import {h,e,i}from'./chunk-6UNATTB7.js';import {u,h as h$1,g as g$1}from'./chunk-VQZ5PI5J.js';import be from'crypto';import ne from'fs';import y from'fs/promises';import d from'path';import {execa}from'execa';import X from'fs-extra';async function Q(e,t){let[n,r]=await Promise.all([X.realpath(e).catch(()=>null),X.realpath(t).catch(()=>null)]);if(!n||!r)return null;let s=d.relative(n,r);return !s||d.isAbsolute(s)||s===".."||s.startsWith(`..${d.sep}`)?null:(await X.stat(r).catch(()=>null))?.isFile()?r:null}var Ne=h.projectContextAgent.schemaVersion,ft=["managed","local","off"],se="<!-- WORKSPAI:PROJECT-GROUNDING:START -->",ve="<!-- WORKSPAI:PROJECT-GROUNDING:END -->",ee="<!-- WORKSPAI:GENERATED-PROJECT-SKILL -->",B=".agents/skills/workspai-grounding/SKILL.md";function he(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}async function E(e){try{return JSON.parse(await y.readFile(e,"utf8"))}catch(t){return null}}function W(e){return e.replace(/\\/g,"/").replace(/^\.\/+/,"")}function _(e,t,n){let r=e.replace(/\\/g,"/"),s=/^[A-Za-z]:\//.test(r);if(!d.isAbsolute(e)&&!s)return W(r);if(s&&process.platform!=="win32")return null;let a=d.resolve(e),i=d.relative(n,a);if(i&&!i.startsWith("..")&&!d.isAbsolute(i))return W(i);let c=d.relative(t,a);return c&&!c.startsWith("..")&&!d.isAbsolute(c)?`workspace:${W(c)}`:null}function I(e,t,n){return [[n,"project:"],[n.replace(/\\/g,"/"),"project:"],[t,"workspace:"],[t.replace(/\\/g,"/"),"workspace:"]].reduce((s,[a,i])=>a.length>0?s.split(a).join(i):s,e)}function Ee(e,t){return he(e?.adoption)?.mode==="linked"?"adopted":he(e?.import)?"imported":t}function xe(e){if(!e.model)return null;let t=W(e.relativePath);return e.model.projects.find(n=>n.name===e.projectName||W(n.path)===t)??null}function U(e,t){e[t]=(e[t]??0)+1;}var fe=["project","language","service","api","endpoint","schema","protocol","runtime-unit","lifecycle-stage","database","queue","container","deployment","pipeline","environment","test-suite","owner","decision","document","package","file","module","symbol"],te=48,oe=12*1024;function Le(e,t=te,n=oe){let r={language:12,api:8,service:8,endpoint:8,schema:8,protocol:8,"runtime-unit":12,"lifecycle-stage":12,file:4,module:4,symbol:4},s=new Map,a={};for(let u of e)U(a,u.kind);for(let u of fe)s.set(u,e.filter(h=>h.kind===u).sort((h,f)=>h.label.localeCompare(f.label)||h.id.localeCompare(f.id)).slice(0,r[u]??6));let i=[],c={},m=0,p=0,l=true;for(;i.length<t&&l;){l=false;for(let u of fe){let h=s.get(u)?.[p];if(!h)continue;let f=Buffer.byteLength(JSON.stringify(h));if(!(m+f>n)&&(i.push(h),m+=f,U(c,u),l=true,i.length>=t))break}p+=1;}let k=Object.fromEntries(Object.entries(a).map(([u,h])=>[u,h-(c[u]??0)]).filter(([,u])=>u>0).sort(([u],[h])=>u.localeCompare(h)));return {entities:i,selectedBytes:m,selectedByKind:c,omittedByKind:k}}function $e(e,t){if(!e)return {entityCount:0,relationCount:0,proofCount:0,entitiesByKind:{},relationsByKind:{},languages:{},semantic:{protocolConceptCount:0,protocolImplementationBindings:0,equivalenceBindings:0,generationBindings:0,runtimeUnitCount:0,lifecycleStageCount:0,runtimeCoverage:[]},projection:{mode:"stratified-byte-bounded",maxEntities:te,byteBudget:oe,selectedBytes:0,eligibleCount:0,selectedCount:0,omittedCount:0,selectedByKind:{},omittedByKind:{}},relatedProjects:[],proofArtifacts:[],entities:[],relations:[],proofs:[],topology:{status:"unavailable",dependencies:[],dependents:[]},diagnostics:[]};let n=e.entities.find(o=>o.kind==="project"&&(o.id===t||o.label===t||o.projectId===t)),r=new Set(e.entities.filter(o=>o.projectId===t||o.id===n?.id||o.kind==="project"&&o.label===t).map(o=>o.id));n&&r.add(n.id);let s=e.relations.filter(o=>r.has(o.from)||r.has(o.to)),a=new Set(r);for(let o of s)a.add(o.from),a.add(o.to);let i=e.entities.filter(o=>a.has(o.id)),c=new Set,m={},p={},l={},k=new Set(i.filter(o=>o.kind==="language").map(o=>o.attributes.language).filter(o=>typeof o=="string"));for(let o of i){U(m,o.kind);let w=typeof o.attributes.language=="string"?o.attributes.language:void 0;if(w&&o.kind==="language")l[w]={fileCount:typeof o.attributes.fileCount=="number"?o.attributes.fileCount:0,symbolCount:l[w]?.symbolCount??0,generatedFileCount:typeof o.attributes.generatedFileCount=="number"?o.attributes.generatedFileCount:0};else if(w&&(o.kind==="file"||o.kind==="symbol")){let b=l[w]??{fileCount:0,symbolCount:0,generatedFileCount:0};o.kind==="file"&&!k.has(w)?(b.fileCount+=1,o.attributes.generated===true&&(b.generatedFileCount+=1)):o.kind==="symbol"&&(b.symbolCount+=1),l[w]=b;}for(let b of o.proofIds)c.add(b);}for(let o of s){U(p,o.kind);for(let w of o.proofIds)c.add(w);}let u=e.proofs.filter(o=>c.has(o.id)),h=[...new Set(e.entities.filter(o=>a.has(o.id)&&o.projectId&&o.projectId!==t).map(o=>o.projectId))].sort(),f=e.diagnostics.filter(o=>(!o.entityIds||o.entityIds.length===0)&&(!o.relationIds||o.relationIds.length===0)||o.entityIds?.some(w=>a.has(w))||o.relationIds?.some(w=>s.some(b=>b.id===w))).map(o=>({code:o.code,severity:o.severity,message:o.message,...o.recommendation?{recommendation:o.recommendation}:{}})),j=(o,w)=>({project:w,kind:o.kind,source:o.source,confidence:o.confidence,evidence:[...new Set(o.evidence.map(b=>b.file.replace(/\\/g,"/")))].sort()}),P=e.projectTopology.edges.filter(o=>o.from===t).map(o=>j(o,o.to)).sort((o,w)=>`${o.project}:${o.kind}`.localeCompare(`${w.project}:${w.kind}`)),S=e.projectTopology.edges.filter(o=>o.to===t).map(o=>j(o,o.from)).sort((o,w)=>`${o.project}:${o.kind}`.localeCompare(`${w.project}:${w.kind}`)),N=Le(i),T=N.entities,L=i.filter(o=>o.kind==="runtime-unit"),A=new Set(T.map(o=>o.id)),$=[...s].sort((o,w)=>{let b=Number(A.has(o.from)||A.has(o.to));return Number(A.has(w.from)||A.has(w.to))-b||o.id.localeCompare(w.id)}).slice(0,16),D=new Set([...T.flatMap(o=>o.proofIds),...$.flatMap(o=>o.proofIds)]),g=u.filter(o=>D.has(o.id)).sort((o,w)=>o.id.localeCompare(w.id)).slice(0,16);return {entityCount:i.length,relationCount:s.length,proofCount:u.length,entitiesByKind:m,relationsByKind:p,languages:Object.fromEntries(Object.entries(l).sort(([o],[w])=>o.localeCompare(w))),semantic:{protocolConceptCount:m.protocol??0,protocolImplementationBindings:p["implements-protocol"]??0,equivalenceBindings:p["equivalent-to"]??0,generationBindings:(p["generated-from"]??0)+(p["generated-by"]??0),runtimeUnitCount:L.length,lifecycleStageCount:m["lifecycle-stage"]??0,runtimeCoverage:[...new Set(L.map(o=>o.attributes.runtime).filter(o=>typeof o=="string"))].sort()},projection:{mode:"stratified-byte-bounded",maxEntities:te,byteBudget:oe,selectedBytes:N.selectedBytes,eligibleCount:i.length,selectedCount:T.length,omittedCount:Math.max(0,i.length-T.length),selectedByKind:Object.fromEntries(Object.entries(N.selectedByKind).sort(([o],[w])=>o.localeCompare(w))),omittedByKind:N.omittedByKind},relatedProjects:h,proofArtifacts:[...new Set(g.map(o=>o.artifact))].sort().slice(0,24),entities:T,relations:$,proofs:g,topology:{status:P.length>0||S.length>0?"proven":e.projectTopology.nodes.some(o=>o.id===t)?"unproven":"unavailable",dependencies:P,dependents:S},diagnostics:f}}function Ae(e,t,n){return Array.isArray(e)?e.map(r=>typeof r=="string"?I(r,t,n):r):typeof e=="string"?I(e,t,n):e}function Ge(e,t,n){return {id:e.id,kind:e.kind,label:I(e.label,t,n),attributes:Object.fromEntries(Object.entries(e.attributes).map(([r,s])=>[r,Ae(s,t,n)])),proofIds:[...e.proofIds].sort()}}function We(e,t,n){let r=(...a)=>e.filter(i=>a.includes(i.kind)).map(i=>Ge(i,t,n)).slice(0,4),s=[];for(let a of e){for(let[i,c]of Object.entries(a.attributes))if(/(?:^|[-_.])ports?(?:$|[-_.])/i.test(i)&&(s.push({entityId:a.id,label:I(a.label,t,n),attribute:i,value:Ae(c,t,n)}),s.length>=8))break;if(s.length>=8)break}return {services:r("service"),packages:r("package"),protocols:r("protocol"),runtimeUnits:r("runtime-unit"),lifecycleStages:r("lifecycle-stage"),apis:r("api"),endpoints:r("endpoint"),dataStores:r("database","queue"),deployments:r("container","deployment","environment"),pipelines:r("pipeline"),tests:r("test-suite"),owners:r("owner"),decisions:r("decision"),ports:s}}function Oe(e,t,n){let r=_(e.artifact,t,n);return r?{id:e.id,provider:e.provider,artifact:r,...e.pointer?{pointer:I(e.pointer,t,n)}:{},...e.line!==void 0?{line:e.line}:{},derivation:e.derivation,trust:e.trust,confidence:e.confidence,freshness:e.freshness}:null}async function Ke(e,t,n){let r=[],s=await E(d.join(e,".workspai","reports","INDEX.json"));if(Array.isArray(s?.blockers))for(let l of s.blockers)typeof l=="string"&&(l.startsWith(`${n}:`)||l.includes(`project:${n}`)||l.includes(`project ${n}`))&&r.push({source:"workspace-report-index",severity:"error",message:I(l,e,t)});let a=await E(d.join(e,".workspai","reports","doctor-project-last-run.json")),i=await E(d.join(e,".workspai","reports","doctor-last-run.json")),c=i?.projects?.find(l=>l.name===n),p=[...a?.project&&(a.projectName===n||a.project.name===n)?[{generatedAt:a.generatedAt,project:a.project}]:[],...c?[{generatedAt:i?.generatedAt,project:c}]:[]].sort((l,k)=>{let u=typeof l.generatedAt=="string"&&Date.parse(l.generatedAt)||0;return (typeof k.generatedAt=="string"&&Date.parse(k.generatedAt)||0)-u})[0];if(p)for(let l of c$1({project:p.project}))r.push({source:"doctor-project",severity:l.status==="blocking"?"error":"warning",message:I(l.message,e,t),...l.id?{code:l.id}:{}});return [...new Map(r.map(l=>[`${l.source}:${l.code??""}:${l.message}`,l])).values()].slice(0,32)}function re(e,t=[]){return typeof e=="string"?/^[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])[A-Za-z]:[\\/]/.test(e)||/(?:^|[\s("'`])\/(?:Users|home|private|var|opt|srv|mnt|Volumes|tmp)\//.test(e)||t.some(n=>n.length>0&&(e.includes(n)||e.includes(n.replace(/\\/g,"/")))):Array.isArray(e)?e.some(n=>re(n,t)):e&&typeof e=="object"?Object.values(e).some(n=>re(n,t)):false}function _e(e){return be.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Fe(e$1){let t=d.resolve(e$1.workspacePath),n=d.resolve(e$1.projectPath),r=u(n,"project.json").find(g=>ne.existsSync(g)),s=r?await E(r):null,a$1=await E(d.join(t,".workspai","workspace.contract.json")),i$1=d.resolve(n),c=a$1?.projects?.find(g=>g.externalPath?d.resolve(g.externalPath)===i$1:!g.relativePath||g.relativePath.startsWith("external/")?false:d.resolve(t,g.relativePath)===i$1)??a$1?.projects?.find(g=>g.slug===e$1.projectName||g.slug===d.basename(n)),m=e$1.projectName??(typeof s?.name=="string"?s.name:void 0)??c?.slug??d.basename(n),p=c?.relativePath??(()=>{let g=W(d.relative(t,n));return !g||g.startsWith("..")?`external/${m}`:g})(),l=await E(d.join(t,e.model)),k=await E(d.join(t,e.knowledgeGraph)),u$1=l?d$1(l):void 0,h=!!(u$1&&k?.source.hash===u$1),f=xe({model:l,projectName:m,relativePath:p}),j=$e(h?k:null,m),P=await Ke(t,n,m),S=j.proofs.map(g=>g.freshness),N=k?!h||S.includes("stale")?"stale":S.includes("unknown")?"unknown":"fresh":"missing",T=l?l.factFreshness?.status??"unknown":"missing",L=[...l?[]:[{code:"project.context.model-missing",severity:"warning",message:"The canonical Workspace Model has not been generated yet. Refresh workspace intelligence before relying on project topology."}],...l&&!f?[{code:"project.context.project-not-materialized",severity:"warning",message:"The project is registered in the workspace contract but is not present in the current Workspace Model."}]:[],...k?[]:[{code:"project.context.graph-missing",severity:"warning",message:"The Workspace Knowledge Graph has not been generated yet. Run the workspace intelligence loop to build proof-backed relationships."}],...k&&!h?[{code:"project.context.graph-model-mismatch",severity:"warning",message:"The persisted Knowledge Graph does not match the current Workspace Model and was excluded from this project lens."}]:[]],A=Ee(s,e$1.relationship??c?.relationship??"managed"),$={schemaVersion:Ne,generatedAt:(e$1.now??new Date).toISOString(),workspace:{name:a$1?.workspace?.name??l?.workspace.name??d.basename(t),...a$1?.workspace?.profile||l?.workspace.profile?{profile:a$1?.workspace?.profile??l?.workspace.profile}:{},relationship:A,contract:`workspace:${i.workspaceContract}`,projectKnowledgeGraph:i.projectKnowledgeGraphReference,model:`workspace:${e.model}`,knowledgeGraph:`workspace:${e.knowledgeGraph}`,index:`workspace:${e.agentIndex}`,context:`workspace:${e.agentContext}`,skillsIndex:`workspace:${e.skillsIndex}`,boundedGraphSearch:`workspai workspace graph search <task-query> --scope project:${m} --limit 12 --json`,access:{localBinding:i.projectWorkspaceLink,canonicalEvidenceAvailableAtGeneration:true,identityIsFilesystemPath:false,resolverCommand:"workspai project workspace status --json",portableUriScheme:"workspace:",resolvedPathPolicy:"runtime-private-never-persist"}},project:{name:m,relativePath:p,...f?.kind?{kind:f.kind}:{},...f?.runtime||c?.runtime?{runtime:f?.runtime??c?.runtime}:{},...f?.runtimeCandidates?.length?{runtimeCandidates:[...f.runtimeCandidates].sort()}:{},...f?.framework||c?.framework?{framework:f?.framework??c?.framework}:{},...f?.kit||c?.kit?{kit:f?.kit??c?.kit}:{},...f?.supportTier?{supportTier:f.supportTier}:{},...f?.governance?{governance:f.governance}:{},commands:{supported:[...f?.commands.supported??[]].sort(),unsupported:[...f?.commands.unsupported??[]].sort(),fleetStages:[...f?.commands.fleetStages??[]].sort()},importantFiles:[...new Set((f?.importantFiles??[]).map(g=>_(g,t,n)).filter(g=>g!==null))].sort()},intelligence:{...l?.generatedAt?{modelGeneratedAt:l.generatedAt}:{},...k?.generatedAt?{graphGeneratedAt:k.generatedAt}:{},...k?.source.hash?{graphModelHash:k.source.hash}:{},entityCount:j.entityCount,relationCount:j.relationCount,proofCount:j.proofCount,entitiesByKind:j.entitiesByKind,relationsByKind:j.relationsByKind,languages:j.languages,semantic:j.semantic,projection:{...j.projection,continuationCommand:`workspai workspace graph search <task-query> --scope project:${m} --limit 12 --json`},relatedProjects:j.relatedProjects,freshness:{model:T,graph:N,graphMatchesModel:h},topology:{...j.topology,dependencies:j.topology.dependencies.map(g=>({...g,evidence:g.evidence.map(o=>_(o,t,n)).filter(o=>o!==null)})),dependents:j.topology.dependents.map(g=>({...g,evidence:g.evidence.map(o=>_(o,t,n)).filter(o=>o!==null)}))},surfaces:We(j.entities,t,n),diagnostics:[...L,...j.diagnostics].map(g=>({...g,message:I(g.message,t,n),...g.recommendation?{recommendation:I(g.recommendation,t,n)}:{}}))},evidence:{readOrder:[b,".workspai/PROJECT-GROUNDING.md",i.projectContextAgent,"AGENTS.md","workspace:.workspai/goals/index.json",`workspace:${i.goalPackLastRun}`,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search <task-query> --scope project:${m} --limit 12 --json`],projectProofArtifacts:[...new Set(j.proofArtifacts.map(g=>_(g,t,n)).filter(g=>g!==null))],relations:j.relations.map(g=>({id:g.id,from:g.from,to:g.to,kind:g.kind,derivation:g.derivation,trust:g.trust,confidence:g.confidence,proofIds:[...g.proofIds].sort()})),proofs:j.proofs.map(g=>Oe(g,t,n)).filter(g=>g!==null)},blockers:P,agentRouting:{enforcement:"required",mandatoryPreflight:{command:"workspai agent bootstrap --for-agent generic --strict --json",successCondition:"ready"},workspaceLocator:{command:"workspai project workspace status --json",successCondition:"resolved",outputClassification:"machine-local",persistence:"forbidden",disclosure:"forbidden",portableUriScheme:"workspace:"},workspaceEvidenceRequiredFor:["repository-analysis","architecture-analysis","change-impact","cross-project-change","contract-change","infrastructure-change","release-readiness"],requiredReadOrder:[b,"command:workspai agent bootstrap --for-agent generic --strict --json","command:workspai project workspace status --json",i.projectContextAgent,"workspace:.workspai/reports/workspace-skills-index.json",`command:workspai workspace graph search ${JSON.stringify(m)} --scope ${JSON.stringify(`project:${m}`)} --limit 12 --json`],degradedMode:{allowCompleteArchitectureClaims:false,requireDisclosure:true}},commands:{refresh:"workspai workspace intelligence run --for-agent generic --strict --json",verify:"workspai workspace verify --strict --json",graphSearch:`workspai workspace graph search ${JSON.stringify(m)} --scope ${JSON.stringify(`project:${m}`)} --limit 12 --json`,doctor:"workspai doctor project --json",workspaceStatus:"workspai project workspace status --json"}};if(re($,[t,n]))throw new Error("Project context lens rejected a non-portable absolute path.");let D={...$,integrity:{algorithm:"sha256",...u$1?{modelHash:u$1}:{},payloadHash:_e($),portable:true,absolutePathsEmitted:false}};return a(D,"contracts/workspace-intelligence/project-context-agent.v1.json","Project context agent"),D}function Be(e){let t=e.intelligence.relatedProjects.length>0?e.intelligence.relatedProjects.map(s=>`\`${s}\``).join(", "):"No proven cross-project relation is currently available.",n=e.intelligence.diagnostics.length>0?e.intelligence.diagnostics.slice(0,8).map(s=>`- **${s.severity} \xB7 ${s.code}:** ${s.message}`).join(`
2
- `):"- No project-scoped graph diagnostic is currently recorded.",r=e.blockers.length>0?e.blockers.slice(0,12).map(s=>`- **${s.severity}${s.code?` \xB7 ${s.code}`:""}:** ${s.message}`).join(`
3
- `):"- No current project-scoped blocker is recorded.";return `# Workspai project grounding
4
-
5
- This project is adopted into the **${e.workspace.name}** Workspai workspace.
6
- That value is the canonical workspace identity, not its filesystem path. Workspai
7
- commands launched here resolve the machine-local workspace automatically.
8
-
9
- ## Mandatory first contact
10
-
11
- Do not begin broad repository discovery, architecture claims, planning, or mutation
12
- until this sequence is complete:
13
-
14
- 1. Read \`${b}\` to discover the portable protocol.
15
- 2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
16
- 3. Follow the receipt's \`requiredReadOrder\` exactly.
17
- 4. Read \`.workspai/reports/project-context-agent.json\`.
18
- 5. If the receipt reports an active Goal, read its immutable Goal Pack and agent
19
- handoff before choosing or expanding work.
20
- 6. Read the compact workspace Skills index and load only a matching playbook.
21
- 7. Query the bounded Workspace Graph with the user's actual task before opening broad
22
- source, then inspect only returned proof paths and targeted live files.
23
-
24
- Receipt policy:
25
-
26
- - \`ready\`: continue with bounded evidence and targeted source inspection.
27
- - \`degraded\`: disclose the limitation and do not claim complete architecture or verification.
28
- - \`blocked\`: stop governed claims, execute \`nextActions\`, and rerun bootstrap.
29
-
30
- ## Workspace location and portable paths
31
-
32
- - \`${e.workspace.name}\` is an identity, not a directory name to guess.
33
- - Project-local paths begin with \`.workspai/\`.
34
- - Canonical workspace paths begin with \`workspace:\`.
35
- - Resolve the exact local workspace root only when direct file access is necessary by
36
- running \`workspai project workspace status --json\` from this project.
37
- - The resolver's absolute paths are machine-local runtime data. Never persist or copy
38
- them into answers, shared logs, commits, prompts, telemetry, or portable artifacts.
39
-
40
- ## Authority boundary
41
-
42
- The Workspace Model owns canonical project identity and its compact \`projectTopology\`.
43
- The Workspace Knowledge Graph is a separate, proof-backed enrichment containing
44
- files, symbols, APIs, infrastructure, tests, owners, and decisions. Do not treat
45
- an unproven topology edge as proof that two projects are independent. Live source owns
46
- exact implementation. CLI evidence owns Goal, readiness, repair, and verification claims.
47
- Repository-authored instructions remain authoritative for source changes after this
48
- entry gate; Workspai preserves rather than replaces them.
49
-
50
- ## Knowledge Graph routing
51
-
52
- - Project graph reference: \`${e.workspace.projectKnowledgeGraph}\`. It integrity-binds
53
- this project to its exact canonical projection without duplicating the full graph.
54
- - Workspace aggregate: \`${e.workspace.knowledgeGraph}\`. Resolve it through the
55
- workspace binding only for cross-project or workspace-wide consumption.
56
- - Default agent path: use the bounded graph-search command below; resolve the canonical
57
- graph only when the task explicitly requires full graph interchange.
58
-
59
- ## Project
60
-
61
- - Name: \`${e.project.name}\`
62
- - Workspace-relative identity: \`${e.project.relativePath}\`
63
- - Runtime: \`${e.project.runtime??"unknown"}\`
64
- - Framework: \`${e.project.framework??"unknown"}\`
65
- - Relationship: \`${e.workspace.relationship}\`
66
- - Related projects: ${t}
67
- - Topology status: \`${e.intelligence.topology.status}\`
68
- - Model freshness: \`${e.intelligence.freshness.model}\`
69
- - Knowledge Graph freshness: \`${e.intelligence.freshness.graph}\`
70
-
71
- ## Current evidence coverage
72
-
73
- - Project-scoped entities: ${e.intelligence.entityCount}
74
- - Project-scoped relations: ${e.intelligence.relationCount}
75
- - Portable proofs: ${e.intelligence.proofCount}
76
-
77
- ${n}
78
-
79
- ## Current project blockers
80
-
81
- ${r}
82
-
83
- ## Safe commands from this project
84
-
85
- \`\`\`bash
86
- ${e.commands.workspaceStatus}
87
- ${e.commands.doctor}
88
- ${e.commands.graphSearch}
89
- ${e.commands.verify}
90
- \`\`\`
91
-
92
- The machine-local workspace binding lives only in
93
- \`.workspai/workspace-link.local.json\`, which is gitignored. Portable grounding files
94
- never publish its value.
95
- `}function Me(e){return `# Workspai agent entry gate (mandatory)
96
-
97
- - Project: \`${e.project.name}\`
98
- - Workspace identity: \`${e.workspace.name}\` (logical name, not a filesystem path)
99
- - Entry contract: \`${b}\`
100
-
101
- Before broad repository discovery, architecture claims, planning, or mutation:
102
-
103
- 1. Read \`${b}\`.
104
- 2. Run \`workspai agent bootstrap --for-agent generic --strict --json\`.
105
- 3. Follow the receipt's \`requiredReadOrder\` exactly.
106
- 4. If a Goal is active, read its immutable Goal Pack and handoff before acting.
107
- 5. Read the compact workspace Skills index and load only a matching playbook.
108
- 6. Query the bounded Workspace Graph with the user's task, then inspect only returned proofs and targeted live source.
109
-
110
- Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations and may not claim complete architecture or verification; \`blocked\` must stop governed claims, execute \`nextActions\`, and rerun bootstrap.
111
-
112
- \`workspace:\` paths belong to the canonical workspace, not this project's \`.workspai\` directory. Resolve their machine-local root at runtime with \`workspai project workspace status --json\`. That output is machine-local: never copy it into answers, shared logs, commits, or portable artifacts.
113
-
114
- Authority: Workspai evidence owns identity, topology, goals, readiness, and verification. Live source and repository-authored rules own exact implementation and source conventions.`}function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(e,t){return new RegExp(`${ke(e)}[\\s\\S]*?${ke(t)}`,"m")}function Ce(e){let t=e.replace(q(se,ve),"");return d$3(t)?.includes("# Workspai project boundary")&&(t=t.replace(q(a$1,b$1),"")),t.replace(/\n{3,}/g,`
115
-
116
- `).trim()}function De(e,t){let n=Ce(e),r=`${se}
117
- ${t.trim()}
118
- ${ve}`;return n?`${r}
119
-
120
- ${n}
121
- `:`${r}
122
- `}async function x(e,t){await y.mkdir(d.dirname(e),{recursive:true});let n=`${e}.${process.pid}.${be.randomUUID()}.tmp`;try{await y.writeFile(n,t,"utf8");try{await y.rename(n,e);}catch(r){let s=r.code;if(s!=="EEXIST"&&s!=="EPERM")throw r;await X.move(n,e,{overwrite:true});}}finally{await y.rm(n,{force:true}).catch(()=>{});}}async function F(e,t){let n=d.resolve(e),r=await y.realpath(n).catch(()=>n),s=d.resolve(t),a=d.relative(n,s);if(!a||a===".."||a.startsWith(`..${d.sep}`)||d.isAbsolute(a))throw new Error("Project agent output path must remain inside the project.");let i=a.split(d.sep),c=n;for(let[m,p]of i.entries()){c=d.join(c,p);let l=await y.lstat(c).catch(u=>{if(u.code==="ENOENT")return null;throw u});if(!l)return d.join(c,...i.slice(m+1));let k=m===i.length-1;if(l.isSymbolicLink()){if(k)throw new Error(`Project agent output is blocked by authored state: ${a}`);let u=await y.realpath(c),h=d.relative(r,u),f=await y.stat(u);if(h===".."||h.startsWith(`..${d.sep}`)||d.isAbsolute(h)||!f.isDirectory())throw new Error(`Project agent output is blocked by authored state: ${a}`);c=u;continue}if(k?!l.isFile():!l.isDirectory())throw new Error(`Project agent output is blocked by authored state: ${a}`)}return c}async function kt(e$1){let t=d.join(e$1.projectPath,".agents","skills");try{await F(e$1.projectPath,d.join(t,"workspai-grounding","SKILL.md"));}catch{return []}let n=await E(d.join(e$1.workspacePath,e.skillsIndex)),r=new Set([B,...(n?.skills??[]).map(i=>`.agents/skills/${i.skillId}/SKILL.md`)]),s=await y.readdir(t,{withFileTypes:true}).catch(i=>{if(i.code==="ENOENT")return [];throw i});for(let i of s)i.isDirectory()&&i.name.startsWith("workspai-")&&r.add(`.agents/skills/${i.name}/SKILL.md`);let a=[];for(let i of r){let c=d.join(e$1.projectPath,i);a.push(await F(e$1.projectPath,c));}return a}function Je(e,t){let n=t?.skillId??"workspai-grounding",r=t?.title??"Workspai project grounding",s=t?`workspace:${t.path}`:null;return ["---",`name: ${n}`,`description: ${JSON.stringify(`${r} through the Workspai project intelligence contract`)}`,"---","",ee,"",`# ${r}`,"",`This is a portable project entry for \`${e.project.name}\`. It contains no machine-local workspace path.`,"","## Workflow","",`1. Read \`${b}\`.`,"2. Run `workspai agent bootstrap --for-agent generic --strict --json`.","3. Continue only when the receipt permits it and follow its bounded `requiredReadOrder`.",...s?[`4. Resolve and follow the canonical Skill \`${s}\` listed in \`workspace:.workspai/reports/workspace-skills-index.json\`.`,`5. Query the graph with \`workspai workspace graph search <task-query> --scope project:${e.project.name} --limit 12 --json\` before broad source inspection.`]:["4. Load only the matching canonical Skill from `workspace:.workspai/reports/workspace-skills-index.json`.",`5. Query the graph with \`workspai workspace graph search <task-query> --scope project:${e.project.name} --limit 12 --json\` before broad source inspection.`],"","Repository-authored instructions and live source remain authoritative for exact implementation.",""].join(`
123
- `)}async function we(e$1){let t=d.join(e$1.projectPath,".agents","skills"),n=await E(d.join(e$1.workspacePath,e.skillsIndex)),r=e$1.context?[{relativePath:B,skill:void 0},...(n?.skills??[]).map(p=>({relativePath:`.agents/skills/${p.skillId}/SKILL.md`,skill:p}))]:[],s=new Set(r.map(p=>p.relativePath)),a=[],i=[],c=[];try{await F(e$1.projectPath,d.join(t,"workspai-grounding","SKILL.md"));}catch(p){return {availableFiles:a,writtenFiles:i,authoredCollisions:c,reason:String(p)}}if(e$1.mode==="managed"&&e$1.context)for(let p of r){let l=d.join(e$1.projectPath,p.relativePath),k=await F(e$1.projectPath,l),u=await y.readFile(k,"utf8").catch(f=>{if(f.code==="ENOENT")return "";throw f});if(u&&!u.includes(ee)){a.push(p.relativePath),c.push(p.relativePath);continue}let h=Je(e$1.context,p.skill);h!==u&&await x(k,h),a.push(p.relativePath),i.push(p.relativePath);}let m=await y.readdir(t,{withFileTypes:true}).catch(p=>{if(p.code==="ENOENT")return [];throw p});for(let p of m){if(!p.isDirectory()||!p.name.startsWith("workspai-"))continue;let l=`.agents/skills/${p.name}/SKILL.md`;if(e$1.mode==="managed"&&s.has(l))continue;let k=d.join(e$1.projectPath,l),u=await F(e$1.projectPath,k);(await y.readFile(u,"utf8").catch(()=>"")).includes(ee)&&await y.rm(d.dirname(u),{recursive:true,force:true});}return {availableFiles:a,writtenFiles:i,authoredCollisions:c}}async function Re(e,t){let n;try{n=await execa("git",["rev-parse","--show-toplevel"],{cwd:e,reject:false});}catch{return false}if(n?.exitCode!==0)return false;let r=n.stdout.trim();if(!r)return false;let s,a;try{[s,a]=await Promise.all([y.realpath(d.resolve(r)),y.realpath(e)]);}catch{return false}let i=d.resolve(a,t),c=d.relative(s,i).replace(/\\/g,"/");if(!c||d.isAbsolute(c)||c===".."||c.startsWith("../"))return false;let m;try{m=await execa("git",["cat-file","-e",`HEAD:${c}`],{cwd:s,reject:false});}catch{return false}if(m?.exitCode!==0)return false;let p;try{p=await execa("git",["ls-files","--deleted","--error-unmatch","--",`:(top)${c}`],{cwd:s,reject:false});}catch{return false}return p?.exitCode===0}async function ye(e,t){let n=d.join(e,".gitignore"),r=await y.readFile(n,"utf8").catch(c=>{if(c.code==="ENOENT")return "";throw c}),s=[g$1,h$1,b],a=r.split(/\r?\n/).filter(c=>c.trim()!=="# Workspai local project grounding"&&!s.includes(c.trim()));for(;a.length>0&&a[a.length-1]==="";)a.pop();t==="local"&&(a.length>0&&a.push(""),a.push("# Workspai local project grounding",...s));let i=a.length>0?`${a.join(`
124
- `)}
125
- `:"";i!==r&&await x(n,i);}var M=[{host:"claude",relativePath:"CLAUDE.md",importFromAgents:"@AGENTS.md",importFromGrounding:"@.workspai/PROJECT-GROUNDING.md"},{host:"gemini",relativePath:"GEMINI.md",importFromAgents:"@./AGENTS.md",importFromGrounding:"@./.workspai/PROJECT-GROUNDING.md"},{host:"qwen",relativePath:"QWEN.md",importFromAgents:"@AGENTS.md",importFromGrounding:"@.workspai/PROJECT-GROUNDING.md"},{host:"amazon-q",relativePath:".amazonq/rules/workspai-agent-entry.md",importFromAgents:"",importFromGrounding:""}];if(M.length!==g.length||M.some((e,t)=>e.relativePath!==g[t]))throw new Error("Project agent adapter paths must match the portable entry contract.");async function Ue(e,t){let n=t.split("/").slice(0,-1),r=e;for(let s of n){r=d.join(r,s);let a=await y.lstat(r).catch(i=>{if(i.code==="ENOENT")return null;throw i});if(!a)return null;if(a.isSymbolicLink()||!a.isDirectory())return d.relative(e,r).split(d.sep).join("/")}return null}function qe(e){let t=e.agentsAvailable?e.adapter.importFromAgents:e.adapter.importFromGrounding;return t?`${t}
126
-
127
- # Workspai host binding \xB7 ${e.adapter.host}
128
-
129
- The imported Workspai entry gate is mandatory. Validate this host with
130
- \`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`, then follow
131
- the receipt's \`requiredReadOrder\`, Goal handoff, bounded Graph queries, proof paths,
132
- status policy, workspace locator privacy policy, and authority boundary. Do not repeat
133
- the imported instructions or replace repository-authored source rules.`:`# Workspai entry for ${e.adapter.host}
134
-
135
- Before broad repository discovery, architecture claims, planning, or mutation:
136
-
137
- 1. Read \`${b}\`.
138
- 2. Run \`workspai agent bootstrap --for-agent ${e.adapter.host} --strict --json\`.
139
- 3. Follow \`requiredReadOrder\`, any active Goal handoff, bounded Graph queries, and returned proof paths.
140
-
141
- Receipt policy: \`ready\` may proceed; \`degraded\` must disclose limitations; \`blocked\` must execute \`nextActions\` and rerun bootstrap before governed claims.
142
-
143
- The workspace name is a logical identity, not a path. Resolve \`workspace:\` URIs at runtime with \`workspai project workspace status --json\`; its absolute paths are machine-local and must never be copied into shared output or portable artifacts. Live source owns exact implementation; Workspai evidence owns identity, topology, goals, readiness, and verification. Repository-authored rules remain authoritative for source changes after this entry gate.`}async function je(e){let t=await Ue(e.projectPath,e.adapter.relativePath);if(t)return {reason:`${e.adapter.relativePath} has an unsafe repository-authored parent at ${t}.`};let n=d.join(e.projectPath,e.adapter.relativePath),r=n,s=await y.lstat(n).catch(l=>{if(l.code==="ENOENT")return null;throw l});if(s?.isSymbolicLink()){let l=await Q(e.projectPath,n);if(!l)return {reason:`${e.adapter.relativePath} is a symbolic link without a safe repository-local file target.`};let k=await y.readFile(l,"utf8");if(e.agentsAvailable&&k.includes(se)){let h=`${k.replace(q(d$2,e$1),"").replace(/\n{3,}/g,`
144
-
145
- `).trimEnd()}
146
- `;return h!==k&&await x(l,h),{path:e.adapter.relativePath}}if(k.includes(d$2))return {path:e.adapter.relativePath};r=l;}let a=s?.isFile()===true,i=await y.readFile(r,"utf8").catch(l=>{if(l.code==="ENOENT")return "";throw l});if(e.mode==="managed"&&!a&&await Re(e.projectPath,e.adapter.relativePath))return {reason:`${e.adapter.relativePath} has an authored tracked deletion.`};let c=i.replace(q(d$2,e$1),"").replace(/\n{3,}/g,`
147
-
148
- `).trim(),m=e.mode==="managed"?[c,`${d$2}
149
- ${qe(e).trim()}
150
- ${e$1}`].filter(Boolean).join(`
151
-
152
- `):c;if(!m)return a&&!s?.isSymbolicLink()&&await y.rm(r,{force:true}),{};let p=`${m.trimEnd()}
153
- `;return p!==i&&await x(r,p),e.mode==="managed"?{path:e.adapter.relativePath}:{}}function He(e){let t={id:"generic",discovery:"portable-fallback",entryFiles:[g$1],status:"ready",managed:e.mode==="managed"},r=["codex","kimi","grok","copilot","cursor","windsurf"].map(i=>({id:i,discovery:"native",entryFiles:["AGENTS.md",...["codex","kimi","grok"].includes(i)&&e.portableSkillsAvailable?[B]:[]],status:e.agentsAvailable?["codex","kimi","grok"].includes(i)&&!e.portableSkillsAvailable?"blocked":["codex","kimi","grok"].includes(i)&&e.portableGroundingAuthoredCollision?"degraded":"ready":"blocked",managed:e.mode==="managed"&&e.agentsAvailable&&(!["codex","kimi","grok"].includes(i)||e.portableSkillsAvailable&&!e.portableGroundingAuthoredCollision),...e.agentsAvailable?["codex","kimi","grok"].includes(i)&&!e.portableSkillsAvailable?{reason:e.portableSkillsReason??"The provider-neutral project Skill projection could not be generated safely."}:["codex","kimi","grok"].includes(i)&&e.portableGroundingAuthoredCollision?{reason:"An authored Skill occupies the Workspai grounding path; it was preserved and AGENTS.md remains the fallback entry."}:{}:{reason:"AGENTS.md could not be managed without overriding authored repository state."}})),s=M.map(i=>{let c=e.adapters.get(i.host);return {id:i.host,discovery:"adapter",entryFiles:[i.relativePath],status:c?.path?"ready":e.mode==="managed"?"blocked":"degraded",managed:!!c?.path,...c?.path?{}:{reason:c?.reason??"Provider adapter generation is disabled by the project grounding policy."}}}),a=[t,...r,...s];return f.map(i=>a.find(c=>c.id===i))}async function Pe(e,t,n){let r=d.join(e,"AGENTS.md"),s=await y.lstat(r).catch(l=>{if(l.code==="ENOENT")return null;throw l}),a=s?.isSymbolicLink()?await Q(e,r):r;if(!a)return;let i=s?.isFile()===true||s?.isSymbolicLink()===true,c=await y.readFile(a,"utf8").catch(l=>{if(l.code==="ENOENT")return "";throw l});if(t==="managed"&&!n)throw new Error("Managed project grounding requires a project context.");if(t==="managed"&&!i&&await Re(e,"AGENTS.md"))return;let m=t==="managed"&&n?De(c,Me(n)):Ce(c);if(!m){i&&!s?.isSymbolicLink()&&await y.rm(a,{force:true});return}let p=`${m.trimEnd()}
154
- `;return p!==c&&await x(a,p),t==="managed"?r:void 0}async function ze(e){let t=e.mode??"managed",n=d.resolve(e.workspacePath),r=d.resolve(e.projectPath);if(t==="off"){let P=u(r,"project.json").find(A=>ne.existsSync(A)),S=P?await E(P):null,N=e.projectName??(typeof S?.name=="string"?S.name:void 0)??d.basename(r),T=Ee(S,e.relationship??"managed"),L=await c({workspacePath:n,projectPath:r,projectName:N,relationship:T,now:e.now});return await ye(r,t),await Pe(r,t),await we({workspacePath:n,projectPath:r,mode:t}),await Promise.all(M.map(A=>je({projectPath:r,adapter:A,mode:t,agentsAvailable:false}))),await Promise.all([y.rm(d.join(r,h$1),{force:true}),y.rm(d.join(r,g$1),{force:true}),y.rm(d.join(r,b),{force:true}),y.rm(d.join(r,i.projectKnowledgeGraphReference),{force:true})]),{mode:t,projectPath:r,linkPath:L.linkPath,writtenFiles:[i.projectWorkspaceLink]}}let s=await Fe(e),a=s.workspace.relationship,i$2=await c({workspacePath:n,projectPath:r,projectName:s.project.name,relationship:a,workspaceName:s.workspace.name,relativePath:s.project.relativePath,now:e.now});await ye(r,t);let c$1=await Pe(r,t,s),m=new Map;for(let P of M)m.set(P.host,await je({projectPath:r,adapter:P,mode:t,agentsAvailable:!!c$1}));let p=await we({workspacePath:n,projectPath:r,mode:t,context:s}),l=He({mode:t,agentsAvailable:!!c$1,portableSkillsAvailable:p.availableFiles.includes(B),portableGroundingAuthoredCollision:p.authoredCollisions.includes(B),...p.reason?{portableSkillsReason:p.reason}:{},adapters:m}),k=d.join(r,h$1),u$1=d.join(r,g$1),h=d.join(r,b),f=i$1({context:s,hosts:l});await x(k,`${JSON.stringify(s,null,2)}
155
- `),await x(u$1,`${Be(s).trimEnd()}
156
- `),await x(h,`${JSON.stringify(f,null,2)}
157
- `);let j=[i.projectWorkspaceLink,h$1,g$1,b];c$1&&j.push("AGENTS.md");for(let P of m.values())P.path&&j.push(P.path);return j.push(...p.writtenFiles),{mode:t,projectPath:r,linkPath:i$2.linkPath,groundingPath:u$1,contextPath:k,agentEntryPath:h,agentsPath:c$1,hostCoverage:l,writtenFiles:j}}async function wt(e){let t=d.resolve(e.workspacePath),n=e.mode??"managed",r=await Ve(t),s=[],a=[];for(let i of r.resolved)try{s.push(await ze({workspacePath:t,projectPath:i.projectPath,projectName:i.name,relationship:i.relationship,mode:n,now:e.now}));}catch(c){a.push({name:i.name,reason:c instanceof Error?c.message:String(c)});}return {workspacePath:t,mode:n,projects:s,skipped:[...r.skipped,...a]}}async function Ve(e){let t=d.resolve(e),n=await E(d.join(t,".workspai","workspace.contract.json")),r=[],s=[];for(let a of n?.projects??[]){let i=a.slug??a.relativePath??"unknown-project",c=typeof a.externalPath=="string"?d.resolve(a.externalPath):typeof a.relativePath=="string"&&!a.relativePath.startsWith("external/")?d.resolve(t,a.relativePath):null;if(!c||!ne.existsSync(c)){s.push({name:i,reason:"project path is unavailable on this machine"});continue}r.push({name:i,projectPath:c,relationship:a.relationship??"managed"});}return {resolved:r,skipped:s}}export{Q as a,Ne as b,ft as c,se as d,ve as e,ee as f,B as g,Le as h,Fe as i,kt as j,ze as k,wt as l,Ve as m};