workspai 0.69.0 → 0.71.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 (116) hide show
  1. package/README.md +43 -80
  2. package/contracts/workspace-intelligence/decision-event.v1.json +20 -0
  3. package/contracts/workspace-intelligence/goal-lifecycle-result.v1.json +19 -0
  4. package/contracts/workspace-intelligence/proof-carrying-change-capsule.v1.json +1 -0
  5. package/dist/analyze-4YQ67OCK.js +1 -0
  6. package/dist/{artifact-remediation-plan-JHHZ4L24.js → artifact-remediation-plan-URQL5MBN.js} +1 -1
  7. package/dist/autopilot-release-V3A3YCDD.js +1 -0
  8. package/dist/capabilities-command-NFGX42CH.js +1 -0
  9. package/dist/chunk-26VNCHVV.js +8 -0
  10. package/dist/{chunk-3G5FF2JZ.js → chunk-2KJNASF3.js} +1 -1
  11. package/dist/chunk-37SWTS2B.js +1 -0
  12. package/dist/{chunk-37ZLNFV5.js → chunk-4CE3GI4Y.js} +2 -2
  13. package/dist/chunk-554W2TXP.js +9 -0
  14. package/dist/{chunk-OU3BBWH5.js → chunk-5HURQABR.js} +5 -5
  15. package/dist/chunk-7V3YDKMG.js +4 -0
  16. package/dist/{chunk-MAWHHHU3.js → chunk-ACCWXKZW.js} +2 -2
  17. package/dist/{chunk-WZ5V5U2K.js → chunk-AUQLOQ2S.js} +1 -1
  18. package/dist/chunk-AUVWD3WV.js +2 -0
  19. package/dist/chunk-C563KVBD.js +1 -0
  20. package/dist/{chunk-N2Q4MSSP.js → chunk-CX6PAQTQ.js} +5 -5
  21. package/dist/chunk-FE5R6EUV.js +2 -0
  22. package/dist/{chunk-AD4ZY3RF.js → chunk-FFE2JZZJ.js} +8 -8
  23. package/dist/{chunk-EBEAJIBI.js → chunk-GL3KLNIG.js} +1 -1
  24. package/dist/{chunk-BM2F5C4J.js → chunk-H64KAPJJ.js} +1 -1
  25. package/dist/chunk-HMKDU7OU.js +2 -0
  26. package/dist/{chunk-IBJEQHJR.js → chunk-HV6EQMUJ.js} +24 -7
  27. package/dist/{chunk-EG6EZ7HW.js → chunk-IOKEF3DE.js} +1 -1
  28. package/dist/{chunk-A3MYO55A.js → chunk-IRLKWRLP.js} +2 -2
  29. package/dist/chunk-JK6XEF7K.js +6 -0
  30. package/dist/{chunk-ABMB6MJT.js → chunk-K2LKJBQ4.js} +1 -1
  31. package/dist/{chunk-V6TIT6M3.js → chunk-L5IV2SI4.js} +1 -1
  32. package/dist/{chunk-M37ALD4V.js → chunk-LOXR5QUX.js} +1 -1
  33. package/dist/{chunk-KFTJVVJR.js → chunk-M2R6UXJB.js} +1 -1
  34. package/dist/{chunk-XPGCFVGC.js → chunk-QHHSSIMZ.js} +1 -1
  35. package/dist/chunk-RMGSMDJW.js +5 -0
  36. package/dist/chunk-TD5TQZEG.js +2 -0
  37. package/dist/{chunk-YKY4JFCF.js → chunk-XVTN5DDV.js} +1 -1
  38. package/dist/chunk-XY537LCX.js +1 -0
  39. package/dist/chunk-YC676TPF.js +1 -0
  40. package/dist/chunk-YS34N35Y.js +2 -0
  41. package/dist/chunk-ZOE43SGQ.js +1 -0
  42. package/dist/{create-GWBQ74ZI.js → create-HSHAZYAK.js} +1 -1
  43. package/dist/{doctor-OQAXSMEM.js → doctor-VZ2MZ7EI.js} +1 -1
  44. package/dist/{dotnet-webapi-clean-XL4IBUQV.js → dotnet-webapi-clean-VJX6SGGP.js} +39 -33
  45. package/dist/{goal-lifecycle-YWBVQ2DF.js → goal-lifecycle-NKSCALES.js} +1 -1
  46. package/dist/{goal-pack-KUXPZVNO.js → goal-pack-MPKW4K6F.js} +1 -1
  47. package/dist/{gofiber-standard-OHHMCNMJ.js → gofiber-standard-I6ASLOEE.js} +77 -66
  48. package/dist/{gogin-standard-BAZXPOKL.js → gogin-standard-U2LSRLIP.js} +78 -67
  49. package/dist/index.js +102 -102
  50. package/dist/pipeline-RIA5UXUC.js +5 -0
  51. package/dist/{project-agent-entry-H3JAGNLS.js → project-agent-entry-GQAPCSOT.js} +1 -1
  52. package/dist/{project-intelligence-lens-7NMKHV5N.js → project-intelligence-lens-5I2GQBWC.js} +1 -1
  53. package/dist/{project-test-coverage-3DKZKLWY.js → project-test-coverage-4RRCHY5W.js} +1 -1
  54. package/dist/proof-carrying-change-T33C2SSD.js +1 -0
  55. package/dist/{rust-axum-CCJ6UCBW.js → rust-axum-JMV7UPO7.js} +25 -20
  56. package/dist/{springboot-standard-M5JQEJML.js → springboot-standard-OC2RS3KC.js} +41 -39
  57. package/dist/verified-goal-MK5MXGRY.js +1 -0
  58. package/dist/{workspace-TJHCETBV.js → workspace-AZKZPG45.js} +1 -1
  59. package/dist/{workspace-agent-sync-Z35NTXCB.js → workspace-agent-sync-CGK44F3O.js} +1 -1
  60. package/dist/{workspace-context-KNJQUJWC.js → workspace-context-S6ZWRUFZ.js} +1 -1
  61. package/dist/{workspace-contract-VIUQT5SZ.js → workspace-contract-Y7WRHLYR.js} +1 -1
  62. package/dist/{workspace-explain-HM6GMK26.js → workspace-explain-CSJL3GJR.js} +1 -1
  63. package/dist/{workspace-feedback-YSPEGCON.js → workspace-feedback-D6HJLKBQ.js} +1 -1
  64. package/dist/{workspace-foundation-PLXFPI3J.js → workspace-foundation-LLND2WIF.js} +1 -1
  65. package/dist/{workspace-graph-stream-FNRQ2FTB.js → workspace-graph-stream-PHFO2J2E.js} +1 -1
  66. package/dist/{workspace-history-HDDFG6LH.js → workspace-history-WWPS4U7H.js} +1 -1
  67. package/dist/{workspace-intelligence-QLSD5EEV.js → workspace-intelligence-ND2N3B2A.js} +1 -1
  68. package/dist/{workspace-intelligence-runner-4EW4T2OW.js → workspace-intelligence-runner-LHHJM2AT.js} +1 -1
  69. package/dist/{workspace-knowledge-graph-EEOW5VAJ.js → workspace-knowledge-graph-NOGGGENE.js} +1 -1
  70. package/dist/workspace-knowledge-graph-snapshot-7XHZNRFK.js +1 -0
  71. package/dist/workspace-mcp-serve-6NVF7AS6.js +3 -0
  72. package/dist/{workspace-model-NCOOY5LC.js → workspace-model-VOQOEDVU.js} +1 -1
  73. package/dist/{workspace-onboarding-JNC7ZFMR.js → workspace-onboarding-ZRLUMBLE.js} +1 -1
  74. package/dist/{workspace-readme-OV2ADTLW.js → workspace-readme-HA6XLDME.js} +2 -2
  75. package/dist/{workspace-registry-summary-ONT4VOJX.js → workspace-registry-summary-NWZK5IKS.js} +1 -1
  76. package/dist/workspace-repair-engine-VUOCH66O.js +3 -0
  77. package/dist/workspace-run-3YZTVOU6.js +1 -0
  78. package/dist/{workspace-verify-MLABQUWK.js → workspace-verify-4EQI3MCW.js} +1 -1
  79. package/dist/{workspace-watch-MJOG5AZ3.js → workspace-watch-BPRU2X7K.js} +1 -1
  80. package/docs/README.md +39 -34
  81. package/docs/README_CONTENT_CONTRACT.md +14 -9
  82. package/docs/ci-workflows.md +1 -1
  83. package/docs/commands-reference.md +41 -33
  84. package/docs/contracts/PROOF_CARRYING_CHANGE_CONTRACT_PLAN.md +6 -3
  85. package/docs/native-kit-baselines.md +82 -0
  86. package/docs/proof-carrying-change.implementation.v1.json +3 -2
  87. package/docs/proof-carrying-change.md +42 -8
  88. package/docs/real-world-qualification.md +8 -3
  89. package/docs/workspace-knowledge-graph.md +6 -2
  90. package/docs/workspace-run.md +16 -0
  91. package/package.json +1 -1
  92. package/dist/analyze-GPYPXXRT.js +0 -1
  93. package/dist/autopilot-release-FL47VMF7.js +0 -1
  94. package/dist/capabilities-command-MYSLJIYS.js +0 -1
  95. package/dist/chunk-2LZWBUJD.js +0 -1
  96. package/dist/chunk-3HFFKW4Q.js +0 -2
  97. package/dist/chunk-ERVWW5HX.js +0 -1
  98. package/dist/chunk-GSSJJS5M.js +0 -6
  99. package/dist/chunk-I3UCODXU.js +0 -1
  100. package/dist/chunk-MBICKDYP.js +0 -1
  101. package/dist/chunk-MHQHRMKU.js +0 -5
  102. package/dist/chunk-OZXCNVGW.js +0 -2
  103. package/dist/chunk-RVOW3BHQ.js +0 -2
  104. package/dist/chunk-UW4SESKD.js +0 -2
  105. package/dist/chunk-VNKAISFE.js +0 -8
  106. package/dist/chunk-W6WRT77T.js +0 -1
  107. package/dist/chunk-WHR5SL33.js +0 -4
  108. package/dist/chunk-YWZBGSFE.js +0 -9
  109. package/dist/chunk-YZL7ZY7J.js +0 -2
  110. package/dist/pipeline-PGB5TEV3.js +0 -5
  111. package/dist/proof-carrying-change-QFH7WI2E.js +0 -1
  112. package/dist/verified-goal-7XHRWYSE.js +0 -1
  113. package/dist/workspace-knowledge-graph-snapshot-X347REDB.js +0 -1
  114. package/dist/workspace-mcp-serve-NQ42PE2I.js +0 -3
  115. package/dist/workspace-repair-engine-WMJCYWO4.js +0 -3
  116. package/dist/workspace-run-3S35MDX6.js +0 -1
@@ -1,34 +1,5 @@
1
1
  # Commands Reference
2
2
 
3
- ## Live cross-terminal activity
4
-
5
- ```bash
6
- workspai live [target]
7
- workspai live --global [--max-scopes <count>]
8
- workspai live --run <run-id>
9
- workspai live --once --json
10
- workspai live --once --json --projection monitor|board
11
- workspai live --no-motion --no-color
12
- workspai live --ascii|--accessible|--classic
13
- workspai live --capture <file.svg> [--capture-preset github|linkedin|x|square|wide]
14
- workspai live --replay <run-id> [--replay-speed <0.25..64>]
15
- ```
16
-
17
- `workspai live` observes versioned run/block/activity journals emitted by every
18
- Workspai CLI command in the same project or workspace. It works without
19
- `adopt`; adoption adds workspace correlation and cross-project intelligence.
20
- Its default TTY surface is a bounded interactive Flow Board with live block and
21
- edge state, durable per-block retry attempts, semantic phase rails, an adaptive
22
- Inspector, a deduplicated multi-workspace Fleet Cockpit, deterministic
23
- redacted-by-default SVG capture, durable replay, responsive compaction and
24
- changed-row rendering. Use `--accessible` for stable screen-reader output or
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.
30
- See [Workspai Live Activity](./workspace-live-activity.md).
31
-
32
3
  Human-readable CLI syntax for the Workspai CLI. The machine-complete command,
33
4
  argument, option, alias, ownership, and integrity inventory is available through
34
5
  `workspai commands --json` and
@@ -51,6 +22,38 @@ project`, and a complete ownership-grouped command map. Scoped help carries
51
22
  exact flags and examples. `commands --json` remains the machine-complete
52
23
  inventory used to prevent the human map from drifting.
53
24
 
25
+ ## Start with the core loop
26
+
27
+ ```bash
28
+ npx workspai adopt .
29
+ npx workspai workspace intelligence run --for-agent generic --strict --json
30
+ npx workspai goal "Describe the required outcome" --for-agent generic
31
+ npx workspai agent bootstrap --for-agent generic --strict --json
32
+ ```
33
+
34
+ For source-changing work, continue through `change begin`, bounded
35
+ authorization, effect receipts, independent verification, and capsule
36
+ validation. For exact syntax, see the lifecycle section below.
37
+
38
+ ## Live cross-terminal activity
39
+
40
+ ```bash
41
+ workspai live [target]
42
+ workspai live --global [--max-scopes <count>]
43
+ workspai live --run <run-id>
44
+ workspai live --once --json --projection monitor|board
45
+ workspai live --ascii|--accessible|--classic
46
+ workspai live --capture <file.svg> [--capture-preset github|linkedin|x|square|wide]
47
+ workspai live --replay <run-id> [--replay-speed <0.25..64>]
48
+ ```
49
+
50
+ `workspai live` observes versioned activity emitted by CLI and Studio without
51
+ changing command outcomes or upgrading telemetry into verification proof. The
52
+ default TTY is an interactive Flow Board; the `board` JSON projection is the
53
+ shared renderer-neutral surface for IDE, web, replay, and capture consumers.
54
+ Use `--accessible` for stable screen-reader output and `--classic` for the
55
+ compatibility view. See [Workspai Live Activity](./workspace-live-activity.md).
56
+
54
57
  ## Workspace lifecycle
55
58
 
56
59
  ```bash
@@ -71,10 +74,12 @@ npx workspai change authorize --change <change-id> --effects <classes> [--grante
71
74
  npx workspai change effect record --change <change-id> --file <effect-receipt.json> [--workspace <path>] [--json]
72
75
  npx workspai change verify --change <change-id> [--strict] [--no-refresh] [--workspace <path>] [--json]
73
76
  npx workspai change verification record --change <change-id> --file <verification-receipt.json> [--workspace <path>] [--json]
74
- npx workspai change <status|explain> --change <change-id> [--workspace <path>] [--json]
77
+ npx workspai change status --change <change-id> [--workspace <path>] [--json]
78
+ npx workspai change explain --change <change-id> [--workspace <path>] [--json]
75
79
  npx workspai change resume --change <change-id> --to <authorized|executing|verifying> --reason <text> [--actor <identity>] [--json]
76
80
  npx workspai change abort --change <change-id> --reason <text> [--actor <identity>] [--json]
77
- npx workspai change capsule <validate|export> --change <change-id> [--output <path>] [--json]
81
+ npx workspai change capsule validate --change <change-id> [--workspace <path>] [--json]
82
+ npx workspai change capsule export --change <change-id> --output <path> [--workspace <path>] [--json]
78
83
  npx workspai agent bootstrap [--project <path>] [--for-agent <host>] [--no-live-inputs] [--strict] [--json]
79
84
  ```
80
85
 
@@ -135,7 +140,7 @@ npx workspai workspace snapshot [--workspace <path>] [--json] [--include-paths]
135
140
  npx workspai workspace diff --from <snapshot-or-model|git[:ref]> [--workspace <path>] [--json] [--include-paths] [--include-evidence] [--scan-depth <count>] [--strict]
136
141
  npx workspai workspace impact --from <workspace-diff-report> [--workspace <path>] [--scope project:<name>] [--json] [--include-paths] [--include-evidence] [--scan-depth <count>] [--strict]
137
142
  npx workspai workspace verify [--from-impact <file>] [--workspace <path>] [--scope project:<name>] [--strict] [--json] [--include-paths] [--include-evidence] [--scan-depth <count>]
138
- npx workspai workspace graph [emit|explain|search|benchmark|entities|evidence|path|overlay|dot|mermaid|jsonld|graphml|gexf] [key] [value] [--from <graph.json>] [--output <file>] [--limit <1..100>] [--kind <entity-kind>] [--workspace <path>] [--scope project:<name>] [--refresh-graph] [--graph-inventory-limit <count>] [--graph-semantic-budget <count>] [--graph-deep-budget <count>] [--graph-source-budget <count>] [--json] [--include-paths] [--include-evidence] [--scan-depth <count>]
143
+ npx workspai workspace graph [emit|explain|search|benchmark|benchmark-suite|entities|evidence|path|overlay|dot|mermaid|jsonld|graphml|gexf] [key] [value] [--from <graph.json>] [--output <file>] [--limit <1..100>] [--kind <entity-kind>] [--workspace <path>] [--scope project:<name>] [--refresh-graph] [--graph-inventory-limit <count>] [--graph-semantic-budget <count>] [--graph-deep-budget <count>] [--graph-source-budget <count>] [--json] [--include-paths] [--include-evidence] [--scan-depth <count>]
139
144
  npx workspai workspace eval [init <task> [strategy]|record|status|report|compare --from <report>] [--workspace <path>] [--output <file>] [--json]
140
145
  npx workspai workspace watch [--workspace <path>] [--json] [--graph-stream] [--once] [--scan-depth <count>]
141
146
  npx workspai workspace explain <target> [--workspace <path>] [--json] [--write]
@@ -227,7 +232,10 @@ capsules. `begin` pins the
227
232
  exact Model, Graph, and live-input generation. `predict` is explicitly
228
233
  noncanonical and never counts as proof. A human uses `authorize` to grant
229
234
  bounded effect classes; agents and tools then append typed, idempotent effect
230
- receipts. `verify` re-observes the canonical Graph, derives the actual overlay,
235
+ receipts. Removed paths use `deletedArtifacts: [{ "artifact": "..." }]`; the
236
+ CLI emits a governed tombstone only after proving the path is absent and
237
+ contained by the workspace or linked-project contract. `verify` re-observes
238
+ the canonical Graph, derives the actual overlay,
231
239
  reports prediction surprises, and records Workspace Verify against the exact
232
240
  post-effect generation. Additional Goal-domain receipts enter through
233
241
  `verification record`. Only complete, passing criteria can seal a capsule. See
@@ -42,9 +42,12 @@ JSON shape is necessary but insufficient. The runtime additionally verifies:
42
42
  5. unique effect receipt IDs and idempotency keys;
43
43
  6. exact effect-head binding for verification receipts;
44
44
  7. current Model/Graph target identity;
45
- 8. successful receipt coverage for changed Graph proof artifacts;
46
- 9. latest passing receipt for every immutable Goal criterion;
47
- 10. capsule, lease, decision-head, baseline-cache, and referenced-artifact integrity.
45
+ 8. successful receipt or validated deletion-tombstone coverage for changed
46
+ Graph proof artifacts;
47
+ 9. deletion paths remain absent and contained by the workspace or an explicit
48
+ linked-project contract;
49
+ 10. latest passing receipt for every immutable Goal criterion;
50
+ 11. capsule, lease, decision-head, baseline-cache, and referenced-artifact integrity.
48
51
 
49
52
  ## Compatibility rules
50
53
 
@@ -0,0 +1,82 @@
1
+ # Native Kit Baselines
2
+
3
+ Workspai owns the generated source, build, container, and CI contract for these
4
+ native kits:
5
+
6
+ - `gofiber.standard`
7
+ - `gogin.standard`
8
+ - `springboot.standard`
9
+ - `dotnet.webapi.clean`
10
+ - `rust.axum`
11
+
12
+ This policy does not cover FastAPI or NestJS kits owned by the RapidKit Python
13
+ engine. It also does not cover generators delegated to an upstream official
14
+ CLI, such as Next.js, Astro, Angular, Vue, Svelte, Nuxt, or React Native.
15
+
16
+ ## Current tested baseline
17
+
18
+ Reviewed: August 31, 2026
19
+
20
+ | Kit | Runtime baseline | Framework baseline | Compatibility policy |
21
+ | ------------ | ------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------- |
22
+ | Go/Fiber | Go 1.26 | Fiber 2.52.15 | Stay on the maintained v2 line until a separately qualified v3 migration is complete. |
23
+ | Go/Gin | Go 1.26 | Gin 1.12.0 | Generate and test against the same supported Go baseline. |
24
+ | Spring Boot | Java 21 | Spring Boot 3.5.16, springdoc 2.9.0 | Build on Java 21 and verify the generated project on Java 21 and 25. |
25
+ | .NET Web API | .NET 10 LTS | ASP.NET Core 10.0.11 | Use `net10.0` consistently across source, tests, containers, and CI. |
26
+ | Rust/Axum | Rust 1.98.0, edition 2024 | Axum 0.8.9 | Pin the toolchain so local, CI, and container builds use one compiler contract. |
27
+
28
+ The executable source of truth is
29
+ [`native-kit-baselines.ts`](../src/generators/native-kit-baselines.ts). A
30
+ baseline review changes that file and the affected generator tests together so
31
+ templates cannot silently drift apart.
32
+
33
+ ## Enterprise generation contract
34
+
35
+ Every owned native kit must generate:
36
+
37
+ - deterministic runtime and framework versions rather than `latest`;
38
+ - health/readiness endpoints and runtime smoke tests;
39
+ - a multi-stage container with a non-root runtime user;
40
+ - CI with explicit read-only permissions and pinned action major versions;
41
+ - formatting, linting, build, and test gates appropriate to the ecosystem;
42
+ - automated dependency and GitHub Actions update discovery through Dependabot;
43
+ - portable Workspai metadata and lifecycle launchers.
44
+
45
+ The Spring kit additionally emits an OWASP dependency scan and CycloneDX SBOM.
46
+ The .NET kit uses the SDK's transitive vulnerability audit. Go and Rust security
47
+ scanner adoption remains gated on selecting and qualifying a pinned scanner
48
+ contract; a floating install is not an acceptable substitute.
49
+
50
+ ## Upgrade rules
51
+
52
+ 1. Prefer a supported, mature runtime line over a release published only days
53
+ before the Workspai release.
54
+ 2. Treat framework major upgrades as migrations, not version bumps. They need
55
+ generated-source compatibility, runtime smoke, Docker, and cross-platform CI
56
+ evidence.
57
+ 3. Keep runtime, package, container, CI, documentation, and warning text on the
58
+ same baseline.
59
+ 4. Never use floating tool versions in generated CI.
60
+ 5. Run generator golden tests without host runtimes, then qualify generated
61
+ projects with their real runtime before promoting a preview kit to stable.
62
+ 6. Review baselines for every Workspai minor release and immediately after a
63
+ relevant security or end-of-support announcement.
64
+
65
+ ## Validation
66
+
67
+ The local generator contract is network-free:
68
+
69
+ ```bash
70
+ npm --workspace workspai run typecheck
71
+ npm --workspace workspai run test:no-build -- \
72
+ src/__tests__/generators/gofiber-standard.test.ts \
73
+ src/__tests__/generators/gogin-standard.test.ts \
74
+ src/__tests__/generators/springboot-standard.test.ts \
75
+ src/__tests__/generators/dotnet-webapi-clean.test.ts \
76
+ src/__tests__/project-taxonomy-and-new-kits.test.ts
77
+ ```
78
+
79
+ Release qualification must also generate every owned kit in an isolated
80
+ workspace and run its native restore, format/lint, build, test, and container
81
+ checks on supported CI hosts. A machine without Go, .NET, or Rust can validate
82
+ the scaffold contract, but it cannot provide runtime qualification evidence.
@@ -2,6 +2,7 @@
2
2
  "schemaVersion": "workspai.proof-carrying-change-implementation-plan.v1",
3
3
  "status": "released",
4
4
  "release": "0.69.0",
5
+ "hardeningRelease": "0.70.0",
5
6
  "runtimeImplemented": true,
6
7
  "packageDecision": {
7
8
  "newPackage": false,
@@ -53,8 +54,8 @@
53
54
  "cli": "complete",
54
55
  "ciJsonGate": "complete",
55
56
  "mcpReadTools": "complete",
56
- "extensionReadProjection": "implemented-awaiting-pcc-cli-release",
57
- "extensionStudioMutationAdapter": "deferred-until-pcc-cli-release"
57
+ "extensionReadProjection": "implemented-cli-contract-ready",
58
+ "extensionStudioMutationAdapter": "implemented-cli-contract-ready"
58
59
  },
59
60
  "stages": [
60
61
  {
@@ -1,6 +1,7 @@
1
1
  # Proof-Carrying Change
2
2
 
3
- Status: released in Workspai CLI v0.69.0
3
+ Status: released in Workspai CLI v0.69.0; deletion-tombstone and overlapping
4
+ artifact-identity hardening released in v0.70.0.
4
5
 
5
6
  > Every change carries its intent, pinned architecture baseline, predicted
6
7
  > impact, authorized effects, actual architecture delta, independent
@@ -81,6 +82,8 @@ The runtime enforces these rules:
81
82
  - receipt idempotency keys cannot be reused;
82
83
  - verification binds the exact current Model, Graph, and effect-head digest;
83
84
  - observed changed artifacts must be covered by successful effect receipts;
85
+ - removed artifacts must be covered by validated deletion tombstones rather
86
+ than references to files that no longer exist;
84
87
  - a changed Graph with no effect receipt blocks verification;
85
88
  - every required Goal criterion needs a latest passing receipt before commit;
86
89
  - failed or uncertain effects block the transaction;
@@ -106,13 +109,45 @@ baseline identity, not the cache as architecture truth.
106
109
  ## Typed receipts
107
110
 
108
111
  An effect receipt includes an ID, effect class, result, summary, observation
109
- time, idempotency key, optional command argv, and artifact references. Artifact
110
- references use labeled digest semantics:
112
+ time, idempotency key, optional command argv, present artifact references, and
113
+ optional deleted-artifact tombstones. Artifact references use labeled digest
114
+ semantics:
111
115
 
112
116
  - `canonical-json-v1` for JSON evidence;
113
117
  - `raw-bytes-v1` for source or command-output files;
114
118
  - `workspace-model-structural-v1` for canonical Model identity.
115
119
 
120
+ A deletion is not represented by a fake file digest. CLI and IDE consumers may
121
+ submit the compact input below; the CLI normalizes it into a
122
+ `deletion-tombstone-v1` reference before the event enters the ledger:
123
+
124
+ ```json
125
+ {
126
+ "id": "remove-obsolete-retry",
127
+ "effectClass": "filesystem",
128
+ "status": "succeeded",
129
+ "summary": "Removed the obsolete retry implementation.",
130
+ "artifacts": [],
131
+ "deletedArtifacts": [{ "artifact": "api/src/obsolete-retry.ts" }],
132
+ "observedAt": "2026-08-31T12:00:00.000Z",
133
+ "idempotencyKey": "remove-obsolete-retry-v1"
134
+ }
135
+ ```
136
+
137
+ Admission proves that each deleted path is absent and remains inside the
138
+ workspace or an explicitly contracted linked-project root. Verification then
139
+ requires the fresh Graph overlay to report the same removal. Recreating the
140
+ path invalidates capsule validation. A tombstone intentionally carries no
141
+ unverifiable claim about the deleted bytes; the pinned baseline Graph owns the
142
+ pre-change architecture identity.
143
+
144
+ When adopted scopes overlap, one physical source file can have both an
145
+ aggregate-project Graph label and a nested-project Graph label. Effect coverage
146
+ resolves those portable labels through the workspace contract and treats them
147
+ as one mutation only when they map to the same contained filesystem target. It
148
+ never requires duplicate receipts for one physical effect, and it never uses
149
+ label similarity as proof of equivalence.
150
+
116
151
  Verification receipts add a Goal criterion ID and an exact target. Domain
117
152
  receipts are admitted only after `change verify` has re-observed the Graph and
118
153
  recorded passing Workspace Verify evidence.
@@ -192,11 +227,10 @@ and cannot replace verification.
192
227
 
193
228
  ## Deferred work
194
229
 
195
- The next layer is IDE timeline/Graph overlay and Repair/Studio transaction
196
- adapters. Rich hosted PR annotations remain separate from the machine-readable
197
- CI gate above. Semantic multi-change overlap, immutable historical Graph
198
- queries, isolated patch simulation, and remote attestation remain separate
199
- follow-up capabilities. No current command claims those behaviors.
230
+ Rich hosted PR annotations remain separate from the machine-readable CI gate
231
+ above. Semantic multi-change overlap, immutable historical Graph queries,
232
+ isolated patch simulation, and remote attestation remain separate follow-up
233
+ capabilities. No current command claims those behaviors.
200
234
 
201
235
  See the [contract reference](./contracts/PROOF_CARRYING_CHANGE_CONTRACT_PLAN.md)
202
236
  and [implementation manifest](./proof-carrying-change.implementation.v1.json).
@@ -5,8 +5,9 @@ remain the release gates. Real-world qualification complements them by running
5
5
  the installed CLI against explicitly selected reference repositories through
6
6
  local, network-free Git snapshots
7
7
  without installing dependencies or executing project lifecycle commands.
8
- Every isolated workspace also receives a private `WORKSPAI_STATE_DIR` beneath
9
- `--run-root`; qualification cannot read or update the user's canonical registry,
8
+ Every isolated workspace also receives private `WORKSPAI_STATE_DIR` and
9
+ `WORKSPAI_ACTIVITY_STATE_DIR` roots beneath `--run-root`; qualification cannot
10
+ read or update the user's canonical registry, activity journals, transaction
10
11
  journals, or legacy registry mirror.
11
12
 
12
13
  ## Isolated and cumulative layouts
@@ -96,7 +97,9 @@ that safety boundary as a command failure.
96
97
  - Runtime candidates describe observed nested composition; the authoritative
97
98
  project runtime controls repair-adapter assertions. An aggregate boundary with
98
99
  runtime `unknown` therefore follows the governed manual-repair path instead of
99
- promoting its first nested runtime candidate.
100
+ promoting its first nested runtime candidate. Analyze reports a confirmed
101
+ multi-runtime aggregate as informational architecture rather than an
102
+ unknown-stack blocker.
100
103
  - Goal qualification publishes one system-understanding Goal inside the
101
104
  isolated test workspace, validates its lifecycle binding, and previews
102
105
  runtime-specific coverage and release-readiness goals without executing
@@ -110,6 +113,8 @@ that safety boundary as a command failure.
110
113
  are wrong.
111
114
  - Full graphs belong in `--output` artifacts. Agents and IDEs consume bounded
112
115
  `search`, `entities`, `evidence`, and `path` results.
116
+ - Every qualification also reads the renderer-neutral Live Board projection
117
+ from its isolated activity state and requires at least one observed CLI run.
113
118
 
114
119
  These suites are explicit and opt-in because they require local reference
115
120
  repositories. They do not replace cross-platform CI fixtures or release gates.
@@ -203,8 +203,12 @@ canonical per-project storage boundary.
203
203
 
204
204
  Workspai-generated agent entry projections are downstream consumers and are
205
205
  excluded from Graph inventory and Git diff hashing. Regenerating `AGENTS.md`,
206
- adapter entry files, or the Amazon Q entry rule therefore cannot invalidate the
207
- Graph that produced them or become circular architecture evidence.
206
+ adapter entry files, GitHub agent definitions, or the Amazon Q entry rule
207
+ therefore cannot invalidate the Graph that produced them or become circular
208
+ architecture evidence. The reserved `.workspai-workspace` marker is excluded
209
+ for the same ownership reason: its extension/CLI usage telemetry and other
210
+ operational metadata describe Workspai activity, not source architecture. Real
211
+ repository and workspace source changes remain part of the live fingerprint.
208
212
 
209
213
  ## Pick the command by question
210
214
 
@@ -47,6 +47,22 @@ The authoritative scaffold/import/lifecycle tiers are in
47
47
  Inspect one project's effective surface with
48
48
  `npx workspai project commands --json` before orchestration.
49
49
 
50
+ ## Cold initialization and progress
51
+
52
+ Dependency initialization uses a longer bounded budget than ordinary test or
53
+ build stages. Python, JVM, .NET, and Rust cold starts receive up to ten minutes;
54
+ other runtimes receive up to five. An explicit
55
+ `RAPIDKIT_WORKSPACE_RUN_STAGE_TIMEOUT_MS` value always takes precedence.
56
+
57
+ Human-readable runs stream child progress so a slow package restore does not
58
+ look frozen. JSON mode keeps stdout machine-readable. The final report records
59
+ the command that actually ran, status, exit code, duration, diagnostic, and
60
+ runtime unit instead of repeating only the planned command.
61
+
62
+ Full workspace `init` continues after a project failure so one run reports every
63
+ missing runtime or failed dependency bootstrap. Each failure remains explicit,
64
+ and the overall run still fails when any project fails.
65
+
50
66
  ## Enterprise configuration
51
67
 
52
68
  Override stage commands per project via `.workspai/context.json`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspai",
3
- "version": "0.69.0",
3
+ "version": "0.71.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": [
@@ -1 +0,0 @@
1
- export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-YWZBGSFE.js';
@@ -1 +0,0 @@
1
- export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-VNKAISFE.js';
@@ -1 +0,0 @@
1
- export{b as runDoctorCapabilities}from'./chunk-GSSJJS5M.js';
@@ -1 +0,0 @@
1
- import {k,q}from'./chunk-46QH3ZVI.js';import {a as a$6}from'./chunk-HTYMXMQM.js';import {b as b$2,c as c$2,a as a$3}from'./chunk-V52R2W2Q.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {d,a as a$1,p as p$1,g as g$2,f as f$2,e}from'./chunk-UW4SESKD.js';import {c,b as b$1,j as j$1,z as z$1,f}from'./chunk-KFTJVVJR.js';import {m,l}from'./chunk-U5ENEDJA.js';import {a as a$5}from'./chunk-GR6442P7.js';import {i,f as f$1,a as a$4,g as g$1}from'./chunk-OZXCNVGW.js';import {a}from'./chunk-2LIVMG5C.js';import {d as d$1,c as c$1}from'./chunk-EWZZUQBR.js';import {q as q$1,p,t as t$1,s}from'./chunk-ODK4LCEL.js';import {t}from'./chunk-VQZ5PI5J.js';import g from'path';import P from'fs-extra';import It from'crypto';import {execFile}from'child_process';import {promisify}from'util';import {createRequire}from'module';var Rt=new Set(c().map(e=>e.id)),At=[...k().map(e=>({id:e.kitId,aliases:[...e.aliases],ecosystem:e.framework,plannerFramework:e.id,runtime:"node",runtimeCandidates:["node"],workspacePythonEngine:"none",status:"available",canExecuteCreate:true,versionPolicy:e.versionPolicy,officialCommands:[e.commandDisplay("<name>",{skipGit:false,skipInstall:false})],adoptAfterCreate:true,...e.minNodeVersion?{runtimeRequirements:{node:`>=${e.minNodeVersion}`}}:e.minNodeMajor?{runtimeRequirements:{node:`>=${e.minNodeMajor}`}}:{}})),...q().map(e=>({id:e.kitId,aliases:[...e.aliases],ecosystem:e.framework,plannerFramework:e.framework,runtime:e.runtime,runtimeCandidates:[...e.runtimeCandidates],workspacePythonEngine:"none",status:"available",canExecuteCreate:true,versionPolicy:e.versionPolicy,officialCommands:[e.commandDisplay("<name>",{skipGit:false,skipInstall:false})],adoptAfterCreate:true,...e.nodeSupport?{runtimeRequirements:{node:e.nodeSupport.requirement}}:{}})),{id:"wordpress-site",aliases:["wordpress","wordpress-site","wp","wp-site"],ecosystem:"wordpress",plannerFramework:"wordpress",runtime:"php",runtimeCandidates:["php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["wp core download","wp config create","wp db create","wp core install"],adoptAfterCreate:true},{id:"wordpress-block",aliases:["wordpress-block","wp-block","gutenberg-block"],ecosystem:"wordpress",plannerFramework:"wordpress",runtime:"node",runtimeCandidates:["node","php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["npx @wordpress/create-block@latest <slug>"],adoptAfterCreate:true},{id:"symfony",aliases:["symfony","php-symfony"],ecosystem:"php",plannerFramework:"symfony",runtime:"php",runtimeCandidates:["php"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["composer create-project symfony/skeleton <name>"],adoptAfterCreate:true},{id:"rails",aliases:["rails","ruby-on-rails","ruby-rails"],ecosystem:"ruby",plannerFramework:"rails",runtime:"ruby",runtimeCandidates:["ruby"],workspacePythonEngine:"none",status:"planned",canExecuteCreate:false,versionPolicy:"planned",officialCommands:["rails new <name>"],adoptAfterCreate:true}],H=new Map;for(let e of At){H.set(e.id,e);for(let t of e.aliases)H.set(t,e);}var Mt=new Set(["php","ruby","rust","elixir","clojure","scala","kotlin","unknown"]);function K(e){return e?.trim().toLowerCase()||void 0}function Qe(e){let t=K(e.kitId)??K(e.framework)??K(e.runtime)??"unknown";if(e.projectExists)return {lane:"existing",status:"available",canExecuteCreate:false,requested:t,reason:"Existing projects enter Workspace Intelligence through adopt/import."};let r=e.kitId?b$1(e.kitId):void 0;if(r&&Rt.has(r))return {lane:"native",status:"available",canExecuteCreate:true,requested:t,resolved:r,reason:"Workspai owns the create contract, project marker, registry, doctor, and workspace model path."};let o=H.get(t)??H.get(K(e.framework)??"")??H.get(K(e.runtime)??"");if(o)return {lane:"official",status:o.status,canExecuteCreate:o.canExecuteCreate,requested:t,resolved:o.id,officialCommands:o.officialCommands,fallbackLane:o.canExecuteCreate?void 0:"existing",reason:o.status==="available"?"Workspai runs the official ecosystem generator, then registers the project in Workspace Intelligence.":"Official generator support is planned but not enabled; use adopt/import until Workspai owns the post-create contract."};let s=K(e.runtime);return s&&Mt.has(s)?{lane:"existing",status:"available",canExecuteCreate:false,requested:t,resolved:s,reason:"Runtime can be governed through Workspace Intelligence, but native create is not supported."}:{lane:"existing",status:"available",canExecuteCreate:false,requested:t,reason:"No native create contract is available; use adopt/import to enter Workspace Intelligence."}}function $r(e){return !e.canExecuteCreate&&(e.lane==="official"||e.lane==="existing"&&e.resolved!==void 0)}var Lr="rapidkit-freshness-metadata-v1";function fe(e){if(Array.isArray(e))return e.map(t=>fe(t));if(e&&typeof e=="object"){let t={};for(let r of Object.keys(e).sort())t[r]=fe(e[r]);return t}return e}function Ft(e){return JSON.stringify(fe(e))}function G(e){return It.createHash("sha256").update(Ft(e)).digest("hex")}var Ze=".workspai/workspace-graph.overrides.json",Dt=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]),Ot=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","node_modules","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),tt=600,rt=5,Gt=256*1024,et={inferred:1,contract:2,manual:3};function _t(e){return e.split(g.sep).join("/")}function Z(e,t){return _t(g.relative(e,t)||".")}function nt(e){let t=new Map;for(let r of e.projects)t.has(r.name)||t.set(r.name,{id:r.name,path:r.path,...r.runtime?{runtime:r.runtime}:{},...r.framework?{framework:r.framework}:{},...r.kind?{kind:r.kind}:{}});return [...t.values()].sort((r,o)=>r.id.localeCompare(o.id))}function ot(e,t){let r=new Map,o=new Map;for(let n of t.projects){if(r.has(n.name))continue;let c=n.absolutePath?g.resolve(n.absolutePath):g.resolve(e,n.path);r.set(n.name,c),o.has(c)||o.set(c,n.name);}let s=[...o.entries()].map(([n,c])=>({dir:n,id:c})).sort((n,c)=>c.dir.length-n.dir.length||n.dir.localeCompare(c.dir));return {idToDir:r,dirToId:o,sortedDirs:s}}function ee(e,t){let r=g.resolve(t);for(let{dir:o,id:s}of e.sortedDirs)if(r===o||r.startsWith(`${o}${g.sep}`))return s;return null}async function he(e){try{if(!await P.pathExists(e))return null;let t=await P.readJSON(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}async function ye(e){try{return await P.pathExists(e)?await P.readFile(e,"utf8"):null}catch{return null}}async function st(e,t){let r=[],o=new Map;for(let[s,n]of t.idToDir.entries()){let c=await he(g.join(n,"package.json")),a=typeof c?.name=="string"?c.name.trim():"";a&&!o.has(a)&&o.set(a,s);}for(let[s,n]of t.idToDir.entries()){let c=await he(g.join(n,"package.json"));if(c){let a=["dependencies","devDependencies","peerDependencies","optionalDependencies"],i=new Set;for(let l of a){let u=c[l];if(!(!u||typeof u!="object"||Array.isArray(u)))for(let p of Object.keys(u)){let d=o.get(p);!d||d===s||i.has(d)||(i.add(d),r.push({from:s,to:d,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:Z(e,g.join(n,"package.json")),detail:`declares dependency ${p}`}]}));}}}r.push(...await Tt(e,t,s,n)),r.push(...await Nt(e,t,s,n));}return r}async function Tt(e,t,r,o){let s=await ye(g.join(o,"pyproject.toml"));if(!s)return [];let n=[],c=new Set,a=/path\s*=\s*["']([^"']+)["']/g,i;for(;(i=a.exec(s))!==null;){let l=ee(t,g.resolve(o,i[1]));!l||l===r||c.has(l)||(c.add(l),n.push({from:r,to:l,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:Z(e,g.join(o,"pyproject.toml")),detail:`path dependency ${i[1]}`}]}));}return n}async function Nt(e,t,r,o){let s=await ye(g.join(o,"go.mod"));if(!s)return [];let n=[],c=new Set,a=/replace\s+\S+\s+=>\s+(\.[^\s]+)/g,i;for(;(i=a.exec(s))!==null;){let l=ee(t,g.resolve(o,i[1]));!l||l===r||c.has(l)||(c.add(l),n.push({from:r,to:l,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:Z(e,g.join(o,"go.mod")),detail:`go.mod replace ${i[1]}`}]}));}return n}async function Kt(e,t){let r=[],o=[e];for(;o.length>0&&r.length<t;){let s=o.shift();if(!s)continue;let n=[];try{n=await P.readdir(s,{withFileTypes:true});}catch{continue}let c=[],a=[];for(let i of n)if(i.isDirectory()){if(Ot.has(i.name)||a$5(i.name)||i.name.startsWith("."))continue;c.push(g.join(s,i.name));}else i.isFile()&&Dt.has(g.extname(i.name))&&a.push(g.join(s,i.name));a.sort((i,l)=>i.localeCompare(l)),c.sort((i,l)=>i.localeCompare(l));for(let i of a){if(r.length>=t)break;r.push(i);}o.push(...c);}return r}var $t=[/\bfrom\s+["']([^"']+)["']/g,/\bimport\s+["']([^"']+)["']/g,/\bimport\s*\(\s*["']([^"']+)["']\s*\)/g,/\brequire\s*\(\s*["']([^"']+)["']\s*\)/g];function Vt(e){let t=new Set;for(let r of $t){r.lastIndex=0;let o;for(;(o=r.exec(e))!==null;){let s=o[1];s.startsWith(".")&&t.add(s);}}return [...t]}async function ke(e,t,r,o){let s=new Map;for(let[n,c]of t.idToDir.entries()){if(o&&!o.has(n))continue;let a=await Kt(c,r);for(let i of a){let l=await P.stat(i).catch(()=>null);if(!l||l.size>Gt)continue;let u=await ye(i);if(u)for(let p of Vt(u)){let d=g.resolve(g.dirname(i),p),f=ee(t,d);if(!f||f===n)continue;let y=`${n}\0${f}`,m=s.get(y);m||(m={from:n,to:f,evidence:[]},s.set(y,m)),m.evidence.length<rt&&m.evidence.push({file:Z(e,i),detail:`imports ${p}`});}}}return [...s.values()].map(n=>({from:n.from,to:n.to,kind:"code-import",source:"inferred",confidence:"medium",evidence:n.evidence}))}function Ht(e,t,r){let o=new Map;for(let s of r.projects){let n=Bt(e,t,s);n&&o.set(s.slug,n);}return o}function Bt(e,t,r){let o=[r.relativePath,r.externalPath].filter(s=>typeof s=="string"&&s.length>0);for(let s of o){let n=g.resolve(e,s),c=t.dirToId.get(n)??ee(t,n);if(c)return c}return t.idToDir.has(r.slug)?r.slug:null}function at(e,t,r){let o=[],s=Ht(e,t,r),n=g$2,c=new Map,a=new Map;for(let i of r.projects){let l=s.get(i.slug);if(!l)continue;let u=i.contracts??{publishes:[],consumes:[],dependsOn:[]};for(let p of u.dependsOn??[]){let d=s.get(p);!d||d===l||o.push({from:l,to:d,kind:"service-dependsOn",source:"contract",confidence:"high",evidence:[{file:n,detail:`dependsOn ${p}`}]});}for(let p of u.publishes??[])c.has(p)||c.set(p,new Set),c.get(p)?.add(l);for(let p of u.consumes??[])a.has(p)||a.set(p,new Set),a.get(p)?.add(l);}for(let[i,l]of c.entries()){let u=a.get(i);if(u)for(let p of u)for(let d of l)p!==d&&o.push({from:p,to:d,kind:"event-pub-sub",source:"contract",confidence:"high",evidence:[{file:n,detail:`consumes event ${i}`}]});}return o.push(...Lt(r,s)),o}function me(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function Lt(e,t){let r=[],o=e.projects.map(s=>({project:s,id:t.get(s.slug)})).filter(s=>!!s.id).filter(s=>me(s.project.slug).length>=3);for(let s of e.projects){let n=t.get(s.slug);if(!n)continue;let c=s.contracts?.env??[];if(c.length===0)continue;let a=new Set;for(let i of c){let l=me(i);for(let u of o)u.id===n||a.has(u.id)||!(l.includes(me(u.project.slug))&&(u.project.ports?.length??0)>0)||(a.add(u.id),r.push({from:n,to:u.id,kind:"shared-resource",source:"inferred",confidence:"low",evidence:[{file:g$2,detail:`env ${i} references ${u.project.slug}`}]}));}}return r}async function it(e,t){let r=await he(g.join(e,Ze)),o=Array.isArray(r?.edges)?r?.edges:[],s=[],n=new Set(f$2);for(let c of o){if(!c||typeof c!="object"||Array.isArray(c))continue;let a=c,i=typeof a.from=="string"?a.from:"",l=typeof a.to=="string"?a.to:"",u=typeof a.kind=="string"?a.kind:"";if(!t.has(i)||!t.has(l)||i===l||!n.has(u))continue;let p=Array.isArray(a.evidence)?a.evidence.map(d=>d&&typeof d=="object"&&typeof d.file=="string"?{file:d.file,...typeof d.detail=="string"?{detail:d.detail}:{}}:null).filter(d=>!!d):[];s.push({from:i,to:l,kind:u,source:"manual",confidence:"high",evidence:p.length>0?p:[{file:Ze,detail:"manual edge"}]});}return s}function Ut(e){return `${e.from}\0${e.to}\0${e.kind}`}function zt(e){let t=new Set,r=[];for(let o of e){let s=`${o.file}\0${o.detail??""}`;t.has(s)||(t.add(s),r.push(o));}return r.sort((o,s)=>o.file.localeCompare(s.file)||(o.detail??"").localeCompare(s.detail??"")).slice(0,rt)}function qt(e){let t=new Map;for(let r of e){let o=Ut(r),s=t.get(o);if(!s){t.set(o,{...r,evidence:[...r.evidence]});continue}let n=et[s.source],c=et[r.source];c>n?t.set(o,{...r,evidence:[...r.evidence,...s.evidence]}):c===n&&s.evidence.push(...r.evidence);}return [...t.values()].map(r=>({from:r.from,to:r.to,kind:r.kind,source:r.source,confidence:r.confidence,evidence:zt(r.evidence)})).sort((r,o)=>r.from.localeCompare(o.from)||r.to.localeCompare(o.to)||r.kind.localeCompare(o.kind)||r.source.localeCompare(o.source))}function ge(e){return Math.round(e*1e3)/1e3}function Jt(e){return Math.max(0,Math.min(100,Math.round(e)))}function Xt(e){return e>=75?"critical":e>=50?"high":e>=20?"medium":"low"}function Yt(e){return e==="critical"||e==="high"?"strict":e==="medium"?"elevated":"normal"}function Qt(e,t){let r=a$6({nodes:e,edges:t}),o=new Map;for(let s of e){let n=r.byId.get(s.id)??{fanIn:0,fanOut:0,reach:0,betweenness:0,isHotspot:false},c=t.filter(f=>f.from===s.id||f.to===s.id),a=c.filter(f=>f.source==="contract"||f.source==="manual").length,i=c.filter(f=>f.confidence==="low").length,l=[],u=n.reach*20+n.fanIn*14+n.fanOut*8+Math.min(20,n.betweenness*4)+a*8;n.isHotspot&&(u+=24,l.push("Critical-path hotspot in dependency graph")),n.reach>0&&l.push(`Change reaches ${n.reach} dependent project(s)`),n.fanIn>0&&l.push(`${n.fanIn} direct dependent project(s)`),n.fanOut>0&&l.push(`${n.fanOut} direct dependency project(s)`),a>0&&l.push(`${a} contract/manual edge(s)`),i>0&&l.push(`${i} low-confidence inferred edge(s) need review`),c.length===0&&l.push(e.length===1?"Single-project workspace; inter-project dependency edges are not applicable":"No dependency evidence connected to this project yet");let p=Jt(u),d=Xt(p);o.set(s.id,{weight:d,score:p,verificationPriority:Yt(d),reasons:l.slice(0,5),centrality:{fanIn:n.fanIn,fanOut:n.fanOut,reach:n.reach,betweenness:n.betweenness,isHotspot:n.isHotspot}});}return o}function Zt(e,t){let r=Qt(e,t);return e.map(o=>({...o,operationalProfile:r.get(o.id)}))}function er(e,t){let r=new Set;for(let i of t)r.add(i.from),r.add(i.to);let o=e.length,s=t.length,n=e.filter(i=>r.has(i.id)).length,c=Math.max(0,o-n),a=a$6({nodes:e,edges:t});return {nodeCount:o,edgeCount:s,inferredEdges:t.filter(i=>i.source==="inferred").length,contractEdges:t.filter(i=>i.source==="contract").length,manualEdges:t.filter(i=>i.source==="manual").length,authoritativeEdges:t.filter(i=>i.source==="contract"||i.source==="manual").length,lowConfidenceEdges:t.filter(i=>i.confidence==="low").length,orphanCount:c,connectedNodeCount:n,density:ge(o>1?s/(o*(o-1)):0),edgeCoverageRatio:ge(o>0?n/o:1),evidenceCoverageRatio:ge(s>0?t.filter(i=>i.evidence.length>0).length/s:1),hotspotCount:a.hotspots.length,hasCycle:rr(e,t)}}function tr(e,t,r){let o=[],s=e.filter(n=>!t.some(c=>c.from===n.id||c.to===n.id)).map(n=>n.id).sort((n,c)=>n.localeCompare(c));return r.nodeCount===0&&o.push({code:"graph.empty",severity:"info",message:"Workspace model has no projects, so dependency reasoning is unavailable.",recommendation:"Import, scaffold, or register projects before relying on graph-aware impact."}),r.nodeCount>1&&r.edgeCount===0?o.push({code:"graph.edges.missing",severity:"warning",message:"Projects were detected, but no inter-project dependency edges were found.",recommendation:"Run graph explain, add workspace contract relationships, or define manual graph overrides for operational dependencies that code imports cannot reveal.",nodeIds:s}):r.nodeCount>1&&r.orphanCount>0&&o.push({code:"graph.orphans.detected",severity:"warning",message:`${r.orphanCount} project(s) have no dependency evidence connected to the graph.`,recommendation:"Review isolated projects and add package, contract, or manual edges when they participate in release-critical flows.",nodeIds:s.slice(0,12)}),r.lowConfidenceEdges>0&&o.push({code:"graph.low_confidence_edges",severity:"info",message:`${r.lowConfidenceEdges} inferred edge(s) are low confidence.`,recommendation:"Promote important low-confidence relationships to workspace contract or manual overrides."}),r.edgeCount>0&&r.evidenceCoverageRatio<1&&o.push({code:"graph.evidence.partial",severity:"warning",message:"Some dependency edges do not include file-level evidence.",recommendation:"Attach evidence to manual overrides so agents can audit why a relationship exists."}),r.hasCycle&&o.push({code:"graph.cycle.detected",severity:"error",message:"The dependency graph contains at least one directed cycle.",recommendation:"Break the cycle or document the relationship explicitly before using graph-aware release gates."}),o.sort((n,c)=>{let a={error:0,warning:1,info:2};return a[n.severity]-a[c.severity]||n.code.localeCompare(c.code)})}function rr(e,t){let r=new Map;for(let i of e)r.set(i.id,[]);for(let i of t)r.has(i.from)||r.set(i.from,[]),r.get(i.from)?.push(i.to);let o=0,s=1,n=2,c=new Map;for(let i of r.keys())c.set(i,o);let a=i=>{let l=[{id:i,index:0}];for(c.set(i,s);l.length>0;){let u=l[l.length-1],p=r.get(u.id)??[];if(u.index>=p.length){c.set(u.id,n),l.pop();continue}let d=p[u.index];u.index+=1;let f=c.get(d)??o;if(f===s)return true;f===o&&(c.set(d,s),l.push({id:d,index:0}));}return false};for(let i of [...r.keys()].sort())if(c.get(i)===o&&a(i))return true;return false}function ct(e$1,t,r,o){let s=qt(r.filter(i=>t.has(i.from)&&t.has(i.to))),n=Zt(e$1,s),c=er(e$1,s),a=tr(e$1,s,c);return {schemaVersion:e,generatedAt:(o??new Date).toISOString(),nodes:n,edges:s,stats:c,...a.length>0?{diagnostics:a}:{}}}async function dt(e){let t=g.resolve(e.workspacePath),r=e.maxImportFilesPerProject??tt,o=nt(e.model),s=new Set(o.map(a=>a.id)),n=ot(t,e.model),c=[];return c.push(...await st(t,n)),c.push(...await ke(t,n,r)),e.contract&&c.push(...at(t,n,e.contract)),c.push(...await it(t,s)),ct(o,s,c,e.now)}async function pt(e){let t=g.resolve(e.workspacePath),r=e.maxImportFilesPerProject??tt,o=nt(e.model),s=new Set(o.map(a=>a.id)),n=ot(t,e.model),c=[];if(c.push(...await st(t,n)),e.structuralChange)c.push(...await ke(t,n,r));else {c.push(...await ke(t,n,r,e.changedProjectIds));for(let a of e.previousGraph.edges)a.kind==="code-import"&&a.source==="inferred"&&!e.changedProjectIds.has(a.from)&&s.has(a.from)&&s.has(a.to)&&c.push({from:a.from,to:a.to,kind:"code-import",source:"inferred",confidence:a.confidence,evidence:a.evidence});}return e.contract&&c.push(...at(t,n,e.contract)),c.push(...await it(t,s)),ct(o,s,c,e.now)}var te="workspace-model-producer.v3";var ve=s.workspaceModelCache.schemaVersion,we=t$1.workspaceModelCache,ir=["package.json","pyproject.toml","setup.py","requirements.txt","requirements.in","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","Gemfile.lock","mix.exs","mix.lock","deno.json","deno.jsonc","deno.lock","bun.lock","bun.lockb","bunfig.toml",".bunfig.toml","deps.edn","project.clj","build.sbt","CMakeLists.txt","meson.build","workspai.project.json",".workspai/project.json",".workspai/context.json","rapidkit.project.json",".rapidkit/project.json",".rapidkit/context.json"],cr=[".csproj",".fsproj",".vbproj",".sln",".slnx",".gemspec"],lt=[t$1.workspaceContract,".workspai/workspace.json","workspai.workspace.json",".workspai/policies.yml",".workspai/policies.yaml",".rapidkit/workspace.contract.json",".rapidkit/workspace.json","rapidkit.workspace.json",".rapidkit/policies.yml",".rapidkit/policies.yaml"],ut=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".vue",".svelte",".rb",".go",".py",".java",".kt",".kts",".rs",".cs",".php",".ex",".exs",".clj",".cljs",".scala",".c",".cc",".cpp",".cxx",".h",".hh",".hpp",".hxx",".proto",".graphql",".gql",".sql",".sh"]),dr=new Set([".git",".workspai",".rapidkit","node_modules","dist","build","out","target","coverage",".next",".turbo",".cache",".venv"]),pr=1500,re=promisify(execFile);function lr(e){return ut.has(g.extname(e).toLowerCase())}async function ur(e){try{let{stdout:t}=await re("git",["-C",e,"rev-parse","--show-toplevel"],{encoding:"utf8",timeout:1e4,maxBuffer:1048576}),r=t.trim();if(!r)return null;let o=g.relative(r,e).split(g.sep).join("/");if(o===".."||o.startsWith("../"))return null;let s=o||".",n=o?`HEAD:${o}`:"HEAD^{tree}",{stdout:c}=await re("git",["-C",r,"rev-parse",n],{encoding:"utf8",timeout:1e4,maxBuffer:1024*1024}),[a,i]=await Promise.all([re("git",["-C",r,"diff","--name-only","-z","HEAD","--",s],{encoding:"buffer",timeout:2e4,maxBuffer:64*1024*1024}),re("git",["-C",r,"ls-files","--others","--exclude-standard","-z","--",s],{encoding:"buffer",timeout:2e4,maxBuffer:64*1024*1024})]),l=new Set([a.stdout,i.stdout].flatMap(p=>p.toString("utf8").split("\0")).filter(Boolean)),u=[`git-tree:${c.trim()}`];for(let p of [...l].sort((d,f)=>d.localeCompare(f))){let d=g.resolve(r,p),f=g.relative(e,d).split(g.sep).join("/");f===".."||f.startsWith("../")||!lr(f)||u.push(`${f}:${await L(d)??"<deleted>"}`);}return u}catch{return null}}var B=null;function be(){if(B)return B;try{B=createRequire(import.meta.url)("../package.json")?.version??"0.0.0";}catch{B="0.0.0";}return B}async function L(e){try{let t=await P.readFile(e);return It.createHash("sha256").update(t).digest("hex")}catch{return null}}async function ft(e){let t={};for(let o of ir){let s=await L(g.join(e,o));s&&(t[o]=s);}let r=await P.readdir(e).catch(()=>[]);for(let o of r.sort((s,n)=>s.localeCompare(n))){if(!cr.some(n=>o.toLowerCase().endsWith(n)))continue;let s=await L(g.join(e,o));s&&(t[o]=s);}return t}async function fr(e){let t=await ft(e),r=await ur(e),o=r??[];if(r)return G({manifests:t,source:o});let s=[e];for(;s.length>0&&o.length<pr;){let n=s.shift();if(!n)continue;let c=[];try{c=await P.readdir(n,{withFileTypes:true});}catch{continue}let a=[];for(let i of c)if(i.isDirectory()){if(dr.has(i.name)||a$5(i.name)||i.name.startsWith("."))continue;a.push(g.join(n,i.name));}else if(i.isFile()&&ut.has(g.extname(i.name))){let l=g.join(n,i.name),u=await P.stat(l).catch(()=>null);if(u){let p=g.relative(e,l).split(g.sep).join("/");o.push(`${p}:${u.size}:${Math.round(u.mtimeMs)}`);}}a.sort((i,l)=>i.localeCompare(l)),s.push(...a);}return o.sort((n,c)=>n.localeCompare(c)),G({manifests:t,source:o})}async function ne(e,t){let r=g.resolve(e),o={},s=[...new Set(t.map(n=>g.relative(r,g.resolve(n)).split(g.sep).join("/")))].sort((n,c)=>n.localeCompare(c));for(let n of s)o[n]=await fr(g.join(r,n));return o}async function oe(e){let t=g.resolve(e),r={};for(let o of lt){let s=await L(g.join(t,o));s&&(r[o]=s);}return r}async function se(e){let t=g.resolve(e.workspacePath),r=[...new Set(e.projectPaths.map(n=>g.relative(t,g.resolve(n)).split(g.sep).join("/")))].sort((n,c)=>n.localeCompare(c)),o=[];for(let n of r){let c=await ft(g.join(t,n));o.push({project:n,manifests:c});}let s={};for(let n of lt){let c=await L(g.join(t,n));c&&(s[n]=c);}return G({cacheSchema:ve,cliVersion:e.cliVersion,flags:e.flags,workspaceJson:e.workspaceJson??null,marker:e.marker??null,projects:o,workspaceFiles:s})}async function je(e){let t=await f$1(e,we)??a$4(e,we);try{if(!await P.pathExists(t))return null;let r=await P.readJson(t);return !r||r.schemaVersion!==ve||r.producerRevision!==te||typeof r.inputsHash!="string"||typeof r.cliVersion!="string"||!r.model?null:r}catch{return null}}async function ae(e,t){let r={schemaVersion:ve,producerRevision:te,...t};return g$1(e,we,r)}var mt="rapidkit-fact-freshness-v1",U={durable:720*60*60,derived:10080*60,evidenceBacked:1440*60,live:300,verifyBeforeUse:1440*60};function mr(e){switch(e){case "durable":return U.durable;case "derived":return U.derived;case "evidence-backed":return U.evidenceBacked;case "live":return U.live;case "verify-before-use":return U.verifyBeforeUse}}function gr(e){if(e.status)return e.status;if(e.ttlSeconds===null)return "unknown";let t=Date.parse(e.generatedAt);if(!Number.isFinite(t))return "unknown";let r=t+e.ttlSeconds*1e3;return e.now.getTime()>r?"stale":"fresh"}function hr(e){let t=e.now??new Date,r=e.generatedAt??t.toISOString(),o=Date.parse(r),s=Number.isFinite(o),n=s?r:t.toISOString(),c=e.ttlSeconds===void 0?mr(e.kind):e.ttlSeconds,a=gr({generatedAt:n,ttlSeconds:c,status:e.status??(s?void 0:"unknown"),now:t}),i=Date.parse(n),l=c===null||!Number.isFinite(i)?void 0:new Date(i+c*1e3),u=e.verifyBeforeUse??(e.kind==="live"||e.kind==="verify-before-use"||e.category!=="structure"||a!=="fresh");return {schemaVersion:mt,kind:e.kind,category:e.category,generatedAt:n,ttlSeconds:c,...l?{expiresAt:l.toISOString()}:{},status:a,verifyBeforeUse:u,...e.sourceArtifact?{sourceArtifact:e.sourceArtifact}:{},...e.sourcePath?{sourcePath:e.sourcePath}:{},inputsHash:e.inputsHash??G(e.value??null),reason:e.reason}}function b(e){return {id:e.id,label:e.label,scope:e.scope,value:e.value,...e.project?{project:e.project}:{},freshness:hr({...e.freshness,value:e.value})}}function gt(e){let t=e.generatedAt??(e.now??new Date).toISOString(),r={durable:0,derived:0,"evidence-backed":0,live:0,"verify-before-use":0},o={structure:0,verification:0,state:0},s=0,n=0,c=0,a=0;for(let i of e.facts)r[i.freshness.kind]+=1,o[i.freshness.category]+=1,i.freshness.status==="stale"&&(s+=1),i.freshness.status==="unknown"&&(n+=1),i.freshness.kind==="live"&&(c+=1),i.freshness.verifyBeforeUse&&(a+=1);return {schemaVersion:mt,generatedAt:t,status:s>0?"stale":n>0?"unknown":"fresh",totalFacts:e.facts.length,staleFacts:s,unknownFacts:n,liveFacts:c,verifyBeforeUseFacts:a,byKind:r,byCategory:o}}function z(e,t){let r=[...new Set(e)],o=r.filter(s=>t.has(s)).length;return {eligibleCount:r.length,boundCount:o,unknownCount:r.length-o,coverageRatio:r.length===0?null:o/r.length}}function ht(e,t){let r=e.filter(d=>d.kind==="project").map(d=>d.id),o=e.filter(d=>d.kind==="endpoint").map(d=>d.id),s=new Set(o),n=e.filter(d=>d.kind==="api"&&!!d.projectId&&d.attributes.runtimeRegistrationRequired===true).map(d=>d.id),c=new Set(n),a=new Map(e.map(d=>[d.id,d.kind])),i=new Set(t.filter(d=>d.kind==="implements"||d.kind==="defines"&&a.get(d.from)==="file"&&a.get(d.to)==="endpoint").flatMap(d=>s.has(d.from)?[d.from]:s.has(d.to)?[d.to]:[])),l=new Set(t.filter(d=>d.kind==="implements"&&(a.get(d.from)==="runtime-unit"||a.get(d.to)==="runtime-unit")).flatMap(d=>c.has(d.from)?[d.from]:c.has(d.to)?[d.to]:[])),u=new Set(r),p=d=>new Set(t.filter(f=>f.kind===d).flatMap(f=>[f.from,f.to]).filter(f=>u.has(f)));return {apiImplementation:z(o,i),apiRuntimeRegistration:z(n,l),projectTests:z(r,p("tests")),projectDeployment:z(r,p("deploys")),projectOwnership:z(r,p("owns"))}}function kt(e,t){return e.filter(o=>o.code.includes("unknown")||o.code.includes("unresolved")||o.code.includes("limit_reached")||o.code.endsWith(".empty_result")).reduce((o,s)=>o+Math.max(s.entityIds?.length??0,s.relationIds?.length??0,1),0)+Object.values(t).reduce((o,s)=>o+s.unknownCount,0)}function Ce(e,t){return t===0?1:e/t}function kr(e,t,r,o){return e.entityIds?.some(s=>t.has(s))||e.relationIds?.some(s=>r.has(s))?true:e.entityIds?.length||e.relationIds?.length?false:!/\bproject\b/i.test(e.message)||e.message.includes(o)}function yr(e,t,r,o,s){let n=new Set(s.filter(a=>a.provider===e.id).map(a=>a.id)),c=e.inputCoverage?.filter(a=>a.scope==="workspace"||a.scope==="project"&&a.scopeId===t);return {...e,discoveredEntities:r.filter(a=>a.proofIds.some(i=>n.has(i))).length,discoveredRelations:o.filter(a=>a.proofIds.some(i=>n.has(i))).length,proofCount:n.size,...c?{inputCoverage:c}:{}}}function wr(e,t){let r=new Set(e.entities.filter(m=>m.projectId===t).map(m=>m.id)),o=e.relations.filter(m=>r.has(m.from)||r.has(m.to)),s=new Set(r);for(let m of o)s.add(m.from),s.add(m.to);let n=e.entities.filter(m=>s.has(m.id)),c=new Set([...n,...o].flatMap(m=>m.proofIds)),a=e.proofs.filter(m=>c.has(m.id)),i=new Set(o.map(m=>m.id)),l=e.diagnostics.filter(m=>kr(m,s,i,t)),u=e.providers.map(m=>yr(m,t,n,o,a)),p=e.source.inputs?.scopes.filter(m=>m.kind==="workspace"||m.kind==="project"&&m.id===t)??[],d=p.filter(m=>!m.truncated).length,f=u.reduce((m,v)=>(v.status==="failed"?m.failed+=1:v.status==="skipped"||v.inputCoverage?.every(x=>x.status==="not-applicable")?m.notApplicable+=1:v.status==="partial"||v.inputCoverage?.some(x=>x.status==="bounded")?m.bounded+=1:m.complete+=1,m),{complete:0,bounded:0,notApplicable:0,failed:0}),y=ht(n,o);return {...e,entities:n,relations:o,proofs:a,providers:u,quality:{entityCount:n.length,relationCount:o.length,proofCount:a.length,entityProofCoverageRatio:Ce(n.filter(m=>m.proofIds.length>0).length,n.length),relationProofCoverageRatio:Ce(o.filter(m=>m.proofIds.length>0).length,o.length),providerSuccessRatio:Ce(u.filter(m=>m.status!=="failed").length,u.length),conflictCount:l.filter(m=>m.code.includes("conflict")).length,unknownCount:kt(l,y),bindingCoverage:y,...e.quality.completeness?{completeness:{status:p.some(m=>m.truncated)||f.bounded>0||f.failed>0?"bounded":"complete",inventory:{scopeCount:p.length,completeScopes:d,boundedScopes:p.length-d,eligibleFiles:p.reduce((m,v)=>m+(v.eligibleFileCount??v.fileCount),0),indexedFiles:p.reduce((m,v)=>m+v.fileCount,0),eligibleFileCountExact:p.every(m=>m.eligibleFileCountExact!==false)},providers:f}}:{},portable:true,secretValuesEmitted:false},diagnostics:l}}var vr=s.projectKnowledgeGraphReference.schemaVersion;function wt(e,t){let r=wr(e,t),o={schemaVersion:vr,generatedAt:e.generatedAt,project:{name:t},canonical:{graph:"workspace:.workspai/reports/workspace-knowledge-graph.json",boundedQuery:`workspai workspace graph search <task-query> --scope project:${t} --limit 12 --json`,sourceHash:e.source.hash,projectionHash:c$1(r)},summary:{entityCount:r.entities.length,relationCount:r.relations.length,proofCount:r.proofs.length}};return {...o,integrity:{algorithm:"sha256",payloadHash:c$1(o),portable:true,absolutePathsEmitted:false}}}function vt(e,t){return g.resolve(t.absolutePath??g.join(e,t.path))}var br=q$1.model,ie=p.model;function Pe(e){return e.projectTopology??e.graph}function jt(e){return !!(e.projectTopology&&e.graph&&c$1(e.projectTopology)===c$1(e.graph))}function eo(e){let t=e.engineStatus==="hit"||e.engineStatus==="unchanged"?"reused":e.engineStatus==="incremental"?"partially-reused":"rebuilt";return {schemaVersion:"workspace-model-build.v1",mode:e.mode,outcome:t,engineStatus:e.engineStatus}}var jr=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","mix.exs","deno.json","deno.jsonc","bun.lock","bun.lockb","bunfig.toml",".bunfig.toml","deps.edn","project.clj","build.sbt","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","terraform.tf"],Cr=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next",".turbo"]);function Ct(e,t){return (g.relative(e,t)||".").split(g.sep).join("/")}async function Pt(e){try{if(!await P.pathExists(e))return null;let t=await P.readJSON(e);return t&&typeof t=="object"?t:null}catch{return null}}async function Pr(e,t){for(let r of t)if(await P.pathExists(g.join(e,r)))return true;return false}function Se(e){let t=Number.parseInt(process.env.RAPIDKIT_WORKSPACE_MODEL_SCAN_DEPTH??"",10),r=typeof e=="number"&&Number.isFinite(e)?e:Number.isFinite(t)?t:4;return Math.min(12,Math.max(1,Math.trunc(r)))}async function Sr(e,t){let r=g.resolve(e),o=[{dirPath:r,depth:0}],s=new Set,n=new Set;for(;o.length>0;){let c=o.shift();if(!c)continue;let a=g.resolve(c.dirPath);if(n.has(a))continue;if(n.add(a),a!==r&&await Pr(a,jr)){s.add(a);continue}if(c.depth>=t)continue;let i=[];try{i=await P.readdir(a,{withFileTypes:true});}catch{continue}for(let l of i)!l.isDirectory()||Cr.has(l.name)||a$5(l.name)||l.name.startsWith(".")&&l.name!==".config"||o.push({dirPath:g.join(a,l.name),depth:c.depth+1});}return Array.from(s).sort((c,a)=>c.localeCompare(a))}function Er(e){let t=new Set,r=[];for(let o of e){let s=g.resolve(o);t.has(s)||(t.add(s),r.push(s));}return r.sort((o,s)=>o.localeCompare(s))}function bt(e,t){let r=e?.[t];return typeof r=="string"&&r.trim()?r.trim():void 0}function Wr(e,t){return e?.[t]===true}function xr(e,t,r){let o=e?.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,s=bt(o,"generator"),n=bt(o,"command_display"),c=typeof t=="string"&&t.startsWith("frontend.");if(!(!s&&!c))return {...s?{id:s}:{},...t?{kit:t}:{},displayName:r,source:Wr(o,"official_generator")?"official-generator":"metadata",...n?{commandDisplay:n}:{}}}async function Rr(e){let t=[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json","package.json","product.json","tsconfig.json","pnpm-workspace.yaml","bunfig.toml",".bunfig.toml","nx.json","turbo.json","pyproject.toml","requirements.txt","go.mod","go.work","go.work.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","rust-toolchain.toml","rust-toolchain","CMakeLists.txt","meson.build","Makefile","WORKSPACE","WORKSPACE.bazel","MODULE.bazel","BUILD","BUILD.bazel",".bazelrc","composer.json","Gemfile","mix.exs","deno.json","setup.py","setup.cfg","Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","README.md"],r=[];for(let s of t)await P.pathExists(g.join(e,s))&&r.push(s);let o=new Set(["package.json","pyproject.toml","go.mod","go.work","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","CMakeLists.txt","meson.build","composer.json","Gemfile","mix.exs","deno.json"]);if(!r.some(s=>o.has(s))){let s=[],n=new Set([".git",".workspai",".rapidkit",".venv","build","dist","node_modules","target","third_party","vendor"]),c=(p,d)=>{let f=p.toLowerCase();return ["package.json","pyproject.toml","go.mod","pom.xml","build.gradle","build.gradle.kts","cargo.toml","cmakelists.txt","meson.build","composer.json","gemfile","mix.exs","deno.json"].includes(f)||f.endsWith(".gemspec")||f==="description"&&d.toLowerCase()==="r"},a=async(p,d)=>{if(d>3||s.length>=512)return;let f=await P.readdir(p,{withFileTypes:true}).catch(()=>[]);for(let y of f.sort((m,v)=>m.name.localeCompare(v.name))){if(s.length>=512)return;y.isFile()&&c(y.name,g.basename(p))?s.push(g.relative(e,g.join(p,y.name)).split(g.sep).join("/")):y.isDirectory()&&!n.has(y.name)&&await a(g.join(p,y.name),d+1);}};await a(e,0);let i=new Map;for(let p of s){let d=p.split("/")[0],f=i.get(d)??[];f.push(p),i.set(d,f);}for(let p of i.values())p.sort((d,f)=>d.split("/").length-f.split("/").length||d.localeCompare(f));let l=[],u=[...i.keys()].sort();for(let p=0;l.length<16&&u.some(d=>p<(i.get(d)?.length??0));p+=1)for(let d of u){let f=i.get(d)?.[p];f&&l.length<16&&l.push(f);}r.push(...l.filter(p=>!r.includes(p)));}return r}async function R(e,t,r,o=t){let s=await f$1(e,t),n=s!==null,c={path:o.split(g.sep).join("/"),exists:n};if(s&&r){let a=await Pt(s);typeof a?.generatedAt=="string"&&(c.generatedAt=a.generatedAt);let i=a?.status??a?.result??a?.verdict;typeof i=="string"&&(c.status=i);}return c}async function Ar(e,t,r){let o=Ct(e,t),s=".workspai/reports",n=i=>R(t,`${s}/${i}`,r,`${o}/${s}/${i}`),c=await n("doctor-project-last-run.json");return {doctor:c?.exists===true?c:await n("doctor-last-run.json"),remediationPlan:await n("doctor-remediation-plan-last-run.json"),fixResult:await n("doctor-fix-result-last-run.json"),analyze:await n("analyze-last-run.json"),readiness:await n("release-readiness-last-run.json")}}async function Mr(e,t,r){let o=j$1(t),s=m(t,o),n=z$1(t),c=f(s.runtime),a=await b$2(t,o,{runtime:s.runtime,framework:s.key}),i=r.contractProject?.slug?r.contractProject.slug:typeof o?.name=="string"&&o.name.trim()?o.name.trim():g.basename(t),l$1=typeof o?.kit_name=="string"?o.kit_name:typeof o?.kit=="string"?o.kit:r.contractProject?.kit,u=typeof o?.engine=="string"?o.engine:n.engine!=="unknown"?n.engine:void 0,p=xr(o,l$1,s.displayName),d=Qe({kitId:l$1,framework:s.key,runtime:s.runtime}),f$1=l(t),y=[s.runtime,...f$1.filter(v=>v!==s.runtime)],m$1=await c$2({projectPath:t,declaration:r.contractProject?.governance});return {name:i,path:Ct(e,t),...r.includeAbsolutePaths?{absolutePath:t}:{},kind:a,category:a$3(a),runtime:s.runtime,runtimeCandidates:y,framework:s.key,frameworkDisplayName:s.displayName,confidence:s.confidence,detectionSource:s.source,supportTier:s.supportTier,runtimeSupportTier:c.tier,runtimeDoctorSupport:c.doctorSupport,moduleSupport:n.moduleSupport,...l$1?{kit:l$1}:{},...u?{engine:u}:{},...p?{generator:p}:{},createCapability:d,commands:{supported:n.supportedCommands,unsupported:n.unsupportedCommands,global:n.globalCommands,fleetStages:n.fleetStages,localOnly:n.localOnlyCommands,map:n.commandMap},importantFiles:await Rr(t),governance:m$1,evidence:await Ar(e,t,r.includeEvidence),provenance:{path:r.contractProject?"workspace contract declaration reconciled with filesystem discovery":"filesystem discovery",runtime:s.source,framework:s.source,commands:"project command capability matrix",createCapability:"create planner capability contract",governance:r.contractProject?.governance!==void 0?"workspace contract declaration reconciled with repository evidence":"repository and documented external governance discovery",evidence:"project .workspai/reports"}}}async function Ir(e){for(let t$1 of t(e,"workspace.json")){let r=await Pt(t$1);if(r)return r}return null}function Fr(e){if(e.length===0)return "empty-workspace";let t=new Set(e.map(r=>r.category));return t.size>1?"polyglot-product-workspace":t.has("frontend")&&e.length>1?"full-stack-workspace":t.has("frontend")?"frontend-workspace":t.has("desktop")?"desktop-application-workspace":t.has("extension")?"extension-workspace":t.has("platform")?"platform-workspace":t.has("library")?"library-workspace":e.length>1?"backend-platform":"backend-workspace"}function Dr(e){let t=new Set;for(let r of e){let o=`${r.name} ${r.path}`.toLowerCase();for(let s of ["auth","billing","payment","notification","order","admin","report","search","analytics"])o.includes(s)&&t.add(s);}return Array.from(t).sort()}function C(e,t,r,o){return {severity:e,code:t,message:r,target:o}}function St(e){let t=[];e.workspace.name.trim()||t.push(C("error","workspace.name.missing","Workspace name could not be resolved.","workspace")),e.workspace.type==="observed-workspace"&&t.push(C("warning","workspace.marker.missing","Workspace marker is missing; model is based on filesystem observation.","workspace.marker")),e.summary.projectCount===0&&t.push(C("warning","workspace.projects.empty","No project roots were detected in this workspace.","projects")),e.contracts.exists||t.push(C("warning","workspace.contract.missing","Workspace contract is missing; dependency and API edges may be incomplete.",e.contracts.workspaceContractPath));let r=new Map;for(let n of e.projects){let c=n.name.toLowerCase(),a=r.get(c)??[];a.push(n),r.set(c,a),n.importantFiles.length||t.push(C("warning","project.markers.missing",`Project ${n.name} has no important manifest files recorded.`,n.path));let i=g.isAbsolute(n.path)?n.path:g.resolve(e.workspace.root,n.path);P.existsSync(i)||t.push(C("warning","project.path.missing",`Registered project ${n.name} is not available at its declared path.`,n.path)),n.runtime==="unknown"&&t.push(C("warning","project.runtime.unknown",`Project ${n.name} runtime could not be confidently detected.`,n.path));let l=["test","build"];for(let d of l)n.commands.supported.includes(d)&&n.commands.unsupported.includes(d)&&t.push(C("error","project.commands.conflict",`Project ${n.name} marks ${d} as both supported and unsupported.`,n.path));let u=new Set(n.commands.fleetStages),p=new Set(n.commands.localOnly);for(let d of n.commands.fleetStages){p.has(d)&&t.push(C("error","project.commands.scope-conflict",`Project ${n.name} marks ${d} as both fleet and local-only.`,n.path));let f=n.commands.map[d];(!f||f.status!=="supported"||f.fleetEligible!==true||f.executionScope!=="fleet")&&t.push(C("error","project.commands.fleet-stage-invalid",`Project ${n.name} advertises ${d} as a fleet stage without a supported fleet capability.`,n.path));}for(let d of n.commands.localOnly){let f=n.commands.map[d];(!f||f.status!=="supported"||f.executionScope!=="local-only"||f.fleetEligible===true)&&t.push(C("error","project.commands.local-only-invalid",`Project ${n.name} advertises ${d} as local-only without a matching local-only capability.`,n.path));}for(let d of Object.values(n.commands.map))d.status==="supported"&&(d.fleetEligible===true&&!u.has(d.command)&&t.push(C("error","project.commands.fleet-stage-missing",`Project ${n.name} capability ${d.command} is fleet-eligible but missing from fleetStages.`,n.path)),d.executionScope==="local-only"&&d.fleetEligible!==true&&!p.has(d.command)&&t.push(C("error","project.commands.local-only-missing",`Project ${n.name} capability ${d.command} is local-only but missing from localOnly commands.`,n.path)));}for(let[n,c]of r.entries())c.length>1&&t.push(C("error","project.name.duplicate",`Project name "${n}" is ambiguous across ${c.length} project roots.`,c.map(a=>a.path).join(", ")));e.projectTopology&&e.graph&&c$1({...e.projectTopology,generatedAt:"<ignored>"})!==c$1({...e.graph,generatedAt:"<ignored>"})&&t.push(C("error","workspace.project-topology.alias-mismatch","Deprecated model.graph must remain structurally identical to canonical model.projectTopology during the v1 migration window.","projectTopology"));let o=t.filter(n=>n.severity==="error").length,s=t.filter(n=>n.severity==="warning").length;return {status:o>0?"failed":s>0?"warning":"passed",errors:o,warnings:s,issues:t}}function to(e){return St(e)}function j(e){return e.join(".")}function Or(e,t){let r=ie,o=e.generatedAt,s=[b({id:"workspace.name",label:"Workspace name",scope:"workspace",value:e.workspace.name,freshness:{kind:"durable",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:j(["workspace","name"]),reason:"Workspace identity is structural metadata and changes through workspace setup."}}),b({id:"workspace.type",label:"Workspace type",scope:"workspace",value:e.identity.workspaceType,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:j(["identity","workspaceType"]),reason:"Workspace type is derived from the current project inventory."}}),b({id:"workspace.projectCount",label:"Project count",scope:"workspace",value:e.summary.projectCount,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:j(["summary","projectCount"]),reason:"Project count is derived from workspace discovery and should be refreshed after structural changes."}}),b({id:"workspace.runtimeFamilies",label:"Runtime families",scope:"workspace",value:e.identity.runtimeFamilies,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:j(["identity","runtimeFamilies"]),reason:"Runtime coverage is inferred from project surfaces."}}),b({id:"workspace.policyMode",label:"Workspace policy mode",scope:"policy",value:e.policies.mode,freshness:{kind:"durable",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:j(["policies","mode"]),reason:"Policy mode is configuration, not runtime state."}}),b({id:"workspace.contract.exists",label:"Workspace contract presence",scope:"contract",value:e.contracts.exists,freshness:{kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,sourcePath:j(["contracts","exists"]),reason:"Contract presence is derived from workspace files and should be refreshed before release gating."}})],n=Pe(e);n&&s.push(b({id:"graph.edgeCount",label:"Dependency graph edge count",scope:"graph",value:n.stats.edgeCount,freshness:{kind:"derived",category:"structure",generatedAt:n.generatedAt??o,now:t,sourceArtifact:r,sourcePath:j(["projectTopology","stats","edgeCount"]),reason:"Graph topology is derived from manifests, imports, and workspace contracts."}}),b({id:"graph.evidenceCoverageRatio",label:"Dependency graph evidence coverage",scope:"graph",value:n.stats.evidenceCoverageRatio,freshness:{kind:"derived",category:"structure",generatedAt:n.generatedAt??o,now:t,sourceArtifact:r,sourcePath:j(["projectTopology","stats","evidenceCoverageRatio"]),reason:"Graph evidence coverage changes when dependency evidence or contract edges change."}}));for(let[c,a]of e.projects.entries()){let i=`projects[${c}]`,l={kind:"derived",category:"structure",generatedAt:o,now:t,sourceArtifact:r,reason:"Project facts are derived from workspace discovery, project metadata, and framework probes."};s.push(b({id:`project.${a.name}.kind`,label:`${a.name} kind`,scope:"project",project:a.name,value:a.kind,freshness:{...l,sourcePath:j([i,"kind"])}}),b({id:`project.${a.name}.category`,label:`${a.name} category`,scope:"project",project:a.name,value:a.category,freshness:{...l,sourcePath:j([i,"category"])}}),b({id:`project.${a.name}.runtime`,label:`${a.name} runtime`,scope:"project",project:a.name,value:a.runtime,freshness:{...l,sourcePath:j([i,"runtime"])}}),b({id:`project.${a.name}.framework`,label:`${a.name} framework`,scope:"project",project:a.name,value:a.frameworkDisplayName,freshness:{...l,sourcePath:j([i,"frameworkDisplayName"])}}),b({id:`project.${a.name}.supportTier`,label:`${a.name} support tier`,scope:"project",project:a.name,value:a.supportTier,freshness:{...l,sourcePath:j([i,"supportTier"])}}),b({id:`project.${a.name}.safeFleetStages`,label:`${a.name} safe fleet stages`,scope:"command",project:a.name,value:a.commands.fleetStages,freshness:{...l,sourcePath:j([i,"commands","fleetStages"]),reason:"Safe command availability is derived from package and project command surfaces."}}),...["ci","release","ownership"].map(u=>b({id:`project.${a.name}.governance.${u}`,label:`${a.name} ${u} governance`,scope:"policy",project:a.name,value:a.governance?.[u]??{status:"unknown",provider:null,evidence:[],reference:null},freshness:{...l,sourcePath:j([i,"governance",u]),reason:"Governance truth is reconciled from repository surfaces and explicit workspace contract declarations."}})));for(let[u,p]of Object.entries(a.evidence))s.push(b({id:`project.${a.name}.evidence.${u}`,label:`${a.name} ${u} evidence`,scope:"evidence",project:a.name,value:p?{path:p.path,exists:p.exists,status:p.status??null}:{exists:false},freshness:{kind:p?.exists?"evidence-backed":"verify-before-use",category:"verification",generatedAt:p?.generatedAt??o,now:t,status:p?.exists?void 0:"unknown",sourceArtifact:p?.path??r,sourcePath:j([i,"evidence",u]),verifyBeforeUse:true,reason:p?.exists?"Evidence reports can expire or become stale after source changes.":"Missing evidence must be generated before this fact is used for verification."}}));}for(let[c,a]of Object.entries(e.evidence))s.push(b({id:`workspace.evidence.${c}`,label:`Workspace ${c} evidence`,scope:"evidence",value:a?{path:a.path,exists:a.exists,status:a.status??null}:null,freshness:{kind:a?.exists?"evidence-backed":"verify-before-use",category:"verification",generatedAt:a?.generatedAt??o,now:t,status:a?.exists?void 0:"unknown",sourceArtifact:a?.path??r,sourcePath:j(["evidence",c]),verifyBeforeUse:true,reason:a?.exists?"Workspace evidence can expire or become stale after project, dependency, or policy changes.":"Missing workspace evidence must be generated before release or repair decisions."}}));return s}async function Ee(e,t){let[r,o,s,n,c,a$3]=await Promise.all([a(e),Ir(e),We(e),a$1(e),a$2(e,{descendIntoMatchedProjects:false}),Sr(e,t)]),i=new Map;for(let u of s?.projects??[]){let p=u.externalPath?g.resolve(e,u.externalPath):g.resolve(e,u.relativePath);i.set(p,u);}let l=Er([...c,...a$3,...i.keys(),...n.map(u=>g.isAbsolute(u.path)?u.path:g.join(e,u.path))]);return {marker:r,workspaceJson:o,workspaceContract:s,contractProjectPaths:i,projectPaths:l}}async function ce(e){let t$2=g.resolve(e.workspacePath),r=e.includeAbsolutePaths===true,o=e.includeEvidence===true,s=Se(e.observableScanDepth),n=e.now??new Date,{marker:c,workspaceJson:a,workspaceContract:i,contractProjectPaths:l,projectPaths:u}=await Ee(t$2,s),p$1=e.reuseProjectModels,d=await Promise.all(u.map(k=>{if(p$1){let xt=g.relative(t$2,g.resolve(k)).split(g.sep).join("/"),xe=p$1.get(xt);if(xe)return Promise.resolve(xe)}return Mr(t$2,k,{includeAbsolutePaths:r,includeEvidence:o,contractProject:l.get(g.resolve(k))})})),f=typeof a?.workspace_name=="string"?a.workspace_name:typeof a?.name=="string"?a.name:c?.name||i?.workspace.name||g.basename(t$2),y=typeof a?.profile=="string"?a.profile:typeof a?.mode=="string"?a.mode:i?.workspace.profile,m=Array.from(new Set(d.map(k=>k.kind))).sort(),v=Array.from(new Set(d.map(k=>k.category))).sort(),x=Array.from(new Set(d.flatMap(k=>k.runtimeCandidates.length>0?k.runtimeCandidates:[k.runtime]))).sort(),q=Array.from(new Set(d.map(k=>k.framework))).sort(),_=[".workspai/policies.yml",".workspai/policies.yaml",".rapidkit/policies.yml",".rapidkit/policies.yaml"].find(k=>P.existsSync(g.join(t$2,k))),J=t(t$2,"workspace.contract.json").map(k=>g.relative(t$2,k).split(g.sep).join("/")).find(k=>P.existsSync(g.join(t$2,k)))??t$1.workspaceContract,D=await P.pathExists(g.join(t$2,J)),X={schemaVersion:br,generatedAt:n.toISOString(),workspace:{name:f,root:t$2,...y?{profile:y}:{},type:c?"rapidkit-workspace":"observed-workspace",...c?{marker:{createdBy:c.createdBy,version:c.version,createdAt:c.createdAt}}:{}},identity:{workspaceType:Fr(d),surfaces:m,categories:v,runtimeFamilies:x,businessCapabilities:Dr(d)},discovery:{observableScanDepth:s},projects:d,policies:{mode:typeof a?.policy_mode=="string"?a.policy_mode:typeof a?.policyMode=="string"?a.policyMode:"warn",source:_??null,exists:!!_},contracts:{workspaceContractPath:J,exists:D,status:D?"known":"missing"},evidence:{doctor:await R(t$2,p.doctor,o),projectDoctor:await R(t$2,t$1.doctorProject,o),doctorRemediationPlan:await R(t$2,t$1.doctorRemediationPlan,o),artifactRemediationPlan:await R(t$2,t$1.artifactRemediationPlan,o),doctorFixResult:await R(t$2,t$1.doctorFixResult,o),analyze:await R(t$2,p.analyze,o),readiness:await R(t$2,p.readiness,o),pipeline:await R(t$2,t$1.pipelineLastRun,o)},summary:{projectCount:d.length,runtimes:x,frameworks:q,firstClassProjects:d.filter(k=>k.supportTier==="first-class").length,extendedProjects:d.filter(k=>k.supportTier==="extended").length,observedProjects:d.filter(k=>k.supportTier==="observed").length}},S=await Et(t$2,X,{contractExists:D,now:n,incrementalGraph:e.incrementalGraph}),E={...X,projectTopology:S,graph:S},O=St(E),T=Or({...E},n),Wt=gt({facts:T,generatedAt:n.toISOString(),now:n});return {...E,facts:T,factFreshness:Wt,validation:O}}async function ro(e){if(e.cache!==true)return {model:await ce(e),cache:"disabled"};let t=g.resolve(e.workspacePath),r=Se(e.observableScanDepth),o=be(),{marker:s,workspaceJson:n,projectPaths:c}=await Ee(t,r),a=await se({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:c,workspaceJson:n,marker:s}),i=await je(t);if(i&&i.cliVersion===o&&i.inputsHash===a&&jt(i.model))return {model:i.model,cache:"hit"};let l=await ce({...e}),[u,p]=await Promise.all([ne(t,c),oe(t)]);return await ae(t,{cliVersion:o,inputsHash:a,generatedAt:(e.now??new Date).toISOString(),model:l,projectSignatures:u,workspaceFileSignatures:p}),{model:l,cache:"miss"}}function Gr(e,t){let r=new Set,o=new Set,s=new Set;for(let[n,c]of Object.entries(t))n in e?e[n]!==c&&r.add(n):o.add(n);for(let n of Object.keys(e))n in t||s.add(n);return {changed:r,added:o,removed:s}}function _r(e={},t={}){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of r)if(e[o]!==t[o])return false;return true}async function no(e){let t=g.resolve(e.workspacePath),r=Se(e.observableScanDepth),o=be(),s=e.now??new Date,{marker:n,workspaceJson:c,projectPaths:a}=await Ee(t,r),i=await je(t),l=async()=>{let S=await ce({...e}),E=await se({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:a,workspaceJson:c,marker:n}),[O,T]=await Promise.all([ne(t,a),oe(t)]);return await ae(t,{cliVersion:o,inputsHash:E,generatedAt:s.toISOString(),model:S,projectSignatures:O,workspaceFileSignatures:T}),{model:S,mode:"full"}},u=i?Pe(i.model):void 0;if(!i||i.cliVersion!==o||!i.projectSignatures||!u||!jt(i.model))return l();let p=await oe(t);if(!_r(i.workspaceFileSignatures,p))return l();let d=await ne(t,a),{changed:f,added:y,removed:m}=Gr(i.projectSignatures,d);if(f.size===0&&y.size===0&&m.size===0)return {model:i.model,mode:"unchanged"};let v=new Set([...f,...y]),x=new Map;for(let S of i.model.projects){let E=S.path.split(g.sep).join("/");!v.has(E)&&!m.has(E)&&x.set(E,S);}let q=new Set,_=false;for(let S of i.model.projects){let E=S.path.split(g.sep).join("/");f.has(E)&&q.add(S.name);}let J=y.size>0||m.size>0,D=await ce({...e,reuseProjectModels:x,incrementalGraph:{previousGraph:u,changedProjectIds:q,structuralChange:J||_}});for(let S of i.model.projects){let E=S.path.split(g.sep).join("/");if(!f.has(E))continue;let O=D.projects.find(T=>T.path.split(g.sep).join("/")===E);if(O&&O.name!==S.name){_=true;break}}if(_)return l();let X=await se({workspacePath:t,cliVersion:o,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:r},projectPaths:a,workspaceJson:c,marker:n});return await ae(t,{cliVersion:o,inputsHash:X,generatedAt:s.toISOString(),model:D,projectSignatures:d,workspaceFileSignatures:p}),{model:D,mode:"incremental"}}async function We(e){try{let{contract:t}=await p$1({workspacePath:e});return t&&typeof t=="object"?t:null}catch{return null}}async function Et(e,t,r){let o=r.contractExists?await We(e):null;try{return r.incrementalGraph?await pt({workspacePath:e,model:t,contract:o,now:r.now,previousGraph:r.incrementalGraph.previousGraph,changedProjectIds:r.incrementalGraph.changedProjectIds,structuralChange:r.incrementalGraph.structuralChange}):await dt({workspacePath:e,model:t,contract:o,now:r.now})}catch{let s=t.projects.map(n=>({id:n.name,path:n.path}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:r.now.toISOString(),nodes:s,edges:[],stats:{nodeCount:s.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:s.length,connectedNodeCount:0,density:0,edgeCoverageRatio:s.length>0?0:1,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:s.length>1?[{code:"graph.inference.failed",severity:"warning",message:"Dependency graph inference failed; model contains projects but no dependency edges.",recommendation:"Run workspace model again after fixing graph inputs, or add workspace contract/manual graph overrides.",nodeIds:s.map(n=>n.id).sort((n,c)=>n.localeCompare(c))}]:void 0}}}async function oo(e,t,r={}){let o=e.contracts.exists?await We(t):null,{buildWorkspaceKnowledgeGraph:s}=await import('./workspace-knowledge-graph-EEOW5VAJ.js'),n=d(e),c=r.refreshKnowledgeGraph?null:await P.readJson(g.join(t,p.knowledgeGraph)).then(p=>p).catch(()=>null),a=await s({workspacePath:t,workspace:{name:e.workspace.name,...e.workspace.profile?{profile:e.workspace.profile}:{}},projects:e.projects.map(p=>({id:p.name,path:p.path,...p.absolutePath?{absolutePath:p.absolutePath}:{},runtime:p.runtime,runtimeCandidates:p.runtimeCandidates,framework:p.framework,kind:p.kind,category:p.category,...p.governance?{governance:p.governance}:{},...p.kit?{kit:p.kit}:{}})),projectTopology:Pe(e)??await Et(t,e,{contractExists:e.contracts.exists,now:new Date(e.generatedAt)}),contract:o,now:new Date(e.generatedAt),source:{kind:"workspace-model",artifact:ie,hashAlgorithm:"sha256",hash:d$1(n)},previousGraph:c}),i$1=[],l=new Map;for(let p of e.projects){let d=vt(t,p);if(!(await P.stat(d).catch(()=>null))?.isDirectory())continue;let y=await P.realpath(d),m=l.get(y);if(m)throw new Error(`Projects ${m} and ${p.name} resolve to the same graph artifact root: ${d}`);l.set(y,p.name),i$1.push({rootPath:d,relativePath:t$1.projectKnowledgeGraphReference,payload:wt(a,p.name)});}let u=await i(t,ie,[{rootPath:t,relativePath:p.knowledgeGraph,payload:a},{rootPath:t,relativePath:ie,payload:n},...i$1]);for(let p$1 of i$1){let d=g.join(p$1.rootPath,p.knowledgeGraph);(await P.readJson(d).catch(()=>null))?.schemaVersion===q$1.knowledgeGraph&&await P.remove(d).catch(()=>{});}return u[1]}export{Qe as a,$r as b,Lr as c,G as d,mt as e,b as f,gt as g,ht as h,kt as i,wr as j,br as k,ie as l,Pe as m,eo as n,to as o,Or as p,ce as q,ro as r,no as s,oo as t};
@@ -1,2 +0,0 @@
1
- import {q as q$1,l,m,k as k$1}from'./chunk-2LZWBUJD.js';import {a}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {d as d$1}from'./chunk-UW4SESKD.js';import {g}from'./chunk-OZXCNVGW.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {e,d,b as b$1}from'./chunk-EWZZUQBR.js';import {q,p}from'./chunk-ODK4LCEL.js';import k from'path';import V from'fs-extra';import {spawnSync}from'child_process';function ue(){let e={...process.env};return delete e.GIT_DIR,delete e.GIT_WORK_TREE,delete e.GIT_INDEX_FILE,delete e.GIT_PREFIX,e}function $(e,t,a){let r=spawnSync("git",t,{cwd:e,env:ue(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(r.status!==0)return {ok:false,stdout:""};let i=r.stdout??"";return {ok:true,stdout:a?.preserveWhitespace?i:i.trim()}}function ge(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return t===".workspai/AGENT-GROUNDING.md"?true:[".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(a=>t.startsWith(a))}function ke(e){let t=[],a=[],r=[];for(let i of e.split(`
2
- `)){if(!i.trim())continue;let n=i.slice(0,2),c=i.slice(3).trim();if(c&&!ge(c)){if(n==="??"){a.push(c);continue}n.includes("D")&&r.push(c),t.push(c);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(a)].sort(),deletedFiles:[...new Set(r)].sort()}}function Q(e,t){let a={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=$(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return a;let i=$(e,["rev-parse","--abbrev-ref","HEAD"]),n=$(e,["rev-parse","HEAD"]),c=$(e,["status","--porcelain=v1","--untracked-files=all"],{preserveWhitespace:true}),p=ke(c.stdout),m=p.changedFiles.length>0||p.untrackedFiles.length>0||p.deletedFiles.length>0;return {available:true,branch:i.ok?i.stdout:void 0,commit:n.ok?n.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:p.changedFiles,untrackedFiles:p.untrackedFiles,deletedFiles:p.deletedFiles}}var oe=q.snapshot,L=q.diff,_=p.snapshot,ae=p.diff,he=q.impact,we=p.impact;function ye(e$1){if(e$1.model.projectTopology||!e$1.model.graph||e$1.modelHash!==e(e$1.model))return null;let t={...e$1.model,projectTopology:e$1.model.graph,graph:e$1.model.graph};return {...e$1,modelHash:d(t),model:t}}function ne(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function We(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function se(e,t){return k.isAbsolute(t)?t:k.join(e,t)}async function be(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion===oe){a$1(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=a;if(!r.model||r.model.schemaVersion!==k$1)throw new Error(`Invalid workspace model snapshot: ${e}`);let i=d(r.model);if(r.modelHash!==i){let n=ye(r);if(!n)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:n.model,hash:n.modelHash}}return {model:r.model,hash:r.modelHash}}if(a.schemaVersion===k$1){a$1(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=a;return {model:r,hash:d(r)}}throw a.schemaVersion===L?new Error(`workspace diff --from received a diff report (${k.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${_}. To analyze an existing diff report, run: npx workspai workspace impact --from ${k.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(a.schemaVersion)}`)}async function ve(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion!==L)return null;a$1(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=a;if(!r.currentModel||r.currentModel.schemaVersion!==k$1||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==d(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Ye(e){let t=e.model??await q$1({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:oe,generatedAt:(e.now??new Date).toISOString(),modelHash:d(t),modelRef:l,model:t}}async function Qe(e,t){return g(t,_,d$1(e))}function x(e){return {name:e.name,path:e.path,kind:e.kind,category:e.category,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function h(e,t){e.push(t);}function Me(e,t){let a=[],r=["name","profile","type"],i=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let n of r){let c=e.workspace[n],p=t.workspace[n];b$1(c)!==b$1(p)&&h(a,{type:"workspace.changed",severity:"info",target:`workspace.${n}`,message:`Workspace metadata field changed: ${String(n)}`,before:c,after:p});}for(let n of i){let c=e.identity[n],p=t.identity[n];b$1(c)!==b$1(p)&&h(a,{type:"workspace.changed",severity:"info",target:`identity.${n}`,message:`Workspace identity field changed: ${String(n)}`,before:c,after:p});}return b$1(e.policies)!==b$1(t.policies)&&h(a,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),b$1(e.discovery)!==b$1(t.discovery)&&h(a,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&h(a,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),a}function je(e,t){let a=e.validation??null,r=t.validation??null;return b$1(a)===b$1(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:a,after:r}]}function Ie(e,t){let a=[],r=new Map(e.projects.map(n=>[n.path,n])),i=new Map(t.projects.map(n=>[n.path,n]));for(let[n,c]of i.entries()){let p=r.get(n);if(!p){h(a,{type:"project.added",severity:"info",target:n,message:`Project added: ${c.name}`,after:x(c)});continue}let m=x(p),l=x(c);if(b$1(m)!==b$1(l)){let u=p.runtime!==c.runtime||p.framework!==c.framework;h(a,{type:"project.changed",severity:u?"warning":"info",target:n,message:`Project changed: ${c.name}`,before:m,after:l});}}for(let[n,c]of r.entries())i.has(n)||h(a,{type:"project.removed",severity:"warning",target:n,message:`Project removed: ${c.name}`,before:x(c)});return a.sort((n,c)=>`${n.type}:${n.target}`.localeCompare(`${c.type}:${c.target}`))}async function Pe(e){let t=k.resolve(e.workspacePath),a=ne(e.fromPath),r=a?We(e.fromPath):void 0,i=e.fromPath;if(a){let f=k.join(t,_);if(!await V.pathExists(f))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");i=_;}let n=se(t,i),c=await be(n),p=e.model??await q$1({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=d(p),l$1=[...Me(c.model,p),...Ie(c.model,p),...je(c.model,p)],u;e.includeGitObservation!==false&&(u=e.gitObservation??Q(t,{ref:r}),u.available&&Ee(l$1,u,p));let v=l$1.filter(f=>f.type.startsWith("git.")).length,R=c.hash!==m,w=a?`git:${r??"HEAD"}`:k.relative(t,n).split(k.sep).join("/");return {schemaVersion:L,generatedAt:(e.now??new Date).toISOString(),fromRef:w,toRef:l,fromHash:c.hash,toHash:m,summary:{changed:R||v>0,addedProjects:l$1.filter(f=>f.type==="project.added").length,removedProjects:l$1.filter(f=>f.type==="project.removed").length,changedProjects:l$1.filter(f=>f.type==="project.changed").length,workspaceChanges:l$1.filter(f=>f.type==="workspace.changed").length,validationChanges:l$1.filter(f=>f.type==="validation.changed").length,gitChangedFiles:v},git:u?.available?Oe(u,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:l$1,currentModel:p}}async function Ze(e,t){return g(t,ae,d$1(e))}function I(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Z(e){return e.reduce((t,a)=>I(a)>I(t)?a:t,"none")}var N=["none","low","medium","high","critical"];function Re(e){let t=Math.max(1,I(e)-1);return N[t]}function Ce(e){let t=Math.min(N.length-1,I(e)+1);return N[t]}function ee(e){return e.join(" ")}function b(e,t,a,r){return {id:e,label:t,scope:r.scope,project:r.project,display:ee(["npx","workspai",...a]),execute:ee(["npx","--yes","--package","workspai","workspai",...a]),required:r.required!==false}}function te(e){let t=`project:${e.name}`,a=e.commands.fleetStages,r={init:`Run init for ${e.name}`,test:`Run tests for ${e.name}`,build:`Run build for ${e.name}`,start:`Run start for ${e.name}`};return ["init","test","build","start"].filter(i=>a.includes(i)).map(i=>b(`project.${e.name}.${i}`,r[i],["workspace","run",i,"--scope",t,"--json"],{scope:"project",project:e.name}))}function T(){return [b("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),b("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),b("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),b("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),b("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),b("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Se(e,t){let a=t.split(k.sep).join("/");return e.projects.filter(i=>{let n=i.path.split(k.sep).join("/");return a===n||a.startsWith(`${n}/`)}).sort((i,n)=>n.path.length-i.path.length)[0]}function Ee(e,t,a){let r=new Set(e.map(n=>n.target)),i=(n,c)=>{let p=c.split(k.sep).join("/"),m=`git:${p}`;if(r.has(m))return;let l=Se(a,p),u=l?`${l.name} (${l.path})`:"workspace";h(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:m,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${u}: ${p}`,after:{path:p,project:l?.name,projectPath:l?.path}}),r.add(m);};for(let n of t.changedFiles)i("git.file.changed",n);for(let n of t.untrackedFiles)i("git.untracked",n);for(let n of t.deletedFiles)i("git.deleted",n);}function Oe(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Ae(e){let t=new Set,a=[];for(let r of e){let i=`${r.scope}:${r.project??""}:${r.display}`;t.has(i)||(t.add(i),a.push(r));}return a}function De(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function Fe(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function $e(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(a=>a.severity==="critical"?false:a.type.startsWith("git.")||a.type==="validation.changed")?e.risk:I(e.risk)>=I("high")||e.risk==="medium"?"low":e.risk}function re(e,t){if(!e||e==="workspace")return true;let a=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,k.basename(t.path),t.absolutePath].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim().toLowerCase()).includes(a)}function xe(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(a=>a.project?.name??a.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function et(e){let t=k.resolve(e.workspacePath),a$1=ne(e.fromPath),r=e.diff;if(!r&&!a$1){let o=se(t,e.fromPath);r=await ve(o)??void 0;}r||(r=await Pe({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let i=new Map(r.currentModel.projects.map(o=>[o.path,o])),n=new Map(r.currentModel.projects.map(o=>[o.name,o])),c$1=r.changes.filter(o=>o.type.startsWith("project.")),p=new Map;for(let o of c$1){let d=(i.get(o.target)??(typeof o.before?.name=="string"?n.get(o.before.name):void 0))?.path??o.target,y=p.get(d)??[];y.push(o),p.set(d,y);}let m$1=[];for(let[o,s]of p.entries()){let d=i.get(o);if(d&&!re(e.scope,d))continue;let y=Z(s.map(De)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):o);m$1.push({id:`project:${C}`,scope:"project",target:o,title:`Project impact: ${C}`,summary:s.map(M=>M.message).join(" "),risk:y,reasons:s.map(M=>`${M.type}: ${M.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?te(d):T()});}let l=m(r.currentModel),u=l?a(l):void 0,v=new Set(m$1.map(o=>o.project?.name).filter(o=>typeof o=="string")),R=new Map;for(let o of m$1)if(o.project?.name){let s=u?.byId.get(o.project.name);s&&(o.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(o.risk=Ce(o.risk),o.reasons=[...o.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),o.origin="direct",o.distance=0,R.set(o.project.name,o.risk);}let w=[],f=0;if(l&&v.size>0){let o=c(l,v);for(let s of o.values()){if(s.distance===0||v.has(s.id))continue;let d=n.get(s.id);if(d&&!re(e.scope,d))continue;let y=s.path[0],C=s.path[s.path.length-2]??y,M=R.get(y)??"medium",de=Re(M),j=u?.byId.get(s.id);f=Math.max(f,s.distance),w.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${y}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:de,reasons:[`graph.dependent: depends on ${C}${s.via?` via ${s.via}`:""} (path ${s.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?te(d):T(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...j?{centrality:{fanIn:j.fanIn,fanOut:j.fanOut,reach:j.reach,betweenness:j.betweenness,isHotspot:j.isHotspot}}:{}});}}w.sort((o,s)=>o.target.localeCompare(s.target));let ie=u?u.hotspots.flatMap(o=>{let s=u.byId.get(o);return s?[{project:o,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],ce=r.changes.filter(o=>!o.type.startsWith("project.")),K=r.currentModel.summary?.projectCount??r.currentModel.projects.length,P=ce.map(o=>({id:`workspace:${o.target}`,scope:"workspace",target:o.target,title:`Workspace impact: ${o.target}`,summary:o.message,risk:Fe(o,{projectCount:K}),reasons:[`${o.type}: ${o.message}`],verification:T()})),B=Ae([...m$1.flatMap(o=>o.verification),...w.flatMap(o=>o.verification),...P.flatMap(o=>o.verification),...r.summary.changed?T():[]]).filter(o=>o.required),pe=Z([...m$1.map(o=>o.risk),...w.map(o=>o.risk),...P.map(o=>o.risk)]),z=$e({risk:pe,affectedProjects:m$1.length,projectCount:K,changes:r.changes}),q={changed:r.summary.changed,risk:z,affectedProjects:m$1.length,workspaceItems:P.length,recommendedCommands:B.length,blastRadius:{directlyAffected:m$1.length,transitivelyAffected:w.length,maxDistance:f,graphEdges:l?.edges.length??0}};return {schemaVersion:he,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:ae,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:q,affectedProjects:m$1.sort((o,s)=>o.target.localeCompare(s.target)),transitiveImpact:w,criticalPathHotspots:ie,workspaceImpact:P.sort((o,s)=>o.target.localeCompare(s.target)),verificationPlan:B,agentBrief:xe({changed:q.changed,risk:z,affectedProjects:m$1,workspaceImpact:P}),diff:r}}async function tt(e,t){return g(t,we,d$1(e))}export{Q as a,oe as b,L as c,_ as d,ae as e,he as f,we as g,ye as h,ne as i,We as j,Ye as k,Qe as l,Pe as m,Ze as n,T as o,et as p,tt as q};
@@ -1 +0,0 @@
1
- import {e,g}from'./chunk-OZXCNVGW.js';import {t,s}from'./chunk-ODK4LCEL.js';import {t as t$1}from'./chunk-VQZ5PI5J.js';import u from'fs';import A from'path';var a=s.workspaceRunLast.schemaVersion,W="workspace-run-last.json",o=t.workspaceRunLast;var P=new Set(["init","test","build","start"]);function _(e){return P.has(e)}async function d(e){try{return await u.promises.access(e,u.constants.F_OK),true}catch{return false}}async function w(e){try{let r=await u.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}function m(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function h(e){let r=e.stage;return typeof r!="string"||r.trim().length===0||!Array.isArray(e.projects)?false:_(r)||/^[a-z][a-z0-9_-]*$/i.test(r)}function T(e){let r=m(e);return !r||r.schemaVersion===a?false:h(r)}function C(e){let r=m(e);return r?r.schemaVersion===a&&r.stages!=null:false}function p(e){if(C(e))return e;if(T(e)){let r=e.stage;return {schemaVersion:a,generatedAt:e.generatedAt,workspacePath:e.workspacePath,latestStage:r,stages:{[r]:e},enterpriseControls:e.enterpriseControls??{jsonReady:true,evidencePath:o}}}return null}function U(e,r){let n=p(e);if(!n)return null;let t=r??n.latestStage;return n.stages[t]??null}async function V(e){let r=(await Promise.all(t$1(A.resolve(e),"reports",W).map(async t=>await d(t)?t:null))).find(t=>typeof t=="string");if(!r)return null;let n=await w(r);return p(n)}async function j(e$1,r){let n=A.resolve(e$1);return e(n,o,async()=>{let t=(await Promise.all(t$1(n,"reports",W).map(async s=>await d(s)?s:null))).find(s=>typeof s=="string"),R=t?await w(t):null,i=p(R);if(t&&!i)throw new Error(`Workspace run evidence is unreadable or invalid; refusing to overwrite: ${t}`);let l=i?{...i.stages}:{};l[r.stage]=r;let g$1={schemaVersion:a,generatedAt:r.generatedAt,workspacePath:r.workspacePath,latestStage:r.stage,stages:l,enterpriseControls:{jsonReady:true,evidencePath:o}};return await g(n,o,g$1),g$1})}export{W as a,o as b,U as c,V as d,j as e};