workspai 0.64.0 → 0.66.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 (207) hide show
  1. package/README.md +40 -44
  2. package/contracts/agent-customization-pack.v1.json +4 -2
  3. package/contracts/analyze-last-run.v1.json +9 -1
  4. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +117 -0
  5. package/contracts/extension-cli-compatibility.v1.json +2 -0
  6. package/contracts/published-contract-catalog.v1.json +10 -0
  7. package/contracts/runtime-command-surface.v1.json +59 -3
  8. package/contracts/workspace-activity-event.v1.json +132 -0
  9. package/contracts/workspace-contract.v1.json +51 -6
  10. package/contracts/workspace-intelligence/agent-bootstrap-receipt.v1.json +17 -0
  11. package/contracts/workspace-intelligence/mcp-design.v1.json +49 -2
  12. package/contracts/workspace-intelligence/project-agent-entry.v1.json +3 -0
  13. package/contracts/workspace-intelligence/project-context-agent.v1.json +78 -7
  14. package/contracts/workspace-intelligence/project-knowledge-graph-reference.v1.json +51 -0
  15. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +108 -3
  16. package/contracts/workspace-intelligence/workspace-model.v1.json +28 -1
  17. package/contracts/workspace-intelligence/workspace-skills-index.v1.json +34 -0
  18. package/contracts/workspace-model-cache.v1.json +4 -0
  19. package/contracts/workspace-repair-capabilities.v1.json +66 -0
  20. package/dist/analyze-UJQWGNM2.js +1 -0
  21. package/dist/{artifact-remediation-plan-XIQNI35L.js → artifact-remediation-plan-M2XBS2IU.js} +1 -1
  22. package/dist/autopilot-release-U6F4M2BQ.js +1 -0
  23. package/dist/capabilities-command-XUKPO25Z.js +1 -0
  24. package/dist/chunk-2LIVMG5C.js +2 -0
  25. package/dist/{chunk-ZGS5NKEO.js → chunk-2PACEMNE.js} +1 -1
  26. package/dist/chunk-334J2KIP.js +7 -0
  27. package/dist/{chunk-6TBTMWNA.js → chunk-3H5ACWWZ.js} +1 -1
  28. package/dist/{chunk-HCFWT42C.js → chunk-3NM3JAZW.js} +1 -1
  29. package/dist/chunk-4XEH3WNV.js +13 -0
  30. package/dist/chunk-5OA33JH2.js +2 -0
  31. package/dist/chunk-5TY74LLW.js +2 -0
  32. package/dist/{chunk-QCKWQFCD.js → chunk-5U4L6VF2.js} +1 -1
  33. package/dist/{chunk-W6FHVXNL.js → chunk-5XGR3LRI.js} +1 -1
  34. package/dist/{chunk-KTN2ARZJ.js → chunk-6JX56VAL.js} +3 -3
  35. package/dist/chunk-6UNATTB7.js +1 -0
  36. package/dist/{chunk-J3X56S7L.js → chunk-727IQFGN.js} +1 -1
  37. package/dist/chunk-7FF5EOIO.js +2 -0
  38. package/dist/chunk-AP4PV6WJ.js +1 -0
  39. package/dist/chunk-AXUA7PFV.js +2 -0
  40. package/dist/chunk-B4IVVTMQ.js +2 -0
  41. package/dist/{chunk-LNXIMF3O.js → chunk-C4S22E6S.js} +1 -1
  42. package/dist/{chunk-PXWKMPPI.js → chunk-D4UHRJAP.js} +1 -1
  43. package/dist/chunk-DUBOKZMA.js +49 -0
  44. package/dist/{chunk-VYDURWN7.js → chunk-ECLMYTWT.js} +1 -1
  45. package/dist/{chunk-VB6I52ZT.js → chunk-EHH4SKVH.js} +50 -50
  46. package/dist/chunk-EP4CUWOO.js +9 -0
  47. package/dist/chunk-FY4X2VOE.js +39 -0
  48. package/dist/chunk-GAYK3WGV.js +2 -0
  49. package/dist/{chunk-YUGKQ44M.js → chunk-H5RJCS5E.js} +1 -1
  50. package/dist/{chunk-5SFCBZOH.js → chunk-H7MRINGP.js} +1 -1
  51. package/dist/chunk-HJLGXFMK.js +1 -0
  52. package/dist/{chunk-VRGEPPUB.js → chunk-HLWDIIWL.js} +1 -1
  53. package/dist/{chunk-KJXMLBSY.js → chunk-IIFFEEMX.js} +1 -1
  54. package/dist/chunk-IVF6NEHS.js +1 -0
  55. package/dist/chunk-JC4XSU7G.js +1 -0
  56. package/dist/chunk-JRP6WP5C.js +681 -0
  57. package/dist/chunk-JZJBA2V2.js +1 -0
  58. package/dist/{chunk-N4QQADXX.js → chunk-L5CCIIF2.js} +1 -1
  59. package/dist/chunk-L5Q2S5GY.js +3 -0
  60. package/dist/chunk-LPCZHKD5.js +1 -0
  61. package/dist/chunk-MZ7U4BIQ.js +157 -0
  62. package/dist/chunk-NMXGSVMD.js +1 -0
  63. package/dist/{chunk-GQSRNUCU.js → chunk-NVND4727.js} +3 -3
  64. package/dist/chunk-O37UBRMX.js +4 -0
  65. package/dist/chunk-OI2VOU6S.js +1 -0
  66. package/dist/chunk-PD7Y6HIM.js +2 -0
  67. package/dist/chunk-PJPS7CNH.js +1 -0
  68. package/dist/chunk-QGAPGZPL.js +97 -0
  69. package/dist/chunk-R2M5OJOK.js +5 -0
  70. package/dist/chunk-SX6A656X.js +1 -0
  71. package/dist/{chunk-X6TNBARH.js → chunk-TABXSDTR.js} +2 -2
  72. package/dist/chunk-TTHO4MFC.js +2 -0
  73. package/dist/chunk-U5ENEDJA.js +7 -0
  74. package/dist/chunk-UOCERSAN.js +1 -0
  75. package/dist/chunk-UPIPSSXY.js +1 -0
  76. package/dist/chunk-UTV4DTNM.js +1 -0
  77. package/dist/chunk-VA5VSOBL.js +2 -0
  78. package/dist/chunk-VQOWB26M.js +12 -0
  79. package/dist/chunk-VQZ5PI5J.js +1 -0
  80. package/dist/chunk-WCJU3CFG.js +1 -0
  81. package/dist/chunk-WTWRSEOW.js +1 -0
  82. package/dist/{chunk-D65FCQIO.js → chunk-XESFJN52.js} +1 -1
  83. package/dist/chunk-XQFWUM2P.js +1 -0
  84. package/dist/chunk-XWKGZRHN.js +1 -0
  85. package/dist/{chunk-WRQWVSBJ.js → chunk-YX5VWPR5.js} +1 -1
  86. package/dist/chunk-ZEEV5J4I.js +1 -0
  87. package/dist/chunk-ZQH2I5RQ.js +1 -0
  88. package/dist/{create-PWJDTKDN.js → create-SOLLXXAB.js} +1 -1
  89. package/dist/{demo-kit-QHIDCSBI.js → demo-kit-5UQH2OXC.js} +1 -1
  90. package/dist/{doctor-CGXY4IDE.js → doctor-NQ5PUCUP.js} +1 -1
  91. package/dist/{dotnet-webapi-clean-AVHPJG7Y.js → dotnet-webapi-clean-YEHYIGOT.js} +1 -1
  92. package/dist/{goal-lifecycle-BRFFTIU2.js → goal-lifecycle-IPNY7KNR.js} +1 -1
  93. package/dist/goal-pack-2WV3EA4Y.js +1 -0
  94. package/dist/{gofiber-standard-47S2GYAO.js → gofiber-standard-C44IIQYH.js} +1 -1
  95. package/dist/{gogin-standard-EWB4XNOI.js → gogin-standard-X7VKACVR.js} +1 -1
  96. package/dist/index.d.ts +8 -2
  97. package/dist/index.js +170 -170
  98. package/dist/live-command-Q6E45N7S.js +18 -0
  99. package/dist/{pipeline-DF4UIHAD.js → pipeline-MIMENSI7.js} +1 -1
  100. package/dist/{project-agent-entry-IWUCV72J.js → project-agent-entry-OWLJ3IHQ.js} +1 -1
  101. package/dist/project-intelligence-lens-I67EO6AE.js +1 -0
  102. package/dist/{project-test-coverage-4S7MEQ6T.js → project-test-coverage-OPDVSFPH.js} +1 -1
  103. package/dist/{pythonRapidkitExec-VAW5XE4Z.js → pythonRapidkitExec-44ORGQ4R.js} +1 -1
  104. package/dist/{rust-axum-M5X4ZC4Z.js → rust-axum-JKZTZDRZ.js} +1 -1
  105. package/dist/{springboot-standard-Y5ADLZMQ.js → springboot-standard-PI4FLTAN.js} +1 -1
  106. package/dist/verified-goal-46JWNCDY.js +1 -0
  107. package/dist/{workspace-35Q2IXAR.js → workspace-KO37XHF6.js} +1 -1
  108. package/dist/{workspace-agent-sync-FFNSW2PD.js → workspace-agent-sync-32FIJQBH.js} +1 -1
  109. package/dist/{workspace-archive-ZBCKJHXS.js → workspace-archive-6R5DRNZW.js} +1 -1
  110. package/dist/{workspace-context-IJ36ZP6G.js → workspace-context-JKRPX775.js} +1 -1
  111. package/dist/workspace-contract-4T3NYNK5.js +1 -0
  112. package/dist/workspace-explain-MOGL4GEA.js +1 -0
  113. package/dist/workspace-explain-contract-W2E6LF4Q.js +1 -0
  114. package/dist/{workspace-feedback-RQ4TGJW6.js → workspace-feedback-6VQ7T4CR.js} +1 -1
  115. package/dist/{workspace-foundation-GMGDUMPR.js → workspace-foundation-GHWO3BZU.js} +1 -1
  116. package/dist/workspace-graph-stream-PTVS47NJ.js +1 -0
  117. package/dist/workspace-graph-token-efficiency-Z5JD5NHI.js +1 -0
  118. package/dist/{workspace-history-SYCDK7FO.js → workspace-history-M2K4M2JY.js} +1 -1
  119. package/dist/{workspace-intelligence-5NO4K5SC.js → workspace-intelligence-PJIPTXL3.js} +1 -1
  120. package/dist/{workspace-intelligence-evaluation-CQDKOYZZ.js → workspace-intelligence-evaluation-GONCRE6O.js} +1 -1
  121. package/dist/{workspace-intelligence-runner-FGEBFVVM.js → workspace-intelligence-runner-M47QR3JM.js} +1 -1
  122. package/dist/{workspace-intelligence-runtime-registry-IW6J53LO.js → workspace-intelligence-runtime-registry-FFGQF4A7.js} +1 -1
  123. package/dist/workspace-knowledge-graph-V2EAYDCL.js +1 -0
  124. package/dist/workspace-knowledge-graph-contract-VANN7RCA.js +1 -0
  125. package/dist/{workspace-knowledge-graph-query-ON45H6Y7.js → workspace-knowledge-graph-query-RASPF7FS.js} +1 -1
  126. package/dist/workspace-knowledge-graph-snapshot-5YIG6EMG.js +1 -0
  127. package/dist/{workspace-marker-7NHMDIRL.js → workspace-marker-XGAWZZDX.js} +1 -1
  128. package/dist/workspace-mcp-serve-YRORNE4P.js +3 -0
  129. package/dist/workspace-model-VSVKLX7M.js +1 -0
  130. package/dist/{workspace-onboarding-VS3YYNGK.js → workspace-onboarding-2VMJZVLZ.js} +1 -1
  131. package/dist/{workspace-python-engine-state-J4QKW55K.js → workspace-python-engine-state-BE4A3BL5.js} +1 -1
  132. package/dist/{workspace-readme-G7TZ3V5T.js → workspace-readme-6X3GLTBM.js} +2 -2
  133. package/dist/{workspace-registry-summary-MIDFG6EC.js → workspace-registry-summary-QVSJKKTX.js} +1 -1
  134. package/dist/workspace-repair-engine-WSKV3Q4V.js +3 -0
  135. package/dist/workspace-run-3BXKTLVL.js +1 -0
  136. package/dist/{workspace-verify-4R7QHUPO.js → workspace-verify-EJCSOBIK.js} +1 -1
  137. package/dist/workspace-watch-JTIFBF4Z.js +1 -0
  138. package/docs/SETUP.md +10 -0
  139. package/docs/agent-entry.md +22 -7
  140. package/docs/ci-workflows.md +1 -1
  141. package/docs/commands-reference.md +43 -7
  142. package/docs/contracts/ARTIFACT_CATALOG.md +63 -44
  143. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +1 -0
  144. package/docs/contracts/NAMING_AND_COEXISTENCE.md +20 -18
  145. package/docs/contracts/README.md +4 -3
  146. package/docs/real-world-qualification.md +19 -3
  147. package/docs/workspace-knowledge-graph.md +131 -27
  148. package/docs/workspace-live-activity.md +199 -0
  149. package/docs/workspace-operations.md +54 -9
  150. package/docs/workspace-repair-engine.md +17 -0
  151. package/package.json +1 -1
  152. package/dist/analyze-NUGNB256.js +0 -1
  153. package/dist/autopilot-release-TWJWSVVF.js +0 -1
  154. package/dist/capabilities-command-LHM3XIS6.js +0 -1
  155. package/dist/chunk-2647BYBC.js +0 -1
  156. package/dist/chunk-27UR373Z.js +0 -1
  157. package/dist/chunk-2VJUAKMS.js +0 -2
  158. package/dist/chunk-3A23KJAQ.js +0 -1
  159. package/dist/chunk-4PUJVYRM.js +0 -1
  160. package/dist/chunk-5B2GAZAC.js +0 -5
  161. package/dist/chunk-6DAQ7PYT.js +0 -13
  162. package/dist/chunk-CCAXADKP.js +0 -49
  163. package/dist/chunk-CCDGHPEJ.js +0 -2
  164. package/dist/chunk-CJHWKXDN.js +0 -1
  165. package/dist/chunk-CT4IODPG.js +0 -2
  166. package/dist/chunk-DK6JNE6K.js +0 -2
  167. package/dist/chunk-DOXNVBX6.js +0 -1
  168. package/dist/chunk-DWB2RRF4.js +0 -1
  169. package/dist/chunk-FQSBOLM7.js +0 -1
  170. package/dist/chunk-ILIBOMYL.js +0 -1
  171. package/dist/chunk-ISOOENLW.js +0 -8
  172. package/dist/chunk-J7RU5WR5.js +0 -2
  173. package/dist/chunk-JQLJBK5N.js +0 -1
  174. package/dist/chunk-KANAJH65.js +0 -681
  175. package/dist/chunk-KV6PS54A.js +0 -8
  176. package/dist/chunk-L22EABIC.js +0 -7
  177. package/dist/chunk-MOSXTVPU.js +0 -1
  178. package/dist/chunk-NHTDPXTW.js +0 -4
  179. package/dist/chunk-NZ3WZYD5.js +0 -1
  180. package/dist/chunk-Q2WF7D5U.js +0 -2
  181. package/dist/chunk-RSG2GJXT.js +0 -2
  182. package/dist/chunk-SFO5GVRT.js +0 -1
  183. package/dist/chunk-T5YRFRJV.js +0 -1
  184. package/dist/chunk-THIOE2PB.js +0 -2
  185. package/dist/chunk-TOYN76K4.js +0 -144
  186. package/dist/chunk-U5WVR74V.js +0 -1
  187. package/dist/chunk-UXEO5QCF.js +0 -33
  188. package/dist/chunk-VR6XMUF3.js +0 -2
  189. package/dist/chunk-WY4DOMEA.js +0 -1
  190. package/dist/chunk-XKDR5BGS.js +0 -6
  191. package/dist/chunk-Y5YAP4F3.js +0 -2
  192. package/dist/chunk-ZH7CXQH3.js +0 -94
  193. package/dist/goal-pack-FG3QDNQH.js +0 -1
  194. package/dist/project-intelligence-lens-PZPPSCUW.js +0 -1
  195. package/dist/verified-goal-BBHZRYYH.js +0 -1
  196. package/dist/workspace-contract-JS4LZZQZ.js +0 -1
  197. package/dist/workspace-explain-TITIT5XN.js +0 -1
  198. package/dist/workspace-explain-contract-V2IVSROX.js +0 -1
  199. package/dist/workspace-graph-stream-7UU2YVHC.js +0 -1
  200. package/dist/workspace-graph-token-efficiency-D7CUT6NX.js +0 -1
  201. package/dist/workspace-knowledge-graph-RSDP2E36.js +0 -1
  202. package/dist/workspace-knowledge-graph-snapshot-3FJHH5IK.js +0 -1
  203. package/dist/workspace-mcp-serve-WUIQ2AE6.js +0 -3
  204. package/dist/workspace-model-OKY4CQ3X.js +0 -1
  205. package/dist/workspace-repair-engine-VUBT77Y7.js +0 -3
  206. package/dist/workspace-run-SSF6Z26G.js +0 -1
  207. package/dist/workspace-watch-IOPSHQS5.js +0 -1
@@ -21,6 +21,40 @@
21
21
  },
22
22
  "additionalProperties": false
23
23
  }
24
+ },
25
+ "selection": {
26
+ "type": "object",
27
+ "required": ["generatedCount", "suppressedCount", "decisions"],
28
+ "properties": {
29
+ "generatedCount": { "type": "integer", "minimum": 0 },
30
+ "suppressedCount": { "type": "integer", "minimum": 0 },
31
+ "decisions": {
32
+ "type": "array",
33
+ "items": {
34
+ "type": "object",
35
+ "required": [
36
+ "skillId",
37
+ "title",
38
+ "status",
39
+ "confidence",
40
+ "reasons",
41
+ "signals",
42
+ "scopedProjects"
43
+ ],
44
+ "properties": {
45
+ "skillId": { "type": "string", "minLength": 1 },
46
+ "title": { "type": "string" },
47
+ "status": { "enum": ["generated", "suppressed"] },
48
+ "confidence": { "enum": ["high", "medium"] },
49
+ "reasons": { "type": "array", "items": { "type": "string" } },
50
+ "signals": { "type": "array", "items": { "type": "string" } },
51
+ "scopedProjects": { "type": "array", "items": { "type": "string" } }
52
+ },
53
+ "additionalProperties": false
54
+ }
55
+ }
56
+ },
57
+ "additionalProperties": false
24
58
  }
25
59
  },
26
60
  "additionalProperties": false
@@ -5,6 +5,7 @@
5
5
  "type": "object",
6
6
  "required": [
7
7
  "schemaVersion",
8
+ "producerRevision",
8
9
  "cliVersion",
9
10
  "inputsHash",
10
11
  "generatedAt",
@@ -14,6 +15,9 @@
14
15
  "schemaVersion": {
15
16
  "const": "workspace-model-cache.v1"
16
17
  },
18
+ "producerRevision": {
19
+ "const": "workspace-model-producer.v3"
20
+ },
17
21
  "cliVersion": {
18
22
  "type": "string",
19
23
  "minLength": 1
@@ -85,6 +85,72 @@
85
85
  ".workspai/repair/engine.lock"
86
86
  ]
87
87
  },
88
+ "qualificationMatrix": {
89
+ "schemaVersion": "workspai.workspace-repair-qualification-matrix.v1",
90
+ "status": "contract-enforced",
91
+ "dimensions": {
92
+ "adapters": [
93
+ "node",
94
+ "python",
95
+ "go",
96
+ "rust",
97
+ "php-composer",
98
+ "ruby-bundler",
99
+ "elixir-mix",
100
+ "deno",
101
+ "dotnet",
102
+ "jvm-maven",
103
+ "jvm-gradle",
104
+ "clojure",
105
+ "scala-sbt"
106
+ ],
107
+ "scopes": [
108
+ "project",
109
+ "workspace",
110
+ "linked-project",
111
+ "polyglot-project"
112
+ ],
113
+ "failureFamilies": [
114
+ "missing-tool",
115
+ "stale-evidence",
116
+ "missing-artifact",
117
+ "no-op-proposal",
118
+ "source-drift",
119
+ "validation-failure",
120
+ "producer-failure",
121
+ "provider-outage",
122
+ "interrupted-rollback",
123
+ "unsupported-runtime"
124
+ ],
125
+ "recoveryPaths": [
126
+ "automatic-refresh",
127
+ "bounded-replan",
128
+ "decision-required",
129
+ "checkpoint-rollback",
130
+ "durable-resume",
131
+ "manual-repair"
132
+ ],
133
+ "failureRecoveryPolicy": {
134
+ "missing-tool": "decision-required",
135
+ "stale-evidence": "automatic-refresh",
136
+ "missing-artifact": "automatic-refresh",
137
+ "no-op-proposal": "bounded-replan",
138
+ "source-drift": "bounded-replan",
139
+ "validation-failure": "checkpoint-rollback",
140
+ "producer-failure": "bounded-replan",
141
+ "provider-outage": "durable-resume",
142
+ "interrupted-rollback": "durable-resume",
143
+ "unsupported-runtime": "manual-repair"
144
+ }
145
+ },
146
+ "invariants": {
147
+ "everyAdapterDeclaresClosureStages": true,
148
+ "everyFailureTerminates": true,
149
+ "everyMutationIsCheckpointed": true,
150
+ "workspaceAndProjectScopesUseTheSameEngine": true,
151
+ "linkedProjectsRemainBoundaryChecked": true
152
+ }
153
+ },
88
154
  "adapters": [
89
155
  {
90
156
  "id": "node",
@@ -0,0 +1 @@
1
+ export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-EP4CUWOO.js';
@@ -1 +1 @@
1
- export{a as buildArtifactRemediationPlan,b as writeArtifactRemediationPlan}from'./chunk-WRQWVSBJ.js';
1
+ export{a as buildArtifactRemediationPlan,b as writeArtifactRemediationPlan}from'./chunk-YX5VWPR5.js';
@@ -0,0 +1 @@
1
+ export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-IIFFEEMX.js';
@@ -0,0 +1 @@
1
+ export{b as runDoctorCapabilities}from'./chunk-3H5ACWWZ.js';
@@ -0,0 +1,2 @@
1
+ import {r,s}from'./chunk-VQZ5PI5J.js';import o from'fs-extra';async function i(a){for(let t of [r(a),s(a)])try{if(await o.pathExists(t))return await o.readJson(t)}catch{}return null}async function c(a,t){let e=await i(a);e?.metadata&&(t.metadata={...e.metadata,...t.metadata});let r$1=JSON.stringify(t,null,2)+`
2
+ `;await o.outputFile(r(a),r$1,"utf-8");}async function m(a,t){let e=await i(a);return e?(e.metadata={...e.metadata,...t,vscode:t.vscode?{...e.metadata?.vscode,...t.vscode}:e.metadata?.vscode,npm:t.npm?{...e.metadata?.npm,...t.npm}:e.metadata?.npm,python:t.python?{...e.metadata?.python,...t.python}:e.metadata?.python},await c(a,e),true):false}function u(a,t,e,r){return {signature:"RAPIDKIT_WORKSPACE",createdBy:"workspai-cli",version:t,createdAt:new Date().toISOString(),name:a,metadata:{npm:{packageVersion:t,installMethod:e,lastUsedAt:new Date().toISOString()},...r?{python:r}:{}}}}function f(a){if(!a||typeof a!="object")return false;let t=a;return t.signature==="RAPIDKIT_WORKSPACE"&&typeof t.createdBy=="string"&&typeof t.version=="string"&&typeof t.createdAt=="string"&&typeof t.name=="string"}export{i as a,c as b,m as c,u as d,f as e};
@@ -1 +1 @@
1
- import {f,l}from'./chunk-CJHWKXDN.js';import {a,b}from'./chunk-S5KTATOU.js';function u(r){let s=new Map;for(let n of r.projects)s.has(n.name)||s.set(n.name,f(n));return s}function w(r){let s=u(r),n=l(r)??{nodes:r.projects.map(t=>({id:t.name,path:t.path})),edges:[]},a$1=a(n),o=new Map;for(let t of n.nodes){let e=s.get(t.id)??f({missing:t.id}),l=[...b(a$1,[t.id],{direction:"dependencies"}).keys()].filter(c=>c!==t.id).sort((c,f)=>c.localeCompare(f)).map(c=>({id:c,hash:s.get(c)??"<unknown>"}));o.set(t.id,{id:t.id,ownHash:e,transitiveInputsHash:f({own:e,dependencies:l})});}return o}function y(r,s){if(!s||Object.keys(s).length===0)return {verdict:"unknown",baseline:"none",changed:[],added:[],removed:[]};let n=[],a=[];for(let[e,i]of r.entries())e in s?s[e]!==i.transitiveInputsHash&&n.push(e):a.push(e);let o=[];for(let e of Object.keys(s))r.has(e)||o.push(e);return n.sort((e,i)=>e.localeCompare(i)),a.sort((e,i)=>e.localeCompare(i)),o.sort((e,i)=>e.localeCompare(i)),{verdict:n.length>0||a.length>0||o.length>0?"stale":"fresh",baseline:"recorded",changed:n,added:a,removed:o}}function M(r){let s={};for(let[n,a]of [...r.entries()].sort((o,t)=>o[0].localeCompare(t[0])))s[n]=a.transitiveInputsHash;return s}export{u as a,w as b,y as c,M as d};
1
+ import {d,m}from'./chunk-PJPS7CNH.js';import {a,b}from'./chunk-S5KTATOU.js';function u(r){let s=new Map;for(let n of r.projects)s.has(n.name)||s.set(n.name,d(n));return s}function w(r){let s=u(r),n=m(r)??{nodes:r.projects.map(t=>({id:t.name,path:t.path})),edges:[]},a$1=a(n),o=new Map;for(let t of n.nodes){let e=s.get(t.id)??d({missing:t.id}),l=[...b(a$1,[t.id],{direction:"dependencies"}).keys()].filter(c=>c!==t.id).sort((c,f)=>c.localeCompare(f)).map(c=>({id:c,hash:s.get(c)??"<unknown>"}));o.set(t.id,{id:t.id,ownHash:e,transitiveInputsHash:d({own:e,dependencies:l})});}return o}function y(r,s){if(!s||Object.keys(s).length===0)return {verdict:"unknown",baseline:"none",changed:[],added:[],removed:[]};let n=[],a=[];for(let[e,i]of r.entries())e in s?s[e]!==i.transitiveInputsHash&&n.push(e):a.push(e);let o=[];for(let e of Object.keys(s))r.has(e)||o.push(e);return n.sort((e,i)=>e.localeCompare(i)),a.sort((e,i)=>e.localeCompare(i)),o.sort((e,i)=>e.localeCompare(i)),{verdict:n.length>0||a.length>0||o.length>0?"stale":"fresh",baseline:"recorded",changed:n,added:a,removed:o}}function M(r){let s={};for(let[n,a]of [...r.entries()].sort((o,t)=>o[0].localeCompare(t[0])))s[n]=a.transitiveInputsHash;return s}export{u as a,w as b,y as c,M as d};
@@ -0,0 +1,7 @@
1
+ import {a}from'./chunk-A5FBGRJA.js';import {a as a$1}from'./chunk-AFIFZTOY.js';import {i as i$1,h}from'./chunk-6UNATTB7.js';import {s}from'./chunk-RGNCL5OB.js';import {k,v,e,a as a$2,u,f as f$1}from'./chunk-VQZ5PI5J.js';import b from'crypto';import P from'fs';import d from'fs/promises';import i from'path';import T from'fs-extra';var x=h.projectWorkspaceLink.schemaVersion,L="workspai.project-workspace-link",l=class extends Error{constructor(r,a,o={}){super(a);this.code=r;this.context=o;this.name="ProjectWorkspaceResolutionError";}code;context};function $(e){return P.existsSync(i.join(e,".workspai-workspace"))?".workspai-workspace":".workspai/workspace.json"}function _(e){return b.createHash("sha256").update([e.workspaceName,a(e.workspacePath),e.projectName,a(e.projectPath),e.relativePath.replace(/\\/g,"/"),e.relationship].join("\0")).digest("hex")}function I(e){let t=i.resolve(e);for(;;){if(k(t))return t;let r=i.dirname(t);if(r===t)return null;t=r;}}function J(e){let t=i.resolve(e);for(;;){if([...u(t,"project.json"),...u(t,"context.json")].some(a=>P.existsSync(a)))return t;let r=i.dirname(t);if(r===t)return null;t=r;}}function y(e){return JSON.parse(P.readFileSync(e,"utf8"))}function K(e){let t=y(e);if(!t||typeof t!="object"||Array.isArray(t))throw new l("project.workspace.link-invalid",`Project workspace link is not a JSON object: ${e}`,{linkPath:e});let r=t;if(r.schemaVersion!==x||r.kind!==L||r.state!=="active"||!r.workspace||typeof r.workspace.name!="string"||r.workspace.name.trim().length===0||typeof r.workspace.root!="string"||!i.isAbsolute(r.workspace.root)||![".workspai-workspace",".workspai/workspace.json"].includes(r.workspace.marker??"")||r.workspace.contract!==i$1.workspaceContract||!r.project||typeof r.project.name!="string"||r.project.name.trim().length===0||typeof r.project.relativePath!="string"||i.isAbsolute(r.project.relativePath)||r.project.relativePath.split(/[\\/]/).includes("..")||!["managed","adopted","imported","linked","restored"].includes(r.project.relationship??"")||!r.integrity||r.integrity.algorithm!=="sha256"||typeof r.integrity.binding!="string"||!/^[a-f0-9]{64}$/.test(r.integrity.binding))throw new l("project.workspace.link-invalid",`Project workspace link does not satisfy ${x}: ${e}`,{linkPath:e});try{a$1(t,"contracts/project-workspace-link.v1.json","Project workspace link");}catch(a){throw new l("project.workspace.link-invalid",`Project workspace link does not satisfy ${x}: ${e}`,{linkPath:e,validationError:a instanceof Error?a.message:String(a)})}return r}function f(e,t){let r=i.join(e,".workspai","workspace.contract.json");if(!P.existsSync(r))return null;try{let a$1=y(r);if(!Array.isArray(a$1.projects))return false;let o=a(t);return a$1.projects.some(n=>typeof n.externalPath=="string"?a(n.externalPath)===o:typeof n.relativePath!="string"||n.relativePath.startsWith("external/")?false:a(i.resolve(e,n.relativePath))===o)}catch{return false}}function M(e,t,r){let a$1=a(e),o=new Map;for(let n of s(t,r)){if(!P.existsSync(n))continue;let c;try{c=y(n);}catch{continue}if(Array.isArray(c.workspaces))for(let p of c.workspaces){if(!p||typeof p.name!="string"||typeof p.path!="string"||!Array.isArray(p.projects)||!p.projects.some(w=>w&&typeof w.path=="string"&&a(w.path)===a$1))continue;let s=a(p.path);!k(s)||f(s,e)!==true||o.set(s,{name:p.name,path:s});}}return [...o.values()].sort((n,c)=>n.path.localeCompare(c.path))}function m(e,t){if(e)throw t;return null}function te(e$1){let t=e$1.strict===true,r=i.resolve(e$1.startPath),a=e$1.explicitWorkspacePath?i.resolve(e$1.explicitWorkspacePath):null,o=J(r);if(a)return k(a)?e$1.requireProjectMembership===true&&o&&f(a,o)!==true?m(t,new l("project.workspace.membership-missing",`Project is not registered in the explicit workspace contract: ${a}`,{workspacePath:a,projectPath:o})):{workspacePath:a,projectPath:o,source:"explicit",linkPath:o?v(o,e):null,recovered:false}:m(t,new l("project.workspace.explicit-invalid",`Explicit workspace path is not a Workspai workspace: ${a}`,{workspacePath:a,projectPath:o}));let n=I(r);if(n)return e$1.requireProjectMembership===true&&o&&f(n,o)!==true?m(t,new l("project.workspace.membership-missing",`Project is not registered in its parent workspace contract: ${n}`,{workspacePath:n,projectPath:o})):{workspacePath:n,projectPath:o,source:"parent",linkPath:o?v(o,e):null,recovered:false};if(!o)return m(t,new l("project.workspace.unlinked","No Workspai project or workspace could be resolved from the current directory.",{startPath:r}));let c=v(o,e),p=null;if(P.existsSync(c)){let s;try{s=K(c);}catch(O){if(t)throw O;return null}let u=_({workspaceName:s.workspace.name,workspacePath:s.workspace.root,projectName:s.project.name,projectPath:o,relativePath:s.project.relativePath,relationship:s.project.relationship}),w=f(s.workspace.root,o);if(s.integrity.binding===u&&k(s.workspace.root)&&P.existsSync(i.join(s.workspace.root,s.workspace.marker))&&w===true)return {workspacePath:i.resolve(s.workspace.root),projectPath:o,source:"local-link",linkPath:c,recovered:false};p=s;}let h=M(o,e$1.env??process.env,e$1.platform??process.platform);return h.length>1?m(t,new l("project.workspace.ambiguous",`Project is registered in more than one valid workspace: ${h.map(s=>s.name).join(", ")}. Pass --workspace <path> or run project workspace relink.`,{projectPath:o,candidates:h})):h.length===1?{workspacePath:h[0].path,projectPath:o,source:"registry",linkPath:c,recovered:p!==null}:p?m(t,new l("project.workspace.link-stale",`Project workspace link is stale and no valid registry relocation was found: ${p.workspace.root}`,{projectPath:o,linkPath:c,linkedWorkspacePath:p.workspace.root})):m(t,new l("project.workspace.unlinked","This Workspai project is not linked to a valid workspace. Run `npx workspai adopt .` or `npx workspai project workspace relink --workspace <path>`.",{projectPath:o,linkPath:c}))}async function F(e,t){await d.mkdir(i.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${b.randomUUID()}.tmp`;try{await d.writeFile(r,`${JSON.stringify(t,null,2)}
2
+ `,{encoding:"utf8",mode:384});try{await d.rename(r,e);}catch(a){let o=a.code;if(o!=="EEXIST"&&o!=="EPERM")throw a;await T.move(r,e,{overwrite:true});}}finally{await d.rm(r,{force:true}).catch(()=>{});}}async function D(e){let t=i.join(e,".gitignore"),r=await d.readFile(t,"utf8").catch(c=>{if(c.code==="ENOENT")return "";throw c});if(r.split(/\r?\n/).map(c=>c.trim()).includes(f$1))return;let n=`${r.length>0&&!r.endsWith(`
3
+ `)?`
4
+ `:""}
5
+ # Workspai machine-local workspace binding
6
+ ${f$1}
7
+ `;await d.writeFile(t,`${r}${n}`,"utf8");}async function V(e$1){let t=i.resolve(e$1.workspacePath),r=i.resolve(e$1.projectPath);if(!k(t))throw new l("project.workspace.explicit-invalid",`Cannot link project to an invalid Workspai workspace: ${t}`,{workspacePath:t,projectPath:r});let a$3=i.join(t,".workspai","workspace.contract.json"),o=e$1.workspaceName??i.basename(t),n=e$1.relativePath;if(P.existsSync(a$3)){let h=y(a$3);typeof h.workspace?.name=="string"&&(o=h.workspace.name);let s=a(r),u=h.projects?.find(w=>typeof w.externalPath=="string"?a(w.externalPath)===s:typeof w.relativePath=="string"&&!w.relativePath.startsWith("external/")&&a(i.resolve(t,w.relativePath))===s);u&&typeof u.relativePath=="string"&&(n=u.relativePath);}if(n??=i.relative(t,r).replace(/\\/g,"/"),(!n||n.startsWith(".."))&&(n=`external/${e$1.projectName}`),f(t,r)!==true)throw new l("project.workspace.membership-missing",`Project is not registered in the canonical workspace contract: ${e$1.projectName}`,{workspacePath:t,projectPath:r,projectName:e$1.projectName});let c={schemaVersion:x,kind:L,generatedAt:(e$1.now??new Date).toISOString(),state:"active",workspace:{name:o,root:t,marker:$(t),contract:i$1.workspaceContract},project:{name:e$1.projectName,relativePath:n,relationship:e$1.relationship},integrity:{algorithm:"sha256",binding:_({workspaceName:o,workspacePath:t,projectName:e$1.projectName,projectPath:r,relativePath:n,relationship:e$1.relationship})}};a$1(c,"contracts/project-workspace-link.v1.json","Project workspace link");let p=i.join(r,a$2,e);return await D(r),await F(p,c),{linkPath:p,link:c}}async function oe(e,t="linked"){if(!e.projectPath)return null;let r=u(e.projectPath,"project.json").find(o=>P.existsSync(o)),a=i.basename(e.projectPath);if(r)try{let o=y(r);typeof o.name=="string"?a=o.name:typeof o.slug=="string"&&(a=o.slug);}catch{}return V({workspacePath:e.workspacePath,projectPath:e.projectPath,projectName:a,relationship:t})}export{l as a,te as b,V as c,oe as d};
@@ -1,4 +1,4 @@
1
- import {a as a$1}from'./chunk-VRGEPPUB.js';import {a}from'./chunk-NS53IPAC.js';import {e}from'./chunk-CCDGHPEJ.js';import {h as h$1,b,a as a$2,d,c}from'./chunk-NZ3WZYD5.js';import pe from'path';import h from'chalk';import {createHash}from'crypto';var F="workspai.doctor-adapter.v1",D=["runtime","dependency","security","configuration","test","quality"];function A(e){return e.trim().toLowerCase().replace(/[^a-z0-9+.#-]+/g,"-")}function ae(e){if(e.contractVersion!==F)throw new Error(`Unsupported Doctor adapter contract: ${e.contractVersion}`);if(!e.id.trim())throw new Error("Doctor adapter id must not be empty.");if(e.runtimeFamilies.length===0)throw new Error(`Doctor adapter ${e.id} must own at least one runtime family.`);if(e.platforms.length===0)throw new Error(`Doctor adapter ${e.id} must declare supported platforms.`);let i=e.domains.map(t=>t.domain);if(i.length!==D.length||new Set(i).size!==D.length||D.some(t=>!i.includes(t)))throw new Error(`Doctor adapter ${e.id} must declare every canonical diagnostic domain exactly once.`);for(let t of e.domains)if(t.level==="unsupported"&&t.limitations.length===0)throw new Error(`Doctor adapter ${e.id} must explain unsupported ${t.domain} coverage.`)}var $=class{#e=new Map;#i=new Map;#t=new Map;register(i){ae(i);let t=A(i.id);if(this.#e.has(t))throw new Error(`Doctor adapter id is already registered: ${i.id}`);let s=[...i.runtimeFamilies,...i.aliases].map(A);for(let c of s){let a=this.#i.get(c);if(a)throw new Error(`Doctor runtime ${c} is already owned by adapter ${a}.`)}for(let c of i.frameworks.map(A)){let a=this.#t.get(c);if(a)throw new Error(`Doctor framework ${c} is already owned by adapter ${a}.`)}let r=structuredClone(i);this.#e.set(t,r);for(let c of s)this.#i.set(c,t);for(let c of i.frameworks.map(A))this.#t.set(c,t);return this}resolveWithDiagnostics(i){let t=i.runtimeFamily?this.#i.get(A(i.runtimeFamily)):void 0,s=i.framework?this.#t.get(A(i.framework)):void 0;if(t&&s&&t!==s)return {status:"conflict",descriptor:null,runtimeOwner:t,frameworkOwner:s};let r=t??s;return {status:r?"matched":"unresolved",descriptor:r?structuredClone(this.#e.get(r)??null):null,...t?{runtimeOwner:t}:{},...s?{frameworkOwner:s}:{}}}resolve(i){return this.resolveWithDiagnostics(i).descriptor}list(){return [...this.#e.values()].map(i=>structuredClone(i)).sort((i,t)=>i.id.localeCompare(t.id))}};var Y=[...D],W=["linux","darwin","win32"],re=[{id:"node",aliases:["nodejs","javascript","typescript"],frameworks:["NestJS","Next.js","Remix","Nuxt","React","Vue","Angular","SvelteKit","Svelte","Vite","Astro","Solid","Express","Fastify","Koa","Electron","VS Code Extension"],tier:"first-class",native:Y},{id:"python",aliases:["py"],frameworks:["FastAPI","Django","Flask","Python"],tier:"first-class",native:Y},{id:"go",aliases:["golang"],frameworks:["Go","Go/Fiber","Go/Gin","Echo"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"java",aliases:["jvm"],frameworks:["Java","Spring Boot"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"dotnet",aliases:[".net","csharp","c#"],frameworks:["ASP.NET"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"rust",aliases:["cargo"],frameworks:["Rust","Axum"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"php",aliases:["composer"],frameworks:["PHP","Laravel"],tier:"first-class",native:["runtime","dependency","security"],portable:["configuration","test","quality"]},{id:"ruby",aliases:["bundler"],frameworks:["Ruby","Ruby on Rails"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"elixir",aliases:["beam"],frameworks:["Elixir","Phoenix"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"clojure",frameworks:["Clojure"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"deno",frameworks:["Deno"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"bun",frameworks:["Bun"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"scala",frameworks:["Scala"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"kotlin",frameworks:["Kotlin"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"c",aliases:["c-lang"],frameworks:["C"],tier:"extended",portable:["runtime","dependency","test","quality"],observable:["configuration"],limitations:["Security diagnosis requires a declared native scanner or workspace adapter."]},{id:"cpp",aliases:["c++","cplusplus"],frameworks:["C++"],tier:"extended",portable:["runtime","dependency","test","quality"],observable:["configuration"],limitations:["Security diagnosis requires a declared native scanner or workspace adapter."]}];function oe(e,i){let t={runtime:["project markers","entrypoints","toolchain evidence"],dependency:["dependency manifests","lockfiles","installed-tree evidence"],security:["runtime-native audit","advisory evidence"],configuration:["environment contracts","deployment/container markers"],test:["test scripts","test configuration","coverage evidence"],quality:["lint/format/static-analysis contracts"]};return [`${e} adapter`,...t[i]]}function ce(e,i){return e.native?.includes(i)?"native":e.portable?.includes(i)?"portable":e.observable?.includes(i)?"observable":"unsupported"}function le(e){let i=D.map(t=>{let s=ce(e,t);return {domain:t,level:s,evidenceSources:s==="unsupported"?[]:oe(e.id,t),limitations:s==="unsupported"?[`${e.id} has no built-in ${t} provider; declare a workspace adapter.`]:s==="observable"?[`${t} evidence is observable but not runtime-native for ${e.id}.`]:[]}});return {contractVersion:F,id:`builtin.${e.id}`,runtimeFamilies:[e.id],aliases:e.aliases??[],frameworks:e.frameworks,projectKinds:["backend","frontend","desktop","extension","fullstack","generic"],tier:e.tier,platforms:[...W],domains:i,repairModes:["typed-operation","structured-invocation","manual-guidance"],source:"builtin",limitations:e.limitations??[]}}function de(){return {contractVersion:F,id:"builtin.unknown",runtimeFamilies:["unknown"],aliases:["generic","unrecognized"],frameworks:["Unknown"],projectKinds:["backend","frontend","desktop","extension","fullstack","generic"],tier:"fallback",platforms:[...W],domains:D.map(e=>({domain:e,level:e==="security"?"unsupported":"observable",evidenceSources:e==="security"?[]:["portable workspace markers","declared custom checks"],limitations:[e==="security"?"No safe security claim is possible without a runtime-native audit provider.":`Only portable ${e} evidence is available until a runtime adapter is registered.`]})),repairModes:["manual-guidance"],source:"builtin",limitations:["Unknown runtimes are fail-closed: missing domain evidence is reported as unknown, never healthy.","Automatic repair is unavailable until a typed adapter owns the runtime."]}}function P(){let e=new $;for(let i of re)e.register(le(i));return e.register(de()),e}function J(e,i=P()){let t=i.resolveWithDiagnostics(e),s=t.descriptor??i.resolve({runtimeFamily:"unknown"});if(!s)throw new Error("Doctor fallback adapter is not registered.");let r=c=>s.domains.filter(a=>a.level===c).map(a=>a.domain);return {registryVersion:b,adapterId:s.id,runtimeFamily:s.runtimeFamilies[0]??"unknown",tier:s.tier,confidence:s.tier==="first-class"?"high":s.tier==="extended"?"medium":"low",nativeDomains:r("native"),portableDomains:r("portable"),observableDomains:r("observable"),unsupportedDomains:r("unsupported"),limitations:[...t.status==="conflict"?[`Runtime/framework ownership conflict (${t.runtimeOwner} vs ${t.frameworkOwner}); Doctor failed closed instead of selecting an ambiguous adapter.`]:[],...s.limitations,...s.domains.flatMap(c=>c.limitations)]}}function K(e={}){let i=P(),t=i.list(),s=i.resolveWithDiagnostics({runtimeFamily:e.runtime,framework:e.framework}),r=e.runtime||e.framework?[s.descriptor]:t;if((e.runtime||e.framework)&&!r[0]){let a=i.resolve({runtimeFamily:"unknown"});a&&(s.status==="conflict"&&a.limitations.unshift(`Runtime/framework ownership conflict (${s.runtimeOwner} vs ${s.frameworkOwner}); Doctor failed closed instead of selecting an ambiguous adapter.`),r[0]=a);}let c=r.filter(a=>!!a);return {schemaVersion:a$2,registryVersion:b,generatedBy:"workspai",policy:{unknownIsHealthy:false,unsupportedIsHealthy:false,repairRequiresTypedOperation:true,canonicalDomains:[...D]},summary:{adapterCount:c.length,firstClassRuntimes:c.filter(a=>a.tier==="first-class").length,extendedRuntimes:c.filter(a=>a.tier==="extended").length,fallbackRuntimes:c.filter(a=>a.tier==="fallback").length,frameworkCount:new Set(c.flatMap(a=>a.frameworks)).size,platformCount:new Set(c.flatMap(a=>a.platforms)).size},adapters:c}}var me=["runtime","dependency","security","configuration","test","quality"];function I(e){return createHash("sha256").update(e).digest("hex").slice(0,12)}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Q(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim()}function ge(e,i){let t=Q(e);return t?i.some(s=>[s.reason,s.recommendation??""].map(Q).filter(Boolean).some(c=>c===t||c.includes(t)||t.includes(c))):true}function fe(e){return e.status==="fail"?"blocking":e.status==="warn"?"advisory":"informational"}function X(e){return e.issueClass==="dependency"?"dependency":e.issueClass==="security"?"security":e.issueClass==="environment"||e.issueClass==="configuration"||e.issueClass==="container"||e.issueClass==="deployment"||e.issueClass==="workspace-contract"?"configuration":e.issueClass==="test"?"test":e.issueClass==="quality"||e.issueClass==="custom"?"quality":e.issueClass==="runtime"||e.issueClass==="framework"||e.issueClass==="source-tree"?"runtime":null}function ye(e,i){return me.map(t=>{let s=e.filter(o=>X(o)===t),r=e.filter(o=>o.applicability!=="not-applicable"&&X(o)===t),c=i.unsupportedDomains.includes(t);if(r.length===0){let o=s.some(d=>d.applicability==="not-applicable");return {id:t,status:o?"not-applicable":"not-run",observationCount:0,blockingFindings:0,advisoryFindings:0,reason:o?`${t} checks ran and found no declared intent requiring this domain.`:c?`${t} is unsupported by Doctor adapter ${i.adapterId}; no healthy claim is allowed.`:`No ${t} diagnostic observation was produced.`}}let a=r.some(o=>o.freshness?.status==="stale"||o.freshness?.status==="unknown"),p=r.filter(o=>o.status==="fail").length,m=r.filter(o=>o.status==="warn").length,C=p>0||m>0;return {id:t,status:a?"stale":C?"findings":c?"not-run":"clean",observationCount:r.length,blockingFindings:p,advisoryFindings:m,reason:a?`${t} evidence is stale or has unknown freshness.`:C?`${t} diagnostics produced findings.`:c?`${t} observations cannot establish complete health because adapter ${i.adapterId} declares the domain unsupported.`:`${t} diagnostics completed without findings.`}})}function De(e){if(e.status==="pass")return "not-needed";let i=e.repairCapability;return i?i.status==="manual"||i.requiresReview?"manual":i.status!=="available"||!i.canAutoFix?"unavailable":i.requiresApproval?"approval-required":"automatic":"unavailable"}function be(e){if(e.freshness?.status==="stale"||e.freshness?.status==="unknown")return {label:"low",score:.35,state:"unknown"};let i=!!(e.issueClass&&e.issueClass!=="unknown"),t=!!(e.repairCapability?.operation?.type||e.repairCapability?.invocation?.executable);return i&&t&&e.repairIntent?.confidence==="high"?{label:"high",score:.95,state:"confirmed"}:i&&(e.status==="fail"||e.status==="warn")?{label:"medium",score:t?.82:.68,state:"candidate"}:e.status==="pass"?{label:"high",score:.98,state:"confirmed"}:{label:"low",score:.3,state:"unknown"}}function ve(e,i){let t=[{kind:"probe",role:"observation",ref:`probe:${e.id}`,claim:e.reason}];for(let r of e.repairCapability?.files??[])t.push({kind:"file",role:"repair-target",ref:r.split(pe.sep).join("/"),claim:"Structured repair capability declared this path as an affected target."});if(e.repairCapability?.invocation?.executable){let r=e.repairCapability.invocation;t.push({kind:"command",role:"verification",ref:[r.executable,...r.args??[]].join(" "),claim:"Structured command invocation is available for this diagnostic path."});}if(e.issueClass==="security"&&/(?:dependency|audit|vulnerab|security-hygiene)/i.test(`${e.id} ${e.label}`))for(let r of i??[])t.push({kind:"dependency",role:"subject",ref:r.version?`${r.name}@${r.version}`:r.name,claim:r.advisoryIds&&r.advisoryIds.length>0?`Dependency is referenced by ${r.advisoryIds.join(", ")}.`:"Dependency is present in security audit evidence."});return t}function we(e,i){let t=i.issueClass?.trim()||"unknown",s=be(i);return {id:`${S(i.id)}:${I(`${e.projectPath}\0${i.id}`)}`,causalKey:[S(e.projectName),I(e.projectPath),S(t),S(i.id)].join(":"),projectName:e.projectName,projectPath:e.projectPath,probeId:i.id,label:i.label,status:fe(i),severity:i.severity,issueClass:t,operationalImpact:i.operationalImpact?.trim()||"developer-friction",applicability:i.applicability??"applicable",confidence:s.label,confidenceScore:s.score,diagnosisState:s.state,symptom:i.reason,...i.recommendation?{recommendation:i.recommendation}:{},proofs:ve(i,e.dependencySubjects),repair:{disposition:De(i),...i.repairCapability?.id?{capabilityId:i.repairCapability.id}:{},...i.repairCapability?.operation?.type?{operationType:i.repairCapability.operation.type}:{},...i.repairCapability?.verifyCommand?{verifyCommand:i.repairCapability.verifyCommand}:{},requiresFreshEvidence:i.repairIntent?.requiresFreshEvidence===true||i.freshness?.verifyBeforeUse===true}}}function he(e,i,t){let s=`legacy-runtime-issue-${t+1}`;return {id:`${s}:${I(`${e.projectPath}\0${i}`)}`,causalKey:[S(e.projectName),I(e.projectPath),"unknown",I(i)].join(":"),projectName:e.projectName,projectPath:e.projectPath,probeId:s,label:"Runtime diagnostic issue",status:"blocking",severity:"error",issueClass:"unknown",operationalImpact:"runtime-risk",applicability:"applicable",confidence:"low",confidenceScore:.25,diagnosisState:"unknown",symptom:i,proofs:[{kind:"unknown",role:"observation",ref:`legacy-issue:${t+1}`,claim:i}],repair:{disposition:"unavailable",requiresFreshEvidence:true}}}function Z(e){let i=[...e.probes],t=[...new Set((e.runtimeFamilies&&e.runtimeFamilies.length>0?e.runtimeFamilies:[e.runtimeFamily??"unknown"]).filter(Boolean))],s=e.runtimeFamily??t[0]??"unknown",r=t.filter(n=>n!==s&&n!=="unknown"),c=J({runtimeFamily:e.runtimeFamily,framework:e.framework},e.adapterRegistry),a$1=ye(i,c),p=(e.legacyIssues??[]).filter(n=>!ge(n,i)),m=new Map;for(let n of i){let l=m.get(n.id)??new Set;l.add(n.status),m.set(n.id,l);}let C=[...m.entries()].filter(([,n])=>n.size>1).map(([n,l])=>({probeId:n,statuses:[...l].sort(),reason:"The same diagnostic probe produced contradictory states in one project scan."})),o=[...i.filter(n=>n.applicability!=="not-applicable"&&n.status!=="pass").map(n=>we(e,n)),...p.map((n,l)=>he(e,n,l))],d={blocking:4,unknown:3,advisory:2,informational:1},O=new Map;for(let n of o){let l=O.get(n.causalKey)??[];l.push(n),O.set(n.causalKey,l);}let g=[...O.values()].map(n=>{let u=[...n].sort((f,j)=>d[j.status]-d[f.status]||j.confidenceScore-f.confidenceScore||f.id.localeCompare(j.id)).at(0);if(!u)throw new Error("Doctor diagnosis causal group cannot be empty.");let G=structuredClone(u);return G.proofs=[...new Map(n.flatMap(f=>f.proofs).map(f=>[`${f.kind}:${f.role}:${f.ref}:${f.claim}`,f])).values()],G}).sort((n,l)=>n.causalKey.localeCompare(l.causalKey)||n.id.localeCompare(l.id)),k=new Map;for(let n of g){let l=k.get(n.causalKey)??[];l.push(n),k.set(n.causalKey,l);}let b=[...k.entries()].map(([n,l])=>({causalKey:n,issueClass:l[0]?.issueClass??"unknown",status:l.some(u=>u.status==="blocking")?"blocking":l.some(u=>u.status==="advisory")?"advisory":l.some(u=>u.status==="unknown")?"unknown":"informational",findingIds:l.map(u=>u.id),projectPaths:[...new Set(l.map(u=>u.projectPath))],repairable:l.some(u=>u.repair.disposition==="automatic"||u.repair.disposition==="approval-required")})),v=[...g.filter(n=>n.diagnosisState==="unknown"||n.issueClass==="unknown"||n.applicability==="unknown").map(n=>({id:`unknown:${n.id}`,probeId:n.probeId,reason:n.issueClass==="unknown"?"The observation is real, but Doctor cannot yet bind it to a typed issue class.":"Evidence is insufficient or stale for a confirmed diagnosis."})),...a$1.filter(n=>n.status==="not-run"||n.status==="stale").map(n=>({id:`unknown:domain:${n.id}:${I(e.projectPath)}`,reason:n.reason})),...r.map(n=>({id:`unknown:runtime:${S(n)}:${I(e.projectPath)}`,reason:e.projectArchetype==="platform"?`${n} is part of this cross-language platform, but only portable evidence and the primary ${s} runtime adapter were evaluated. Add a typed ${n} adapter before making runtime-specific health claims.`:`${n} was detected inside this composite project boundary, but the ${s} adapter is the only runtime-specific adapter evaluated for this scan. Declare a nested project boundary or a typed Doctor adapter before treating ${n} as healthy.`}))],y=g.filter(n=>n.diagnosisState!=="unknown").length,x=g.length===0?100:y/g.length*100,ie=a$1.filter(n=>n.status!=="not-run"&&n.status!=="stale").length/a$1.length*100,U=t.filter(n=>n!=="unknown").length,te=s!=="unknown"&&t.includes(s)?1:0,ne=U===0?0:te/U*100,se=Math.round(Math.min(x,ie,ne)*100)/100;return {schemaVersion:a,engineVersion:"universal-diagnosis-v1",project:{name:e.projectName,path:e.projectPath,runtimeFamily:e.runtimeFamily??"unknown",runtimeFamilies:t,framework:e.framework??"Unknown",projectKind:e.projectKind??"generic"},capability:c,domains:a$1,coverage:{totalObservations:i.length+p.length,evaluatedObservations:i.filter(n=>n.applicability!=="not-applicable").length,passingObservations:i.filter(n=>n.applicability!=="not-applicable"&&n.status==="pass").length,blockingFindings:g.filter(n=>n.status==="blocking").length,advisoryFindings:g.filter(n=>n.status==="advisory").length,unknownFindings:v.length,repairableFindings:g.filter(n=>n.repair.disposition==="automatic"||n.repair.disposition==="approval-required").length,manualFindings:g.filter(n=>n.repair.disposition==="manual").length,unsupportedFindings:g.filter(n=>n.repair.disposition==="unavailable").length,contradictionCount:C.length,diagnosisCompleteness:se},findings:g,causalGroups:b,unknowns:v,contradictions:C}}function w(e){let i=e.severity??"error",t=e.repair??"unavailable";return {id:e.id,label:e.label,status:i==="error"?"fail":"warn",severity:i,reason:`${e.label} detected by the validation corpus.`,issueClass:e.issueClass,operationalImpact:i==="error"?"release-risk":"ci-risk",repairIntent:{confidence:e.confidence??"medium",requiresFreshEvidence:true},...t==="unavailable"?{}:{repairCapability:{id:`repair.${e.id}`,status:t==="manual"?"manual":"available",canAutoFix:t==="automatic"||t==="approval-required",requiresApproval:t==="approval-required",requiresReview:t==="manual",operation:{type:"validation-operation"},verifyCommand:"npx workspai doctor project --json"}}}}var Ce=[{id:"runtime-missing",diseaseClass:"runtime",description:"Required runtime is absent.",probe:w({id:"runtime-missing",label:"Runtime missing",issueClass:"runtime"}),expected:{finding:true,domain:"runtime",status:"blocking",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"dependencies-missing",diseaseClass:"dependency",description:"Installed dependency tree is absent.",probe:w({id:"dependencies-missing",label:"Dependencies missing",issueClass:"dependency",repair:"automatic",confidence:"high"}),expected:{finding:true,domain:"dependency",status:"blocking",diagnosisState:"confirmed",repairDisposition:"automatic"}},{id:"security-advisory",diseaseClass:"security",description:"A runtime-native audit reports a blocking advisory.",probe:w({id:"security-advisory",label:"Security advisory",issueClass:"security",repair:"approval-required",confidence:"high"}),expected:{finding:true,domain:"security",status:"blocking",diagnosisState:"confirmed",repairDisposition:"approval-required"}},{id:"environment-contract",diseaseClass:"configuration",description:"Environment/configuration contract is incomplete.",probe:w({id:"environment-contract",label:"Environment contract incomplete",issueClass:"environment",severity:"warn",repair:"manual"}),expected:{finding:true,domain:"configuration",status:"advisory",diagnosisState:"candidate",repairDisposition:"manual"}},{id:"container-contract",diseaseClass:"configuration",description:"Container delivery contract is incomplete.",probe:w({id:"container-contract",label:"Container contract incomplete",issueClass:"container",severity:"warn"}),expected:{finding:true,domain:"configuration",status:"advisory",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"tests-missing",diseaseClass:"test",description:"No deterministic test surface is declared.",probe:w({id:"tests-missing",label:"Tests missing",issueClass:"test",severity:"warn",repair:"manual"}),expected:{finding:true,domain:"test",status:"advisory",diagnosisState:"candidate",repairDisposition:"manual"}},{id:"quality-missing",diseaseClass:"quality",description:"No lint/format/static-analysis surface is declared.",probe:w({id:"quality-missing",label:"Quality tooling missing",issueClass:"quality",severity:"warn"}),expected:{finding:true,domain:"quality",status:"advisory",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"stale-evidence",diseaseClass:"freshness",description:"Evidence is stale and must not be treated as confirmed.",probe:{...w({id:"stale-evidence",label:"Stale evidence",issueClass:"security"}),freshness:{status:"stale",verifyBeforeUse:true}},expected:{finding:true,domain:"security",status:"blocking",diagnosisState:"unknown",repairDisposition:"unavailable"}},{id:"unknown-disease",diseaseClass:"unknown",description:"A real symptom cannot be bound to a typed disease class.",probe:w({id:"unknown-disease",label:"Unknown disease",issueClass:"unknown"}),expected:{finding:true,status:"blocking",diagnosisState:"unknown",repairDisposition:"unavailable"}},{id:"healthy-runtime",diseaseClass:"healthy-control",description:"Healthy evidence must not become a finding.",probe:{id:"healthy-runtime",label:"Healthy runtime",status:"pass",severity:"info",reason:"Runtime evidence is healthy.",issueClass:"runtime",operationalImpact:"none"},expected:{finding:false,domain:"runtime"}}];function _(e){return Math.round(e*1e4)/1e4}function ee(){let i=P().list(),t=i.flatMap(o=>Ce.map(d=>{let O=o.runtimeFamilies[0]??"unknown",g=o.frameworks[0]??"Unknown",k=Z({projectName:`validation-${o.id}-${d.id}`,projectPath:`/virtual/doctor-validation/${o.id}/${d.id}`,runtimeFamily:O,framework:g,projectKind:"generic",probes:[d.probe]}),b=k.findings.find(x=>x.probeId===d.probe.id),N=k.domains.find(x=>x.observationCount>0)?.id,v={finding:!!b,...N?{domain:N}:{},...b?.status?{status:b.status}:{},...b?.diagnosisState?{diagnosisState:b.diagnosisState}:{},...b?.repair.disposition?{repairDisposition:b.repair.disposition}:{}},y=[];return v.finding!==d.expected.finding&&y.push("finding-presence"),d.expected.domain&&v.domain!==d.expected.domain&&y.push("domain"),d.expected.status&&v.status!==d.expected.status&&y.push("status"),d.expected.diagnosisState&&v.diagnosisState!==d.expected.diagnosisState&&y.push("diagnosis-state"),d.expected.repairDisposition&&v.repairDisposition!==d.expected.repairDisposition&&y.push("repair-disposition"),k.capability.adapterId!==o.id&&y.push("adapter-binding"),{id:`${o.id}:${d.id}`,passed:y.length===0,expected:d.expected,actual:v,failures:y}})),s=t.filter(o=>o.expected.finding),r=t.filter(o=>!o.expected.finding),c$1=s.filter(o=>o.actual.finding).length,a=s.length-c$1,p=r.filter(o=>!o.actual.finding).length,m=r.length-p,C=new Set(t.map(o=>o.actual.domain).filter(o=>!!o));return {schemaVersion:c,corpusVersion:d,capabilityRegistryVersion:b,scope:"synthetic-contract-corpus",summary:{totalCases:t.length,passedCases:t.filter(o=>o.passed).length,failedCases:t.filter(o=>!o.passed).length,truePositives:c$1,trueNegatives:p,falsePositives:m,falseNegatives:a,precision:_(c$1/Math.max(1,c$1+m)),recall:_(c$1/Math.max(1,c$1+a)),domainCoverage:_(C.size/D.length),runtimeAdapterCoverage:_(new Set(t.map(o=>o.id.split(":",1)[0])).size/Math.max(1,i.length)),runtimeAdaptersExercised:i.length,declaredPlatforms:new Set(i.flatMap(o=>o.platforms)).size},cases:t,limitations:["Precision and recall describe the versioned synthetic contract corpus, not every public repository.","Every registered runtime adapter is exercised against the same disease corpus; this proves contract behavior, not tool availability on a host.","Runtime-native fixture and real Linux, macOS, and Windows acceptance gates remain separate evidence surfaces."]}}async function Qe(e$1={}){let i=K({runtime:e$1.runtime,framework:e$1.framework}),t=e$1.validate?ee():void 0,s,r;if(e$1.write){let a=e$1.workspace?pe.resolve(e$1.workspace):a$1(process.cwd());if(!a)return e$1.json?console.log(JSON.stringify({schemaVersion:i.schemaVersion,status:"error",error:{code:"doctor.capabilities.workspace-not-found",message:"--write requires a Workspai workspace or --workspace <path>."}},null,2)):console.log(h.red("Doctor capabilities could not be written: no workspace found.")),1;let p=K();s=await e(a,h$1.doctorCapabilities.artifactPath,p),t&&(r=await e(a,h$1.doctorValidation.artifactPath,t));}let c={...i,...t?{validation:t}:{},...s?{artifactPath:s}:{},...r?{validationArtifactPath:r}:{}};if(e$1.json)e$1.quiet||console.log(JSON.stringify(c,null,2));else if(!e$1.quiet){console.log(h.bold.cyan(`
1
+ import {a as a$1}from'./chunk-HLWDIIWL.js';import {a}from'./chunk-NS53IPAC.js';import {e}from'./chunk-GAYK3WGV.js';import {h as h$1,b,a as a$2,d,c}from'./chunk-6UNATTB7.js';import pe from'path';import h from'chalk';import {createHash}from'crypto';var F="workspai.doctor-adapter.v1",D=["runtime","dependency","security","configuration","test","quality"];function A(e){return e.trim().toLowerCase().replace(/[^a-z0-9+.#-]+/g,"-")}function ae(e){if(e.contractVersion!==F)throw new Error(`Unsupported Doctor adapter contract: ${e.contractVersion}`);if(!e.id.trim())throw new Error("Doctor adapter id must not be empty.");if(e.runtimeFamilies.length===0)throw new Error(`Doctor adapter ${e.id} must own at least one runtime family.`);if(e.platforms.length===0)throw new Error(`Doctor adapter ${e.id} must declare supported platforms.`);let i=e.domains.map(t=>t.domain);if(i.length!==D.length||new Set(i).size!==D.length||D.some(t=>!i.includes(t)))throw new Error(`Doctor adapter ${e.id} must declare every canonical diagnostic domain exactly once.`);for(let t of e.domains)if(t.level==="unsupported"&&t.limitations.length===0)throw new Error(`Doctor adapter ${e.id} must explain unsupported ${t.domain} coverage.`)}var $=class{#e=new Map;#i=new Map;#t=new Map;register(i){ae(i);let t=A(i.id);if(this.#e.has(t))throw new Error(`Doctor adapter id is already registered: ${i.id}`);let s=[...i.runtimeFamilies,...i.aliases].map(A);for(let c of s){let a=this.#i.get(c);if(a)throw new Error(`Doctor runtime ${c} is already owned by adapter ${a}.`)}for(let c of i.frameworks.map(A)){let a=this.#t.get(c);if(a)throw new Error(`Doctor framework ${c} is already owned by adapter ${a}.`)}let r=structuredClone(i);this.#e.set(t,r);for(let c of s)this.#i.set(c,t);for(let c of i.frameworks.map(A))this.#t.set(c,t);return this}resolveWithDiagnostics(i){let t=i.runtimeFamily?this.#i.get(A(i.runtimeFamily)):void 0,s=i.framework?this.#t.get(A(i.framework)):void 0;if(t&&s&&t!==s)return {status:"conflict",descriptor:null,runtimeOwner:t,frameworkOwner:s};let r=t??s;return {status:r?"matched":"unresolved",descriptor:r?structuredClone(this.#e.get(r)??null):null,...t?{runtimeOwner:t}:{},...s?{frameworkOwner:s}:{}}}resolve(i){return this.resolveWithDiagnostics(i).descriptor}list(){return [...this.#e.values()].map(i=>structuredClone(i)).sort((i,t)=>i.id.localeCompare(t.id))}};var Y=[...D],W=["linux","darwin","win32"],re=[{id:"node",aliases:["nodejs","javascript","typescript"],frameworks:["NestJS","Next.js","Remix","Nuxt","React","Vue","Angular","SvelteKit","Svelte","Vite","Astro","Solid","Express","Fastify","Koa","Electron","VS Code Extension"],tier:"first-class",native:Y},{id:"python",aliases:["py"],frameworks:["FastAPI","Django","Flask","Python"],tier:"first-class",native:Y},{id:"go",aliases:["golang"],frameworks:["Go","Go/Fiber","Go/Gin","Echo"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"java",aliases:["jvm"],frameworks:["Java","Spring Boot"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"dotnet",aliases:[".net","csharp","c#"],frameworks:["ASP.NET"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"rust",aliases:["cargo"],frameworks:["Rust","Axum"],tier:"first-class",native:["runtime","dependency","test","quality"],portable:["security","configuration"]},{id:"php",aliases:["composer"],frameworks:["PHP","Laravel"],tier:"first-class",native:["runtime","dependency","security"],portable:["configuration","test","quality"]},{id:"ruby",aliases:["bundler"],frameworks:["Ruby","Ruby on Rails"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"elixir",aliases:["beam"],frameworks:["Elixir","Phoenix"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"clojure",frameworks:["Clojure"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"deno",frameworks:["Deno"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"bun",frameworks:["Bun"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"scala",frameworks:["Scala"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"kotlin",frameworks:["Kotlin"],tier:"extended",portable:["runtime","dependency","configuration","test","quality"],observable:["security"]},{id:"c",aliases:["c-lang"],frameworks:["C"],tier:"extended",portable:["runtime","dependency","test","quality"],observable:["configuration"],limitations:["Security diagnosis requires a declared native scanner or workspace adapter."]},{id:"cpp",aliases:["c++","cplusplus"],frameworks:["C++"],tier:"extended",portable:["runtime","dependency","test","quality"],observable:["configuration"],limitations:["Security diagnosis requires a declared native scanner or workspace adapter."]}];function oe(e,i){let t={runtime:["project markers","entrypoints","toolchain evidence"],dependency:["dependency manifests","lockfiles","installed-tree evidence"],security:["runtime-native audit","advisory evidence"],configuration:["environment contracts","deployment/container markers"],test:["test scripts","test configuration","coverage evidence"],quality:["lint/format/static-analysis contracts"]};return [`${e} adapter`,...t[i]]}function ce(e,i){return e.native?.includes(i)?"native":e.portable?.includes(i)?"portable":e.observable?.includes(i)?"observable":"unsupported"}function le(e){let i=D.map(t=>{let s=ce(e,t);return {domain:t,level:s,evidenceSources:s==="unsupported"?[]:oe(e.id,t),limitations:s==="unsupported"?[`${e.id} has no built-in ${t} provider; declare a workspace adapter.`]:s==="observable"?[`${t} evidence is observable but not runtime-native for ${e.id}.`]:[]}});return {contractVersion:F,id:`builtin.${e.id}`,runtimeFamilies:[e.id],aliases:e.aliases??[],frameworks:e.frameworks,projectKinds:["backend","frontend","desktop","extension","fullstack","generic"],tier:e.tier,platforms:[...W],domains:i,repairModes:["typed-operation","structured-invocation","manual-guidance"],source:"builtin",limitations:e.limitations??[]}}function de(){return {contractVersion:F,id:"builtin.unknown",runtimeFamilies:["unknown"],aliases:["generic","unrecognized"],frameworks:["Unknown"],projectKinds:["backend","frontend","desktop","extension","fullstack","generic"],tier:"fallback",platforms:[...W],domains:D.map(e=>({domain:e,level:e==="security"?"unsupported":"observable",evidenceSources:e==="security"?[]:["portable workspace markers","declared custom checks"],limitations:[e==="security"?"No safe security claim is possible without a runtime-native audit provider.":`Only portable ${e} evidence is available until a runtime adapter is registered.`]})),repairModes:["manual-guidance"],source:"builtin",limitations:["Unknown runtimes are fail-closed: missing domain evidence is reported as unknown, never healthy.","Automatic repair is unavailable until a typed adapter owns the runtime."]}}function P(){let e=new $;for(let i of re)e.register(le(i));return e.register(de()),e}function J(e,i=P()){let t=i.resolveWithDiagnostics(e),s=t.descriptor??i.resolve({runtimeFamily:"unknown"});if(!s)throw new Error("Doctor fallback adapter is not registered.");let r=c=>s.domains.filter(a=>a.level===c).map(a=>a.domain);return {registryVersion:b,adapterId:s.id,runtimeFamily:s.runtimeFamilies[0]??"unknown",tier:s.tier,confidence:s.tier==="first-class"?"high":s.tier==="extended"?"medium":"low",nativeDomains:r("native"),portableDomains:r("portable"),observableDomains:r("observable"),unsupportedDomains:r("unsupported"),limitations:[...t.status==="conflict"?[`Runtime/framework ownership conflict (${t.runtimeOwner} vs ${t.frameworkOwner}); Doctor failed closed instead of selecting an ambiguous adapter.`]:[],...s.limitations,...s.domains.flatMap(c=>c.limitations)]}}function K(e={}){let i=P(),t=i.list(),s=i.resolveWithDiagnostics({runtimeFamily:e.runtime,framework:e.framework}),r=e.runtime||e.framework?[s.descriptor]:t;if((e.runtime||e.framework)&&!r[0]){let a=i.resolve({runtimeFamily:"unknown"});a&&(s.status==="conflict"&&a.limitations.unshift(`Runtime/framework ownership conflict (${s.runtimeOwner} vs ${s.frameworkOwner}); Doctor failed closed instead of selecting an ambiguous adapter.`),r[0]=a);}let c=r.filter(a=>!!a);return {schemaVersion:a$2,registryVersion:b,generatedBy:"workspai",policy:{unknownIsHealthy:false,unsupportedIsHealthy:false,repairRequiresTypedOperation:true,canonicalDomains:[...D]},summary:{adapterCount:c.length,firstClassRuntimes:c.filter(a=>a.tier==="first-class").length,extendedRuntimes:c.filter(a=>a.tier==="extended").length,fallbackRuntimes:c.filter(a=>a.tier==="fallback").length,frameworkCount:new Set(c.flatMap(a=>a.frameworks)).size,platformCount:new Set(c.flatMap(a=>a.platforms)).size},adapters:c}}var me=["runtime","dependency","security","configuration","test","quality"];function I(e){return createHash("sha256").update(e).digest("hex").slice(0,12)}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Q(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim()}function ge(e,i){let t=Q(e);return t?i.some(s=>[s.reason,s.recommendation??""].map(Q).filter(Boolean).some(c=>c===t||c.includes(t)||t.includes(c))):true}function fe(e){return e.status==="fail"?"blocking":e.status==="warn"?"advisory":"informational"}function X(e){return e.issueClass==="dependency"?"dependency":e.issueClass==="security"?"security":e.issueClass==="environment"||e.issueClass==="configuration"||e.issueClass==="container"||e.issueClass==="deployment"||e.issueClass==="workspace-contract"?"configuration":e.issueClass==="test"?"test":e.issueClass==="quality"||e.issueClass==="custom"?"quality":e.issueClass==="runtime"||e.issueClass==="framework"||e.issueClass==="source-tree"?"runtime":null}function ye(e,i){return me.map(t=>{let s=e.filter(o=>X(o)===t),r=e.filter(o=>o.applicability!=="not-applicable"&&X(o)===t),c=i.unsupportedDomains.includes(t);if(r.length===0){let o=s.some(d=>d.applicability==="not-applicable");return {id:t,status:o?"not-applicable":"not-run",observationCount:0,blockingFindings:0,advisoryFindings:0,reason:o?`${t} checks ran and found no declared intent requiring this domain.`:c?`${t} is unsupported by Doctor adapter ${i.adapterId}; no healthy claim is allowed.`:`No ${t} diagnostic observation was produced.`}}let a=r.some(o=>o.freshness?.status==="stale"||o.freshness?.status==="unknown"),p=r.filter(o=>o.status==="fail").length,m=r.filter(o=>o.status==="warn").length,C=p>0||m>0;return {id:t,status:a?"stale":C?"findings":c?"not-run":"clean",observationCount:r.length,blockingFindings:p,advisoryFindings:m,reason:a?`${t} evidence is stale or has unknown freshness.`:C?`${t} diagnostics produced findings.`:c?`${t} observations cannot establish complete health because adapter ${i.adapterId} declares the domain unsupported.`:`${t} diagnostics completed without findings.`}})}function De(e){if(e.status==="pass")return "not-needed";let i=e.repairCapability;return i?i.status==="manual"||i.requiresReview?"manual":i.status!=="available"||!i.canAutoFix?"unavailable":i.requiresApproval?"approval-required":"automatic":"unavailable"}function be(e){if(e.freshness?.status==="stale"||e.freshness?.status==="unknown")return {label:"low",score:.35,state:"unknown"};let i=!!(e.issueClass&&e.issueClass!=="unknown"),t=!!(e.repairCapability?.operation?.type||e.repairCapability?.invocation?.executable);return i&&t&&e.repairIntent?.confidence==="high"?{label:"high",score:.95,state:"confirmed"}:i&&(e.status==="fail"||e.status==="warn")?{label:"medium",score:t?.82:.68,state:"candidate"}:e.status==="pass"?{label:"high",score:.98,state:"confirmed"}:{label:"low",score:.3,state:"unknown"}}function ve(e,i){let t=[{kind:"probe",role:"observation",ref:`probe:${e.id}`,claim:e.reason}];for(let r of e.repairCapability?.files??[])t.push({kind:"file",role:"repair-target",ref:r.split(pe.sep).join("/"),claim:"Structured repair capability declared this path as an affected target."});if(e.repairCapability?.invocation?.executable){let r=e.repairCapability.invocation;t.push({kind:"command",role:"verification",ref:[r.executable,...r.args??[]].join(" "),claim:"Structured command invocation is available for this diagnostic path."});}if(e.issueClass==="security"&&/(?:dependency|audit|vulnerab|security-hygiene)/i.test(`${e.id} ${e.label}`))for(let r of i??[])t.push({kind:"dependency",role:"subject",ref:r.version?`${r.name}@${r.version}`:r.name,claim:r.advisoryIds&&r.advisoryIds.length>0?`Dependency is referenced by ${r.advisoryIds.join(", ")}.`:"Dependency is present in security audit evidence."});return t}function we(e,i){let t=i.issueClass?.trim()||"unknown",s=be(i);return {id:`${S(i.id)}:${I(`${e.projectPath}\0${i.id}`)}`,causalKey:[S(e.projectName),I(e.projectPath),S(t),S(i.id)].join(":"),projectName:e.projectName,projectPath:e.projectPath,probeId:i.id,label:i.label,status:fe(i),severity:i.severity,issueClass:t,operationalImpact:i.operationalImpact?.trim()||"developer-friction",applicability:i.applicability??"applicable",confidence:s.label,confidenceScore:s.score,diagnosisState:s.state,symptom:i.reason,...i.recommendation?{recommendation:i.recommendation}:{},proofs:ve(i,e.dependencySubjects),repair:{disposition:De(i),...i.repairCapability?.id?{capabilityId:i.repairCapability.id}:{},...i.repairCapability?.operation?.type?{operationType:i.repairCapability.operation.type}:{},...i.repairCapability?.verifyCommand?{verifyCommand:i.repairCapability.verifyCommand}:{},requiresFreshEvidence:i.repairIntent?.requiresFreshEvidence===true||i.freshness?.verifyBeforeUse===true}}}function he(e,i,t){let s=`legacy-runtime-issue-${t+1}`;return {id:`${s}:${I(`${e.projectPath}\0${i}`)}`,causalKey:[S(e.projectName),I(e.projectPath),"unknown",I(i)].join(":"),projectName:e.projectName,projectPath:e.projectPath,probeId:s,label:"Runtime diagnostic issue",status:"blocking",severity:"error",issueClass:"unknown",operationalImpact:"runtime-risk",applicability:"applicable",confidence:"low",confidenceScore:.25,diagnosisState:"unknown",symptom:i,proofs:[{kind:"unknown",role:"observation",ref:`legacy-issue:${t+1}`,claim:i}],repair:{disposition:"unavailable",requiresFreshEvidence:true}}}function Z(e){let i=[...e.probes],t=[...new Set((e.runtimeFamilies&&e.runtimeFamilies.length>0?e.runtimeFamilies:[e.runtimeFamily??"unknown"]).filter(Boolean))],s=e.runtimeFamily??t[0]??"unknown",r=t.filter(n=>n!==s&&n!=="unknown"),c=J({runtimeFamily:e.runtimeFamily,framework:e.framework},e.adapterRegistry),a$1=ye(i,c),p=(e.legacyIssues??[]).filter(n=>!ge(n,i)),m=new Map;for(let n of i){let l=m.get(n.id)??new Set;l.add(n.status),m.set(n.id,l);}let C=[...m.entries()].filter(([,n])=>n.size>1).map(([n,l])=>({probeId:n,statuses:[...l].sort(),reason:"The same diagnostic probe produced contradictory states in one project scan."})),o=[...i.filter(n=>n.applicability!=="not-applicable"&&n.status!=="pass").map(n=>we(e,n)),...p.map((n,l)=>he(e,n,l))],d={blocking:4,unknown:3,advisory:2,informational:1},O=new Map;for(let n of o){let l=O.get(n.causalKey)??[];l.push(n),O.set(n.causalKey,l);}let g=[...O.values()].map(n=>{let u=[...n].sort((f,j)=>d[j.status]-d[f.status]||j.confidenceScore-f.confidenceScore||f.id.localeCompare(j.id)).at(0);if(!u)throw new Error("Doctor diagnosis causal group cannot be empty.");let G=structuredClone(u);return G.proofs=[...new Map(n.flatMap(f=>f.proofs).map(f=>[`${f.kind}:${f.role}:${f.ref}:${f.claim}`,f])).values()],G}).sort((n,l)=>n.causalKey.localeCompare(l.causalKey)||n.id.localeCompare(l.id)),k=new Map;for(let n of g){let l=k.get(n.causalKey)??[];l.push(n),k.set(n.causalKey,l);}let b=[...k.entries()].map(([n,l])=>({causalKey:n,issueClass:l[0]?.issueClass??"unknown",status:l.some(u=>u.status==="blocking")?"blocking":l.some(u=>u.status==="advisory")?"advisory":l.some(u=>u.status==="unknown")?"unknown":"informational",findingIds:l.map(u=>u.id),projectPaths:[...new Set(l.map(u=>u.projectPath))],repairable:l.some(u=>u.repair.disposition==="automatic"||u.repair.disposition==="approval-required")})),v=[...g.filter(n=>n.diagnosisState==="unknown"||n.issueClass==="unknown"||n.applicability==="unknown").map(n=>({id:`unknown:${n.id}`,probeId:n.probeId,reason:n.issueClass==="unknown"?"The observation is real, but Doctor cannot yet bind it to a typed issue class.":"Evidence is insufficient or stale for a confirmed diagnosis."})),...a$1.filter(n=>n.status==="not-run"||n.status==="stale").map(n=>({id:`unknown:domain:${n.id}:${I(e.projectPath)}`,reason:n.reason})),...r.map(n=>({id:`unknown:runtime:${S(n)}:${I(e.projectPath)}`,reason:e.projectArchetype==="platform"?`${n} is part of this cross-language platform, but only portable evidence and the primary ${s} runtime adapter were evaluated. Add a typed ${n} adapter before making runtime-specific health claims.`:`${n} was detected inside this composite project boundary, but the ${s} adapter is the only runtime-specific adapter evaluated for this scan. Declare a nested project boundary or a typed Doctor adapter before treating ${n} as healthy.`}))],y=g.filter(n=>n.diagnosisState!=="unknown").length,x=g.length===0?100:y/g.length*100,ie=a$1.filter(n=>n.status!=="not-run"&&n.status!=="stale").length/a$1.length*100,U=t.filter(n=>n!=="unknown").length,te=s!=="unknown"&&t.includes(s)?1:0,ne=U===0?0:te/U*100,se=Math.round(Math.min(x,ie,ne)*100)/100;return {schemaVersion:a,engineVersion:"universal-diagnosis-v1",project:{name:e.projectName,path:e.projectPath,runtimeFamily:e.runtimeFamily??"unknown",runtimeFamilies:t,framework:e.framework??"Unknown",projectKind:e.projectKind??"generic"},capability:c,domains:a$1,coverage:{totalObservations:i.length+p.length,evaluatedObservations:i.filter(n=>n.applicability!=="not-applicable").length,passingObservations:i.filter(n=>n.applicability!=="not-applicable"&&n.status==="pass").length,blockingFindings:g.filter(n=>n.status==="blocking").length,advisoryFindings:g.filter(n=>n.status==="advisory").length,unknownFindings:v.length,repairableFindings:g.filter(n=>n.repair.disposition==="automatic"||n.repair.disposition==="approval-required").length,manualFindings:g.filter(n=>n.repair.disposition==="manual").length,unsupportedFindings:g.filter(n=>n.repair.disposition==="unavailable").length,contradictionCount:C.length,diagnosisCompleteness:se},findings:g,causalGroups:b,unknowns:v,contradictions:C}}function w(e){let i=e.severity??"error",t=e.repair??"unavailable";return {id:e.id,label:e.label,status:i==="error"?"fail":"warn",severity:i,reason:`${e.label} detected by the validation corpus.`,issueClass:e.issueClass,operationalImpact:i==="error"?"release-risk":"ci-risk",repairIntent:{confidence:e.confidence??"medium",requiresFreshEvidence:true},...t==="unavailable"?{}:{repairCapability:{id:`repair.${e.id}`,status:t==="manual"?"manual":"available",canAutoFix:t==="automatic"||t==="approval-required",requiresApproval:t==="approval-required",requiresReview:t==="manual",operation:{type:"validation-operation"},verifyCommand:"npx workspai doctor project --json"}}}}var Ce=[{id:"runtime-missing",diseaseClass:"runtime",description:"Required runtime is absent.",probe:w({id:"runtime-missing",label:"Runtime missing",issueClass:"runtime"}),expected:{finding:true,domain:"runtime",status:"blocking",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"dependencies-missing",diseaseClass:"dependency",description:"Installed dependency tree is absent.",probe:w({id:"dependencies-missing",label:"Dependencies missing",issueClass:"dependency",repair:"automatic",confidence:"high"}),expected:{finding:true,domain:"dependency",status:"blocking",diagnosisState:"confirmed",repairDisposition:"automatic"}},{id:"security-advisory",diseaseClass:"security",description:"A runtime-native audit reports a blocking advisory.",probe:w({id:"security-advisory",label:"Security advisory",issueClass:"security",repair:"approval-required",confidence:"high"}),expected:{finding:true,domain:"security",status:"blocking",diagnosisState:"confirmed",repairDisposition:"approval-required"}},{id:"environment-contract",diseaseClass:"configuration",description:"Environment/configuration contract is incomplete.",probe:w({id:"environment-contract",label:"Environment contract incomplete",issueClass:"environment",severity:"warn",repair:"manual"}),expected:{finding:true,domain:"configuration",status:"advisory",diagnosisState:"candidate",repairDisposition:"manual"}},{id:"container-contract",diseaseClass:"configuration",description:"Container delivery contract is incomplete.",probe:w({id:"container-contract",label:"Container contract incomplete",issueClass:"container",severity:"warn"}),expected:{finding:true,domain:"configuration",status:"advisory",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"tests-missing",diseaseClass:"test",description:"No deterministic test surface is declared.",probe:w({id:"tests-missing",label:"Tests missing",issueClass:"test",severity:"warn",repair:"manual"}),expected:{finding:true,domain:"test",status:"advisory",diagnosisState:"candidate",repairDisposition:"manual"}},{id:"quality-missing",diseaseClass:"quality",description:"No lint/format/static-analysis surface is declared.",probe:w({id:"quality-missing",label:"Quality tooling missing",issueClass:"quality",severity:"warn"}),expected:{finding:true,domain:"quality",status:"advisory",diagnosisState:"candidate",repairDisposition:"unavailable"}},{id:"stale-evidence",diseaseClass:"freshness",description:"Evidence is stale and must not be treated as confirmed.",probe:{...w({id:"stale-evidence",label:"Stale evidence",issueClass:"security"}),freshness:{status:"stale",verifyBeforeUse:true}},expected:{finding:true,domain:"security",status:"blocking",diagnosisState:"unknown",repairDisposition:"unavailable"}},{id:"unknown-disease",diseaseClass:"unknown",description:"A real symptom cannot be bound to a typed disease class.",probe:w({id:"unknown-disease",label:"Unknown disease",issueClass:"unknown"}),expected:{finding:true,status:"blocking",diagnosisState:"unknown",repairDisposition:"unavailable"}},{id:"healthy-runtime",diseaseClass:"healthy-control",description:"Healthy evidence must not become a finding.",probe:{id:"healthy-runtime",label:"Healthy runtime",status:"pass",severity:"info",reason:"Runtime evidence is healthy.",issueClass:"runtime",operationalImpact:"none"},expected:{finding:false,domain:"runtime"}}];function _(e){return Math.round(e*1e4)/1e4}function ee(){let i=P().list(),t=i.flatMap(o=>Ce.map(d=>{let O=o.runtimeFamilies[0]??"unknown",g=o.frameworks[0]??"Unknown",k=Z({projectName:`validation-${o.id}-${d.id}`,projectPath:`/virtual/doctor-validation/${o.id}/${d.id}`,runtimeFamily:O,framework:g,projectKind:"generic",probes:[d.probe]}),b=k.findings.find(x=>x.probeId===d.probe.id),N=k.domains.find(x=>x.observationCount>0)?.id,v={finding:!!b,...N?{domain:N}:{},...b?.status?{status:b.status}:{},...b?.diagnosisState?{diagnosisState:b.diagnosisState}:{},...b?.repair.disposition?{repairDisposition:b.repair.disposition}:{}},y=[];return v.finding!==d.expected.finding&&y.push("finding-presence"),d.expected.domain&&v.domain!==d.expected.domain&&y.push("domain"),d.expected.status&&v.status!==d.expected.status&&y.push("status"),d.expected.diagnosisState&&v.diagnosisState!==d.expected.diagnosisState&&y.push("diagnosis-state"),d.expected.repairDisposition&&v.repairDisposition!==d.expected.repairDisposition&&y.push("repair-disposition"),k.capability.adapterId!==o.id&&y.push("adapter-binding"),{id:`${o.id}:${d.id}`,passed:y.length===0,expected:d.expected,actual:v,failures:y}})),s=t.filter(o=>o.expected.finding),r=t.filter(o=>!o.expected.finding),c$1=s.filter(o=>o.actual.finding).length,a=s.length-c$1,p=r.filter(o=>!o.actual.finding).length,m=r.length-p,C=new Set(t.map(o=>o.actual.domain).filter(o=>!!o));return {schemaVersion:c,corpusVersion:d,capabilityRegistryVersion:b,scope:"synthetic-contract-corpus",summary:{totalCases:t.length,passedCases:t.filter(o=>o.passed).length,failedCases:t.filter(o=>!o.passed).length,truePositives:c$1,trueNegatives:p,falsePositives:m,falseNegatives:a,precision:_(c$1/Math.max(1,c$1+m)),recall:_(c$1/Math.max(1,c$1+a)),domainCoverage:_(C.size/D.length),runtimeAdapterCoverage:_(new Set(t.map(o=>o.id.split(":",1)[0])).size/Math.max(1,i.length)),runtimeAdaptersExercised:i.length,declaredPlatforms:new Set(i.flatMap(o=>o.platforms)).size},cases:t,limitations:["Precision and recall describe the versioned synthetic contract corpus, not every public repository.","Every registered runtime adapter is exercised against the same disease corpus; this proves contract behavior, not tool availability on a host.","Runtime-native fixture and real Linux, macOS, and Windows acceptance gates remain separate evidence surfaces."]}}async function Qe(e$1={}){let i=K({runtime:e$1.runtime,framework:e$1.framework}),t=e$1.validate?ee():void 0,s,r;if(e$1.write){let a=e$1.workspace?pe.resolve(e$1.workspace):a$1(process.cwd());if(!a)return e$1.json?console.log(JSON.stringify({schemaVersion:i.schemaVersion,status:"error",error:{code:"doctor.capabilities.workspace-not-found",message:"--write requires a Workspai workspace or --workspace <path>."}},null,2)):console.log(h.red("Doctor capabilities could not be written: no workspace found.")),1;let p=K();s=await e(a,h$1.doctorCapabilities.artifactPath,p),t&&(r=await e(a,h$1.doctorValidation.artifactPath,t));}let c={...i,...t?{validation:t}:{},...s?{artifactPath:s}:{},...r?{validationArtifactPath:r}:{}};if(e$1.json)e$1.quiet||console.log(JSON.stringify(c,null,2));else if(!e$1.quiet){console.log(h.bold.cyan(`
2
2
  \u{1FA7A} Workspai Doctor capabilities
3
3
  `)),console.log(`${i.summary.adapterCount} adapter(s) \xB7 ${i.summary.frameworkCount} framework mapping(s) \xB7 ${i.summary.platformCount} platform(s)`);for(let a of i.adapters){let p=a.domains.map(m=>`${m.domain}:${m.level}`).join(" \xB7 ");console.log(h.bold(`
4
4
  ${a.runtimeFamilies.join(", ")} \xB7 ${a.tier}`)),console.log(h.gray(p));for(let m of a.limitations)console.log(h.yellow(` ! ${m}`));}if(t){let a=t.summary,p=a.failedCases===0?h.green:h.red;console.log(p(`
@@ -1 +1 @@
1
- import {a}from'./chunk-NS53IPAC.js';import {a as a$1}from'./chunk-AO2ZI42U.js';import {f,h}from'./chunk-NZ3WZYD5.js';var R=f.doctor,O=h.doctorProject.schemaVersion;function s(a){return !a||typeof a!="object"||Array.isArray(a)?null:a}function M(a,o){let t=s(a);if(!t)return false;let i=t.schemaVersion,e=t.evidenceType;if(i!==void 0&&typeof i!="string"||e!==void 0&&typeof e!="string")return false;if(i===void 0){let l=Array.isArray(t.projects)||s(t.summary)!==null||s(t.healthScore)!==null,u=s(t.project)!==null;if(!(o==="workspace"?l:o==="project"?u:l||u))return false}return !(typeof i=="string"&&(i!==R&&i!==O||o==="workspace"&&i!==R||o==="project"&&i!==O)||typeof e=="string"&&(e!=="workspace"&&e!=="project"||o&&e!==o))}function r(a,o){let t=a[o];if(!Number.isInteger(t)||Number(t)<0)throw new Error(`Doctor evidence ${o} must be a non-negative integer.`);return Number(t)}function I(a){if(Array.isArray(a.projects))return a.projects.map(s).filter(t=>t!==null);let o=s(a.project);return o?[o]:[]}function _(a$1){let o=s(a$1.diagnosis);if(!o)return;if(o.schemaVersion!==a)throw new Error("Doctor diagnosis schemaVersion is missing or unsupported.");let t=Array.isArray(o.findings)?o.findings.map(s).filter(n=>n!==null):[],i=s(o.coverage);if(!i)throw new Error("Doctor diagnosis must publish coverage.");let e=s(o.capability);if(!e)throw new Error("Doctor diagnosis must publish capability truth.");let l=Array.isArray(o.domains)?o.domains.map(s).filter(n=>n!==null):[],u=l.map(n=>n.id);if(l.length!==6||new Set(u).size!==l.length)throw new Error("Doctor diagnosis must publish each canonical diagnostic domain exactly once.");let f=["nativeDomains","portableDomains","observableDomains","unsupportedDomains"].flatMap(n=>Array.isArray(e[n])?e[n]:[]);if(f.length!==6||new Set(f).size!==f.length||u.some(n=>!f.includes(n)))throw new Error("Doctor capability truth must classify every canonical domain exactly once.");if(e.tier==="fallback"&&e.confidence!=="low")throw new Error("Doctor fallback capability cannot claim medium or high confidence.");let h=new Set;for(let n of t){if(typeof n.id!="string"||!n.id.trim())throw new Error("Doctor diagnosis finding id must be non-empty.");if(h.has(n.id))throw new Error(`Doctor diagnosis finding id is duplicated: ${n.id}`);if(h.add(n.id),!Array.isArray(n.proofs)||n.proofs.length===0)throw new Error(`Doctor diagnosis finding ${n.id} has no proof.`)}let D=t.filter(n=>n.status==="blocking").length,v=t.filter(n=>n.status==="advisory").length;if(r(i,"blockingFindings")!==D)throw new Error("Doctor diagnosis blockingFindings contradicts its finding set.");if(r(i,"advisoryFindings")!==v)throw new Error("Doctor diagnosis advisoryFindings contradicts its finding set.");let k=r(i,"totalObservations"),w=r(i,"evaluatedObservations"),c=r(i,"passingObservations");if(w>k||c>w)throw new Error("Doctor diagnosis observation accounting is inconsistent.");if(r(i,"repairableFindings")+r(i,"manualFindings")+r(i,"unsupportedFindings")!==t.length)throw new Error("Doctor diagnosis repair disposition counts contradict its finding set.");let y=Array.isArray(o.unknowns)?o.unknowns:[];if(r(i,"unknownFindings")!==y.length)throw new Error("Doctor diagnosis unknownFindings contradicts its unknown set.");let g=i.diagnosisCompleteness;if(typeof g!="number"||g<0||g>100)throw new Error("Doctor diagnosis completeness must be between 0 and 100.");if(g===100&&l.some(n=>n.status==="not-run"||n.status==="stale"))throw new Error("Doctor diagnosis cannot claim complete coverage with missing or stale domains.");if(g===100&&y.length>0)throw new Error("Doctor diagnosis cannot claim complete coverage while unknowns remain.");let b=new Set;for(let n of Array.isArray(o.causalGroups)?o.causalGroups:[]){let d=s(n);if(!d||!Array.isArray(d.findingIds))throw new Error("Doctor diagnosis causal group is malformed.");for(let p of d.findingIds){if(typeof p!="string"||!h.has(p))throw new Error("Doctor diagnosis causal group references an unknown finding.");if(b.has(p))throw new Error("Doctor diagnosis finding belongs to more than one causal group.");b.add(p);}}if(b.size!==h.size)throw new Error("Doctor diagnosis causal groups do not cover every finding exactly once.")}function P(a){let o=[...Array.isArray(a.repairCapabilities)?a.repairCapabilities:[],...Array.isArray(a.probes)?a.probes.map(s).map(t=>t&&s(t.repairCapability)):[]];for(let t of o){let i=s(t);if(!(!i||i.operation===void 0)&&!a$1(i.operation)){let e=typeof i.id=="string"?i.id:"unknown";throw new Error(`Doctor repair capability ${e} contains an invalid typed operation.`)}}}function z(a){let o=s(a);if(!o)throw new Error("Doctor evidence must be an object.");let t=I(o),i=s(o.contract);for(let c of t)_(c),P(c);if(i?.scoringPolicyVersion==="doctor-score-policy-v2"&&t.some(c=>!s(c.diagnosis)))throw new Error("Canonical Doctor evidence contains a project without diagnosis.");let e=s(o.healthScore);if(!e||typeof e.verdict!="string")return;let l=r(e,"total"),u=r(e,"passed"),E=r(e,"warnings"),f=r(e,"errors");if(l!==u+E+f)throw new Error("Doctor healthScore total must equal passed + warnings + errors.");let h=f>0?"blocked":E>0?"attention":"passed";if(e.verdict!==h)throw new Error(`Doctor healthScore verdict ${String(e.verdict)} contradicts score counts (${h}).`);let D=s(e.components);if(D){let c=s(D.host),m=s(D.projects);if(!c||!m)throw new Error("Doctor healthScore components must publish host and projects.");for(let[y,g]of [["host",c],["projects",m]]){let b=r(g,"total"),n=r(g,"passed"),d=r(g,"warnings"),p=r(g,"errors");if(b!==n+d+p)throw new Error(`Doctor ${y} score total contradicts its component counts.`)}if(u!==r(c,"passed")+r(m,"passed")||E!==r(c,"warnings")+r(m,"warnings")||f!==r(c,"errors")+r(m,"errors"))throw new Error("Doctor healthScore contradicts its host/project components.")}let v=0,k=0;for(let c of t){let m=Array.isArray(c.probes)?c.probes:[],y=s(c.diagnosis),g=y?s(y.coverage):null,b=m.filter(p=>s(p)?.status==="fail").length+(Array.isArray(c.issues)?c.issues.length:0),n=g?r(g,"blockingFindings"):b;v+=n;let d=s(c.probeSummary);if(d){if(r(d,"total")!==r(d,"passed")+r(d,"warnings")+r(d,"failed"))throw new Error("Doctor project probeSummary total contradicts its probe counts.");let p=r(d,"blockingFindings");if(p!==n)throw new Error("Doctor project probeSummary.blockingFindings contradicts its canonical diagnosis.");let A=p>0?"blocked":r(d,"advisoryFindings")+Number(d.unknownFindings??0)+Number(d.contradictionFindings??0)>0?"attention":"passed";if(d.verdict!==A||c.verdict!==A)throw new Error("Doctor project verdict contradicts its probe summary.");k+=r(d,"advisoryFindings");}}if(v>0&&f===0)throw new Error("Doctor evidence contains blocking findings but healthScore.errors is zero.");let w=s(o.summary);if(w&&Array.isArray(o.projects)){if(w.blockingFindings!==void 0&&r(w,"blockingFindings")!==v)throw new Error("Doctor workspace summary blockingFindings contradicts project diagnosis.");if(w.advisoryFindings!==void 0&&r(w,"advisoryFindings")!==k)throw new Error("Doctor workspace summary advisoryFindings contradicts project diagnosis.")}}export{R as a,O as b,M as c,z as d};
1
+ import {a}from'./chunk-NS53IPAC.js';import {a as a$1}from'./chunk-AO2ZI42U.js';import {f,h}from'./chunk-6UNATTB7.js';var R=f.doctor,O=h.doctorProject.schemaVersion;function s(a){return !a||typeof a!="object"||Array.isArray(a)?null:a}function M(a,o){let t=s(a);if(!t)return false;let i=t.schemaVersion,e=t.evidenceType;if(i!==void 0&&typeof i!="string"||e!==void 0&&typeof e!="string")return false;if(i===void 0){let l=Array.isArray(t.projects)||s(t.summary)!==null||s(t.healthScore)!==null,u=s(t.project)!==null;if(!(o==="workspace"?l:o==="project"?u:l||u))return false}return !(typeof i=="string"&&(i!==R&&i!==O||o==="workspace"&&i!==R||o==="project"&&i!==O)||typeof e=="string"&&(e!=="workspace"&&e!=="project"||o&&e!==o))}function r(a,o){let t=a[o];if(!Number.isInteger(t)||Number(t)<0)throw new Error(`Doctor evidence ${o} must be a non-negative integer.`);return Number(t)}function I(a){if(Array.isArray(a.projects))return a.projects.map(s).filter(t=>t!==null);let o=s(a.project);return o?[o]:[]}function _(a$1){let o=s(a$1.diagnosis);if(!o)return;if(o.schemaVersion!==a)throw new Error("Doctor diagnosis schemaVersion is missing or unsupported.");let t=Array.isArray(o.findings)?o.findings.map(s).filter(n=>n!==null):[],i=s(o.coverage);if(!i)throw new Error("Doctor diagnosis must publish coverage.");let e=s(o.capability);if(!e)throw new Error("Doctor diagnosis must publish capability truth.");let l=Array.isArray(o.domains)?o.domains.map(s).filter(n=>n!==null):[],u=l.map(n=>n.id);if(l.length!==6||new Set(u).size!==l.length)throw new Error("Doctor diagnosis must publish each canonical diagnostic domain exactly once.");let f=["nativeDomains","portableDomains","observableDomains","unsupportedDomains"].flatMap(n=>Array.isArray(e[n])?e[n]:[]);if(f.length!==6||new Set(f).size!==f.length||u.some(n=>!f.includes(n)))throw new Error("Doctor capability truth must classify every canonical domain exactly once.");if(e.tier==="fallback"&&e.confidence!=="low")throw new Error("Doctor fallback capability cannot claim medium or high confidence.");let h=new Set;for(let n of t){if(typeof n.id!="string"||!n.id.trim())throw new Error("Doctor diagnosis finding id must be non-empty.");if(h.has(n.id))throw new Error(`Doctor diagnosis finding id is duplicated: ${n.id}`);if(h.add(n.id),!Array.isArray(n.proofs)||n.proofs.length===0)throw new Error(`Doctor diagnosis finding ${n.id} has no proof.`)}let D=t.filter(n=>n.status==="blocking").length,v=t.filter(n=>n.status==="advisory").length;if(r(i,"blockingFindings")!==D)throw new Error("Doctor diagnosis blockingFindings contradicts its finding set.");if(r(i,"advisoryFindings")!==v)throw new Error("Doctor diagnosis advisoryFindings contradicts its finding set.");let k=r(i,"totalObservations"),w=r(i,"evaluatedObservations"),c=r(i,"passingObservations");if(w>k||c>w)throw new Error("Doctor diagnosis observation accounting is inconsistent.");if(r(i,"repairableFindings")+r(i,"manualFindings")+r(i,"unsupportedFindings")!==t.length)throw new Error("Doctor diagnosis repair disposition counts contradict its finding set.");let y=Array.isArray(o.unknowns)?o.unknowns:[];if(r(i,"unknownFindings")!==y.length)throw new Error("Doctor diagnosis unknownFindings contradicts its unknown set.");let g=i.diagnosisCompleteness;if(typeof g!="number"||g<0||g>100)throw new Error("Doctor diagnosis completeness must be between 0 and 100.");if(g===100&&l.some(n=>n.status==="not-run"||n.status==="stale"))throw new Error("Doctor diagnosis cannot claim complete coverage with missing or stale domains.");if(g===100&&y.length>0)throw new Error("Doctor diagnosis cannot claim complete coverage while unknowns remain.");let b=new Set;for(let n of Array.isArray(o.causalGroups)?o.causalGroups:[]){let d=s(n);if(!d||!Array.isArray(d.findingIds))throw new Error("Doctor diagnosis causal group is malformed.");for(let p of d.findingIds){if(typeof p!="string"||!h.has(p))throw new Error("Doctor diagnosis causal group references an unknown finding.");if(b.has(p))throw new Error("Doctor diagnosis finding belongs to more than one causal group.");b.add(p);}}if(b.size!==h.size)throw new Error("Doctor diagnosis causal groups do not cover every finding exactly once.")}function P(a){let o=[...Array.isArray(a.repairCapabilities)?a.repairCapabilities:[],...Array.isArray(a.probes)?a.probes.map(s).map(t=>t&&s(t.repairCapability)):[]];for(let t of o){let i=s(t);if(!(!i||i.operation===void 0)&&!a$1(i.operation)){let e=typeof i.id=="string"?i.id:"unknown";throw new Error(`Doctor repair capability ${e} contains an invalid typed operation.`)}}}function z(a){let o=s(a);if(!o)throw new Error("Doctor evidence must be an object.");let t=I(o),i=s(o.contract);for(let c of t)_(c),P(c);if(i?.scoringPolicyVersion==="doctor-score-policy-v2"&&t.some(c=>!s(c.diagnosis)))throw new Error("Canonical Doctor evidence contains a project without diagnosis.");let e=s(o.healthScore);if(!e||typeof e.verdict!="string")return;let l=r(e,"total"),u=r(e,"passed"),E=r(e,"warnings"),f=r(e,"errors");if(l!==u+E+f)throw new Error("Doctor healthScore total must equal passed + warnings + errors.");let h=f>0?"blocked":E>0?"attention":"passed";if(e.verdict!==h)throw new Error(`Doctor healthScore verdict ${String(e.verdict)} contradicts score counts (${h}).`);let D=s(e.components);if(D){let c=s(D.host),m=s(D.projects);if(!c||!m)throw new Error("Doctor healthScore components must publish host and projects.");for(let[y,g]of [["host",c],["projects",m]]){let b=r(g,"total"),n=r(g,"passed"),d=r(g,"warnings"),p=r(g,"errors");if(b!==n+d+p)throw new Error(`Doctor ${y} score total contradicts its component counts.`)}if(u!==r(c,"passed")+r(m,"passed")||E!==r(c,"warnings")+r(m,"warnings")||f!==r(c,"errors")+r(m,"errors"))throw new Error("Doctor healthScore contradicts its host/project components.")}let v=0,k=0;for(let c of t){let m=Array.isArray(c.probes)?c.probes:[],y=s(c.diagnosis),g=y?s(y.coverage):null,b=m.filter(p=>s(p)?.status==="fail").length+(Array.isArray(c.issues)?c.issues.length:0),n=g?r(g,"blockingFindings"):b;v+=n;let d=s(c.probeSummary);if(d){if(r(d,"total")!==r(d,"passed")+r(d,"warnings")+r(d,"failed"))throw new Error("Doctor project probeSummary total contradicts its probe counts.");let p=r(d,"blockingFindings");if(p!==n)throw new Error("Doctor project probeSummary.blockingFindings contradicts its canonical diagnosis.");let A=p>0?"blocked":r(d,"advisoryFindings")+Number(d.unknownFindings??0)+Number(d.contradictionFindings??0)>0?"attention":"passed";if(d.verdict!==A||c.verdict!==A)throw new Error("Doctor project verdict contradicts its probe summary.");k+=r(d,"advisoryFindings");}}if(v>0&&f===0)throw new Error("Doctor evidence contains blocking findings but healthScore.errors is zero.");let w=s(o.summary);if(w&&Array.isArray(o.projects)){if(w.blockingFindings!==void 0&&r(w,"blockingFindings")!==v)throw new Error("Doctor workspace summary blockingFindings contradicts project diagnosis.");if(w.advisoryFindings!==void 0&&r(w,"advisoryFindings")!==k)throw new Error("Doctor workspace summary advisoryFindings contradicts project diagnosis.")}}export{R as a,O as b,M as c,z as d};
@@ -0,0 +1,13 @@
1
+ import {a as a$1}from'./chunk-JEI6BTZI.js';import {a}from'./chunk-D4UHRJAP.js';import {c,e,d}from'./chunk-H5RJCS5E.js';import {d as d$1,b}from'./chunk-UOCERSAN.js';import {g}from'./chunk-VA5VSOBL.js';import {q as q$1,m}from'./chunk-PJPS7CNH.js';import {p,d as d$2}from'./chunk-7FF5EOIO.js';import {e as e$1}from'./chunk-GAYK3WGV.js';import {b as b$1}from'./chunk-XESFJN52.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import j from'path';import W from'fs-extra';function X(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function q(e$1){switch(e$1){case "why":return d;case "trace":return e;default:return c}}async function P(e,n,o){try{if(!await W.pathExists(e))return null;let r=await W.readJson(e);return n?b$1(n,r,e):o&&a$2(r,o,e),r}catch(r){if((n||o)&&await W.pathExists(e))throw r;return null}}function Y(e,n){if(!e)return null;let o=n.trim().toLowerCase();return e.projects.find(r=>r.slug.toLowerCase()===o||r.relativePath.toLowerCase()===o)??null}function Q(e,n,o){let r=o.trim().toLowerCase(),t=(m(e)?.nodes.map(i=>i.id)??e.projects.map(i=>i.name)).find(i=>i.toLowerCase()===r);if(t)return t;let m$1=e.projects.find(i=>[i.name,i.path,j.basename(i.path)].filter(u=>u.trim().length>0).some(u=>u.toLowerCase()===r));if(m$1)return m$1.name;let p=Y(n,o);if(p){let i=e.projects.find(u=>u.path===p.relativePath||u.path.endsWith(`/${p.relativePath}`));if(i)return i.name}return o}function U(e,n){if(!e)return [];let o=n.trim().toLowerCase(),r=new Set;for(let d of e.projects){d.contracts.dependsOn?.some(t=>t.toLowerCase()===o)&&r.add(d.slug);for(let t of d.contracts.consumes??[])for(let m of e.projects)m.contracts.publishes?.includes(t)&&m.slug===o&&r.add(d.slug);}return [...r].sort()}function Z(e,n){if(!e)return [];let o=n.trim().toLowerCase();return e.steps.filter(r=>r.scope==="project"&&r.project?.toLowerCase()===o&&r.command?.display).map(r=>r.command.display).slice(0,8)}function l(e,n,o){return {id:e,title:n,body:o.trim()}}async function ke(e){let n=j.resolve(e.workspacePath),o=(e.now??new Date).toISOString(),r=e.model??await q$1({workspacePath:n,includeEvidence:true}),d=e.contract;if(d===void 0)try{d=(await p({workspacePath:n})).contract;}catch{d=null;}let t=e.verify;t===void 0&&(t=await P(j.join(n,d$1),d$1));let m$1=e.impact;if(m$1===void 0&&(m$1=await P(j.join(n,g),g)),e.target.kind==="release-blocked"){let s=t?.blockingReasons??[],c=(r.summary?.projectCount??r.projects.length)===0,g=[l("verdict",c?"Workspace scaffold posture":"Release verdict",t?c?`Scaffold posture: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Freshness: **${t.freshness.verdict}**. No registered projects yet \u2014 release gates apply after the first project is added.`:`Verdict: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Risk: **${t.impact.risk}**. Freshness: **${t.freshness.verdict}**.`:"No workspace verify report found. Run `npx workspai workspace verify --json --write` first."),l("blockers",c?"Pre-project signals":"Blocking reasons",s.length?s.map(h=>`- ${h}`).join(`
2
+ `):c?"No pre-project signals in the latest verify report.":"No blocking reasons in the latest verify report.")];return t?.resolutionHints?.length&&g.push(l("resolution","Resolution hints",t.resolutionHints.map(h=>`- **${h.blockerId}** (${h.resolutionClass}): ${h.commandRetryHint??h.fixHints[0]?.detail??"See fix hints"}`).join(`
3
+ `))),{schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:t?c?b(s.length,t.summary.verdict):s.length>0||t.summary.verdict==="blocked"?`Release blocked: ${t.summary.verdict} with ${s.length} blocking reason(s).`:t.summary.verdict==="needs-attention"?"Release needs attention: advisory or incomplete verification evidence remains; no blocking reason was reported.":`Release posture: ${t.summary.verdict}; no blocking reason was reported.`:"Release posture unknown \u2014 verify report missing.",sections:g,releaseVerdict:t?.summary.verdict,evidenceFreshness:t?.freshness.verdict,blocking:!!(t&&(t.summary.verdict==="blocked"||s.length>0)),releaseRisk:t?.impact.risk,blockingReasons:s,resolutionHints:t?.resolutionHints}}if(e.target.kind==="blocker"){let s=e.target,f=t?.resolutionHints?.find(g=>g.blockerId===s.blockerId),c=t?.blockingReasons.find(g=>g.includes(s.blockerId))??t?.blockingReasons[0];return {schemaVersion:a,generatedAt:o,workspacePath:n,target:s,summary:f?`Blocker ${s.blockerId}: ${f.resolutionClass}`:`Blocker ${s.blockerId} (no structured hint)`,sections:[l("reason","Blocking signal",c??"No matching blocking reason in verify."),l("hint","Resolution class",f?`${f.resolutionClass}
4
+
5
+ ${f.commandRetryHint??""}
6
+
7
+ ${f.fixHints.map(g=>`- ${g.detail}`).join(`
8
+ `)}`:"Run workspace verify to emit resolutionHints for this blocker.")],blockingReasons:c?[c]:[],resolutionHints:f?[f]:[]}}if(e.target.kind==="trace"){let s=j.isAbsolute(e.target.diffRef)?e.target.diffRef:j.join(n,e.target.diffRef),f=await P(s,void 0,"contracts/workspace-intelligence/workspace-model-diff.v1.json"),c=[...new Set((f?.changes??[]).filter(a=>a.type?.startsWith("project.")).map(a=>{let O=X(a.after),H=X(a.before);return typeof O.name=="string"&&O.name.trim()||typeof H.name=="string"&&H.name.trim()||a.project?.trim()||a.target?.trim()||""}).filter(Boolean))],h=(r.summary?.projectCount??r.projects.length)===0,_=m$1?.transitiveImpact?.map(a=>`${a.project?.name??a.target} (d${a.distance??0}, via ${a.via??"\u2014"})`)??[],y=t?.affectedSubgraph;return {schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:c?.length?`Trace from ${c.length} changed project(s) through blast radius to gate coverage.`:h?"Trace: workspace scaffold baseline \u2014 no project changes in the latest diff.":"Trace: diff baseline present with no project changes.",sections:[l("origin","Change origin",c?.length?c.map(a=>`- ${a}`).join(`
9
+ `):"No changed projects in diff."),l("blast-radius","Transitive impact",_.length?_.map(a=>`- ${a}`).join(`
10
+ `):"No transitive impact report."),l("gate","Subgraph gate",y?`Directly changed: ${y.directlyChanged}; transitive dependents: ${y.transitiveDependents}; covered: ${y.covered}; uncovered: ${y.uncovered}; unverifiable: ${y.unverifiable}.`:"No verify subgraph coverage available.")],releaseRisk:m$1?.summary?.risk??t?.impact.risk,blockingReasons:t?.blockingReasons}}let p$1=e.target.project,i=Q(r,d,p$1),u=m(r),k=u?a$1(u,i):{found:false,centrality:null,directDependents:[],transitiveDependents:[]},w=Y(d,p$1),E=U(d,p$1),x=Z(t,p$1),v=r.projects.find(s=>s.name.toLowerCase()===p$1.toLowerCase()),A=[l("overview","Project overview",v?`${v.name} (${v.frameworkDisplayName}, ${v.runtime}) at \`${v.path}\`.`:`Project **${p$1}** ${k.found?"exists in graph":"not found in workspace model"}.`),l("consumers","Consumers / dependents",[`Direct dependents: ${k.directDependents.join(", ")||"none"}`,`Contract consumers: ${E.join(", ")||"none"}`,`Transitive dependents (blast radius): ${k.transitiveDependents.length}`].join(`
11
+ `)),l("contracts","Critical contracts",w?[`Owns: ${w.contracts?.owns?.join(", ")||"none"}`,`Publishes: ${w.contracts.publishes.join(", ")||"none"}`,`Consumes: ${w.contracts.consumes.join(", ")||"none"}`,`APIs: ${w.contracts.apis.map(s=>s.name).join(", ")||"none"}`].join(`
12
+ `):"No workspace.contract.json entry for this project."),l("verification","Required verification",x.length?x.map(s=>`- ${s}`).join(`
13
+ `):"- `npx workspai workspace verify --json`\n- Project test/build via `workspace run` when configured")];k.centrality&&A.push(l("centrality","Graph centrality",`fanIn ${k.centrality.fanIn}, fanOut ${k.centrality.fanOut}, reach ${k.centrality.reach}, hotspot ${k.centrality.isHotspot?"yes":"no"}.`));let I=p$1.trim().toLowerCase(),T=s=>s.project?.name?.toLowerCase()===I||s.target.toLowerCase()===I,S=m$1?.affectedProjects?.find(T)?.risk??m$1?.transitiveImpact?.find(T)?.risk??t?.impact.risk??"unknown";return {schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:`${p$1}: ${E.length} consumer(s), release risk **${S}**.`,sections:A,releaseRisk:String(S)}}async function he(e,n,o="explain"){let r=q(o);return await e$1(n,r,d$2(e)),r}export{q as a,ke as b,he as c};
@@ -0,0 +1,2 @@
1
+ import {e,b as b$1}from'./chunk-5TY74LLW.js';import b from'crypto';import {constants}from'fs';import a from'fs/promises';import n from'path';var O="workspai.lifecycle-transaction",k=1,v="manifest.json",N="lifecycle-transaction-";async function h(r){try{return await a.lstat(r)}catch(e){if(e.code==="ENOENT")return null;throw e}}function D(r){let e=r?.code;return process.platform==="win32"&&(e==="EPERM"||e==="EINVAL"||e==="ENOSYS")}async function E(r){try{await r.sync();}catch(e){if(!D(e))throw e}}function T(r){if(typeof r!="string"||!n.isAbsolute(r))throw new Error("Lifecycle transaction journal contains a non-absolute target path.")}function F(r){if(typeof r!="string"||r.length===0||n.basename(r)!==r||r==="."||r==="..")throw new Error("Lifecycle transaction journal contains an unsafe backup reference.")}function J(r){if(!r||typeof r!="object")throw new Error("Lifecycle transaction journal is not an object.");let e=r;if(e.kind!==O||e.version!==k)throw new Error("Lifecycle transaction journal has an unsupported format.");if(!Number.isInteger(e.ownerPid)||e.ownerPid<=0)throw new Error("Lifecycle transaction journal has an invalid owner process.");if(!["active","committed","rolling-back"].includes(e.phase))throw new Error("Lifecycle transaction journal has an invalid phase.");if(!Array.isArray(e.operations))throw new Error("Lifecycle transaction journal has invalid operations.");for(let t of e.operations){if(!t||typeof t!="object")throw new Error("Lifecycle transaction journal contains an invalid operation.");let i=t;if(T(i.path),i.type!=="tree"){if(i.type!=="file"||!["absent","regular"].includes(i.state))throw new Error("Lifecycle transaction journal contains an invalid operation.");if(i.state==="regular"){if(!Number.isInteger(i.mode)||i.mode<0||i.mode>4095)throw new Error("Lifecycle transaction journal contains an invalid file mode.");F(i.backup);}}}return e}async function L(r){let e;try{e=await a.open(r,constants.O_RDONLY);}catch(t){if(D(t))return;throw t}try{await E(e);}finally{await e.close();}}async function P(r,e){let t=n.join(n.dirname(r),`.${n.basename(r)}.${process.pid}.${b.randomUUID()}.tmp`);try{let i=await a.open(t,constants.O_WRONLY|constants.O_CREAT|constants.O_EXCL,384);try{await i.writeFile(e),await E(i);}finally{await i.close();}await a.rename(t,r),await L(n.dirname(r));}catch(i){throw await a.rm(t,{force:true}).catch(()=>{}),i}}async function S(r,e){await P(n.join(r,v),Buffer.from(`${JSON.stringify(e,null,2)}
2
+ `));}async function A(r,e){let t=await h(r.path);if(t?.isSymbolicLink()||t&&!t.isFile())throw new Error(`Refusing to restore over a non-regular file: ${r.path}`);if(r.state==="absent"){t&&await a.unlink(r.path);return}if(!e)throw new Error(`Missing durable backup for: ${r.path}`);if(!await h(n.dirname(r.path)))return;let i=n.join(e,r.backup),o=await a.lstat(i).catch(s=>{if(s.code==="ENOENT"&&t?.isFile())return t;throw s});if(o===t)return;if(!o.isFile()||o.isSymbolicLink())throw new Error(`Lifecycle transaction backup is not a regular file: ${i}`);let c=await a.readFile(i),u=n.join(n.dirname(r.path),`.${n.basename(r.path)}.${process.pid}.${b.randomUUID()}.rollback`),l=await a.open(u,constants.O_WRONLY|constants.O_CREAT|constants.O_EXCL,r.mode);try{await l.writeFile(c),await l.chmod(r.mode),await E(l);}finally{await l.close();}try{await a.rename(u,r.path),await L(n.dirname(r.path));}catch(s){throw await a.rm(u,{force:true}).catch(()=>{}),s}}async function R(r){let e=await h(r.path);if(e){if(e.isSymbolicLink()||!e.isDirectory())throw new Error(`Refusing to remove a non-directory owned tree: ${r.path}`);await a.rm(r.path,{recursive:true});}}async function $(r,e){let t=[];for(let i of [...r].reverse())try{i.type==="file"?await A(i,e):await R(i);}catch(o){t.push(o);}if(t.length>0)throw new AggregateError(t,"Lifecycle transaction rollback failed.")}var g=class r{constructor(e){this.transactionDirectory=e;this.journalPath=e?n.join(e,v):void 0;}transactionDirectory;journalPath;actions=[];durableOperations=[];phase="active";finished=false;static async create(e={}){if(!e.journalDirectory)return new r;let t=n.resolve(e.journalDirectory);await a.mkdir(t,{recursive:true});let i=await a.mkdtemp(n.join(t,N));await L(t);let o=new r(i);return await o.persist(),o}assertActive(){if(this.finished||this.phase!=="active")throw new Error("Lifecycle transaction is no longer active.")}async persist(e=this.durableOperations){this.transactionDirectory&&await S(this.transactionDirectory,{kind:O,version:k,ownerPid:process.pid,phase:this.phase,operations:e});}async addDurableOperation(e){let t=[...this.durableOperations,e];await this.persist(t),this.durableOperations.push(e),this.actions.push(e);}async captureFile(e$1){this.assertActive();let t=n.resolve(e$1),i=await h(t);if(!i){await this.addDurableOperation({type:"file",path:t,state:"absent"}),e({targetPath:t,operation:"capture-preimage",status:"planned"});return}if(i.isSymbolicLink()||!i.isFile())throw new Error(`Lifecycle transaction can only capture regular files: ${t}`);let o;try{o=await a.open(t,constants.O_RDONLY|(constants.O_NOFOLLOW??0));}catch(c){throw c.code==="ENOENT"?new Error(`File changed while being captured: ${t}`,{cause:c}):c}try{let c=await o.stat();if(!c.isFile())throw new Error(`Lifecycle transaction can only capture regular files: ${t}`);let u=await o.readFile(),l=c.mode&4095;if(this.transactionDirectory){let s=`file-${this.durableOperations.length}-${b.randomUUID()}.bin`;await P(n.join(this.transactionDirectory,s),u),await this.addDurableOperation({type:"file",path:t,state:"regular",mode:l,backup:s});}else {let s=`memory-${this.durableOperations.length}`,d={type:"file",path:t,state:"regular",mode:l,backup:s};this.durableOperations.push(d),this.actions.push({type:"compensation",run:async()=>{let p=await h(t);if(p?.isSymbolicLink()||p&&!p.isFile())throw new Error(`Refusing to restore over a non-regular file: ${t}`);let w=n.join(n.dirname(t),`.${n.basename(t)}.${process.pid}.${b.randomUUID()}.rollback`);await a.writeFile(w,u,{flag:"wx",mode:l}),await a.chmod(w,l);try{await a.rename(w,t);}catch(j){throw await a.rm(w,{force:true}).catch(()=>{}),j}}});}e({targetPath:t,operation:"capture-preimage",status:"planned"});}finally{await o.close();}}async captureOwnedTree(e$1){this.assertActive();let t=n.resolve(e$1),i=await h(t);if(!i)return await this.addDurableOperation({type:"tree",path:t}),e({targetPath:t,operation:"create-tree",status:"planned"}),true;if(i.isSymbolicLink()||!i.isDirectory())throw new Error(`Lifecycle transaction tree must be absent or a directory: ${t}`);return false}registerCompensation(e){this.assertActive(),this.actions.push({type:"compensation",run:async()=>e()});}async commit(){if(!this.finished){this.assertActive(),this.phase="committed";try{await this.persist(),this.finished=true,this.actions.length=0,this.transactionDirectory&&await a.rm(this.transactionDirectory,{recursive:true}).catch(()=>{}),b$1({kind:"operation.completed",status:"succeeded",component:"lifecycle-transaction",message:"Lifecycle transaction committed.",attributes:{capturedTargets:this.durableOperations.length}});}catch(e){throw this.phase="active",e}}}async rollback(){if(this.finished||this.phase==="committed")return;this.assertActive(),this.phase="rolling-back",b$1({kind:"operation.started",status:"running",component:"lifecycle-transaction",message:"Lifecycle transaction rollback started.",attributes:{capturedTargets:this.durableOperations.length}});try{await this.persist();}catch(t){throw this.phase="active",t}let e=[];for(let t of [...this.actions].reverse())try{t.type==="compensation"?await t.run():t.type==="file"?await A(t,this.transactionDirectory):await R(t);}catch(i){e.push(i);}if(e.length>0)throw b$1({kind:"operation.failed",status:"failed",component:"lifecycle-transaction",message:"Lifecycle transaction rollback failed.",attributes:{failures:e.length}}),new AggregateError(e,"Lifecycle transaction rollback failed.");this.finished=true,this.transactionDirectory&&await a.rm(this.transactionDirectory,{recursive:true}),b$1({kind:"operation.completed",status:"rolled-back",component:"lifecycle-transaction",message:"Lifecycle transaction rolled back.",attributes:{restoredTargets:this.durableOperations.length}});}};async function Y(r={}){return g.create(r)}async function V(r){let e=n.resolve(r),t=await a.readdir(e,{withFileTypes:true}).catch(c=>{if(c.code==="ENOENT")return [];throw c}),i=[],o=[];for(let c of t){if(!c.isDirectory()||!c.name.startsWith(N))continue;let u=n.join(e,c.name);try{let l;try{l=await a.readFile(n.join(u,v),"utf8");}catch(p){if(p.code==="ENOENT")continue;throw p}let s=J(JSON.parse(l));if(s.phase==="committed"){await a.rm(u,{recursive:true});continue}let d=false;try{process.kill(s.ownerPid,0),d=true;}catch(p){d=p.code==="EPERM";}if(d)continue;s.phase==="active"&&(s.phase="rolling-back",await S(u,s)),await $(s.operations,u),await a.rm(u,{recursive:true}),i.push(u);}catch(l){o.push(l);}}if(o.length>0)throw new AggregateError(o,"Lifecycle transaction recovery failed.");return i}export{Y as a,V as b};
@@ -0,0 +1,2 @@
1
+ import {e,i,h as h$1,g as g$1,f,a}from'./chunk-UTV4DTNM.js';import E from'crypto';import k from'fs';import m from'path';var s=null,h=/(?:authorization|cookie|credential|password|passwd|secret|token|api[-_]?key)/i;function R(t,e){return e.WORKSPAI_ACTIVITY_DISABLE==="1"||(e.VITEST==="true"||e.VITEST==="1"||e.NODE_ENV==="test")&&e.WORKSPAI_ACTIVITY_FORCE!=="1"?true:t[0]==="live"}function g(t,e="",n=0){if(h.test(e))return "[REDACTED]";if(n>4)return "[TRUNCATED]";if(t!==void 0){if(t===null||typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return u(t);if(Array.isArray(t))return t.slice(0,100).map(o=>g(o,e,n+1));if(t instanceof Error)return {name:t.name,message:u(t.message)};if(typeof t=="object"){let o={};for(let[r,i]of Object.entries(t).slice(0,100))o[r]=g(i,r,n+1);return o}return String(t)}}function u(t){let e=t;for(let n of s?.sensitiveValues??[])n.length>=3&&(e=e.split(n).join("[REDACTED]"));if(e=e.replace(/((?:authorization|cookie|credential|password|passwd|secret|token|api[-_]?key)\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/gi,"$1[REDACTED]"),e=e.replace(/\bBearer\s+[^\s,;]+/gi,"Bearer [REDACTED]"),s){let n=s.resolvedScope.observationRootPath,o=[n,s.resolvedScope.rootPath].sort((r,i)=>i.length-r.length);for(let r of new Set(o))e=e.split(r).join("."),m.sep==="\\"&&(e=e.split(r.replaceAll("\\","/")).join("."));e=e.replace(/(^|[\s("'=])((?:[A-Za-z]:[\\/]|\/)(?!\/)[^\s"',;)\]}]+)/g,(r,i,a)=>`${i}${g$1(n,a)}`);}return e.length>2e3?`${e.slice(0,2e3)}\u2026`:e}function S(t,e){return t.startsWith("-")?h.test(t)?true:e.some(o=>/^(?:set|add|update|rotate)-(?:api-)?(?:key|token|secret|password)$/i.test(o))&&/^--?key$/i.test(t):false}function w(t){let e=[],n=false;for(let o of t){if(n){o.length>0&&e.push(o),n=false;continue}let r=o.indexOf("="),i=r>=0?o.slice(0,r):o;if(S(i,t))if(r>=0){let a=o.slice(r+1);a.length>0&&e.push(a);}else n=true;}return [...new Set(e)]}function P(t,e){let n=false;return t.map(o=>{if(n)return n=false,"[REDACTED]";let r=o.indexOf("="),i=r>=0?o.slice(0,r):o;return S(i,t)?r>=0?`${i}=[REDACTED]`:(n=true,o):m.isAbsolute(o)?g$1(e,o):o.length>300?`${o.slice(0,300)}\u2026`:o})}function T(t){if(t)return g(t)}function l(t){if(!s||s.finalized)return null;let e;if(t.blockId&&t.kind.startsWith("block.")&&t.kind!=="block.planned"){let i=s.blockAttempts.get(t.blockId)??0,a=s.blockStatuses.get(t.blockId);t.kind==="block.started"?e=a==="running"?Math.max(1,i):i+1:(t.kind!=="block.skipped"||i>0)&&(e=Math.max(1,i));}let n={schemaVersion:a,eventId:E.randomUUID(),sequence:++s.sequence,timestamp:new Date().toISOString(),runId:s.runId,...s.parentRunId?{parentRunId:s.parentRunId}:{},scope:s.resolvedScope.scope,...t,origin:f(s.resolvedScope),...e!==void 0?{attempt:e}:{},component:u(t.component),message:u(t.message),...t.target?{target:{...t.target,...t.target.locator?{locator:u(t.target.locator)}:{},...t.target.operation?{operation:u(t.target.operation)}:{}}}:{},...t.attributes?{attributes:T(t.attributes)}:{}},o=`${JSON.stringify(n)}
2
+ `,r=false;for(let i of s.fds)try{k.writeSync(i,o),r=true;}catch{}return r&&n.blockId&&n.kind.startsWith("block.")&&(s.blockStatuses.set(n.blockId,n.status),n.attempt!==void 0&&s.blockAttempts.set(n.blockId,n.attempt)),r?n:null}function O(t){let e$1=t.env??process.env;if(!R(t.command,e$1)){D(1,"Previous in-process activity run was superseded.");try{let n=e(t.cwd,{env:e$1}),r=[n.statePath,...n.mirrorStatePaths].map(c=>{let p=m.join(c,"runs");return k.mkdirSync(p,{recursive:true,mode:448}),i(p,{maxRuns:h$1-1}),m.join(p,`${t.runId}.ndjson`)}),i$1=[];try{for(let c of r)i$1.push(k.openSync(c,"a",384));}catch(c){for(let p of i$1)try{k.closeSync(p);}catch{}throw c}let a=w(t.command),d=P(t.command,n.observationRootPath);s={runId:t.runId,...t.parentRunId?{parentRunId:t.parentRunId}:{},command:d,sensitiveValues:a,startedAtMs:Date.now(),sequence:0,fds:i$1,journalPaths:r,resolvedScope:n,...t.blueprint?.nodes[0]?.id?{rootBlockId:t.blueprint.nodes[0].id}:{},blockStatuses:new Map,blockAttempts:new Map,finalized:false},l({kind:"run.started",status:"running",component:"cli",message:d.length>0?`workspai ${d.join(" ")}`:"workspai",attributes:{command:d,rapidkitVersion:t.rapidkitVersion,pid:process.pid,blueprintId:t.blueprint?.id,blueprintVersion:t.blueprint?.version}});for(let c of t.blueprint?.nodes??[])l({kind:"block.planned",status:"planned",component:"cli",blockId:c.id,parentSpanId:c.parentId,message:c.label,attributes:{order:c.order,layoutHint:c.layoutHint,group:c.group}});for(let c of t.blueprint?.edges??[])l({kind:"edge.declared",status:"planned",component:"cli",message:`${c.from} -> ${c.to}`,edge:{id:c.id,fromBlockId:c.from,toBlockId:c.to,kind:c.kind},attributes:{order:c.order}});s.rootBlockId&&l({kind:"block.started",status:"running",component:"cli",blockId:s.rootBlockId,message:t.blueprint?.nodes[0]?.label??"Workspai command"});}catch{s=null;}}}function j(t){return l(t)}function K(t){let e=t.status==="planned"?"block.planned":t.status==="running"?t.progress?"block.progress":"block.started":t.status==="succeeded"?"block.completed":t.status==="failed"?"block.failed":t.status==="blocked"?"block.blocked":t.status==="skipped"?"block.skipped":"block.progress";return l({kind:e,status:t.status,component:t.component??"cli",blockId:t.blockId,message:t.message,...t.progress?{progress:t.progress}:{},...t.attributes?{attributes:t.attributes}:{}})}function L(t){let e=s?g$1(s.resolvedScope.observationRootPath,m.resolve(t.workspacePath,t.relativePath)):t.relativePath.replaceAll("\\","/");return l({kind:"artifact.published",status:"succeeded",component:"artifact-store",message:`Published ${e}`,target:{kind:"artifact",locator:e,operation:t.operation??"publish",provenance:"authoritative"}})}function U(t){if(!s)return null;let e=g$1(s.resolvedScope.observationRootPath,t.targetPath);return l({kind:t.status==="planned"?"touch.planned":"touch.observed",status:t.status??"succeeded",component:"filesystem",message:t.message??`${t.operation} ${e}`,target:{kind:"file",locator:e,operation:t.operation,provenance:t.provenance??"authoritative"}})}function D(t,e){if(!s||s.finalized)return;let n=s,o=Date.now()-n.startedAtMs;for(let[r,i]of [...n.blockStatuses.entries()]){if(r===n.rootBlockId||i!=="planned"&&i!=="running")continue;let a=i==="running",d=t===130||t===143;l({kind:a?t===0?"block.completed":d?"block.blocked":"block.failed":"block.skipped",status:a?t===0?"succeeded":d?"cancelled":"failed":"skipped",component:"cli",blockId:r,message:a?t===0?"Stage completed with command":e??`Stage interrupted by command exit ${t}`:"Stage was not entered",durationMs:o,attributes:{finalizedByRun:true}});}n.rootBlockId&&l({kind:t===0?"block.completed":t===130||t===143?"block.blocked":"block.failed",status:t===0?"succeeded":t===130||t===143?"cancelled":"failed",component:"cli",blockId:n.rootBlockId,message:e??(t===0?"Command completed":`Command exited with code ${t}`),durationMs:o}),l({kind:t===0?"run.completed":t===130||t===143?"run.cancelled":"run.failed",status:t===0?"succeeded":t===130||t===143?"cancelled":"failed",component:"cli",message:e??(t===0?"CLI run completed":`CLI run exited with code ${t}`),durationMs:o,attributes:{exitCode:t}}),n.finalized=true;for(let r of n.fds)try{k.closeSync(r);}catch{}s=null;}export{O as a,j as b,K as c,L as d,U as e,D as f};
@@ -1 +1 @@
1
- import {f}from'./chunk-NZ3WZYD5.js';var o="model-usage-event.v1",s=f.evaluationLive,a="workspace-intelligence-evaluation-comparison.v1",i=["provider-reported","tokenizer-counted","estimated","unavailable"];export{o as a,s as b,a as c,i as d};
1
+ import {f}from'./chunk-6UNATTB7.js';var o="model-usage-event.v1",s=f.evaluationLive,a="workspace-intelligence-evaluation-comparison.v1",i=["provider-reported","tokenizer-counted","estimated","unavailable"];export{o as a,s as b,a as c,i as d};
@@ -1 +1 @@
1
- import {c,e}from'./chunk-CCDGHPEJ.js';import {i,h as h$1}from'./chunk-NZ3WZYD5.js';import {s}from'./chunk-MOSXTVPU.js';import u from'fs';import A from'path';var a=h$1.workspaceRunLast.schemaVersion,W="workspace-run-last.json",o=i.workspaceRunLast;var P=new Set(["init","test","build","start"]);function _(e){return P.has(e)}async function d(e){try{return await u.promises.access(e,u.constants.F_OK),true}catch{return false}}async function w(e){try{let r=await u.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}function m(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function h(e){let r=e.stage;return typeof r!="string"||r.trim().length===0||!Array.isArray(e.projects)?false:_(r)||/^[a-z][a-z0-9_-]*$/i.test(r)}function T(e){let r=m(e);return !r||r.schemaVersion===a?false:h(r)}function C(e){let r=m(e);return r?r.schemaVersion===a&&r.stages!=null:false}function p(e){if(C(e))return e;if(T(e)){let r=e.stage;return {schemaVersion:a,generatedAt:e.generatedAt,workspacePath:e.workspacePath,latestStage:r,stages:{[r]:e},enterpriseControls:e.enterpriseControls??{jsonReady:true,evidencePath:o}}}return null}function U(e,r){let n=p(e);if(!n)return null;let t=r??n.latestStage;return n.stages[t]??null}async function V(e){let r=(await Promise.all(s(A.resolve(e),"reports",W).map(async t=>await d(t)?t:null))).find(t=>typeof t=="string");if(!r)return null;let n=await w(r);return p(n)}async function j(e$1,r){let n=A.resolve(e$1);return c(n,o,async()=>{let t=(await Promise.all(s(n,"reports",W).map(async s=>await d(s)?s:null))).find(s=>typeof s=="string"),R=t?await w(t):null,i=p(R);if(t&&!i)throw new Error(`Workspace run evidence is unreadable or invalid; refusing to overwrite: ${t}`);let l=i?{...i.stages}:{};l[r.stage]=r;let g={schemaVersion:a,generatedAt:r.generatedAt,workspacePath:r.workspacePath,latestStage:r.stage,stages:l,enterpriseControls:{jsonReady:true,evidencePath:o}};return await e(n,o,g),g})}export{W as a,o as b,U as c,V as d,j as e};
1
+ import {c,e}from'./chunk-GAYK3WGV.js';import {i,h as h$1}from'./chunk-6UNATTB7.js';import {t}from'./chunk-VQZ5PI5J.js';import u from'fs';import A from'path';var a=h$1.workspaceRunLast.schemaVersion,W="workspace-run-last.json",o=i.workspaceRunLast;var P=new Set(["init","test","build","start"]);function _(e){return P.has(e)}async function d(e){try{return await u.promises.access(e,u.constants.F_OK),true}catch{return false}}async function w(e){try{let r=await u.promises.readFile(e,"utf-8");return JSON.parse(r)}catch{return null}}function m(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function h(e){let r=e.stage;return typeof r!="string"||r.trim().length===0||!Array.isArray(e.projects)?false:_(r)||/^[a-z][a-z0-9_-]*$/i.test(r)}function T(e){let r=m(e);return !r||r.schemaVersion===a?false:h(r)}function C(e){let r=m(e);return r?r.schemaVersion===a&&r.stages!=null:false}function p(e){if(C(e))return e;if(T(e)){let r=e.stage;return {schemaVersion:a,generatedAt:e.generatedAt,workspacePath:e.workspacePath,latestStage:r,stages:{[r]:e},enterpriseControls:e.enterpriseControls??{jsonReady:true,evidencePath:o}}}return null}function U(e,r){let n=p(e);if(!n)return null;let t=r??n.latestStage;return n.stages[t]??null}async function V(e){let r=(await Promise.all(t(A.resolve(e),"reports",W).map(async t=>await d(t)?t:null))).find(t=>typeof t=="string");if(!r)return null;let n=await w(r);return p(n)}async function j(e$1,r){let n=A.resolve(e$1);return c(n,o,async()=>{let t$1=(await Promise.all(t(n,"reports",W).map(async s=>await d(s)?s:null))).find(s=>typeof s=="string"),R=t$1?await w(t$1):null,i=p(R);if(t$1&&!i)throw new Error(`Workspace run evidence is unreadable or invalid; refusing to overwrite: ${t$1}`);let l=i?{...i.stages}:{};l[r.stage]=r;let g={schemaVersion:a,generatedAt:r.generatedAt,workspacePath:r.workspacePath,latestStage:r.stage,stages:l,enterpriseControls:{jsonReady:true,evidencePath:o}};return await e(n,o,g),g})}export{W as a,o as b,U as c,V as d,j as e};