@askdkc/dsh-lsp-server 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.
Files changed (58) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +27 -0
  4. package/cordis.patch.yml +29 -0
  5. package/docs/usage.md +94 -0
  6. package/lib/cli/doctor.js +135 -0
  7. package/lib/cli/doctor.js.map +1 -0
  8. package/lib/completion-B7NPVCEN.js +79 -0
  9. package/lib/completion-B7NPVCEN.js.map +1 -0
  10. package/lib/errors-DtyWAUi0.js +16 -0
  11. package/lib/errors-DtyWAUi0.js.map +1 -0
  12. package/lib/extra-tool.js +113 -0
  13. package/lib/extra-tool.js.map +1 -0
  14. package/lib/launch-ByUvgkVv.js +308 -0
  15. package/lib/launch-ByUvgkVv.js.map +1 -0
  16. package/lib/provider.js +1164 -0
  17. package/lib/provider.js.map +1 -0
  18. package/lib/types/cli/availability.d.ts +3 -0
  19. package/lib/types/cli/doctor.d.ts +33 -0
  20. package/lib/types/config.d.ts +87 -0
  21. package/lib/types/errors.d.ts +7 -0
  22. package/lib/types/extra-tool.d.ts +13 -0
  23. package/lib/types/host/dsh.d.ts +10 -0
  24. package/lib/types/host/source.d.ts +8 -0
  25. package/lib/types/host/uri.d.ts +2 -0
  26. package/lib/types/host/workspace.d.ts +16 -0
  27. package/lib/types/merge/completion.d.ts +6 -0
  28. package/lib/types/merge/diagnostics.d.ts +6 -0
  29. package/lib/types/merge/hover.d.ts +5 -0
  30. package/lib/types/protocol/capabilities.d.ts +3 -0
  31. package/lib/types/protocol/initialize.d.ts +3 -0
  32. package/lib/types/protocol/normalize-completion.d.ts +3 -0
  33. package/lib/types/protocol/normalize-diagnostic.d.ts +3 -0
  34. package/lib/types/protocol/normalize-hover.d.ts +6 -0
  35. package/lib/types/protocol/normalize-location.d.ts +7 -0
  36. package/lib/types/protocol/types.d.ts +57 -0
  37. package/lib/types/provider.d.ts +35 -0
  38. package/lib/types/routing/classifier.d.ts +8 -0
  39. package/lib/types/routing/language-id.d.ts +5 -0
  40. package/lib/types/routing/route-table.d.ts +13 -0
  41. package/lib/types/routing/tailwind-candidate.d.ts +1 -0
  42. package/lib/types/runtime/cancellation.d.ts +4 -0
  43. package/lib/types/runtime/connection.d.ts +22 -0
  44. package/lib/types/runtime/framing.d.ts +14 -0
  45. package/lib/types/runtime/process-lifecycle.d.ts +21 -0
  46. package/lib/types/runtime/server-pool.d.ts +24 -0
  47. package/lib/types/runtime/server-session.d.ts +32 -0
  48. package/lib/types/runtime/webstack-runtime.d.ts +28 -0
  49. package/lib/types/servers/html.d.ts +2 -0
  50. package/lib/types/servers/launch.d.ts +5 -0
  51. package/lib/types/servers/package-bin.d.ts +2 -0
  52. package/lib/types/servers/phpantom.d.ts +2 -0
  53. package/lib/types/servers/svelte.d.ts +2 -0
  54. package/lib/types/servers/tailwind.d.ts +2 -0
  55. package/lib/types/servers/types.d.ts +26 -0
  56. package/lib/types/servers/typescript.d.ts +2 -0
  57. package/lib/types/service.d.ts +83 -0
  58. package/package.json +138 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ - Connect the provider and extra tool to actual DSH services, schemas, session workspaces, and plugin disposal.
6
+ - Implement real navigation, diagnostics, completion, document synchronization, configuration replies, timeouts, and bounded process cleanup.
7
+ - Add CSS routing, Tailwind candidate ranking, executable availability checks, and working packaged CLI/declarations.
8
+ - Replace skipped placeholders with real DSH and language-server tests, including isolated packed-artifact loading.
9
+
10
+ ## 0.1.0-alpha.1
11
+
12
+ - Added bounded JSON-RPC framing, cancellation, retries, workspace containment, and server lifecycle management.
13
+ - Added deterministic multi-language routing, Blade precedence, normalized locations/hover/diagnostics/completions, and provenance-preserving merges.
14
+ - Added the read-only `lsp_extra` service surface and doctor diagnostics.
15
+ - Added focused protocol, security, lifecycle, routing, merge, and provider tests.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 askdkc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @askdkc/dsh-lsp-server
2
+
3
+ An LSP plugin for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), providing code navigation, diagnostics, and completion without applying edits.
4
+
5
+ Supports PHP/Blade via **PHPantom**, TypeScript/JavaScript, Svelte, HTML, CSS, and Tailwind.
6
+
7
+ ## Install
8
+
9
+ Requires Node.js **22.18+**. For PHP/Blade, install **PHPantom** with `phpantom_lsp` in `PATH`. The other language servers are included.
10
+
11
+ From npm:
12
+
13
+ ```sh
14
+ pnpm dsh plugin --profile web add @askdkc/dsh-lsp-server
15
+ ```
16
+
17
+ Or from GitHub:
18
+
19
+ ```sh
20
+ pnpm dsh plugin --profile web add github:askdkc/dsh-lsp-server
21
+ ```
22
+
23
+ [Configuration, tool usage, and troubleshooting](docs/usage.md)
24
+
25
+ ## License
26
+
27
+ [MIT](LICENSE)
@@ -0,0 +1,29 @@
1
+ - insert:
2
+ - id: lsp
3
+ name: '@deepseek-ai/dsh-lsp'
4
+
5
+ - id: lsp-webstack-provider
6
+ name: '@askdkc/dsh-lsp-server/provider'
7
+ config:
8
+ missingServerPolicy: warn
9
+ servers:
10
+ phpantom:
11
+ enabled: true
12
+ mode: path
13
+ command: phpantom_lsp
14
+ args: ['--stdio']
15
+
16
+ - id: tool-lsp
17
+ name: '@deepseek-ai/dsh-tool-lsp'
18
+ config:
19
+ maxLocations: 200
20
+ maxResultChars: 32000
21
+ timeoutMs: 60000
22
+
23
+ - id: tool-lsp-extra
24
+ name: '@askdkc/dsh-lsp-server/extra-tool'
25
+ config:
26
+ maxDiagnostics: 200
27
+ maxCompletions: 100
28
+ maxResultChars: 32000
29
+ timeoutMs: 60000
package/docs/usage.md ADDED
@@ -0,0 +1,94 @@
1
+ # Usage and configuration
2
+
3
+ [Back to README](../README.md)
4
+
5
+ A composite language-server plugin for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness). It provides precise code navigation through DSH's standard `lsp` tool and diagnostics/completion through `lsp_extra`.
6
+
7
+ | Files | Primary server | Additional support |
8
+ |---|---|---|
9
+ | PHP, Blade | PHPantom (external executable) | Tailwind for Blade |
10
+ | TypeScript, JavaScript, JSX, TSX | TypeScript Language Server | Tailwind |
11
+ | Svelte | Svelte Language Server | Tailwind |
12
+ | HTML | VS Code HTML Language Server | Tailwind |
13
+ | CSS, PCSS | VS Code CSS Language Server | Tailwind |
14
+
15
+ The five Node language servers and TypeScript are package dependencies. PHPantom must be installed separately as `phpantom_lsp`, or configured with an explicit executable path. Disabling PHPantom does not disable the other languages.
16
+
17
+ ## Install
18
+
19
+ See the [installation commands](../README.md#install).
20
+
21
+ The bundle adds `lsp`, `lsp-webstack-provider`, `tool-lsp`, and `tool-lsp-extra` rows. It requires DSH's LSP/tool packages and the profile's `fs`, `subprocess`, `tools`, and `systemPrompt` services. DSH packages are host-provided peers; installing this package alone does not install the harness. If you already enabled another LSP provider for these extensions, remove its overlapping mappings first: DSH intentionally rejects duplicate ownership with `LSP_CONFLICT`. If your profile already declares the `lsp` or `tool-lsp` rows, compose the provider and extra-tool rows manually instead of inserting the whole bundle twice.
22
+
23
+ These instructions follow [DSH's profile composition](https://github.com/deepseek-ai/deepseek-harness/blob/d347e703908d0406b7a7ef80e3a0e594d86b2215/apps/cli/README.md). No user profile is changed by this repository's tests or doctor command.
24
+
25
+ ## Tools
26
+
27
+ DSH's standard `lsp` tool supports `goToDefinition`, `findReferences`, `goToImplementation`, and `hover`, where the selected language server supports that operation. References include declarations.
28
+
29
+ Additional tool calls:
30
+
31
+ ```json
32
+ {"operation":"status"}
33
+ {"operation":"diagnostics","file_path":"src/app.ts","severity":"error"}
34
+ {"operation":"completion","file_path":"src/app.ts","line":12,"character":8}
35
+ ```
36
+
37
+ Both tools obtain the workspace from the **calling session**. Completion's line and character are **one-based UTF-16**; diagnostic/output ranges are **zero-based UTF-16**. The model cannot supply a different workspace root. The underlying service API uses zero-based positions.
38
+
39
+ Hover and completion can include Tailwind results. Completion ranks the typed prefix before truncating large catalogs. Diagnostics report omitted auxiliary servers; no publication before the deadline is a failure, not a clean-file result. Unsupported navigation returns `LSP_UNSUPPORTED_OPERATION`.
40
+
41
+ ## Configuration
42
+
43
+ Override the existing provider row in your profile's `cordis.patch.yml`, using DSH's row-id patch syntax:
44
+
45
+ ```yaml
46
+ - id: lsp-webstack-provider
47
+ config:
48
+ missingServerPolicy: warn
49
+ servers:
50
+ phpantom:
51
+ enabled: true
52
+ mode: path
53
+ command: phpantom_lsp
54
+ args: ['--stdio']
55
+ typescript:
56
+ mode: bundled
57
+ tailwind:
58
+ enabled: true
59
+ queryStrategy: candidate
60
+ ```
61
+
62
+ `missingServerPolicy: warn` lets available languages work when another executable is missing; status/doctor report availability, and a query to a missing primary server fails. `error` rejects plugin startup if an enabled executable is unavailable. A failed auxiliary hover/completion does not discard a successful primary result.
63
+
64
+ Each server accepts `enabled`, `mode` (`bundled` or `path`), `command`, `args`, `env`, `initializationOptions`, and `configuration`. In `path` mode, `command` is required except for PHPantom. `env` is passed through DSH's subprocess service and layered onto its scrubbed environment. `workspace/configuration` resolves requested sections from `configuration`.
65
+
66
+ Other options include `providerId`, `limits.maxDocumentBytes`, `limits.maxMessageBytes`, `limits.maxStderrBytes`, operation-specific `timeouts`, `routing.bladeSuffixes`, and Tailwind `classAttributes`, `classRegex`, `includeLanguages`, and `queryStrategy` (`candidate` or `always`). See [configuration defaults](../src/config.ts) for defaults. Tool row `tool-lsp-extra` accepts `maxDiagnostics`, `maxCompletions`, `maxResultChars`, and `timeoutMs`.
67
+
68
+ Bundled mode resolves executables on the Node host and is intended for local DSH filesystem/subprocess backends. Remote backends require `path` mode with executables and dependencies installed in that execution environment; remote operation is not covered by this test suite.
69
+
70
+ ## Doctor
71
+
72
+ ```sh
73
+ node lib/cli/doctor.js --json
74
+ node lib/cli/doctor.js --config ./webstack-config.json --deep
75
+ ```
76
+
77
+ The JSON config file contains the provider configuration object above. Doctor checks package binaries and PATH availability without launching servers, and exits nonzero when an enabled server is missing. `--deep` adds an explicit read-only inspection summary; it is **not** a protocol handshake or a check of the running DSH profile. Runtime status is available through `lsp_extra`.
78
+
79
+ ## Verification
80
+
81
+ Source installs build automatically through `prepare`; npm releases include the built files. `.npmrc` prevents automatic resolution of the published DSH packages’ incomplete peer tree during development and Git builds.
82
+
83
+ ```sh
84
+ pnpm install --frozen-lockfile
85
+ pnpm check # types, deterministic/DSH integration tests, build, packed-artifact smoke test
86
+ pnpm test:e2e # real TS/JS, HTML, CSS, Svelte, Tailwind v3/v4
87
+ PHPANTOM_E2E=1 pnpm test:e2e # additionally tests installed PHPantom with PHP and Blade
88
+ ```
89
+
90
+ The packed-artifact test extracts the archive into an isolated consumer, supplies DSH peers, imports its public exports, and runs a real TypeScript query. It also checks declaration paths and the executable doctor. E2E needs working OS file watchers; sandboxed macOS watchers may fail with `EMFILE`.
91
+
92
+ Integration tests run against the published DSH `0.0.1-rc.1` service/tool packages and Cordis 4.0.2. Contracts were also compared with upstream commit `d347e703908d0406b7a7ef80e3a0e594d86b2215` (`0.1.3-alpha.1`). The full Web UI and a source-built upstream application are not exercised here.
93
+
94
+ The provider reads current documents through `ctx.fs`, confines sources to the canonical workspace, and starts/cleans up processes through `ctx.subprocess`. It refuses `workspace/applyEdit` and never applies completion edits. Language servers themselves may read project dependencies, evaluate framework configuration, and write caches; this plugin is not an OS sandbox.
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+ import "../errors-DtyWAUi0.js";
3
+ import { SERVER_IDS, createUnavailableService, resolveConfig, resolveLaunch } from "../launch-ByUvgkVv.js";
4
+ import { basename, delimiter, isAbsolute, join } from "node:path";
5
+ import { access, readFile } from "node:fs/promises";
6
+ import { pathToFileURL } from "node:url";
7
+ import { constants, realpathSync } from "node:fs";
8
+
9
+ //#region src/cli/availability.ts
10
+ function localStatusService(config) {
11
+ return {
12
+ ...createUnavailableService(config.providerId),
13
+ async status() {
14
+ return {
15
+ providerId: config.providerId,
16
+ servers: await Promise.all(SERVER_IDS.map(async (id) => {
17
+ const server = config.servers[id];
18
+ let available = false;
19
+ try {
20
+ const spec = await resolveLaunch(id, config, process.cwd());
21
+ const candidates = isAbsolute(spec.command) ? [spec.command] : (server.env.PATH ?? process.env.PATH ?? "").split(delimiter).filter(Boolean).map((dir) => join(dir, spec.command));
22
+ for (const path of candidates) try {
23
+ await access(path, constants.X_OK);
24
+ available = true;
25
+ break;
26
+ } catch {}
27
+ if (available && server.mode === "bundled") await access(spec.args[0], constants.R_OK);
28
+ } catch {
29
+ available = false;
30
+ }
31
+ return {
32
+ id,
33
+ enabled: server.enabled && (id !== "tailwind" || config.tailwind.enabled),
34
+ available,
35
+ source: server.mode,
36
+ liveWorkspaces: 0,
37
+ restarts: 0
38
+ };
39
+ }))
40
+ };
41
+ }
42
+ };
43
+ }
44
+
45
+ //#endregion
46
+ //#region src/cli/doctor.ts
47
+ async function collectDoctorReport(service, options = {}) {
48
+ const snapshot = await service.status();
49
+ const servers = snapshot.servers.map((server) => ({
50
+ id: server.id,
51
+ enabled: server.enabled,
52
+ available: server.available,
53
+ source: server.source,
54
+ ...server.command ? { command: redactCommand(server.command) } : {},
55
+ ...server.version ? { version: server.version } : {},
56
+ liveWorkspaces: server.liveWorkspaces,
57
+ restarts: server.restarts
58
+ }));
59
+ const issues = [];
60
+ snapshot.servers.forEach((server) => {
61
+ if (server.enabled && !server.available) issues.push({
62
+ code: "server_unavailable",
63
+ severity: "error",
64
+ message: `${server.id} is enabled but unavailable`
65
+ });
66
+ if (server.lastError) issues.push({
67
+ code: "server_error",
68
+ severity: "warning",
69
+ message: `${server.id}: ${redactMessage(server.lastError)}`
70
+ });
71
+ });
72
+ if (servers.length === 0) issues.push({
73
+ code: "no_servers",
74
+ severity: "error",
75
+ message: "no language servers are configured or available"
76
+ });
77
+ const report = {
78
+ providerId: snapshot.providerId,
79
+ ok: issues.every((issue) => issue.severity !== "error"),
80
+ servers,
81
+ issues
82
+ };
83
+ if (options.deep) report.deep = {
84
+ checked: true,
85
+ readOnly: true,
86
+ notes: ["configuration snapshot inspected", "no files, processes, or text edits were changed"]
87
+ };
88
+ return report;
89
+ }
90
+ async function runDoctor(service, options = {}) {
91
+ const report = await collectDoctorReport(service, options);
92
+ if (options.json) return JSON.stringify(report, null, 2);
93
+ const lines = [`${report.providerId}: ${report.ok ? "ok" : "attention required"}`];
94
+ for (const server of report.servers) lines.push(`- ${server.id}: ${server.enabled ? server.available ? "available" : "missing" : "disabled"}${server.version ? ` (${server.version})` : ""}`);
95
+ for (const issue of report.issues) lines.push(`${issue.severity === "error" ? "ERROR" : "WARN"}: ${issue.message}`);
96
+ if (report.deep) lines.push(...report.deep.notes.map((note) => `- ${note}`));
97
+ return lines.join("\n");
98
+ }
99
+ function redactCommand(command) {
100
+ const clean = command.replace(/\\/g, "/");
101
+ return clean.includes("/") ? basename(clean) : clean;
102
+ }
103
+ function redactMessage(message) {
104
+ return message.replace(/(?:[A-Za-z]:)?(?:\\|\/)[^\s'"`]+/g, "<path>").replace(/(token|password|secret|key)=\S+/gi, "$1=<redacted>");
105
+ }
106
+ async function main() {
107
+ const args = new Set(process.argv.slice(2));
108
+ const configIndex = process.argv.indexOf("--config");
109
+ const configPath = configIndex >= 0 ? process.argv[configIndex + 1] : void 0;
110
+ if (configIndex >= 0 && (!configPath || configPath.startsWith("--"))) throw new Error("--config requires a JSON file path");
111
+ const service = localStatusService(resolveConfig(configPath ? JSON.parse(await readFile(configPath, "utf8")) : {}));
112
+ const options = {
113
+ json: args.has("--json"),
114
+ deep: args.has("--deep")
115
+ };
116
+ const report = await collectDoctorReport(service, options);
117
+ const output = options.json ? JSON.stringify(report, null, 2) : await runDoctor(service, options);
118
+ process.stdout.write(`${output}\n`);
119
+ process.exitCode = report.ok ? 0 : 1;
120
+ }
121
+ function isMain() {
122
+ try {
123
+ return !!process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href;
124
+ } catch {
125
+ return false;
126
+ }
127
+ }
128
+ if (isMain()) main().catch((error) => {
129
+ process.stderr.write(`${error instanceof Error ? error.message : "doctor failed"}\n`);
130
+ process.exitCode = 1;
131
+ });
132
+
133
+ //#endregion
134
+ export { collectDoctorReport, runDoctor };
135
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","names":["issues: DoctorIssue[]","report: DoctorReport"],"sources":["../../src/cli/availability.ts","../../src/cli/doctor.ts"],"sourcesContent":["import { access } from 'node:fs/promises'\nimport { constants } from 'node:fs'\nimport { delimiter, isAbsolute, join } from 'node:path'\nimport { SERVER_IDS, type ResolvedConfig } from '../config.js'\nimport { resolveLaunch } from '../servers/launch.js'\nimport type { WebstackLspService } from '../service.js'\nimport { createUnavailableService } from '../service.js'\n\nexport function localStatusService(config: ResolvedConfig): WebstackLspService {\n return {\n ...createUnavailableService(config.providerId),\n async status() {\n return { providerId: config.providerId, servers: await Promise.all(SERVER_IDS.map(async id => {\n const server = config.servers[id]\n let available = false\n try {\n const spec = await resolveLaunch(id, config, process.cwd())\n const candidates = isAbsolute(spec.command) ? [spec.command] : (server.env.PATH ?? process.env.PATH ?? '').split(delimiter).filter(Boolean).map(dir => join(dir, spec.command))\n for (const path of candidates) { try { await access(path, constants.X_OK); available = true; break } catch {} }\n // Package manifests can survive an incomplete installation without their executable.\n if (available && server.mode === 'bundled') await access(spec.args[0]!, constants.R_OK)\n } catch { available = false }\n return { id, enabled: server.enabled && (id !== 'tailwind' || config.tailwind.enabled), available, source: server.mode, liveWorkspaces: 0, restarts: 0 }\n })) }\n },\n }\n}\n","#!/usr/bin/env node\nimport { basename } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport type { WebstackLspService } from '../service.js'\nimport { resolveConfig } from '../config.js'\nimport { localStatusService } from './availability.js'\nimport { readFile } from 'node:fs/promises'\nimport { realpathSync } from 'node:fs'\n\nexport interface DoctorOptions { json?: boolean; deep?: boolean }\nexport interface DoctorIssue { code: string; severity: 'warning' | 'error'; message: string }\nexport interface DoctorReport { providerId: string; ok: boolean; servers: Array<{ id: string; enabled: boolean; available: boolean; source: string; command?: string; version?: string; liveWorkspaces: number; restarts: number }>; issues: DoctorIssue[]; deep?: { checked: boolean; readOnly: true; notes: string[] } }\n\nexport async function collectDoctorReport(service: WebstackLspService, options: DoctorOptions = {}): Promise<DoctorReport> {\n const snapshot = await service.status()\n const servers = snapshot.servers.map((server) => ({\n id: server.id,\n enabled: server.enabled,\n available: server.available,\n source: server.source,\n ...(server.command ? { command: redactCommand(server.command) } : {}),\n ...(server.version ? { version: server.version } : {}),\n liveWorkspaces: server.liveWorkspaces,\n restarts: server.restarts,\n }))\n const issues: DoctorIssue[] = []\n snapshot.servers.forEach((server) => {\n if (server.enabled && !server.available) issues.push({ code: 'server_unavailable', severity: 'error', message: `${server.id} is enabled but unavailable` })\n if (server.lastError) issues.push({ code: 'server_error', severity: 'warning', message: `${server.id}: ${redactMessage(server.lastError)}` })\n })\n if (servers.length === 0) issues.push({ code: 'no_servers', severity: 'error', message: 'no language servers are configured or available' })\n const report: DoctorReport = { providerId: snapshot.providerId, ok: issues.every((issue) => issue.severity !== 'error'), servers, issues }\n if (options.deep) report.deep = { checked: true, readOnly: true, notes: ['configuration snapshot inspected', 'no files, processes, or text edits were changed'] }\n return report\n}\n\nexport async function runDoctor(service: WebstackLspService, options: DoctorOptions = {}): Promise<string> {\n const report = await collectDoctorReport(service, options)\n if (options.json) return JSON.stringify(report, null, 2)\n const lines = [`${report.providerId}: ${report.ok ? 'ok' : 'attention required'}`]\n for (const server of report.servers) lines.push(`- ${server.id}: ${server.enabled ? (server.available ? 'available' : 'missing') : 'disabled'}${server.version ? ` (${server.version})` : ''}`)\n for (const issue of report.issues) lines.push(`${issue.severity === 'error' ? 'ERROR' : 'WARN'}: ${issue.message}`)\n if (report.deep) lines.push(...report.deep.notes.map((note) => `- ${note}`))\n return lines.join('\\n')\n}\n\nfunction redactCommand(command: string): string {\n const clean = command.replace(/\\\\/g, '/')\n return clean.includes('/') ? basename(clean) : clean\n}\nfunction redactMessage(message: string): string {\n return message.replace(/(?:[A-Za-z]:)?(?:\\\\|\\/)[^\\s'\"`]+/g, '<path>').replace(/(token|password|secret|key)=\\S+/gi, '$1=<redacted>')\n}\n\nasync function main(): Promise<void> {\n const args = new Set(process.argv.slice(2))\n const configIndex = process.argv.indexOf('--config')\n const configPath = configIndex >= 0 ? process.argv[configIndex + 1] : undefined\n if (configIndex >= 0 && (!configPath || configPath.startsWith('--'))) throw new Error('--config requires a JSON file path')\n const service = localStatusService(resolveConfig(configPath ? JSON.parse(await readFile(configPath, 'utf8')) : {}))\n const options = { json: args.has('--json'), deep: args.has('--deep') }\n const report = await collectDoctorReport(service, options)\n const output = options.json ? JSON.stringify(report, null, 2) : await runDoctor(service, options)\n process.stdout.write(`${output}\\n`)\n process.exitCode = report.ok ? 0 : 1\n}\n\nfunction isMain(): boolean {\n try { return !!process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href } catch { return false }\n}\n\nif (isMain()) void main().catch(error => { process.stderr.write(`${error instanceof Error ? error.message : 'doctor failed'}\\n`); process.exitCode = 1 })\n"],"mappings":";;;;;;;;;AAQA,SAAgB,mBAAmB,QAA4C;AAC7E,QAAO;EACL,GAAG,yBAAyB,OAAO,WAAW;EAC9C,MAAM,SAAS;AACb,UAAO;IAAE,YAAY,OAAO;IAAY,SAAS,MAAM,QAAQ,IAAI,WAAW,IAAI,OAAM,OAAM;KAC5F,MAAM,SAAS,OAAO,QAAQ;KAC9B,IAAI,YAAY;AAChB,SAAI;MACF,MAAM,OAAO,MAAM,cAAc,IAAI,QAAQ,QAAQ,KAAK,CAAC;MAC3D,MAAM,aAAa,WAAW,KAAK,QAAQ,GAAG,CAAC,KAAK,QAAQ,IAAI,OAAO,IAAI,QAAQ,QAAQ,IAAI,QAAQ,IAAI,MAAM,UAAU,CAAC,OAAO,QAAQ,CAAC,KAAI,QAAO,KAAK,KAAK,KAAK,QAAQ,CAAC;AAC/K,WAAK,MAAM,QAAQ,WAAc,KAAI;AAAE,aAAM,OAAO,MAAM,UAAU,KAAK;AAAE,mBAAY;AAAM;cAAc;AAE3G,UAAI,aAAa,OAAO,SAAS,UAAW,OAAM,OAAO,KAAK,KAAK,IAAK,UAAU,KAAK;aACjF;AAAE,kBAAY;;AACtB,YAAO;MAAE;MAAI,SAAS,OAAO,YAAY,OAAO,cAAc,OAAO,SAAS;MAAU;MAAW,QAAQ,OAAO;MAAM,gBAAgB;MAAG,UAAU;MAAG;MACxJ,CAAC;IAAE;;EAER;;;;;ACZH,eAAsB,oBAAoB,SAA6B,UAAyB,EAAE,EAAyB;CACzH,MAAM,WAAW,MAAM,QAAQ,QAAQ;CACvC,MAAM,UAAU,SAAS,QAAQ,KAAK,YAAY;EAChD,IAAI,OAAO;EACX,SAAS,OAAO;EAChB,WAAW,OAAO;EAClB,QAAQ,OAA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,GAAG,CAAC,CAAC;SAAa;AAAE,SAAO;;;AAG3H,IAAI,QAAQ,CAAE,CAAK,MAAM,CAAC,OAAM,UAAS;AAAE,SAAQ,OAAO,MAAM,GAAG,iBAAiB,QAAQ,MAAM,UAAU,gBAAgB,IAAI;AAAE,SAAQ,WAAW;EAAI"}
@@ -0,0 +1,79 @@
1
+ //#region src/merge/diagnostics.ts
2
+ function mergeDiagnostics(groups, limits) {
3
+ const byKey = /* @__PURE__ */ new Map();
4
+ for (const group of groups) for (const item of group) {
5
+ const key = `${item.uri}|${item.range.start.line}:${item.range.start.character}-${item.range.end.line}:${item.range.end.character}|${item.message}|${item.code ?? ""}`;
6
+ const existing = byKey.get(key);
7
+ if (existing) {
8
+ if (!existing.servers.includes(item.server)) existing.servers.push(item.server);
9
+ } else byKey.set(key, {
10
+ ...item,
11
+ servers: [item.server]
12
+ });
13
+ }
14
+ const sorted = [...byKey.values()].sort(compareDiagnostics);
15
+ const diagnostics = [];
16
+ let characters = 0;
17
+ let omitted = 0;
18
+ let omittedCharacters = 0;
19
+ for (const item of sorted) {
20
+ const size = JSON.stringify(item).length;
21
+ if (diagnostics.length >= limits.maxDiagnostics || characters + size > limits.maxResultChars) {
22
+ omitted += 1;
23
+ omittedCharacters += size;
24
+ continue;
25
+ }
26
+ characters += size;
27
+ const { servers,...publicItem } = item;
28
+ diagnostics.push(servers.length === 1 ? publicItem : {
29
+ ...publicItem,
30
+ servers
31
+ });
32
+ }
33
+ return omitted === 0 ? { diagnostics } : {
34
+ diagnostics,
35
+ truncated: {
36
+ diagnostics: omitted,
37
+ characters: omittedCharacters
38
+ }
39
+ };
40
+ }
41
+ function compareDiagnostics(left, right) {
42
+ const severity = (left.severity ?? 4) - (right.severity ?? 4);
43
+ if (severity) return severity;
44
+ return left.uri.localeCompare(right.uri) || left.range.start.line - right.range.start.line || left.range.start.character - right.range.start.character || left.message.localeCompare(right.message);
45
+ }
46
+
47
+ //#endregion
48
+ //#region src/merge/completion.ts
49
+ function mergeCompletions(groups, limits) {
50
+ const seen = /* @__PURE__ */ new Set();
51
+ const items = [];
52
+ let characters = 0;
53
+ let omitted = 0;
54
+ let omittedCharacters = 0;
55
+ for (const group of groups) for (const item of group) {
56
+ const key = `${item.label}|${item.insertText ?? ""}|${item.detail ?? ""}`;
57
+ if (seen.has(key)) continue;
58
+ seen.add(key);
59
+ const size = JSON.stringify(item).length;
60
+ if (items.length >= limits.maxCompletions || characters + size > limits.maxResultChars) {
61
+ omitted += 1;
62
+ omittedCharacters += size;
63
+ continue;
64
+ }
65
+ characters += size;
66
+ items.push({ ...item });
67
+ }
68
+ return omitted === 0 ? { items } : {
69
+ items,
70
+ truncated: {
71
+ items: omitted,
72
+ characters: omittedCharacters
73
+ }
74
+ };
75
+ }
76
+
77
+ //#endregion
78
+ export { mergeCompletions, mergeDiagnostics };
79
+ //# sourceMappingURL=completion-B7NPVCEN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion-B7NPVCEN.js","names":["diagnostics: NormalizedDiagnostic[]","items: NormalizedCompletionItem[]"],"sources":["../src/merge/diagnostics.ts","../src/merge/completion.ts"],"sourcesContent":["import type { DiagnosticsResult, NormalizedDiagnostic } from '../service.js'\n\nexport interface DiagnosticMergeLimits { maxDiagnostics: number; maxResultChars: number }\n\nexport function mergeDiagnostics(groups: ReadonlyArray<ReadonlyArray<NormalizedDiagnostic>>, limits: DiagnosticMergeLimits): DiagnosticsResult {\n const byKey = new Map<string, NormalizedDiagnostic & { servers: string[] }>()\n for (const group of groups) for (const item of group) {\n const key = `${item.uri}|${item.range.start.line}:${item.range.start.character}-${item.range.end.line}:${item.range.end.character}|${item.message}|${item.code ?? ''}`\n const existing = byKey.get(key)\n if (existing) { if (!existing.servers.includes(item.server)) existing.servers.push(item.server) }\n else byKey.set(key, { ...item, servers: [item.server] })\n }\n const sorted = [...byKey.values()].sort(compareDiagnostics)\n const diagnostics: NormalizedDiagnostic[] = []\n let characters = 0\n let omitted = 0\n let omittedCharacters = 0\n for (const item of sorted) {\n const size = JSON.stringify(item).length\n if (diagnostics.length >= limits.maxDiagnostics || characters + size > limits.maxResultChars) { omitted += 1; omittedCharacters += size; continue }\n characters += size\n const { servers, ...publicItem } = item\n diagnostics.push(servers.length === 1 ? publicItem : { ...publicItem, servers })\n }\n return omitted === 0 ? { diagnostics } : { diagnostics, truncated: { diagnostics: omitted, characters: omittedCharacters } }\n}\n\nfunction compareDiagnostics(left: NormalizedDiagnostic, right: NormalizedDiagnostic): number {\n const severity = (left.severity ?? 4) - (right.severity ?? 4)\n if (severity) return severity\n return left.uri.localeCompare(right.uri) || left.range.start.line - right.range.start.line || left.range.start.character - right.range.start.character || left.message.localeCompare(right.message)\n}\n","import type { CompletionResult, NormalizedCompletionItem } from '../service.js'\n\nexport interface CompletionMergeLimits { maxCompletions: number; maxResultChars: number }\n\nexport function mergeCompletions(groups: ReadonlyArray<ReadonlyArray<NormalizedCompletionItem>>, limits: CompletionMergeLimits): CompletionResult {\n const seen = new Set<string>()\n const items: NormalizedCompletionItem[] = []\n let characters = 0\n let omitted = 0\n let omittedCharacters = 0\n for (const group of groups) for (const item of group) {\n const key = `${item.label}|${item.insertText ?? ''}|${item.detail ?? ''}`\n if (seen.has(key)) continue\n seen.add(key)\n const size = JSON.stringify(item).length\n if (items.length >= limits.maxCompletions || characters + size > limits.maxResultChars) { omitted += 1; omittedCharacters += size; continue }\n characters += size\n items.push({ ...item })\n }\n return omitted === 0 ? { items } : { items, truncated: { items: omitted, characters: omittedCharacters } }\n}\n"],"mappings":";AAIA,SAAgB,iBAAiB,QAA4D,QAAkD;CAC7I,MAAM,wBAAQ,IAAI,KAA2D;AAC7E,MAAK,MAAM,SAAS,OAAQ,MAAK,MAAM,QAAQ,OAAO;EACpD,MAAM,MAAM,GAAG,KAAK,IAAI,GAAG,KAAK,MAAM,MAAM,KAAK,GAAG,KAAK,MAAM,MAAM,UAAU,GAAG,KAAK,MAAM,IAAI,KAAK,GAAG,KAAK,MAAM,IAAI,UAAU,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U;CACd,IAAI,oBAAoB;AACxB,MAAK,MAAM,SAAS,OAAQ,MAAK,MAAM,QAAQ,OAAO;EACpD,MAAM,MAAM,GAAG,KAAK,MAAM,GAAG,KAAK,cAAc,GAAG,GAAG,KAAK,UAAU;AACrE,MAAI,KAAK,IAAI,IAAI,CAAE;AACnB,OAAK,IAAI,IAAI;EACb,MAAM,OAAO,KAAK,UAAU,KAAK,CAAC;AAClC,MAAI,MAAM,UAAU,OAAO,kBAAkB,aAAa,OAAO,OAAO,gBAAgB;AAAE,cAAW;AAAG,wBAAqB;AAAM;;AACnI,gBAAc;AACd,QAAM,KAAK,EAAE,GAAG,MAAM,CAAC;;AAEzB,QAAO,YAAY,IAAI,EAAE,OAAO,GAAG;EAAE;EAAO,WAAW;GAAE,OAAO;GAAS,YAAY;GAAmB;EAAE"}
@@ -0,0 +1,16 @@
1
+ import { LspError } from "@deepseek-ai/dsh-lsp";
2
+
3
+ //#region src/errors.ts
4
+ var WebstackLspError = class extends LspError {
5
+ constructor(code, message, options) {
6
+ super(message, code, options);
7
+ this.name = "WebstackLspError";
8
+ }
9
+ };
10
+ function configError(message) {
11
+ return new WebstackLspError("LSP_WEBSTACK_CONFIG_INVALID", message);
12
+ }
13
+
14
+ //#endregion
15
+ export { WebstackLspError, configError };
16
+ //# sourceMappingURL=errors-DtyWAUi0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-DtyWAUi0.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { LspError } from '@deepseek-ai/dsh-lsp'\n\nexport type WebstackErrorCode =\n | 'LSP_UNAVAILABLE'\n | 'LSP_UNSUPPORTED_OPERATION'\n | 'LSP_DISPOSED'\n | 'LSP_MALFORMED_RESPONSE'\n | 'LSP_CONFLICT'\n | 'LSP_WORKSPACE_REQUIRED'\n | 'LSP_WEBSTACK_CONFIG_INVALID'\n\nexport class WebstackLspError extends LspError {\n declare readonly code: WebstackErrorCode\n\n constructor(code: WebstackErrorCode, message: string, options?: ErrorOptions) {\n super(message, code, options)\n this.name = 'WebstackLspError'\n }\n}\n\nexport function configError(message: string): WebstackLspError {\n return new WebstackLspError('LSP_WEBSTACK_CONFIG_INVALID', message)\n}\n"],"mappings":";;;AAWA,IAAa,mBAAb,cAAsC,SAAS;CAG7C,YAAY,MAAyB,SAAiB,SAAwB;AAC5E,QAAM,SAAS,MAAM,QAAQ;AAC7B,OAAK,OAAO;;;AAIhB,SAAgB,YAAY,SAAmC;AAC7D,QAAO,IAAI,iBAAiB,+BAA+B,QAAQ"}
@@ -0,0 +1,113 @@
1
+ import { WebstackLspError } from "./errors-DtyWAUi0.js";
2
+ import { mergeCompletions, mergeDiagnostics } from "./completion-B7NPVCEN.js";
3
+ import { defineTool } from "@deepseek-ai/dsh-tools";
4
+
5
+ //#region src/extra-tool.ts
6
+ const name = "lsp_extra";
7
+ const inject = [
8
+ "tools",
9
+ "systemPrompt",
10
+ "webstackLsp"
11
+ ];
12
+ function createExtraTool(service, config = {}) {
13
+ const limits = {
14
+ maxDiagnostics: 200,
15
+ maxCompletions: 100,
16
+ maxResultChars: 32e3,
17
+ timeoutMs: 6e4,
18
+ ...config
19
+ };
20
+ for (const [key, value] of Object.entries(limits)) if (!Number.isSafeInteger(value) || value < 1 || value > 2147483647) throw new TypeError(`${key} must be a positive integer no greater than 2147483647`);
21
+ return defineTool({
22
+ name,
23
+ description: "Read language-server status, diagnostics, or completion candidates. file_path is workspace-relative. Completion line and character are one-based UTF-16. No edits are applied.",
24
+ parameters: {
25
+ operation: {
26
+ type: "string",
27
+ enum: [
28
+ "status",
29
+ "diagnostics",
30
+ "completion"
31
+ ],
32
+ required: true
33
+ },
34
+ file_path: { type: "string" },
35
+ line: { type: "integer" },
36
+ character: { type: "integer" },
37
+ severity: {
38
+ type: "string",
39
+ enum: [
40
+ "all",
41
+ "error",
42
+ "warning"
43
+ ]
44
+ },
45
+ servers: {
46
+ type: "array",
47
+ items: { type: "string" }
48
+ }
49
+ },
50
+ output: {
51
+ schema: { type: "json" },
52
+ render: (_args, value) => {
53
+ const text = JSON.stringify(value);
54
+ return [{
55
+ type: "text",
56
+ text: text.length <= limits.maxResultChars ? text : `${text.slice(0, Math.max(0, limits.maxResultChars - 14))}\n[truncated]`.slice(0, limits.maxResultChars)
57
+ }];
58
+ }
59
+ },
60
+ timeoutMs: limits.timeoutMs,
61
+ async execute(args, exec) {
62
+ const signal = AbortSignal.any([exec.signal, AbortSignal.timeout(limits.timeoutMs)]);
63
+ signal.throwIfAborted();
64
+ let result;
65
+ if (args.operation === "status") result = await service.status();
66
+ else {
67
+ const workspaceRoot = exec.agent?.session.header.cwd;
68
+ if (!workspaceRoot) throw new WebstackLspError("LSP_WORKSPACE_REQUIRED", "lsp_extra requires a session workspace cwd");
69
+ if (!args.file_path) throw new TypeError("file_path is required");
70
+ if (args.operation === "diagnostics") {
71
+ const diagnostics = await service.diagnostics({
72
+ workspaceRoot,
73
+ filePath: args.file_path,
74
+ ...args.severity ? { severity: args.severity } : {},
75
+ ...args.servers ? { servers: args.servers } : {}
76
+ }, signal);
77
+ result = {
78
+ ...diagnostics,
79
+ ...mergeDiagnostics([diagnostics.diagnostics], limits)
80
+ };
81
+ } else {
82
+ if (!args.line || args.line < 1 || !args.character || args.character < 1) throw new TypeError("completion requires positive one-based line and character");
83
+ const completion = await service.completion({
84
+ workspaceRoot,
85
+ filePath: args.file_path,
86
+ position: {
87
+ line: args.line - 1,
88
+ character: args.character - 1
89
+ }
90
+ }, signal);
91
+ result = {
92
+ ...completion,
93
+ ...mergeCompletions([completion.items], limits)
94
+ };
95
+ }
96
+ }
97
+ return JSON.parse(JSON.stringify(result));
98
+ }
99
+ });
100
+ }
101
+ function apply(ctx, config = {}) {
102
+ const tool = createExtraTool(ctx.webstackLsp, config);
103
+ ctx.tools.register(tool);
104
+ ctx.systemPrompt.section({
105
+ name: "tool:lsp_extra",
106
+ order: 500,
107
+ text: "Use lsp_extra diagnostics after edits to inspect static errors. Use completion for exact symbol or framework candidates. Completion cursors are one-based UTF-16; output ranges are zero-based. The tool never applies edits."
108
+ });
109
+ }
110
+
111
+ //#endregion
112
+ export { apply, createExtraTool, inject, name };
113
+ //# sourceMappingURL=extra-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extra-tool.js","names":["result: unknown"],"sources":["../src/extra-tool.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis'\nimport { defineTool } from '@deepseek-ai/dsh-tools'\nimport type { ToolDefinition } from '@deepseek-ai/dsh-tools'\nimport type {} from '@deepseek-ai/dsh-system-prompt'\nimport type {} from './provider.js'\nimport type { WebstackLspService } from './service.js'\nimport { WebstackLspError } from './errors.js'\nimport { mergeDiagnostics } from './merge/diagnostics.js'\nimport { mergeCompletions } from './merge/completion.js'\n\nexport const name = 'lsp_extra'\nexport const inject = ['tools', 'systemPrompt', 'webstackLsp']\nexport interface Config { maxDiagnostics?: number; maxCompletions?: number; maxResultChars?: number; timeoutMs?: number }\n\nexport function createExtraTool(service: WebstackLspService, config: Config = {}): ToolDefinition {\n const limits = { maxDiagnostics: 200, maxCompletions: 100, maxResultChars: 32000, timeoutMs: 60000, ...config }\n for (const [key, value] of Object.entries(limits)) if (!Number.isSafeInteger(value) || value < 1 || value > 2147483647) throw new TypeError(`${key} must be a positive integer no greater than 2147483647`)\n return defineTool({\n name,\n description: 'Read language-server status, diagnostics, or completion candidates. file_path is workspace-relative. Completion line and character are one-based UTF-16. No edits are applied.',\n parameters: {\n operation: { type: 'string', enum: ['status', 'diagnostics', 'completion'], required: true },\n file_path: { type: 'string' }, line: { type: 'integer' }, character: { type: 'integer' },\n severity: { type: 'string', enum: ['all', 'error', 'warning'] },\n servers: { type: 'array', items: { type: 'string' } },\n },\n output: {\n schema: { type: 'json' },\n render: (_args, value) => {\n const text = JSON.stringify(value)\n return [{ type: 'text', text: text.length <= limits.maxResultChars ? text : `${text.slice(0, Math.max(0, limits.maxResultChars - 14))}\\n[truncated]`.slice(0, limits.maxResultChars) }]\n },\n },\n timeoutMs: limits.timeoutMs,\n async execute(args, exec) {\n const signal = AbortSignal.any([exec.signal, AbortSignal.timeout(limits.timeoutMs)])\n signal.throwIfAborted()\n let result: unknown\n if (args.operation === 'status') result = await service.status()\n else {\n const workspaceRoot = exec.agent?.session.header.cwd\n if (!workspaceRoot) throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'lsp_extra requires a session workspace cwd')\n if (!args.file_path) throw new TypeError('file_path is required')\n if (args.operation === 'diagnostics') {\n const diagnostics = await service.diagnostics({ workspaceRoot, filePath: args.file_path, ...(args.severity ? { severity: args.severity } : {}), ...(args.servers ? { servers: args.servers } : {}) }, signal)\n result = { ...diagnostics, ...mergeDiagnostics([diagnostics.diagnostics], limits) }\n } else {\n if (!args.line || args.line < 1 || !args.character || args.character < 1) throw new TypeError('completion requires positive one-based line and character')\n const completion = await service.completion({ workspaceRoot, filePath: args.file_path, position: { line: args.line - 1, character: args.character - 1 } }, signal)\n result = { ...completion, ...mergeCompletions([completion.items], limits) }\n }\n }\n // Strip undefined optionals and expose a lossless JSON result to DSH's schema validator.\n return JSON.parse(JSON.stringify(result))\n },\n })\n}\n\nexport function apply(ctx: Context, config: Config = {}): void {\n const tool = createExtraTool(ctx.webstackLsp, config)\n ctx.tools.register(tool)\n ctx.systemPrompt.section({ name: 'tool:lsp_extra', order: 500, text: 'Use lsp_extra diagnostics after edits to inspect static errors. Use completion for exact symbol or framework candidates. Completion cursors are one-based UTF-16; output ranges are zero-based. The tool never applies edits.' })\n}\n"],"mappings":";;;;;AAUA,MAAa,OAAO;AACpB,MAAa,SAAS;CAAC;CAAS;CAAgB;CAAc;AAG9D,SAAgB,gBAAgB,SAA6B,SAAiB,EAAE,EAAkB;CAChG,MAAM,SAAS;EAAE,gBAAgB;EAAK,gBAAgB;EAAK,gBAAgB;EAAO,WAAW;EAAO,GAAG;EAAQ;AAC/G,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAAE,KAAI,CAAC,OAAO,cAAc,MAAM,I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