workspai 0.55.1 → 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 (174) hide show
  1. package/README.md +36 -8
  2. package/contracts/adopt-effects.v1.json +72 -0
  3. package/contracts/artifact-remediation-plan.v1.json +110 -2
  4. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +33 -1
  5. package/contracts/doctor-project-evidence.v1.json +95 -2
  6. package/contracts/doctor-remediation-plan.v1.json +29 -2
  7. package/contracts/doctor-workspace-evidence.v1.json +97 -2
  8. package/contracts/extension-cli-compatibility.v1.json +7 -1
  9. package/contracts/published-contract-catalog.v1.json +30 -0
  10. package/contracts/runtime-command-surface.v1.json +63 -0
  11. package/contracts/workspace-intelligence/doctor-capabilities.v1.json +133 -0
  12. package/contracts/workspace-intelligence/doctor-diagnosis.v1.json +273 -0
  13. package/contracts/workspace-intelligence/doctor-graph-diagnosis.v1.json +3 -0
  14. package/contracts/workspace-intelligence/doctor-receipt.v1.json +136 -0
  15. package/contracts/workspace-intelligence/doctor-summary.v1.json +101 -0
  16. package/contracts/workspace-intelligence/doctor-validation.v1.json +109 -0
  17. package/contracts/workspace-intelligence/project-context-agent.v1.json +110 -0
  18. package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +25 -0
  19. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +36 -0
  20. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +54 -0
  21. package/dist/analyze-HJ774J3E.js +1 -0
  22. package/dist/{artifact-remediation-plan-O3YIULQN.js → artifact-remediation-plan-BPLON5VX.js} +1 -1
  23. package/dist/autopilot-release-WIFFFQKW.js +1 -0
  24. package/dist/capabilities-command-44JVOE5S.js +1 -0
  25. package/dist/chunk-2647BYBC.js +1 -0
  26. package/dist/chunk-3U4VLIGW.js +1 -0
  27. package/dist/chunk-5EPPPMAS.js +1 -0
  28. package/dist/{chunk-AMB42V2F.js → chunk-64JUYYRC.js} +1 -1
  29. package/dist/chunk-6OFGLNFS.js +1 -0
  30. package/dist/chunk-75HOCFNH.js +1 -0
  31. package/dist/{chunk-M5ICGR55.js → chunk-7WUT5ZSO.js} +1 -1
  32. package/dist/chunk-AA4PNQKR.js +1 -0
  33. package/dist/{chunk-WIO6L24E.js → chunk-ADL3CK44.js} +1 -1
  34. package/dist/chunk-AO2ZI42U.js +4 -0
  35. package/dist/chunk-CNWUIXF3.js +1 -0
  36. package/dist/chunk-D4RST2HE.js +1 -0
  37. package/dist/chunk-DF4NWPB7.js +8 -0
  38. package/dist/chunk-DT4X7I5M.js +81 -0
  39. package/dist/{chunk-HY3RMPW5.js → chunk-E53BGUOW.js} +1 -1
  40. package/dist/chunk-GBMCHFOV.js +1 -0
  41. package/dist/chunk-GDKFN3CM.js +8 -0
  42. package/dist/chunk-GTJY55QK.js +5 -0
  43. package/dist/chunk-GXTCU4WF.js +1 -0
  44. package/dist/{chunk-WSAFBPS5.js → chunk-IUYZ3NHS.js} +4 -4
  45. package/dist/chunk-IXOLHPTN.js +6 -0
  46. package/dist/chunk-IZLEMTES.js +1 -0
  47. package/dist/chunk-L36ZASME.js +1 -0
  48. package/dist/chunk-LYVDRRDO.js +2 -0
  49. package/dist/chunk-N2BIIUDH.js +4 -0
  50. package/dist/{chunk-IBPPMOHM.js → chunk-NHTLE3WN.js} +1 -1
  51. package/dist/chunk-NS53IPAC.js +1 -0
  52. package/dist/{chunk-NWQ5VWUW.js → chunk-P475BOJW.js} +1 -1
  53. package/dist/chunk-PKIRVQLG.js +1 -0
  54. package/dist/chunk-QHY6F4SS.js +2 -0
  55. package/dist/chunk-QK5QOXOE.js +13 -0
  56. package/dist/chunk-RPHM7LQW.js +36 -0
  57. package/dist/chunk-SNO3WG4V.js +2 -0
  58. package/dist/chunk-T5YRFRJV.js +1 -0
  59. package/dist/chunk-TTFQWH55.js +91 -0
  60. package/dist/chunk-UQEQ6CXU.js +1 -0
  61. package/dist/chunk-V5EYVQ63.js +1 -0
  62. package/dist/{chunk-HUPLAFZQ.js → chunk-VL3APTVB.js} +1 -1
  63. package/dist/chunk-VUR7H2FU.js +2 -0
  64. package/dist/chunk-VZPWIILU.js +1 -0
  65. package/dist/{chunk-MRFN5ZQP.js → chunk-W5ZFXKSL.js} +1 -1
  66. package/dist/chunk-WP3CXMVA.js +2 -0
  67. package/dist/chunk-X7FYEKLI.js +1 -0
  68. package/dist/{chunk-KFKZOPZC.js → chunk-XMTLKDPP.js} +1 -1
  69. package/dist/chunk-YJTEMJFV.js +3 -0
  70. package/dist/chunk-YM77FQB3.js +8 -0
  71. package/dist/{chunk-FZCYTRBQ.js → chunk-Z57G62KE.js} +1 -1
  72. package/dist/chunk-ZCPT6KC3.js +6 -0
  73. package/dist/chunk-ZPA6ECBJ.js +7 -0
  74. package/dist/{create-3NSOY7CA.js → create-O2KLTN5H.js} +1 -1
  75. package/dist/doctor-AL5YWO5X.js +1 -0
  76. package/dist/index.d.ts +19 -0
  77. package/dist/index.js +169 -167
  78. package/dist/pipeline-4ST4BQWY.js +5 -0
  79. package/dist/{project-intelligence-lens-ZOAWXYC5.js → project-intelligence-lens-JHYECYOK.js} +1 -1
  80. package/dist/project-test-coverage-FRMVYTFB.js +1 -0
  81. package/dist/verified-goal-KFNRGOKT.js +1 -0
  82. package/dist/{workspace-C4UETGY7.js → workspace-O4E5CCGK.js} +1 -1
  83. package/dist/{workspace-agent-sync-446AXPHJ.js → workspace-agent-sync-N5DPGU2E.js} +1 -1
  84. package/dist/{workspace-archive-VHUPOBAV.js → workspace-archive-BA3ONVXX.js} +1 -1
  85. package/dist/{workspace-context-XSECHC7O.js → workspace-context-ETZNEHOJ.js} +1 -1
  86. package/dist/workspace-contract-OSI7NBXS.js +1 -0
  87. package/dist/workspace-explain-EM7IUV6L.js +1 -0
  88. package/dist/workspace-explain-contract-KVQO57RC.js +1 -0
  89. package/dist/{workspace-feedback-WXE7NVMV.js → workspace-feedback-PCZKXG5R.js} +1 -1
  90. package/dist/{workspace-foundation-3EVAQ5X6.js → workspace-foundation-QQHX66KE.js} +1 -1
  91. package/dist/{workspace-graph-stream-AJPS45FD.js → workspace-graph-stream-UZJQ75XZ.js} +1 -1
  92. package/dist/workspace-graph-token-efficiency-TF23UYEF.js +1 -0
  93. package/dist/{workspace-history-YY7YRDOH.js → workspace-history-CHJOABME.js} +1 -1
  94. package/dist/{workspace-intelligence-FWRB47EJ.js → workspace-intelligence-A7O7MN6T.js} +1 -1
  95. package/dist/workspace-intelligence-evaluation-YMY3C5AW.js +1 -0
  96. package/dist/{workspace-intelligence-runner-SMEAB4CO.js → workspace-intelligence-runner-4EF66L66.js} +1 -1
  97. package/dist/workspace-intelligence-runtime-registry-NCVHKCMP.js +1 -0
  98. package/dist/workspace-knowledge-graph-BVN4NTJ6.js +1 -0
  99. package/dist/{workspace-knowledge-graph-query-EKHIE3E2.js → workspace-knowledge-graph-query-6DAOXGGT.js} +1 -1
  100. package/dist/workspace-knowledge-graph-snapshot-XSQADCNR.js +1 -0
  101. package/dist/workspace-mcp-serve-TKX4J3SX.js +3 -0
  102. package/dist/{workspace-model-MNJOGBPP.js → workspace-model-7ESEP366.js} +1 -1
  103. package/dist/{workspace-onboarding-5KO7Z7AD.js → workspace-onboarding-SY255V7L.js} +1 -1
  104. package/dist/{workspace-readme-4S6PJ74A.js → workspace-readme-IVJXSIBS.js} +1 -1
  105. package/dist/{workspace-registry-summary-GPJEL7K7.js → workspace-registry-summary-7ISKYEPM.js} +1 -1
  106. package/dist/workspace-repair-engine-GMA2YTCF.js +3 -0
  107. package/dist/workspace-run-ZZXVNFUS.js +1 -0
  108. package/dist/{workspace-verify-C6HWHRLJ.js → workspace-verify-CNXZPWS5.js} +1 -1
  109. package/dist/{workspace-watch-DLPHLF5R.js → workspace-watch-HGFL2EU3.js} +1 -1
  110. package/docs/From Code to Shared Understanding-B.png +0 -0
  111. package/docs/From Code to Shared Understanding.png +0 -0
  112. package/docs/README_CONTENT_CONTRACT.md +25 -12
  113. package/docs/ci-workflows.md +9 -1
  114. package/docs/commands-reference.md +36 -7
  115. package/docs/contracts/ARTIFACT_CATALOG.md +6 -1
  116. package/docs/contracts/README.md +21 -12
  117. package/docs/doctor-command.md +189 -14
  118. package/docs/from-code-to-shared-understanding.md +22 -17
  119. package/docs/graph-benchmark-methodology.md +13 -0
  120. package/docs/real-world-qualification.md +73 -0
  121. package/docs/workspace-intelligence-runner.md +4 -0
  122. package/docs/workspace-knowledge-graph.md +77 -7
  123. package/docs/workspace-operations.md +14 -2
  124. package/docs/workspace-run.md +30 -7
  125. package/package.json +14 -3
  126. package/dist/analyze-AAZEJ4FC.js +0 -1
  127. package/dist/autopilot-release-3H5FTF6H.js +0 -1
  128. package/dist/chunk-2PY65U6X.js +0 -5
  129. package/dist/chunk-3DONU3DU.js +0 -1
  130. package/dist/chunk-44VJHNZB.js +0 -1
  131. package/dist/chunk-5XDPQ3CB.js +0 -1
  132. package/dist/chunk-6HJJHEL6.js +0 -2
  133. package/dist/chunk-7AR5PDLD.js +0 -1
  134. package/dist/chunk-7KKP7RNB.js +0 -3
  135. package/dist/chunk-7S4QNH5A.js +0 -5
  136. package/dist/chunk-7T4TSV5C.js +0 -1
  137. package/dist/chunk-BYVTHIC3.js +0 -2
  138. package/dist/chunk-CEIJIFY7.js +0 -88
  139. package/dist/chunk-D37NEYV6.js +0 -1
  140. package/dist/chunk-DPMO4U3Z.js +0 -8
  141. package/dist/chunk-DS4UYMLX.js +0 -1
  142. package/dist/chunk-FQLB4BIC.js +0 -7
  143. package/dist/chunk-GDU7VP6G.js +0 -1
  144. package/dist/chunk-H7P7SSUW.js +0 -75
  145. package/dist/chunk-KVUYAYTY.js +0 -8
  146. package/dist/chunk-MQ73VS4E.js +0 -2
  147. package/dist/chunk-NYHVCFBT.js +0 -1
  148. package/dist/chunk-OUBBBC7T.js +0 -36
  149. package/dist/chunk-P7K5RHJC.js +0 -2
  150. package/dist/chunk-PS5F4DCT.js +0 -1
  151. package/dist/chunk-QZ7PNMVP.js +0 -1
  152. package/dist/chunk-RA24WQLF.js +0 -1
  153. package/dist/chunk-RMXXK64P.js +0 -4
  154. package/dist/chunk-S7Z4DP3P.js +0 -2
  155. package/dist/chunk-SJLUE6AY.js +0 -1
  156. package/dist/chunk-TEHQ7XKK.js +0 -3
  157. package/dist/chunk-UFOCUHG3.js +0 -1
  158. package/dist/chunk-WD2XDMGB.js +0 -1
  159. package/dist/chunk-XVRJVKOX.js +0 -1
  160. package/dist/chunk-YTLUT6IA.js +0 -13
  161. package/dist/doctor-UEFFNAUD.js +0 -1
  162. package/dist/pipeline-B5S6P36F.js +0 -5
  163. package/dist/project-test-coverage-44ZPCOPV.js +0 -1
  164. package/dist/verified-goal-KOU3WJYN.js +0 -1
  165. package/dist/workspace-contract-AYFTZIKM.js +0 -1
  166. package/dist/workspace-explain-ZEWVKDBF.js +0 -1
  167. package/dist/workspace-explain-contract-6CCC26QT.js +0 -1
  168. package/dist/workspace-graph-token-efficiency-5FNH4JZ5.js +0 -1
  169. package/dist/workspace-intelligence-evaluation-UP2K3L35.js +0 -1
  170. package/dist/workspace-intelligence-runtime-registry-MRSF7RTT.js +0 -1
  171. package/dist/workspace-knowledge-graph-BMMM2FUE.js +0 -1
  172. package/dist/workspace-mcp-serve-X6C3AWTA.js +0 -3
  173. package/dist/workspace-repair-engine-GWTXVVKB.js +0 -3
  174. package/dist/workspace-run-FJTBX4JQ.js +0 -1
@@ -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
  },
@@ -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
@@ -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-DF4NWPB7.js';
@@ -0,0 +1 @@
1
+ export{b as runDoctorCapabilities}from'./chunk-IXOLHPTN.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}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 @@
1
+ var r="workspai.doctor-capabilities.v1",k="universal-doctor-capabilities-v1",t="workspai.doctor-validation.v1",w="doctor-disease-corpus-v1";var o={model:".workspai/reports/workspace-model.json",knowledgeGraph:".workspai/reports/workspace-knowledge-graph.json",snapshot:".workspai/reports/workspace-model-snapshot.json",diff:".workspai/reports/workspace-model-diff-last-run.json",impact:".workspai/reports/workspace-impact-last-run.json",analyze:".workspai/reports/analyze-last-run.json",doctor:".workspai/reports/doctor-last-run.json",contractVerify:".workspai/reports/workspace-contract-verify-last-run.json",readiness:".workspai/reports/release-readiness-last-run.json",verify:".workspai/reports/workspace-verify-last-run.json",history:".workspai/reports/workspace-intelligence-history.json",agentContext:".workspai/reports/workspace-context-agent.json",agentIndex:".workspai/reports/INDEX.json",agentCustomizationPack:".workspai/reports/agent-customization-pack.json",skillsIndex:".workspai/reports/workspace-skills-index.json",agents:"AGENTS.md",explain:".workspai/reports/workspace-explain-last-run.json",intelligenceRun:".workspai/reports/workspace-intelligence-run-last-run.json",evaluationLive:".workspai/reports/workspace-intelligence-evaluation-live.json",evaluationLastRun:".workspai/reports/workspace-intelligence-evaluation-last-run.json",verifiedGoalStatus:".workspai/reports/verified-goal-last-run.json",repairTransaction:".workspai/reports/workspace-repair-last-run.json"},s={model:"workspace-model.v1",knowledgeGraph:"workspace-knowledge-graph.v1",snapshot:"workspace-model-snapshot.v1",diff:"workspace-model-diff.v1",impact:"workspace-impact.v1",analyze:"rapidkit-analyze-v1",doctor:"doctor-workspace-evidence-v1",contractVerify:"workspace-contract-verify.v1",readiness:"release-readiness-v1",verify:"workspace-verify.v1",history:"workspace-intelligence-history.v1",agentContext:"workspace-context.v1",agentIndex:"rapidkit-agent-reports-index.v1",agentCustomizationPack:"rapidkit-agent-customization-pack.v1",skillsIndex:"workspace-skills-index.v1",agents:null,explain:"workspace-explain.v1",intelligenceRun:"workspace-intelligence-run.v1",evaluationLive:"workspace-intelligence-evaluation.v1",evaluationLastRun:"workspace-intelligence-evaluation.v1",verifiedGoalStatus:"workspai.verified-goal-status.v1",repairTransaction:"workspai.workspace-repair-transaction.v1"},c={model:"contracts/workspace-intelligence/workspace-model.v1.json",knowledgeGraph:"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json",snapshot:"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",diff:"contracts/workspace-intelligence/workspace-model-diff.v1.json",impact:"contracts/workspace-intelligence/workspace-impact.v1.json",analyze:"contracts/analyze-last-run.v1.json",doctor:"contracts/doctor-workspace-evidence.v1.json",contractVerify:"contracts/workspace-intelligence/workspace-contract-verify.v1.json",readiness:"contracts/release-readiness.v1.json",verify:"contracts/workspace-intelligence/workspace-verify.v1.json",history:"contracts/workspace-intelligence/workspace-intelligence-history.v1.json",agentContext:"contracts/workspace-intelligence/workspace-context.v1.json",agentIndex:"contracts/workspace-intelligence/agent-reports-index.v1.json",agentCustomizationPack:"contracts/workspace-intelligence/agent-customization-pack-report.v1.json",skillsIndex:"contracts/workspace-intelligence/workspace-skills-index.v1.json",agents:null,explain:"contracts/workspace-intelligence/workspace-explain.v1.json",intelligenceRun:"contracts/workspace-intelligence/workspace-intelligence-run.v1.json",evaluationLive:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",evaluationLastRun:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",verifiedGoalStatus:"contracts/workspace-intelligence/verified-goal-status.v1.json",repairTransaction:"contracts/workspace-intelligence/workspace-repair-transaction.v1.json"},l={projectWorkspaceLink:{artifactPath:".workspai/workspace-link.local.json",schemaVersion:"project-workspace-link.v1",contractPath:"contracts/project-workspace-link.v1.json",producerCommands:[["adopt"],["import"],["project","workspace","relink"],["workspace","sync"]]},projectContextAgent:{artifactPath:".workspai/reports/project-context-agent.json",schemaVersion:"project-context-agent.v1",contractPath:"contracts/workspace-intelligence/project-context-agent.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},workspaceContract:{artifactPath:".workspai/workspace.contract.json",schemaVersion:1,contractPath:"contracts/workspace-contract.v1.json",producerCommands:[["workspace","sync"],["workspace","contract","sync"]]},workspaceModelCache:{artifactPath:".workspai/cache/workspace-model.v1.json",schemaVersion:"workspace-model-cache.v1",contractPath:"contracts/workspace-model-cache.v1.json",producerCommands:[["workspace","model"]]},workspaceRegistry:{artifactPath:".workspai/workspace-registry.v1.json",schemaVersion:"workspace-registry.v1",contractPath:"contracts/workspace-registry.v1.json",producerCommands:[["workspace","sync"]]},compatibilityMatrix:{artifactPath:".workspai/compatibility-matrix.json",schemaVersion:"rapidkit.compatibility-matrix.v1",contractPath:"contracts/compatibility-matrix.v1.json",producerCommands:[["bootstrap"]]},doctorWorkspaceCache:{artifactPath:".workspai/reports/doctor-workspace-cache.json",schemaVersion:"doctor-workspace-cache-v2",contractPath:"contracts/doctor-workspace-cache.v2.json",producerCommands:[["doctor","workspace"]]},doctorCapabilities:{artifactPath:".workspai/reports/doctor-capabilities.json",schemaVersion:r,contractPath:"contracts/workspace-intelligence/doctor-capabilities.v1.json",producerCommands:[["doctor","capabilities","--write"]]},doctorValidation:{artifactPath:".workspai/reports/doctor-validation-last-run.json",schemaVersion:t,contractPath:"contracts/workspace-intelligence/doctor-validation.v1.json",producerCommands:[["doctor","capabilities","--validate","--write"]]},bootstrapCompliance:{artifactPath:".workspai/reports/bootstrap-compliance.latest.json",schemaVersion:"bootstrap-compliance.v1",contractPath:"contracts/bootstrap-compliance.v1.json",producerCommands:[["bootstrap"]]},mirrorOps:{artifactPath:".workspai/reports/mirror-ops.latest.json",schemaVersion:"mirror-ops.v1",contractPath:"contracts/mirror-ops.v1.json",producerCommands:[["mirror","status"]]},transparencyEvidence:{artifactPath:".workspai/reports/transparency-evidence.latest.json",schemaVersion:"transparency-evidence.v1",contractPath:"contracts/transparency-evidence.v1.json",producerCommands:[["mirror","sync"]]},workspaceShareBundle:{artifactPath:".workspai/reports/share-bundle.json",schemaVersion:"1.1",schemaVersionField:"schema_version",contractPath:"contracts/workspace-share-bundle.v1.json",producerCommands:[["workspace","share"]]},doctorProject:{artifactPath:".workspai/reports/doctor-project-last-run.json",schemaVersion:"doctor-project-evidence-v1",contractPath:"contracts/doctor-project-evidence.v1.json",producerCommands:[["doctor","project"]]},doctorReceipt:{artifactPath:".workspai/reports/doctor-receipt-last-run.json",schemaVersion:"workspai.doctor-receipt.v1",contractPath:"contracts/workspace-intelligence/doctor-receipt.v1.json",producerCommands:[["doctor","workspace"],["doctor","project"]]},projectTestCoverage:{artifactPath:".workspai/reports/project-test-coverage-last-run.json",schemaVersion:"workspai.project-test-coverage.v1",contractPath:"contracts/project-test-coverage.v1.json",producerCommands:[["project","coverage"]]},doctorRemediationPlan:{artifactPath:".workspai/reports/doctor-remediation-plan-last-run.json",schemaVersion:"doctor-remediation-plan-v2",contractPath:"contracts/doctor-remediation-plan.v2.json",producerCommands:[["workspace","remediation-plan"]]},artifactRemediationPlan:{artifactPath:".workspai/reports/artifact-remediation-plan-last-run.json",schemaVersion:"artifact-remediation-plan-v1",contractPath:"contracts/artifact-remediation-plan.v1.json",producerCommands:[["workspace","remediation-plan"]]},doctorFixResult:{artifactPath:".workspai/reports/doctor-fix-result-last-run.json",schemaVersion:"rapidkit-doctor-fix-result-v1",contractPath:"contracts/workspace-intelligence/doctor-fix-result.v1.json",producerCommands:[["doctor","workspace"]]},pipelineLastRun:{artifactPath:".workspai/reports/pipeline-last-run.json",schemaVersion:"rapidkit-pipeline-v1",contractPath:"contracts/pipeline-last-run.v1.json",producerCommands:[["pipeline"]]},autopilotReleaseLastRun:{artifactPath:".workspai/reports/autopilot-release-last-run.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},autopilotReleaseAlias:{artifactPath:".workspai/reports/autopilot-release.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},workspaceRunLast:{artifactPath:".workspai/reports/workspace-run-last.json",schemaVersion:"workspace-run-v1",contractPath:"contracts/workspace-run-last.v1.json",producerCommands:[["workspace","run"]]},workspaiMcpDesign:{artifactPath:".workspai/reports/workspai-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},legacyMcpDesign:{artifactPath:".workspai/reports/rapidkit-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},workspaceWhy:{artifactPath:".workspai/reports/workspace-why-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","why"]]},workspaceTrace:{artifactPath:".workspai/reports/workspace-trace-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","trace"]]},agentHooks:{artifactPath:".vscode/workspai-agent-hooks.json",schemaVersion:"workspai-agent-hooks.v1",contractPath:"contracts/workspace-intelligence/agent-hooks.v1.json",producerCommands:[["workspace","agent-sync"]]},infraPlan:{artifactPath:".workspai/reports/infra-plan.json",schemaVersion:"rapidkit.infra-plan.v1",contractPath:"contracts/infra-plan.v1.json",producerCommands:[["infra","plan"]]}},h=Object.freeze(Object.fromEntries(Object.entries(l).map(([a,n])=>[a,n.artifactPath]))),g={[o.intelligenceRun]:[["workspace","intelligence","run"]],[o.snapshot]:[["workspace","snapshot"]],[o.history]:[["workspace","feedback","record","--json"]],[o.evaluationLive]:[["workspace","eval","init"],["workspace","eval","record","--json"]],[o.evaluationLastRun]:[["workspace","eval","report","--json"]],[o.verifiedGoalStatus]:[["workspace","goal","plan"],["workspace","goal","verify"]],[o.repairTransaction]:[["workspace","repair","plan"],["workspace","repair","propose"],["workspace","repair","approve"],["workspace","repair","decide"],["workspace","repair","execute"],["workspace","repair","resume"],["workspace","repair","rollback"],["workspace","repair","cancel"]]},j={analyze:"analyze",workspace:"workspace <action> [subaction] [key] [value]",doctor:"doctor [scope]",readiness:"readiness"},f=["analyze","readiness","doctor","workspace"],C=["model","diff","impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify","context","agent-sync","explain"],P=["sync","baseline"],I={sync:[".workspai/workspace.contract.json",".workspai/workspace-registry.v1.json"],baseline:[o.snapshot]},e=o,d={model:{command:["workspace","model","--json","--write"],produces:[e.model,e.knowledgeGraph]},diff:{command:["workspace","diff","--from",e.snapshot,"--json"],produces:[e.diff]},impact:{command:["workspace","impact","--from",e.diff,"--json"],produces:[e.impact]},"doctor-evidence":{command:["doctor","workspace","--json"],produces:[e.doctor]},"contract-evidence":{command:["workspace","contract","verify","--strict","--json"],produces:[e.contractVerify]},"analyze-evidence":{command:["analyze","--json"],produces:[e.analyze]},"readiness-evidence":{command:["readiness","--json","--skip-verify"],produces:[e.readiness]},verify:{command:["workspace","verify","--from-impact",e.impact,"--json"],produces:[e.verify,e.history]},context:{command:["workspace","context","--for-agent","--json","--write","--no-agent-sync"],produces:[e.agentContext]},"agent-sync":{command:["workspace","agent-sync","--write","--json","--preset","enterprise"],produces:[e.agentIndex,e.agentCustomizationPack,e.skillsIndex,e.agents]},explain:{command:["workspace","explain","release-blocked","--json","--write"],produces:[e.explain]}};function y(a){return d[a]}export{r as a,k as b,t as c,w as d,o as e,s as f,c as g,l as h,h as i,g as j,j as k,f as l,C as m,P as n,I as o,d as p,y as q};
@@ -1 +1 @@
1
- import {e,a as a$1}from'./chunk-44VJHNZB.js';var i=".workspai/skills";var _=a$1.skillsIndex,a=a$1.explain,P=e.workspaceWhy,O=e.workspaceTrace,c=".workspai/AGENT-GROUNDING.md",I=".rapidkit/AGENT-GROUNDING.md",A=".cursor/rules/workspai-grounding.mdc",T=".cursor/rules/rapidkit-grounding.mdc",E=".claude/rules/workspai-evidence.md",R=".claude/rules/rapidkit-evidence.md",L=".github/instructions/workspai-workspace.instructions.md",d=".github/instructions/rapidkit-workspace.instructions.md",S=".github/instructions/workspai-evidence.instructions.md",C=".github/instructions/rapidkit-evidence.instructions.md",k=".github/prompts/workspai-diagnose.prompt.md",N=".github/prompts/rapidkit-diagnose.prompt.md",l=".github/prompts/workspai-repair.prompt.md",m=".github/prompts/rapidkit-repair.prompt.md",u=".github/prompts/workspai-release-readiness.prompt.md",g=".github/prompts/rapidkit-release-readiness.prompt.md",K=".github/prompts/workspai-project-onboard.prompt.md",G=".github/prompts/rapidkit-project-onboard.prompt.md",x=".github/prompts/workspai-adopt-project.prompt.md",w=".github/prompts/rapidkit-adopt-project.prompt.md",H=".github/skills/workspai-grounding/SKILL.md",D=".github/skills/rapidkit-grounding/SKILL.md",W=".github/skills/workspai-workspace-intelligence/SKILL.md",h=".github/skills/rapidkit-workspace-intelligence/SKILL.md",U=e.workspaiMcpDesign,b=e.legacyMcpDesign,M=e.agentHooks,Y=".vscode/rapidkit-agent-hooks.json";function f(r){let s=r.trim();if(!s||s.includes("..")||s.includes("/"))throw new Error(`Invalid operational skill id: ${r}`);return `${i}/${s}.md`}var B={"workspai-diagnose-api-failure":"workspai-diagnose","workspai-release-readiness":"workspai-release-readiness","workspai-safe-schema-migration":"workspai-safe-schema-migration","workspai-dependency-upgrade":"workspai-dependency-upgrade","workspai-rename-contract":"workspai-rename-contract"};export{D as A,W as B,h as C,U as D,b as E,M as F,Y as G,f as H,B as I,i as a,_ as b,a as c,P as d,O as e,c as f,I as g,A as h,T as i,E as j,R as k,L as l,d as m,S as n,C as o,k as p,N as q,l as r,m as s,u as t,g as u,K as v,G as w,x,w as y,H as z};
1
+ import {i as i$1,e}from'./chunk-5EPPPMAS.js';var i=".workspai/skills";var _=e.skillsIndex,a=e.explain,P=i$1.workspaceWhy,O=i$1.workspaceTrace,c=".workspai/AGENT-GROUNDING.md",I=".rapidkit/AGENT-GROUNDING.md",A=".cursor/rules/workspai-grounding.mdc",T=".cursor/rules/rapidkit-grounding.mdc",E=".claude/rules/workspai-evidence.md",R=".claude/rules/rapidkit-evidence.md",L=".github/instructions/workspai-workspace.instructions.md",d=".github/instructions/rapidkit-workspace.instructions.md",S=".github/instructions/workspai-evidence.instructions.md",C=".github/instructions/rapidkit-evidence.instructions.md",k=".github/prompts/workspai-diagnose.prompt.md",N=".github/prompts/rapidkit-diagnose.prompt.md",l=".github/prompts/workspai-repair.prompt.md",m=".github/prompts/rapidkit-repair.prompt.md",u=".github/prompts/workspai-release-readiness.prompt.md",g=".github/prompts/rapidkit-release-readiness.prompt.md",K=".github/prompts/workspai-project-onboard.prompt.md",G=".github/prompts/rapidkit-project-onboard.prompt.md",x=".github/prompts/workspai-adopt-project.prompt.md",w=".github/prompts/rapidkit-adopt-project.prompt.md",H=".github/skills/workspai-grounding/SKILL.md",D=".github/skills/rapidkit-grounding/SKILL.md",W=".github/skills/workspai-workspace-intelligence/SKILL.md",h=".github/skills/rapidkit-workspace-intelligence/SKILL.md",U=i$1.workspaiMcpDesign,b=i$1.legacyMcpDesign,M=i$1.agentHooks,Y=".vscode/rapidkit-agent-hooks.json";function f(r){let s=r.trim();if(!s||s.includes("..")||s.includes("/"))throw new Error(`Invalid operational skill id: ${r}`);return `${i}/${s}.md`}var B={"workspai-diagnose-api-failure":"workspai-diagnose","workspai-release-readiness":"workspai-release-readiness","workspai-safe-schema-migration":"workspai-safe-schema-migration","workspai-dependency-upgrade":"workspai-dependency-upgrade","workspai-rename-contract":"workspai-rename-contract"};export{D as A,W as B,h as C,U as D,b as E,M as F,Y as G,f as H,B as I,i as a,_ as b,a as c,P as d,O as e,c as f,I as g,A as h,T as i,E as j,R as k,L as l,d as m,S as n,C as o,k as p,N as q,l as r,m as s,u as t,g as u,K as v,G as w,x,w as y,H as z};
@@ -0,0 +1 @@
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};
@@ -0,0 +1 @@
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-6HJJHEL6.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};
@@ -0,0 +1 @@
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};
@@ -1,2 +1,2 @@
1
- import {b as b$1}from'./chunk-BYVTHIC3.js';import {v,w}from'./chunk-MOSXTVPU.js';import l from'path';import {randomUUID}from'crypto';import {open}from'fs/promises';import c from'fs-extra';function k(t,e){let n=l.resolve(t),r=e.trim();if(!r||l.isAbsolute(r))throw new Error(`Workspace artifact path must be non-empty and relative: ${e}`);let a=l.resolve(n,r),o=l.relative(n,a);if(o===".."||o.startsWith(`..${l.sep}`)||l.isAbsolute(o))throw new Error(`Workspace artifact path escapes workspace root: ${e}`);return a}function u(t,e){return k(t,v(e))}function N(t,e){return k(t,w(e))}async function S(t,e){let n=l.resolve(t);await c.ensureDir(n);let r=l.dirname(e);await c.ensureDir(r);let[a,o]=await Promise.all([c.realpath(n),c.realpath(r)]),i=l.relative(a,o);if(i===".."||i.startsWith(`..${l.sep}`)||l.isAbsolute(i))throw new Error(`Workspace artifact parent resolves outside workspace root: ${r}`)}async function _(t,e){let n=l.resolve(t),[r,a]=await Promise.all([c.realpath(n),c.realpath(e)]),o=l.relative(r,a);if(o===".."||o.startsWith(`..${l.sep}`)||l.isAbsolute(o))throw new Error(`Workspace artifact resolves outside workspace root: ${e}`)}function F(t){let e=t?.code;return process.platform==="win32"&&(e==="EPERM"||e==="EINVAL"||e==="ENOSYS")}function b(t,e=process.platform){if(e!=="win32")return false;let n=t?.code;return n==="EPERM"||n==="EACCES"||n==="EBUSY"}async function p(t){let e=process.platform==="win32"?6:1,n;for(let r=0;r<e;r+=1)try{await c.remove(t);return}catch(a){if(n=a,!b(a)||r===e-1)throw a;await new Promise(o=>setTimeout(o,10*2**r));}throw n}var m=new Map;async function J(t,e){let n=m.get(t)??Promise.resolve(),r,a=new Promise(i=>{r=i;}),o=n.catch(()=>{}).then(()=>a);m.set(t,o),await n.catch(()=>{});try{return await e()}finally{r(),m.get(t)===o&&m.delete(t);}}async function I(t){try{await t.sync();}catch(e){if(!F(e))throw e}}async function h(t,e,n){await S(t,e);let r=l.dirname(e),a=`${l.basename(e)}.`,o=Date.now();for(let s of await c.readdir(r)){if(!s.startsWith(a)||!s.endsWith(".tmp"))continue;let w=l.join(r,s),f=await c.stat(w).catch(()=>null);f&&o-f.mtimeMs>3e4&&await c.remove(w).catch(()=>{});}let i=`${e}.${process.pid}.${randomUUID()}.tmp`;try{await n(i);let s=await open(i,"r");try{await I(s);}finally{await s.close();}let w=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(w)&&w>0&&await new Promise(f=>setTimeout(f,Math.min(w,3e4)));try{await c.rename(i,e);}catch(f){let d=f.code;if(d!=="EEXIST"&&d!=="EPERM")throw f;await c.move(i,e,{overwrite:true});}}finally{await c.remove(i).catch(()=>{});}}async function D(t,e,n,r={}){let a=u(t,e);await S(t,a);let o=`${a}.lock`;return J(o,()=>L(o,e,n,r))}async function L(t,e,n,r){let a=r.timeoutMs??1e4,o=r.staleAfterMs??3e4,i=Date.now(),s;for(;!s;)try{s=await open(t,"wx"),await s.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
1
+ import {b as b$1}from'./chunk-LYVDRRDO.js';import {v,w}from'./chunk-MOSXTVPU.js';import l from'path';import {randomUUID}from'crypto';import {open}from'fs/promises';import c from'fs-extra';function k(t,e){let n=l.resolve(t),r=e.trim();if(!r||l.isAbsolute(r))throw new Error(`Workspace artifact path must be non-empty and relative: ${e}`);let a=l.resolve(n,r),o=l.relative(n,a);if(o===".."||o.startsWith(`..${l.sep}`)||l.isAbsolute(o))throw new Error(`Workspace artifact path escapes workspace root: ${e}`);return a}function u(t,e){return k(t,v(e))}function N(t,e){return k(t,w(e))}async function S(t,e){let n=l.resolve(t);await c.ensureDir(n);let r=l.dirname(e);await c.ensureDir(r);let[a,o]=await Promise.all([c.realpath(n),c.realpath(r)]),i=l.relative(a,o);if(i===".."||i.startsWith(`..${l.sep}`)||l.isAbsolute(i))throw new Error(`Workspace artifact parent resolves outside workspace root: ${r}`)}async function _(t,e){let n=l.resolve(t),[r,a]=await Promise.all([c.realpath(n),c.realpath(e)]),o=l.relative(r,a);if(o===".."||o.startsWith(`..${l.sep}`)||l.isAbsolute(o))throw new Error(`Workspace artifact resolves outside workspace root: ${e}`)}function F(t){let e=t?.code;return process.platform==="win32"&&(e==="EPERM"||e==="EINVAL"||e==="ENOSYS")}function b(t,e=process.platform){if(e!=="win32")return false;let n=t?.code;return n==="EPERM"||n==="EACCES"||n==="EBUSY"}async function p(t){let e=process.platform==="win32"?6:1,n;for(let r=0;r<e;r+=1)try{await c.remove(t);return}catch(a){if(n=a,!b(a)||r===e-1)throw a;await new Promise(o=>setTimeout(o,10*2**r));}throw n}var m=new Map;async function J(t,e){let n=m.get(t)??Promise.resolve(),r,a=new Promise(i=>{r=i;}),o=n.catch(()=>{}).then(()=>a);m.set(t,o),await n.catch(()=>{});try{return await e()}finally{r(),m.get(t)===o&&m.delete(t);}}async function I(t){try{await t.sync();}catch(e){if(!F(e))throw e}}async function h(t,e,n){await S(t,e);let r=l.dirname(e),a=`${l.basename(e)}.`,o=Date.now();for(let s of await c.readdir(r)){if(!s.startsWith(a)||!s.endsWith(".tmp"))continue;let w=l.join(r,s),f=await c.stat(w).catch(()=>null);f&&o-f.mtimeMs>3e4&&await c.remove(w).catch(()=>{});}let i=`${e}.${process.pid}.${randomUUID()}.tmp`;try{await n(i);let s=await open(i,"r");try{await I(s);}finally{await s.close();}let w=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(w)&&w>0&&await new Promise(f=>setTimeout(f,Math.min(w,3e4)));try{await c.rename(i,e);}catch(f){let d=f.code;if(d!=="EEXIST"&&d!=="EPERM")throw f;await c.move(i,e,{overwrite:true});}}finally{await c.remove(i).catch(()=>{});}}async function D(t,e,n,r={}){let a=u(t,e);await S(t,a);let o=`${a}.lock`;return J(o,()=>L(o,e,n,r))}async function L(t,e,n,r){let a=r.timeoutMs??1e4,o=r.staleAfterMs??3e4,i=Date.now(),s;for(;!s;)try{s=await open(t,"wx"),await s.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
2
2
  `),await I(s);}catch(w){if(!(w.code==="EEXIST"||b(w)))throw s&&(await s.close().catch(()=>{}),s=void 0,await p(t).catch(()=>{})),w;s&&(await s.close().catch(()=>{}),s=void 0,await p(t).catch(()=>{}));let[P,M]=await Promise.all([c.stat(t).catch(()=>null),c.readJson(t).catch(()=>null)]),g=Number(M?.pid),E=Number.isInteger(g)&&g>0,A=false;if(E)try{process.kill(g,0),A=true;}catch(y){A=y.code==="EPERM";}let R=!E&&!!(P&&Date.now()-P.mtimeMs>o);if(E&&!A||R){await p(t).catch(()=>{});continue}if(Date.now()-i>=a)throw new Error(`Timed out waiting for workspace artifact lock: ${e}`);await new Promise(y=>setTimeout(y,20));}try{return await n()}finally{await s.close().catch(()=>{}),await p(t);}}async function K(t,e){let n=[u(t,e),N(t,e)];for(let r of n)if(await c.pathExists(r))return await _(t,r),r;return null}async function X(t,e,n){b$1(e,n);let r=u(t,e);return await h(t,r,a=>c.writeJson(a,n,{spaces:2})),r}async function V(t,e,n){if(n.length===0)return [];let r=n.map(o=>({...o,path:u(t,o.relativePath)})),a=r.find((o,i)=>r.findIndex(s=>s.path===o.path)!==i);if(a)throw new Error(`Duplicate workspace artifact transaction target: ${a.relativePath}`);for(let o of r)b$1(o.relativePath,o.payload);return D(t,e,async()=>{let o=await Promise.all(r.map(async i=>({path:i.path,exists:await c.pathExists(i.path),contents:await c.readFile(i.path).catch(()=>null)})));try{for(let i=0;i<r.length;i+=1){let s=r[i];await h(t,s.path,f=>c.writeJson(f,s.payload,{spaces:2}));let w=Number(process.env.WORKSPAI_TEST_FAIL_ARTIFACT_SET_AFTER??0);if(Number.isInteger(w)&&w===i+1)throw new Error(`Injected artifact-set failure after ${w} write(s).`)}return r.map(i=>i.path)}catch(i){let w=(await Promise.allSettled(o.map(async f=>{if(!f.exists||f.contents===null){await c.remove(f.path);return}await h(t,f.path,d=>c.writeFile(d,f.contents));}))).filter(f=>f.status==="rejected");throw w.length>0?new AggregateError([i,...w.map(f=>f.reason)],"Workspace artifact transaction failed and rollback was incomplete."):i}})}async function q(t,e,n){let r=u(t,e);return await h(t,r,a=>c.writeFile(a,n,"utf-8")),r}export{u as a,N as b,D as c,K as d,X as e,V as f,q as g};