modkh 0.0.0-stage → 0.2.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 (327) hide show
  1. package/README.md +66 -2
  2. package/dist/agent/bundled-skills.d.ts +13 -0
  3. package/dist/agent/bundled-skills.js +95 -0
  4. package/dist/agent/compaction.d.ts +53 -0
  5. package/dist/agent/compaction.js +191 -0
  6. package/dist/agent/images.d.ts +10 -0
  7. package/dist/agent/images.js +33 -0
  8. package/dist/agent/loop.d.ts +103 -0
  9. package/dist/agent/loop.js +267 -0
  10. package/dist/agent/skills.d.ts +26 -0
  11. package/dist/agent/skills.js +190 -0
  12. package/dist/agent/types.d.ts +137 -0
  13. package/dist/agent/types.js +12 -0
  14. package/dist/cli/agenticreplay.d.ts +1 -0
  15. package/dist/cli/agenticreplay.js +66 -0
  16. package/dist/cli/agents.d.ts +8 -0
  17. package/dist/cli/agents.js +12 -0
  18. package/dist/cli/answer-markdown.d.ts +3 -0
  19. package/dist/cli/answer-markdown.js +29 -0
  20. package/dist/cli/approval.d.ts +29 -0
  21. package/dist/cli/approval.js +92 -0
  22. package/dist/cli/catalog.d.ts +37 -0
  23. package/dist/cli/catalog.js +46 -0
  24. package/dist/cli/chat.d.ts +18 -0
  25. package/dist/cli/chat.js +1061 -0
  26. package/dist/cli/clipboard.d.ts +11 -0
  27. package/dist/cli/clipboard.js +82 -0
  28. package/dist/cli/color.d.ts +59 -0
  29. package/dist/cli/color.js +244 -0
  30. package/dist/cli/compaction-settings.d.ts +21 -0
  31. package/dist/cli/compaction-settings.js +54 -0
  32. package/dist/cli/completion-art.d.ts +2 -0
  33. package/dist/cli/completion-art.js +62 -0
  34. package/dist/cli/config.d.ts +50 -0
  35. package/dist/cli/config.js +192 -0
  36. package/dist/cli/editor.d.ts +23 -0
  37. package/dist/cli/editor.js +115 -0
  38. package/dist/cli/file-mentions.d.ts +14 -0
  39. package/dist/cli/file-mentions.js +141 -0
  40. package/dist/cli/head-checks.d.ts +41 -0
  41. package/dist/cli/head-checks.js +146 -0
  42. package/dist/cli/initial-connection.d.ts +7 -0
  43. package/dist/cli/initial-connection.js +20 -0
  44. package/dist/cli/keys.d.ts +29 -0
  45. package/dist/cli/keys.js +107 -0
  46. package/dist/cli/language.d.ts +1 -0
  47. package/dist/cli/language.js +105 -0
  48. package/dist/cli/limits.d.ts +13 -0
  49. package/dist/cli/limits.js +19 -0
  50. package/dist/cli/lines.d.ts +18 -0
  51. package/dist/cli/lines.js +80 -0
  52. package/dist/cli/model-catalog.d.ts +16 -0
  53. package/dist/cli/model-catalog.js +130 -0
  54. package/dist/cli/models.d.ts +4 -0
  55. package/dist/cli/models.js +101 -0
  56. package/dist/cli/official-models.d.ts +6 -0
  57. package/dist/cli/official-models.js +77 -0
  58. package/dist/cli/pdf.d.ts +8 -0
  59. package/dist/cli/pdf.js +71 -0
  60. package/dist/cli/permissions.d.ts +25 -0
  61. package/dist/cli/permissions.js +30 -0
  62. package/dist/cli/plugins.d.ts +1 -0
  63. package/dist/cli/plugins.js +53 -0
  64. package/dist/cli/providers.d.ts +10 -0
  65. package/dist/cli/providers.js +82 -0
  66. package/dist/cli/shell-display.d.ts +6 -0
  67. package/dist/cli/shell-display.js +35 -0
  68. package/dist/cli/stateright.d.ts +1 -0
  69. package/dist/cli/stateright.js +37 -0
  70. package/dist/cli/terminal-mouse.d.ts +21 -0
  71. package/dist/cli/terminal-mouse.js +51 -0
  72. package/dist/cli/terminal.d.ts +231 -0
  73. package/dist/cli/terminal.js +1417 -0
  74. package/dist/cli/tool-display.d.ts +9 -0
  75. package/dist/cli/tool-display.js +87 -0
  76. package/dist/cli/transcript-selection.d.ts +22 -0
  77. package/dist/cli/transcript-selection.js +75 -0
  78. package/dist/cli/usage.d.ts +22 -0
  79. package/dist/cli/usage.js +117 -0
  80. package/dist/cli/waiting-nyan.d.ts +3 -0
  81. package/dist/cli/waiting-nyan.js +17 -0
  82. package/dist/cli/waiting-whales.d.ts +3 -0
  83. package/dist/cli/waiting-whales.js +24 -0
  84. package/dist/index.d.ts +11 -0
  85. package/dist/index.js +186 -0
  86. package/dist/language/catalog.d.ts +44 -0
  87. package/dist/language/catalog.js +100 -0
  88. package/dist/language/commonlisp-bundled.d.ts +11 -0
  89. package/dist/language/commonlisp-bundled.js +22 -0
  90. package/dist/language/commonlisp-dependencies.d.ts +16 -0
  91. package/dist/language/commonlisp-dependencies.js +68 -0
  92. package/dist/language/commonlisp-install.d.ts +15 -0
  93. package/dist/language/commonlisp-install.js +214 -0
  94. package/dist/language/commonlisp-reader.d.ts +17 -0
  95. package/dist/language/commonlisp-reader.js +47 -0
  96. package/dist/language/commonlisp-systems.d.ts +3 -0
  97. package/dist/language/commonlisp-systems.js +32 -0
  98. package/dist/language/commonlisp-tls.d.ts +10 -0
  99. package/dist/language/commonlisp-tls.js +51 -0
  100. package/dist/language/detect.d.ts +29 -0
  101. package/dist/language/detect.js +103 -0
  102. package/dist/language/grammars/LICENSE +24 -0
  103. package/dist/language/grammars/manifest.json +76 -0
  104. package/dist/language/grammars/tree-sitter-c.wasm +0 -0
  105. package/dist/language/grammars/tree-sitter-cpp.wasm +0 -0
  106. package/dist/language/grammars/tree-sitter-css.wasm +0 -0
  107. package/dist/language/grammars/tree-sitter-html.wasm +0 -0
  108. package/dist/language/grammars/tree-sitter-javascript.wasm +0 -0
  109. package/dist/language/grammars/tree-sitter-php.wasm +0 -0
  110. package/dist/language/grammars/tree-sitter-python.wasm +0 -0
  111. package/dist/language/grammars/tree-sitter-ruby.wasm +0 -0
  112. package/dist/language/grammars/tree-sitter-rust.wasm +0 -0
  113. package/dist/language/grammars/tree-sitter-swift.wasm +0 -0
  114. package/dist/language/grammars/tree-sitter-tsx.wasm +0 -0
  115. package/dist/language/grammars/tree-sitter-typescript.wasm +0 -0
  116. package/dist/language/install.d.ts +50 -0
  117. package/dist/language/install.js +293 -0
  118. package/dist/language/lsp/client.d.ts +97 -0
  119. package/dist/language/lsp/client.js +340 -0
  120. package/dist/language/lsp/pool.d.ts +75 -0
  121. package/dist/language/lsp/pool.js +140 -0
  122. package/dist/language/lsp/service.d.ts +50 -0
  123. package/dist/language/lsp/service.js +174 -0
  124. package/dist/language/native.d.ts +8 -0
  125. package/dist/language/native.js +100 -0
  126. package/dist/language/platform.d.ts +14 -0
  127. package/dist/language/platform.js +20 -0
  128. package/dist/language/positions.d.ts +20 -0
  129. package/dist/language/positions.js +46 -0
  130. package/dist/language/syntax/assets.d.ts +9 -0
  131. package/dist/language/syntax/assets.js +73 -0
  132. package/dist/language/syntax/parser.d.ts +33 -0
  133. package/dist/language/syntax/parser.js +162 -0
  134. package/dist/language/typescript-capability.d.ts +6 -0
  135. package/dist/language/typescript-capability.js +42 -0
  136. package/dist/lisp/builtin-agents.d.ts +5 -0
  137. package/dist/lisp/builtin-agents.js +52 -0
  138. package/dist/lisp/config.d.ts +25 -0
  139. package/dist/lisp/config.js +202 -0
  140. package/dist/lisp/routing.d.ts +5 -0
  141. package/dist/lisp/routing.js +24 -0
  142. package/dist/lisp/runtime.d.ts +26 -0
  143. package/dist/lisp/runtime.js +107 -0
  144. package/dist/memory/kiokuko.d.ts +32 -0
  145. package/dist/memory/kiokuko.js +102 -0
  146. package/dist/memory/mcp.d.ts +38 -0
  147. package/dist/memory/mcp.js +211 -0
  148. package/dist/model/ai-sdk.d.ts +27 -0
  149. package/dist/model/ai-sdk.js +185 -0
  150. package/dist/model/chatgpt/login.d.ts +42 -0
  151. package/dist/model/chatgpt/login.js +180 -0
  152. package/dist/model/chatgpt/responses.d.ts +41 -0
  153. package/dist/model/chatgpt/responses.js +254 -0
  154. package/dist/model/chatgpt/tokens.d.ts +11 -0
  155. package/dist/model/chatgpt/tokens.js +50 -0
  156. package/dist/model/connection.d.ts +6 -0
  157. package/dist/model/connection.js +67 -0
  158. package/dist/model/context-window.d.ts +3 -0
  159. package/dist/model/context-window.js +64 -0
  160. package/dist/model/context.d.ts +11 -0
  161. package/dist/model/context.js +69 -0
  162. package/dist/model/factory.d.ts +27 -0
  163. package/dist/model/factory.js +89 -0
  164. package/dist/model/fixed.d.ts +17 -0
  165. package/dist/model/fixed.js +41 -0
  166. package/dist/model/harness-profile.d.ts +6 -0
  167. package/dist/model/harness-profile.js +23 -0
  168. package/dist/model/providers.d.ts +32 -0
  169. package/dist/model/providers.js +72 -0
  170. package/dist/model/reasoning.d.ts +16 -0
  171. package/dist/model/reasoning.js +84 -0
  172. package/dist/model/record-fetch.d.ts +2 -0
  173. package/dist/model/record-fetch.js +19 -0
  174. package/dist/plugins/api.d.ts +60 -0
  175. package/dist/plugins/api.js +1 -0
  176. package/dist/plugins/manager.d.ts +35 -0
  177. package/dist/plugins/manager.js +280 -0
  178. package/dist/plugins/package.d.ts +13 -0
  179. package/dist/plugins/package.js +99 -0
  180. package/dist/plugins/registry.d.ts +8 -0
  181. package/dist/plugins/registry.js +14 -0
  182. package/dist/session/store.d.ts +93 -0
  183. package/dist/session/store.js +311 -0
  184. package/dist/session/workspace.d.ts +19 -0
  185. package/dist/session/workspace.js +73 -0
  186. package/dist/subagents/head-assignment.d.ts +11 -0
  187. package/dist/subagents/head-assignment.js +47 -0
  188. package/dist/subagents/limits.d.ts +4 -0
  189. package/dist/subagents/limits.js +6 -0
  190. package/dist/subagents/processes.d.ts +18 -0
  191. package/dist/subagents/processes.js +73 -0
  192. package/dist/subagents/request.d.ts +4 -0
  193. package/dist/subagents/request.js +38 -0
  194. package/dist/subagents/service.d.ts +73 -0
  195. package/dist/subagents/service.js +645 -0
  196. package/dist/subagents/settings.d.ts +10 -0
  197. package/dist/subagents/settings.js +32 -0
  198. package/dist/subagents/types.d.ts +63 -0
  199. package/dist/subagents/types.js +1 -0
  200. package/dist/subagents/verification.d.ts +34 -0
  201. package/dist/subagents/verification.js +215 -0
  202. package/dist/tools/browse.d.ts +13 -0
  203. package/dist/tools/browse.js +117 -0
  204. package/dist/tools/browser-capability.d.ts +3 -0
  205. package/dist/tools/browser-capability.js +29 -0
  206. package/dist/tools/diff.d.ts +6 -0
  207. package/dist/tools/diff.js +82 -0
  208. package/dist/tools/edit.d.ts +3 -0
  209. package/dist/tools/edit.js +152 -0
  210. package/dist/tools/files.d.ts +6 -0
  211. package/dist/tools/files.js +96 -0
  212. package/dist/tools/formal-input.d.ts +6 -0
  213. package/dist/tools/formal-input.js +29 -0
  214. package/dist/tools/formal.d.ts +9 -0
  215. package/dist/tools/formal.js +79 -0
  216. package/dist/tools/guard.d.ts +7 -0
  217. package/dist/tools/guard.js +48 -0
  218. package/dist/tools/job-tools.d.ts +19 -0
  219. package/dist/tools/job-tools.js +148 -0
  220. package/dist/tools/jobs.d.ts +79 -0
  221. package/dist/tools/jobs.js +186 -0
  222. package/dist/tools/language.d.ts +6 -0
  223. package/dist/tools/language.js +172 -0
  224. package/dist/tools/lean-proof.d.ts +38 -0
  225. package/dist/tools/lean-proof.js +83 -0
  226. package/dist/tools/registry.d.ts +30 -0
  227. package/dist/tools/registry.js +113 -0
  228. package/dist/tools/run.d.ts +13 -0
  229. package/dist/tools/run.js +163 -0
  230. package/dist/tools/search.d.ts +2 -0
  231. package/dist/tools/search.js +156 -0
  232. package/dist/tools/shell-process.d.ts +115 -0
  233. package/dist/tools/shell-process.js +297 -0
  234. package/dist/tools/skills.d.ts +2 -0
  235. package/dist/tools/skills.js +46 -0
  236. package/dist/tools/stateright-runtime.d.ts +3 -0
  237. package/dist/tools/stateright-runtime.js +16 -0
  238. package/dist/tools/stateright.d.ts +3 -0
  239. package/dist/tools/stateright.js +78 -0
  240. package/dist/tools/web.d.ts +24 -0
  241. package/dist/tools/web.js +391 -0
  242. package/dist/version.d.ts +2 -0
  243. package/dist/version.js +2 -0
  244. package/docs/ci-repair-20261116.md +30 -0
  245. package/docs/commonlisp-build-output.md +14 -0
  246. package/docs/commonlisp-provider-migration.md +22 -0
  247. package/docs/commonlisp-qlot-recovery.md +28 -0
  248. package/docs/commonlisp-tls-recovery.md +28 -0
  249. package/docs/context-efficiency.md +122 -0
  250. package/docs/input.md +126 -0
  251. package/docs/languages.md +117 -0
  252. package/docs/models.md +109 -0
  253. package/docs/modkh-evidence.json +641 -0
  254. package/docs/modkh-failure-comparison.json +675 -0
  255. package/docs/modkh-namespace.md +39 -0
  256. package/docs/modkh-qlot-evidence.json +37 -0
  257. package/docs/modkh-verification.md +173 -0
  258. package/docs/modkh.md +128 -0
  259. package/docs/presets.md +64 -0
  260. package/docs/setup.md +99 -0
  261. package/docs/stateright.md +45 -0
  262. package/docs/subagents.md +152 -0
  263. package/docs/web.md +57 -0
  264. package/experiments/presets/common-lisp.lisp +38 -0
  265. package/experiments/presets/css.lisp +38 -0
  266. package/experiments/presets/formal.lisp +18 -0
  267. package/experiments/presets/html.lisp +38 -0
  268. package/experiments/presets/js.lisp +38 -0
  269. package/experiments/presets/language-microagents.lisp +29 -0
  270. package/experiments/presets/php.lisp +38 -0
  271. package/experiments/presets/svelte.lisp +38 -0
  272. package/experiments/presets/tailwindcss.lisp +24 -0
  273. package/experiments/presets/ts.lisp +38 -0
  274. package/native/stateright/Cargo.lock +478 -0
  275. package/native/stateright/Cargo.toml +11 -0
  276. package/native/stateright/src/lib.rs +163 -0
  277. package/native/stateright/src/main.rs +38 -0
  278. package/package.json +57 -4
  279. package/plugins/modkh-explorer/index.mjs +3 -0
  280. package/plugins/modkh-explorer/plugin.json +1 -0
  281. package/plugins/modkh-worker/index.mjs +3 -0
  282. package/plugins/modkh-worker/plugin.json +1 -0
  283. package/skills/kiokuko-dsh/LICENSE +21 -0
  284. package/skills/kiokuko-dsh/coding-ideal-routine-skill/SKILL.md +106 -0
  285. package/skills/kiokuko-dsh/japanese-translation-for-oss-models/SKILL.md +65 -0
  286. package/skills/kiokuko-dsh/kiokuko-architecture/SKILL.md +20 -0
  287. package/skills/kiokuko-dsh/kiokuko-architecture/references/cases.md +11 -0
  288. package/skills/kiokuko-dsh/kiokuko-benchmark/SKILL.md +20 -0
  289. package/skills/kiokuko-dsh/kiokuko-benchmark/references/cases.md +11 -0
  290. package/skills/kiokuko-dsh/kiokuko-investigate/SKILL.md +20 -0
  291. package/skills/kiokuko-dsh/kiokuko-investigate/references/cases.md +11 -0
  292. package/skills/kiokuko-dsh/kiokuko-lisp/SKILL.md +390 -0
  293. package/skills/kiokuko-dsh/kiokuko-review/SKILL.md +20 -0
  294. package/skills/kiokuko-dsh/kiokuko-review/references/cases.md +11 -0
  295. package/skills/kiokuko-dsh/kiokuko-simple-work/SKILL.md +70 -0
  296. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/SKILL.md +79 -0
  297. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/boundaries-and-ownership.md +52 -0
  298. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/domain-and-types.md +48 -0
  299. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/effects-and-data.md +43 -0
  300. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/kiokuko-patterns.md +314 -0
  301. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/problem-shaping-and-language.md +90 -0
  302. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/protocols-and-idempotency.md +42 -0
  303. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/review-checklist.md +92 -0
  304. package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/verification.md +45 -0
  305. package/skills/kiokuko-dsh/kiokuko-skill-authoring/SKILL.md +20 -0
  306. package/skills/kiokuko-dsh/kiokuko-skill-authoring/references/cases.md +11 -0
  307. package/skills/kiokuko-dsh/kiokuko-soul/SKILL.md +25 -0
  308. package/skills/kiokuko-dsh/kiokuko-technical-writing/SKILL.md +20 -0
  309. package/skills/kiokuko-dsh/kiokuko-technical-writing/references/cases.md +11 -0
  310. package/skills/kiokuko-dsh/kiokuko-ui-design-soul/SKILL.md +64 -0
  311. package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/accessibility-and-navigation.md +31 -0
  312. package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/async-recovery.md +49 -0
  313. package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/forms-and-controls.md +35 -0
  314. package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/interaction-feedback.md +34 -0
  315. package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/responsive-and-platform.md +38 -0
  316. package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/safety-and-review.md +43 -0
  317. package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/ui-checklist.md +75 -0
  318. package/skills/kiokuko-dsh/kiokuko-verification/SKILL.md +20 -0
  319. package/skills/kiokuko-dsh/kiokuko-verification/references/cases.md +11 -0
  320. package/skills/kiokuko-dsh/manifest.json +168 -0
  321. package/skills/kiokuko-dsh/memory-reasoning/SKILL.md +44 -0
  322. package/skills/kiokuko-dsh/one-shot-software-completion/SKILL.md +113 -0
  323. package/skills/kiokuko-dsh/one-shot-software-completion/references/boundaries-and-lifecycle.md +70 -0
  324. package/skills/kiokuko-dsh/one-shot-software-completion/references/discovery-and-scope.md +71 -0
  325. package/skills/kiokuko-dsh/one-shot-software-completion/references/failure-recovery.md +43 -0
  326. package/skills/kiokuko-dsh/one-shot-software-completion/references/verification-and-completion.md +73 -0
  327. package/skills/kiokuko-dsh/veteran-programmer-skill/SKILL.md +66 -0
@@ -0,0 +1,29 @@
1
+ import { type LanguageDefinition, type LanguageId } from './catalog.ts';
2
+ export interface Detection {
3
+ language: LanguageDefinition;
4
+ /** Absolute, real project root chosen from manifest proximity. */
5
+ root: string;
6
+ /** Manifest that justified the root, if any. */
7
+ manifest?: string;
8
+ }
9
+ /** Detection is limited to the named file plus a bounded manifest scan; no project code is executed. */
10
+ export declare function detectLanguage(file: string, workspaceRoot: string): Detection | undefined;
11
+ /** Languages suggested by manifests in the workspace root, used by `modkh language status`. */
12
+ export declare function detectedLanguages(workspaceRoot: string): LanguageDefinition[];
13
+ export interface LanguageSettings {
14
+ autoInstall: boolean;
15
+ disabled: LanguageId[];
16
+ /** Milliseconds allowed for an install before it is reported as preparing. */
17
+ installTimeoutMs: number;
18
+ /** Milliseconds allowed for a server to answer a single request. */
19
+ requestTimeoutMs: number;
20
+ /** Languages the user explicitly configured a server path for. */
21
+ servers: Partial<Record<LanguageId, {
22
+ command: string;
23
+ args?: string[];
24
+ }>>;
25
+ }
26
+ export declare const DEFAULT_LANGUAGE_SETTINGS: LanguageSettings;
27
+ export declare function languageHome(): string;
28
+ /** Parse an untrusted settings object; unknown keys and invalid values fall back to defaults. */
29
+ export declare function parseLanguageSettings(raw: unknown): LanguageSettings;
@@ -0,0 +1,103 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { configDir } from "../cli/config.js";
4
+ import { LANGUAGES, languageById, languageForPath } from "./catalog.js";
5
+ const MAX_SCAN_ENTRIES = 400;
6
+ /** Walk up from the file until a manifest for that language appears; stop at the workspace root. */
7
+ function findRoot(file, workspaceRoot, language) {
8
+ let current = path.dirname(file);
9
+ const stop = path.resolve(workspaceRoot);
10
+ for (let depth = 0; depth < 24; depth++) {
11
+ for (const name of language.manifests) {
12
+ if (name.includes('*')) {
13
+ try {
14
+ const match = fs.readdirSync(current).find(entry => entry.endsWith(name.slice(name.indexOf('*') + 1)));
15
+ if (match)
16
+ return { root: current, manifest: match };
17
+ }
18
+ catch { /* unreadable directory: keep walking up */ }
19
+ }
20
+ else if (fs.existsSync(path.join(current, name))) {
21
+ return { root: current, manifest: name };
22
+ }
23
+ }
24
+ const parent = path.dirname(current);
25
+ if (parent === current || path.relative(stop, parent).startsWith('..'))
26
+ break;
27
+ current = parent;
28
+ }
29
+ return { root: stop };
30
+ }
31
+ /** Detection is limited to the named file plus a bounded manifest scan; no project code is executed. */
32
+ export function detectLanguage(file, workspaceRoot) {
33
+ const language = languageForPath(file);
34
+ if (!language)
35
+ return undefined;
36
+ const { root, manifest } = findRoot(file, workspaceRoot, language);
37
+ return { language, root, ...(manifest ? { manifest } : {}) };
38
+ }
39
+ /** Languages suggested by manifests in the workspace root, used by `modkh language status`. */
40
+ export function detectedLanguages(workspaceRoot) {
41
+ let entries = [];
42
+ try {
43
+ entries = fs.readdirSync(workspaceRoot).slice(0, MAX_SCAN_ENTRIES);
44
+ }
45
+ catch {
46
+ return [];
47
+ }
48
+ const found = new Set();
49
+ for (const language of LANGUAGES) {
50
+ if (language.manifests.length === 0)
51
+ continue;
52
+ for (const name of language.manifests) {
53
+ const hit = name.includes('*')
54
+ ? entries.some(entry => entry.endsWith(name.slice(name.indexOf('*') + 1)))
55
+ : entries.includes(name);
56
+ if (hit) {
57
+ found.add(language.id);
58
+ break;
59
+ }
60
+ }
61
+ }
62
+ return [...found].map(id => languageById(id)).filter(Boolean);
63
+ }
64
+ export const DEFAULT_LANGUAGE_SETTINGS = {
65
+ autoInstall: true,
66
+ disabled: [],
67
+ installTimeoutMs: 180_000,
68
+ requestTimeoutMs: 20_000,
69
+ servers: {},
70
+ };
71
+ export function languageHome() {
72
+ return path.join(configDir(), 'language');
73
+ }
74
+ /** Parse an untrusted settings object; unknown keys and invalid values fall back to defaults. */
75
+ export function parseLanguageSettings(raw) {
76
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
77
+ return DEFAULT_LANGUAGE_SETTINGS;
78
+ const value = raw;
79
+ const disabled = Array.isArray(value['disabled'])
80
+ ? value['disabled'].filter((id) => typeof id === 'string' && languageById(id) !== undefined)
81
+ : [];
82
+ const servers = {};
83
+ if (value['servers'] && typeof value['servers'] === 'object' && !Array.isArray(value['servers'])) {
84
+ for (const [id, entry] of Object.entries(value['servers'])) {
85
+ if (languageById(id) === undefined || !entry || typeof entry !== 'object')
86
+ continue;
87
+ const command = entry['command'];
88
+ const args = entry['args'];
89
+ if (typeof command !== 'string' || command.length === 0 || command.length > 4096)
90
+ continue;
91
+ const list = Array.isArray(args) ? args.filter((a) => typeof a === 'string').slice(0, 32) : [];
92
+ servers[id] = { command, args: list };
93
+ }
94
+ }
95
+ const positive = (input, fallback) => typeof input === 'number' && Number.isSafeInteger(input) && input > 0 && input <= 3_600_000 ? input : fallback;
96
+ return {
97
+ autoInstall: value['autoInstall'] !== false,
98
+ disabled,
99
+ installTimeoutMs: positive(value['installTimeoutMs'], DEFAULT_LANGUAGE_SETTINGS.installTimeoutMs),
100
+ requestTimeoutMs: positive(value['requestTimeoutMs'], DEFAULT_LANGUAGE_SETTINGS.requestTimeoutMs),
101
+ servers,
102
+ };
103
+ }
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
@@ -0,0 +1,76 @@
1
+ {
2
+ "schema": 1,
3
+ "source": "tree-sitter-wasms@0.1.13",
4
+ "packageMetadataSha256": "d08bdba4e2f2d9c90d9bcaa65df6fee733cfa280edcf6762ca60516c32bf96f5",
5
+ "license": {
6
+ "file": "LICENSE",
7
+ "sha256": "6b0382b16279f26ff69014300541967a356a666eb0b91b422f6862f6b7dad17e"
8
+ },
9
+ "provenance": "Installed npm package and lockfile; grammar upstream revisions are not supplied by this package. Digests identify bytes, not independent upstream authentication.",
10
+ "unavailable": [
11
+ "commonlisp",
12
+ "svelte"
13
+ ],
14
+ "grammars": [
15
+ {
16
+ "id": "typescript",
17
+ "bytes": 2342690,
18
+ "sha256": "8515404dceed38e1ed86aa34b09fcf3379fff1b4ff9dd3967bcd6d1eb5ac3d8f"
19
+ },
20
+ {
21
+ "id": "tsx",
22
+ "bytes": 2411272,
23
+ "sha256": "6aa3b2c70e76f5d48eafef1093e9c4de383e13f2fdde2f4e9b98a378f6a8f1b6"
24
+ },
25
+ {
26
+ "id": "javascript",
27
+ "bytes": 647334,
28
+ "sha256": "63812b9e275d26851264734868d27a1656bd44a2ef6eb3e85e6b03728c595ab5"
29
+ },
30
+ {
31
+ "id": "html",
32
+ "bytes": 18468,
33
+ "sha256": "11b3405c1543fb012f5ed7f8ee73125076dce8b168301e1e787e4c717da6b456"
34
+ },
35
+ {
36
+ "id": "css",
37
+ "bytes": 98133,
38
+ "sha256": "5fc615467b1b98420ed7517e5bf9e1f88468132dd903d842dfb13714f6a1cb0c"
39
+ },
40
+ {
41
+ "id": "python",
42
+ "bytes": 476105,
43
+ "sha256": "9056d0fb0c337810d019fae350e8167786119da98f0f282aceae7ab89ee8253b"
44
+ },
45
+ {
46
+ "id": "rust",
47
+ "bytes": 818756,
48
+ "sha256": "4409921a70d0aa5bec7d1d7ce809a557a8ee1cf6ace901e3ac6a76e62cfea903"
49
+ },
50
+ {
51
+ "id": "c",
52
+ "bytes": 792959,
53
+ "sha256": "056b25072382f72deee2c64ec238ffc4bb8cf42844ef21502c0e70f03a8a0d66"
54
+ },
55
+ {
56
+ "id": "cpp",
57
+ "bytes": 4662978,
58
+ "sha256": "f6afdf53bfd6de76557bb7edb624a3a3869e14d9a83b78433f93617ecee42527"
59
+ },
60
+ {
61
+ "id": "ruby",
62
+ "bytes": 2106447,
63
+ "sha256": "93a5022855314cdb45458c7bb026a24a0ebc3a5ff6439e542e881f14dfa13a39"
64
+ },
65
+ {
66
+ "id": "swift",
67
+ "bytes": 3147876,
68
+ "sha256": "41c4fdb2249a3aa6d87eed0d383081ff09725c2248b4977043a43825980ffcc7"
69
+ },
70
+ {
71
+ "id": "php",
72
+ "bytes": 812594,
73
+ "sha256": "55bb617b6f01e14bab997861f0b20a2420cf6ba3199ffeb295b9ec398966d8a3"
74
+ }
75
+ ]
76
+ }
@@ -0,0 +1,50 @@
1
+ import type { LanguageDefinition } from './catalog.ts';
2
+ export interface InstalledServer {
3
+ command: string;
4
+ args: string[];
5
+ /** Digest of the installed manifest, used to notice a changed install. */
6
+ digest: string;
7
+ version: string;
8
+ installedAt: string;
9
+ }
10
+ export declare function verifyTsserver(prefix: string): void;
11
+ export interface Resolution {
12
+ status: 'ready' | 'missing' | 'unsupported' | 'disabled' | 'error';
13
+ command?: string;
14
+ args?: string[];
15
+ detail?: string;
16
+ installed?: boolean;
17
+ }
18
+ /**
19
+ * Find a server without installing: explicit setting, then MODKH-managed prefix, then host PATH.
20
+ * Installation is a separate step so a plain read never blocks on a network download.
21
+ */
22
+ export declare function resolveServer(language: LanguageDefinition, options: {
23
+ disabled?: boolean;
24
+ server?: {
25
+ command: string;
26
+ args?: string[];
27
+ };
28
+ }): Resolution;
29
+ export interface InstallOutcome {
30
+ status: 'ready' | 'unavailable' | 'error';
31
+ detail?: string;
32
+ }
33
+ /** Idempotent: a verified install is reused, and a failed install is reported without retrying. */
34
+ export declare function ensureInstalled(language: LanguageDefinition, options: {
35
+ autoInstall: boolean;
36
+ disabled?: boolean;
37
+ server?: {
38
+ command: string;
39
+ args?: string[];
40
+ };
41
+ signal?: AbortSignal;
42
+ }): Promise<InstallOutcome>;
43
+ /** Explicit retry clears the remembered failure and re-resolves the recipe. */
44
+ export declare function clearFailure(id: string): void;
45
+ export declare function statusReport(): {
46
+ id: string;
47
+ version?: string;
48
+ command?: string;
49
+ installedAt?: string;
50
+ }[];
@@ -0,0 +1,293 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createHash } from 'node:crypto';
4
+ import { executeBounded, privateEnvironment } from "../lisp/runtime.js";
5
+ import { CL_LSP_REPOSITORY } from "./commonlisp-bundled.js";
6
+ import { installCommonLisp, reusableCommonLisp } from "./commonlisp-install.js";
7
+ import { installPhpantom } from "./native.js";
8
+ import { hostPlatform } from "./platform.js";
9
+ import { probeTypescript, recommendedTypescript } from "./typescript-capability.js";
10
+ import { LspServer } from "./lsp/client.js";
11
+ import { languageHome } from "./detect.js";
12
+ const LOCK_STALE_MS = 10 * 60_000;
13
+ const MAKE_TIMEOUT_MS = 240_000;
14
+ function statePath() { return path.join(languageHome(), 'state.json'); }
15
+ function readState() {
16
+ try {
17
+ const parsed = JSON.parse(fs.readFileSync(statePath(), 'utf8'));
18
+ if (parsed && typeof parsed === 'object' && parsed.version === 1 && parsed.servers && typeof parsed.servers === 'object')
19
+ return parsed;
20
+ }
21
+ catch { /* missing or corrupt: start clean, never trust half-written JSON */ }
22
+ return { version: 1, servers: {} };
23
+ }
24
+ /** Write through a temporary file so a crash cannot leave a truncated manifest. */
25
+ function writeState(state) {
26
+ fs.mkdirSync(languageHome(), { recursive: true });
27
+ const target = statePath();
28
+ const temporary = `${target}.${process.pid}.${Date.now()}.tmp`;
29
+ fs.writeFileSync(temporary, `${JSON.stringify(state, null, 2)}\n`, { encoding: 'utf8', flush: true });
30
+ fs.renameSync(temporary, target);
31
+ }
32
+ function digestOf(file) {
33
+ return createHash('sha256').update(fs.readFileSync(file)).digest('hex');
34
+ }
35
+ function isExecutable(file) {
36
+ try {
37
+ const stat = fs.statSync(file);
38
+ if (!stat.isFile())
39
+ return false;
40
+ fs.accessSync(file, fs.constants.X_OK);
41
+ return true;
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ }
47
+ function versionOf(packageJson) {
48
+ try {
49
+ const parsed = JSON.parse(fs.readFileSync(packageJson, 'utf8'));
50
+ return typeof parsed.version === 'string' ? parsed.version : 'unknown';
51
+ }
52
+ catch {
53
+ return 'unknown';
54
+ }
55
+ }
56
+ function serverRoot(language) {
57
+ return path.join(languageHome(), 'servers', language.id);
58
+ }
59
+ /** Cross-process exclusion for one install target; a stale lock is reclaimed after a fixed age. */
60
+ async function withLock(target, action) {
61
+ fs.mkdirSync(path.dirname(target), { recursive: true });
62
+ const lock = `${target}.lock`;
63
+ const deadline = Date.now() + 60_000;
64
+ for (;;) {
65
+ try {
66
+ fs.mkdirSync(lock);
67
+ break;
68
+ }
69
+ catch (e) {
70
+ if (e.code !== 'EEXIST')
71
+ throw e;
72
+ try {
73
+ if (Date.now() - fs.statSync(lock).mtimeMs > LOCK_STALE_MS) {
74
+ fs.rmSync(lock, { recursive: true, force: true });
75
+ continue;
76
+ }
77
+ }
78
+ catch {
79
+ continue;
80
+ }
81
+ if (Date.now() > deadline)
82
+ throw new Error('他のMODKHプロセスが導入中のため待機時間を超えました');
83
+ await new Promise(resolve => setTimeout(resolve, 250));
84
+ }
85
+ }
86
+ const heartbeat = setInterval(() => { try {
87
+ const now = new Date();
88
+ fs.utimesSync(lock, now, now);
89
+ }
90
+ catch { /* action reports its own failure */ } }, 30000);
91
+ try {
92
+ return await action();
93
+ }
94
+ finally {
95
+ clearInterval(heartbeat);
96
+ fs.rmSync(lock, { recursive: true, force: true });
97
+ }
98
+ }
99
+ async function run(command, args, signal) {
100
+ const home = path.join(languageHome(), 'runtime-home');
101
+ fs.mkdirSync(home, { recursive: true, mode: 0o700 });
102
+ const result = await executeBounded(command, [...args], { cwd: home, env: privateEnvironment(home),
103
+ inputDigest: createHash('sha256').update(JSON.stringify([command, args])).digest('hex'), signal, timeoutMs: MAKE_TIMEOUT_MS, maxOutputBytes: 1024 * 1024 });
104
+ if (result.state !== 'exited')
105
+ throw new Error(`Installer ${result.state}: ${result.stderr.slice(-1000)}`);
106
+ return { code: result.exitCode ?? -1, stdout: result.stdout, stderr: result.stderr };
107
+ }
108
+ export function verifyTsserver(prefix) {
109
+ const api = path.join(prefix, 'node_modules', 'typescript', 'lib', 'tsserver.js');
110
+ if (!fs.existsSync(api) || !fs.statSync(api).isFile())
111
+ throw new Error('TypeScript dependency lacks required typescript/lib/tsserver.js API');
112
+ }
113
+ async function initializeProbe(language, command, args, root, signal) {
114
+ const server = new LspServer({ id: language.id, command, args, root, requestTimeoutMs: 10000,
115
+ env: privateEnvironment(root), inheritEnv: false });
116
+ try {
117
+ await server.start(signal);
118
+ }
119
+ finally {
120
+ await server.dispose();
121
+ }
122
+ }
123
+ /** Install into a private prefix with a private npm cache; never touch the project or the user cache. */
124
+ async function installNpm(language, signal) {
125
+ const recipe = language.install;
126
+ if (recipe?.kind !== 'npm')
127
+ throw new Error('npm 導入レシピがありません');
128
+ const target = serverRoot(language);
129
+ await withLock(target, async () => {
130
+ if (readState().servers[language.id] && resolveServer(language, {}).status === 'ready')
131
+ return;
132
+ const staging = `${target}.staging-${process.pid}-${Date.now()}`;
133
+ fs.rmSync(staging, { recursive: true, force: true });
134
+ fs.mkdirSync(staging, { recursive: true });
135
+ try {
136
+ const space = fs.statfsSync(staging);
137
+ if (space.bavail * space.bsize < 512 * 1024 * 1024)
138
+ throw new Error('Insufficient disk space for server install (512 MiB reserve)');
139
+ const cache = path.join(languageHome(), 'npm-cache');
140
+ fs.mkdirSync(cache, { recursive: true });
141
+ const result = await run('npm', [
142
+ 'install', '--prefix', staging, '--cache', cache, '--no-audit', '--no-fund', '--ignore-scripts', '--registry', 'https://registry.npmjs.org',
143
+ ...recipe.packages,
144
+ ], signal);
145
+ if (result.code !== 0) {
146
+ fs.rmSync(staging, { recursive: true, force: true });
147
+ throw new Error(`npm 導入に失敗: ${result.stderr.trim().split('\n').slice(-3).join(' ').slice(0, 400)}`);
148
+ }
149
+ let typescript;
150
+ if (['typescript', 'javascript', 'tsx'].includes(language.id)) {
151
+ let selection = 'typescript@latest';
152
+ let recommendationSha256;
153
+ // Missing JS tsserver is the compatibility trigger, not a numeric version gate.
154
+ try {
155
+ verifyTsserver(staging);
156
+ }
157
+ catch {
158
+ if (signal?.aborted)
159
+ throw new Error('TypeScript installation aborted');
160
+ const readme = fs.readFileSync(path.join(staging, 'node_modules/typescript-language-server/README.md'), 'utf8');
161
+ const recommended = recommendedTypescript(readme);
162
+ if (!recommended)
163
+ throw new Error('Missing tsserver API and no unambiguous official compatibility recommendation');
164
+ selection = recommended;
165
+ recommendationSha256 = createHash('sha256').update(readme).digest('hex');
166
+ const fallback = await run('npm', ['install', '--prefix', staging, '--cache', cache, '--no-audit', '--no-fund', '--ignore-scripts', '--registry', 'https://registry.npmjs.org', recommended], signal);
167
+ if (fallback.code !== 0)
168
+ throw new Error(`TypeScript compatibility install failed: ${fallback.stderr.slice(-400)}`);
169
+ verifyTsserver(staging);
170
+ }
171
+ typescript = { ...await probeTypescript(staging, signal), selection, recommendationSha256 };
172
+ }
173
+ // Only publish a prefix that actually contains the expected entry point.
174
+ if (!isExecutable(path.join(staging, 'node_modules', '.bin', recipe.entry))) {
175
+ fs.rmSync(staging, { recursive: true, force: true });
176
+ throw new Error(`導入後に ${recipe.entry} が見つかりません`);
177
+ }
178
+ await initializeProbe(language, path.join(staging, 'node_modules', '.bin', recipe.entry), [...(language.lsp?.args ?? [])], staging, signal);
179
+ fs.rmSync(target, { recursive: true, force: true });
180
+ fs.renameSync(staging, target);
181
+ const binary = path.join(target, 'node_modules', '.bin', recipe.entry);
182
+ const manifest = path.join(target, 'node_modules', recipe.packages[0].replace(/@[^@/]+$/, ''), 'package.json');
183
+ const lockfile = path.join(target, 'package-lock.json');
184
+ fs.writeFileSync(path.join(target, 'install-receipt.json'), JSON.stringify({
185
+ typescript, platform: hostPlatform(), packages: recipe.packages, packageName: recipe.packages[0].replace(/@[^@/]+$/, ''), binary: recipe.entry,
186
+ lockfileSha256: fs.existsSync(lockfile) ? digestOf(lockfile) : null,
187
+ binarySha256: digestOf(binary), initialized: true, finishedAt: new Date().toISOString(),
188
+ }, null, 2));
189
+ const state = readState();
190
+ state.servers[language.id] = {
191
+ command: binary,
192
+ args: [...(language.lsp?.args ?? [])],
193
+ digest: fs.existsSync(manifest) ? digestOf(manifest) : digestOf(binary),
194
+ version: fs.existsSync(manifest) ? versionOf(manifest) : 'unknown',
195
+ installedAt: new Date().toISOString(),
196
+ };
197
+ delete state.failures?.[language.id];
198
+ writeState(state);
199
+ }
200
+ finally {
201
+ fs.rmSync(staging, { recursive: true, force: true });
202
+ }
203
+ });
204
+ }
205
+ /**
206
+ * Find a server without installing: explicit setting, then MODKH-managed prefix, then host PATH.
207
+ * Installation is a separate step so a plain read never blocks on a network download.
208
+ */
209
+ export function resolveServer(language, options) {
210
+ if (options.disabled)
211
+ return { status: 'disabled', detail: `${language.id} は設定で無効` };
212
+ if (options.server)
213
+ return { status: 'ready', command: options.server.command, args: [...(options.server.args ?? language.lsp?.args ?? [])] };
214
+ const state = readState();
215
+ const managed = state.servers[language.id];
216
+ if (managed && isExecutable(managed.command) && (language.id !== 'commonlisp' || reusableCommonLisp(managed.command, managed.digest)))
217
+ return { status: 'ready', command: managed.command, args: managed.args, installed: true };
218
+ const recipe = language.install;
219
+ if (recipe?.kind === 'host') {
220
+ for (const candidate of recipe.candidates) {
221
+ if (candidate.includes('/') ? isExecutable(candidate) : isOnPath(candidate)) {
222
+ return { status: 'ready', command: candidate, args: [...(language.lsp?.args ?? [])], installed: true };
223
+ }
224
+ }
225
+ return { status: 'missing', detail: recipe.requirement ?? 'サーバーが見つかりません' };
226
+ }
227
+ return { status: 'missing' };
228
+ }
229
+ function isOnPath(binary) {
230
+ const pathValue = process.env['PATH'] ?? '';
231
+ return pathValue.split(path.delimiter).some(directory => directory.length > 0 && isExecutable(path.join(directory, binary)));
232
+ }
233
+ /** Idempotent: a verified install is reused, and a failed install is reported without retrying. */
234
+ export async function ensureInstalled(language, options) {
235
+ if (!hostPlatform())
236
+ return { status: 'unavailable', detail: `Unsupported OS/CPU: ${process.platform}/${process.arch}` };
237
+ const existing = resolveServer(language, options);
238
+ if (existing.status === 'ready')
239
+ return { status: 'ready' };
240
+ if (existing.status === 'disabled')
241
+ return { status: 'unavailable', detail: existing.detail };
242
+ if (language.install?.kind === 'host' && !['php', 'commonlisp'].includes(language.id)) {
243
+ return { status: 'unavailable', detail: `${language.install.requirement ?? 'サーバーがありません'}(自動取得は行いません)` };
244
+ }
245
+ if (!options.autoInstall)
246
+ return { status: 'unavailable', detail: '自動導入は無効です' };
247
+ const remembered = readState().failures?.[language.id];
248
+ if (remembered && (language.id !== 'commonlisp' || remembered.recipe === CL_LSP_REPOSITORY) && (remembered.retryable === false || Date.now() - Date.parse(remembered.at) < 60000))
249
+ return { status: 'unavailable', detail: `前回の導入失敗: ${remembered.reason}` };
250
+ try {
251
+ if (language.id === 'php' || language.id === 'commonlisp') {
252
+ const target = serverRoot(language);
253
+ await withLock(target, async () => {
254
+ if (resolveServer(language, {}).status === 'ready')
255
+ return;
256
+ const prior = readState().failures?.[language.id];
257
+ if (prior && (language.id !== 'commonlisp' || prior.recipe === CL_LSP_REPOSITORY) && (prior.retryable === false || Date.now() - Date.parse(prior.at) < 60000))
258
+ throw new Error(`Previous install failed: ${prior.reason}`);
259
+ const result = await (language.id === 'php' ? installPhpantom : installCommonLisp)(target, options.signal);
260
+ const state = readState();
261
+ state.servers[language.id] = { command: result.command, args: [], version: result.version, digest: result.digest, installedAt: new Date().toISOString() };
262
+ delete state.failures?.[language.id];
263
+ writeState(state);
264
+ });
265
+ }
266
+ else
267
+ await installNpm(language, options.signal);
268
+ return { status: 'ready' };
269
+ }
270
+ catch (e) {
271
+ const reason = e instanceof Error ? e.message : String(e);
272
+ // Remembering the failure is best effort: an unwritable home must not escape as a crash.
273
+ try {
274
+ const state = readState();
275
+ state.failures = { ...(state.failures ?? {}), [language.id]: { ...(language.id === 'commonlisp' ? { recipe: CL_LSP_REPOSITORY } : {}), reason: reason.slice(0, 500), at: new Date().toISOString(), retryable: !/ENOSPC|Insufficient disk|unknown/.test(reason) } };
276
+ writeState(state);
277
+ }
278
+ catch { /* the caller still receives the original reason below */ }
279
+ return { status: 'error', detail: reason };
280
+ }
281
+ }
282
+ /** Explicit retry clears the remembered failure and re-resolves the recipe. */
283
+ export function clearFailure(id) {
284
+ const state = readState();
285
+ if (!state.failures?.[id])
286
+ return;
287
+ delete state.failures[id];
288
+ writeState(state);
289
+ }
290
+ export function statusReport() {
291
+ const state = readState();
292
+ return Object.entries(state.servers).map(([id, server]) => ({ id, version: server.version, command: server.command, installedAt: server.installedAt }));
293
+ }