modkh 0.0.0-stage → 0.1.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.
- package/README.md +24 -2
- package/dist/agent/bundled-skills.d.ts +13 -0
- package/dist/agent/bundled-skills.js +95 -0
- package/dist/agent/images.d.ts +10 -0
- package/dist/agent/images.js +33 -0
- package/dist/agent/loop.d.ts +56 -0
- package/dist/agent/loop.js +155 -0
- package/dist/agent/skills.d.ts +20 -0
- package/dist/agent/skills.js +169 -0
- package/dist/agent/types.d.ts +132 -0
- package/dist/agent/types.js +12 -0
- package/dist/cli/agents.d.ts +8 -0
- package/dist/cli/agents.js +12 -0
- package/dist/cli/approval.d.ts +27 -0
- package/dist/cli/approval.js +62 -0
- package/dist/cli/catalog.d.ts +39 -0
- package/dist/cli/catalog.js +76 -0
- package/dist/cli/chat.d.ts +18 -0
- package/dist/cli/chat.js +733 -0
- package/dist/cli/clipboard.d.ts +9 -0
- package/dist/cli/clipboard.js +54 -0
- package/dist/cli/color.d.ts +42 -0
- package/dist/cli/color.js +176 -0
- package/dist/cli/config.d.ts +41 -0
- package/dist/cli/config.js +188 -0
- package/dist/cli/editor.d.ts +16 -0
- package/dist/cli/editor.js +77 -0
- package/dist/cli/keys.d.ts +18 -0
- package/dist/cli/keys.js +82 -0
- package/dist/cli/language.d.ts +1 -0
- package/dist/cli/language.js +105 -0
- package/dist/cli/limits.d.ts +13 -0
- package/dist/cli/limits.js +19 -0
- package/dist/cli/lines.d.ts +18 -0
- package/dist/cli/lines.js +80 -0
- package/dist/cli/models.d.ts +4 -0
- package/dist/cli/models.js +69 -0
- package/dist/cli/permissions.d.ts +25 -0
- package/dist/cli/permissions.js +30 -0
- package/dist/cli/plugins.d.ts +1 -0
- package/dist/cli/plugins.js +53 -0
- package/dist/cli/providers.d.ts +46 -0
- package/dist/cli/providers.js +76 -0
- package/dist/cli/terminal.d.ts +143 -0
- package/dist/cli/terminal.js +742 -0
- package/dist/cli/usage.d.ts +29 -0
- package/dist/cli/usage.js +75 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +164 -0
- package/dist/language/catalog.d.ts +44 -0
- package/dist/language/catalog.js +100 -0
- package/dist/language/commonlisp-bundled.d.ts +11 -0
- package/dist/language/commonlisp-bundled.js +22 -0
- package/dist/language/commonlisp-dependencies.d.ts +16 -0
- package/dist/language/commonlisp-dependencies.js +68 -0
- package/dist/language/commonlisp-install.d.ts +14 -0
- package/dist/language/commonlisp-install.js +213 -0
- package/dist/language/commonlisp-reader.d.ts +17 -0
- package/dist/language/commonlisp-reader.js +47 -0
- package/dist/language/commonlisp-systems.d.ts +3 -0
- package/dist/language/commonlisp-systems.js +32 -0
- package/dist/language/commonlisp-tls.d.ts +10 -0
- package/dist/language/commonlisp-tls.js +51 -0
- package/dist/language/detect.d.ts +29 -0
- package/dist/language/detect.js +103 -0
- package/dist/language/grammars/LICENSE +24 -0
- package/dist/language/grammars/manifest.json +76 -0
- package/dist/language/grammars/tree-sitter-c.wasm +0 -0
- package/dist/language/grammars/tree-sitter-cpp.wasm +0 -0
- package/dist/language/grammars/tree-sitter-css.wasm +0 -0
- package/dist/language/grammars/tree-sitter-html.wasm +0 -0
- package/dist/language/grammars/tree-sitter-javascript.wasm +0 -0
- package/dist/language/grammars/tree-sitter-php.wasm +0 -0
- package/dist/language/grammars/tree-sitter-python.wasm +0 -0
- package/dist/language/grammars/tree-sitter-ruby.wasm +0 -0
- package/dist/language/grammars/tree-sitter-rust.wasm +0 -0
- package/dist/language/grammars/tree-sitter-swift.wasm +0 -0
- package/dist/language/grammars/tree-sitter-tsx.wasm +0 -0
- package/dist/language/grammars/tree-sitter-typescript.wasm +0 -0
- package/dist/language/install.d.ts +50 -0
- package/dist/language/install.js +293 -0
- package/dist/language/lsp/client.d.ts +97 -0
- package/dist/language/lsp/client.js +337 -0
- package/dist/language/lsp/pool.d.ts +67 -0
- package/dist/language/lsp/pool.js +122 -0
- package/dist/language/lsp/service.d.ts +46 -0
- package/dist/language/lsp/service.js +138 -0
- package/dist/language/native.d.ts +8 -0
- package/dist/language/native.js +100 -0
- package/dist/language/platform.d.ts +14 -0
- package/dist/language/platform.js +20 -0
- package/dist/language/positions.d.ts +20 -0
- package/dist/language/positions.js +46 -0
- package/dist/language/syntax/assets.d.ts +9 -0
- package/dist/language/syntax/assets.js +73 -0
- package/dist/language/syntax/parser.d.ts +24 -0
- package/dist/language/syntax/parser.js +144 -0
- package/dist/language/typescript-capability.d.ts +6 -0
- package/dist/language/typescript-capability.js +42 -0
- package/dist/lisp/config.d.ts +16 -0
- package/dist/lisp/config.js +159 -0
- package/dist/lisp/routing.d.ts +5 -0
- package/dist/lisp/routing.js +24 -0
- package/dist/lisp/runtime.d.ts +21 -0
- package/dist/lisp/runtime.js +83 -0
- package/dist/memory/kiokuko.d.ts +32 -0
- package/dist/memory/kiokuko.js +102 -0
- package/dist/memory/mcp.d.ts +38 -0
- package/dist/memory/mcp.js +211 -0
- package/dist/model/ai-sdk.d.ts +27 -0
- package/dist/model/ai-sdk.js +180 -0
- package/dist/model/chatgpt/login.d.ts +42 -0
- package/dist/model/chatgpt/login.js +180 -0
- package/dist/model/chatgpt/responses.d.ts +41 -0
- package/dist/model/chatgpt/responses.js +202 -0
- package/dist/model/chatgpt/tokens.d.ts +11 -0
- package/dist/model/chatgpt/tokens.js +50 -0
- package/dist/model/connection.d.ts +6 -0
- package/dist/model/connection.js +65 -0
- package/dist/model/context.d.ts +9 -0
- package/dist/model/context.js +69 -0
- package/dist/model/factory.d.ts +25 -0
- package/dist/model/factory.js +88 -0
- package/dist/model/fixed.d.ts +17 -0
- package/dist/model/fixed.js +41 -0
- package/dist/model/reasoning.d.ts +16 -0
- package/dist/model/reasoning.js +62 -0
- package/dist/plugins/api.d.ts +60 -0
- package/dist/plugins/api.js +1 -0
- package/dist/plugins/manager.d.ts +34 -0
- package/dist/plugins/manager.js +261 -0
- package/dist/plugins/package.d.ts +13 -0
- package/dist/plugins/package.js +99 -0
- package/dist/plugins/registry.d.ts +8 -0
- package/dist/plugins/registry.js +14 -0
- package/dist/session/store.d.ts +82 -0
- package/dist/session/store.js +285 -0
- package/dist/session/workspace.d.ts +19 -0
- package/dist/session/workspace.js +73 -0
- package/dist/subagents/processes.d.ts +18 -0
- package/dist/subagents/processes.js +73 -0
- package/dist/subagents/request.d.ts +4 -0
- package/dist/subagents/request.js +21 -0
- package/dist/subagents/service.d.ts +39 -0
- package/dist/subagents/service.js +352 -0
- package/dist/subagents/settings.d.ts +10 -0
- package/dist/subagents/settings.js +32 -0
- package/dist/subagents/types.d.ts +43 -0
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/verification.d.ts +31 -0
- package/dist/subagents/verification.js +178 -0
- package/dist/tools/diff.d.ts +6 -0
- package/dist/tools/diff.js +82 -0
- package/dist/tools/edit.d.ts +3 -0
- package/dist/tools/edit.js +152 -0
- package/dist/tools/files.d.ts +6 -0
- package/dist/tools/files.js +96 -0
- package/dist/tools/formal.d.ts +8 -0
- package/dist/tools/formal.js +77 -0
- package/dist/tools/guard.d.ts +7 -0
- package/dist/tools/guard.js +48 -0
- package/dist/tools/job-tools.d.ts +19 -0
- package/dist/tools/job-tools.js +148 -0
- package/dist/tools/jobs.d.ts +77 -0
- package/dist/tools/jobs.js +181 -0
- package/dist/tools/language.d.ts +6 -0
- package/dist/tools/language.js +174 -0
- package/dist/tools/registry.d.ts +28 -0
- package/dist/tools/registry.js +105 -0
- package/dist/tools/run.d.ts +13 -0
- package/dist/tools/run.js +159 -0
- package/dist/tools/search.d.ts +2 -0
- package/dist/tools/search.js +156 -0
- package/dist/tools/shell-process.d.ts +115 -0
- package/dist/tools/shell-process.js +286 -0
- package/dist/tools/skills.d.ts +2 -0
- package/dist/tools/skills.js +46 -0
- package/dist/tools/web.d.ts +24 -0
- package/dist/tools/web.js +386 -0
- package/docs/ci-repair-20261116.md +30 -0
- package/docs/commonlisp-provider-migration.md +22 -0
- package/docs/commonlisp-qlot-recovery.md +28 -0
- package/docs/commonlisp-tls-recovery.md +28 -0
- package/docs/context-efficiency.md +100 -0
- package/docs/input.md +66 -0
- package/docs/languages.md +117 -0
- package/docs/models.md +85 -0
- package/docs/modkh-evidence.json +641 -0
- package/docs/modkh-failure-comparison.json +675 -0
- package/docs/modkh-namespace.md +39 -0
- package/docs/modkh-qlot-evidence.json +37 -0
- package/docs/modkh-verification.md +173 -0
- package/docs/modkh.md +124 -0
- package/docs/presets.md +19 -0
- package/docs/setup.md +112 -0
- package/docs/subagents.md +134 -0
- package/docs/web.md +57 -0
- package/experiments/presets/common-lisp.lisp +38 -0
- package/experiments/presets/css.lisp +38 -0
- package/experiments/presets/formal.lisp +7 -0
- package/experiments/presets/html.lisp +38 -0
- package/experiments/presets/js.lisp +38 -0
- package/experiments/presets/php.lisp +38 -0
- package/experiments/presets/svelte.lisp +38 -0
- package/experiments/presets/tailwindcss.lisp +24 -0
- package/experiments/presets/ts.lisp +38 -0
- package/package.json +49 -4
- package/plugins/modkh-explorer/index.mjs +3 -0
- package/plugins/modkh-explorer/plugin.json +1 -0
- package/plugins/modkh-worker/index.mjs +3 -0
- package/plugins/modkh-worker/plugin.json +1 -0
- package/skills/kiokuko-dsh/LICENSE +21 -0
- package/skills/kiokuko-dsh/coding-ideal-routine-skill/SKILL.md +106 -0
- package/skills/kiokuko-dsh/japanese-translation-for-oss-models/SKILL.md +65 -0
- package/skills/kiokuko-dsh/kiokuko-architecture/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-architecture/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-benchmark/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-benchmark/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-investigate/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-investigate/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-lisp/SKILL.md +390 -0
- package/skills/kiokuko-dsh/kiokuko-review/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-review/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-simple-work/SKILL.md +70 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/SKILL.md +79 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/boundaries-and-ownership.md +52 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/domain-and-types.md +48 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/effects-and-data.md +43 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/kiokuko-patterns.md +314 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/problem-shaping-and-language.md +90 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/protocols-and-idempotency.md +42 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/review-checklist.md +92 -0
- package/skills/kiokuko-dsh/kiokuko-single-purpose-functions/references/verification.md +45 -0
- package/skills/kiokuko-dsh/kiokuko-skill-authoring/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-skill-authoring/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-soul/SKILL.md +25 -0
- package/skills/kiokuko-dsh/kiokuko-technical-writing/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-technical-writing/references/cases.md +11 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/SKILL.md +64 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/accessibility-and-navigation.md +31 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/async-recovery.md +49 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/forms-and-controls.md +35 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/interaction-feedback.md +34 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/responsive-and-platform.md +38 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/safety-and-review.md +43 -0
- package/skills/kiokuko-dsh/kiokuko-ui-design-soul/references/ui-checklist.md +75 -0
- package/skills/kiokuko-dsh/kiokuko-verification/SKILL.md +20 -0
- package/skills/kiokuko-dsh/kiokuko-verification/references/cases.md +11 -0
- package/skills/kiokuko-dsh/manifest.json +168 -0
- package/skills/kiokuko-dsh/memory-reasoning/SKILL.md +44 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/SKILL.md +113 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/references/boundaries-and-lifecycle.md +70 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/references/discovery-and-scope.md +71 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/references/failure-recovery.md +43 -0
- package/skills/kiokuko-dsh/one-shot-software-completion/references/verification-and-completion.md +73 -0
- package/skills/kiokuko-dsh/veteran-programmer-skill/SKILL.md +66 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { languageForPath } from "../catalog.js";
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
6
|
+
import { createMessageConnection, StreamMessageReader, StreamMessageWriter, } from 'vscode-jsonrpc/node';
|
|
7
|
+
const MAX_DIAGNOSTICS = 200;
|
|
8
|
+
function severityName(value) {
|
|
9
|
+
switch (value) {
|
|
10
|
+
case 1: return 'error';
|
|
11
|
+
case 2: return 'warning';
|
|
12
|
+
case 3: return 'info';
|
|
13
|
+
default: return 'hint';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** One LSP process and connection. Every failure is reported, never silently swallowed. */
|
|
17
|
+
/** Upper bound on waiting for push diagnostics after an edit; a slower server reports waiting. */
|
|
18
|
+
const DIAGNOSTIC_WAIT_MS = 1200;
|
|
19
|
+
export class LspServer {
|
|
20
|
+
id;
|
|
21
|
+
options;
|
|
22
|
+
child;
|
|
23
|
+
connection;
|
|
24
|
+
open = new Map();
|
|
25
|
+
starting;
|
|
26
|
+
disposed = false;
|
|
27
|
+
disposal;
|
|
28
|
+
selectedEncoding = 'utf-16';
|
|
29
|
+
/** Pull-diagnostics support, announced by the server's capabilities rather than a version string. */
|
|
30
|
+
pullDiagnostics = false;
|
|
31
|
+
capabilities = {};
|
|
32
|
+
diagnosticTrace = { pushNotifications: 0, pullRequests: 0, pullReports: 0 };
|
|
33
|
+
get diagnosticEvidence() { return { ...this.diagnosticTrace, pullSupported: this.pullDiagnostics }; }
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.id = options.id;
|
|
36
|
+
this.options = options;
|
|
37
|
+
}
|
|
38
|
+
get running() { return this.child !== undefined && this.connection !== undefined; }
|
|
39
|
+
get documents() { return this.open; }
|
|
40
|
+
async start(signal) {
|
|
41
|
+
if (this.running)
|
|
42
|
+
return;
|
|
43
|
+
if (this.starting)
|
|
44
|
+
return this.starting;
|
|
45
|
+
this.starting = this.launch(signal).finally(() => { this.starting = undefined; });
|
|
46
|
+
return this.starting;
|
|
47
|
+
}
|
|
48
|
+
async launch(signal) {
|
|
49
|
+
if (this.disposed)
|
|
50
|
+
throw new Error('サーバーは終了済みです');
|
|
51
|
+
const child = spawn(this.options.command, [...this.options.args], {
|
|
52
|
+
cwd: this.options.root,
|
|
53
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
54
|
+
detached: process.platform !== 'win32',
|
|
55
|
+
env: { ...(this.options.inheritEnv === false ? {} : process.env), NO_COLOR: '1', ...this.options.env },
|
|
56
|
+
});
|
|
57
|
+
this.child = child;
|
|
58
|
+
const spawnFailure = new Promise((_, reject) => child.once('error', reject));
|
|
59
|
+
let stderr = '';
|
|
60
|
+
child.stderr.on('data', (data) => { stderr = (stderr + data).slice(-4000); });
|
|
61
|
+
// A server may exit while a request is in flight; stream errors are not user-facing failures.
|
|
62
|
+
child.stdin.on('error', () => undefined);
|
|
63
|
+
child.stdout.on('error', () => undefined);
|
|
64
|
+
child.stderr.on('error', () => undefined);
|
|
65
|
+
const connection = createMessageConnection(new StreamMessageReader(child.stdout), new StreamMessageWriter(child.stdin));
|
|
66
|
+
this.connection = connection;
|
|
67
|
+
connection.onNotification('textDocument/publishDiagnostics', (params) => {
|
|
68
|
+
this.diagnosticTrace.pushNotifications++;
|
|
69
|
+
this.acceptPushDiagnostics(params);
|
|
70
|
+
});
|
|
71
|
+
connection.onRequest('client/registerCapability', () => null); // Acknowledgement only; no filesystem watch is claimed.
|
|
72
|
+
connection.onRequest('client/unregisterCapability', () => null);
|
|
73
|
+
connection.onRequest('workspace/configuration', (params) => this.configuration(params));
|
|
74
|
+
// A server asking to edit the workspace is refused: edits go through the approved tool path.
|
|
75
|
+
connection.onRequest('workspace/applyEdit', () => ({ applied: false, failureReason: 'MODKHはサーバー発の編集を適用しません' }));
|
|
76
|
+
connection.onRequest('window/workDoneProgress/create', () => null);
|
|
77
|
+
connection.onNotification('window/logMessage', (value) => {
|
|
78
|
+
const message = value?.message;
|
|
79
|
+
if (typeof message === 'string')
|
|
80
|
+
this.options.log?.(message.slice(0, 2000));
|
|
81
|
+
});
|
|
82
|
+
connection.listen();
|
|
83
|
+
// Track the stop so launch() can await it; an untracked dispose would outlive its caller.
|
|
84
|
+
let stopping;
|
|
85
|
+
const abort = () => { stopping ??= this.dispose(); };
|
|
86
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
87
|
+
try {
|
|
88
|
+
const rootUri = pathToFileURL(this.options.root).href;
|
|
89
|
+
const initialized = await this.withTimeout(Promise.race([spawnFailure, connection.sendRequest('initialize', {
|
|
90
|
+
processId: process.pid,
|
|
91
|
+
clientInfo: { name: 'modkh' },
|
|
92
|
+
rootUri,
|
|
93
|
+
workspaceFolders: [{ uri: rootUri, name: path.basename(this.options.root) }],
|
|
94
|
+
capabilities: {
|
|
95
|
+
textDocument: {
|
|
96
|
+
synchronization: { dynamicRegistration: false },
|
|
97
|
+
publishDiagnostics: { relatedInformation: true, versionSupport: true },
|
|
98
|
+
hover: { contentFormat: ['markdown', 'plaintext'] },
|
|
99
|
+
definition: { linkSupport: false },
|
|
100
|
+
references: {},
|
|
101
|
+
diagnostic: { dynamicRegistration: false },
|
|
102
|
+
},
|
|
103
|
+
workspace: { configuration: true, workspaceFolders: true, applyEdit: false },
|
|
104
|
+
},
|
|
105
|
+
initializationOptions: {},
|
|
106
|
+
})]), 'initialize');
|
|
107
|
+
this.capabilities = initialized.capabilities ?? {};
|
|
108
|
+
const provider = this.capabilities['diagnosticProvider'];
|
|
109
|
+
this.pullDiagnostics = provider !== undefined && provider !== null;
|
|
110
|
+
const encoding = this.capabilities['positionEncoding'];
|
|
111
|
+
this.selectedEncoding = encoding === 'utf-8' || encoding === 'utf-32' ? encoding : 'utf-16';
|
|
112
|
+
await connection.sendNotification('initialized', {});
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
const detail = stderr.trim().split('\n').slice(-3).join(' ');
|
|
116
|
+
await (stopping ?? this.dispose());
|
|
117
|
+
throw new Error(`${this.id} の初期化に失敗: ${e.message}${detail ? ` / ${detail.slice(0, 300)}` : ''}`);
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
signal?.removeEventListener('abort', abort);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
configuration(params) {
|
|
124
|
+
const items = Array.isArray(params?.items) ? params.items : [];
|
|
125
|
+
return items.map(() => ({}));
|
|
126
|
+
}
|
|
127
|
+
/** Servers may use UTF-8 offsets; only the announced encoding is trusted. */
|
|
128
|
+
get encoding() { return this.selectedEncoding; }
|
|
129
|
+
withTimeout(promise, what, ms = this.options.requestTimeoutMs) {
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
const timer = setTimeout(() => reject(new Error(`${what} が ${ms}ms 以内に応答しません`)), ms);
|
|
132
|
+
promise.then(value => { clearTimeout(timer); resolve(value); }, (error) => { clearTimeout(timer); reject(error instanceof Error ? error : new Error(String(error))); });
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
acceptPushDiagnostics(params) {
|
|
136
|
+
const value = params;
|
|
137
|
+
if (typeof value?.uri !== 'string' || !Array.isArray(value.diagnostics))
|
|
138
|
+
return;
|
|
139
|
+
const file = fileURLToPath(value.uri);
|
|
140
|
+
const state = this.open.get(file);
|
|
141
|
+
if (!state)
|
|
142
|
+
return;
|
|
143
|
+
const version = typeof value.version === 'number' ? value.version : undefined;
|
|
144
|
+
// A diagnostic for an older version is not evidence about the current text.
|
|
145
|
+
if (version !== undefined && version !== state.version)
|
|
146
|
+
return;
|
|
147
|
+
state.diagnostics = value.diagnostics.slice(0, MAX_DIAGNOSTICS).map((raw) => {
|
|
148
|
+
const item = raw;
|
|
149
|
+
return {
|
|
150
|
+
path: file,
|
|
151
|
+
line: (item.range?.start?.line ?? 0) + 1,
|
|
152
|
+
column: (item.range?.start?.character ?? 0) + 1,
|
|
153
|
+
endLine: (item.range?.end?.line ?? 0) + 1,
|
|
154
|
+
endColumn: (item.range?.end?.character ?? 0) + 1,
|
|
155
|
+
severity: severityName(item.severity),
|
|
156
|
+
message: typeof item.message === 'string' ? item.message.slice(0, 2000) : '',
|
|
157
|
+
...(typeof item.source === 'string' ? { source: item.source } : {}),
|
|
158
|
+
server: this.id,
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
state.diagnosticVersion = version ?? state.version;
|
|
162
|
+
state.notified = true;
|
|
163
|
+
}
|
|
164
|
+
async openDocument(file, text) {
|
|
165
|
+
const connection = this.requireConnection();
|
|
166
|
+
const existing = this.open.get(file);
|
|
167
|
+
const state = existing ?? { version: 0, text, diagnostics: [], notified: false };
|
|
168
|
+
// Re-analyzing unchanged text must not discard a diagnostic the server already sent.
|
|
169
|
+
if (existing && existing.text === text)
|
|
170
|
+
return state;
|
|
171
|
+
state.version += 1;
|
|
172
|
+
state.text = text;
|
|
173
|
+
state.diagnostics = [];
|
|
174
|
+
state.diagnosticVersion = undefined;
|
|
175
|
+
state.notified = false;
|
|
176
|
+
this.open.set(file, state);
|
|
177
|
+
if (existing) {
|
|
178
|
+
await connection.sendNotification('textDocument/didChange', {
|
|
179
|
+
textDocument: { uri: pathToFileURL(file).href, version: state.version },
|
|
180
|
+
contentChanges: [{ text }],
|
|
181
|
+
});
|
|
182
|
+
return state;
|
|
183
|
+
}
|
|
184
|
+
await connection.sendNotification('textDocument/didOpen', {
|
|
185
|
+
textDocument: { uri: pathToFileURL(file).href, languageId: this.id === 'tailwind' ? (languageForPath(file)?.id === 'tsx' ? 'typescriptreact' : languageForPath(file)?.id ?? 'plaintext') : this.id, version: state.version, text },
|
|
186
|
+
});
|
|
187
|
+
return state;
|
|
188
|
+
}
|
|
189
|
+
/** Waits for a diagnostic result that belongs to the current version, or reports absence. */
|
|
190
|
+
async synchronize(file, text) {
|
|
191
|
+
const before = this.open.get(file)?.text;
|
|
192
|
+
const state = await this.openDocument(file, text);
|
|
193
|
+
// Nothing changed, so the earlier answer is still the answer: polling again only delays the caller.
|
|
194
|
+
if (state.notified && (state.diagnosticVersion === undefined || state.diagnosticVersion >= state.version)) {
|
|
195
|
+
return { status: 'observed', diagnostics: state.diagnostics, version: state.version };
|
|
196
|
+
}
|
|
197
|
+
if (before === text)
|
|
198
|
+
return { status: 'waiting', diagnostics: state.diagnostics, version: state.version };
|
|
199
|
+
if (this.pullDiagnostics) {
|
|
200
|
+
try {
|
|
201
|
+
this.diagnosticTrace.pullRequests++;
|
|
202
|
+
const report = await this.withTimeout(this.requireConnection().sendRequest('textDocument/diagnostic', {
|
|
203
|
+
textDocument: { uri: pathToFileURL(file).href },
|
|
204
|
+
}), '診断');
|
|
205
|
+
// A null report means the server had nothing for this document; keep the push state.
|
|
206
|
+
if (report && Array.isArray(report.items)) {
|
|
207
|
+
this.diagnosticTrace.pullReports++;
|
|
208
|
+
this.acceptPushDiagnostics({ uri: pathToFileURL(file).href, diagnostics: report.items, version: state.version });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch { /* fall through to the push state below */ }
|
|
212
|
+
if (state.notified && (state.diagnosticVersion === undefined || state.diagnosticVersion >= state.version)) {
|
|
213
|
+
return { status: 'observed', diagnostics: state.diagnostics, version: state.version };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Push diagnostics arrive asynchronously. The wait is a user-visible delay on every read and
|
|
217
|
+
// edit, so it stays short: a slower server reports "waiting", which is distinct from a clean
|
|
218
|
+
// zero-diagnostic result and never claims the file is fine.
|
|
219
|
+
const budget = Math.min(this.options.requestTimeoutMs, DIAGNOSTIC_WAIT_MS);
|
|
220
|
+
const deadline = Date.now() + budget;
|
|
221
|
+
while (Date.now() < deadline) {
|
|
222
|
+
await new Promise(resolve => setTimeout(resolve, 15));
|
|
223
|
+
if (state.notified && (state.diagnosticVersion === undefined || state.diagnosticVersion >= state.version))
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
const observed = state.notified && (state.diagnosticVersion === undefined || state.diagnosticVersion >= state.version);
|
|
227
|
+
return { status: observed ? 'observed' : 'waiting', diagnostics: state.diagnostics, version: state.version };
|
|
228
|
+
}
|
|
229
|
+
async hover(file, position) {
|
|
230
|
+
const result = await this.withTimeout(this.requireConnection().sendRequest('textDocument/hover', {
|
|
231
|
+
textDocument: { uri: pathToFileURL(file).href }, position,
|
|
232
|
+
}), 'hover');
|
|
233
|
+
return renderHover(result?.contents);
|
|
234
|
+
}
|
|
235
|
+
async definition(file, position) {
|
|
236
|
+
const result = await this.withTimeout(this.requireConnection().sendRequest('textDocument/definition', {
|
|
237
|
+
textDocument: { uri: pathToFileURL(file).href }, position,
|
|
238
|
+
}), '定義');
|
|
239
|
+
return this.locations(result);
|
|
240
|
+
}
|
|
241
|
+
async references(file, position) {
|
|
242
|
+
const result = await this.withTimeout(this.requireConnection().sendRequest('textDocument/references', {
|
|
243
|
+
textDocument: { uri: pathToFileURL(file).href }, position, context: { includeDeclaration: true },
|
|
244
|
+
}), '参照');
|
|
245
|
+
return this.locations(result, 50);
|
|
246
|
+
}
|
|
247
|
+
locations(result, limit = 20) {
|
|
248
|
+
const items = Array.isArray(result) ? result : result ? [result] : [];
|
|
249
|
+
const out = [];
|
|
250
|
+
for (const item of items.slice(0, limit)) {
|
|
251
|
+
const value = item;
|
|
252
|
+
const uri = value.uri ?? value.targetUri;
|
|
253
|
+
const range = value.range ?? value.targetRange;
|
|
254
|
+
if (typeof uri !== 'string' || !uri.startsWith('file:') || !range?.start)
|
|
255
|
+
continue;
|
|
256
|
+
out.push({ file: fileURLToPath(uri), line: (range.start.line ?? 0) + 1, character: (range.start.character ?? 0) + 1 });
|
|
257
|
+
}
|
|
258
|
+
return out;
|
|
259
|
+
}
|
|
260
|
+
requireConnection() {
|
|
261
|
+
if (!this.connection)
|
|
262
|
+
throw new Error(`${this.id} は起動していません`);
|
|
263
|
+
return this.connection;
|
|
264
|
+
}
|
|
265
|
+
dispose() { return this.disposal ??= this.stop(); }
|
|
266
|
+
async stop() {
|
|
267
|
+
this.disposed = true;
|
|
268
|
+
const connection = this.connection, child = this.child;
|
|
269
|
+
this.connection = undefined;
|
|
270
|
+
this.child = undefined;
|
|
271
|
+
this.open.clear();
|
|
272
|
+
if (connection) {
|
|
273
|
+
// Dispose detaches the reader/writer; without this, later notifications race stream teardown.
|
|
274
|
+
// The writer may still flush a queued message, so its rejection stays observed but ignored.
|
|
275
|
+
try {
|
|
276
|
+
connection.dispose();
|
|
277
|
+
}
|
|
278
|
+
catch { /* already gone */ }
|
|
279
|
+
}
|
|
280
|
+
let cleanupUnknown = false;
|
|
281
|
+
if (child?.pid && process.platform !== 'win32') {
|
|
282
|
+
const pid = child.pid;
|
|
283
|
+
const alive = () => { try {
|
|
284
|
+
process.kill(-pid, 0);
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
return e.code !== 'ESRCH';
|
|
289
|
+
} };
|
|
290
|
+
const stop = (signal) => { try {
|
|
291
|
+
process.kill(-pid, signal);
|
|
292
|
+
}
|
|
293
|
+
catch { /* checked below */ } };
|
|
294
|
+
stop('SIGTERM');
|
|
295
|
+
const started = Date.now();
|
|
296
|
+
while (alive() && Date.now() - started < 3000) {
|
|
297
|
+
if (Date.now() - started >= 1000)
|
|
298
|
+
stop('SIGKILL');
|
|
299
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
300
|
+
}
|
|
301
|
+
cleanupUnknown = alive();
|
|
302
|
+
}
|
|
303
|
+
else if (child?.pid && child.exitCode === null && child.signalCode === null) {
|
|
304
|
+
child.kill('SIGKILL');
|
|
305
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
306
|
+
cleanupUnknown = child.exitCode === null && child.signalCode === null;
|
|
307
|
+
}
|
|
308
|
+
// Pipes are closed only after the process is gone; nothing can write into them afterwards.
|
|
309
|
+
child?.stdin.destroy();
|
|
310
|
+
child?.stdout.destroy();
|
|
311
|
+
child?.stderr.destroy();
|
|
312
|
+
if (cleanupUnknown)
|
|
313
|
+
throw new Error(`${this.id}: process-group cleanup unknown`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function renderHover(contents) {
|
|
317
|
+
if (contents === null || contents === undefined)
|
|
318
|
+
return null;
|
|
319
|
+
if (typeof contents === 'string')
|
|
320
|
+
return contents.slice(0, 4000);
|
|
321
|
+
if (Array.isArray(contents)) {
|
|
322
|
+
return contents.map(part => renderHover(part)).filter(Boolean).join('\n').slice(0, 4000) || null;
|
|
323
|
+
}
|
|
324
|
+
const value = contents;
|
|
325
|
+
return typeof value.value === 'string' ? value.value.slice(0, 4000) : null;
|
|
326
|
+
}
|
|
327
|
+
export function rememberDocumentText(server, file) {
|
|
328
|
+
return server.documents.get(file)?.text;
|
|
329
|
+
}
|
|
330
|
+
export function fileStillExists(file) {
|
|
331
|
+
try {
|
|
332
|
+
return fs.statSync(file).isFile();
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { LspServer, type ServerDiagnostic } from './client.ts';
|
|
2
|
+
import type { LanguageDefinition } from '../catalog.ts';
|
|
3
|
+
export interface PoolKeyParts {
|
|
4
|
+
root: string;
|
|
5
|
+
language: LanguageDefinition;
|
|
6
|
+
/** Digest of the effective server settings, so a changed configuration starts a new server. */
|
|
7
|
+
configDigest: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function poolKey(parts: PoolKeyParts): string;
|
|
10
|
+
export declare function serverKey(root: string, id: string, configDigest: string): string;
|
|
11
|
+
export interface StartedServer {
|
|
12
|
+
server: LspServer;
|
|
13
|
+
reused: boolean;
|
|
14
|
+
/** true when the configured language is not running and cannot start right now. */
|
|
15
|
+
status: 'ready' | 'starting' | 'unavailable';
|
|
16
|
+
detail?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PoolOptions {
|
|
19
|
+
/** Maximum number of concurrently running servers. */
|
|
20
|
+
maxRunning?: number;
|
|
21
|
+
/** Milliseconds a server may stay idle before it is stopped. */
|
|
22
|
+
idleTimeoutMs?: number;
|
|
23
|
+
requestTimeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Servers are keyed by (real root, language, config digest). A child Stop affects only the
|
|
27
|
+
* caller's request through its own timeout/signal; the shared server keeps running for others.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ServerPool {
|
|
30
|
+
private readonly entries;
|
|
31
|
+
private readonly options;
|
|
32
|
+
/** Stops started by capacity eviction; they are awaited by settled()/disposeAll(). */
|
|
33
|
+
private readonly pending;
|
|
34
|
+
private disposal?;
|
|
35
|
+
private readonly cleanupFailures;
|
|
36
|
+
constructor(options?: PoolOptions);
|
|
37
|
+
get size(): number;
|
|
38
|
+
acquire(parts: PoolKeyParts, launch: {
|
|
39
|
+
command: string;
|
|
40
|
+
args: string[];
|
|
41
|
+
}, signal?: AbortSignal): Promise<StartedServer>;
|
|
42
|
+
find(root: string, id: string, configDigest: string): LspServer | undefined;
|
|
43
|
+
private releaseOldestIdle;
|
|
44
|
+
/** Resolves once every detached stop has completed; used before a caller reports closure. */
|
|
45
|
+
settled(): Promise<void>;
|
|
46
|
+
/** Stop servers that nobody used recently; called opportunistically between requests. */
|
|
47
|
+
releaseIdle(now?: number): Promise<void>;
|
|
48
|
+
disposeAll(): Promise<void>;
|
|
49
|
+
private stopAll;
|
|
50
|
+
}
|
|
51
|
+
export declare function realRoot(root: string): string;
|
|
52
|
+
/** Aggregate per-server outcomes without hiding partial failure. */
|
|
53
|
+
export interface Aggregate {
|
|
54
|
+
diagnostics: ServerDiagnostic[];
|
|
55
|
+
servers: {
|
|
56
|
+
id: string;
|
|
57
|
+
status: 'observed' | 'waiting' | 'unsupported' | 'error';
|
|
58
|
+
detail?: string;
|
|
59
|
+
count: number;
|
|
60
|
+
}[];
|
|
61
|
+
}
|
|
62
|
+
export declare function aggregate(results: {
|
|
63
|
+
id: string;
|
|
64
|
+
status: Aggregate['servers'][number]['status'];
|
|
65
|
+
detail?: string;
|
|
66
|
+
diagnostics?: ServerDiagnostic[];
|
|
67
|
+
}[]): Aggregate;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { LspServer } from "./client.js";
|
|
4
|
+
export function poolKey(parts) {
|
|
5
|
+
return serverKey(parts.root, parts.language.id, parts.configDigest);
|
|
6
|
+
}
|
|
7
|
+
export function serverKey(root, id, configDigest) {
|
|
8
|
+
return `${root}::${id}::${configDigest}`;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Servers are keyed by (real root, language, config digest). A child Stop affects only the
|
|
12
|
+
* caller's request through its own timeout/signal; the shared server keeps running for others.
|
|
13
|
+
*/
|
|
14
|
+
export class ServerPool {
|
|
15
|
+
entries = new Map();
|
|
16
|
+
options;
|
|
17
|
+
/** Stops started by capacity eviction; they are awaited by settled()/disposeAll(). */
|
|
18
|
+
pending = new Set();
|
|
19
|
+
disposal;
|
|
20
|
+
cleanupFailures = [];
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
this.options = {
|
|
23
|
+
maxRunning: options.maxRunning ?? 3,
|
|
24
|
+
idleTimeoutMs: options.idleTimeoutMs ?? 60_000,
|
|
25
|
+
requestTimeoutMs: options.requestTimeoutMs ?? 20_000,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
get size() { return this.entries.size; }
|
|
29
|
+
async acquire(parts, launch, signal) {
|
|
30
|
+
const key = poolKey(parts);
|
|
31
|
+
const existing = this.entries.get(key);
|
|
32
|
+
if (existing) {
|
|
33
|
+
existing.lastUsed = Date.now();
|
|
34
|
+
if (existing.server.running)
|
|
35
|
+
return { server: existing.server, reused: true, status: 'ready' };
|
|
36
|
+
this.entries.delete(key);
|
|
37
|
+
}
|
|
38
|
+
if (this.entries.size >= this.options.maxRunning)
|
|
39
|
+
this.releaseOldestIdle();
|
|
40
|
+
if (this.entries.size >= this.options.maxRunning) {
|
|
41
|
+
// Never start a fourth server: an explicit unavailable result is better than thrashing.
|
|
42
|
+
return { server: new LspServer({ id: parts.language.id, command: launch.command, args: launch.args, root: parts.root, requestTimeoutMs: this.options.requestTimeoutMs }), reused: false, status: 'unavailable', detail: `同時起動数が上限(${this.options.maxRunning})です` };
|
|
43
|
+
}
|
|
44
|
+
const server = new LspServer({
|
|
45
|
+
id: parts.language.id,
|
|
46
|
+
command: launch.command,
|
|
47
|
+
args: launch.args,
|
|
48
|
+
root: parts.root,
|
|
49
|
+
requestTimeoutMs: this.options.requestTimeoutMs,
|
|
50
|
+
});
|
|
51
|
+
this.entries.set(key, { server, key, root: parts.root, id: parts.language.id, lastUsed: Date.now() });
|
|
52
|
+
try {
|
|
53
|
+
await server.start(signal);
|
|
54
|
+
return { server, reused: false, status: 'ready' };
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
this.entries.delete(key);
|
|
58
|
+
await server.dispose();
|
|
59
|
+
return { server, reused: false, status: 'unavailable', detail: e instanceof Error ? e.message : String(e) };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
find(root, id, configDigest) {
|
|
63
|
+
const entry = this.entries.get(serverKey(realRoot(root), id, configDigest));
|
|
64
|
+
return entry?.server.running ? entry.server : undefined;
|
|
65
|
+
}
|
|
66
|
+
releaseOldestIdle() {
|
|
67
|
+
let oldest;
|
|
68
|
+
for (const entry of this.entries.values()) {
|
|
69
|
+
if (!oldest || entry.lastUsed < oldest.lastUsed)
|
|
70
|
+
oldest = entry;
|
|
71
|
+
}
|
|
72
|
+
if (!oldest)
|
|
73
|
+
return;
|
|
74
|
+
this.entries.delete(oldest.key);
|
|
75
|
+
// Stopping is awaited later: an untracked dispose lets protocol writes outlive the caller.
|
|
76
|
+
this.pending.add(oldest.server.dispose().catch(error => { this.cleanupFailures.push(error); }));
|
|
77
|
+
}
|
|
78
|
+
/** Resolves once every detached stop has completed; used before a caller reports closure. */
|
|
79
|
+
async settled() {
|
|
80
|
+
while (this.pending.size > 0) {
|
|
81
|
+
const current = [...this.pending];
|
|
82
|
+
await Promise.all(current);
|
|
83
|
+
for (const entry of current)
|
|
84
|
+
this.pending.delete(entry);
|
|
85
|
+
}
|
|
86
|
+
if (this.cleanupFailures.length)
|
|
87
|
+
throw new AggregateError(this.cleanupFailures, 'LSP cleanup unknown');
|
|
88
|
+
}
|
|
89
|
+
/** Stop servers that nobody used recently; called opportunistically between requests. */
|
|
90
|
+
async releaseIdle(now = Date.now()) {
|
|
91
|
+
for (const [key, entry] of [...this.entries]) {
|
|
92
|
+
if (now - entry.lastUsed < this.options.idleTimeoutMs)
|
|
93
|
+
continue;
|
|
94
|
+
this.entries.delete(key);
|
|
95
|
+
await entry.server.dispose();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
disposeAll() { return this.disposal ??= this.stopAll(); }
|
|
99
|
+
async stopAll() {
|
|
100
|
+
const entries = [...this.entries.values()];
|
|
101
|
+
this.entries.clear();
|
|
102
|
+
const results = await Promise.allSettled(entries.map(entry => entry.server.dispose()));
|
|
103
|
+
for (const result of results)
|
|
104
|
+
if (result.status === 'rejected')
|
|
105
|
+
this.cleanupFailures.push(result.reason);
|
|
106
|
+
await this.settled();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function realRoot(root) {
|
|
110
|
+
try {
|
|
111
|
+
return fs.realpathSync(root);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return path.resolve(root);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function aggregate(results) {
|
|
118
|
+
return {
|
|
119
|
+
diagnostics: results.flatMap(result => result.diagnostics ?? []),
|
|
120
|
+
servers: results.map(result => ({ id: result.id, status: result.status, ...(result.detail ? { detail: result.detail } : {}), count: result.diagnostics?.length ?? 0 })),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type LanguageSettings } from '../detect.ts';
|
|
2
|
+
import { ServerPool, type Aggregate } from './pool.ts';
|
|
3
|
+
import type { ServerDiagnostic } from './client.ts';
|
|
4
|
+
export interface LanguageServiceOptions {
|
|
5
|
+
root: string;
|
|
6
|
+
settings: LanguageSettings;
|
|
7
|
+
/** Called for status text; never used to influence correctness. */
|
|
8
|
+
progress?: (message: string) => void;
|
|
9
|
+
pool?: ServerPool;
|
|
10
|
+
}
|
|
11
|
+
export interface AnalyzeResult {
|
|
12
|
+
status: 'ok' | 'partial' | 'unavailable';
|
|
13
|
+
detail?: string;
|
|
14
|
+
diagnostics?: ServerDiagnostic[];
|
|
15
|
+
servers?: Aggregate['servers'];
|
|
16
|
+
language?: string;
|
|
17
|
+
installed?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Owns language detection, installation and semantic analysis for one workspace. Analysis never
|
|
21
|
+
* changes the outcome of an edit: callers keep their own success result and append this report.
|
|
22
|
+
*/
|
|
23
|
+
export declare class LanguageService {
|
|
24
|
+
readonly root: string;
|
|
25
|
+
private readonly settings;
|
|
26
|
+
private readonly progress?;
|
|
27
|
+
private readonly pool;
|
|
28
|
+
/** In-flight work per file prevents duplicate installs/starts in one turn. */
|
|
29
|
+
private readonly inflight;
|
|
30
|
+
private disposed;
|
|
31
|
+
constructor(options: LanguageServiceOptions);
|
|
32
|
+
get poolSize(): number;
|
|
33
|
+
/** The already-running server for a file, if its language/root was analyzed before. */
|
|
34
|
+
poolFor(file: string, selector?: 'tailwind'): import('./client.ts').LspServer | undefined;
|
|
35
|
+
detect(file: string): import("../detect.ts").Detection | undefined;
|
|
36
|
+
/** Analyze a file after a read or a successful write. Never throws. */
|
|
37
|
+
analyze(file: string, text: string, signal?: AbortSignal, selector?: 'tailwind'): Promise<AnalyzeResult>;
|
|
38
|
+
private analyzeGuarded;
|
|
39
|
+
private analyzeOnce;
|
|
40
|
+
close(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export declare function formatDiagnostics(result: AnalyzeResult): string;
|
|
43
|
+
/** Kept for callers that need the resolved workspace root without constructing a service. */
|
|
44
|
+
export declare function workspaceRoot(root: string): string;
|
|
45
|
+
export declare function exists(file: string): boolean;
|
|
46
|
+
export declare function resolveWithin(root: string, file: string): string;
|