workspai 0.56.0 → 0.57.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 (88) hide show
  1. package/README.md +36 -8
  2. package/contracts/adopt-effects.v1.json +72 -0
  3. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
  4. package/contracts/doctor-project-evidence.v1.json +27 -0
  5. package/contracts/doctor-workspace-evidence.v1.json +29 -0
  6. package/contracts/extension-cli-compatibility.v1.json +1 -0
  7. package/contracts/published-contract-catalog.v1.json +5 -0
  8. package/contracts/workspace-intelligence/doctor-summary.v1.json +3 -1
  9. package/dist/autopilot-release-WIFFFQKW.js +1 -0
  10. package/dist/capabilities-command-44JVOE5S.js +1 -0
  11. package/dist/{chunk-XH7PDHBF.js → chunk-6OFGLNFS.js} +1 -1
  12. package/dist/{chunk-QTCZPS5I.js → chunk-75HOCFNH.js} +1 -1
  13. package/dist/{chunk-5RL254O2.js → chunk-7WUT5ZSO.js} +1 -1
  14. package/dist/{chunk-KR7CIEQR.js → chunk-AA4PNQKR.js} +1 -1
  15. package/dist/chunk-CNWUIXF3.js +1 -0
  16. package/dist/{chunk-6HCAGHCY.js → chunk-DF4NWPB7.js} +1 -1
  17. package/dist/chunk-DT4X7I5M.js +81 -0
  18. package/dist/chunk-GDKFN3CM.js +8 -0
  19. package/dist/{chunk-WLCBXCZV.js → chunk-GTJY55QK.js} +1 -1
  20. package/dist/{chunk-5ZA4JYOP.js → chunk-GXTCU4WF.js} +1 -1
  21. package/dist/{chunk-SV2SP22H.js → chunk-IUYZ3NHS.js} +3 -3
  22. package/dist/{chunk-KS4FB5W7.js → chunk-IXOLHPTN.js} +1 -1
  23. package/dist/{chunk-2L4PSZQB.js → chunk-L36ZASME.js} +1 -1
  24. package/dist/{chunk-7PNARN6S.js → chunk-N2BIIUDH.js} +1 -1
  25. package/dist/{chunk-QFCKHUEP.js → chunk-P475BOJW.js} +1 -1
  26. package/dist/{chunk-5BGPGNRQ.js → chunk-QHY6F4SS.js} +1 -1
  27. package/dist/chunk-QK5QOXOE.js +13 -0
  28. package/dist/{chunk-QAF26ZQX.js → chunk-RPHM7LQW.js} +1 -1
  29. package/dist/chunk-SNO3WG4V.js +2 -0
  30. package/dist/chunk-TTFQWH55.js +91 -0
  31. package/dist/{chunk-HASVV34S.js → chunk-VL3APTVB.js} +1 -1
  32. package/dist/{chunk-WOTTSPSF.js → chunk-VUR7H2FU.js} +1 -1
  33. package/dist/chunk-VZPWIILU.js +1 -0
  34. package/dist/chunk-WP3CXMVA.js +2 -0
  35. package/dist/{chunk-ESWFBSYM.js → chunk-Z57G62KE.js} +1 -1
  36. package/dist/{create-DLUWG46F.js → create-O2KLTN5H.js} +1 -1
  37. package/dist/{doctor-IZ4YOCYE.js → doctor-AL5YWO5X.js} +1 -1
  38. package/dist/index.d.ts +4 -0
  39. package/dist/index.js +166 -164
  40. package/dist/{pipeline-IBQYDLFF.js → pipeline-4ST4BQWY.js} +1 -1
  41. package/dist/{project-intelligence-lens-SIU7IXKG.js → project-intelligence-lens-JHYECYOK.js} +1 -1
  42. package/dist/{verified-goal-M4GPOXNL.js → verified-goal-KFNRGOKT.js} +1 -1
  43. package/dist/{workspace-3AAOUELG.js → workspace-O4E5CCGK.js} +1 -1
  44. package/dist/{workspace-agent-sync-QGYLY7HH.js → workspace-agent-sync-N5DPGU2E.js} +1 -1
  45. package/dist/{workspace-context-JCLPRYNC.js → workspace-context-ETZNEHOJ.js} +1 -1
  46. package/dist/{workspace-contract-IUUPBQXU.js → workspace-contract-OSI7NBXS.js} +1 -1
  47. package/dist/{workspace-explain-CZGBVDE6.js → workspace-explain-EM7IUV6L.js} +1 -1
  48. package/dist/{workspace-foundation-7IGMO4CW.js → workspace-foundation-QQHX66KE.js} +1 -1
  49. package/dist/{workspace-graph-stream-5YMLJXAJ.js → workspace-graph-stream-UZJQ75XZ.js} +1 -1
  50. package/dist/workspace-graph-token-efficiency-TF23UYEF.js +1 -0
  51. package/dist/{workspace-intelligence-XHSUFTAT.js → workspace-intelligence-A7O7MN6T.js} +1 -1
  52. package/dist/{workspace-intelligence-runner-EN5V4KSC.js → workspace-intelligence-runner-4EF66L66.js} +1 -1
  53. package/dist/{workspace-knowledge-graph-VWQTIEYK.js → workspace-knowledge-graph-BVN4NTJ6.js} +1 -1
  54. package/dist/{workspace-knowledge-graph-query-TXA3KVUV.js → workspace-knowledge-graph-query-6DAOXGGT.js} +1 -1
  55. package/dist/{workspace-knowledge-graph-snapshot-WB62AVDK.js → workspace-knowledge-graph-snapshot-XSQADCNR.js} +1 -1
  56. package/dist/{workspace-mcp-serve-NCAGGWQS.js → workspace-mcp-serve-TKX4J3SX.js} +1 -1
  57. package/dist/{workspace-model-NXFIKX26.js → workspace-model-7ESEP366.js} +1 -1
  58. package/dist/{workspace-onboarding-OP22NHQ4.js → workspace-onboarding-SY255V7L.js} +1 -1
  59. package/dist/{workspace-registry-summary-A5VDPRHU.js → workspace-registry-summary-7ISKYEPM.js} +1 -1
  60. package/dist/{workspace-repair-engine-N4KXNSVL.js → workspace-repair-engine-GMA2YTCF.js} +1 -1
  61. package/dist/workspace-run-ZZXVNFUS.js +1 -0
  62. package/dist/{workspace-verify-TUVLFPPN.js → workspace-verify-CNXZPWS5.js} +1 -1
  63. package/dist/{workspace-watch-2ZNOYSUQ.js → workspace-watch-HGFL2EU3.js} +1 -1
  64. package/docs/From Code to Shared Understanding-B.png +0 -0
  65. package/docs/From Code to Shared Understanding.png +0 -0
  66. package/docs/README_CONTENT_CONTRACT.md +25 -12
  67. package/docs/ci-workflows.md +9 -1
  68. package/docs/commands-reference.md +1 -1
  69. package/docs/contracts/README.md +16 -12
  70. package/docs/doctor-command.md +35 -11
  71. package/docs/from-code-to-shared-understanding.md +22 -17
  72. package/docs/real-world-qualification.md +73 -0
  73. package/docs/workspace-knowledge-graph.md +24 -3
  74. package/docs/workspace-operations.md +14 -2
  75. package/docs/workspace-run.md +16 -4
  76. package/package.json +5 -1
  77. package/dist/autopilot-release-CH57CGET.js +0 -1
  78. package/dist/capabilities-command-WEOGFCWF.js +0 -1
  79. package/dist/chunk-664GXRLD.js +0 -1
  80. package/dist/chunk-7Y3KVZJF.js +0 -8
  81. package/dist/chunk-BDN32Y2N.js +0 -81
  82. package/dist/chunk-DIZSHNZ5.js +0 -2
  83. package/dist/chunk-DOIZANFA.js +0 -2
  84. package/dist/chunk-OX53L237.js +0 -13
  85. package/dist/chunk-QRWWYL52.js +0 -88
  86. package/dist/chunk-VGJVIHHR.js +0 -1
  87. package/dist/workspace-graph-token-efficiency-HK4KNWWP.js +0 -1
  88. package/dist/workspace-run-PXKC3ELS.js +0 -1
package/README.md CHANGED
@@ -4,10 +4,40 @@
4
4
  [![Downloads](https://img.shields.io/npm/dm/workspai.svg?style=flat-square)](https://www.npmjs.com/package/workspai)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE)
6
6
 
7
- ## Workspace Intelligence for software systems
7
+ ## Give your AI agent the system—not just the repository
8
+
9
+ Your coding agent should not have to rediscover your architecture in every
10
+ session. Workspai builds a current, evidence-backed view of your projects,
11
+ APIs, dependencies, infrastructure, and change boundaries, then gives agents
12
+ the bounded context they need.
8
13
 
9
14
  > One workspace. One truth. Humans and AI aligned.
10
15
 
16
+ ```bash
17
+ npx workspai adopt .
18
+ npx workspai workspace intelligence run --for-agent generic
19
+ ```
20
+
21
+ A single run gives developers and tools the same operational picture:
22
+
23
+ ```text
24
+ System projects · runtimes · APIs · dependencies · infrastructure
25
+ Evidence relationships linked back to canonical proof
26
+ Change affected projects and verification targets
27
+ Agents bounded context instead of an unfiltered repository dump
28
+ ```
29
+
30
+ **Understand the system before an agent changes it.**
31
+
32
+ ![Workspai CLI adopting and analyzing the gRPC repository](https://raw.githubusercontent.com/chistiq/workspai/main/packages/cli/docs/workspai-grpc-readme-cli.gif)
33
+
34
+ [Get started](#start-in-two-minutes) ·
35
+ [See what you get](#what-happens-after-the-first-run) ·
36
+ [How it works](#how-workspace-intelligence-works) ·
37
+ [Documentation](docs/README.md)
38
+
39
+ ## Workspace Intelligence for software systems
40
+
11
41
  Workspai is an open-source CLI that brings related software projects together,
12
42
  so people and AI tools can understand and work with the same system.
13
43
 
@@ -17,11 +47,6 @@ so people and AI tools can understand and work with the same system.
17
47
  - **Act with confidence:** understand impact, verify changes, and prepare focused
18
48
  context for AI tools.
19
49
 
20
- [Quickstart](#start-in-two-minutes) ·
21
- [Everyday workflows](#everyday-workflows) ·
22
- [How it works](#how-workspace-intelligence-works) ·
23
- [Documentation](docs/README.md)
24
-
25
50
  ![From Code to Shared Understanding](https://raw.githubusercontent.com/chistiq/workspai/main/packages/cli/docs/From%20Code%20to%20Shared%20Understanding.png)
26
51
 
27
52
  ## Start in two minutes
@@ -38,14 +63,17 @@ npx workspai adopt .
38
63
  The project stays where it is. Workspai creates or reuses a minimal workspace
39
64
  in the default system location and records a validated local link.
40
65
 
41
- Stay in the same project directory and run the complete intelligence loop:
66
+ Stay in the same project directory and run Workspace Intelligence:
42
67
 
43
68
  ```bash
44
- npx workspai workspace intelligence run --for-agent generic --strict --json
69
+ npx workspai workspace intelligence run --for-agent generic
45
70
  ```
46
71
 
47
72
  Workspai now knows which workspace owns the project. You only need
48
73
  `--workspace <path>` when a moved or ambiguous binding cannot be resolved.
74
+ The shorter command is intended for a human-readable first run. CI, agents, and
75
+ other machine consumers should use the strict JSON form shown in
76
+ [How Workspace Intelligence works](#how-workspace-intelligence-works).
49
77
 
50
78
  ### Start new software
51
79
 
@@ -0,0 +1,72 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://workspai.dev/contracts/adopt-effects.v1.json",
4
+ "title": "Workspai Adopt Effects v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion",
9
+ "sourceMode",
10
+ "sourceCodeModified",
11
+ "projectMetadataFiles",
12
+ "repositoryControlFiles",
13
+ "workspaceOperations"
14
+ ],
15
+ "properties": {
16
+ "schemaVersion": {
17
+ "const": "workspai.adopt-effects.v1"
18
+ },
19
+ "sourceMode": {
20
+ "const": "linked"
21
+ },
22
+ "sourceCodeModified": {
23
+ "const": false
24
+ },
25
+ "projectMetadataFiles": {
26
+ "type": "array",
27
+ "items": {
28
+ "type": "string",
29
+ "minLength": 1
30
+ },
31
+ "uniqueItems": true
32
+ },
33
+ "repositoryControlFiles": {
34
+ "type": "array",
35
+ "items": {
36
+ "type": "object",
37
+ "additionalProperties": false,
38
+ "required": [
39
+ "path",
40
+ "action",
41
+ "condition"
42
+ ],
43
+ "properties": {
44
+ "path": {
45
+ "type": "string",
46
+ "minLength": 1
47
+ },
48
+ "action": {
49
+ "const": "reconcile"
50
+ },
51
+ "condition": {
52
+ "type": "string",
53
+ "minLength": 1
54
+ }
55
+ }
56
+ }
57
+ },
58
+ "workspaceOperations": {
59
+ "type": "array",
60
+ "items": {
61
+ "enum": [
62
+ "register-project",
63
+ "sync-contract",
64
+ "rebuild-model",
65
+ "rebuild-graph",
66
+ "sync-agent-grounding"
67
+ ]
68
+ },
69
+ "uniqueItems": true
70
+ }
71
+ }
72
+ }
@@ -384,6 +384,10 @@
384
384
  "flags": "--fresh",
385
385
  "attributeName": "fresh"
386
386
  },
387
+ {
388
+ "flags": "--verbose",
389
+ "attributeName": "verbose"
390
+ },
387
391
  {
388
392
  "flags": "--strict",
389
393
  "attributeName": "strict"
@@ -270,6 +270,7 @@
270
270
  "warnings": { "type": "integer", "minimum": 0 },
271
271
  "errors": { "type": "integer", "minimum": 0 },
272
272
  "verdict": { "enum": ["passed", "attention", "blocked"] },
273
+ "presentation": { "$ref": "#/$defs/healthScorePresentation" },
273
274
  "components": {
274
275
  "type": "object",
275
276
  "required": ["host", "projects"],
@@ -282,6 +283,30 @@
282
283
  },
283
284
  "additionalProperties": false
284
285
  },
286
+ "healthScorePresentation": {
287
+ "type": "object",
288
+ "required": [
289
+ "policy",
290
+ "diagnosticPassRatePercent",
291
+ "blockingFindings",
292
+ "advisoryFindings",
293
+ "unknownFindings",
294
+ "contradictionFindings",
295
+ "notApplicableChecks",
296
+ "label"
297
+ ],
298
+ "properties": {
299
+ "policy": { "const": "doctor-multi-axis-v1" },
300
+ "diagnosticPassRatePercent": { "type": ["number", "null"], "minimum": 0, "maximum": 100 },
301
+ "blockingFindings": { "type": "integer", "minimum": 0 },
302
+ "advisoryFindings": { "type": "integer", "minimum": 0 },
303
+ "unknownFindings": { "type": "integer", "minimum": 0 },
304
+ "contradictionFindings": { "type": "integer", "minimum": 0 },
305
+ "notApplicableChecks": { "type": "integer", "minimum": 0 },
306
+ "label": { "const": "diagnostic-pass-rate" }
307
+ },
308
+ "additionalProperties": false
309
+ },
285
310
  "probeSummary": {
286
311
  "type": "object",
287
312
  "required": [
@@ -300,6 +325,8 @@
300
325
  "failed": { "type": "integer", "minimum": 0 },
301
326
  "blockingFindings": { "type": "integer", "minimum": 0 },
302
327
  "advisoryFindings": { "type": "integer", "minimum": 0 },
328
+ "unknownFindings": { "type": "integer", "minimum": 0 },
329
+ "contradictionFindings": { "type": "integer", "minimum": 0 },
303
330
  "verdict": { "enum": ["passed", "attention", "blocked"] }
304
331
  },
305
332
  "additionalProperties": false
@@ -68,6 +68,8 @@
68
68
  "verdict": { "enum": ["passed", "attention", "blocked"] },
69
69
  "blockingFindings": { "type": "integer", "minimum": 0 },
70
70
  "advisoryFindings": { "type": "integer", "minimum": 0 },
71
+ "unknownFindings": { "type": "integer", "minimum": 0 },
72
+ "contradictionFindings": { "type": "integer", "minimum": 0 },
71
73
  "hasSystemErrors": { "type": "boolean" },
72
74
  "scopeProvenance": { "type": "object", "additionalProperties": true }
73
75
  },
@@ -280,6 +282,7 @@
280
282
  "warnings": { "type": "integer", "minimum": 0 },
281
283
  "errors": { "type": "integer", "minimum": 0 },
282
284
  "verdict": { "enum": ["passed", "attention", "blocked"] },
285
+ "presentation": { "$ref": "#/$defs/healthScorePresentation" },
283
286
  "components": {
284
287
  "type": "object",
285
288
  "required": ["host", "projects"],
@@ -292,6 +295,30 @@
292
295
  },
293
296
  "additionalProperties": false
294
297
  },
298
+ "healthScorePresentation": {
299
+ "type": "object",
300
+ "required": [
301
+ "policy",
302
+ "diagnosticPassRatePercent",
303
+ "blockingFindings",
304
+ "advisoryFindings",
305
+ "unknownFindings",
306
+ "contradictionFindings",
307
+ "notApplicableChecks",
308
+ "label"
309
+ ],
310
+ "properties": {
311
+ "policy": { "const": "doctor-multi-axis-v1" },
312
+ "diagnosticPassRatePercent": { "type": ["number", "null"], "minimum": 0, "maximum": 100 },
313
+ "blockingFindings": { "type": "integer", "minimum": 0 },
314
+ "advisoryFindings": { "type": "integer", "minimum": 0 },
315
+ "unknownFindings": { "type": "integer", "minimum": 0 },
316
+ "contradictionFindings": { "type": "integer", "minimum": 0 },
317
+ "notApplicableChecks": { "type": "integer", "minimum": 0 },
318
+ "label": { "const": "diagnostic-pass-rate" }
319
+ },
320
+ "additionalProperties": false
321
+ },
295
322
  "probeSummary": {
296
323
  "type": "object",
297
324
  "required": [
@@ -310,6 +337,8 @@
310
337
  "failed": { "type": "integer", "minimum": 0 },
311
338
  "blockingFindings": { "type": "integer", "minimum": 0 },
312
339
  "advisoryFindings": { "type": "integer", "minimum": 0 },
340
+ "unknownFindings": { "type": "integer", "minimum": 0 },
341
+ "contradictionFindings": { "type": "integer", "minimum": 0 },
313
342
  "verdict": { "enum": ["passed", "attention", "blocked"] }
314
343
  },
315
344
  "additionalProperties": false
@@ -13,6 +13,7 @@
13
13
  "workspaceArchiveOperationResult": "workspai-workspace-archive-operation-result-v1",
14
14
  "ingestionPlan": "workspai.ingestion-plan.v1",
15
15
  "ingestionResult": "workspai.ingestion-result.v1",
16
+ "adoptEffects": "workspai.adopt-effects.v1",
16
17
  "projectEntryCapability": "workspai-project-entry-capability-v1",
17
18
  "projectWorkspaceLink": "project-workspace-link.v1",
18
19
  "projectWorkspaceResolution": "project-workspace-resolution.v1",
@@ -51,6 +51,11 @@
51
51
  "contractPath": "contracts/ingestion-result.v1.json",
52
52
  "publication": "json-schema"
53
53
  },
54
+ "adoptEffects": {
55
+ "schemaVersion": "workspai.adopt-effects.v1",
56
+ "contractPath": "contracts/adopt-effects.v1.json",
57
+ "publication": "json-schema"
58
+ },
54
59
  "projectEntryCapability": {
55
60
  "schemaVersion": "workspai-project-entry-capability-v1",
56
61
  "contractPath": "contracts/project-entry-capability.v1.json",
@@ -27,7 +27,8 @@
27
27
  "name": { "type": "string" },
28
28
  "path": { "type": "string" },
29
29
  "runtimeFamily": { "type": "string" },
30
- "framework": { "type": "string" }
30
+ "framework": { "type": "string" },
31
+ "projectArchetype": { "enum": ["application", "service", "library", "sdk", "platform", "plugin", "monorepo", "unknown"] }
31
32
  },
32
33
  "additionalProperties": false
33
34
  },
@@ -40,6 +41,7 @@
40
41
  "name": { "type": "string" },
41
42
  "path": { "type": "string" },
42
43
  "runtimeFamily": { "type": "string" },
44
+ "projectArchetype": { "enum": ["application", "service", "library", "sdk", "platform", "plugin", "monorepo", "unknown"] },
43
45
  "verdict": { "enum": ["passed", "attention", "blocked"] },
44
46
  "blockingCauses": { "type": "integer", "minimum": 0 },
45
47
  "advisoryFindings": { "type": "integer", "minimum": 0 },
@@ -0,0 +1 @@
1
+ export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-DF4NWPB7.js';
@@ -0,0 +1 @@
1
+ export{b as runDoctorCapabilities}from'./chunk-IXOLHPTN.js';
@@ -1 +1 @@
1
- import {b,c,d as d$1}from'./chunk-ESWFBSYM.js';import {a as a$1,b as b$1}from'./chunk-PYCJWW4B.js';import {c as c$2}from'./chunk-IZLEMTES.js';import {c as c$1,d as d$4}from'./chunk-2L4PSZQB.js';import {p as p$1,a,o,g,d as d$3,f as f$1}from'./chunk-5BGPGNRQ.js';import {a as a$4}from'./chunk-X7FYEKLI.js';import {p,l,f as f$2}from'./chunk-5ZA4JYOP.js';import {d}from'./chunk-EWZZUQBR.js';import {a as a$2}from'./chunk-DOIZANFA.js';import {d as d$2,e as e$1}from'./chunk-ADL3CK44.js';import {a as a$3}from'./chunk-AFIFZTOY.js';import {f,e,i,g as g$1,h}from'./chunk-5EPPPMAS.js';import m from'path';import v from'fs-extra';var fe="rapidkit-blocker-resolution-v1";function pe(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return f$2({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function we(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function me(e){let t=we(e.reason),r=pe({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",...e.sourceCommand?{}:{studioActionId:"run-analyze"}}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:fe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?e.sourceCommand?`Run the source command once: ${e.sourceCommand}, then verify.`:"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function Re(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function Ce(e){return e.length===0||e.every(t=>Re(t))}function ge(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&Ce(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function tt(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ye=f.verify,G=e.verify;function Ae(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ke(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f$1)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$3(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$3(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let o=s.transitiveImpact.reduce((u,d)=>Math.max(u,d.distance??0),0);s.summary.blastRadius.maxDistance!==o&&i.push("blastRadius.maxDistance does not match transitive impact distances");let k=l(s.diff.currentModel)?.edges.length??0;if(s.summary.blastRadius.graphEdges!==k&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==d(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function Ee(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function Se(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function We(e$1,t){if(e$1.id==="workspace.doctor")return m.join(t,e.doctor);if(e$1.id==="workspace.contract.verify")return m.join(t,e.contractVerify);if(e$1.id==="workspace.readiness")return m.join(t,e.readiness);if(e$1.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e$1.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e$1.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e$1.id.startsWith("project.")&&e$1.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function C(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function je(e){if(!c$1(e,"workspace"))return {status:"fail",message:"Doctor evidence contract is missing or unsupported."};try{d$4(e);}catch(s){return {status:"fail",message:`Doctor evidence semantic validation failed: ${s instanceof Error?s.message:String(s)}`}}let t=a$4(e);return t.hasSystemErrors||t.blockingFindings>0?{status:"fail",message:`Doctor evidence reports ${t.blockingFindings} canonical blocking finding(s).`}:t.advisoryFindings+t.unknownFindings+t.contradictionCount+t.missingDiagnosisProjects>0||t.staleEvidence||t.unknownFreshness||t.minimumDiagnosisCompleteness<100?{status:"warn",message:`Doctor evidence needs attention (${t.advisoryFindings} advisory, ${t.unknownFindings} unknown, ${t.contradictionCount} contradictory; ${t.minimumDiagnosisCompleteness}% complete).`}:{status:"pass",message:"Canonical Doctor evidence is complete, fresh, and healthy."}}function xe(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function Pe(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function Ie(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function Ve(e){let t=e.schemaVersion===h.doctorFixResult.schemaVersion?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function Fe(e,t){let r=await d$2(e,i.doctorRemediationPlan);if(!r)return false;try{let s=C(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let o=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!o||!t)return true;let k=Date.parse(o),u=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(u)?true:k>=u}catch{return false}}function $e(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Oe(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function De(e,t,r){let s=$e(t),i=c$2(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let o=i.stage;if(s&&o!==s)return {status:"missing",message:`Workspace run evidence is for stage "${o}", expected "${s}".`};let k=Array.isArray(i.projects)?i.projects:[],u=t.project?.toLowerCase();if(!u)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=k.find(g=>{let c=C(g);if(!c)return false;let n=typeof c.projectName=="string"?c.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(f=>c[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return n===u||a.some(f=>f.endsWith(`/${u}`)||f===u)});if(d){let g=R(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(g)return {status:"fail",message:g};let c=C(d),n=typeof c?.status=="string"?c.status:"unknown";return n==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:n==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:n==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${n} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function R(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function Be(e){if(e.id==="workspace.doctor")return g$1.doctor;if(e.id==="workspace.readiness")return g$1.readiness;if(e.id==="workspace.contract.verify")return g$1.contractVerify;if(e.id==="workspace.analyze")return g$1.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function _e(e,t,r,s){let i=We(e,t),o=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let k=i?await d$2(t,o??""):null;if(!i||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:o,message:o?`Missing evidence report: ${o}`:"No evidence mapping exists for this command."};let u;try{u=await v.readJson(k);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=C(u);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:"Evidence report is not a JSON object."};let g=Be(e);if(g)try{a$3(d,g,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=R(d.generatedAt,s,"Doctor evidence");n?c={status:"fail",message:n}:c=je(d);}else if(e.id==="workspace.readiness"){let n=R(d.generatedAt,s,"Release readiness evidence");n?c={status:"fail",message:n}:c=xe(d);}else if(e.id==="workspace.contract.verify"){let n=R(d.generatedAt,s,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.analyze"){let n=R(d.generatedAt,s,"Analyze evidence");n?c={status:"fail",message:n}:c=Ie(d);}else if(e.id==="workspace.pipeline"){let n=R(d.generatedAt,s,"Pipeline evidence");n?c={status:"fail",message:n}:c=Oe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion===h.doctorFixResult.schemaVersion?d:d.fixResult,a=C(n),f=typeof a?.generatedAt=="string"?a.generatedAt:void 0,y=R(f,s,"Doctor fix result");y?c={status:"fail",message:y}:await Fe(t,f)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=Ve(d);}else if(e.id.startsWith("project."))c=De(d,e,s);else {let n=R(d.generatedAt,s,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:o,message:c.message}}function Ne(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,o=e.filter(n=>n.status==="missing").length,k=e.filter(n=>n.status==="skipped").length,u=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,g="ready",c=0;return u.length>0||t.blockingReasons.length>0?(g="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(g="needs-attention",c=1),{verdict:g,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:o,stepsSkipped:k}}function He(e,t){let r=x(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),s=new Set(r.map(a=>a.toLowerCase())),i=x(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!s.has(a.toLowerCase()))),o=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let f=a.project.toLowerCase(),y=o.get(f)??[];y.push(a),o.set(f,y);}let k=[],u=[],d=[],g=[],c=false,n=(a,f)=>{let y=o.get(a.toLowerCase())??[];if(y.length===0){d.push(a);return}let P=y.filter(p=>p.status==="fail"),b=P.filter(p=>p.required),I=y.filter(p=>p.status==="missing"),E=I.filter(p=>p.required),V=y.some(p=>p.status==="pass"||p.status==="warn");if(b.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has failed verification evidence (${b.map(p=>p.id).join(", ")}).`);return}if(P.length>0){u.push(a),c=true;return}if(E.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has missing required verification evidence (${E.map(p=>p.id).join(", ")}).`);return}if(I.length>0){u.push(a),c=true;return}if(V){k.push(a);return}d.push(a);};for(let a of r)n(a,"directly-changed");for(let a of i)n(a,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:x(k),uncovered:x(u),unverifiable:x(d)},blockingReasons:g,needsAttention:c}}function x(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Me(e$1){let t=m.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let o=Ae(t,e$1.fromImpactPath);return {impact:await ke(o),fromImpactRef:m.relative(t,o).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g);if(await v.pathExists(r))return {impact:await ke(r),fromImpactRef:g,impactFromDisk:true};let s=m.join(t,d$3);if(await v.pathExists(s))return {impact:await p$1({workspacePath:t,fromPath:d$3,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:d$3,impactFromDisk:false};let i=await p({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:f$1,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:e.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:l(i)?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:f.diff,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:e.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Te(e,t){if(t)return e.generatedAt}async function bt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Me(e),o$1=r.diff.currentModel,k=i?await p({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):o$1,u=[];if(i){let l=await p$1({workspacePath:t,fromPath:r.diff.fromRef,diff:r.diff,scope:e.scope,now:e.now}),W=[r.affectedProjects,r.transitiveImpact,r.verificationPlan],A=[l.affectedProjects,l.transitiveImpact,l.verificationPlan];JSON.stringify(W)!==JSON.stringify(A)&&u.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&d(k)!==r.diff.toHash&&u.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$2=r.diff.git;if(i&&d$2?.available){let l=a(t,{ref:d$2.ref}),W=r.diff.changes.filter(h=>h.type.startsWith("git.")).map(h=>`${h.type}:${h.target.replace(/^git:/,"")}`).sort(),A=[...l.changedFiles.map(h=>`git.file.changed:${h}`),...l.untrackedFiles.map(h=>`git.untracked:${h}`),...l.deletedFiles.map(h=>`git.deleted:${h}`)].sort();(!l.available||l.commit!==d$2.commit||JSON.stringify(A)!==JSON.stringify(W))&&u.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let g=Te(r,i),c$1=Ee([...o(),...r.verificationPlan]).filter(l=>Se(e.scope,l)),n=[];for(let l of c$1)n.push(await _e(l,t,o$1.contracts.exists===true,g));let a$2=He(r,n),f=a$1(l(o$1)??{nodes:[],edges:[]}),y=b(o$1),P=await Ke(t),b$2=c(y,P?.freshness?.projectHashes),I={verdict:b$2.verdict,baseline:b$2.baseline,changed:b$2.changed,added:b$2.added,removed:b$2.removed,projectHashes:d$1(y)},E=b$1(f),V=o$1.policies?.mode??"warn",p$2=await Le(o$1,t),B=qe(V,p$2),S=Ne(n,{blockingReasons:[...a$2.blockingReasons,...E,...B.blockingReasons,...u],needsAttention:a$2.needsAttention||B.needsAttention}),he=n.filter(l=>l.status==="missing"&&l.evidencePath).map(l=>l.evidencePath),_=[...n.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),...a$2.blockingReasons,...E,...B.blockingReasons,...u],ve=p$2.filter(l=>l.severity==="error").length,be=o$1.summary?.projectCount??o$1.projects.length,U=ge({projectCount:be,verdict:S.verdict,exitCode:S.exitCode,blockingReasons:_,policyErrorCount:ve});S.verdict=U.verdict,S.exitCode=U.exitCode;let Y=Array.from(new Set(_.map(l=>l.trim()).filter(Boolean))).slice(0,12).map((l,W)=>{let A=n.find(h=>l.startsWith(`${h.id}:`));return me({reason:l,blockerId:`blocker-${W+1}`,sourceCommand:A?.command.display,sourceArtifact:A?.evidencePath,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:G})});return {schemaVersion:ye,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:S,steps:n,missingEvidence:he,blockingReasons:_,...Y.length>0?{resolutionHints:Y}:{},verificationPlan:c$1,affectedSubgraph:a$2.subgraph,graphIntegrity:f,freshness:I,policyMode:V,policyViolations:p$2}}async function Le(e$1,t){let r=[];for(let i of e$1.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await d$2(t,e.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let o of i.violations)typeof o=="string"&&o.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:o});}}catch{}return r.sort((i,o)=>i.source!==o.source?i.source.localeCompare(o.source):i.code!==o.code?i.code.localeCompare(o.code):i.message.localeCompare(o.message))}function qe(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function Ke(e){let t=m.join(e,G);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ye?r:null}catch{return null}}async function wt(e,t){return e$1(t,G,a$2(e))}function ze(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function Rt(e,t){return ze(e,t).exitCode}export{fe as a,tt as b,ye as c,G as d,He as e,bt as f,wt as g,ze as h,Rt as i};
1
+ import {b,c,d as d$1}from'./chunk-Z57G62KE.js';import {a as a$1,b as b$1}from'./chunk-PYCJWW4B.js';import {c as c$2}from'./chunk-IZLEMTES.js';import {c as c$1,d as d$4}from'./chunk-L36ZASME.js';import {p as p$1,a,o,g,d as d$3,f as f$1}from'./chunk-QHY6F4SS.js';import {a as a$4}from'./chunk-X7FYEKLI.js';import {p,l,f as f$2}from'./chunk-GXTCU4WF.js';import {d}from'./chunk-EWZZUQBR.js';import {a as a$2}from'./chunk-SNO3WG4V.js';import {d as d$2,e as e$1}from'./chunk-ADL3CK44.js';import {a as a$3}from'./chunk-AFIFZTOY.js';import {f,e,i,g as g$1,h}from'./chunk-5EPPPMAS.js';import m from'path';import v from'fs-extra';var fe="rapidkit-blocker-resolution-v1";function pe(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return f$2({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function we(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function me(e){let t=we(e.reason),r=pe({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",...e.sourceCommand?{}:{studioActionId:"run-analyze"}}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:fe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?e.sourceCommand?`Run the source command once: ${e.sourceCommand}, then verify.`:"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function Re(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function Ce(e){return e.length===0||e.every(t=>Re(t))}function ge(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&Ce(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function tt(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ye=f.verify,G=e.verify;function Ae(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ke(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f$1)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$3(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$3(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let o=s.transitiveImpact.reduce((u,d)=>Math.max(u,d.distance??0),0);s.summary.blastRadius.maxDistance!==o&&i.push("blastRadius.maxDistance does not match transitive impact distances");let k=l(s.diff.currentModel)?.edges.length??0;if(s.summary.blastRadius.graphEdges!==k&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==d(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function Ee(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function Se(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function We(e$1,t){if(e$1.id==="workspace.doctor")return m.join(t,e.doctor);if(e$1.id==="workspace.contract.verify")return m.join(t,e.contractVerify);if(e$1.id==="workspace.readiness")return m.join(t,e.readiness);if(e$1.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e$1.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e$1.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e$1.id.startsWith("project.")&&e$1.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function C(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function je(e){if(!c$1(e,"workspace"))return {status:"fail",message:"Doctor evidence contract is missing or unsupported."};try{d$4(e);}catch(s){return {status:"fail",message:`Doctor evidence semantic validation failed: ${s instanceof Error?s.message:String(s)}`}}let t=a$4(e);return t.hasSystemErrors||t.blockingFindings>0?{status:"fail",message:`Doctor evidence reports ${t.blockingFindings} canonical blocking finding(s).`}:t.advisoryFindings+t.unknownFindings+t.contradictionCount+t.missingDiagnosisProjects>0||t.staleEvidence||t.unknownFreshness||t.minimumDiagnosisCompleteness<100?{status:"warn",message:`Doctor evidence needs attention (${t.advisoryFindings} advisory, ${t.unknownFindings} unknown, ${t.contradictionCount} contradictory; ${t.minimumDiagnosisCompleteness}% complete).`}:{status:"pass",message:"Canonical Doctor evidence is complete, fresh, and healthy."}}function xe(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function Pe(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function Ie(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function Ve(e){let t=e.schemaVersion===h.doctorFixResult.schemaVersion?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function Fe(e,t){let r=await d$2(e,i.doctorRemediationPlan);if(!r)return false;try{let s=C(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let o=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!o||!t)return true;let k=Date.parse(o),u=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(u)?true:k>=u}catch{return false}}function $e(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Oe(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function De(e,t,r){let s=$e(t),i=c$2(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let o=i.stage;if(s&&o!==s)return {status:"missing",message:`Workspace run evidence is for stage "${o}", expected "${s}".`};let k=Array.isArray(i.projects)?i.projects:[],u=t.project?.toLowerCase();if(!u)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=k.find(g=>{let c=C(g);if(!c)return false;let n=typeof c.projectName=="string"?c.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(f=>c[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return n===u||a.some(f=>f.endsWith(`/${u}`)||f===u)});if(d){let g=R(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(g)return {status:"fail",message:g};let c=C(d),n=typeof c?.status=="string"?c.status:"unknown";return n==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:n==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:n==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${n} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function R(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function Be(e){if(e.id==="workspace.doctor")return g$1.doctor;if(e.id==="workspace.readiness")return g$1.readiness;if(e.id==="workspace.contract.verify")return g$1.contractVerify;if(e.id==="workspace.analyze")return g$1.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function _e(e,t,r,s){let i=We(e,t),o=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let k=i?await d$2(t,o??""):null;if(!i||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:o,message:o?`Missing evidence report: ${o}`:"No evidence mapping exists for this command."};let u;try{u=await v.readJson(k);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=C(u);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:"Evidence report is not a JSON object."};let g=Be(e);if(g)try{a$3(d,g,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=R(d.generatedAt,s,"Doctor evidence");n?c={status:"fail",message:n}:c=je(d);}else if(e.id==="workspace.readiness"){let n=R(d.generatedAt,s,"Release readiness evidence");n?c={status:"fail",message:n}:c=xe(d);}else if(e.id==="workspace.contract.verify"){let n=R(d.generatedAt,s,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.analyze"){let n=R(d.generatedAt,s,"Analyze evidence");n?c={status:"fail",message:n}:c=Ie(d);}else if(e.id==="workspace.pipeline"){let n=R(d.generatedAt,s,"Pipeline evidence");n?c={status:"fail",message:n}:c=Oe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion===h.doctorFixResult.schemaVersion?d:d.fixResult,a=C(n),f=typeof a?.generatedAt=="string"?a.generatedAt:void 0,y=R(f,s,"Doctor fix result");y?c={status:"fail",message:y}:await Fe(t,f)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=Ve(d);}else if(e.id.startsWith("project."))c=De(d,e,s);else {let n=R(d.generatedAt,s,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:o,message:c.message}}function Ne(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,o=e.filter(n=>n.status==="missing").length,k=e.filter(n=>n.status==="skipped").length,u=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,g="ready",c=0;return u.length>0||t.blockingReasons.length>0?(g="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(g="needs-attention",c=1),{verdict:g,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:o,stepsSkipped:k}}function He(e,t){let r=x(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),s=new Set(r.map(a=>a.toLowerCase())),i=x(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!s.has(a.toLowerCase()))),o=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let f=a.project.toLowerCase(),y=o.get(f)??[];y.push(a),o.set(f,y);}let k=[],u=[],d=[],g=[],c=false,n=(a,f)=>{let y=o.get(a.toLowerCase())??[];if(y.length===0){d.push(a);return}let P=y.filter(p=>p.status==="fail"),b=P.filter(p=>p.required),I=y.filter(p=>p.status==="missing"),E=I.filter(p=>p.required),V=y.some(p=>p.status==="pass"||p.status==="warn");if(b.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has failed verification evidence (${b.map(p=>p.id).join(", ")}).`);return}if(P.length>0){u.push(a),c=true;return}if(E.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has missing required verification evidence (${E.map(p=>p.id).join(", ")}).`);return}if(I.length>0){u.push(a),c=true;return}if(V){k.push(a);return}d.push(a);};for(let a of r)n(a,"directly-changed");for(let a of i)n(a,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:x(k),uncovered:x(u),unverifiable:x(d)},blockingReasons:g,needsAttention:c}}function x(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Me(e$1){let t=m.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let o=Ae(t,e$1.fromImpactPath);return {impact:await ke(o),fromImpactRef:m.relative(t,o).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g);if(await v.pathExists(r))return {impact:await ke(r),fromImpactRef:g,impactFromDisk:true};let s=m.join(t,d$3);if(await v.pathExists(s))return {impact:await p$1({workspacePath:t,fromPath:d$3,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:d$3,impactFromDisk:false};let i=await p({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:f$1,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:e.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:l(i)?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:f.diff,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:e.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Te(e,t){if(t)return e.generatedAt}async function bt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Me(e),o$1=r.diff.currentModel,k=i?await p({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):o$1,u=[];if(i){let l=await p$1({workspacePath:t,fromPath:r.diff.fromRef,diff:r.diff,scope:e.scope,now:e.now}),W=[r.affectedProjects,r.transitiveImpact,r.verificationPlan],A=[l.affectedProjects,l.transitiveImpact,l.verificationPlan];JSON.stringify(W)!==JSON.stringify(A)&&u.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&d(k)!==r.diff.toHash&&u.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$2=r.diff.git;if(i&&d$2?.available){let l=a(t,{ref:d$2.ref}),W=r.diff.changes.filter(h=>h.type.startsWith("git.")).map(h=>`${h.type}:${h.target.replace(/^git:/,"")}`).sort(),A=[...l.changedFiles.map(h=>`git.file.changed:${h}`),...l.untrackedFiles.map(h=>`git.untracked:${h}`),...l.deletedFiles.map(h=>`git.deleted:${h}`)].sort();(!l.available||l.commit!==d$2.commit||JSON.stringify(A)!==JSON.stringify(W))&&u.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let g=Te(r,i),c$1=Ee([...o(),...r.verificationPlan]).filter(l=>Se(e.scope,l)),n=[];for(let l of c$1)n.push(await _e(l,t,o$1.contracts.exists===true,g));let a$2=He(r,n),f=a$1(l(o$1)??{nodes:[],edges:[]}),y=b(o$1),P=await Ke(t),b$2=c(y,P?.freshness?.projectHashes),I={verdict:b$2.verdict,baseline:b$2.baseline,changed:b$2.changed,added:b$2.added,removed:b$2.removed,projectHashes:d$1(y)},E=b$1(f),V=o$1.policies?.mode??"warn",p$2=await Le(o$1,t),B=qe(V,p$2),S=Ne(n,{blockingReasons:[...a$2.blockingReasons,...E,...B.blockingReasons,...u],needsAttention:a$2.needsAttention||B.needsAttention}),he=n.filter(l=>l.status==="missing"&&l.evidencePath).map(l=>l.evidencePath),_=[...n.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),...a$2.blockingReasons,...E,...B.blockingReasons,...u],ve=p$2.filter(l=>l.severity==="error").length,be=o$1.summary?.projectCount??o$1.projects.length,U=ge({projectCount:be,verdict:S.verdict,exitCode:S.exitCode,blockingReasons:_,policyErrorCount:ve});S.verdict=U.verdict,S.exitCode=U.exitCode;let Y=Array.from(new Set(_.map(l=>l.trim()).filter(Boolean))).slice(0,12).map((l,W)=>{let A=n.find(h=>l.startsWith(`${h.id}:`));return me({reason:l,blockerId:`blocker-${W+1}`,sourceCommand:A?.command.display,sourceArtifact:A?.evidencePath,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:G})});return {schemaVersion:ye,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:S,steps:n,missingEvidence:he,blockingReasons:_,...Y.length>0?{resolutionHints:Y}:{},verificationPlan:c$1,affectedSubgraph:a$2.subgraph,graphIntegrity:f,freshness:I,policyMode:V,policyViolations:p$2}}async function Le(e$1,t){let r=[];for(let i of e$1.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await d$2(t,e.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let o of i.violations)typeof o=="string"&&o.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:o});}}catch{}return r.sort((i,o)=>i.source!==o.source?i.source.localeCompare(o.source):i.code!==o.code?i.code.localeCompare(o.code):i.message.localeCompare(o.message))}function qe(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function Ke(e){let t=m.join(e,G);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ye?r:null}catch{return null}}async function wt(e,t){return e$1(t,G,a$2(e))}function ze(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function Rt(e,t){return ze(e,t).exitCode}export{fe as a,tt as b,ye as c,G as d,He as e,bt as f,wt as g,ze as h,Rt as i};
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-A5FBGRJA.js';import {d as d$1,m}from'./chunk-DOIZANFA.js';import {d,e}from'./chunk-ADL3CK44.js';import {i,h}from'./chunk-5EPPPMAS.js';import {s}from'./chunk-MOSXTVPU.js';import {s as s$1,q}from'./chunk-RJIYCDVC.js';import a from'path';import {existsSync}from'fs';import m$1 from'fs-extra';var f=i.workspaceRegistry,w=h.workspaceRegistry.schemaVersion;function E(r){return {slug:r.slug,relativePath:r.relativePath,framework:r.framework,kit:r.kit,source:r.source}}async function b(r){let e=s(r,"workspace.json").find(t=>existsSync(t));if(!e)return {exists:false,legacyProjectCount:0};try{let t=await m$1.readJson(e),c=Array.isArray(t.projects)?t.projects.length:0,o=typeof t.workspace_name=="string"&&t.workspace_name.trim()||typeof t.name=="string"&&t.name.trim()||a.basename(r);return {exists:true,manifestPath:e,workspaceName:o,profile:typeof t.profile=="string"?t.profile:void 0,legacyProjectCount:c}}catch{return {exists:true,manifestPath:e,legacyProjectCount:0,workspaceName:a.basename(r)}}}async function _(r){let e=a$1(r);for(let t of s$1())if(await m$1.pathExists(t))try{let o=((await m$1.readJson(t)).workspaces||[]).find(s=>a$1(s.path)===e);if(o)return {exists:true,projectCount:Array.isArray(o.projects)?o.projects.length:0,registryPath:t}}catch{continue}return {exists:false,projectCount:0,registryPath:a.join(q(),"workspaces.json")}}async function T(r,e){let t=a.resolve(r),c=await d(t,d$1),o=await b(t),s=await _(t),i=e?.contract!==void 0||!!c,n=[];if(e?.contract)n=e.contract.projects||[];else if(i)try{let{contract:A}=await m({workspacePath:t});n=A.projects||[];}catch{n=[];}let d$2={contract:{exists:i,projectCount:n.length,path:d$1},globalRegistry:{exists:s.exists,projectCount:s.projectCount,path:s.registryPath},legacyWorkspaceJson:{exists:o.exists,projectCount:o.legacyProjectCount,path:o.manifestPath?a.relative(t,o.manifestPath):void 0}},p="none",u=[],y=0;return i?(p="workspace.contract.json",u=n.map(E),y=u.length):s.projectCount>0?(p="global-registry",y=s.projectCount):o.legacyProjectCount>0&&(p="legacy-workspace.json",y=o.legacyProjectCount),{contractExists:i,summary:{schemaVersion:w,kind:"rapidkit.workspace.registry",workspacePath:t,workspaceName:o.workspaceName||a.basename(t),profile:o.profile,projectCount:y,authority:p,contractPath:d$1,projects:u,sources:d$2}}}async function U(r){let e=await d(r,f);if(!e)return null;try{let t=await m$1.readJson(e);return t?.schemaVersion!==w?null:t}catch{return null}}async function D(r,e$1){let t=await M(r,e$1);return await e(r,f,t),t}async function M(r,e){return {...(await T(r,{contract:e?.contract})).summary,generatedAt:(e?.now??new Date).toISOString(),registrySummaryPath:f}}function F(r,e=""){return r.projectCount>0?r.authority==="workspace.contract.json"?`${r.projectCount} project(s) registered in workspace contract${e}.`:r.authority==="global-registry"?`${r.projectCount} project(s) registered in global workspace registry${e}.`:`${r.projectCount} project(s) registered in legacy workspace manifest${e}.`:`Workspace state exists, but no projects are registered yet${e}.`}export{f as a,w as b,T as c,U as d,D as e,M as f,F as g};
1
+ import {a as a$1}from'./chunk-A5FBGRJA.js';import {d as d$1,m}from'./chunk-SNO3WG4V.js';import {d,e}from'./chunk-ADL3CK44.js';import {i,h}from'./chunk-5EPPPMAS.js';import {s}from'./chunk-MOSXTVPU.js';import {s as s$1,q}from'./chunk-RJIYCDVC.js';import a from'path';import {existsSync}from'fs';import m$1 from'fs-extra';var f=i.workspaceRegistry,w=h.workspaceRegistry.schemaVersion;function E(r){return {slug:r.slug,relativePath:r.relativePath,framework:r.framework,kit:r.kit,source:r.source}}async function b(r){let e=s(r,"workspace.json").find(t=>existsSync(t));if(!e)return {exists:false,legacyProjectCount:0};try{let t=await m$1.readJson(e),c=Array.isArray(t.projects)?t.projects.length:0,o=typeof t.workspace_name=="string"&&t.workspace_name.trim()||typeof t.name=="string"&&t.name.trim()||a.basename(r);return {exists:true,manifestPath:e,workspaceName:o,profile:typeof t.profile=="string"?t.profile:void 0,legacyProjectCount:c}}catch{return {exists:true,manifestPath:e,legacyProjectCount:0,workspaceName:a.basename(r)}}}async function _(r){let e=a$1(r);for(let t of s$1())if(await m$1.pathExists(t))try{let o=((await m$1.readJson(t)).workspaces||[]).find(s=>a$1(s.path)===e);if(o)return {exists:true,projectCount:Array.isArray(o.projects)?o.projects.length:0,registryPath:t}}catch{continue}return {exists:false,projectCount:0,registryPath:a.join(q(),"workspaces.json")}}async function T(r,e){let t=a.resolve(r),c=await d(t,d$1),o=await b(t),s=await _(t),i=e?.contract!==void 0||!!c,n=[];if(e?.contract)n=e.contract.projects||[];else if(i)try{let{contract:A}=await m({workspacePath:t});n=A.projects||[];}catch{n=[];}let d$2={contract:{exists:i,projectCount:n.length,path:d$1},globalRegistry:{exists:s.exists,projectCount:s.projectCount,path:s.registryPath},legacyWorkspaceJson:{exists:o.exists,projectCount:o.legacyProjectCount,path:o.manifestPath?a.relative(t,o.manifestPath):void 0}},p="none",u=[],y=0;return i?(p="workspace.contract.json",u=n.map(E),y=u.length):s.projectCount>0?(p="global-registry",y=s.projectCount):o.legacyProjectCount>0&&(p="legacy-workspace.json",y=o.legacyProjectCount),{contractExists:i,summary:{schemaVersion:w,kind:"rapidkit.workspace.registry",workspacePath:t,workspaceName:o.workspaceName||a.basename(t),profile:o.profile,projectCount:y,authority:p,contractPath:d$1,projects:u,sources:d$2}}}async function U(r){let e=await d(r,f);if(!e)return null;try{let t=await m$1.readJson(e);return t?.schemaVersion!==w?null:t}catch{return null}}async function D(r,e$1){let t=await M(r,e$1);return await e(r,f,t),t}async function M(r,e){return {...(await T(r,{contract:e?.contract})).summary,generatedAt:(e?.now??new Date).toISOString(),registrySummaryPath:f}}function F(r,e=""){return r.projectCount>0?r.authority==="workspace.contract.json"?`${r.projectCount} project(s) registered in workspace contract${e}.`:r.authority==="global-registry"?`${r.projectCount} project(s) registered in global workspace registry${e}.`:`${r.projectCount} project(s) registered in legacy workspace manifest${e}.`:`Workspace state exists, but no projects are registered yet${e}.`}export{f as a,w as b,T as c,U as d,D as e,M as f,F as g};
@@ -1,2 +1,2 @@
1
- import {b as b$1}from'./chunk-KVSYBHUR.js';import {i,o}from'./chunk-WJVB6SSD.js';import {c}from'./chunk-DIZSHNZ5.js';import {f,g}from'./chunk-VRW6KXNK.js';import {b}from'./chunk-RO73VVHW.js';import {l,k}from'./chunk-MOSXTVPU.js';import {promises}from'fs';import s from'path';import F,{homedir}from'os';import {pathToFileURL}from'url';import f$1 from'process';import T from'fs-extra';function I(e){let o=e.label.indexOf(" \u2014 ");return o>=0?e.label.slice(o+3).trim():e.label.trim()}function L(){let e=c().map(r=>({value:r.id,label:`${j(r.category)} \xB7 ${I(r)}`,hint:`${r.runtime} \xB7 tested baseline`,name:r.label})),t=i().map(r=>({value:r.kitId,label:`Frontend \xB7 ${r.displayName}`,hint:"official \xB7 latest stable",name:`${r.displayName} \u2014 ${r.framework}`})),o$1=o().map(r=>({value:r.kitId,label:`${j(r.category)} \xB7 ${r.displayName}`,hint:`${r.runtimeCandidates.join(" + ")} \xB7 official latest stable`,name:`${r.displayName} \u2014 ${r.category}`})),n=[...e,...t,...o$1].sort((r,i)=>{let a=["Backend","Frontend","Desktop","Extension"],c=r.label?.split(" \xB7 ")[0]??"",p=i.label?.split(" \xB7 ")[0]??"";return a.indexOf(c)-a.indexOf(p)||(r.label??"").localeCompare(i.label??"")});return E(n),n}function j(e){return e.charAt(0).toUpperCase()+e.slice(1)}function E(e){let t=new Set,o=new Set;for(let n of e){let r=n.label??n.name??String(n.value),i=String(n.value);if(t.has(r))throw new Error(`Duplicate kit picker label: ${r}`);if(o.has(i))throw new Error(`Duplicate kit picker value: ${i}`);t.add(r),o.add(i);}}var U=".workspairc.json",A=".rapidkitrc.json",O=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"],R=["workspai.config.json","rapidkit.config.json"];function $(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function h(e,t){let o=t instanceof Error?t.message:String(t),n=e.endsWith(".js")&&/module is not defined in ES module scope/i.test(o)?' CommonJS syntax in a .js config is not valid when the project package uses "type": "module"; rename the file to .cjs or use export default.':"";return `Failed to load Workspai config at ${e}.${n} Cause: ${o}`}async function We(){for(let e of [s.join(F.homedir(),U),s.join(F.homedir(),A)])try{let t=await promises.readFile(e,"utf-8"),o=JSON.parse(t);return f.debug(`Loaded config from ${e}`),o}catch{}return f.debug("No user config found, using defaults"),{}}async function je(e=process.cwd(),t={}){let o=e,n=s.parse(o).root;for(;o!==n;){for(let r of R){let i=s.join(o,r);try{let a=await promises.readFile(i,"utf-8"),c=JSON.parse(a);if(!c||typeof c!="object"||Array.isArray(c))throw new Error("configuration root must be a JSON object");return f.debug(`Loaded data-only Workspai config from ${r}`),c}catch(a){if($(a))continue;throw new Error(h(i,a))}}for(let r of O){let i=s.join(o,r);try{await promises.access(i);}catch(a){if($(a))continue;throw new Error(h(i,a))}if(f.debug(`Found config file: ${i}`),!t.trustExecutableConfig)throw new Error(`Refusing to execute Workspai config at ${i} without explicit trust. Use a data-only workspai.config.json file, pass --trust-config, or set WORKSPAI_TRUST_CONFIG=1.`);try{let c=await import(pathToFileURL(i).href),p=c.default||c;return f.debug(`Loaded Workspai config from ${r}`),p}catch(a){throw new Error(h(i,a))}}o=s.dirname(o);}return f.debug("No Workspai config file found, using defaults"),{}}function Ee(e,t,o){return {author:o.author||t.workspace?.defaultAuthor||e.author,pythonVersion:o.pythonVersion||t.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:o.defaultInstallMethod||t.workspace?.installMethod||e.defaultInstallMethod,defaultKit:o.defaultKit||t.projects?.defaultKit||e.defaultKit,skipGit:o.skipGit??t.projects?.skipGit??e.skipGit,license:o.license||e.license,testRapidKitPath:o.testRapidKitPath||e.testRapidKitPath}}function Fe(e){return g("DEV_PATH")||e.testRapidKitPath||void 0}var w=class extends Error{constructor(o,n){super(["Workspai workspaces cannot be nested.",`Target: ${o}`,`Containing workspace: ${n}`,"Choose Managed home or pass --output <path> with a location outside the current workspace."].join(`
1
+ import {b as b$1}from'./chunk-KVSYBHUR.js';import {i,o}from'./chunk-WJVB6SSD.js';import {c}from'./chunk-WP3CXMVA.js';import {f,g}from'./chunk-VRW6KXNK.js';import {b}from'./chunk-RO73VVHW.js';import {l,k}from'./chunk-MOSXTVPU.js';import {promises}from'fs';import s from'path';import F,{homedir}from'os';import {pathToFileURL}from'url';import f$1 from'process';import T from'fs-extra';function I(e){let o=e.label.indexOf(" \u2014 ");return o>=0?e.label.slice(o+3).trim():e.label.trim()}function L(){let e=c().map(r=>({value:r.id,label:`${j(r.category)} \xB7 ${I(r)}`,hint:`${r.runtime} \xB7 tested baseline`,name:r.label})),t=i().map(r=>({value:r.kitId,label:`Frontend \xB7 ${r.displayName}`,hint:"official \xB7 latest stable",name:`${r.displayName} \u2014 ${r.framework}`})),o$1=o().map(r=>({value:r.kitId,label:`${j(r.category)} \xB7 ${r.displayName}`,hint:`${r.runtimeCandidates.join(" + ")} \xB7 official latest stable`,name:`${r.displayName} \u2014 ${r.category}`})),n=[...e,...t,...o$1].sort((r,i)=>{let a=["Backend","Frontend","Desktop","Extension"],c=r.label?.split(" \xB7 ")[0]??"",p=i.label?.split(" \xB7 ")[0]??"";return a.indexOf(c)-a.indexOf(p)||(r.label??"").localeCompare(i.label??"")});return E(n),n}function j(e){return e.charAt(0).toUpperCase()+e.slice(1)}function E(e){let t=new Set,o=new Set;for(let n of e){let r=n.label??n.name??String(n.value),i=String(n.value);if(t.has(r))throw new Error(`Duplicate kit picker label: ${r}`);if(o.has(i))throw new Error(`Duplicate kit picker value: ${i}`);t.add(r),o.add(i);}}var U=".workspairc.json",A=".rapidkitrc.json",O=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"],R=["workspai.config.json","rapidkit.config.json"];function $(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function h(e,t){let o=t instanceof Error?t.message:String(t),n=e.endsWith(".js")&&/module is not defined in ES module scope/i.test(o)?' CommonJS syntax in a .js config is not valid when the project package uses "type": "module"; rename the file to .cjs or use export default.':"";return `Failed to load Workspai config at ${e}.${n} Cause: ${o}`}async function We(){for(let e of [s.join(F.homedir(),U),s.join(F.homedir(),A)])try{let t=await promises.readFile(e,"utf-8"),o=JSON.parse(t);return f.debug(`Loaded config from ${e}`),o}catch{}return f.debug("No user config found, using defaults"),{}}async function je(e=process.cwd(),t={}){let o=e,n=s.parse(o).root;for(;o!==n;){for(let r of R){let i=s.join(o,r);try{let a=await promises.readFile(i,"utf-8"),c=JSON.parse(a);if(!c||typeof c!="object"||Array.isArray(c))throw new Error("configuration root must be a JSON object");return f.debug(`Loaded data-only Workspai config from ${r}`),c}catch(a){if($(a))continue;throw new Error(h(i,a))}}for(let r of O){let i=s.join(o,r);try{await promises.access(i);}catch(a){if($(a))continue;throw new Error(h(i,a))}if(f.debug(`Found config file: ${i}`),!t.trustExecutableConfig)throw new Error(`Refusing to execute Workspai config at ${i} without explicit trust. Use a data-only workspai.config.json file, pass --trust-config, or set WORKSPAI_TRUST_CONFIG=1.`);try{let c=await import(pathToFileURL(i).href),p=c.default||c;return f.debug(`Loaded Workspai config from ${r}`),p}catch(a){throw new Error(h(i,a))}}o=s.dirname(o);}return f.debug("No Workspai config file found, using defaults"),{}}function Ee(e,t,o){return {author:o.author||t.workspace?.defaultAuthor||e.author,pythonVersion:o.pythonVersion||t.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:o.defaultInstallMethod||t.workspace?.installMethod||e.defaultInstallMethod,defaultKit:o.defaultKit||t.projects?.defaultKit||e.defaultKit,skipGit:o.skipGit??t.projects?.skipGit??e.skipGit,license:o.license||e.license,testRapidKitPath:o.testRapidKitPath||e.testRapidKitPath}}function Fe(e){return g("DEV_PATH")||e.testRapidKitPath||void 0}var w=class extends Error{constructor(o,n){super(["Workspai workspaces cannot be nested.",`Target: ${o}`,`Containing workspace: ${n}`,"Choose Managed home or pass --output <path> with a location outside the current workspace."].join(`
2
2
  `));this.targetPath=o;this.containingWorkspacePath=n;this.name="NestedWorkspaceCreationError";}targetPath;containingWorkspacePath;code="WORKSPACE_NESTING_NOT_SUPPORTED"};async function _(e){try{return !!await T.stat(e)}catch{return false}}function G(e,t){let o=e.indexOf(t);if(o>=0&&o+1<e.length)return e[o+1];let n=e.find(r=>r.startsWith(`${t}=`));if(n)return n.slice(t.length+1)}function M(e){return e.includes("--here")}async function N(e){let t=s.resolve(e);for(;;){let o=[s.join(t,".workspai-workspace"),s.join(t,".rapidkit-workspace"),s.join(t,".workspai","workspace.json"),s.join(t,".rapidkit","workspace.json")];if((await Promise.all(o.map(_))).some(Boolean))return t;let n=s.dirname(t);if(n===t)return;t=n;}}async function Oe(e){let t=s.resolve(e),o=await N(s.dirname(t));if(o)throw new w(t,o)}async function V(e,t=homedir()){let n=[{value:"managed",label:"Managed home",hint:k(t)}];return await N(e)||n.push({value:"here",label:"Current directory",hint:e}),n}function S(e,t=f$1.cwd()){if(M(e))return s.resolve(t);let o=G(e,"--output");if(o)return s.resolve(o)}function Re(e,t=f$1.cwd()){let o=s.resolve(e),n=s.resolve(t),r=s.relative(n,o);return r.length>0&&!r.startsWith("..")&&!s.isAbsolute(r)?`cd ${r}`:`cd ${o}`}function Te(e,t={}){let o=t.argv??[],n=t.outputParent??S(o,f$1.cwd());return l(e.trim(),{homeDir:t.homeDir,outputDir:n})}function _e(e,t,o={}){return e?s.resolve(e)===s.resolve(t)?true:o.outputParent===void 0:false}async function Ge(e,t={}){let o=t.cwd??f$1.cwd(),n=t.homeDir??homedir(),r=S(e,o);if(r!==void 0)return r;let i=t.hasYes??(e.includes("--yes")||e.includes("-y"));if(!(t.interactive??(!i&&!!f$1.stdin.isTTY&&!b())))return;let c=await V(o,n);if(c.length===1)return;let{location:p}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:c,default:0}]);if(p==="here")return s.resolve(o)}export{L as a,We as b,je as c,Ee as d,Fe as e,Oe as f,Re as g,Te as h,_e as i,Ge as j};
@@ -1 +1 @@
1
- import {f}from'./chunk-VGJVIHHR.js';import s from'path';import p from'fs-extra';var b=4,w="workspace-graph-token-efficiency.v1";function k(e){return Math.ceil(e/b)}function y(e,t){let r=s.resolve(e,t),o=s.relative(e,r);return !o||o.startsWith("..")||s.isAbsolute(o)?null:r}async function C(e){let t=new Map,r=[s.join(e,".workspai","workspace.contract.json"),s.join(e,".rapidkit","workspace.contract.json")];for(let o of r)if(await p.pathExists(o))try{let a=await p.readJson(o);for(let n of a.projects??[])typeof n.relativePath=="string"&&typeof n.externalPath=="string"&&s.isAbsolute(n.externalPath)&&t.set(n.relativePath.replace(/\\/g,"/").replace(/\/$/,""),n.externalPath);break}catch{}return t}function P(e,t,r){if(!t||s.isAbsolute(t))return null;let o=s.resolve(e),a=t.replace(/\\/g,"/");for(let[n,i]of [...r.entries()].sort(([u],[h])=>h.length-u.length))if(a.startsWith(`${n}/`))return y(i,a.slice(n.length+1));return y(o,a)}async function S(e){let t=s.resolve(e.workspacePath),r=f(e.graph,{query:e.query,...e.kind?{kind:e.kind}:{},...e.projectId?{projectId:e.projectId}:{},limit:e.limit,projection:"agent"}),o=[...new Set(e.graph.proofs.map(l=>l.artifact))].sort(),a=[],n=await C(t),i=0,u=0;for(let l of o){let f=P(t,l,n);if(!f){a.push(l);continue}try{let v=await p.readFile(f,"utf8");i+=v.length,u+=1;}catch{a.push(l);}}let h=JSON.stringify(r).length,c=k(i),d=k(h),g=Math.max(0,c-d);return {schemaVersion:w,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,query:e.query,graph:{schemaVersion:e.graph.schemaVersion,sourceArtifact:e.graph.source.artifact,sourceHash:e.graph.source.hash,entityCount:e.graph.entities.length,relationCount:e.graph.relations.length,proofCount:e.graph.proofs.length},methodology:{id:"indexed-corpus-vs-bounded-retrieval.v1",estimated:true,charsPerToken:b,claimBoundary:"Measures retrieval payload reduction against readable proof-source text; it does not claim equivalent answer quality or model-specific billing savings."},corpus:{artifactCount:u,characterCount:i,estimatedTokens:c,unreadableArtifacts:a},retrieval:{matchCount:r.entities.length,characterCount:h,estimatedTokens:d,truncated:r.truncated,payload:r},savings:{estimatedTokensAvoided:g,reductionRatio:d===0?0:Number((c/d).toFixed(2)),reductionPercent:c===0?0:Number((g/c*100).toFixed(2))}}}export{w as a,S as b};
1
+ import {f}from'./chunk-CNWUIXF3.js';import s from'path';import p from'fs-extra';var b=4,w="workspace-graph-token-efficiency.v1";function k(e){return Math.ceil(e/b)}function y(e,t){let r=s.resolve(e,t),o=s.relative(e,r);return !o||o.startsWith("..")||s.isAbsolute(o)?null:r}async function C(e){let t=new Map,r=[s.join(e,".workspai","workspace.contract.json"),s.join(e,".rapidkit","workspace.contract.json")];for(let o of r)if(await p.pathExists(o))try{let a=await p.readJson(o);for(let n of a.projects??[])typeof n.relativePath=="string"&&typeof n.externalPath=="string"&&s.isAbsolute(n.externalPath)&&t.set(n.relativePath.replace(/\\/g,"/").replace(/\/$/,""),n.externalPath);break}catch{}return t}function P(e,t,r){if(!t||s.isAbsolute(t))return null;let o=s.resolve(e),a=t.replace(/\\/g,"/");for(let[n,i]of [...r.entries()].sort(([u],[h])=>h.length-u.length))if(a.startsWith(`${n}/`))return y(i,a.slice(n.length+1));return y(o,a)}async function S(e){let t=s.resolve(e.workspacePath),r=f(e.graph,{query:e.query,...e.kind?{kind:e.kind}:{},...e.projectId?{projectId:e.projectId}:{},limit:e.limit,projection:"agent"}),o=[...new Set(e.graph.proofs.map(l=>l.artifact))].sort(),a=[],n=await C(t),i=0,u=0;for(let l of o){let f=P(t,l,n);if(!f){a.push(l);continue}try{let v=await p.readFile(f,"utf8");i+=v.length,u+=1;}catch{a.push(l);}}let h=JSON.stringify(r).length,c=k(i),d=k(h),g=Math.max(0,c-d);return {schemaVersion:w,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,query:e.query,graph:{schemaVersion:e.graph.schemaVersion,sourceArtifact:e.graph.source.artifact,sourceHash:e.graph.source.hash,entityCount:e.graph.entities.length,relationCount:e.graph.relations.length,proofCount:e.graph.proofs.length},methodology:{id:"indexed-corpus-vs-bounded-retrieval.v1",estimated:true,charsPerToken:b,claimBoundary:"Measures retrieval payload reduction against readable proof-source text; it does not claim equivalent answer quality or model-specific billing savings."},corpus:{artifactCount:u,characterCount:i,estimatedTokens:c,unreadableArtifacts:a},retrieval:{matchCount:r.entities.length,characterCount:h,estimatedTokens:d,truncated:r.truncated,payload:r},savings:{estimatedTokensAvoided:g,reductionRatio:d===0?0:Number((c/d).toFixed(2)),reductionPercent:c===0?0:Number((g/c*100).toFixed(2))}}}export{w as a,S as b};
@@ -0,0 +1 @@
1
+ var X="workspace-knowledge-search.v1";function b(e){return e.trim().toLowerCase()}var z=new WeakMap;function A(e){let t=z.get(e);if(t)return t;let o=new Map(e.relations.map(s=>[s.id,s])),a=new Map(e.entities.map(s=>[s.id,s])),l=new Map(e.proofs.map(s=>[s.id,s])),r=new Map,d=new Map,f=(s,p)=>{let g=d.get(s)??[];g.push(p),d.set(s,g);};for(let s of e.entities){let p=[s.id,s.label,s.identity.key,...s.kind==="project"&&s.projectId?[s.projectId]:[],...s.identity.aliases];for(let g of new Set(p.map(b))){let m=r.get(g)??[];m.push(s),r.set(g,m);}}for(let s of e.relations)f(s.from,{from:s.from,to:s.to,relationId:s.id,kind:s.kind,direction:"forward",proofIds:s.proofIds}),f(s.to,{from:s.to,to:s.from,relationId:s.id,kind:s.kind,direction:"reverse",proofIds:s.proofIds});for(let s of r.values())s.sort((p,g)=>p.id.localeCompare(g.id));for(let s of d.values())s.sort((p,g)=>p.to.localeCompare(g.to)||p.relationId.localeCompare(g.relationId));let c={entitiesById:a,relationsById:o,entitiesByAlias:r,proofsById:l,adjacency:d};return z.set(e,c),c}function _(e,t){let o=A(e),a=o.relationsById.get(t);if(a)return {found:true,targetType:"relation",relation:a};let l=b(t),r=o.entitiesByAlias.get(l)??[];return r.length===1?{found:true,targetType:"entity",entity:r[0]}:{found:false,query:t,candidates:r.map(d=>d.id).sort()}}function fe(e,t){let o=_(e,t);if(!o.found)return {query:t,found:false,target:null,proofs:[],candidates:o.candidates};let a=o.targetType==="entity"?o.entity:o.relation,l=new Set(a.proofIds);return {query:t,found:true,target:a,candidates:[],proofs:[...l].map(r=>A(e).proofsById.get(r)).filter(r=>!!r).sort((r,d)=>r.id.localeCompare(d.id))}}function ue(e,t,o){let a=_(e,t),l=_(e,o);if(!a.found||a.targetType!=="entity"||!l.found||l.targetType!=="entity")return {from:t,to:o,found:false,resolvedFrom:a.found&&a.targetType==="entity"?a.entity.id:null,resolvedTo:l.found&&l.targetType==="entity"?l.entity.id:null,entityPath:[],hops:[],proofs:[]};let r=A(e),d=[a.entity.id],f=new Map,c=new Set(d),s=0;for(;s<d.length&&!c.has(l.entity.id);){let h=d[s++];for(let w of r.adjacency.get(h)??[])c.has(w.to)||(c.add(w.to),f.set(w.to,w),d.push(w.to));}if(!c.has(l.entity.id))return {from:t,to:o,found:false,resolvedFrom:a.entity.id,resolvedTo:l.entity.id,entityPath:[],hops:[],proofs:[]};let p=[],g=l.entity.id;for(;g!==a.entity.id;){let h=f.get(g);if(!h)break;p.push(h),g=h.from;}p.reverse();let m=new Set(p.flatMap(h=>h.proofIds));return {from:t,to:o,found:true,resolvedFrom:a.entity.id,resolvedTo:l.entity.id,entityPath:[a.entity.id,...p.map(h=>h.to)],hops:p,proofs:[...m].map(h=>r.proofsById.get(h)).filter(h=>!!h).sort((h,w)=>h.id.localeCompare(w.id))}}function ke(e,t){return e.entities.filter(o=>!t||o.kind===t).sort((o,a)=>o.kind.localeCompare(a.kind)||o.label.localeCompare(a.label))}var y={relations:24,relatedEntities:24,proofs:16,proofIdsPerItem:4,aliasesPerEntity:8,attributeArrayItems:8,attributeStringCharacters:256};function Z(e){let t=[],o=new Set;for(let a=0;a<y.proofIdsPerItem&&t.length<y.proofs;a+=1)for(let l of e){let r=l.proofIds[a];if(!(!r||o.has(r))&&(o.add(r),t.push(r),t.length>=y.proofs))break}return t}function J(e,t,o){let a=e.identity.aliases.slice(0,y.aliasesPerEntity);o.aliases+=e.identity.aliases.length-a.length;let l=Object.fromEntries(Object.entries(e.attributes).map(([d,f])=>{if(Array.isArray(f)){let c=f.slice(0,y.attributeArrayItems);return o.attributeValues+=f.length-c.length,[d,c]}return typeof f=="string"&&f.length>y.attributeStringCharacters?(o.attributeValues+=1,[d,f.slice(0,y.attributeStringCharacters)]):[d,f]})),r=e.proofIds.filter(d=>t.has(d)).slice(0,y.proofIdsPerItem);return o.proofReferences+=e.proofIds.length-r.length,{...e,identity:{...e.identity,aliases:a},attributes:l,proofIds:r}}function ee(e){let t=Object.values(e.attributes).flatMap(o=>Array.isArray(o)?o:[o]);return [e.id,e.kind,e.label,e.projectId??"",e.identity.key,...e.identity.aliases,...t.map(o=>String(o??""))].join(" ").toLowerCase()}var te=new Set(["a","an","and","are","as","at","be","been","being","by","can","check","could","did","do","does","find","for","from","give","had","has","have","how","i","in","into","is","it","its","may","might","of","on","or","our","show","should","that","the","their","them","then","there","these","they","this","those","tell","to","was","we","were","what","when","where","which","who","why","will","with","would","you","your"]);function j(e){let t=o=>b(o).split(/[^a-z0-9]+/u).filter(a=>a.length>1);return [...new Set([...t(e),...t(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"))])]}function ne(e){let t=b(e.label),o=b(e.identity.key),a=e.identity.aliases.map(b),l=ee(e);return {entity:e,label:t,identity:o,aliases:a,haystack:l,labelTokens:new Set(j(e.label)),identityTokens:new Set(j(e.identity.key)),aliasTokens:new Set(e.identity.aliases.flatMap(j)),allTokens:new Set(j(l))}}function S(e,t){return e.has(t)||t.length>=3&&[...e].some(o=>o.startsWith(t))}function O(e,t){return S(e.labelTokens,t)||S(e.identityTokens,t)||S(e.aliasTokens,t)||S(e.allTokens,t)}function oe(e,t,o,a){let{label:l,identity:r,aliases:d,haystack:f}=e,c=0;(l===t||r===t||d.includes(t))&&(c+=1e4),(l.startsWith(t)||r.startsWith(t))&&(c+=250),f.includes(t)&&(c+=100);let s=0;for(let p of o){let g=a.get(p)??1,m=S(e.labelTokens,p),h=S(e.identityTokens,p),w=S(e.aliasTokens,p),u=O(e,p);u&&(s+=1),l===p?c+=80*g:m&&(c+=36*g),h&&(c+=24*g),w&&(c+=20*g),u&&(c+=10*g);}return o.length>0&&(c+=s/o.length*120),c}function se(e,t){return t.filter(o=>O(e,o)).length}var ae=new Map([["clojure","clojure"],["cplusplus","cpp"],["cpp","cpp"],["typescript","typescript"],["ts","typescript"],["javascript","javascript"],["js","javascript"],["nodejs","javascript"],["python","python"],["py","python"],["go","go"],["golang","go"],["csharp","csharp"],["dotnet","csharp"],["dart","dart"],["elixir","elixir"],["fsharp","fsharp"],["java","java"],["kotlin","kotlin"],["lua","lua"],["php","php"],["ruby","ruby"],["rust","rust"],["scala","scala"],["svelte","svelte"],["swift","swift"],["vue","vue"]]);function re(e){return new Set(e.map(t=>ae.get(t)).filter(t=>!!t))}function F(e){let t=e.attributes.language;return typeof t=="string"?b(t):null}function ie(e){return {project:1e3,service:900,api:900,package:850,endpoint:800,container:700,deployment:700,environment:650,pipeline:600,"test-suite":550,owner:500,decision:450,document:400}[e.kind]??0}function ce(e,t){let o=t.has("language")||t.has("languages"),a=t.has("binding")||t.has("bindings")||t.has("bridge")||t.has("bridges"),l=t.has("dependency")||t.has("dependencies")||t.has("depends"),r=t.has("core")||t.has("runtime"),d=t.has("owner")||t.has("owners")||t.has("ownership")||t.has("maintainer"),f=t.has("ci")||t.has("pipeline")||t.has("pipelines")||t.has("workflow"),c=t.has("deploy")||t.has("deployment")||t.has("infrastructure")||t.has("container"),s=t.has("doc")||t.has("docs")||t.has("document")||t.has("documentation"),p=t.has("service")||t.has("services")||t.has("api")||t.has("rpc"),g=t.has("schema")||t.has("schemas")||t.has("message")||t.has("protobuf")||t.has("proto")||t.has("contract"),m=typeof e.attributes.mechanism=="string"?b(e.attributes.mechanism):"",h=typeof e.attributes.specification=="string"?b(e.attributes.specification):"",w=b(e.label),u=0;if(o&&e.kind==="language"){let P=typeof e.attributes.fileCount=="number"?e.attributes.fileCount:0;u+=900+Math.min(P,1e4)/10;}return a&&e.kind==="protocol"&&(u+=800),l&&e.kind==="package"&&(u+=650),r&&e.kind==="package"&&/(?:^|[_-])core(?:$|[_-])/u.test(w)&&(u+=700),r&&e.kind==="protocol"&&m.includes("core")&&(u+=300),d&&e.kind==="owner"&&(u+=850),f&&e.kind==="pipeline"&&(u+=800),c&&["deployment","container","environment"].includes(e.kind)&&(u+=775),s&&["document","decision"].includes(e.kind)&&(u+=725),p&&["api","endpoint","service"].includes(e.kind)&&(u+=700),g&&(e.kind==="schema"||(e.kind==="api"||e.kind==="protocol")&&(h.includes("protobuf")||m.includes("protobuf")))&&(u+=750),u}function le(e){return [e.has("language")||e.has("languages"),e.has("binding")||e.has("bindings")||e.has("bridge")||e.has("bridges"),e.has("dependency")||e.has("dependencies")||e.has("depends"),e.has("core")||e.has("runtime"),e.has("owner")||e.has("ownership")||e.has("maintainer"),e.has("ci")||e.has("pipeline")||e.has("workflow"),e.has("deploy")||e.has("deployment")||e.has("infrastructure"),e.has("doc")||e.has("docs")||e.has("documentation"),e.has("service")||e.has("api")||e.has("rpc"),e.has("schema")||e.has("protobuf")||e.has("proto")||e.has("contract")].filter(Boolean).length>=3}function we(e,t){let o=b(t.query),a=[...new Set(j(t.query))],l=new Set(j(t.projectId??"")),r=t.projectId?a.filter(n=>!l.has(n)):a,d=!!(t.projectId&&a.length>0&&r.length===0),f=r.filter(n=>!te.has(n)),c=f.length>0?f:r,s=re(c),p=new Set(c),g=le(p),m=c.length<=1?c.length:Math.min(3,Math.ceil(c.length/3)),h=Math.max(1,Math.min(Math.trunc(t.limit??12),100)),w=Math.max(0,Math.min(Math.trunc(t.relationsPerEntity??4),20)),u=new Set;if(t.projectId){let n=new Set(e.entities.filter(i=>i.kind==="project"&&(i.projectId===t.projectId||i.label===t.projectId)).map(i=>i.id));for(let i of e.relations)n.has(i.from)&&u.add(i.to),n.has(i.to)&&u.add(i.from);}let P=e.entities.filter(n=>(!t.kind||n.kind===t.kind)&&(!t.projectId||n.projectId===t.projectId||n.projectId===void 0&&u.has(n.id))).map(ne),U=new Map(c.map(n=>{let i=P.filter(k=>O(k,n)).length;return [n,Math.log((P.length+1)/(i+1))+1]})),M=P.map(n=>{let i=se(n,c),k=F(n.entity),I=k&&s.has(k)?400:0,K=ce(n.entity,p);return {entity:n.entity,matchedTerms:i,intentScore:K,score:d?ie(n.entity):oe(n,o,c,U)+I+K}}).filter(n=>{let i=F(n.entity);return (s.size===0||i===null||s.has(i))&&(o.length===0||n.score>0&&(d||n.matchedTerms>=m||n.intentScore>0&&(g||c.length<=2)))}).sort((n,i)=>i.score-n.score||n.entity.kind.localeCompare(i.entity.kind)||n.entity.label.localeCompare(i.entity.label)),E=(g?(()=>{let n=[],i=[],k=new Map,I=new Set;for(let K of M){let q=k.get(K.entity.kind)??0,V=b(K.entity.label);q<2&&!I.has(V)?(n.push(K),k.set(K.entity.kind,q+1),I.add(V)):i.push(K);}return [...n,...i]})():M).slice(0,h).map(n=>n.entity),v=new Set(E.map(n=>n.id)),G=new Map,x=e.relations.filter(n=>{if(!(v.has(n.from)||v.has(n.to)))return false;let k=v.has(n.from)?n.from:n.to,I=G.get(k)??0;return I>=w?false:(G.set(k,I+1),true)}),W=t.projection==="agent",T=W?x.slice(0,y.relations):x,D=A(e),B=[...new Set(T.flatMap(n=>[n.from,n.to]).filter(n=>!v.has(n)))].map(n=>D.entitiesById.get(n)).filter(n=>!!n).map(({id:n,kind:i,label:k,projectId:I})=>({id:n,kind:i,label:k,...I?{projectId:I}:{}})).sort((n,i)=>n.kind.localeCompare(i.kind)||n.label.localeCompare(i.label)),H=W?B.slice(0,y.relatedEntities):B,L=new Set([...E.flatMap(n=>n.proofIds),...T.flatMap(n=>n.proofIds)]),Q=W?Z([...E,...T]):[...L],C=new Set(Q),R={entities:M.length-E.length,relations:x.length-T.length,relatedEntities:B.length-H.length,proofs:L.size-C.size,proofReferences:0,aliases:0,attributeValues:0},N=W?E.map(n=>J(n,C,R)):E,$=W?T.map(n=>{let i=n.proofIds.filter(k=>C.has(k)).slice(0,y.proofIdsPerItem);return R.proofReferences+=n.proofIds.length-i.length,{...n,proofIds:i}}):T,Y=[...C].map(n=>D.proofsById.get(n)).filter(n=>!!n).sort((n,i)=>n.id.localeCompare(i.id));return {schemaVersion:X,query:t.query,kind:t.kind??null,...t.projectId?{projectId:t.projectId}:{},limit:h,totalMatches:M.length,truncated:M.length>N.length||W&&Object.values(R).some(n=>n>0),entities:N,relatedEntities:H,relations:$,proofs:Y,...W?{budget:{mode:"agent",limits:{...y},omitted:R}}:{}}}export{X as a,_ as b,fe as c,ue as d,ke as e,we as f};
@@ -1,4 +1,4 @@
1
- import {a as a$1}from'./chunk-WLCBXCZV.js';import {a as a$4}from'./chunk-W5ZFXKSL.js';import {a as a$2,e as e$1}from'./chunk-IZLEMTES.js';import {d,a,e as e$2}from'./chunk-ADL3CK44.js';import {e,h}from'./chunk-5EPPPMAS.js';import a$3 from'chalk';import re from'fs';import b from'path';import {execa}from'execa';var V="autopilot-release-last-run.json",G="autopilot-release.json";function $(r){try{return JSON.parse(r)}catch{return null}}function Se(r){let e=b.resolve(r),n=a$4(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function oe(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function ae(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function be(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function Ae(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await re.promises.mkdir(b.dirname(r),{recursive:true}),await re.promises.writeFile(r,`${JSON.stringify(e,null,2)}
1
+ import {a as a$1}from'./chunk-GTJY55QK.js';import {a as a$4}from'./chunk-W5ZFXKSL.js';import {a as a$2,e as e$1}from'./chunk-IZLEMTES.js';import {d,a,e as e$2}from'./chunk-ADL3CK44.js';import {e,h}from'./chunk-5EPPPMAS.js';import a$3 from'chalk';import re from'fs';import b from'path';import {execa}from'execa';var V="autopilot-release-last-run.json",G="autopilot-release.json";function $(r){try{return JSON.parse(r)}catch{return null}}function Se(r){let e=b.resolve(r),n=a$4(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function oe(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function ae(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function be(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function Ae(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await re.promises.mkdir(b.dirname(r),{recursive:true}),await re.promises.writeFile(r,`${JSON.stringify(e,null,2)}
2
2
  `,"utf-8");}async function ze(r){let e$3=Se(r.workspacePath),n=r.mode,o=[],t=[],L,H,N,q,Q,X=0,f=false,I=0,_=0,W=-1,T=-1,c="skipped",d$1="skipped",ne=n==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(r.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let s=Date.now(),l=await S([...ne],e$3),m=Date.now()-s;if(c="pass",l.crashed)c="fail",f=true,t.push(`doctor workspace execution error: ${l.stderr||"unknown error"}`);else if(l.exitCode===1)c="fail",t.push("doctor workspace command failed or reported errors");else if(l.exitCode===2)c="warn",t.push("doctor workspace reported warnings");else if(l.exitCode!==0)c="fail",t.push("doctor workspace command failed");else {let p=$(l.stdout),E=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},k=Number(E.errors??0),C=Number(E.warnings??0);Number.isFinite(k)&&k>0?(c="fail",t.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite(C)&&C>0&&(c="warn");}W=o.push({name:"doctor-workspace",status:c,durationMs:m,summary:c==="pass"?"doctor workspace passed":c==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,n==="enforce"&&c==="warn"&&t.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await S(["analyze","--json"],e$3),P=Date.now()-g;H=await d(e$3,e.analyze)??a(e$3,e.analyze);let i="pass";if(w.crashed)i="fail",f=true,t.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)i=w.exitCode===2?"warn":"fail",t.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let p=$(w.stdout),E=p&&p.summary&&typeof p.summary=="object"?p.summary:{},k=String(E.verdict??"ready");k==="blocked"?(i="fail",t.push("analyze reported blocked verdict")):k==="needs-attention"&&(i="warn");}o.push({name:"analyze",status:i,durationMs:P,summary:i==="pass"?"analyze passed":i==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),n==="enforce"&&i==="warn"&&t.push("analyze reported warnings under enforce mode");let v=Date.now(),h=await S(["readiness","--json"],e$3),y=Date.now()-v;if(d$1="fail",h.crashed)d$1="fail",f=true,t.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)d$1="fail",t.push("readiness command failed");else {let p=$(h.stdout),E=String(p?.overallStatus??"fail");if(d$1=oe(E),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(L=p.evidencePath),d$1==="fail"){let k=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter(C=>typeof C=="string"):[];k.length>0?t.push(...k.map(C=>`readiness: ${C}`)):t.push("readiness overall status is fail");}}T=o.push({name:"readiness",status:d$1,durationMs:y,summary:`readiness overall status is ${d$1}`})-1,n==="enforce"&&d$1==="warn"&&t.push("readiness reported warnings under enforce mode");}let ie=Date.now(),D=await S(["doctor","workspace","--plan","--json"],e$3),le=Date.now()-ie,R="warn";if(D.crashed)R="fail",f=true,t.push(`doctor remediation plan execution error: ${D.stderr||"unknown error"}`);else if(D.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let s=$(D.stdout),l=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(l?.totalSteps??0),g=Number(l?.executableSteps??0);Number.isFinite(m)&&m>0&&(I=m),Number.isFinite(g)&&g>0&&(_=g),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:le,summary:R==="pass"?"no remediation steps required":"remediation steps available"}),n==="enforce"&&R==="warn"&&t.push("remediation plan has pending steps under enforce mode"),n==="safe-fix"){let s=Date.now(),l=await S(["doctor","workspace","--apply"],e$3),m=Date.now()-s,g=l.crashed||l.exitCode!==0?"fail":"pass";if(l.crashed)f=true,t.push(`doctor remediation apply execution error: ${l.stderr||"unknown error"}`);else if(g==="fail")t.push("doctor remediation apply failed");else {X=_>0?_:I>0?I:1;let w=await S(["doctor","workspace","--json"],e$3);if(w.crashed)c="fail",f=true,t.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",t.push("post-apply doctor workspace command failed");else {let i=$(w.stdout),v=i&&i.healthScore&&typeof i.healthScore=="object"?i.healthScore:{},h=Number(v.errors??0),y=Number(v.warnings??0);Number.isFinite(h)&&h>0?(c="fail",t.push(`post-apply doctor reports ${h} error(s)`)):Number.isFinite(y)&&y>0?c="warn":c="pass";}W>=0&&(o[W].status=c,o[W].summary=`doctor workspace post-apply status is ${c}`);let P=await S(["readiness","--json"],e$3);if(P.crashed)d$1="fail",f=true,t.push(`post-apply readiness execution error: ${P.stderr||"unknown error"}`);else if(P.exitCode!==0)d$1="fail",t.push("post-apply readiness command failed");else {let i=$(P.stdout),v=String(i?.overallStatus??"fail");if(d$1=oe(v),typeof i?.evidencePath=="string"&&i.evidencePath.trim().length>0&&(L=i.evidencePath),d$1==="fail"){let h=Array.isArray(i?.blockingReasons)?i?.blockingReasons.filter(y=>typeof y=="string"):[];h.length>0?t.push(...h.map(y=>`post-apply readiness: ${y}`)):t.push("post-apply readiness overall status is fail");}}T>=0&&(o[T].status=d$1,o[T].summary=`readiness post-apply overall status is ${d$1}`);}o.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let ce=Date.now(),A="pass",x="workspace test/build completed for selected projects";try{let s=await a$1({workspacePath:e$3,stage:"test",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});N=a(e$3,b.join(".workspai","reports",a$2)),await e$1(e$3,s),q=N;let l=ae(s);if(l==="fail")A="fail",x="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {l==="warn"&&(A="warn",x="workspace test stage completed with warnings",n==="enforce"&&t.push("workspace run test reported warnings under enforce mode"));let m=await a$1({workspacePath:e$3,stage:"build",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});await e$1(e$3,m),Q=N;let g=ae(m);g==="fail"?(A="fail",x="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):g==="warn"&&(A="warn",x="workspace test/build completed with warnings",n==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){A="fail",x="workspace test/build orchestration failed",f=true,t.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let pe=Date.now()-ce;o.push({name:"workspace-run-test-build",status:A,durationMs:pe,summary:x});let M=o.filter(s=>s.status==="warn").length,ue=o.filter(s=>s.status==="fail").length,F=n==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):ue>0,j=[...new Set(t)],O=f||F?Math.max(1,j.length):0,de=O>0?j:[],fe=O===0?j:[],me=be(o),ge=f||F?"blocked":M>0?"partial":"approved",we=f?3:F?1:M>0?2:0,he=Ae({mode:n,executionError:f,blockers:j,hasWarnings:M>0}),Y=a(e$3,".workspai/reports"),ke=b.join(Y,V),ye=b.join(Y,G),u={schemaVersion:h.autopilotReleaseLastRun.schemaVersion,generatedAt:new Date().toISOString(),workspacePath:e$3,mode:n,summary:{releaseScore:me,verdict:ge,blockers:O,warnings:M,safeFixesApplied:X,manualActions:j.length,exitCode:we},stages:o,blockingReasons:de,warningReasons:fe,nextActions:he,artifacts:{reportPath:ke,aliasEvidencePath:ye,analyzeEvidencePath:H,readinessEvidencePath:L,workspaceRunEvidencePath:N,workspaceRunTestPath:q,workspaceRunBuildPath:Q},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${V}`,aliasEvidencePath:`.workspai/reports/${G}`}};if(await e$2(e$3,`.workspai/reports/${V}`,u),await e$2(e$3,`.workspai/reports/${G}`,u),r.output&&await xe(b.resolve(r.output),u),!r.json){console.log(a$3.bold.cyan(`
3
3
  \u{1F680} Workspai Autopilot Release
4
4
  `)),console.log(a$3.bold(`Workspace: ${a$3.cyan(b.basename(e$3))}`)),console.log(a$3.gray(`Path: ${e$3}`)),console.log(a$3.white(`Mode: ${n}`)),console.log(a$3.white(`Verdict: ${u.summary.verdict==="approved"?a$3.green("approved"):u.summary.verdict==="partial"?a$3.yellow("partial"):a$3.red("blocked")}`)),console.log(a$3.white(`Release score: ${u.summary.releaseScore}`));for(let s of u.stages){let l=s.status==="pass"?a$3.green("PASS"):s.status==="warn"?a$3.yellow("WARN"):s.status==="skipped"?a$3.gray("SKIP"):a$3.red("FAIL");console.log(` - ${s.name}: ${l} ${s.summary} (${s.durationMs}ms)`);}if(u.blockingReasons.length>0){console.log(a$3.bold.red(`