@actiondock/core 2.5.1 → 2.7.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 (175) hide show
  1. package/dist/app/app.d.ts +14 -1
  2. package/dist/app/app.js +88 -222
  3. package/dist/app/static-index.d.ts +39 -0
  4. package/dist/app/static-index.js +164 -0
  5. package/dist/app/types.d.ts +5 -0
  6. package/dist/catalog/action-index.js +6 -4
  7. package/dist/catalog/package-catalog.js +2 -1
  8. package/dist/doctor/checks/index.d.ts +5 -0
  9. package/dist/doctor/checks/index.js +5 -0
  10. package/dist/doctor/checks/project-locate.d.ts +6 -0
  11. package/dist/doctor/checks/project-locate.js +36 -0
  12. package/dist/doctor/checks/project.d.ts +6 -0
  13. package/dist/doctor/checks/project.js +383 -0
  14. package/dist/doctor/checks/registry.d.ts +13 -0
  15. package/dist/doctor/checks/registry.js +207 -0
  16. package/dist/doctor/checks/runtime.d.ts +13 -0
  17. package/dist/doctor/checks/runtime.js +90 -0
  18. package/dist/doctor/checks/storage.d.ts +5 -0
  19. package/dist/doctor/checks/storage.js +34 -0
  20. package/dist/doctor/context.d.ts +35 -0
  21. package/dist/doctor/context.js +11 -0
  22. package/dist/doctor/doctor.d.ts +5 -0
  23. package/dist/doctor/doctor.js +33 -602
  24. package/dist/errors.d.ts +22 -0
  25. package/dist/errors.js +22 -0
  26. package/dist/execution/service.js +14 -9
  27. package/dist/export/templates.js +42 -30
  28. package/dist/host/host.d.ts +33 -0
  29. package/dist/host/host.js +222 -362
  30. package/dist/host/routing.d.ts +92 -0
  31. package/dist/host/routing.js +238 -0
  32. package/dist/host/types.d.ts +8 -0
  33. package/dist/index.d.ts +3 -1
  34. package/dist/index.js +3 -1
  35. package/dist/input/advice.d.ts +100 -0
  36. package/dist/input/advice.js +767 -0
  37. package/dist/input/describe.d.ts +106 -0
  38. package/dist/input/describe.js +176 -0
  39. package/dist/input/file-input.d.ts +54 -0
  40. package/dist/input/file-input.js +124 -0
  41. package/dist/input/flat-decode.d.ts +11 -0
  42. package/dist/input/flat-decode.js +13 -0
  43. package/dist/input/flat-errors.d.ts +72 -0
  44. package/dist/input/flat-errors.js +87 -0
  45. package/dist/input/flat-materializer.d.ts +29 -0
  46. package/dist/input/flat-materializer.js +179 -0
  47. package/dist/input/flat-parser.d.ts +50 -0
  48. package/dist/input/flat-parser.js +169 -0
  49. package/dist/input/flat-predicates.d.ts +34 -0
  50. package/dist/input/flat-predicates.js +50 -0
  51. package/dist/input/index.d.ts +14 -0
  52. package/dist/input/index.js +14 -0
  53. package/dist/input/input-resolver.d.ts +63 -0
  54. package/dist/input/input-resolver.js +254 -0
  55. package/dist/input/json-depth-scanner.d.ts +17 -0
  56. package/dist/input/json-depth-scanner.js +49 -0
  57. package/dist/input/metadata.d.ts +99 -0
  58. package/dist/input/metadata.js +99 -0
  59. package/dist/input/stdin-input.d.ts +26 -0
  60. package/dist/input/stdin-input.js +125 -0
  61. package/dist/input/utf8.d.ts +19 -0
  62. package/dist/input/utf8.js +36 -0
  63. package/dist/input/validation-mapper.d.ts +27 -0
  64. package/dist/input/validation-mapper.js +144 -0
  65. package/dist/ipc/host.js +38 -0
  66. package/dist/json/index.d.ts +1 -0
  67. package/dist/json/index.js +1 -0
  68. package/dist/json/value-validator.d.ts +88 -0
  69. package/dist/json/value-validator.js +330 -0
  70. package/dist/platform/types.d.ts +7 -0
  71. package/dist/process/control-arbiter.d.ts +107 -0
  72. package/dist/process/control-arbiter.js +251 -0
  73. package/dist/process/diagnostics-sink.d.ts +26 -0
  74. package/dist/process/diagnostics-sink.js +35 -0
  75. package/dist/process/index.d.ts +7 -0
  76. package/dist/process/index.js +7 -0
  77. package/dist/process/input-dispatcher.d.ts +88 -0
  78. package/dist/process/input-dispatcher.js +240 -0
  79. package/dist/process/managed-record.d.ts +78 -0
  80. package/dist/process/managed-record.js +1 -0
  81. package/dist/process/process-manager.d.ts +15 -56
  82. package/dist/process/process-manager.js +119 -707
  83. package/dist/process/reservation-table.d.ts +39 -0
  84. package/dist/process/reservation-table.js +80 -0
  85. package/dist/process/run-executor.d.ts +16 -0
  86. package/dist/process/run-executor.js +155 -0
  87. package/dist/process/terminal-output-cache.d.ts +66 -0
  88. package/dist/process/terminal-output-cache.js +132 -0
  89. package/dist/profile/client-actions.d.ts +56 -0
  90. package/dist/profile/client-actions.js +215 -0
  91. package/dist/profile/client-config.d.ts +20 -0
  92. package/dist/profile/client-config.js +51 -0
  93. package/dist/profile/client-health.d.ts +14 -0
  94. package/dist/profile/client-health.js +69 -0
  95. package/dist/profile/client-playbooks.d.ts +19 -0
  96. package/dist/profile/client-playbooks.js +36 -0
  97. package/dist/profile/client-query.d.ts +30 -0
  98. package/dist/profile/client-query.js +70 -0
  99. package/dist/profile/client-runs.d.ts +42 -0
  100. package/dist/profile/client-runs.js +58 -0
  101. package/dist/profile/client-state.d.ts +56 -0
  102. package/dist/profile/client-state.js +83 -0
  103. package/dist/profile/client-transport.d.ts +61 -0
  104. package/dist/profile/client-transport.js +156 -0
  105. package/dist/profile/client.d.ts +23 -142
  106. package/dist/profile/client.js +28 -588
  107. package/dist/profile/manager.js +1 -1
  108. package/dist/project/closure.d.ts +4 -4
  109. package/dist/project/closure.js +11 -5
  110. package/dist/project/init.js +2 -2
  111. package/dist/project/loader.d.ts +0 -25
  112. package/dist/project/loader.js +1 -154
  113. package/dist/project/transactions.d.ts +12 -14
  114. package/dist/project/transactions.js +60 -836
  115. package/dist/registry/registry.js +6 -4
  116. package/dist/registry/resolve.js +1 -1
  117. package/dist/runtime/action-registry.d.ts +45 -0
  118. package/dist/runtime/action-registry.js +108 -0
  119. package/dist/runtime/clock.d.ts +5 -17
  120. package/dist/runtime/clock.js +5 -15
  121. package/dist/runtime/context.d.ts +3 -0
  122. package/dist/runtime/context.js +17 -56
  123. package/dist/runtime/index.d.ts +3 -0
  124. package/dist/runtime/index.js +3 -0
  125. package/dist/runtime/package-runner-factory.d.ts +82 -0
  126. package/dist/runtime/package-runner-factory.js +186 -0
  127. package/dist/runtime/run-persistence.d.ts +85 -0
  128. package/dist/runtime/run-persistence.js +111 -0
  129. package/dist/runtime/runner.d.ts +25 -45
  130. package/dist/runtime/runner.js +130 -354
  131. package/dist/runtime/standalone.d.ts +25 -2
  132. package/dist/runtime/standalone.js +305 -87
  133. package/dist/schema/index.d.ts +1 -0
  134. package/dist/schema/index.js +1 -0
  135. package/dist/schema/validator.d.ts +10 -0
  136. package/dist/schema/validator.js +48 -54
  137. package/dist/server/dispatcher.d.ts +8 -3
  138. package/dist/server/dispatcher.js +16 -40
  139. package/dist/server/routes/runs.js +6 -4
  140. package/dist/server/security.d.ts +1 -7
  141. package/dist/server/security.js +2 -13
  142. package/dist/storage/clock.d.ts +25 -0
  143. package/dist/storage/clock.js +23 -0
  144. package/dist/storage/data-dir-lock.d.ts +3 -36
  145. package/dist/storage/data-dir-lock.js +48 -881
  146. package/dist/storage/index.d.ts +8 -1
  147. package/dist/storage/index.js +8 -2
  148. package/dist/storage/lazy.js +1 -0
  149. package/dist/storage/lock-core.d.ts +162 -0
  150. package/dist/storage/lock-core.js +885 -0
  151. package/dist/storage/sqlite.d.ts +19 -6
  152. package/dist/storage/sqlite.js +81 -89
  153. package/dist/storage/types.d.ts +27 -5
  154. package/dist/storage/types.js +21 -0
  155. package/dist/storage/utils.d.ts +22 -0
  156. package/dist/storage/utils.js +34 -0
  157. package/dist/target/local.d.ts +1 -0
  158. package/dist/target/local.js +23 -17
  159. package/dist/target/remote-errors.d.ts +21 -0
  160. package/dist/target/remote-errors.js +51 -0
  161. package/dist/target/remote-polling.d.ts +35 -0
  162. package/dist/target/remote-polling.js +104 -0
  163. package/dist/target/remote.d.ts +4 -0
  164. package/dist/target/remote.js +108 -301
  165. package/dist/target/sse-parser.d.ts +35 -0
  166. package/dist/target/sse-parser.js +163 -0
  167. package/dist/target/target.js +2 -0
  168. package/dist/target/types.d.ts +6 -0
  169. package/dist/utils/index.d.ts +1 -0
  170. package/dist/utils/index.js +1 -0
  171. package/dist/utils/net.d.ts +10 -0
  172. package/dist/utils/net.js +16 -0
  173. package/dist/version.d.ts +1 -1
  174. package/dist/version.js +1 -1
  175. package/package.json +2 -2
@@ -0,0 +1,207 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { ActionResolver } from "../../catalog/action-resolver.js";
4
+ import { findProjectRoot, loadProjectConfig } from "../../project/loader.js";
5
+ import { loadManifest } from "../../project/manifest.js";
6
+ import { getRegistryStatus, listLinkedPackages, resolvePackageRoot } from "../../registry/registry.js";
7
+ /**
8
+ * 按白名单过滤已链接包列表(白名单为空时保留全部)。
9
+ */
10
+ function filterLinkedList(ctx) {
11
+ let linkedList = listLinkedPackages(ctx.customHome);
12
+ if (ctx.packageAllowlist && ctx.packageAllowlist.length > 0) {
13
+ linkedList = linkedList.filter((pkg) => ctx.packageAllowlist.includes(pkg.id));
14
+ }
15
+ return linkedList;
16
+ }
17
+ /**
18
+ * 检查全局注册表健康度(链接数量与失效路径)。
19
+ */
20
+ export const checkGlobalRegistry = {
21
+ id: "registry.global",
22
+ run: (ctx) => {
23
+ try {
24
+ const regStatus = getRegistryStatus(ctx.customHome);
25
+ if (regStatus.staleCount > 0) {
26
+ ctx.checks.push({
27
+ id: "registry.global",
28
+ category: "registry",
29
+ name: "Global Registry",
30
+ status: "warn",
31
+ message: `${regStatus.totalPackagesCount} package(s), ${regStatus.workspaces.length} workspace(s), but ${regStatus.staleCount} stale path(s) detected`,
32
+ fix: "Run 'ad unlink --prune' to clean up stale entries from registry",
33
+ });
34
+ }
35
+ else {
36
+ ctx.checks.push({
37
+ id: "registry.global",
38
+ category: "registry",
39
+ name: "Global Registry",
40
+ status: "ok",
41
+ message: `${regStatus.totalPackagesCount} linked package(s), ${regStatus.workspaces.length} workspace(s) (0 stale)`,
42
+ });
43
+ }
44
+ }
45
+ catch (err) {
46
+ ctx.checks.push({
47
+ id: "registry.global",
48
+ category: "registry",
49
+ name: "Global Registry",
50
+ status: "error",
51
+ message: `Failed to read registry: ${err.message}`,
52
+ });
53
+ }
54
+ },
55
+ };
56
+ /**
57
+ * 检查已链接包的依赖完整性(声明依赖但缺失 node_modules)。
58
+ */
59
+ export const checkLinkedPackageDependencies = {
60
+ id: "registry.dependencies",
61
+ run: (ctx) => {
62
+ try {
63
+ const linkedList = filterLinkedList(ctx);
64
+ const missingNodeModules = [];
65
+ for (const pkg of linkedList) {
66
+ if (!existsSync(pkg.path))
67
+ continue;
68
+ const pkgJsonPath = join(pkg.path, "package.json");
69
+ if (!existsSync(pkgJsonPath))
70
+ continue;
71
+ try {
72
+ const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
73
+ const hasDeps = (pkgJson.dependencies && Object.keys(pkgJson.dependencies).length > 0) ||
74
+ (pkgJson.devDependencies && Object.keys(pkgJson.devDependencies).length > 0);
75
+ if (hasDeps && !existsSync(join(pkg.path, "node_modules"))) {
76
+ missingNodeModules.push(pkg.id);
77
+ }
78
+ }
79
+ catch (err) {
80
+ // 单包 package.json 损坏:计入检查告警而非无声跳过,诊断工具必须暴露异常
81
+ missingNodeModules.push(`${pkg.id} (unreadable package.json: ${err?.message || String(err)})`);
82
+ }
83
+ }
84
+ if (missingNodeModules.length > 0) {
85
+ ctx.checks.push({
86
+ id: "registry.dependencies",
87
+ category: "registry",
88
+ name: "Linked Package Dependencies",
89
+ status: "warn",
90
+ message: `${missingNodeModules.length} linked package(s) declare dependencies but miss node_modules: ${missingNodeModules.join(", ")}`,
91
+ fix: "Run 'npm install' in the affected package directories, or execute 'ad run' to auto-install",
92
+ });
93
+ }
94
+ else {
95
+ ctx.checks.push({
96
+ id: "registry.dependencies",
97
+ category: "registry",
98
+ name: "Linked Package Dependencies",
99
+ status: "ok",
100
+ message: linkedList.length > 0
101
+ ? "All linked packages have dependencies installed"
102
+ : "No linked packages requiring dependency verification",
103
+ });
104
+ }
105
+ }
106
+ catch (err) {
107
+ // 依赖检查整体失败:转为 error 检查项呈现在报告中,而非无声跳过
108
+ ctx.checks.push({
109
+ id: "registry.dependencies",
110
+ category: "registry",
111
+ name: "Linked Package Dependencies",
112
+ status: "error",
113
+ message: `Failed to check linked package dependencies: ${err?.message || String(err)}`,
114
+ });
115
+ }
116
+ },
117
+ };
118
+ /**
119
+ * 检查清单 uses 声明的跨包依赖闭包可解析性。
120
+ */
121
+ export const checkUsesClosure = {
122
+ id: "registry.uses_closure",
123
+ run: (ctx) => {
124
+ try {
125
+ const linkedList = filterLinkedList(ctx);
126
+ let packagesToCheck = linkedList.map((p) => ({
127
+ id: p.id,
128
+ root: p.path,
129
+ }));
130
+ const curProjectRoot = ctx.packageIdOrPath
131
+ ? resolvePackageRoot(ctx.packageIdOrPath, ctx.cwd, ctx.customHome) || findProjectRoot(ctx.packageIdOrPath)
132
+ : findProjectRoot(ctx.cwd);
133
+ if (curProjectRoot && !packagesToCheck.some((p) => p.root === curProjectRoot)) {
134
+ try {
135
+ const cfg = loadProjectConfig(curProjectRoot);
136
+ packagesToCheck.push({ id: cfg.id, root: curProjectRoot });
137
+ }
138
+ catch (err) {
139
+ // 当前工程配置损坏:无法纳入闭包检查范围,输出告警而非无声跳过
140
+ console.warn(`[Doctor] Skipping corrupted current project in uses-closure check: '${curProjectRoot}' (${err?.message || String(err)})`);
141
+ }
142
+ }
143
+ if (ctx.packageAllowlist && ctx.packageAllowlist.length > 0) {
144
+ packagesToCheck = packagesToCheck.filter((p) => ctx.packageAllowlist.includes(p.id));
145
+ }
146
+ const unresolvableUses = [];
147
+ for (const pkg of packagesToCheck) {
148
+ if (!existsSync(pkg.root))
149
+ continue;
150
+ const manifest = loadManifest(pkg.root);
151
+ if (!manifest || !manifest.actions)
152
+ continue;
153
+ for (const [actionId, actionEntry] of Object.entries(manifest.actions)) {
154
+ if (!Array.isArray(actionEntry.uses))
155
+ continue;
156
+ for (const rawRef of actionEntry.uses) {
157
+ if (typeof rawRef !== "string" || !rawRef.trim())
158
+ continue;
159
+ let parsed;
160
+ try {
161
+ parsed = ActionResolver.parseRef(rawRef);
162
+ }
163
+ catch {
164
+ unresolvableUses.push(`${pkg.id}/${actionId} -> '${rawRef}'`);
165
+ continue;
166
+ }
167
+ if (parsed.packageId) {
168
+ const depRoot = resolvePackageRoot(parsed.packageId, pkg.root, ctx.customHome);
169
+ if (!depRoot || !existsSync(depRoot)) {
170
+ unresolvableUses.push(`${pkg.id}/${actionId} -> '${rawRef}'`);
171
+ }
172
+ }
173
+ }
174
+ }
175
+ }
176
+ if (unresolvableUses.length > 0) {
177
+ ctx.checks.push({
178
+ id: "registry.uses_closure",
179
+ category: "registry",
180
+ name: "Cross-Package Uses Dependencies",
181
+ status: "warn",
182
+ message: `${unresolvableUses.length} unresolvable cross-package dependency reference(s) found in manifest uses: ${unresolvableUses.join(", ")}`,
183
+ fix: "Link missing packages with 'ad link', or correct unresolvable uses declarations",
184
+ });
185
+ }
186
+ else {
187
+ ctx.checks.push({
188
+ id: "registry.uses_closure",
189
+ category: "registry",
190
+ name: "Cross-Package Uses Dependencies",
191
+ status: "ok",
192
+ message: "All cross-package uses declarations in manifests resolved successfully",
193
+ });
194
+ }
195
+ }
196
+ catch (err) {
197
+ // 闭包检查整体失败:转为 error 检查项呈现在报告中,而非无声跳过
198
+ ctx.checks.push({
199
+ id: "registry.uses_closure",
200
+ category: "registry",
201
+ name: "Cross-Package Uses Dependencies",
202
+ status: "error",
203
+ message: `Failed to check cross-package uses dependencies: ${err?.message || String(err)}`,
204
+ });
205
+ }
206
+ },
207
+ };
@@ -0,0 +1,13 @@
1
+ import type { DoctorCheck } from "../context.js";
2
+ /**
3
+ * 检查 Node.js 运行时版本是否满足最低要求(>= 24.12.0)。
4
+ */
5
+ export declare const checkNodeRuntime: DoctorCheck;
6
+ /**
7
+ * 检查 Bun 运行时可用性(可选环境,用于跨运行时兼容性测试)。
8
+ */
9
+ export declare const checkBunRuntime: DoctorCheck;
10
+ /**
11
+ * 检查 CLI 可执行文件(ad)是否在 PATH 中。
12
+ */
13
+ export declare const checkCliExecutable: DoctorCheck;
@@ -0,0 +1,90 @@
1
+ import { findExecutable } from "../../utils/index.js";
2
+ function compareSemver(v1, v2) {
3
+ const p1 = v1.replace(/^v/, "").split(".").map(Number);
4
+ const p2 = v2.replace(/^v/, "").split(".").map(Number);
5
+ for (let i = 0; i < Math.max(p1.length, p2.length); i++) {
6
+ const num1 = p1[i] || 0;
7
+ const num2 = p2[i] || 0;
8
+ if (num1 > num2)
9
+ return 1;
10
+ if (num1 < num2)
11
+ return -1;
12
+ }
13
+ return 0;
14
+ }
15
+ /**
16
+ * 检查 Node.js 运行时版本是否满足最低要求(>= 24.12.0)。
17
+ */
18
+ export const checkNodeRuntime = {
19
+ id: "runtime.node",
20
+ run: (ctx) => {
21
+ const nodeVersion = process.versions.node;
22
+ if (nodeVersion) {
23
+ const isGte24 = compareSemver(nodeVersion, "24.12.0") >= 0;
24
+ ctx.checks.push({
25
+ id: "runtime.node",
26
+ category: "runtime",
27
+ name: "Node.js Runtime",
28
+ status: isGte24 ? "ok" : "warn",
29
+ message: `v${nodeVersion} (${isGte24 ? ">= 24.12.0 supported" : ">= 24.12.0 recommended"})`,
30
+ fix: isGte24 ? undefined : "Upgrade Node.js to v24.12.0 or higher",
31
+ });
32
+ }
33
+ },
34
+ };
35
+ /**
36
+ * 检查 Bun 运行时可用性(可选环境,用于跨运行时兼容性测试)。
37
+ */
38
+ export const checkBunRuntime = {
39
+ id: "runtime.bun",
40
+ run: (ctx) => {
41
+ const bunVersion = (typeof globalThis.Bun !== "undefined" && globalThis.Bun.version) ||
42
+ process.versions.bun;
43
+ if (bunVersion) {
44
+ ctx.checks.push({
45
+ id: "runtime.bun",
46
+ category: "runtime",
47
+ name: "Bun Runtime",
48
+ status: "ok",
49
+ message: `v${bunVersion} (available for cross-environment testing)`,
50
+ });
51
+ }
52
+ else {
53
+ ctx.checks.push({
54
+ id: "runtime.bun",
55
+ category: "runtime",
56
+ name: "Bun Runtime",
57
+ status: "ok",
58
+ message: "Bun runtime not detected (optional, used for cross-environment compatibility testing)",
59
+ });
60
+ }
61
+ },
62
+ };
63
+ /**
64
+ * 检查 CLI 可执行文件(ad)是否在 PATH 中。
65
+ */
66
+ export const checkCliExecutable = {
67
+ id: "runtime.cli",
68
+ run: (ctx) => {
69
+ const adPath = findExecutable("ad");
70
+ if (adPath) {
71
+ ctx.checks.push({
72
+ id: "runtime.cli",
73
+ category: "runtime",
74
+ name: "CLI Executable",
75
+ status: "ok",
76
+ message: `Found 'ad' in PATH at ${adPath}`,
77
+ });
78
+ }
79
+ else {
80
+ ctx.checks.push({
81
+ id: "runtime.cli",
82
+ category: "runtime",
83
+ name: "CLI Executable",
84
+ status: "warn",
85
+ message: "'ad' command not found in PATH",
86
+ fix: "Run 'npm install -g @actiondock/cli' or in SDK workspace run 'cd packages/cli && npm link'",
87
+ });
88
+ }
89
+ },
90
+ };
@@ -0,0 +1,5 @@
1
+ import type { DoctorCheck } from "../context.js";
2
+ /**
3
+ * 检查全局存储(全局 SQLite 数据库)可写性。
4
+ */
5
+ export declare const checkGlobalStorage: DoctorCheck;
@@ -0,0 +1,34 @@
1
+ import { createGlobalStorage } from "../../storage/index.js";
2
+ import { getActionDockHome } from "../../utils/index.js";
3
+ /**
4
+ * 检查全局存储(全局 SQLite 数据库)可写性。
5
+ */
6
+ export const checkGlobalStorage = {
7
+ id: "storage.global",
8
+ run: async (ctx) => {
9
+ const globalHome = getActionDockHome(ctx.customHome);
10
+ try {
11
+ const globalStorage = createGlobalStorage(ctx.customHome);
12
+ await globalStorage.setConfig("_doctor_probe_", "ok");
13
+ await globalStorage.deleteConfig("_doctor_probe_");
14
+ globalStorage.close();
15
+ ctx.checks.push({
16
+ id: "storage.global",
17
+ category: "storage",
18
+ name: "Global Storage",
19
+ status: "ok",
20
+ message: `Global SQLite database verified at ${globalHome}`,
21
+ });
22
+ }
23
+ catch (err) {
24
+ ctx.checks.push({
25
+ id: "storage.global",
26
+ category: "storage",
27
+ name: "Global Storage",
28
+ status: "error",
29
+ message: `Failed to access global storage: ${err.message}`,
30
+ fix: `Ensure directory '${globalHome}' is writable`,
31
+ });
32
+ }
33
+ },
34
+ };
@@ -0,0 +1,35 @@
1
+ import type { DoctorCheckItem } from "./types.js";
2
+ /**
3
+ * 体检诊断共享上下文:承载诊断输入选项、工程定位结果与累积检查项。
4
+ * 各检查函数按注册表顺序执行,并将检查项追加到 checks 列表。
5
+ */
6
+ export interface DoctorCheckContext {
7
+ /** 工作目录(默认 process.cwd()) */
8
+ cwd: string;
9
+ /** 目标包 ID 或磁盘路径(可选) */
10
+ packageIdOrPath?: string;
11
+ /** 自定义 ActionDock Home 目录(用于测试隔离) */
12
+ customHome?: string;
13
+ /** 允许纳入诊断的包 ID 白名单(可选) */
14
+ packageAllowlist?: string[];
15
+ /** 累积的检查项列表(保持注册顺序,直接决定报告展示顺序) */
16
+ checks: DoctorCheckItem[];
17
+ /** 诊断目标工程根目录(工程定位阶段写入;null 表示无工程上下文或被白名单排除) */
18
+ projectRoot: string | null;
19
+ /** 诊断目标工程的包 ID(工程配置加载成功后写入) */
20
+ packageId?: string;
21
+ }
22
+ /** 单项体检检查:从共享上下文读取输入,并将检查项追加到 ctx.checks。 */
23
+ export interface DoctorCheck {
24
+ /** 检查阶段唯一标识(用于注册表定位与排查) */
25
+ id: string;
26
+ /** 执行检查逻辑(可同步或异步) */
27
+ run: (ctx: DoctorCheckContext) => void | Promise<void>;
28
+ }
29
+ /** 基于诊断选项构建共享上下文(checks 从空列表开始累积)。 */
30
+ export declare function createDoctorCheckContext(options?: {
31
+ cwd?: string;
32
+ packageIdOrPath?: string;
33
+ customHome?: string;
34
+ packageAllowlist?: string[];
35
+ }): DoctorCheckContext;
@@ -0,0 +1,11 @@
1
+ /** 基于诊断选项构建共享上下文(checks 从空列表开始累积)。 */
2
+ export function createDoctorCheckContext(options) {
3
+ return {
4
+ cwd: options?.cwd || process.cwd(),
5
+ packageIdOrPath: options?.packageIdOrPath,
6
+ customHome: options?.customHome,
7
+ packageAllowlist: options?.packageAllowlist,
8
+ checks: [],
9
+ projectRoot: null,
10
+ };
11
+ }
@@ -1,4 +1,9 @@
1
1
  import type { DoctorReport } from "./types.js";
2
+ /**
3
+ * 执行环境与依赖体检诊断。
4
+ * 按注册表顺序执行各检查阶段(各阶段自行兜底异常,转为对应检查项呈现),
5
+ * 最终汇总各状态计数并输出结构化诊断报告。
6
+ */
2
7
  export declare function runDoctorChecks(options?: {
3
8
  cwd?: string;
4
9
  packageIdOrPath?: string;