workspai 0.55.0 → 0.56.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 (167) hide show
  1. package/contracts/artifact-remediation-plan.v1.json +110 -2
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +29 -1
  3. package/contracts/doctor-project-evidence.v1.json +68 -2
  4. package/contracts/doctor-remediation-plan.v1.json +29 -2
  5. package/contracts/doctor-workspace-evidence.v1.json +68 -2
  6. package/contracts/extension-cli-compatibility.v1.json +6 -1
  7. package/contracts/published-contract-catalog.v1.json +25 -0
  8. package/contracts/runtime-command-surface.v1.json +63 -0
  9. package/contracts/workspace-intelligence/doctor-capabilities.v1.json +133 -0
  10. package/contracts/workspace-intelligence/doctor-diagnosis.v1.json +273 -0
  11. package/contracts/workspace-intelligence/doctor-graph-diagnosis.v1.json +3 -0
  12. package/contracts/workspace-intelligence/doctor-receipt.v1.json +136 -0
  13. package/contracts/workspace-intelligence/doctor-summary.v1.json +99 -0
  14. package/contracts/workspace-intelligence/doctor-validation.v1.json +109 -0
  15. package/contracts/workspace-intelligence/project-context-agent.v1.json +110 -0
  16. package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +25 -0
  17. package/contracts/workspace-intelligence/workspace-explain.v1.json +3 -0
  18. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +36 -0
  19. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +54 -0
  20. package/contracts/workspace-intelligence/workspace-repair-transaction.v1.json +27 -0
  21. package/contracts/workspace-repair-capabilities.v1.json +1 -0
  22. package/dist/analyze-HJ774J3E.js +1 -0
  23. package/dist/{artifact-remediation-plan-O3YIULQN.js → artifact-remediation-plan-BPLON5VX.js} +1 -1
  24. package/dist/autopilot-release-CH57CGET.js +1 -0
  25. package/dist/capabilities-command-WEOGFCWF.js +1 -0
  26. package/dist/chunk-2647BYBC.js +1 -0
  27. package/dist/chunk-2L4PSZQB.js +1 -0
  28. package/dist/chunk-3U4VLIGW.js +1 -0
  29. package/dist/chunk-5BGPGNRQ.js +2 -0
  30. package/dist/chunk-5EPPPMAS.js +1 -0
  31. package/dist/{chunk-M5ICGR55.js → chunk-5RL254O2.js} +1 -1
  32. package/dist/chunk-5ZA4JYOP.js +1 -0
  33. package/dist/{chunk-AMB42V2F.js → chunk-64JUYYRC.js} +1 -1
  34. package/dist/chunk-664GXRLD.js +1 -0
  35. package/dist/chunk-6HCAGHCY.js +8 -0
  36. package/dist/chunk-7PNARN6S.js +4 -0
  37. package/dist/chunk-7Y3KVZJF.js +8 -0
  38. package/dist/{chunk-WIO6L24E.js → chunk-ADL3CK44.js} +1 -1
  39. package/dist/chunk-AO2ZI42U.js +4 -0
  40. package/dist/chunk-BDN32Y2N.js +81 -0
  41. package/dist/chunk-D4RST2HE.js +1 -0
  42. package/dist/{chunk-6HJJHEL6.js → chunk-DIZSHNZ5.js} +1 -1
  43. package/dist/chunk-DOIZANFA.js +2 -0
  44. package/dist/{chunk-HY3RMPW5.js → chunk-E53BGUOW.js} +1 -1
  45. package/dist/{chunk-FZCYTRBQ.js → chunk-ESWFBSYM.js} +1 -1
  46. package/dist/chunk-GBMCHFOV.js +1 -0
  47. package/dist/{chunk-HUPLAFZQ.js → chunk-HASVV34S.js} +1 -1
  48. package/dist/chunk-IZLEMTES.js +1 -0
  49. package/dist/chunk-KR7CIEQR.js +1 -0
  50. package/dist/chunk-KS4FB5W7.js +6 -0
  51. package/dist/chunk-LYVDRRDO.js +2 -0
  52. package/dist/chunk-NHTLE3WN.js +1 -0
  53. package/dist/chunk-NS53IPAC.js +1 -0
  54. package/dist/{chunk-WZA5ISAQ.js → chunk-OX53L237.js} +6 -6
  55. package/dist/chunk-PKIRVQLG.js +1 -0
  56. package/dist/chunk-QAF26ZQX.js +36 -0
  57. package/dist/{chunk-NWQ5VWUW.js → chunk-QFCKHUEP.js} +1 -1
  58. package/dist/chunk-QRWWYL52.js +88 -0
  59. package/dist/chunk-QTCZPS5I.js +1 -0
  60. package/dist/{chunk-WSAFBPS5.js → chunk-SV2SP22H.js} +4 -4
  61. package/dist/chunk-T5YRFRJV.js +1 -0
  62. package/dist/chunk-UQEQ6CXU.js +1 -0
  63. package/dist/chunk-V5EYVQ63.js +1 -0
  64. package/dist/chunk-VGJVIHHR.js +1 -0
  65. package/dist/{chunk-MRFN5ZQP.js → chunk-W5ZFXKSL.js} +1 -1
  66. package/dist/chunk-WLCBXCZV.js +5 -0
  67. package/dist/chunk-WOTTSPSF.js +2 -0
  68. package/dist/chunk-X7FYEKLI.js +1 -0
  69. package/dist/chunk-XH7PDHBF.js +1 -0
  70. package/dist/{chunk-KFKZOPZC.js → chunk-XMTLKDPP.js} +1 -1
  71. package/dist/chunk-YJTEMJFV.js +3 -0
  72. package/dist/chunk-YM77FQB3.js +8 -0
  73. package/dist/chunk-ZCPT6KC3.js +6 -0
  74. package/dist/chunk-ZPA6ECBJ.js +7 -0
  75. package/dist/{create-3NSOY7CA.js → create-DLUWG46F.js} +1 -1
  76. package/dist/doctor-IZ4YOCYE.js +1 -0
  77. package/dist/index.d.ts +15 -0
  78. package/dist/index.js +168 -168
  79. package/dist/pipeline-IBQYDLFF.js +5 -0
  80. package/dist/{project-intelligence-lens-ZOAWXYC5.js → project-intelligence-lens-SIU7IXKG.js} +1 -1
  81. package/dist/project-test-coverage-FRMVYTFB.js +1 -0
  82. package/dist/verified-goal-M4GPOXNL.js +1 -0
  83. package/dist/{workspace-C4UETGY7.js → workspace-3AAOUELG.js} +1 -1
  84. package/dist/{workspace-agent-sync-446AXPHJ.js → workspace-agent-sync-QGYLY7HH.js} +1 -1
  85. package/dist/{workspace-archive-VHUPOBAV.js → workspace-archive-BA3ONVXX.js} +1 -1
  86. package/dist/{workspace-context-XSECHC7O.js → workspace-context-JCLPRYNC.js} +1 -1
  87. package/dist/workspace-contract-IUUPBQXU.js +1 -0
  88. package/dist/workspace-explain-CZGBVDE6.js +1 -0
  89. package/dist/workspace-explain-contract-KVQO57RC.js +1 -0
  90. package/dist/{workspace-feedback-WXE7NVMV.js → workspace-feedback-PCZKXG5R.js} +1 -1
  91. package/dist/{workspace-foundation-3EVAQ5X6.js → workspace-foundation-7IGMO4CW.js} +1 -1
  92. package/dist/{workspace-graph-stream-AJPS45FD.js → workspace-graph-stream-5YMLJXAJ.js} +1 -1
  93. package/dist/workspace-graph-token-efficiency-HK4KNWWP.js +1 -0
  94. package/dist/{workspace-history-YY7YRDOH.js → workspace-history-CHJOABME.js} +1 -1
  95. package/dist/{workspace-intelligence-FWRB47EJ.js → workspace-intelligence-XHSUFTAT.js} +1 -1
  96. package/dist/workspace-intelligence-evaluation-YMY3C5AW.js +1 -0
  97. package/dist/{workspace-intelligence-runner-GLC666ER.js → workspace-intelligence-runner-EN5V4KSC.js} +1 -1
  98. package/dist/workspace-intelligence-runtime-registry-NCVHKCMP.js +1 -0
  99. package/dist/workspace-knowledge-graph-VWQTIEYK.js +1 -0
  100. package/dist/{workspace-knowledge-graph-query-EKHIE3E2.js → workspace-knowledge-graph-query-TXA3KVUV.js} +1 -1
  101. package/dist/workspace-knowledge-graph-snapshot-WB62AVDK.js +1 -0
  102. package/dist/workspace-mcp-serve-NCAGGWQS.js +3 -0
  103. package/dist/{workspace-model-MNJOGBPP.js → workspace-model-NXFIKX26.js} +1 -1
  104. package/dist/{workspace-onboarding-5KO7Z7AD.js → workspace-onboarding-OP22NHQ4.js} +1 -1
  105. package/dist/{workspace-readme-4S6PJ74A.js → workspace-readme-IVJXSIBS.js} +1 -1
  106. package/dist/{workspace-registry-summary-GPJEL7K7.js → workspace-registry-summary-A5VDPRHU.js} +1 -1
  107. package/dist/workspace-repair-engine-N4KXNSVL.js +3 -0
  108. package/dist/workspace-run-PXKC3ELS.js +1 -0
  109. package/dist/{workspace-verify-C6HWHRLJ.js → workspace-verify-TUVLFPPN.js} +1 -1
  110. package/dist/{workspace-watch-DLPHLF5R.js → workspace-watch-2ZNOYSUQ.js} +1 -1
  111. package/docs/commands-reference.md +35 -6
  112. package/docs/contracts/ARTIFACT_CATALOG.md +6 -1
  113. package/docs/contracts/README.md +5 -0
  114. package/docs/doctor-command.md +158 -7
  115. package/docs/graph-benchmark-methodology.md +13 -0
  116. package/docs/workspace-intelligence-runner.md +4 -0
  117. package/docs/workspace-knowledge-graph.md +53 -4
  118. package/docs/workspace-run.md +14 -3
  119. package/package.json +10 -3
  120. package/dist/analyze-AAZEJ4FC.js +0 -1
  121. package/dist/autopilot-release-EZXOGAVE.js +0 -1
  122. package/dist/chunk-2PY65U6X.js +0 -5
  123. package/dist/chunk-3DONU3DU.js +0 -1
  124. package/dist/chunk-44VJHNZB.js +0 -1
  125. package/dist/chunk-4GPKQFPY.js +0 -1
  126. package/dist/chunk-5XDPQ3CB.js +0 -1
  127. package/dist/chunk-7AR5PDLD.js +0 -1
  128. package/dist/chunk-7KKP7RNB.js +0 -3
  129. package/dist/chunk-7T4TSV5C.js +0 -1
  130. package/dist/chunk-B5AY55A5.js +0 -1
  131. package/dist/chunk-BQ24743S.js +0 -5
  132. package/dist/chunk-BYVTHIC3.js +0 -2
  133. package/dist/chunk-CEIJIFY7.js +0 -88
  134. package/dist/chunk-EBKYSDCX.js +0 -1
  135. package/dist/chunk-FQLB4BIC.js +0 -7
  136. package/dist/chunk-GDU7VP6G.js +0 -1
  137. package/dist/chunk-H7P7SSUW.js +0 -75
  138. package/dist/chunk-KJYLCZRI.js +0 -8
  139. package/dist/chunk-KVUYAYTY.js +0 -8
  140. package/dist/chunk-MQ73VS4E.js +0 -2
  141. package/dist/chunk-NYHVCFBT.js +0 -1
  142. package/dist/chunk-OUBBBC7T.js +0 -36
  143. package/dist/chunk-P7K5RHJC.js +0 -2
  144. package/dist/chunk-PS5F4DCT.js +0 -1
  145. package/dist/chunk-QZ7PNMVP.js +0 -1
  146. package/dist/chunk-RA24WQLF.js +0 -1
  147. package/dist/chunk-RMXXK64P.js +0 -4
  148. package/dist/chunk-S7Z4DP3P.js +0 -2
  149. package/dist/chunk-SJLUE6AY.js +0 -1
  150. package/dist/chunk-TEHQ7XKK.js +0 -3
  151. package/dist/chunk-UFOCUHG3.js +0 -1
  152. package/dist/chunk-WD2XDMGB.js +0 -1
  153. package/dist/chunk-XVRJVKOX.js +0 -1
  154. package/dist/doctor-UEFFNAUD.js +0 -1
  155. package/dist/pipeline-ZYKDWUKK.js +0 -5
  156. package/dist/project-test-coverage-44ZPCOPV.js +0 -1
  157. package/dist/verified-goal-PE2PGAHF.js +0 -1
  158. package/dist/workspace-contract-AYFTZIKM.js +0 -1
  159. package/dist/workspace-explain-SZI2WAAD.js +0 -1
  160. package/dist/workspace-explain-contract-N2XQHAPM.js +0 -1
  161. package/dist/workspace-graph-token-efficiency-5FNH4JZ5.js +0 -1
  162. package/dist/workspace-intelligence-evaluation-UP2K3L35.js +0 -1
  163. package/dist/workspace-intelligence-runtime-registry-MRSF7RTT.js +0 -1
  164. package/dist/workspace-knowledge-graph-BMMM2FUE.js +0 -1
  165. package/dist/workspace-mcp-serve-COA4FMCA.js +0 -3
  166. package/dist/workspace-repair-engine-NMKOWUQP.js +0 -3
  167. package/dist/workspace-run-2DEVJOVH.js +0 -1
@@ -0,0 +1,109 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://workspai.dev/schemas/workspace-intelligence/doctor-validation.v1.json",
4
+ "title": "Workspai Doctor Validation Report",
5
+ "type": "object",
6
+ "required": [
7
+ "schemaVersion",
8
+ "corpusVersion",
9
+ "capabilityRegistryVersion",
10
+ "scope",
11
+ "summary",
12
+ "cases",
13
+ "limitations"
14
+ ],
15
+ "properties": {
16
+ "schemaVersion": { "const": "workspai.doctor-validation.v1" },
17
+ "corpusVersion": { "const": "doctor-disease-corpus-v1" },
18
+ "capabilityRegistryVersion": { "const": "universal-doctor-capabilities-v1" },
19
+ "scope": { "const": "synthetic-contract-corpus" },
20
+ "summary": {
21
+ "type": "object",
22
+ "required": [
23
+ "totalCases",
24
+ "passedCases",
25
+ "failedCases",
26
+ "truePositives",
27
+ "trueNegatives",
28
+ "falsePositives",
29
+ "falseNegatives",
30
+ "precision",
31
+ "recall",
32
+ "domainCoverage",
33
+ "runtimeAdapterCoverage",
34
+ "runtimeAdaptersExercised",
35
+ "declaredPlatforms"
36
+ ],
37
+ "properties": {
38
+ "totalCases": { "type": "integer", "minimum": 1 },
39
+ "passedCases": { "type": "integer", "minimum": 0 },
40
+ "failedCases": { "type": "integer", "minimum": 0 },
41
+ "truePositives": { "type": "integer", "minimum": 0 },
42
+ "trueNegatives": { "type": "integer", "minimum": 0 },
43
+ "falsePositives": { "type": "integer", "minimum": 0 },
44
+ "falseNegatives": { "type": "integer", "minimum": 0 },
45
+ "precision": { "type": "number", "minimum": 0, "maximum": 1 },
46
+ "recall": { "type": "number", "minimum": 0, "maximum": 1 },
47
+ "domainCoverage": { "type": "number", "minimum": 0, "maximum": 1 },
48
+ "runtimeAdapterCoverage": { "type": "number", "minimum": 0, "maximum": 1 },
49
+ "runtimeAdaptersExercised": { "type": "integer", "minimum": 1 },
50
+ "declaredPlatforms": { "type": "integer", "minimum": 1 }
51
+ },
52
+ "additionalProperties": false
53
+ },
54
+ "cases": {
55
+ "type": "array",
56
+ "minItems": 1,
57
+ "items": {
58
+ "type": "object",
59
+ "required": ["id", "passed", "expected", "actual", "failures"],
60
+ "properties": {
61
+ "id": { "type": "string", "minLength": 1 },
62
+ "passed": { "type": "boolean" },
63
+ "expected": { "$ref": "#/$defs/outcome" },
64
+ "actual": { "$ref": "#/$defs/actualOutcome" },
65
+ "failures": {
66
+ "type": "array",
67
+ "items": { "type": "string", "minLength": 1 },
68
+ "uniqueItems": true
69
+ }
70
+ },
71
+ "additionalProperties": false
72
+ }
73
+ },
74
+ "limitations": {
75
+ "type": "array",
76
+ "items": { "type": "string", "minLength": 1 },
77
+ "minItems": 1,
78
+ "uniqueItems": true
79
+ }
80
+ },
81
+ "$defs": {
82
+ "domain": { "enum": ["runtime", "dependency", "security", "configuration", "test", "quality"] },
83
+ "outcome": {
84
+ "type": "object",
85
+ "required": ["finding"],
86
+ "properties": {
87
+ "finding": { "type": "boolean" },
88
+ "domain": { "$ref": "#/$defs/domain" },
89
+ "status": { "enum": ["blocking", "advisory"] },
90
+ "diagnosisState": { "enum": ["confirmed", "candidate", "unknown"] },
91
+ "repairDisposition": { "enum": ["automatic", "approval-required", "manual", "unavailable"] }
92
+ },
93
+ "additionalProperties": false
94
+ },
95
+ "actualOutcome": {
96
+ "type": "object",
97
+ "required": ["finding"],
98
+ "properties": {
99
+ "finding": { "type": "boolean" },
100
+ "domain": { "$ref": "#/$defs/domain" },
101
+ "status": { "enum": ["blocking", "advisory"] },
102
+ "diagnosisState": { "enum": ["confirmed", "candidate", "unknown"] },
103
+ "repairDisposition": { "enum": ["automatic", "approval-required", "manual", "unavailable"] }
104
+ },
105
+ "additionalProperties": false
106
+ }
107
+ },
108
+ "additionalProperties": false
109
+ }
@@ -12,6 +12,7 @@
12
12
  "intelligence",
13
13
  "evidence",
14
14
  "blockers",
15
+ "agentRouting",
15
16
  "commands",
16
17
  "integrity"
17
18
  ],
@@ -56,6 +57,11 @@
56
57
  },
57
58
  "kind": { "type": "string" },
58
59
  "runtime": { "type": "string" },
60
+ "runtimeCandidates": {
61
+ "type": "array",
62
+ "items": { "type": "string", "minLength": 1 },
63
+ "uniqueItems": true
64
+ },
59
65
  "framework": { "type": "string" },
60
66
  "kit": { "type": "string" },
61
67
  "supportTier": { "type": "string" },
@@ -88,6 +94,8 @@
88
94
  "proofCount",
89
95
  "entitiesByKind",
90
96
  "relationsByKind",
97
+ "languages",
98
+ "semantic",
91
99
  "relatedProjects",
92
100
  "freshness",
93
101
  "topology",
@@ -109,6 +117,45 @@
109
117
  "type": "object",
110
118
  "additionalProperties": { "type": "integer", "minimum": 0 }
111
119
  },
120
+ "languages": {
121
+ "type": "object",
122
+ "additionalProperties": {
123
+ "type": "object",
124
+ "required": ["fileCount", "symbolCount", "generatedFileCount"],
125
+ "properties": {
126
+ "fileCount": { "type": "integer", "minimum": 0 },
127
+ "symbolCount": { "type": "integer", "minimum": 0 },
128
+ "generatedFileCount": { "type": "integer", "minimum": 0 }
129
+ },
130
+ "additionalProperties": false
131
+ }
132
+ },
133
+ "semantic": {
134
+ "type": "object",
135
+ "required": [
136
+ "protocolConceptCount",
137
+ "protocolImplementationBindings",
138
+ "equivalenceBindings",
139
+ "generationBindings",
140
+ "runtimeUnitCount",
141
+ "lifecycleStageCount",
142
+ "runtimeCoverage"
143
+ ],
144
+ "properties": {
145
+ "protocolConceptCount": { "type": "integer", "minimum": 0 },
146
+ "protocolImplementationBindings": { "type": "integer", "minimum": 0 },
147
+ "equivalenceBindings": { "type": "integer", "minimum": 0 },
148
+ "generationBindings": { "type": "integer", "minimum": 0 },
149
+ "runtimeUnitCount": { "type": "integer", "minimum": 0 },
150
+ "lifecycleStageCount": { "type": "integer", "minimum": 0 },
151
+ "runtimeCoverage": {
152
+ "type": "array",
153
+ "items": { "type": "string" },
154
+ "uniqueItems": true
155
+ }
156
+ },
157
+ "additionalProperties": false
158
+ },
112
159
  "relatedProjects": {
113
160
  "type": "array",
114
161
  "items": { "type": "string" },
@@ -146,6 +193,10 @@
146
193
  "type": "object",
147
194
  "required": [
148
195
  "services",
196
+ "packages",
197
+ "protocols",
198
+ "runtimeUnits",
199
+ "lifecycleStages",
149
200
  "apis",
150
201
  "endpoints",
151
202
  "dataStores",
@@ -158,6 +209,10 @@
158
209
  ],
159
210
  "properties": {
160
211
  "services": { "$ref": "#/$defs/entityList" },
212
+ "packages": { "$ref": "#/$defs/entityList" },
213
+ "protocols": { "$ref": "#/$defs/entityList" },
214
+ "runtimeUnits": { "$ref": "#/$defs/entityList" },
215
+ "lifecycleStages": { "$ref": "#/$defs/entityList" },
161
216
  "apis": { "$ref": "#/$defs/entityList" },
162
217
  "endpoints": { "$ref": "#/$defs/entityList" },
163
218
  "dataStores": { "$ref": "#/$defs/entityList" },
@@ -222,6 +277,61 @@
222
277
  "maxItems": 32,
223
278
  "items": { "$ref": "#/$defs/blocker" }
224
279
  },
280
+ "agentRouting": {
281
+ "description": "Machine-readable mandatory routing policy that prevents agents from bypassing canonical workspace evidence.",
282
+ "type": "object",
283
+ "required": [
284
+ "enforcement",
285
+ "mandatoryPreflight",
286
+ "workspaceEvidenceRequiredFor",
287
+ "requiredReadOrder",
288
+ "degradedMode"
289
+ ],
290
+ "properties": {
291
+ "enforcement": { "const": "required" },
292
+ "mandatoryPreflight": {
293
+ "type": "object",
294
+ "required": ["command", "successCondition"],
295
+ "properties": {
296
+ "command": { "const": "npx workspai project workspace status --json" },
297
+ "successCondition": { "const": "resolved" }
298
+ },
299
+ "additionalProperties": false
300
+ },
301
+ "workspaceEvidenceRequiredFor": {
302
+ "type": "array",
303
+ "minItems": 1,
304
+ "uniqueItems": true,
305
+ "items": {
306
+ "enum": [
307
+ "repository-analysis",
308
+ "architecture-analysis",
309
+ "change-impact",
310
+ "cross-project-change",
311
+ "contract-change",
312
+ "infrastructure-change",
313
+ "release-readiness"
314
+ ]
315
+ }
316
+ },
317
+ "requiredReadOrder": {
318
+ "type": "array",
319
+ "minItems": 4,
320
+ "uniqueItems": true,
321
+ "items": { "type": "string", "minLength": 1 }
322
+ },
323
+ "degradedMode": {
324
+ "type": "object",
325
+ "required": ["allowCompleteArchitectureClaims", "requireDisclosure"],
326
+ "properties": {
327
+ "allowCompleteArchitectureClaims": { "const": false },
328
+ "requireDisclosure": { "const": true }
329
+ },
330
+ "additionalProperties": false
331
+ }
332
+ },
333
+ "additionalProperties": false
334
+ },
225
335
  "commands": {
226
336
  "type": "object",
227
337
  "required": ["refresh", "verify", "graphSearch", "doctor", "workspaceStatus"],
@@ -39,6 +39,31 @@
39
39
  "items": { "type": "string", "minLength": 1 },
40
40
  "uniqueItems": true
41
41
  },
42
+ "doctorFindings": {
43
+ "type": "array",
44
+ "description": "Exact causal Doctor findings used to bind Studio repair to stable finding and capability identifiers.",
45
+ "items": {
46
+ "type": "object",
47
+ "required": ["id", "symptom", "status"],
48
+ "properties": {
49
+ "id": { "type": "string", "minLength": 1 },
50
+ "causalKey": { "type": "string" },
51
+ "projectName": { "type": "string" },
52
+ "projectPath": { "type": "string" },
53
+ "probeId": { "type": "string" },
54
+ "issueClass": { "type": "string" },
55
+ "symptom": { "type": "string", "minLength": 1 },
56
+ "status": { "enum": ["blocking", "advisory", "informational", "unknown"] },
57
+ "applicability": { "enum": ["applicable", "not-applicable", "unknown"] },
58
+ "diagnosisState": { "enum": ["confirmed", "candidate", "unknown"] },
59
+ "repairDisposition": { "enum": ["automatic", "approval-required", "manual", "unavailable", "not-needed"] },
60
+ "capabilityId": { "type": "string" },
61
+ "verifyCommand": { "type": "string" },
62
+ "requiresFreshEvidence": { "type": "boolean" }
63
+ },
64
+ "additionalProperties": false
65
+ }
66
+ },
42
67
  "artifactPath": {
43
68
  "type": "string"
44
69
  },
@@ -24,6 +24,9 @@
24
24
  "additionalProperties": false
25
25
  }
26
26
  },
27
+ "releaseVerdict": { "enum": ["ready", "needs-attention", "blocked"] },
28
+ "evidenceFreshness": { "enum": ["fresh", "stale", "unknown"] },
29
+ "blocking": { "type": "boolean" },
27
30
  "releaseRisk": { "type": "string" },
28
31
  "blockingReasons": { "type": "array", "items": { "type": "string" } },
29
32
  "resolutionHints": { "type": "array", "items": { "type": "object" } }
@@ -37,6 +37,34 @@
37
37
  "type": "string",
38
38
  "pattern": "^[a-f0-9]{64}$",
39
39
  "description": "SHA-256 of the stable structural Workspace Model projection. Volatile timestamps, run correlation, live evidence and freshness fields are intentionally excluded."
40
+ },
41
+ "inputs": {
42
+ "type": "object",
43
+ "required": ["schemaVersion", "strategy", "hashAlgorithm", "hash", "scopes"],
44
+ "properties": {
45
+ "schemaVersion": { "const": "workspace-knowledge-graph-inputs.v1" },
46
+ "strategy": { "const": "hybrid-git-content-v2" },
47
+ "hashAlgorithm": { "const": "sha256" },
48
+ "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
49
+ "scopes": {
50
+ "type": "array",
51
+ "items": {
52
+ "type": "object",
53
+ "required": ["kind", "id", "strategy", "hash", "fileCount", "fileLimit", "truncated"],
54
+ "properties": {
55
+ "kind": { "enum": ["workspace", "project"] },
56
+ "id": { "type": "string", "minLength": 1 },
57
+ "strategy": { "enum": ["git-worktree-v2", "content-merkle-v1"] },
58
+ "hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
59
+ "fileCount": { "type": "integer", "minimum": 0 },
60
+ "fileLimit": { "type": "integer", "minimum": 1 },
61
+ "truncated": { "type": "boolean" }
62
+ },
63
+ "additionalProperties": false
64
+ }
65
+ }
66
+ },
67
+ "additionalProperties": false
40
68
  }
41
69
  },
42
70
  "additionalProperties": false
@@ -66,7 +94,11 @@
66
94
  "api",
67
95
  "endpoint",
68
96
  "schema",
97
+ "protocol",
98
+ "language",
69
99
  "package",
100
+ "runtime-unit",
101
+ "lifecycle-stage",
70
102
  "module",
71
103
  "file",
72
104
  "symbol",
@@ -128,6 +160,9 @@
128
160
  "depends-on",
129
161
  "exposes",
130
162
  "implements",
163
+ "implements-protocol",
164
+ "uses-language",
165
+ "equivalent-to",
131
166
  "calls",
132
167
  "reads-from",
133
168
  "writes-to",
@@ -141,6 +176,7 @@
141
176
  "tests",
142
177
  "owns",
143
178
  "generated-by",
179
+ "generated-from",
144
180
  "configured-by",
145
181
  "references"
146
182
  ]
@@ -25,6 +25,7 @@
25
25
  { "$ref": "workspace-knowledge-graph.v1.json#/properties/entities/items/properties/kind" }
26
26
  ]
27
27
  },
28
+ "projectId": { "type": "string", "minLength": 1 },
28
29
  "limit": { "type": "integer", "minimum": 1, "maximum": 100 },
29
30
  "totalMatches": { "type": "integer", "minimum": 0 },
30
31
  "truncated": { "type": "boolean" },
@@ -54,6 +55,59 @@
54
55
  "proofs": {
55
56
  "type": "array",
56
57
  "items": { "$ref": "workspace-knowledge-graph.v1.json#/properties/proofs/items" }
58
+ },
59
+ "budget": {
60
+ "description": "Present for the agent projection. Reports every hard payload limit and omission without changing the v1 full projection contract.",
61
+ "type": "object",
62
+ "required": ["mode", "limits", "omitted"],
63
+ "properties": {
64
+ "mode": { "const": "agent" },
65
+ "limits": {
66
+ "type": "object",
67
+ "required": [
68
+ "relations",
69
+ "relatedEntities",
70
+ "proofs",
71
+ "proofIdsPerItem",
72
+ "aliasesPerEntity",
73
+ "attributeArrayItems",
74
+ "attributeStringCharacters"
75
+ ],
76
+ "properties": {
77
+ "relations": { "type": "integer", "minimum": 1, "maximum": 24 },
78
+ "relatedEntities": { "type": "integer", "minimum": 1, "maximum": 24 },
79
+ "proofs": { "type": "integer", "minimum": 1, "maximum": 16 },
80
+ "proofIdsPerItem": { "type": "integer", "minimum": 1, "maximum": 4 },
81
+ "aliasesPerEntity": { "type": "integer", "minimum": 1, "maximum": 8 },
82
+ "attributeArrayItems": { "type": "integer", "minimum": 1, "maximum": 8 },
83
+ "attributeStringCharacters": { "type": "integer", "minimum": 1, "maximum": 256 }
84
+ },
85
+ "additionalProperties": false
86
+ },
87
+ "omitted": {
88
+ "type": "object",
89
+ "required": [
90
+ "entities",
91
+ "relations",
92
+ "relatedEntities",
93
+ "proofs",
94
+ "proofReferences",
95
+ "aliases",
96
+ "attributeValues"
97
+ ],
98
+ "properties": {
99
+ "entities": { "type": "integer", "minimum": 0 },
100
+ "relations": { "type": "integer", "minimum": 0 },
101
+ "relatedEntities": { "type": "integer", "minimum": 0 },
102
+ "proofs": { "type": "integer", "minimum": 0 },
103
+ "proofReferences": { "type": "integer", "minimum": 0 },
104
+ "aliases": { "type": "integer", "minimum": 0 },
105
+ "attributeValues": { "type": "integer", "minimum": 0 }
106
+ },
107
+ "additionalProperties": false
108
+ }
109
+ },
110
+ "additionalProperties": false
57
111
  }
58
112
  },
59
113
  "additionalProperties": false
@@ -267,9 +267,36 @@
267
267
  "cancel"
268
268
  ]
269
269
  }
270
+ },
271
+ "causes": {
272
+ "type": "array",
273
+ "minItems": 1,
274
+ "items": { "$ref": "#/$defs/decisionCause" }
270
275
  }
271
276
  }
272
277
  },
278
+ "decisionCause": {
279
+ "type": "object",
280
+ "additionalProperties": false,
281
+ "required": ["kind", "id", "message"],
282
+ "properties": {
283
+ "kind": {
284
+ "enum": [
285
+ "missing-executable",
286
+ "unsupported-adapter",
287
+ "failed-precondition",
288
+ "risk-approval",
289
+ "policy-exception",
290
+ "source-repair-required"
291
+ ]
292
+ },
293
+ "id": { "type": "string", "minLength": 1 },
294
+ "message": { "type": "string", "minLength": 1 },
295
+ "projectPath": { "type": "string", "minLength": 1 },
296
+ "adapterId": { "type": "string", "minLength": 1 },
297
+ "executable": { "type": "string", "minLength": 1 }
298
+ }
299
+ },
273
300
  "event": {
274
301
  "type": "object",
275
302
  "additionalProperties": false,
@@ -25,6 +25,7 @@
25
25
  "targetClosure": "selected-causal-action-set",
26
26
  "changeReceipt": "checkpoint-hash-delta",
27
27
  "consumerTimeline": "durable-transaction-events",
28
+ "typedDecisionCauses": true,
28
29
  "consumerHandshakeRequired": true,
29
30
  "ephemeralProposalsAreEvidence": false,
30
31
  "approvalBoundToPlanHash": true,
@@ -0,0 +1 @@
1
+ export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-YM77FQB3.js';
@@ -1 +1 @@
1
- export{a as buildArtifactRemediationPlan,b as writeArtifactRemediationPlan}from'./chunk-TEHQ7XKK.js';
1
+ export{a as buildArtifactRemediationPlan,b as writeArtifactRemediationPlan}from'./chunk-YJTEMJFV.js';
@@ -0,0 +1 @@
1
+ export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-6HCAGHCY.js';
@@ -0,0 +1 @@
1
+ export{b as runDoctorCapabilities}from'./chunk-KS4FB5W7.js';
@@ -0,0 +1 @@
1
+ import y from'fs';import u from'path';var b="polyglot-lifecycle-plan.v1",x=new Set([".git",".workspai",".rapidkit",".venv","bin","build","dist","node_modules","obj","target","third_party","vendor","fixture","fixtures","__fixtures__","testdata"]);function f(o,i){return u.relative(o,i).split(u.sep).join("/")||"."}function P(o,i){let t=[],s=(r,n)=>{if(n>i)return;let m=[];try{m=y.readdirSync(r,{withFileTypes:true});}catch{return}for(let d of m.sort((a,c)=>a.name.localeCompare(c.name))){let a=u.join(r,d.name);if(d.isDirectory()){x.has(d.name)||s(a,n+1);continue}d.isFile()&&(["package.json","pyproject.toml","go.mod","Cargo.toml","pom.xml","build.gradle","build.gradle.kts","CMakeLists.txt","meson.build"].includes(d.name)||/\.(?:cs|fs|vb)proj$/i.test(d.name))&&t.push(a);}};return s(o,0),t}function h(o,i){if(u.basename(i)!=="package.json")return false;let t=f(o,i).toLowerCase().split("/"),s=t.findIndex(r=>["test","tests","spec","specs","e2e","integration","integration-tests"].includes(r));return s<0?false:t.length-s>2}function e(o,i,t="high"){return {stage:o,command:i,confidence:t,preflight:"executable-and-inputs"}}function S(o,i){let t={};try{let n=JSON.parse(i);n.scripts&&typeof n.scripts=="object"&&!Array.isArray(n.scripts)&&(t=n.scripts);}catch{}let s=y.existsSync(u.join(o,"pnpm-lock.yaml"))?"pnpm":y.existsSync(u.join(o,"yarn.lock"))?"yarn":"npm",r=n=>`${s} run ${n}`;return [e("init",s==="yarn"?"yarn install":`${s} install`),...typeof t.test=="string"?[e("test",r("test"))]:[],...typeof t.build=="string"?[e("build",r("build"))]:[],...typeof t.start=="string"?[e("start",r("start"))]:[]]}function j(o,i){let t=u.basename(i),s=u.dirname(i),r=f(o,s),n=f(o,i),m=n.toLowerCase().split("/"),d=m.some(l=>["example","examples","sample","samples","worked"].includes(l))?"example":m.some(l=>["test","tests","e2e","integration","integration-tests"].includes(l))?"test":m.some(l=>["script","scripts","tool","tools","tooling"].includes(l))?"tooling":"production",a="";try{a=y.readFileSync(i,"utf8");}catch{return null}let c,g,p;if(t==="package.json")c="node",g="npm",p=S(s,a);else if(t==="pyproject.toml")c="python",g="python",p=[e("init","python -m pip install -e ."),...y.existsSync(u.join(s,"tests"))||/\[tool\.pytest/i.test(a)?[e("test","python -m pytest")]:[],.../\[build-system\]/.test(a)?[e("build","python -m build","medium")]:[]];else if(t==="go.mod")c="go",g="go",p=[e("init","go mod download"),e("test","go test ./..."),e("build","go build ./...")];else if(t==="Cargo.toml")c="rust",g="cargo",p=[e("init","cargo fetch"),e("test","cargo test"),e("build","cargo build"),...y.existsSync(u.join(s,"src","main.rs"))?[e("start","cargo run")]:[]];else if(t==="pom.xml"){c="java",g="maven";let l=y.existsSync(u.join(s,"mvnw"))?"./mvnw":"mvn";p=[e("init",`${l} dependency:go-offline`),e("test",`${l} test`),e("build",`${l} package`)];}else if(t==="build.gradle"||t==="build.gradle.kts"){c="java",g="gradle";let l=y.existsSync(u.join(s,"gradlew"))?"./gradlew":"gradle";p=[e("init",`${l} dependencies`),e("test",`${l} test`),e("build",`${l} build`)];}else if(/\.(?:cs|fs|vb)proj$/i.test(t)){c="dotnet",g="nuget";let l=d==="test"||/<IsTestProject>\s*true\s*<\/IsTestProject>/i.test(a)||/PackageReference\s+Include=["']Microsoft\.NET\.Test\.Sdk["']/i.test(a);p=[e("init",`dotnet restore ${t}`),...l?[e("test",`dotnet test ${t}`)]:[],e("build",`dotnet build ${t}`)];}else if(t==="CMakeLists.txt")c=/(?:\bcxx\b|\bcplusplus\b|\bc\+\+\b)/iu.test(a)?"cpp":"c",g="cmake",p=[e("init","cmake -S . -B build"),e("test","ctest --test-dir build --output-on-failure","medium"),e("build","cmake --build build")];else if(t==="meson.build")c=/(?:cpp|c\+\+)/iu.test(a)?"cpp":"c",g="meson",p=[e("init","meson setup build"),e("test","meson test -C build","medium"),e("build","meson compile -C build")];else return null;return {id:`${c}:${r}:${n}`,runtime:c,ecosystem:g,role:d,root:r,manifest:n,stages:p}}function R(o,i={}){let t=u.resolve(o),s=P(t,Math.max(0,Math.min(i.maxDepth??4,12))).filter(n=>!h(t,n)).map(n=>j(t,n)).filter(n=>!!n).filter(n=>i.includeExamples===true||n.role!=="example").sort((n,m)=>n.runtime.localeCompare(m.runtime)||n.root.localeCompare(m.root)||n.manifest.localeCompare(m.manifest)),r=[...new Set(s.map(n=>n.runtime))].sort();return {schemaVersion:b,projectRoot:".",polyglot:r.length>1,runtimes:r,units:s}}export{R as a};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-AO2ZI42U.js';import {a}from'./chunk-NS53IPAC.js';import {f,h}from'./chunk-5EPPPMAS.js';var R=f.doctor,O=h.doctorProject.schemaVersion;function s(a){return !a||typeof a!="object"||Array.isArray(a)?null:a}function M(a,o){let t=s(a);if(!t)return false;let i=t.schemaVersion,e=t.evidenceType;if(i!==void 0&&typeof i!="string"||e!==void 0&&typeof e!="string")return false;if(i===void 0){let l=Array.isArray(t.projects)||s(t.summary)!==null||s(t.healthScore)!==null,u=s(t.project)!==null;if(!(o==="workspace"?l:o==="project"?u:l||u))return false}return !(typeof i=="string"&&(i!==R&&i!==O||o==="workspace"&&i!==R||o==="project"&&i!==O)||typeof e=="string"&&(e!=="workspace"&&e!=="project"||o&&e!==o))}function r(a,o){let t=a[o];if(!Number.isInteger(t)||Number(t)<0)throw new Error(`Doctor evidence ${o} must be a non-negative integer.`);return Number(t)}function I(a){if(Array.isArray(a.projects))return a.projects.map(s).filter(t=>t!==null);let o=s(a.project);return o?[o]:[]}function _(a$1){let o=s(a$1.diagnosis);if(!o)return;if(o.schemaVersion!==a)throw new Error("Doctor diagnosis schemaVersion is missing or unsupported.");let t=Array.isArray(o.findings)?o.findings.map(s).filter(n=>n!==null):[],i=s(o.coverage);if(!i)throw new Error("Doctor diagnosis must publish coverage.");let e=s(o.capability);if(!e)throw new Error("Doctor diagnosis must publish capability truth.");let l=Array.isArray(o.domains)?o.domains.map(s).filter(n=>n!==null):[],u=l.map(n=>n.id);if(l.length!==6||new Set(u).size!==l.length)throw new Error("Doctor diagnosis must publish each canonical diagnostic domain exactly once.");let f=["nativeDomains","portableDomains","observableDomains","unsupportedDomains"].flatMap(n=>Array.isArray(e[n])?e[n]:[]);if(f.length!==6||new Set(f).size!==f.length||u.some(n=>!f.includes(n)))throw new Error("Doctor capability truth must classify every canonical domain exactly once.");if(e.tier==="fallback"&&e.confidence!=="low")throw new Error("Doctor fallback capability cannot claim medium or high confidence.");let h=new Set;for(let n of t){if(typeof n.id!="string"||!n.id.trim())throw new Error("Doctor diagnosis finding id must be non-empty.");if(h.has(n.id))throw new Error(`Doctor diagnosis finding id is duplicated: ${n.id}`);if(h.add(n.id),!Array.isArray(n.proofs)||n.proofs.length===0)throw new Error(`Doctor diagnosis finding ${n.id} has no proof.`)}let D=t.filter(n=>n.status==="blocking").length,v=t.filter(n=>n.status==="advisory").length;if(r(i,"blockingFindings")!==D)throw new Error("Doctor diagnosis blockingFindings contradicts its finding set.");if(r(i,"advisoryFindings")!==v)throw new Error("Doctor diagnosis advisoryFindings contradicts its finding set.");let k=r(i,"totalObservations"),w=r(i,"evaluatedObservations"),c=r(i,"passingObservations");if(w>k||c>w)throw new Error("Doctor diagnosis observation accounting is inconsistent.");if(r(i,"repairableFindings")+r(i,"manualFindings")+r(i,"unsupportedFindings")!==t.length)throw new Error("Doctor diagnosis repair disposition counts contradict its finding set.");let y=Array.isArray(o.unknowns)?o.unknowns:[];if(r(i,"unknownFindings")!==y.length)throw new Error("Doctor diagnosis unknownFindings contradicts its unknown set.");let p=i.diagnosisCompleteness;if(typeof p!="number"||p<0||p>100)throw new Error("Doctor diagnosis completeness must be between 0 and 100.");if(p===100&&l.some(n=>n.status==="not-run"||n.status==="stale"))throw new Error("Doctor diagnosis cannot claim complete coverage with missing or stale domains.");if(p===100&&y.length>0)throw new Error("Doctor diagnosis cannot claim complete coverage while unknowns remain.");let b=new Set;for(let n of Array.isArray(o.causalGroups)?o.causalGroups:[]){let d=s(n);if(!d||!Array.isArray(d.findingIds))throw new Error("Doctor diagnosis causal group is malformed.");for(let g of d.findingIds){if(typeof g!="string"||!h.has(g))throw new Error("Doctor diagnosis causal group references an unknown finding.");if(b.has(g))throw new Error("Doctor diagnosis finding belongs to more than one causal group.");b.add(g);}}if(b.size!==h.size)throw new Error("Doctor diagnosis causal groups do not cover every finding exactly once.")}function P(a){let o=[...Array.isArray(a.repairCapabilities)?a.repairCapabilities:[],...Array.isArray(a.probes)?a.probes.map(s).map(t=>t&&s(t.repairCapability)):[]];for(let t of o){let i=s(t);if(!(!i||i.operation===void 0)&&!a$1(i.operation)){let e=typeof i.id=="string"?i.id:"unknown";throw new Error(`Doctor repair capability ${e} contains an invalid typed operation.`)}}}function z(a){let o=s(a);if(!o)throw new Error("Doctor evidence must be an object.");let t=I(o),i=s(o.contract);for(let c of t)_(c),P(c);if(i?.scoringPolicyVersion==="doctor-score-policy-v2"&&t.some(c=>!s(c.diagnosis)))throw new Error("Canonical Doctor evidence contains a project without diagnosis.");let e=s(o.healthScore);if(!e||typeof e.verdict!="string")return;let l=r(e,"total"),u=r(e,"passed"),E=r(e,"warnings"),f=r(e,"errors");if(l!==u+E+f)throw new Error("Doctor healthScore total must equal passed + warnings + errors.");let h=f>0?"blocked":E>0?"attention":"passed";if(e.verdict!==h)throw new Error(`Doctor healthScore verdict ${String(e.verdict)} contradicts score counts (${h}).`);let D=s(e.components);if(D){let c=s(D.host),m=s(D.projects);if(!c||!m)throw new Error("Doctor healthScore components must publish host and projects.");for(let[y,p]of [["host",c],["projects",m]]){let b=r(p,"total"),n=r(p,"passed"),d=r(p,"warnings"),g=r(p,"errors");if(b!==n+d+g)throw new Error(`Doctor ${y} score total contradicts its component counts.`)}if(u!==r(c,"passed")+r(m,"passed")||E!==r(c,"warnings")+r(m,"warnings")||f!==r(c,"errors")+r(m,"errors"))throw new Error("Doctor healthScore contradicts its host/project components.")}let v=0,k=0;for(let c of t){let m=Array.isArray(c.probes)?c.probes:[],y=s(c.diagnosis),p=y?s(y.coverage):null,b=m.filter(g=>s(g)?.status==="fail").length+(Array.isArray(c.issues)?c.issues.length:0),n=p?r(p,"blockingFindings"):b;v+=n;let d=s(c.probeSummary);if(d){if(r(d,"total")!==r(d,"passed")+r(d,"warnings")+r(d,"failed"))throw new Error("Doctor project probeSummary total contradicts its probe counts.");let g=r(d,"blockingFindings");if(g!==n)throw new Error("Doctor project probeSummary.blockingFindings contradicts its canonical diagnosis.");let A=g>0?"blocked":r(d,"advisoryFindings")>0?"attention":"passed";if(d.verdict!==A||c.verdict!==A)throw new Error("Doctor project verdict contradicts its probe summary.");k+=r(d,"advisoryFindings");}}if(v>0&&f===0)throw new Error("Doctor evidence contains blocking findings but healthScore.errors is zero.");let w=s(o.summary);if(w&&Array.isArray(o.projects)){if(w.blockingFindings!==void 0&&r(w,"blockingFindings")!==v)throw new Error("Doctor workspace summary blockingFindings contradicts project diagnosis.");if(w.advisoryFindings!==void 0&&r(w,"advisoryFindings")!==k)throw new Error("Doctor workspace summary advisoryFindings contradicts project diagnosis.")}}export{R as a,O as b,M as c,z as d};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-W5ZFXKSL.js';import {a as a$1}from'./chunk-GR6442P7.js';import {f,e}from'./chunk-ADL3CK44.js';import {h,i}from'./chunk-5EPPPMAS.js';import {createHash}from'crypto';import c from'path';import {execa}from'execa';import u from'fs-extra';var V=h.projectTestCoverage.schemaVersion,k=i.projectTestCoverage,$=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","mix.exs","deps.edn","project.clj","build.sbt","CMakeLists.txt","meson.build","deno.json","deno.jsonc"];function p(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:0}function m(e,t,o=0){let n=p(e),r=Math.min(p(t),n),i=p(o);return {total:n,covered:r,skipped:i,percent:n>0?Math.round(r/n*1e4)/100:null}}function W(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;return m(t.total,t.covered,t.skipped)}function y(e,t){let o=c.isAbsolute(t)?t:c.resolve(e,t),n=c.relative(e,o);return n&&!n.startsWith("..")?n.split(c.sep).join("/"):t}async function x(e){return createHash("sha256").update(await u.readFile(e)).digest("hex")}async function H(e){let t=c.resolve(e);for(;;){if(await u.pathExists(c.join(t,".workspai","project.json"))||await u.pathExists(c.join(t,".rapidkit","project.json"))||(await Promise.all($.map(r=>u.pathExists(c.join(t,r))))).some(Boolean))return t;let n=c.dirname(t);if(n===t)return c.resolve(e);t=n;}}async function D(e){if(await u.pathExists(c.join(e,"deno.json"))||await u.pathExists(c.join(e,"deno.jsonc")))return "deno";if(await u.pathExists(c.join(e,"bun.lock"))||await u.pathExists(c.join(e,"bun.lockb")))return "bun";if(await u.pathExists(c.join(e,"package.json")))return "node";if(await u.pathExists(c.join(e,"pyproject.toml"))||await u.pathExists(c.join(e,"requirements.txt")))return "python";if(await u.pathExists(c.join(e,"go.mod")))return "go";let t=await u.pathExists(c.join(e,"pom.xml"))||await u.pathExists(c.join(e,"build.gradle"))||await u.pathExists(c.join(e,"build.gradle.kts"));return t&&(await P(e,o=>o.endsWith(".kt")||o.endsWith(".kts")&&o!=="build.gradle.kts"&&o!=="settings.gradle.kts",4)).length>0?"kotlin":t?"java":await u.pathExists(c.join(e,"Cargo.toml"))?"rust":await u.pathExists(c.join(e,"composer.json"))?"php":await u.pathExists(c.join(e,"Gemfile"))?"ruby":await u.pathExists(c.join(e,"mix.exs"))?"elixir":await u.pathExists(c.join(e,"deps.edn"))||await u.pathExists(c.join(e,"project.clj"))?"clojure":await u.pathExists(c.join(e,"build.sbt"))?"scala":await u.pathExists(c.join(e,"CMakeLists.txt"))?(await P(e,n=>/\.(c|cc|cpp|cxx)$/.test(n),3)).some(n=>/\.(cc|cpp|cxx)$/.test(n))?"cpp":"c":(await P(e,o=>/\.(sln|csproj)$/.test(o),2)).length>0?"dotnet":"unknown"}async function P(e,t,o=5){let n=[],r=[{dir:e,depth:0}],i=new Set([".git",".workspai",".rapidkit","node_modules",".venv","vendor","deps"]);for(;r.length>0;){let s=r.shift();if(!s)break;let a=await u.readdir(s.dir,{withFileTypes:true}).catch(()=>[]);for(let l of a){if(i.has(l.name)||a$1(l.name))continue;let d=c.join(s.dir,l.name),g=c.relative(e,d).split(c.sep).join("/");l.isFile()&&t(l.name,g)&&n.push(d),l.isDirectory()&&s.depth<o&&r.push({dir:d,depth:s.depth+1});}}return n}async function L(e,t){let o=await u.readJson(t),n=o.total??o,r={};for(let s of ["lines","branches","functions","statements"]){let a=W(n[s]);a&&(r[s]=a);}let i=[];for(let[s,a]of Object.entries(o)){if(s==="total"||!a||typeof a!="object"||Array.isArray(a))continue;let l=a,d={};for(let g of ["lines","branches","functions","statements"]){let b=W(l[g]);b&&(d[g]=b);}i.push({path:y(e,s),metrics:d});}return {metrics:r,files:i,source:{format:"istanbul-json",path:t,sha256:await x(t)}}}async function G(e,t){let o=await u.readJson(t),n=o.totals??{},r={lines:m(n.num_statements,n.covered_lines)};p(n.num_branches)>0&&(r.branches=m(n.num_branches,n.covered_branches));let i=[];for(let[s,a]of Object.entries(o.files??{})){let l=a?.summary??{};i.push({path:y(e,s),metrics:{lines:m(l.num_statements,l.covered_lines),...p(l.num_branches)>0?{branches:m(l.num_branches,l.covered_branches)}:{}}});}return {metrics:r,files:i,source:{format:"coverage-py-json",path:t,sha256:await x(t)}}}function j(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,o=p(t.count),n=p(t.covered);return o>0?m(o,n):void 0}async function q(e,t){let o=await u.readJson(t),n=Array.isArray(o.data)?o.data[0]??{}:o,r=n.totals??{},i={};i.lines=j(r.lines),i.functions=j(r.functions),i.branches=j(r.branches),i.statements=j(r.regions);let s=[];for(let a of Array.isArray(n.files)?n.files:[]){if(!a||typeof a!="object"||Array.isArray(a))continue;let l=a,d=l.summary??{};s.push({path:y(e,String(l.filename??"unknown")),metrics:{lines:j(d.lines),functions:j(d.functions),branches:j(d.branches),statements:j(d.regions)}});}return {metrics:i,files:s,source:{format:"llvm-cov-json",path:t,sha256:await x(t)}}}async function A(e,t){let o=await u.readFile(t,"utf8"),n=[],r="",i=0,s=0,a=0,l=0,d=0,g=0,b=v=>{r&&(n.push({path:y(e,r),metrics:{lines:m(v.lineTotal,v.lineCovered),functions:m(v.functionTotal,v.functionCovered),branches:m(v.branchTotal,v.branchCovered)}}),i+=v.lineTotal,s+=v.lineCovered,a+=v.functionTotal,l+=v.functionCovered,d+=v.branchTotal,g+=v.branchCovered);},h={lineTotal:0,lineCovered:0,functionTotal:0,functionCovered:0,branchTotal:0,branchCovered:0};for(let v of o.split(/\r?\n/))v.startsWith("SF:")?r=v.slice(3):v.startsWith("LF:")?h.lineTotal=p(v.slice(3)):v.startsWith("LH:")?h.lineCovered=p(v.slice(3)):v.startsWith("FNF:")?h.functionTotal=p(v.slice(4)):v.startsWith("FNH:")?h.functionCovered=p(v.slice(4)):v.startsWith("BRF:")?h.branchTotal=p(v.slice(4)):v.startsWith("BRH:")?h.branchCovered=p(v.slice(4)):v==="end_of_record"&&(b(h),r="",h={lineTotal:0,lineCovered:0,functionTotal:0,functionCovered:0,branchTotal:0,branchCovered:0});return {metrics:{lines:m(i,s),functions:m(a,l),branches:m(d,g)},files:n,source:{format:"lcov",path:t,sha256:await x(t)}}}async function U(e,t){let o=await u.readFile(t,"utf8"),n=new Map;for(let s of o.split(/\r?\n/).slice(1)){let a=/^(.+?):\d+\.\d+,\d+\.\d+\s+(\d+)\s+(\d+)$/.exec(s.trim());if(!a)continue;let l=n.get(a[1])??{total:0,covered:0},d=p(a[2]);l.total+=d,p(a[3])>0&&(l.covered+=d),n.set(a[1],l);}let r=[...n.entries()].map(([s,a])=>({path:y(e,s),metrics:{statements:m(a.total,a.covered)}})),i=[...n.values()].reduce((s,a)=>({total:s.total+a.total,covered:s.covered+a.covered}),{total:0,covered:0});return {metrics:{statements:m(i.total,i.covered)},files:r,source:{format:"go-coverprofile",path:t,sha256:await x(t)}}}function T(e,t){let n=[...e.matchAll(new RegExp(`<counter\\s+type=["']${t}["']\\s+missed=["'](\\d+)["']\\s+covered=["'](\\d+)["']\\s*\\/?\\s*>`,"gi"))].at(-1);return n?m(Number(n[1])+Number(n[2]),n[2]):void 0}async function C(e,t){let o=await u.readFile(e,"utf8"),n={};if(t==="cobertura-xml"){let r=/<coverage\b([^>]*)>/i.exec(o)?.[1]??"",i=/\bline-rate=["']([\d.]+)["']/i.exec(r)?.[1],s=/\bbranch-rate=["']([\d.]+)["']/i.exec(r)?.[1];i&&(n.lines=m(1e4,Math.round(Number(i)*1e4))),s&&(n.branches=m(1e4,Math.round(Number(s)*1e4)));}if(t==="clover-xml"){let i=[...o.matchAll(/<metrics\b([^>]*)\/?>/gi)].at(-1)?.[1]??"",s=g=>p(new RegExp(`\\b${g}=["'](\\d+)["']`,"i").exec(i)?.[1]),a=s("statements"),l=s("methods"),d=s("conditionals");a>0&&(n.statements=m(a,s("coveredstatements"))),l>0&&(n.functions=m(l,s("coveredmethods"))),d>0&&(n.branches=m(d,s("coveredconditionals")));}return n.lines??=T(o,"LINE"),n.branches??=T(o,"BRANCH"),n.functions??=T(o,"METHOD"),n.statements??=T(o,"INSTRUCTION"),{metrics:n,files:[],source:{format:t,path:e,sha256:await x(e)}}}async function z(e){let t=await u.readFile(e,"utf8"),o=/<scoverage\b([^>]*)>/i.exec(t)?.[1]??"",n=b=>p(new RegExp(`\\b${b}=["']([\\d.]+)["']`,"i").exec(o)?.[1]),r=n("statement-count"),i=n("statements-invoked"),s=n("branch-count"),a=n("branches-invoked"),l=n("statement-rate"),d=n("branch-rate"),g={};return r>0?g.statements=m(r,i):l>0&&(g.statements=m(1e4,Math.round(l*100))),s>0?g.branches=m(s,a):d>0&&(g.branches=m(1e4,Math.round(d*100))),{metrics:g,files:[],source:{format:"scoverage-xml",path:e,sha256:await x(e)}}}async function B(e,t){let o=await u.readJson(t),n=new Map;for(let s of Object.values(o)){let a=s?.coverage;if(!(!a||typeof a!="object"||Array.isArray(a)))for(let[l,d]of Object.entries(a)){if(!Array.isArray(d))continue;let g=n.get(l)??[];d.forEach((b,h)=>{typeof b=="number"&&(g[h]=Math.max(g[h]??0,b));}),n.set(l,g);}}let r=[...n.entries()].map(([s,a])=>{let l=a.filter(d=>typeof d=="number");return {path:y(e,s),metrics:{lines:m(l.length,l.filter(d=>d>0).length)}}}),i=r.reduce((s,a)=>{let l=a.metrics.lines;return {total:s.total+(l?.total??0),covered:s.covered+(l?.covered??0)}},{total:0,covered:0});return {metrics:{lines:m(i.total,i.covered)},files:r,source:{format:"simplecov-json",path:t,sha256:await x(t)}}}async function K(e){let t=[{relativePath:"coverage/coverage-summary.json",parser:r=>L(e,r)},{relativePath:"coverage.json",parser:async r=>{let i=await u.readJson(r);return Array.isArray(i.data)?q(e,r):G(e,r)}},{relativePath:"coverage/lcov.info",parser:r=>A(e,r)},{relativePath:"cover/lcov.info",parser:r=>A(e,r)},{relativePath:"lcov.info",parser:r=>A(e,r)},{relativePath:"coverage.out",parser:r=>U(e,r)},{relativePath:"target/site/jacoco/jacoco.xml",parser:r=>C(r,"jacoco-xml")},{relativePath:"build/reports/jacoco/test/jacocoTestReport.xml",parser:r=>C(r,"jacoco-xml")},{relativePath:"coverage.xml",parser:r=>C(r,"clover-xml")},{relativePath:".resultset.json",parser:r=>B(e,r)}];for(let r of t){let i=c.join(e,r.relativePath);if(await u.pathExists(i))return r.parser(i)}let n=(await P(e,(r,i)=>r==="coverage.cobertura.xml"||r==="jacoco.xml"||r==="clover.xml"||r==="scoverage.xml"||i.endsWith("/coverage-summary.json"),7)).sort()[0];return n?n.endsWith("coverage-summary.json")?L(e,n):n.endsWith("jacoco.xml")?C(n,"jacoco-xml"):n.endsWith("coverage.cobertura.xml")?C(n,"cobertura-xml"):n.endsWith("scoverage.xml")?z(n):C(n,"clover-xml"):null}async function X(e){return u.readJson(c.join(e,"package.json")).catch(()=>null)}async function Q(e,t){let o=(n,r)=>({cwd:e,executable:n,args:r});if(t==="node"||t==="bun"){let r=(await X(e))?.scripts??{},i=["test:coverage","test:cov","coverage"].find(a=>typeof r[a]=="string"),s=t==="bun"?"bun":await u.pathExists(c.join(e,"pnpm-lock.yaml"))?"pnpm":await u.pathExists(c.join(e,"yarn.lock"))?"yarn":"npm";if(i)return {runner:String(r[i]).split(/\s+/)[0]||s,invocations:[o(s,s==="yarn"?[i]:["run",i])],diagnostics:[]};if(typeof r.test=="string"){let a=s==="yarn"?["test","--coverage"]:s==="bun"?["test","--coverage","--coverage-reporter=lcov"]:["test","--","--coverage"];return {runner:String(r.test).split(/\s+/)[0]||s,invocations:[o(s,a)],diagnostics:[]}}return {runner:null,invocations:[],diagnostics:["No project-owned test or coverage script was detected."]}}if(t==="deno")return {runner:"deno",invocations:[o("deno",["test","--coverage=coverage"]),o("deno",["coverage","--lcov","--output=coverage/lcov.info","coverage"])],diagnostics:[]};if(t==="python")return {runner:"pytest-cov",invocations:[o(await u.pathExists(c.join(e,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python"))?c.join(".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python"):process.platform==="win32"?"python":"python3",["-m","pytest","--cov=.","--cov-report=json:coverage.json"])],diagnostics:[]};if(t==="go")return {runner:"go test",invocations:[o("go",["test","./...","-coverprofile=coverage.out"])],diagnostics:[]};if(t==="java"){let n=await u.pathExists(c.join(e,"gradlew")),r=await u.pathExists(c.join(e,"gradlew.bat")),i=n||r,s=await u.pathExists(c.join(e,"mvnw")),a=await u.pathExists(c.join(e,"mvnw.cmd")),l=i?process.platform==="win32"&&r?".\\gradlew.bat":"./gradlew":await u.pathExists(c.join(e,"pom.xml"))?process.platform==="win32"&&a?".\\mvnw.cmd":s?"./mvnw":"mvn":"gradle";return {runner:i?"jacoco/gradle":"jacoco/maven",invocations:[o(l,i?["test","jacocoTestReport"]:["test","jacoco:report"])],diagnostics:[]}}return t==="dotnet"?{runner:"dotnet coverlet",invocations:[o("dotnet",["test","--collect:XPlat Code Coverage"])],diagnostics:[]}:t==="rust"?{runner:"cargo llvm-cov",invocations:[o("cargo",["llvm-cov","--json","--output-path","coverage.json"])],diagnostics:["cargo-llvm-cov must be available in the project toolchain."]}:t==="php"?{runner:"phpunit",invocations:[o(process.platform==="win32"?"vendor\\bin\\phpunit.bat":"vendor/bin/phpunit",["--coverage-clover","coverage.xml"])],diagnostics:[]}:t==="ruby"?{runner:"simplecov",invocations:[o("bundle",["exec","rspec"])],diagnostics:["The test suite must enable SimpleCov to emit .resultset.json."]}:t==="elixir"?{runner:"mix cover",invocations:[o("mix",["test","--cover"])],diagnostics:["Configure ExCoveralls for JSON or LCOV interchange when machine-readable coverage is required."]}:t==="clojure"?{runner:"cloverage",invocations:[o("clojure",["-M:coverage"])],diagnostics:["The project must declare a coverage alias such as cloverage."]}:t==="scala"?{runner:"sbt-scoverage",invocations:[o("sbt",["clean","coverage","test","coverageReport"])],diagnostics:["The project must declare the scoverage plugin."]}:t==="kotlin"?{runner:"jacoco/gradle",invocations:[o(await u.pathExists(c.join(e,process.platform==="win32"?"gradlew.bat":"gradlew"))?process.platform==="win32"?".\\gradlew.bat":"./gradlew":"gradle",["test","jacocoTestReport"])],diagnostics:["The project must declare the JaCoCo Gradle plugin."]}:t==="c"||t==="cpp"?{runner:"CTest/LLVM coverage",invocations:[o("ctest",["--test-dir","build","--output-on-failure"])],diagnostics:["The native build must be instrumented for coverage and export LCOV, Cobertura, or LLVM JSON evidence."]}:{runner:null,invocations:[],diagnostics:["Project runtime could not be detected."]}}function Y(e,t){let o=e?c.relative(e,t).split(c.sep).join("/"):c.resolve(t),n=c.basename(t).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"project",r=createHash("sha256").update(o).digest("hex").slice(0,12);return `${n}--${r}`}function Z(e){return e.lines?"lines":e.statements?"statements":e.branches?"branches":"functions"}async function ue(e$1={}){let t=await H(e$1.projectPath??process.cwd()),o=a(t),n=await D(t),r=Math.max(0,Math.min(100,Math.round(e$1.target??80))),i=await Q(t,n),s=[],a$1=Date.now();if(e$1.run)for(let f of i.invocations){let w=await execa(f.executable,f.args,{cwd:f.cwd,reject:false,timeout:6e5}).catch(()=>({exitCode:1}));if(s.push(Number(w.exitCode??1)),Number(w.exitCode??1)!==0)break}let l=await K(t).catch(()=>null),d=l?Z(l.metrics):"lines",g=l?.metrics[d]?.percent??null,b=e$1.run&&s.some(f=>f!==0)?"failed":g===null?"unavailable":g>=r?"passed":"below-target",h=Y(o,t),v=c.join(t,k),E=o?`.workspai/reports/projects/${h}/project-test-coverage-last-run.json`:null,R={schemaVersion:V,generatedAt:new Date().toISOString(),status:b,project:{id:h,name:c.basename(t),path:t,workspacePath:o},runtime:n,runner:i.runner,target:{metric:d,percent:r},metrics:l?.metrics??{},files:l?.files??[],lowCoverageFiles:(l?.files??[]).map(f=>{let w=f.metrics[d]??f.metrics.lines??f.metrics.statements;return {path:f.path,percent:w?.percent??null,uncovered:Math.max(0,(w?.total??0)-(w?.covered??0))}}).filter(f=>f.percent===null||f.percent<r).sort((f,w)=>w.uncovered-f.uncovered||f.path.localeCompare(w.path)),source:l?.source??{format:"unknown",path:null,sha256:null},execution:{requested:e$1.run===true,invocations:i.invocations,exitCodes:s,durationMs:Date.now()-a$1},diagnostics:[...i.diagnostics,...l?[]:["No supported machine-readable coverage artifact was found."]],artifactPaths:{project:v,workspaceLatest:o?c.join(o,k):null,workspaceProject:o&&E?c.join(o,E):null}};return o&&E&&await f(o,k,[{relativePath:k,payload:R},{relativePath:E,payload:R}]),await e(t,k,R),R}export{V as a,k as b,ue as c};
@@ -0,0 +1,2 @@
1
+ import {p,k,l,j}from'./chunk-5ZA4JYOP.js';import {a as a$1}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {e as e$1,d,b}from'./chunk-EWZZUQBR.js';import {a}from'./chunk-DOIZANFA.js';import {e as e$2}from'./chunk-ADL3CK44.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import {f,e}from'./chunk-5EPPPMAS.js';import k$1 from'path';import V from'fs-extra';import {spawnSync}from'child_process';function ue(){let e={...process.env};return delete e.GIT_DIR,delete e.GIT_WORK_TREE,delete e.GIT_INDEX_FILE,delete e.GIT_PREFIX,e}function F(e,t,a){let r=spawnSync("git",t,{cwd:e,env:ue(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(r.status!==0)return {ok:false,stdout:""};let c=r.stdout??"";return {ok:true,stdout:a?.preserveWhitespace?c:c.trim()}}function ge(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return t===".workspai/AGENT-GROUNDING.md"?true:[".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(a=>t.startsWith(a))}function ke(e){let t=[],a=[],r=[];for(let c of e.split(`
2
+ `)){if(!c.trim())continue;let n=c.slice(0,2),i=c.slice(3).trim();if(i&&!ge(i)){if(n==="??"){a.push(i);continue}n.includes("D")&&r.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(a)].sort(),deletedFiles:[...new Set(r)].sort()}}function Q(e,t){let a={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=F(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return a;let c=F(e,["rev-parse","--abbrev-ref","HEAD"]),n=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"],{preserveWhitespace:true}),p=ke(i.stdout),m=p.changedFiles.length>0||p.untrackedFiles.length>0||p.deletedFiles.length>0;return {available:true,branch:c.ok?c.stdout:void 0,commit:n.ok?n.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:p.changedFiles,untrackedFiles:p.untrackedFiles,deletedFiles:p.deletedFiles}}var oe=f.snapshot,L=f.diff,_=e.snapshot,ae=e.diff,he=f.impact,we=e.impact;function ye(e){if(e.model.projectTopology||!e.model.graph||e.modelHash!==e$1(e.model))return null;let t={...e.model,projectTopology:e.model.graph,graph:e.model.graph};return {...e,modelHash:d(t),model:t}}function ne(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function We(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function se(e,t){return k$1.isAbsolute(t)?t:k$1.join(e,t)}async function be(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion===oe){a$2(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=a;if(!r.model||r.model.schemaVersion!==j)throw new Error(`Invalid workspace model snapshot: ${e}`);let c=d(r.model);if(r.modelHash!==c){let n=ye(r);if(!n)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:n.model,hash:n.modelHash}}return {model:r.model,hash:r.modelHash}}if(a.schemaVersion===j){a$2(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=a;return {model:r,hash:d(r)}}throw a.schemaVersion===L?new Error(`workspace diff --from received a diff report (${k$1.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${_}. To analyze an existing diff report, run: npx workspai workspace impact --from ${k$1.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(a.schemaVersion)}`)}async function ve(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion!==L)return null;a$2(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=a;if(!r.currentModel||r.currentModel.schemaVersion!==j||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==d(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Ye(e){let t=e.model??await p({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:oe,generatedAt:(e.now??new Date).toISOString(),modelHash:d(t),modelRef:k,model:t}}async function Qe(e,t){return e$2(t,_,a(e))}function x(e){return {name:e.name,path:e.path,kind:e.kind,category:e.category,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function w(e,t){e.push(t);}function Me(e,t){let a=[],r=["name","profile","type"],c=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let n of r){let i=e.workspace[n],p=t.workspace[n];b(i)!==b(p)&&w(a,{type:"workspace.changed",severity:"info",target:`workspace.${n}`,message:`Workspace metadata field changed: ${String(n)}`,before:i,after:p});}for(let n of c){let i=e.identity[n],p=t.identity[n];b(i)!==b(p)&&w(a,{type:"workspace.changed",severity:"info",target:`identity.${n}`,message:`Workspace identity field changed: ${String(n)}`,before:i,after:p});}return b(e.policies)!==b(t.policies)&&w(a,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),b(e.discovery)!==b(t.discovery)&&w(a,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&w(a,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),a}function je(e,t){let a=e.validation??null,r=t.validation??null;return b(a)===b(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:a,after:r}]}function Ie(e,t){let a=[],r=new Map(e.projects.map(n=>[n.path,n])),c=new Map(t.projects.map(n=>[n.path,n]));for(let[n,i]of c.entries()){let p=r.get(n);if(!p){w(a,{type:"project.added",severity:"info",target:n,message:`Project added: ${i.name}`,after:x(i)});continue}let m=x(p),l=x(i);if(b(m)!==b(l)){let u=p.runtime!==i.runtime||p.framework!==i.framework;w(a,{type:"project.changed",severity:u?"warning":"info",target:n,message:`Project changed: ${i.name}`,before:m,after:l});}}for(let[n,i]of r.entries())c.has(n)||w(a,{type:"project.removed",severity:"warning",target:n,message:`Project removed: ${i.name}`,before:x(i)});return a.sort((n,i)=>`${n.type}:${n.target}`.localeCompare(`${i.type}:${i.target}`))}async function Pe(e){let t=k$1.resolve(e.workspacePath),a=ne(e.fromPath),r=a?We(e.fromPath):void 0,c=e.fromPath;if(a){let f=k$1.join(t,_);if(!await V.pathExists(f))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");c=_;}let n=se(t,c),i=await be(n),p$1=e.model??await p({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=d(p$1),l=[...Me(i.model,p$1),...Ie(i.model,p$1),...je(i.model,p$1)],u;e.includeGitObservation!==false&&(u=e.gitObservation??Q(t,{ref:r}),u.available&&Ee(l,u,p$1));let v=l.filter(f=>f.type.startsWith("git.")).length,R=i.hash!==m,y=a?`git:${r??"HEAD"}`:k$1.relative(t,n).split(k$1.sep).join("/");return {schemaVersion:L,generatedAt:(e.now??new Date).toISOString(),fromRef:y,toRef:k,fromHash:i.hash,toHash:m,summary:{changed:R||v>0,addedProjects:l.filter(f=>f.type==="project.added").length,removedProjects:l.filter(f=>f.type==="project.removed").length,changedProjects:l.filter(f=>f.type==="project.changed").length,workspaceChanges:l.filter(f=>f.type==="workspace.changed").length,validationChanges:l.filter(f=>f.type==="validation.changed").length,gitChangedFiles:v},git:u?.available?Oe(u,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:l,currentModel:p$1}}async function Ze(e,t){return e$2(t,ae,a(e))}function I(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Z(e){return e.reduce((t,a)=>I(a)>I(t)?a:t,"none")}var N=["none","low","medium","high","critical"];function Re(e){let t=Math.max(1,I(e)-1);return N[t]}function Ce(e){let t=Math.min(N.length-1,I(e)+1);return N[t]}function ee(e){return e.join(" ")}function h(e,t,a,r){return {id:e,label:t,scope:r.scope,project:r.project,display:ee(["npx","workspai",...a]),execute:ee(["npx","--yes","--package","workspai","workspai",...a]),required:r.required!==false}}function te(e){let t=`project:${e.name}`,a=e.commands.fleetStages;return [h(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("init")}),h(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("test")}),h(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("build")}),h(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("start")})]}function T(){return [h("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),h("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),h("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),h("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),h("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),h("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Se(e,t){let a=t.split(k$1.sep).join("/");return e.projects.filter(c=>{let n=c.path.split(k$1.sep).join("/");return a===n||a.startsWith(`${n}/`)}).sort((c,n)=>n.path.length-c.path.length)[0]}function Ee(e,t,a){let r=new Set(e.map(n=>n.target)),c=(n,i)=>{let p=i.split(k$1.sep).join("/"),m=`git:${p}`;if(r.has(m))return;let l=Se(a,p),u=l?`${l.name} (${l.path})`:"workspace";w(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:m,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${u}: ${p}`,after:{path:p,project:l?.name,projectPath:l?.path}}),r.add(m);};for(let n of t.changedFiles)c("git.file.changed",n);for(let n of t.untrackedFiles)c("git.untracked",n);for(let n of t.deletedFiles)c("git.deleted",n);}function Oe(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Ae(e){let t=new Set,a=[];for(let r of e){let c=`${r.scope}:${r.project??""}:${r.display}`;t.has(c)||(t.add(c),a.push(r));}return a}function De(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function $e(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function Fe(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(a=>a.severity==="critical"?false:a.type.startsWith("git.")||a.type==="validation.changed")?e.risk:I(e.risk)>=I("high")||e.risk==="medium"?"low":e.risk}function re(e,t){if(!e||e==="workspace")return true;let a=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,k$1.basename(t.path),t.absolutePath].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim().toLowerCase()).includes(a)}function xe(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(a=>a.project?.name??a.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function et(e){let t=k$1.resolve(e.workspacePath),a=ne(e.fromPath),r=e.diff;if(!r&&!a){let o=se(t,e.fromPath);r=await ve(o)??void 0;}r||(r=await Pe({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let c$1=new Map(r.currentModel.projects.map(o=>[o.path,o])),n=new Map(r.currentModel.projects.map(o=>[o.name,o])),i=r.changes.filter(o=>o.type.startsWith("project.")),p=new Map;for(let o of i){let d=(c$1.get(o.target)??(typeof o.before?.name=="string"?n.get(o.before.name):void 0))?.path??o.target,W=p.get(d)??[];W.push(o),p.set(d,W);}let m=[];for(let[o,s]of p.entries()){let d=c$1.get(o);if(d&&!re(e.scope,d))continue;let W=Z(s.map(De)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):o);m.push({id:`project:${C}`,scope:"project",target:o,title:`Project impact: ${C}`,summary:s.map(M=>M.message).join(" "),risk:W,reasons:s.map(M=>`${M.type}: ${M.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?te(d):T()});}let l$1=l(r.currentModel),u=l$1?a$1(l$1):void 0,v=new Set(m.map(o=>o.project?.name).filter(o=>typeof o=="string")),R=new Map;for(let o of m)if(o.project?.name){let s=u?.byId.get(o.project.name);s&&(o.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(o.risk=Ce(o.risk),o.reasons=[...o.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),o.origin="direct",o.distance=0,R.set(o.project.name,o.risk);}let y=[],f=0;if(l$1&&v.size>0){let o=c(l$1,v);for(let s of o.values()){if(s.distance===0||v.has(s.id))continue;let d=n.get(s.id);if(d&&!re(e.scope,d))continue;let W=s.path[0],C=s.path[s.path.length-2]??W,M=R.get(W)??"medium",de=Re(M),j=u?.byId.get(s.id);f=Math.max(f,s.distance),y.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${W}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:de,reasons:[`graph.dependent: depends on ${C}${s.via?` via ${s.via}`:""} (path ${s.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?te(d):T(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...j?{centrality:{fanIn:j.fanIn,fanOut:j.fanOut,reach:j.reach,betweenness:j.betweenness,isHotspot:j.isHotspot}}:{}});}}y.sort((o,s)=>o.target.localeCompare(s.target));let ie=u?u.hotspots.flatMap(o=>{let s=u.byId.get(o);return s?[{project:o,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],ce=r.changes.filter(o=>!o.type.startsWith("project.")),K=r.currentModel.summary?.projectCount??r.currentModel.projects.length,P=ce.map(o=>({id:`workspace:${o.target}`,scope:"workspace",target:o.target,title:`Workspace impact: ${o.target}`,summary:o.message,risk:$e(o,{projectCount:K}),reasons:[`${o.type}: ${o.message}`],verification:T()})),B=Ae([...m.flatMap(o=>o.verification),...y.flatMap(o=>o.verification),...P.flatMap(o=>o.verification),...r.summary.changed?T():[]]).filter(o=>o.required),pe=Z([...m.map(o=>o.risk),...y.map(o=>o.risk),...P.map(o=>o.risk)]),q=Fe({risk:pe,affectedProjects:m.length,projectCount:K,changes:r.changes}),z={changed:r.summary.changed,risk:q,affectedProjects:m.length,workspaceItems:P.length,recommendedCommands:B.length,blastRadius:{directlyAffected:m.length,transitivelyAffected:y.length,maxDistance:f,graphEdges:l$1?.edges.length??0}};return {schemaVersion:he,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:ae,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:z,affectedProjects:m.sort((o,s)=>o.target.localeCompare(s.target)),transitiveImpact:y,criticalPathHotspots:ie,workspaceImpact:P.sort((o,s)=>o.target.localeCompare(s.target)),verificationPlan:B,agentBrief:xe({changed:z.changed,risk:q,affectedProjects:m,workspaceImpact:P}),diff:r}}async function tt(e,t){return e$2(t,we,a(e))}export{Q as a,oe as b,L as c,_ as d,ae as e,he as f,we as g,ye as h,ne as i,We as j,Ye as k,Qe as l,Pe as m,Ze as n,T as o,et as p,tt as q};