@askdkc/dsh-lsp-server 0.1.14 → 0.1.15

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 CHANGED
@@ -6,11 +6,11 @@ Markdown and other unsupported documents return an explicit `skipped` diagnostic
6
6
 
7
7
  ## Read-only code structure
8
8
 
9
- The provider also bundles Tree-sitter WASM grammars for JavaScript, TypeScript, and TSX. Through `lsp_extra`, open a workspace-relative snapshot, use its opaque handle with `structure` (`outline`, `enclosing`, `query`, or bounded `span`) or `semantic` operations, then release the snapshot. Structure and semantic positions use zero-based UTF-16 coordinates; completion keeps its existing one-based coordinates. Only registered query IDs (`declarations`, `calls`, `imports`) are accepted. No edits or arbitrary Tree-sitter queries are exposed.
9
+ The provider also bundles Tree-sitter WASM grammars for JavaScript, TypeScript, TSX, and PHP. Svelte instance and module scripts reuse the JavaScript/TypeScript grammars, with ranges mapped back to the component snapshot. Through `lsp_extra`, open a workspace-relative snapshot, use its opaque handle with `structure` (`outline`, `enclosing`, `query`, or bounded `span`) or `semantic` operations, then release the snapshot. Structure and semantic positions use zero-based UTF-16 coordinates; completion keeps its existing one-based coordinates. Only registered query IDs (`declarations`, `calls`, `imports`) are accepted. No edits or arbitrary Tree-sitter queries are exposed.
10
10
 
11
11
  For example, inspect parser availability, open `src/index.ts` with `operation: "snapshot", action: "open", file_path: "src/index.ts"`, pass the returned handle to `operation: "structure", action: "outline"`, and release it with `operation: "snapshot", action: "release"`. Snapshot documents are capped at 2 MiB; outline/query results, source spans, responses, and evaluation budgets are bounded. Unsupported languages or unavailable semantic servers are reported explicitly rather than treated as empty successful results. Tree-sitter cache entries are bounded and released with their snapshots or worker lifetime.
12
12
 
13
- The bundled structural grammar set is currently limited to JavaScript, TypeScript, and TSX. PHP, Blade, Svelte, HTML, CSS, and Rust structural grammars and mixed-language injections are not included yet; their existing LSP routing does not imply structural-parser support.
13
+ PHP supports `declarations` (named classes, functions, and methods) and the corresponding outline, enclosing, and span operations without PHPantom. Svelte supports the registered JavaScript/TypeScript queries inside top-level `<script>` blocks, including `lang="ts"`, `module`, and `context="module"`; markup and styles are not code declarations. Positions and spans refer to the original component snapshot, not extracted scripts (DSH may normalize line endings and strip a UTF-8 BOM when reading text). Blade, HTML, CSS, and Rust structural grammars are not included; their existing LSP routing does not imply structural-parser support.
14
14
 
15
15
  ## Requirements
16
16
 
@@ -16,7 +16,9 @@ const EXTENSION_LANGUAGE = {
16
16
  ".ts": "typescript",
17
17
  ".mts": "typescript",
18
18
  ".cts": "typescript",
19
- ".tsx": "tsx"
19
+ ".tsx": "tsx",
20
+ ".php": "php",
21
+ ".svelte": "svelte"
20
22
  };
21
23
  var DocumentSnapshotStore = class {
22
24
  records = /* @__PURE__ */ new Map();
@@ -146,6 +148,7 @@ var DocumentSnapshotStore = class {
146
148
  }
147
149
  };
148
150
  function languageForPath(filePath) {
151
+ if (filePath.toLowerCase().endsWith(".blade.php")) return null;
149
152
  const suffix = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
150
153
  return EXTENSION_LANGUAGE[suffix] ?? null;
151
154
  }
@@ -257,6 +260,11 @@ function isBetweenSurrogatePair(text, index) {
257
260
  //#endregion
258
261
  //#region src/structure/queries.ts
259
262
  const declarations = {
263
+ php: [
264
+ "(class_declaration name: (_) @name) @declaration",
265
+ "(function_definition name: (_) @name) @declaration",
266
+ "(method_declaration name: (_) @name) @declaration"
267
+ ],
260
268
  javascript: [
261
269
  "(function_declaration name: (_) @name) @declaration",
262
270
  "(class_declaration name: (_) @name) @declaration",
@@ -507,7 +515,7 @@ var StructureEngine = class {
507
515
  const node = this.node(record, scope, declaration.kind, declaration.startIndex, declaration.endIndex, nameCapture ? record.source.text.slice(nameCapture.startIndex, nameCapture.endIndex).slice(0, 256) : void 0, declaration.childCount, coordinates);
508
516
  declarations$1.push(node);
509
517
  }
510
- return this.outlineResult(record, declarations$1, result);
518
+ return this.outlineResult(record, declarations$1, result, limit);
511
519
  }
512
520
  async enclosing(record, scope, position, kinds, signal) {
513
521
  const language = record.descriptor.language;
@@ -567,7 +575,7 @@ var StructureEngine = class {
567
575
  version: record.descriptor.version,
568
576
  queryId,
569
577
  captures,
570
- truncated: Boolean(result.truncated || (result.matches?.length ?? 0) > limit),
578
+ truncated: Boolean(result.truncated || (result.matches ?? []).reduce((total, match) => total + match.captures.length, 0) > limit),
571
579
  processed: captures.length,
572
580
  errors: publicErrors(result.errors)
573
581
  };
@@ -619,7 +627,9 @@ var StructureEngine = class {
619
627
  ".mts",
620
628
  ".cts"
621
629
  ], 14),
622
- this.capability("tsx", [".tsx"], 14)
630
+ this.capability("tsx", [".tsx"], 14),
631
+ this.capability("php", [".php"], 15),
632
+ this.capability("svelte", [".svelte"], null)
623
633
  ];
624
634
  }
625
635
  async dispose() {
@@ -628,6 +638,22 @@ var StructureEngine = class {
628
638
  await this.workers.dispose();
629
639
  }
630
640
  async runMatches(language, record, queryId, limit, range, signal) {
641
+ if (language === "svelte") {
642
+ const scriptQueries = {
643
+ javascript: getRegisteredQuery("javascript", queryId),
644
+ typescript: getRegisteredQuery("typescript", queryId)
645
+ };
646
+ return this.runWorker(language, {
647
+ operation: "matches",
648
+ language,
649
+ text: record.source.text,
650
+ querySource: "",
651
+ scriptQueries,
652
+ limit,
653
+ snapshotHandle: record.descriptor.handle,
654
+ ...range ?? {}
655
+ }, signal);
656
+ }
631
657
  const querySource = getRegisteredQuery(language, queryId);
632
658
  if (!querySource) throw new WebstackLspError("LSP_STRUCTURE_UNSUPPORTED", `query ${queryId} is not registered for ${language}`);
633
659
  return this.runWorker(language, {
@@ -660,9 +686,9 @@ var StructureEngine = class {
660
686
  throw error;
661
687
  }
662
688
  }
663
- outlineResult(record, declarations$1, result) {
664
- const truncated = Boolean(result.truncated || declarations$1.length > MAX_OUTLINE);
665
- const selected = declarations$1.slice(0, MAX_OUTLINE);
689
+ outlineResult(record, declarations$1, result, limit) {
690
+ const truncated = Boolean(result.truncated || declarations$1.length > limit);
691
+ const selected = declarations$1.slice(0, limit);
666
692
  if (Buffer.byteLength(JSON.stringify(selected), "utf8") > MAX_STRUCTURE_RESPONSE_BYTES) throw new WebstackLspError("LSP_STRUCTURE_LIMIT", "outline result exceeds the response byte limit");
667
693
  return {
668
694
  status: result.status,
@@ -706,11 +732,13 @@ function publicErrors(errors) {
706
732
  function publicNodeKind(kind) {
707
733
  return {
708
734
  function_declaration: "function",
735
+ function_definition: "function",
709
736
  class_declaration: "class",
710
737
  interface_declaration: "interface",
711
738
  type_alias_declaration: "type",
712
739
  enum_declaration: "enum",
713
740
  method_definition: "method",
741
+ method_declaration: "method",
714
742
  variable_declarator: "variable"
715
743
  }[kind] ?? kind;
716
744
  }
@@ -887,4 +915,4 @@ function limitSemanticResult(result, limit) {
887
915
 
888
916
  //#endregion
889
917
  export { DocumentSnapshotStore, createCodeIntelligenceToolServiceV1 };
890
- //# sourceMappingURL=code-intelligence-DvhxPnpu.js.map
918
+ //# sourceMappingURL=code-intelligence-BUs39chK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-intelligence-BUs39chK.js","names":["EXTENSION_LANGUAGE: Record<string, StructureLanguage>","readSource: SnapshotReader","maxDocumentBytes: number","descriptor: SnapshotDescriptor","record: SnapshotRecord","text: string","declarations: Partial<Record<StructureLanguage, string[]>>","imports: Partial<Record<StructureLanguage, string[]>>","calls: Partial<Record<StructureLanguage, string[]>>","task: PendingTask","slot: WorkerSlot","declarations: StructureNode[]","declarations","captures: StructureCapture[]","value: SemanticResult","record: Awaited<ReturnType<DocumentSnapshotStore['current']>>"],"sources":["../src/structure/snapshots.ts","../src/structure/coordinates.ts","../src/structure/queries.ts","../src/structure/worker-pool.ts","../src/structure/engine.ts","../src/structure/code-intelligence.ts"],"sourcesContent":["import { createHash, randomUUID } from 'node:crypto'\nimport { isAbsolute } from 'node:path'\nimport { WebstackLspError } from '../errors.js'\nimport type { HostSource } from '../host/dsh.js'\nimport type { SnapshotDescriptor, SnapshotScope, StructureLanguage } from './types.js'\n\nexport const SNAPSHOT_TTL_MS = 5 * 60_000\nexport const SNAPSHOT_MAX_DOCUMENTS = 32\nexport const SNAPSHOT_MAX_BYTES = 32 * 1024 * 1024\nexport const STRUCTURE_MAX_DOCUMENT_BYTES = 2 * 1024 * 1024\n\nexport interface SnapshotRecord {\n readonly descriptor: SnapshotDescriptor\n readonly scopeKey: string\n readonly source: HostSource\n readonly previousSnapshotHandle?: string\n readonly openedAt: number\n lastUsedAt: number\n}\n\ninterface VersionRecord { hash: string; version: number; scopeKey: string }\n\nexport type SnapshotReader = (workspaceRoot: string, filePath: string, maxBytes: number, signal?: AbortSignal) => Promise<HostSource>\n\nconst EXTENSION_LANGUAGE: Record<string, StructureLanguage> = {\n '.js': 'javascript', '.jsx': 'javascript', '.mjs': 'javascript', '.cjs': 'javascript',\n '.ts': 'typescript', '.mts': 'typescript', '.cts': 'typescript',\n '.tsx': 'tsx',\n '.php': 'php', '.svelte': 'svelte',\n}\n\nexport class DocumentSnapshotStore {\n private readonly records = new Map<string, SnapshotRecord>()\n private readonly versions = new Map<string, VersionRecord>()\n\n constructor(private readonly readSource: SnapshotReader, private readonly maxDocumentBytes: number) {}\n\n async open(scope: SnapshotScope, filePath: string, signal?: AbortSignal): Promise<SnapshotRecord> {\n validateScope(scope)\n const normalizedPath = normalizeRelativePath(filePath)\n signal?.throwIfAborted()\n const first = await this.readSource(scope.workspaceRoot, normalizedPath, Math.min(this.maxDocumentBytes, STRUCTURE_MAX_DOCUMENT_BYTES), signal)\n signal?.throwIfAborted()\n const second = await this.readSource(scope.workspaceRoot, normalizedPath, Math.min(this.maxDocumentBytes, STRUCTURE_MAX_DOCUMENT_BYTES), signal)\n if (hashText(first.text) !== hashText(second.text) || first.uri !== second.uri || first.key !== second.key)\n throw new WebstackLspError('LSP_STALE_SNAPSHOT', 'document changed while opening the snapshot')\n\n const ownerKey = scopeKey(scope)\n const hash = hashText(second.text)\n const fileKey = JSON.stringify([ownerKey, second.key, second.uri])\n const version = this.rememberVersion(fileKey, scope, hash)\n const sourceBytes = Buffer.byteLength(second.text, 'utf8')\n this.evictExpired()\n if (this.records.size >= SNAPSHOT_MAX_DOCUMENTS || this.totalBytes() + sourceBytes > SNAPSHOT_MAX_BYTES)\n throw new WebstackLspError('LSP_SNAPSHOT_LIMIT', 'snapshot capacity is full; release an existing snapshot and retry')\n\n const descriptor: SnapshotDescriptor = {\n handle: randomUUID(), version, filePath: normalizedPath,\n language: languageForPath(normalizedPath), sourceKind: 'disk', contentHash: hash, sourceBytes,\n }\n const previous = [...this.records.values()]\n .filter(item => item.scopeKey === ownerKey && item.source.key === second.key && item.source.uri === second.uri)\n .sort((a, b) => b.openedAt - a.openedAt)[0]\n const record: SnapshotRecord = {\n descriptor, scopeKey: ownerKey, source: second, openedAt: Date.now(), lastUsedAt: Date.now(),\n ...(previous ? { previousSnapshotHandle: previous.descriptor.handle } : {}),\n }\n this.records.set(descriptor.handle, record)\n return record\n }\n\n async current(scope: SnapshotScope, handle: string, signal?: AbortSignal): Promise<SnapshotRecord> {\n validateScope(scope)\n signal?.throwIfAborted()\n const record = this.records.get(handle)\n if (!record || record.scopeKey !== scopeKey(scope)) throw staleSnapshot()\n if (Date.now() - record.openedAt > SNAPSHOT_TTL_MS) {\n this.records.delete(handle)\n throw staleSnapshot()\n }\n const current = await this.readSource(scope.workspaceRoot, record.descriptor.filePath, Math.min(this.maxDocumentBytes, STRUCTURE_MAX_DOCUMENT_BYTES), signal)\n signal?.throwIfAborted()\n if (current.uri !== record.source.uri || current.key !== record.source.key || hashText(current.text) !== record.descriptor.contentHash) {\n this.records.delete(handle)\n throw staleSnapshot()\n }\n record.lastUsedAt = Date.now()\n return record\n }\n\n async readFresh(scope: SnapshotScope, filePath: string, signal?: AbortSignal): Promise<HostSource> {\n validateScope(scope)\n signal?.throwIfAborted()\n const source = await this.readSource(scope.workspaceRoot, filePath, this.maxDocumentBytes, signal)\n signal?.throwIfAborted()\n const fileKey = JSON.stringify([scopeKey(scope), source.key, source.uri])\n this.rememberVersion(fileKey, scope, hashText(source.text))\n return source\n }\n\n release(scope: SnapshotScope, handle: string): boolean {\n validateScope(scope)\n const record = this.records.get(handle)\n if (!record || record.scopeKey !== scopeKey(scope)) return false\n return this.records.delete(handle)\n }\n\n releaseOwner(scope: SnapshotScope): number {\n validateScope(scope)\n const owner = scopeKey(scope)\n let released = 0\n for (const [handle, record] of this.records) {\n if (record.scopeKey === owner) { this.records.delete(handle); released++ }\n }\n for (const [key, version] of this.versions) if (version.scopeKey === owner) this.versions.delete(key)\n return released\n }\n\n clear(): void { this.records.clear(); this.versions.clear() }\n get size(): number { return this.records.size }\n get documentByteLimit(): number { return this.maxDocumentBytes }\n\n private totalBytes(): number {\n let bytes = 0\n for (const record of this.records.values()) bytes += record.descriptor.sourceBytes\n return bytes\n }\n\n private rememberVersion(fileKey: string, scope: SnapshotScope, hash: string): number {\n const owner = scopeKey(scope), previous = this.versions.get(fileKey)\n const version = previous ? (previous.hash === hash ? previous.version : previous.version + 1) : 1\n this.versions.delete(fileKey)\n this.versions.set(fileKey, { hash, version, scopeKey: owner })\n while (this.versions.size > 4096) this.versions.delete(this.versions.keys().next().value!)\n return version\n }\n\n private evictExpired(): void {\n const now = Date.now()\n for (const [handle, record] of this.records) if (now - record.openedAt > SNAPSHOT_TTL_MS) this.records.delete(handle)\n }\n}\n\nexport function languageForPath(filePath: string): StructureLanguage | null {\n // Blade's PHP-like suffix does not make its template syntax a PHP document.\n if (filePath.toLowerCase().endsWith('.blade.php')) return null\n const suffix = filePath.slice(filePath.lastIndexOf('.')).toLowerCase()\n return EXTENSION_LANGUAGE[suffix] ?? null\n}\n\nexport function validateScope(scope: SnapshotScope): void {\n if (!scope || typeof scope !== 'object' || !scope.ownerId?.trim() || !scope.sessionId?.trim() || !scope.workspaceRoot?.trim() || !isAbsolute(scope.workspaceRoot) || /[\\u0000-\\u001f\\u007f]/u.test(`${scope.ownerId}${scope.sessionId}${scope.workspaceRoot}`))\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'trusted owner, session and absolute workspace root are required')\n}\n\nexport function normalizeRelativePath(filePath: string): string {\n if (typeof filePath !== 'string' || !filePath.trim() || filePath.length > 4096 || /[\\u0000-\\u001f\\u007f]/u.test(filePath) || isAbsolute(filePath))\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'file path must be a relative workspace path')\n const segments = filePath.replaceAll('\\\\', '/').split('/')\n if (segments.some(segment => segment === '..' || segment === '')) throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'file path contains an invalid segment')\n return segments.filter(segment => segment !== '.').join('/')\n}\n\nexport function scopeIdentity(scope: SnapshotScope): string { return JSON.stringify([scope.ownerId, scope.sessionId, scope.workspaceRoot]) }\nfunction scopeKey(scope: SnapshotScope): string { return scopeIdentity(scope) }\nfunction hashText(text: string): string { return createHash('sha256').update(text, 'utf8').digest('hex') }\nfunction staleSnapshot(): WebstackLspError { return new WebstackLspError('LSP_STALE_SNAPSHOT', 'snapshot is stale, expired or belongs to another owner') }\n","import type { LspPosition, LspRange } from '../service.js'\n\ninterface Line { start: number; end: number }\n\n/** web-tree-sitter 0.27.1 exposes JS-string indices as UTF-16 code-unit offsets. */\nexport class Utf16Coordinates {\n private readonly lines: Line[]\n\n constructor(private readonly text: string) {\n this.lines = []\n let start = 0\n for (let index = 0; index < text.length;) {\n const char = text[index]!\n if (char !== '\\r' && char !== '\\n') { index++; continue }\n this.lines.push({ start, end: index })\n if (char === '\\r' && text[index + 1] === '\\n') index++\n index++\n start = index\n }\n this.lines.push({ start, end: text.length })\n }\n\n positionToIndex(position: LspPosition): number {\n if (!isPosition(position)) throw new RangeError('position must use non-negative zero-based UTF-16 coordinates')\n const line = this.lines[position.line]\n if (!line || position.character > line.end - line.start) throw new RangeError('position is outside document')\n const index = line.start + position.character\n if (isBetweenSurrogatePair(this.text, index)) throw new RangeError('position splits a UTF-16 surrogate pair')\n return index\n }\n\n indexToPosition(index: number): LspPosition {\n if (!Number.isSafeInteger(index) || index < 0 || index > this.text.length) throw new RangeError('Tree-sitter index is outside document')\n let low = 0, high = this.lines.length\n while (low < high) {\n const middle = (low + high) >>> 1\n if (this.lines[middle]!.start <= index) low = middle + 1\n else high = middle\n }\n const lineNumber = Math.max(0, low - 1)\n const line = this.lines[lineNumber]!\n return { line: lineNumber, character: Math.min(index, line.end) - line.start }\n }\n\n rangeToIndices(range: LspRange): { startIndex: number; endIndex: number } {\n const startIndex = this.positionToIndex(range.start)\n const endIndex = this.positionToIndex(range.end)\n if (endIndex < startIndex) throw new RangeError('range end precedes range start')\n return { startIndex, endIndex }\n }\n\n indicesToRange(startIndex: number, endIndex: number): LspRange {\n if (endIndex < startIndex) throw new RangeError('range end precedes range start')\n return { start: this.indexToPosition(startIndex), end: this.indexToPosition(endIndex) }\n }\n}\n\nfunction isPosition(value: unknown): value is LspPosition {\n if (typeof value !== 'object' || value === null) return false\n const position = value as { line?: unknown; character?: unknown }\n return Number.isSafeInteger(position.line) && Number.isSafeInteger(position.character) && (position.line as number) >= 0 && (position.character as number) >= 0\n}\n\nfunction isBetweenSurrogatePair(text: string, index: number): boolean {\n if (index <= 0 || index >= text.length) return false\n const previous = text.charCodeAt(index - 1), next = text.charCodeAt(index)\n return previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff\n}\n","import type { StructureLanguage } from './types.js'\n\nconst declarations: Partial<Record<StructureLanguage, string[]>> = {\n php: [\n '(class_declaration name: (_) @name) @declaration',\n '(function_definition name: (_) @name) @declaration',\n '(method_declaration name: (_) @name) @declaration',\n ],\n javascript: [\n '(function_declaration name: (_) @name) @declaration',\n '(class_declaration name: (_) @name) @declaration',\n '(method_definition name: (_) @name) @declaration',\n '(variable_declarator name: (_) @name) @declaration',\n ],\n typescript: [\n '(function_declaration name: (_) @name) @declaration',\n '(class_declaration name: (_) @name) @declaration',\n '(interface_declaration name: (_) @name) @declaration',\n '(type_alias_declaration name: (_) @name) @declaration',\n '(enum_declaration name: (_) @name) @declaration',\n '(method_definition name: (_) @name) @declaration',\n '(variable_declarator name: (_) @name) @declaration',\n ],\n tsx: [\n '(function_declaration name: (_) @name) @declaration',\n '(class_declaration name: (_) @name) @declaration',\n '(interface_declaration name: (_) @name) @declaration',\n '(type_alias_declaration name: (_) @name) @declaration',\n '(enum_declaration name: (_) @name) @declaration',\n '(method_definition name: (_) @name) @declaration',\n '(variable_declarator name: (_) @name) @declaration',\n ],\n}\n\nconst imports: Partial<Record<StructureLanguage, string[]>> = {\n javascript: ['(import_statement) @import', '(export_statement) @export'],\n typescript: ['(import_statement) @import', '(export_statement) @export'],\n tsx: ['(import_statement) @import', '(export_statement) @export'],\n}\n\nconst calls: Partial<Record<StructureLanguage, string[]>> = {\n javascript: ['(call_expression function: (_) @call) @callsite'],\n typescript: ['(call_expression function: (_) @call) @callsite'],\n tsx: ['(call_expression function: (_) @call) @callsite'],\n}\n\nexport type RegisteredQueryId = 'declarations' | 'calls' | 'imports'\n\nexport function getRegisteredQuery(language: StructureLanguage, queryId: string): string | undefined {\n const patterns = queryId === 'declarations' ? declarations[language] : queryId === 'calls' ? calls[language] : queryId === 'imports' ? imports[language] : undefined\n return patterns?.join('\\n')\n}\n\nexport function isRegisteredQueryId(value: string): value is RegisteredQueryId {\n return value === 'declarations' || value === 'calls' || value === 'imports'\n}\n","import { randomUUID } from 'node:crypto'\nimport { Worker } from 'node:worker_threads'\nimport { WebstackLspError } from '../errors.js'\nimport type { StructureLanguage } from './types.js'\n\nexport interface StructureWorkerRequest {\n operation: 'matches' | 'enclosing' | 'inspect'\n language: StructureLanguage\n text: string\n querySource: string\n scriptQueries?: { javascript: string; typescript: string }\n limit: number\n snapshotHandle?: string\n previousSnapshotHandle?: string\n startIndex?: number\n endIndex?: number\n index?: number\n kinds?: string[]\n}\n\nexport interface WorkerNodeSummary {\n kind: string\n startIndex: number\n endIndex: number\n startPosition: { row: number; column: number }\n endPosition: { row: number; column: number }\n nameStartIndex?: number\n nameEndIndex?: number\n childCount: number\n}\n\nexport interface WorkerErrorSummary { hasError: boolean; errorNodes: number; missingNodes: number; truncated: boolean }\nexport interface WorkerMatch { captures: Array<{ name: string } & WorkerNodeSummary> }\nexport interface StructureWorkerResult {\n status: 'ok' | 'partial'\n abiVersion?: number\n reusedTree?: boolean\n incremental?: boolean\n matches?: WorkerMatch[]\n nodes?: WorkerNodeSummary[]\n truncated?: boolean\n errors: WorkerErrorSummary\n}\n\ninterface WorkerReply { id: string; ok: boolean; value?: StructureWorkerResult; error?: string }\ninterface PendingTask {\n id: string\n request: StructureWorkerRequest\n signal?: AbortSignal\n resolve(value: StructureWorkerResult): void\n reject(error: unknown): void\n timer?: ReturnType<typeof setTimeout>\n removeAbort?: () => void\n}\ninterface WorkerSlot { worker: Worker; current: PendingTask | undefined; completed: number; failed: boolean }\n\nconst MAX_WORKERS = 2\nconst MAX_QUEUE = 16\nconst WORKER_TASK_LIMIT = 100\nconst PARSE_TIMEOUT_MS = 2_000\n\n/** CPU-bound parsing runs off the event loop; cancellation terminates the active worker. */\nexport class StructureWorkerPool {\n private readonly slots = new Set<WorkerSlot>()\n private readonly queue: PendingTask[] = []\n private disposed = false\n\n execute(request: StructureWorkerRequest, signal?: AbortSignal): Promise<StructureWorkerResult> {\n if (this.disposed) return Promise.reject(new WebstackLspError('LSP_DISPOSED', 'structure worker pool is disposed'))\n if (signal?.aborted) return Promise.reject(abortError())\n if (this.queue.length >= MAX_QUEUE) return Promise.reject(new WebstackLspError('LSP_STRUCTURE_BUSY', 'structure worker queue is full'))\n return new Promise((resolve, reject) => {\n const task: PendingTask = { id: randomUUID(), request, ...(signal ? { signal } : {}), resolve, reject }\n if (signal) {\n const abort = () => {\n const index = this.queue.indexOf(task)\n if (index >= 0) { this.queue.splice(index, 1); this.finishTask(task, abortError()) }\n else {\n const slot = [...this.slots].find(candidate => candidate.current === task)\n if (slot) void this.retire(slot, abortError())\n }\n }\n signal.addEventListener('abort', abort, { once: true })\n task.removeAbort = () => signal.removeEventListener('abort', abort)\n }\n this.queue.push(task)\n this.pump()\n })\n }\n\n async dispose(): Promise<void> {\n this.disposed = true\n for (const task of this.queue.splice(0)) this.finishTask(task, new WebstackLspError('LSP_DISPOSED', 'structure worker pool is disposed'))\n await Promise.all([...this.slots].map(slot => this.retire(slot, new WebstackLspError('LSP_DISPOSED', 'structure worker pool is disposed'))))\n }\n\n releaseSnapshot(snapshotHandle: string): void {\n for (const slot of this.slots) {\n if (!slot.failed) {\n try { slot.worker.postMessage({ releaseSnapshotHandle: snapshotHandle }) }\n catch { void this.retire(slot, new WebstackLspError('LSP_STRUCTURE_UNAVAILABLE', 'structure worker could not release a cached snapshot')) }\n }\n }\n }\n\n get queued(): number { return this.queue.length }\n get active(): number { return [...this.slots].filter(slot => slot.current !== undefined).length }\n\n private pump(): void {\n if (this.disposed) return\n while (this.queue.length) {\n let slot = [...this.slots].find(candidate => !candidate.current && !candidate.failed)\n if (!slot && this.slots.size < MAX_WORKERS) slot = this.createWorker()\n if (!slot) return\n const task = this.queue.shift()!\n if (task.signal?.aborted) { this.finishTask(task, abortError()); continue }\n slot.current = task\n task.timer = setTimeout(() => { void this.retire(slot!, new WebstackLspError('LSP_STRUCTURE_TIMEOUT', 'structure parsing exceeded its time limit')) }, PARSE_TIMEOUT_MS)\n try { slot.worker.postMessage({ id: task.id, ...task.request }) }\n catch (error) { void this.retire(slot, error) }\n }\n }\n\n private createWorker(): WorkerSlot {\n const worker = new Worker(new URL('./parser-worker.mjs', import.meta.url))\n const slot: WorkerSlot = { worker, current: undefined, completed: 0, failed: false }\n this.slots.add(slot)\n worker.on('message', (reply: WorkerReply) => {\n if (!slot.current || reply.id !== slot.current.id) { void this.retire(slot, new WebstackLspError('LSP_MALFORMED_RESPONSE', 'structure worker returned an unexpected task identity')); return }\n const task = slot.current\n slot.current = undefined\n slot.completed++\n if (!reply.ok || !reply.value) this.finishTask(task, new WebstackLspError('LSP_STRUCTURE_UNAVAILABLE', reply.error ?? 'structure parsing failed'))\n else this.finishTask(task, undefined, reply.value)\n if (slot.completed >= WORKER_TASK_LIMIT) void this.retire(slot)\n this.pump()\n })\n worker.on('error', error => { void this.retire(slot, error) })\n worker.on('exit', code => {\n if (this.slots.has(slot) && !slot.failed) void this.retire(slot, code === 0 ? undefined : new WebstackLspError('LSP_STRUCTURE_UNAVAILABLE', `structure worker exited (${code})`))\n })\n return slot\n }\n\n private async retire(slot: WorkerSlot, error?: unknown): Promise<void> {\n if (slot.failed) return\n slot.failed = true\n this.slots.delete(slot)\n const task = slot.current\n slot.current = undefined\n if (task) this.finishTask(task, error ?? new WebstackLspError('LSP_STRUCTURE_UNAVAILABLE', 'structure worker was restarted'))\n await slot.worker.terminate().catch(() => 0)\n this.pump()\n }\n\n private finishTask(task: PendingTask, error?: unknown, value?: StructureWorkerResult): void {\n if (task.timer) clearTimeout(task.timer)\n task.removeAbort?.()\n if (error !== undefined) task.reject(error)\n else task.resolve(value!)\n }\n}\n\nfunction abortError(): DOMException { return new DOMException('The operation was aborted', 'AbortError') }\n","import { randomUUID } from 'node:crypto'\nimport { WebstackLspError } from '../errors.js'\nimport { Utf16Coordinates } from './coordinates.js'\nimport { getRegisteredQuery, isRegisteredQueryId } from './queries.js'\nimport { scopeIdentity, type SnapshotRecord } from './snapshots.js'\nimport { StructureWorkerPool } from './worker-pool.js'\nimport type { SnapshotScope, StructureCapture, StructureEnclosingResult, StructureErrorSummary, StructureLanguage, StructureNode, StructureOutlineResult, StructureQueryResult, StructureSpanResult } from './types.js'\n\nexport const MAX_CAPTURES = 200\nexport const MAX_OUTLINE = 100\nexport const MAX_SPAN_CHARS = 8_000\nexport const MAX_STRUCTURE_RESPONSE_BYTES = 32 * 1024\nconst MAX_NODE_HANDLES = 10_000\n\ninterface NodeHandleRecord {\n scopeKey: string\n snapshotHandle: string\n startIndex: number\n endIndex: number\n kind: string\n range: StructureNode['range']\n}\n\nexport class StructureEngine {\n private readonly nodeHandles = new Map<string, NodeHandleRecord>()\n private readonly snapshotOwners = new Map<string, string>()\n private readonly parserFailures = new Map<StructureLanguage, string>()\n constructor(private readonly workers = new StructureWorkerPool()) {}\n\n async inspect(record: SnapshotRecord, signal?: AbortSignal): Promise<{ available: boolean; parseErrors: boolean; reason?: string }> {\n this.snapshotOwners.set(record.descriptor.handle, record.scopeKey)\n const language = record.descriptor.language\n if (!language) return { available: false, parseErrors: false, reason: 'grammar_missing' }\n try {\n const result = await this.runWorker(language, { operation: 'inspect', language, text: record.source.text, querySource: '', limit: 1, snapshotHandle: record.descriptor.handle, ...(record.previousSnapshotHandle ? { previousSnapshotHandle: record.previousSnapshotHandle } : {}) }, signal)\n this.parserFailures.delete(language)\n return { available: true, parseErrors: result.errors.hasError }\n } catch (error) {\n const reason = error instanceof Error ? error.message.slice(0, 128) : 'parser_unavailable'\n return { available: false, parseErrors: false, reason }\n }\n }\n\n async outline(record: SnapshotRecord, scope: SnapshotScope, options: { range?: StructureNode['range']; limit?: number } = {}, signal?: AbortSignal): Promise<StructureOutlineResult> {\n const language = record.descriptor.language\n if (!language) return { status: 'unsupported', handle: record.descriptor.handle, version: record.descriptor.version, declarations: [], truncated: false, processed: 0, errors: { hasError: false, errorNodes: 0, missingNodes: 0, truncated: false } }\n const limit = positiveLimit(options.limit, MAX_OUTLINE, 'outline limit')\n const coordinates = new Utf16Coordinates(record.source.text)\n const range = options.range ? coordinates.rangeToIndices(options.range) : undefined\n const result = await this.runMatches(language, record, 'declarations', limit, range, signal)\n const declarations: StructureNode[] = []\n for (const match of result.matches ?? []) {\n const declaration = match.captures.find(capture => capture.name === 'declaration')\n const nameCapture = match.captures.find(capture => capture.name === 'name')\n if (!declaration) continue\n const node = this.node(record, scope, declaration.kind, declaration.startIndex, declaration.endIndex, nameCapture ? record.source.text.slice(nameCapture.startIndex, nameCapture.endIndex).slice(0, 256) : undefined, declaration.childCount, coordinates)\n declarations.push(node)\n }\n return this.outlineResult(record, declarations, result, limit)\n }\n\n async enclosing(record: SnapshotRecord, scope: SnapshotScope, position: { line: number; character: number }, kinds?: string[], signal?: AbortSignal): Promise<StructureEnclosingResult> {\n const language = record.descriptor.language\n if (!language) return { status: 'unsupported', handle: record.descriptor.handle, version: record.descriptor.version, ancestors: [] }\n const coordinates = new Utf16Coordinates(record.source.text)\n const index = coordinates.positionToIndex(position)\n if (kinds && (!Array.isArray(kinds) || kinds.length > 32 || kinds.some(kind => typeof kind !== 'string' || kind.length > 128 || !/^[a-z][a-z0-9_]*$/u.test(kind))))\n throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'kinds must be a list of at most 32 node type names')\n const result = await this.runWorker(language, { operation: 'enclosing', language, text: record.source.text, querySource: '', limit: 16, snapshotHandle: record.descriptor.handle, index, ...(kinds ? { kinds: [...kinds] } : {}) }, signal)\n const nodes = result.nodes ?? []\n const summaries = nodes.map(item => this.node(record, scope, item.kind, item.startIndex, item.endIndex, undefined, item.childCount, coordinates))\n const [node, ...ancestors] = summaries\n return { status: result.status, handle: record.descriptor.handle, version: record.descriptor.version, ...(node ? { node } : {}), ancestors, errors: publicErrors(result.errors) }\n }\n\n async query(record: SnapshotRecord, scope: SnapshotScope, queryId: string, options: { range?: StructureNode['range']; limit?: number } = {}, signal?: AbortSignal): Promise<StructureQueryResult> {\n const language = record.descriptor.language\n if (!language) throw new WebstackLspError('LSP_STRUCTURE_UNSUPPORTED', 'no bundled Tree-sitter grammar is available for this document')\n if (!isRegisteredQueryId(queryId)) throw new WebstackLspError('LSP_STRUCTURE_UNSUPPORTED', 'queryId is not in the registered query allowlist')\n const limit = positiveLimit(options.limit, MAX_CAPTURES, 'capture limit')\n const coordinates = new Utf16Coordinates(record.source.text)\n const range = options.range ? coordinates.rangeToIndices(options.range) : undefined\n const result = await this.runMatches(language, record, queryId, limit, range, signal)\n const captures: StructureCapture[] = []\n captureLoop: for (const match of result.matches ?? []) for (const capture of match.captures) {\n const node = this.node(record, scope, capture.kind, capture.startIndex, capture.endIndex, undefined, capture.childCount, coordinates)\n captures.push({ capture: capture.name, kind: capture.kind, range: node.range, nodeHandle: node.handle, ...(capture.name === 'name' ? { name: record.source.text.slice(capture.startIndex, capture.endIndex).slice(0, 256) } : {}) })\n if (captures.length >= limit) break captureLoop\n }\n if (Buffer.byteLength(JSON.stringify(captures), 'utf8') > MAX_STRUCTURE_RESPONSE_BYTES) throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'query result exceeds the response byte limit')\n return { status: result.status, handle: record.descriptor.handle, version: record.descriptor.version, queryId, captures, truncated: Boolean(result.truncated || (result.matches ?? []).reduce((total, match) => total + match.captures.length, 0) > limit), processed: captures.length, errors: publicErrors(result.errors) }\n }\n\n async span(record: SnapshotRecord, scope: SnapshotScope, nodeHandle: string, maxChars = MAX_SPAN_CHARS): Promise<StructureSpanResult> {\n const handle = this.nodeHandles.get(nodeHandle)\n if (!handle || handle.snapshotHandle !== record.descriptor.handle || handle.scopeKey !== scopeIdentity(scope))\n throw new WebstackLspError('LSP_STALE_SNAPSHOT', 'node handle is stale or belongs to another owner')\n if (!Number.isSafeInteger(maxChars) || maxChars < 1 || maxChars > MAX_SPAN_CHARS)\n throw new WebstackLspError('LSP_STRUCTURE_LIMIT', `maxChars must be between 1 and ${MAX_SPAN_CHARS}`)\n const full = record.source.text.slice(handle.startIndex, handle.endIndex)\n const codePoints = Array.from(full)\n const truncated = codePoints.length > maxChars\n const text = codePoints.slice(0, maxChars).join('')\n if (Buffer.byteLength(text, 'utf8') > MAX_STRUCTURE_RESPONSE_BYTES) throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'span result exceeds the response byte limit')\n return { status: truncated ? 'partial' : 'ok', text, truncated, range: handle.range }\n }\n\n releaseSnapshot(handle: string): void {\n for (const [nodeHandle, node] of this.nodeHandles) if (node.snapshotHandle === handle) this.nodeHandles.delete(nodeHandle)\n this.snapshotOwners.delete(handle)\n this.workers.releaseSnapshot(handle)\n }\n\n releaseSnapshotForOwner(scope: SnapshotScope, handle: string): void {\n if (this.snapshotOwners.get(handle) === scopeIdentity(scope)) this.releaseSnapshot(handle)\n }\n\n snapshotForNode(scope: SnapshotScope, nodeHandle: string): string {\n const record = this.nodeHandles.get(nodeHandle)\n if (!record || record.scopeKey !== scopeIdentity(scope)) throw new WebstackLspError('LSP_STALE_SNAPSHOT', 'node handle is stale or belongs to another owner')\n return record.snapshotHandle\n }\n\n releaseOwner(scope: SnapshotScope): void {\n const owner = scopeIdentity(scope)\n for (const [nodeHandle, node] of this.nodeHandles) if (node.scopeKey === owner) this.nodeHandles.delete(nodeHandle)\n for (const [snapshotHandle, snapshotOwner] of this.snapshotOwners) {\n if (snapshotOwner === owner) this.releaseSnapshot(snapshotHandle)\n }\n }\n\n capabilities(): Array<{ language: StructureLanguage; extensions: string[]; available: boolean; abiVersion: number | null; lastError?: string }> {\n return [\n this.capability('javascript', ['.js', '.jsx', '.mjs', '.cjs'], 15),\n this.capability('typescript', ['.ts', '.mts', '.cts'], 14),\n this.capability('tsx', ['.tsx'], 14),\n this.capability('php', ['.php'], 15),\n // Svelte uses both script grammars, not a separate grammar ABI.\n this.capability('svelte', ['.svelte'], null),\n ]\n }\n\n async dispose(): Promise<void> { this.nodeHandles.clear(); this.snapshotOwners.clear(); await this.workers.dispose() }\n\n private async runMatches(language: StructureLanguage, record: SnapshotRecord, queryId: string, limit: number, range?: { startIndex: number; endIndex: number }, signal?: AbortSignal) {\n if (language === 'svelte') {\n const scriptQueries = { javascript: getRegisteredQuery('javascript', queryId)!, typescript: getRegisteredQuery('typescript', queryId)! }\n return this.runWorker(language, { operation: 'matches', language, text: record.source.text, querySource: '', scriptQueries, limit, snapshotHandle: record.descriptor.handle, ...(range ?? {}) }, signal)\n }\n const querySource = getRegisteredQuery(language, queryId)\n if (!querySource) throw new WebstackLspError('LSP_STRUCTURE_UNSUPPORTED', `query ${queryId} is not registered for ${language}`)\n return this.runWorker(language, { operation: 'matches', language, text: record.source.text, querySource, limit, snapshotHandle: record.descriptor.handle, ...(range ?? {}) }, signal)\n }\n\n private capability(language: StructureLanguage, extensions: string[], abiVersion: number | null) {\n const lastError = this.parserFailures.get(language)\n return { language, extensions, available: !lastError, abiVersion, ...(lastError ? { lastError } : {}) }\n }\n\n private async runWorker(language: StructureLanguage, request: Parameters<StructureWorkerPool['execute']>[0], signal?: AbortSignal) {\n try {\n const result = await this.workers.execute(request, signal)\n this.parserFailures.delete(language)\n return result\n } catch (error) {\n if (error instanceof WebstackLspError && ['LSP_STRUCTURE_TIMEOUT', 'LSP_STRUCTURE_UNAVAILABLE'].includes(error.code))\n this.parserFailures.set(language, error.message.slice(0, 128))\n throw error\n }\n }\n\n private outlineResult(record: SnapshotRecord, declarations: StructureNode[], result: Awaited<ReturnType<StructureWorkerPool['execute']>>, limit: number): StructureOutlineResult {\n const truncated = Boolean(result.truncated || declarations.length > limit)\n const selected = declarations.slice(0, limit)\n const jsonBytes = Buffer.byteLength(JSON.stringify(selected), 'utf8')\n if (jsonBytes > MAX_STRUCTURE_RESPONSE_BYTES) throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'outline result exceeds the response byte limit')\n return { status: result.status, handle: record.descriptor.handle, version: record.descriptor.version, declarations: selected, truncated, processed: selected.length, errors: publicErrors(result.errors) }\n }\n\n private node(record: SnapshotRecord, scope: SnapshotScope, kind: string, startIndex: number, endIndex: number, name?: string, childCount?: number, coordinates = new Utf16Coordinates(record.source.text)): StructureNode {\n if (this.nodeHandles.size >= MAX_NODE_HANDLES) throw new WebstackLspError('LSP_SNAPSHOT_LIMIT', 'node handle capacity is full; release a snapshot and retry')\n const handle = randomUUID()\n const range = coordinates.indicesToRange(startIndex, endIndex)\n this.nodeHandles.set(handle, { scopeKey: scopeIdentity(scope), snapshotHandle: record.descriptor.handle, startIndex, endIndex, kind, range })\n return { handle, kind: publicNodeKind(kind), range, ...(name ? { name } : {}), ...(childCount === undefined ? {} : { childCount }) }\n }\n}\n\nfunction positiveLimit(value: number | undefined, maximum: number, label: string): number {\n const limit = value ?? maximum\n if (!Number.isSafeInteger(limit) || limit < 1 || limit > maximum) throw new WebstackLspError('LSP_STRUCTURE_LIMIT', `${label} must be between 1 and ${maximum}`)\n return limit\n}\n\nfunction publicErrors(errors: StructureErrorSummary): StructureErrorSummary { return { ...errors } }\n\nfunction publicNodeKind(kind: string): string {\n return ({ function_declaration: 'function', function_definition: 'function', class_declaration: 'class', interface_declaration: 'interface', type_alias_declaration: 'type', enum_declaration: 'enum', method_definition: 'method', method_declaration: 'method', variable_declarator: 'variable' } as Record<string, string>)[kind] ?? kind\n}\n","import { WebstackLspError } from '../errors.js'\nimport { DocumentSnapshotStore } from './snapshots.js'\nimport type { SnapshotRecord } from './snapshots.js'\nimport { StructureEngine, MAX_CAPTURES, MAX_OUTLINE, MAX_SPAN_CHARS, MAX_STRUCTURE_RESPONSE_BYTES } from './engine.js'\nimport type { CodeIntelligenceCapabilities, CodeIntelligenceToolServiceV1, SemanticQuery, SemanticResult, SnapshotScope, StructureEnclosingResult, StructureOutlineResult, StructureQueryResult, StructureSpanResult } from './types.js'\nimport type { CompletionResult, DiagnosticsResult, NavigationResult } from '../service.js'\n\nexport interface CodeIntelligenceServiceOptions {\n snapshots: DocumentSnapshotStore\n semanticQuery(scope: SnapshotScope, snapshot: SnapshotRecord, request: SemanticQuery, signal: AbortSignal): Promise<CompletionResult | DiagnosticsResult | NavigationResult>\n}\n\nexport class CodeIntelligenceRuntime implements CodeIntelligenceToolServiceV1 {\n readonly version = 1 as const\n readonly snapshot: CodeIntelligenceToolServiceV1['snapshot']\n readonly structure: CodeIntelligenceToolServiceV1['structure']\n readonly semantic: CodeIntelligenceToolServiceV1['semantic']\n private readonly store: DocumentSnapshotStore\n private readonly engine: StructureEngine\n\n constructor(options: CodeIntelligenceServiceOptions) {\n this.store = options.snapshots\n this.engine = new StructureEngine()\n\n this.snapshot = {\n open: async (scope, filePath, signal) => {\n const record = await this.store.open(scope, filePath, signal)\n try {\n const parser = await this.engine.inspect(record, signal)\n await this.store.current(scope, record.descriptor.handle, signal)\n return { status: 'ok', ...record.descriptor, parserAvailable: parser.available, parseErrors: parser.parseErrors }\n } catch (error) {\n this.store.release(scope, record.descriptor.handle)\n this.engine.releaseSnapshot(record.descriptor.handle)\n throw error\n }\n },\n release: async (scope, handle) => {\n const released = this.store.release(scope, handle)\n if (released) this.engine.releaseSnapshot(handle)\n return { released }\n },\n }\n\n this.structure = {\n outline: (scope, handle, request, signal) => this.withSnapshot(scope, handle, signal, record => this.engine.outline(record, scope, request, signal)) as Promise<StructureOutlineResult>,\n enclosing: (scope, handle, position, request, signal) => this.withSnapshot(scope, handle, signal, record => this.engine.enclosing(record, scope, position, request?.kinds, signal)) as Promise<StructureEnclosingResult>,\n query: (scope, handle, queryId, request, signal) => this.withSnapshot(scope, handle, signal, record => this.engine.query(record, scope, queryId, request, signal)) as Promise<StructureQueryResult>,\n span: (scope, nodeHandle, maxChars, signal) => this.span(scope, nodeHandle, maxChars, signal),\n }\n\n this.semantic = {\n query: async (scope, handle, request, signal) => {\n validateSemanticQuery(request)\n return this.withSnapshot(scope, handle, signal, async record => {\n const raw = await options.semanticQuery(scope, record, request, signal ?? new AbortController().signal)\n await this.store.current(scope, handle, signal)\n const bounded = limitSemanticResult(raw, request.maxResults ?? 200)\n const truncated = 'truncated' in bounded && Boolean(bounded.truncated)\n const status = semanticIsPartial(bounded) || truncated ? 'partial' : 'ok'\n const value: SemanticResult = { status, operation: request.operation, result: bounded, ...(truncated ? { truncated: true, omitted: 'omitted' in bounded && typeof bounded.omitted === 'number' ? bounded.omitted : 0 } : {}) }\n if (Buffer.byteLength(JSON.stringify(value), 'utf8') > MAX_STRUCTURE_RESPONSE_BYTES)\n throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'semantic result exceeds the response byte limit')\n return value\n }) as Promise<SemanticResult>\n },\n }\n }\n\n capabilities(): CodeIntelligenceCapabilities {\n const parsers = this.engine.capabilities().map(parser => ({\n ...parser,\n runtimeAbi: { minimum: 13, current: 15 },\n }))\n return {\n version: 1,\n parsers,\n sourceKind: 'disk',\n overlay: 'unavailable',\n limits: {\n maxDocumentBytes: Math.min(this.store.documentByteLimit, 2 * 1024 * 1024),\n maxCaptures: MAX_CAPTURES,\n maxOutline: MAX_OUTLINE,\n maxSpanChars: MAX_SPAN_CHARS,\n maxResponseBytes: MAX_STRUCTURE_RESPONSE_BYTES,\n },\n incrementalParsing: true,\n }\n }\n\n async releaseOwner(scope: SnapshotScope): Promise<number> {\n this.engine.releaseOwner(scope)\n return this.store.releaseOwner(scope)\n }\n\n async dispose(): Promise<void> { this.store.clear(); await this.engine.dispose() }\n\n private async span(scope: SnapshotScope, nodeHandle: string, maxChars = MAX_SPAN_CHARS, signal?: AbortSignal): Promise<StructureSpanResult> {\n const snapshotHandle = this.engine.snapshotForNode(scope, nodeHandle)\n return this.withSnapshot(scope, snapshotHandle, signal, record => this.engine.span(record, scope, nodeHandle, maxChars)) as Promise<StructureSpanResult>\n }\n\n private async withSnapshot<T>(scope: SnapshotScope, handle: string, signal: AbortSignal | undefined, execute: (record: Awaited<ReturnType<DocumentSnapshotStore['current']>>) => Promise<T>): Promise<T> {\n let record: Awaited<ReturnType<DocumentSnapshotStore['current']>>\n try { record = await this.store.current(scope, handle, signal) }\n catch (error) {\n if (error instanceof WebstackLspError && error.code === 'LSP_STALE_SNAPSHOT') this.engine.releaseSnapshotForOwner(scope, handle)\n throw error\n }\n try {\n const result = await execute(record)\n await this.store.current(scope, handle, signal)\n return result\n } catch (error) {\n if (error instanceof WebstackLspError && error.code === 'LSP_STALE_SNAPSHOT') this.engine.releaseSnapshotForOwner(scope, handle)\n throw error\n }\n }\n\n}\n\nexport function createCodeIntelligenceToolServiceV1(options: CodeIntelligenceServiceOptions): CodeIntelligenceToolServiceV1 {\n return new CodeIntelligenceRuntime(options)\n}\n\nfunction validateSemanticQuery(request: SemanticQuery): void {\n if (!request || !['definition', 'references', 'implementation', 'hover', 'diagnostics', 'completion'].includes(request.operation))\n throw new WebstackLspError('LSP_UNSUPPORTED_OPERATION', 'semantic operation is not supported')\n if (request.operation !== 'diagnostics' && !request.position)\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'semantic position is required for this operation')\n if (request.position && (!Number.isSafeInteger(request.position.line) || !Number.isSafeInteger(request.position.character) || request.position.line < 0 || request.position.character < 0))\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'semantic position must be a zero-based UTF-16 position')\n if (request.servers && (!Array.isArray(request.servers) || request.servers.length > 6 || request.servers.some(server => typeof server !== 'string' || server.length > 64)))\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'semantic server filter is invalid')\n if (request.maxResults !== undefined && (!Number.isSafeInteger(request.maxResults) || request.maxResults < 1 || request.maxResults > 200))\n throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'maxResults must be between 1 and 200')\n}\n\nfunction semanticIsPartial(result: CompletionResult | DiagnosticsResult | NavigationResult): boolean {\n if ('diagnostics' in result) return Boolean(result.omittedServers?.length || result.truncated)\n if ('items' in result) return Boolean(result.truncated)\n if (result.kind === 'locations') return Boolean(result.truncated)\n return false\n}\n\nfunction limitSemanticResult(result: CompletionResult | DiagnosticsResult | NavigationResult, limit: number): CompletionResult | DiagnosticsResult | NavigationResult {\n if ('items' in result) {\n if (result.items.length <= limit) return result\n return { ...result, items: result.items.slice(0, limit), truncated: { items: result.items.length - limit, characters: 0 } }\n }\n if ('diagnostics' in result) {\n if (result.diagnostics.length <= limit) return result\n return { ...result, diagnostics: result.diagnostics.slice(0, limit), truncated: { diagnostics: result.diagnostics.length - limit, characters: 0 } }\n }\n if (result.kind === 'locations' && result.locations.length > limit)\n return { ...result, locations: result.locations.slice(0, limit), truncated: true, omitted: result.locations.length - limit }\n return result\n}\n"],"mappings":";;;;;;AAMA,MAAa,kBAAkB,IAAI;AACnC,MAAa,yBAAyB;AACtC,MAAa,qBAAqB,KAAK,OAAO;AAC9C,MAAa,+BAA+B,IAAI,OAAO;AAevD,MAAMA,qBAAwD;CAC5D,OAAO;CAAc,QAAQ;CAAc,QAAQ;CAAc,QAAQ;CACzE,OAAO;CAAc,QAAQ;CAAc,QAAQ;CACnD,QAAQ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,OAAO,UAAU;AACjE,QAAO;;AAGT,SAAS,oBAAoB,QAAiE,OAAwE;AACpK,KAAI,WAAW,QAAQ;AACrB,MAAI,OAAO,MAAM,UAAU,MAAO,QAAO;AACzC,SAAO;GAAE,GAAG;GAAQ,OAAO,OAAO,MAAM,MAAM,GAAG,MAAM;GAAE,WAAW;IAAE,OAAO,OAAO,MAAM,SAAS;IAAO,YAAY;IAAG;GAAE;;AAE7H,KAAI,iBAAiB,QAAQ;AAC3B,MAAI,OAAO,YAAY,UAAU,MAAO,QAAO;AAC/C,SAAO;GAAE,GAAG;GAAQ,aAAa,OAAO,YAAY,MAAM,GAAG,MAAM;GAAE,WAAW;IAAE,aAAa,OAAO,YAAY,SAAS;IAAO,YAAY;IAAG;GAAE;;AAErJ,KAAI,OAAO,SAAS,eAAe,OAAO,UAAU,SAAS,MAC3D,QAAO;EAAE,GAAG;EAAQ,WAAW,OAAO,UAAU,MAAM,GAAG,MAAM;EAAE,WAAW;EAAM,SAAS,OAAO,UAAU,SAAS;EAAO;AAC9H,QAAO"}
@@ -1,5 +1,5 @@
1
1
  import "./errors-DtyWAUi0.js";
2
- import { createCodeIntelligenceToolServiceV1 } from "./code-intelligence-DvhxPnpu.js";
2
+ import { createCodeIntelligenceToolServiceV1 } from "./code-intelligence-BUs39chK.js";
3
3
  import { CODE_INTELLIGENCE_SERVICE, CODE_INTELLIGENCE_VERSION } from "./code-intelligence-contracts-CWXTofdI.js";
4
4
 
5
5
  export { CODE_INTELLIGENCE_SERVICE, CODE_INTELLIGENCE_VERSION, createCodeIntelligenceToolServiceV1 };
@@ -35,6 +35,16 @@
35
35
  "abiVersion": 14,
36
36
  "asset": "tree-sitter-tsx.wasm",
37
37
  "sha256": "79e5da75ea62855a0cd67177685f0164eac87d5f630b3cbe1e0a099751ad30f8"
38
+ },
39
+ {
40
+ "language": "php",
41
+ "package": "tree-sitter-php",
42
+ "version": "0.24.2",
43
+ "sourceCommit": "5b5627faaa290d89eb3d01b9bf47c3bb9e797dea",
44
+ "license": "MIT",
45
+ "abiVersion": 15,
46
+ "asset": "tree-sitter-php.wasm",
47
+ "sha256": "d4df6a6ff08c87c3ec4f9cbb785fe09998a0cb570e03f57d7b19b3acfb146aa7"
38
48
  }
39
49
  ]
40
50
  }
@@ -7,6 +7,7 @@ const assets = {
7
7
  javascript: 'tree-sitter-javascript.wasm',
8
8
  typescript: 'tree-sitter-typescript.wasm',
9
9
  tsx: 'tree-sitter-tsx.wasm',
10
+ php: 'tree-sitter-php.wasm',
10
11
  }
11
12
  const MAX_CACHE_ENTRIES = 16
12
13
  const MAX_CACHE_BYTES = 16 * 1024 * 1024
@@ -54,6 +55,70 @@ function nodeSummary(node) {
54
55
  }
55
56
 
56
57
  async function run(request) {
58
+ return request.language === 'svelte' ? runSvelte(request) : runScript(request)
59
+ }
60
+
61
+ // Let Svelte identify its actual top-level scripts. Recover incomplete script
62
+ // bodies with Tree-sitter instead of treating an Acorn failure as a clean file.
63
+ async function runSvelte(request) {
64
+ const { parse, preprocess } = await import('svelte/compiler')
65
+ // Svelte strips a leading BOM; replacing it keeps original UTF-16 offsets.
66
+ const source = request.text.replace(/^\uFEFF/, ' ')
67
+ let ast
68
+ try { ast = parse(source, { modern: true, loose: true }) }
69
+ catch {
70
+ // The compiler preprocessor is a fallback only: its tag scanner can mistake
71
+ // script-looking strings in valid markup for tags, unlike the real parser.
72
+ const mask = ({ content }) => ({ code: content.replace(/[^\r\n]/g, ' ') })
73
+ const masked = await preprocess(source, { script: mask, style: mask })
74
+ if (masked.code.length !== source.length) throw new Error('Svelte preprocessing changed source offsets')
75
+ ast = parse(masked.code, { modern: true, loose: true })
76
+ }
77
+ const scripts = [ast.instance, ast.module].filter(Boolean).sort((a, b) => a.start - b.start)
78
+ const errors = { hasError: false, errorNodes: 0, missingNodes: 0, truncated: false }
79
+ const matches = [], nodes = []
80
+ let truncated = false, reusedTree = scripts.length > 0, incremental = false
81
+ for (const script of scripts) {
82
+ const start = script.content.start, end = script.content.end
83
+ if (request.operation === 'enclosing' && (request.index < start || request.index >= end)) continue
84
+ const lang = script.attributes.find(attribute => attribute.name === 'lang')
85
+ const language = lang?.value?.[0]?.data === 'ts' ? 'typescript' : 'javascript'
86
+ if (lang && !['ts', 'js', 'javascript'].includes(lang.value?.[0]?.data)) throw new Error('unsupported Svelte script language')
87
+ const key = script.context
88
+ const result = await runScript({
89
+ ...request, language, text: request.text.slice(start, end),
90
+ querySource: request.scriptQueries?.[language] ?? request.querySource,
91
+ snapshotHandle: request.snapshotHandle ? `${request.snapshotHandle}:${key}` : undefined,
92
+ previousSnapshotHandle: request.previousSnapshotHandle ? `${request.previousSnapshotHandle}:${key}` : undefined,
93
+ ownerSnapshotHandle: request.snapshotHandle,
94
+ ...(request.index === undefined ? {} : { index: request.index - start }),
95
+ ...(request.startIndex === undefined ? {} : { startIndex: Math.max(0, Math.min(end - start, request.startIndex - start)) }),
96
+ ...(request.endIndex === undefined ? {} : { endIndex: Math.max(0, Math.min(end - start, request.endIndex - start)) }),
97
+ })
98
+ errors.hasError ||= result.errors.hasError
99
+ errors.errorNodes = Math.min(100, errors.errorNodes + result.errors.errorNodes)
100
+ errors.missingNodes = Math.min(100, errors.missingNodes + result.errors.missingNodes)
101
+ errors.truncated ||= result.errors.truncated
102
+ reusedTree &&= Boolean(result.reusedTree)
103
+ incremental ||= Boolean(result.incremental)
104
+ truncated ||= Boolean(result.truncated)
105
+ const offset = pointAt(request.text, start)
106
+ const originalPoint = point => ({ row: point.row + offset.row, column: point.column + (point.row === 0 ? offset.column : 0) })
107
+ const original = node => ({
108
+ ...node, startIndex: node.startIndex + start, endIndex: node.endIndex + start,
109
+ startPosition: originalPoint(node.startPosition),
110
+ endPosition: originalPoint(node.endPosition),
111
+ ...(node.nameStartIndex === undefined ? {} : { nameStartIndex: node.nameStartIndex + start, nameEndIndex: node.nameEndIndex + start }),
112
+ })
113
+ if (request.startIndex === undefined || request.endIndex === undefined || (request.startIndex < end && request.endIndex > start)) {
114
+ matches.push(...(result.matches ?? []).map(match => ({ captures: match.captures.map(original) })))
115
+ }
116
+ nodes.push(...(result.nodes ?? []).map(original))
117
+ }
118
+ return { status: errors.hasError ? 'partial' : 'ok', errors, matches: matches.slice(0, request.limit + 1), nodes, truncated: truncated || matches.length > request.limit, reusedTree, incremental }
119
+ }
120
+
121
+ async function runScript(request) {
57
122
  const language = await loadLanguage(request.language)
58
123
  let cached = request.snapshotHandle ? trees.get(request.snapshotHandle) : undefined
59
124
  let incremental = false
@@ -74,7 +139,7 @@ async function run(request) {
74
139
  } else if (previous && previous.text === request.text) {
75
140
  trees.delete(request.previousSnapshotHandle)
76
141
  tree = previous.tree
77
- if (request.snapshotHandle) trees.set(request.snapshotHandle, previous)
142
+ if (request.snapshotHandle) trees.set(request.snapshotHandle, { ...previous, ownerSnapshotHandle: request.ownerSnapshotHandle })
78
143
  else { cachedBytes -= previous.bytes; tree.delete() }
79
144
  } else {
80
145
  parser = new Parser()
@@ -97,7 +162,7 @@ async function run(request) {
97
162
  if (!tree) throw new Error('parser returned no tree')
98
163
  if (request.snapshotHandle && Buffer.byteLength(request.text, 'utf8') <= MAX_CACHE_BYTES) {
99
164
  const bytes = Buffer.byteLength(request.text, 'utf8')
100
- trees.set(request.snapshotHandle, { tree, text: request.text, languageName: request.language, bytes })
165
+ trees.set(request.snapshotHandle, { tree, text: request.text, languageName: request.language, bytes, ownerSnapshotHandle: request.ownerSnapshotHandle })
101
166
  cachedBytes += bytes
102
167
  while (trees.size > MAX_CACHE_ENTRIES || cachedBytes > MAX_CACHE_BYTES) {
103
168
  const [oldestKey, oldest] = trees.entries().next().value
@@ -127,8 +192,9 @@ async function run(request) {
127
192
  try {
128
193
  const options = {
129
194
  matchLimit: Math.max(1, Math.min(2048, request.limit + 1)),
130
- ...(request.startIndex === undefined ? {} : { startIndex: request.startIndex }),
131
- ...(request.endIndex === undefined ? {} : { endIndex: request.endIndex }),
195
+ // Query index bounds use the underlying byte units; point columns use UTF-16.
196
+ ...(request.startIndex === undefined ? {} : { startPosition: pointAt(request.text, request.startIndex) }),
197
+ ...(request.endIndex === undefined ? {} : { endPosition: pointAt(request.text, request.endIndex) }),
132
198
  }
133
199
  const matches = query.matches(root, options)
134
200
  const result = matches.slice(0, request.limit + 1).map(match => ({
@@ -183,11 +249,12 @@ function splitsSurrogate(text, index) {
183
249
 
184
250
  port.on('message', async request => {
185
251
  if (typeof request.releaseSnapshotHandle === 'string') {
186
- const cached = trees.get(request.releaseSnapshotHandle)
187
- if (cached) {
188
- trees.delete(request.releaseSnapshotHandle)
189
- cachedBytes -= cached.bytes
190
- cached.tree.delete()
252
+ for (const [key, cached] of trees) {
253
+ if (key === request.releaseSnapshotHandle || cached.ownerSnapshotHandle === request.releaseSnapshotHandle) {
254
+ trees.delete(key)
255
+ cachedBytes -= cached.bytes
256
+ cached.tree.delete()
257
+ }
191
258
  }
192
259
  return
193
260
  }
package/lib/provider.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { WebstackLspError } from "./errors-DtyWAUi0.js";
2
2
  import { SERVER_IDS, createWebstackLspService, initializationOptions, resolveConfig, resolveLaunch, serverConfiguration } from "./launch-ByUvgkVv.js";
3
3
  import { mergeCompletions, mergeDiagnostics } from "./completion-B7NPVCEN.js";
4
- import { DocumentSnapshotStore, createCodeIntelligenceToolServiceV1 } from "./code-intelligence-DvhxPnpu.js";
4
+ import { DocumentSnapshotStore, createCodeIntelligenceToolServiceV1 } from "./code-intelligence-BUs39chK.js";
5
5
  import { LspProviderId } from "@deepseek-ai/dsh-lsp";
6
6
  import { isAbsolute } from "node:path";
7
7
  import { TextDecoder } from "node:util";
@@ -1,5 +1,5 @@
1
1
  import type { CompletionResult, DiagnosticsResult, LspPosition, LspRange, NavigationResult } from '../service.js';
2
- export type StructureLanguage = 'javascript' | 'typescript' | 'tsx';
2
+ export type StructureLanguage = 'javascript' | 'typescript' | 'tsx' | 'php' | 'svelte';
3
3
  export type CodeIntelligenceStatus = 'ok' | 'partial' | 'unsupported' | 'unavailable' | 'stale' | 'cancelled' | 'timeout' | 'limit_exceeded';
4
4
  export type SourceKind = 'disk' | 'overlay';
5
5
  /** Values are created by the trusted host adapter, never from model arguments. */
@@ -4,6 +4,10 @@ export interface StructureWorkerRequest {
4
4
  language: StructureLanguage;
5
5
  text: string;
6
6
  querySource: string;
7
+ scriptQueries?: {
8
+ javascript: string;
9
+ typescript: string;
10
+ };
7
11
  limit: number;
8
12
  snapshotHandle?: string;
9
13
  previousSnapshotHandle?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askdkc/dsh-lsp-server",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Composite read-only LSP provider for DeepSeek Harness web stacks",
5
5
  "type": "module",
6
6
  "main": "./lib/provider.js",
@@ -66,6 +66,7 @@
66
66
  "@deepseek-ai/dsh-lsp": "0.2.0-rc.2",
67
67
  "@deepseek-ai/dsh-tool-lsp": "0.2.0-rc.2",
68
68
  "@tailwindcss/language-server": "0.16.0",
69
+ "svelte": "5.55.7",
69
70
  "svelte-language-server": "0.17.15",
70
71
  "typescript": "5.7.3",
71
72
  "typescript-language-server": "4.3.3",
@@ -106,6 +107,7 @@
106
107
  "tailwindcss-v3": "npm:tailwindcss@3.4.17",
107
108
  "tailwindcss-v4": "npm:tailwindcss@4.1.13",
108
109
  "tree-sitter-javascript": "0.25.0",
110
+ "tree-sitter-php": "0.24.2",
109
111
  "tree-sitter-typescript": "0.23.2",
110
112
  "tsdown": "0.15.0",
111
113
  "typescript": "5.7.3",
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-intelligence-DvhxPnpu.js","names":["EXTENSION_LANGUAGE: Record<string, StructureLanguage>","readSource: SnapshotReader","maxDocumentBytes: number","descriptor: SnapshotDescriptor","record: SnapshotRecord","text: string","task: PendingTask","slot: WorkerSlot","declarations: StructureNode[]","declarations","captures: StructureCapture[]","value: SemanticResult","record: Awaited<ReturnType<DocumentSnapshotStore['current']>>"],"sources":["../src/structure/snapshots.ts","../src/structure/coordinates.ts","../src/structure/queries.ts","../src/structure/worker-pool.ts","../src/structure/engine.ts","../src/structure/code-intelligence.ts"],"sourcesContent":["import { createHash, randomUUID } from 'node:crypto'\nimport { isAbsolute } from 'node:path'\nimport { WebstackLspError } from '../errors.js'\nimport type { HostSource } from '../host/dsh.js'\nimport type { SnapshotDescriptor, SnapshotScope, StructureLanguage } from './types.js'\n\nexport const SNAPSHOT_TTL_MS = 5 * 60_000\nexport const SNAPSHOT_MAX_DOCUMENTS = 32\nexport const SNAPSHOT_MAX_BYTES = 32 * 1024 * 1024\nexport const STRUCTURE_MAX_DOCUMENT_BYTES = 2 * 1024 * 1024\n\nexport interface SnapshotRecord {\n readonly descriptor: SnapshotDescriptor\n readonly scopeKey: string\n readonly source: HostSource\n readonly previousSnapshotHandle?: string\n readonly openedAt: number\n lastUsedAt: number\n}\n\ninterface VersionRecord { hash: string; version: number; scopeKey: string }\n\nexport type SnapshotReader = (workspaceRoot: string, filePath: string, maxBytes: number, signal?: AbortSignal) => Promise<HostSource>\n\nconst EXTENSION_LANGUAGE: Record<string, StructureLanguage> = {\n '.js': 'javascript', '.jsx': 'javascript', '.mjs': 'javascript', '.cjs': 'javascript',\n '.ts': 'typescript', '.mts': 'typescript', '.cts': 'typescript',\n '.tsx': 'tsx',\n}\n\nexport class DocumentSnapshotStore {\n private readonly records = new Map<string, SnapshotRecord>()\n private readonly versions = new Map<string, VersionRecord>()\n\n constructor(private readonly readSource: SnapshotReader, private readonly maxDocumentBytes: number) {}\n\n async open(scope: SnapshotScope, filePath: string, signal?: AbortSignal): Promise<SnapshotRecord> {\n validateScope(scope)\n const normalizedPath = normalizeRelativePath(filePath)\n signal?.throwIfAborted()\n const first = await this.readSource(scope.workspaceRoot, normalizedPath, Math.min(this.maxDocumentBytes, STRUCTURE_MAX_DOCUMENT_BYTES), signal)\n signal?.throwIfAborted()\n const second = await this.readSource(scope.workspaceRoot, normalizedPath, Math.min(this.maxDocumentBytes, STRUCTURE_MAX_DOCUMENT_BYTES), signal)\n if (hashText(first.text) !== hashText(second.text) || first.uri !== second.uri || first.key !== second.key)\n throw new WebstackLspError('LSP_STALE_SNAPSHOT', 'document changed while opening the snapshot')\n\n const ownerKey = scopeKey(scope)\n const hash = hashText(second.text)\n const fileKey = JSON.stringify([ownerKey, second.key, second.uri])\n const version = this.rememberVersion(fileKey, scope, hash)\n const sourceBytes = Buffer.byteLength(second.text, 'utf8')\n this.evictExpired()\n if (this.records.size >= SNAPSHOT_MAX_DOCUMENTS || this.totalBytes() + sourceBytes > SNAPSHOT_MAX_BYTES)\n throw new WebstackLspError('LSP_SNAPSHOT_LIMIT', 'snapshot capacity is full; release an existing snapshot and retry')\n\n const descriptor: SnapshotDescriptor = {\n handle: randomUUID(), version, filePath: normalizedPath,\n language: languageForPath(normalizedPath), sourceKind: 'disk', contentHash: hash, sourceBytes,\n }\n const previous = [...this.records.values()]\n .filter(item => item.scopeKey === ownerKey && item.source.key === second.key && item.source.uri === second.uri)\n .sort((a, b) => b.openedAt - a.openedAt)[0]\n const record: SnapshotRecord = {\n descriptor, scopeKey: ownerKey, source: second, openedAt: Date.now(), lastUsedAt: Date.now(),\n ...(previous ? { previousSnapshotHandle: previous.descriptor.handle } : {}),\n }\n this.records.set(descriptor.handle, record)\n return record\n }\n\n async current(scope: SnapshotScope, handle: string, signal?: AbortSignal): Promise<SnapshotRecord> {\n validateScope(scope)\n signal?.throwIfAborted()\n const record = this.records.get(handle)\n if (!record || record.scopeKey !== scopeKey(scope)) throw staleSnapshot()\n if (Date.now() - record.openedAt > SNAPSHOT_TTL_MS) {\n this.records.delete(handle)\n throw staleSnapshot()\n }\n const current = await this.readSource(scope.workspaceRoot, record.descriptor.filePath, Math.min(this.maxDocumentBytes, STRUCTURE_MAX_DOCUMENT_BYTES), signal)\n signal?.throwIfAborted()\n if (current.uri !== record.source.uri || current.key !== record.source.key || hashText(current.text) !== record.descriptor.contentHash) {\n this.records.delete(handle)\n throw staleSnapshot()\n }\n record.lastUsedAt = Date.now()\n return record\n }\n\n async readFresh(scope: SnapshotScope, filePath: string, signal?: AbortSignal): Promise<HostSource> {\n validateScope(scope)\n signal?.throwIfAborted()\n const source = await this.readSource(scope.workspaceRoot, filePath, this.maxDocumentBytes, signal)\n signal?.throwIfAborted()\n const fileKey = JSON.stringify([scopeKey(scope), source.key, source.uri])\n this.rememberVersion(fileKey, scope, hashText(source.text))\n return source\n }\n\n release(scope: SnapshotScope, handle: string): boolean {\n validateScope(scope)\n const record = this.records.get(handle)\n if (!record || record.scopeKey !== scopeKey(scope)) return false\n return this.records.delete(handle)\n }\n\n releaseOwner(scope: SnapshotScope): number {\n validateScope(scope)\n const owner = scopeKey(scope)\n let released = 0\n for (const [handle, record] of this.records) {\n if (record.scopeKey === owner) { this.records.delete(handle); released++ }\n }\n for (const [key, version] of this.versions) if (version.scopeKey === owner) this.versions.delete(key)\n return released\n }\n\n clear(): void { this.records.clear(); this.versions.clear() }\n get size(): number { return this.records.size }\n get documentByteLimit(): number { return this.maxDocumentBytes }\n\n private totalBytes(): number {\n let bytes = 0\n for (const record of this.records.values()) bytes += record.descriptor.sourceBytes\n return bytes\n }\n\n private rememberVersion(fileKey: string, scope: SnapshotScope, hash: string): number {\n const owner = scopeKey(scope), previous = this.versions.get(fileKey)\n const version = previous ? (previous.hash === hash ? previous.version : previous.version + 1) : 1\n this.versions.delete(fileKey)\n this.versions.set(fileKey, { hash, version, scopeKey: owner })\n while (this.versions.size > 4096) this.versions.delete(this.versions.keys().next().value!)\n return version\n }\n\n private evictExpired(): void {\n const now = Date.now()\n for (const [handle, record] of this.records) if (now - record.openedAt > SNAPSHOT_TTL_MS) this.records.delete(handle)\n }\n}\n\nexport function languageForPath(filePath: string): StructureLanguage | null {\n const suffix = filePath.slice(filePath.lastIndexOf('.')).toLowerCase()\n return EXTENSION_LANGUAGE[suffix] ?? null\n}\n\nexport function validateScope(scope: SnapshotScope): void {\n if (!scope || typeof scope !== 'object' || !scope.ownerId?.trim() || !scope.sessionId?.trim() || !scope.workspaceRoot?.trim() || !isAbsolute(scope.workspaceRoot) || /[\\u0000-\\u001f\\u007f]/u.test(`${scope.ownerId}${scope.sessionId}${scope.workspaceRoot}`))\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'trusted owner, session and absolute workspace root are required')\n}\n\nexport function normalizeRelativePath(filePath: string): string {\n if (typeof filePath !== 'string' || !filePath.trim() || filePath.length > 4096 || /[\\u0000-\\u001f\\u007f]/u.test(filePath) || isAbsolute(filePath))\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'file path must be a relative workspace path')\n const segments = filePath.replaceAll('\\\\', '/').split('/')\n if (segments.some(segment => segment === '..' || segment === '')) throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'file path contains an invalid segment')\n return segments.filter(segment => segment !== '.').join('/')\n}\n\nexport function scopeIdentity(scope: SnapshotScope): string { return JSON.stringify([scope.ownerId, scope.sessionId, scope.workspaceRoot]) }\nfunction scopeKey(scope: SnapshotScope): string { return scopeIdentity(scope) }\nfunction hashText(text: string): string { return createHash('sha256').update(text, 'utf8').digest('hex') }\nfunction staleSnapshot(): WebstackLspError { return new WebstackLspError('LSP_STALE_SNAPSHOT', 'snapshot is stale, expired or belongs to another owner') }\n","import type { LspPosition, LspRange } from '../service.js'\n\ninterface Line { start: number; end: number }\n\n/** web-tree-sitter 0.27.1 exposes JS-string indices as UTF-16 code-unit offsets. */\nexport class Utf16Coordinates {\n private readonly lines: Line[]\n\n constructor(private readonly text: string) {\n this.lines = []\n let start = 0\n for (let index = 0; index < text.length;) {\n const char = text[index]!\n if (char !== '\\r' && char !== '\\n') { index++; continue }\n this.lines.push({ start, end: index })\n if (char === '\\r' && text[index + 1] === '\\n') index++\n index++\n start = index\n }\n this.lines.push({ start, end: text.length })\n }\n\n positionToIndex(position: LspPosition): number {\n if (!isPosition(position)) throw new RangeError('position must use non-negative zero-based UTF-16 coordinates')\n const line = this.lines[position.line]\n if (!line || position.character > line.end - line.start) throw new RangeError('position is outside document')\n const index = line.start + position.character\n if (isBetweenSurrogatePair(this.text, index)) throw new RangeError('position splits a UTF-16 surrogate pair')\n return index\n }\n\n indexToPosition(index: number): LspPosition {\n if (!Number.isSafeInteger(index) || index < 0 || index > this.text.length) throw new RangeError('Tree-sitter index is outside document')\n let low = 0, high = this.lines.length\n while (low < high) {\n const middle = (low + high) >>> 1\n if (this.lines[middle]!.start <= index) low = middle + 1\n else high = middle\n }\n const lineNumber = Math.max(0, low - 1)\n const line = this.lines[lineNumber]!\n return { line: lineNumber, character: Math.min(index, line.end) - line.start }\n }\n\n rangeToIndices(range: LspRange): { startIndex: number; endIndex: number } {\n const startIndex = this.positionToIndex(range.start)\n const endIndex = this.positionToIndex(range.end)\n if (endIndex < startIndex) throw new RangeError('range end precedes range start')\n return { startIndex, endIndex }\n }\n\n indicesToRange(startIndex: number, endIndex: number): LspRange {\n if (endIndex < startIndex) throw new RangeError('range end precedes range start')\n return { start: this.indexToPosition(startIndex), end: this.indexToPosition(endIndex) }\n }\n}\n\nfunction isPosition(value: unknown): value is LspPosition {\n if (typeof value !== 'object' || value === null) return false\n const position = value as { line?: unknown; character?: unknown }\n return Number.isSafeInteger(position.line) && Number.isSafeInteger(position.character) && (position.line as number) >= 0 && (position.character as number) >= 0\n}\n\nfunction isBetweenSurrogatePair(text: string, index: number): boolean {\n if (index <= 0 || index >= text.length) return false\n const previous = text.charCodeAt(index - 1), next = text.charCodeAt(index)\n return previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff\n}\n","import type { StructureLanguage } from './types.js'\n\nconst declarations = {\n javascript: [\n '(function_declaration name: (_) @name) @declaration',\n '(class_declaration name: (_) @name) @declaration',\n '(method_definition name: (_) @name) @declaration',\n '(variable_declarator name: (_) @name) @declaration',\n ],\n typescript: [\n '(function_declaration name: (_) @name) @declaration',\n '(class_declaration name: (_) @name) @declaration',\n '(interface_declaration name: (_) @name) @declaration',\n '(type_alias_declaration name: (_) @name) @declaration',\n '(enum_declaration name: (_) @name) @declaration',\n '(method_definition name: (_) @name) @declaration',\n '(variable_declarator name: (_) @name) @declaration',\n ],\n tsx: [\n '(function_declaration name: (_) @name) @declaration',\n '(class_declaration name: (_) @name) @declaration',\n '(interface_declaration name: (_) @name) @declaration',\n '(type_alias_declaration name: (_) @name) @declaration',\n '(enum_declaration name: (_) @name) @declaration',\n '(method_definition name: (_) @name) @declaration',\n '(variable_declarator name: (_) @name) @declaration',\n ],\n} satisfies Record<StructureLanguage, string[]>\n\nconst imports = {\n javascript: ['(import_statement) @import', '(export_statement) @export'],\n typescript: ['(import_statement) @import', '(export_statement) @export'],\n tsx: ['(import_statement) @import', '(export_statement) @export'],\n} satisfies Record<StructureLanguage, string[]>\n\nconst calls = {\n javascript: ['(call_expression function: (_) @call) @callsite'],\n typescript: ['(call_expression function: (_) @call) @callsite'],\n tsx: ['(call_expression function: (_) @call) @callsite'],\n} satisfies Record<StructureLanguage, string[]>\n\nexport type RegisteredQueryId = 'declarations' | 'calls' | 'imports'\n\nexport function getRegisteredQuery(language: StructureLanguage, queryId: string): string | undefined {\n const patterns = queryId === 'declarations' ? declarations[language] : queryId === 'calls' ? calls[language] : queryId === 'imports' ? imports[language] : undefined\n return patterns?.join('\\n')\n}\n\nexport function isRegisteredQueryId(value: string): value is RegisteredQueryId {\n return value === 'declarations' || value === 'calls' || value === 'imports'\n}\n","import { randomUUID } from 'node:crypto'\nimport { Worker } from 'node:worker_threads'\nimport { WebstackLspError } from '../errors.js'\nimport type { StructureLanguage } from './types.js'\n\nexport interface StructureWorkerRequest {\n operation: 'matches' | 'enclosing' | 'inspect'\n language: StructureLanguage\n text: string\n querySource: string\n limit: number\n snapshotHandle?: string\n previousSnapshotHandle?: string\n startIndex?: number\n endIndex?: number\n index?: number\n kinds?: string[]\n}\n\nexport interface WorkerNodeSummary {\n kind: string\n startIndex: number\n endIndex: number\n startPosition: { row: number; column: number }\n endPosition: { row: number; column: number }\n nameStartIndex?: number\n nameEndIndex?: number\n childCount: number\n}\n\nexport interface WorkerErrorSummary { hasError: boolean; errorNodes: number; missingNodes: number; truncated: boolean }\nexport interface WorkerMatch { captures: Array<{ name: string } & WorkerNodeSummary> }\nexport interface StructureWorkerResult {\n status: 'ok' | 'partial'\n abiVersion?: number\n reusedTree?: boolean\n incremental?: boolean\n matches?: WorkerMatch[]\n nodes?: WorkerNodeSummary[]\n truncated?: boolean\n errors: WorkerErrorSummary\n}\n\ninterface WorkerReply { id: string; ok: boolean; value?: StructureWorkerResult; error?: string }\ninterface PendingTask {\n id: string\n request: StructureWorkerRequest\n signal?: AbortSignal\n resolve(value: StructureWorkerResult): void\n reject(error: unknown): void\n timer?: ReturnType<typeof setTimeout>\n removeAbort?: () => void\n}\ninterface WorkerSlot { worker: Worker; current: PendingTask | undefined; completed: number; failed: boolean }\n\nconst MAX_WORKERS = 2\nconst MAX_QUEUE = 16\nconst WORKER_TASK_LIMIT = 100\nconst PARSE_TIMEOUT_MS = 2_000\n\n/** CPU-bound parsing runs off the event loop; cancellation terminates the active worker. */\nexport class StructureWorkerPool {\n private readonly slots = new Set<WorkerSlot>()\n private readonly queue: PendingTask[] = []\n private disposed = false\n\n execute(request: StructureWorkerRequest, signal?: AbortSignal): Promise<StructureWorkerResult> {\n if (this.disposed) return Promise.reject(new WebstackLspError('LSP_DISPOSED', 'structure worker pool is disposed'))\n if (signal?.aborted) return Promise.reject(abortError())\n if (this.queue.length >= MAX_QUEUE) return Promise.reject(new WebstackLspError('LSP_STRUCTURE_BUSY', 'structure worker queue is full'))\n return new Promise((resolve, reject) => {\n const task: PendingTask = { id: randomUUID(), request, ...(signal ? { signal } : {}), resolve, reject }\n if (signal) {\n const abort = () => {\n const index = this.queue.indexOf(task)\n if (index >= 0) { this.queue.splice(index, 1); this.finishTask(task, abortError()) }\n else {\n const slot = [...this.slots].find(candidate => candidate.current === task)\n if (slot) void this.retire(slot, abortError())\n }\n }\n signal.addEventListener('abort', abort, { once: true })\n task.removeAbort = () => signal.removeEventListener('abort', abort)\n }\n this.queue.push(task)\n this.pump()\n })\n }\n\n async dispose(): Promise<void> {\n this.disposed = true\n for (const task of this.queue.splice(0)) this.finishTask(task, new WebstackLspError('LSP_DISPOSED', 'structure worker pool is disposed'))\n await Promise.all([...this.slots].map(slot => this.retire(slot, new WebstackLspError('LSP_DISPOSED', 'structure worker pool is disposed'))))\n }\n\n releaseSnapshot(snapshotHandle: string): void {\n for (const slot of this.slots) {\n if (!slot.failed) {\n try { slot.worker.postMessage({ releaseSnapshotHandle: snapshotHandle }) }\n catch { void this.retire(slot, new WebstackLspError('LSP_STRUCTURE_UNAVAILABLE', 'structure worker could not release a cached snapshot')) }\n }\n }\n }\n\n get queued(): number { return this.queue.length }\n get active(): number { return [...this.slots].filter(slot => slot.current !== undefined).length }\n\n private pump(): void {\n if (this.disposed) return\n while (this.queue.length) {\n let slot = [...this.slots].find(candidate => !candidate.current && !candidate.failed)\n if (!slot && this.slots.size < MAX_WORKERS) slot = this.createWorker()\n if (!slot) return\n const task = this.queue.shift()!\n if (task.signal?.aborted) { this.finishTask(task, abortError()); continue }\n slot.current = task\n task.timer = setTimeout(() => { void this.retire(slot!, new WebstackLspError('LSP_STRUCTURE_TIMEOUT', 'structure parsing exceeded its time limit')) }, PARSE_TIMEOUT_MS)\n try { slot.worker.postMessage({ id: task.id, ...task.request }) }\n catch (error) { void this.retire(slot, error) }\n }\n }\n\n private createWorker(): WorkerSlot {\n const worker = new Worker(new URL('./parser-worker.mjs', import.meta.url))\n const slot: WorkerSlot = { worker, current: undefined, completed: 0, failed: false }\n this.slots.add(slot)\n worker.on('message', (reply: WorkerReply) => {\n if (!slot.current || reply.id !== slot.current.id) { void this.retire(slot, new WebstackLspError('LSP_MALFORMED_RESPONSE', 'structure worker returned an unexpected task identity')); return }\n const task = slot.current\n slot.current = undefined\n slot.completed++\n if (!reply.ok || !reply.value) this.finishTask(task, new WebstackLspError('LSP_STRUCTURE_UNAVAILABLE', reply.error ?? 'structure parsing failed'))\n else this.finishTask(task, undefined, reply.value)\n if (slot.completed >= WORKER_TASK_LIMIT) void this.retire(slot)\n this.pump()\n })\n worker.on('error', error => { void this.retire(slot, error) })\n worker.on('exit', code => {\n if (this.slots.has(slot) && !slot.failed) void this.retire(slot, code === 0 ? undefined : new WebstackLspError('LSP_STRUCTURE_UNAVAILABLE', `structure worker exited (${code})`))\n })\n return slot\n }\n\n private async retire(slot: WorkerSlot, error?: unknown): Promise<void> {\n if (slot.failed) return\n slot.failed = true\n this.slots.delete(slot)\n const task = slot.current\n slot.current = undefined\n if (task) this.finishTask(task, error ?? new WebstackLspError('LSP_STRUCTURE_UNAVAILABLE', 'structure worker was restarted'))\n await slot.worker.terminate().catch(() => 0)\n this.pump()\n }\n\n private finishTask(task: PendingTask, error?: unknown, value?: StructureWorkerResult): void {\n if (task.timer) clearTimeout(task.timer)\n task.removeAbort?.()\n if (error !== undefined) task.reject(error)\n else task.resolve(value!)\n }\n}\n\nfunction abortError(): DOMException { return new DOMException('The operation was aborted', 'AbortError') }\n","import { randomUUID } from 'node:crypto'\nimport { WebstackLspError } from '../errors.js'\nimport { Utf16Coordinates } from './coordinates.js'\nimport { getRegisteredQuery, isRegisteredQueryId } from './queries.js'\nimport { scopeIdentity, type SnapshotRecord } from './snapshots.js'\nimport { StructureWorkerPool } from './worker-pool.js'\nimport type { SnapshotScope, StructureCapture, StructureEnclosingResult, StructureErrorSummary, StructureLanguage, StructureNode, StructureOutlineResult, StructureQueryResult, StructureSpanResult } from './types.js'\n\nexport const MAX_CAPTURES = 200\nexport const MAX_OUTLINE = 100\nexport const MAX_SPAN_CHARS = 8_000\nexport const MAX_STRUCTURE_RESPONSE_BYTES = 32 * 1024\nconst MAX_NODE_HANDLES = 10_000\n\ninterface NodeHandleRecord {\n scopeKey: string\n snapshotHandle: string\n startIndex: number\n endIndex: number\n kind: string\n range: StructureNode['range']\n}\n\nexport class StructureEngine {\n private readonly nodeHandles = new Map<string, NodeHandleRecord>()\n private readonly snapshotOwners = new Map<string, string>()\n private readonly parserFailures = new Map<StructureLanguage, string>()\n constructor(private readonly workers = new StructureWorkerPool()) {}\n\n async inspect(record: SnapshotRecord, signal?: AbortSignal): Promise<{ available: boolean; parseErrors: boolean; reason?: string }> {\n this.snapshotOwners.set(record.descriptor.handle, record.scopeKey)\n const language = record.descriptor.language\n if (!language) return { available: false, parseErrors: false, reason: 'grammar_missing' }\n try {\n const result = await this.runWorker(language, { operation: 'inspect', language, text: record.source.text, querySource: '', limit: 1, snapshotHandle: record.descriptor.handle, ...(record.previousSnapshotHandle ? { previousSnapshotHandle: record.previousSnapshotHandle } : {}) }, signal)\n this.parserFailures.delete(language)\n return { available: true, parseErrors: result.errors.hasError }\n } catch (error) {\n const reason = error instanceof Error ? error.message.slice(0, 128) : 'parser_unavailable'\n return { available: false, parseErrors: false, reason }\n }\n }\n\n async outline(record: SnapshotRecord, scope: SnapshotScope, options: { range?: StructureNode['range']; limit?: number } = {}, signal?: AbortSignal): Promise<StructureOutlineResult> {\n const language = record.descriptor.language\n if (!language) return { status: 'unsupported', handle: record.descriptor.handle, version: record.descriptor.version, declarations: [], truncated: false, processed: 0, errors: { hasError: false, errorNodes: 0, missingNodes: 0, truncated: false } }\n const limit = positiveLimit(options.limit, MAX_OUTLINE, 'outline limit')\n const coordinates = new Utf16Coordinates(record.source.text)\n const range = options.range ? coordinates.rangeToIndices(options.range) : undefined\n const result = await this.runMatches(language, record, 'declarations', limit, range, signal)\n const declarations: StructureNode[] = []\n for (const match of result.matches ?? []) {\n const declaration = match.captures.find(capture => capture.name === 'declaration')\n const nameCapture = match.captures.find(capture => capture.name === 'name')\n if (!declaration) continue\n const node = this.node(record, scope, declaration.kind, declaration.startIndex, declaration.endIndex, nameCapture ? record.source.text.slice(nameCapture.startIndex, nameCapture.endIndex).slice(0, 256) : undefined, declaration.childCount, coordinates)\n declarations.push(node)\n }\n return this.outlineResult(record, declarations, result)\n }\n\n async enclosing(record: SnapshotRecord, scope: SnapshotScope, position: { line: number; character: number }, kinds?: string[], signal?: AbortSignal): Promise<StructureEnclosingResult> {\n const language = record.descriptor.language\n if (!language) return { status: 'unsupported', handle: record.descriptor.handle, version: record.descriptor.version, ancestors: [] }\n const coordinates = new Utf16Coordinates(record.source.text)\n const index = coordinates.positionToIndex(position)\n if (kinds && (!Array.isArray(kinds) || kinds.length > 32 || kinds.some(kind => typeof kind !== 'string' || kind.length > 128 || !/^[a-z][a-z0-9_]*$/u.test(kind))))\n throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'kinds must be a list of at most 32 node type names')\n const result = await this.runWorker(language, { operation: 'enclosing', language, text: record.source.text, querySource: '', limit: 16, snapshotHandle: record.descriptor.handle, index, ...(kinds ? { kinds: [...kinds] } : {}) }, signal)\n const nodes = result.nodes ?? []\n const summaries = nodes.map(item => this.node(record, scope, item.kind, item.startIndex, item.endIndex, undefined, item.childCount, coordinates))\n const [node, ...ancestors] = summaries\n return { status: result.status, handle: record.descriptor.handle, version: record.descriptor.version, ...(node ? { node } : {}), ancestors, errors: publicErrors(result.errors) }\n }\n\n async query(record: SnapshotRecord, scope: SnapshotScope, queryId: string, options: { range?: StructureNode['range']; limit?: number } = {}, signal?: AbortSignal): Promise<StructureQueryResult> {\n const language = record.descriptor.language\n if (!language) throw new WebstackLspError('LSP_STRUCTURE_UNSUPPORTED', 'no bundled Tree-sitter grammar is available for this document')\n if (!isRegisteredQueryId(queryId)) throw new WebstackLspError('LSP_STRUCTURE_UNSUPPORTED', 'queryId is not in the registered query allowlist')\n const limit = positiveLimit(options.limit, MAX_CAPTURES, 'capture limit')\n const coordinates = new Utf16Coordinates(record.source.text)\n const range = options.range ? coordinates.rangeToIndices(options.range) : undefined\n const result = await this.runMatches(language, record, queryId, limit, range, signal)\n const captures: StructureCapture[] = []\n captureLoop: for (const match of result.matches ?? []) for (const capture of match.captures) {\n const node = this.node(record, scope, capture.kind, capture.startIndex, capture.endIndex, undefined, capture.childCount, coordinates)\n captures.push({ capture: capture.name, kind: capture.kind, range: node.range, nodeHandle: node.handle, ...(capture.name === 'name' ? { name: record.source.text.slice(capture.startIndex, capture.endIndex).slice(0, 256) } : {}) })\n if (captures.length >= limit) break captureLoop\n }\n if (Buffer.byteLength(JSON.stringify(captures), 'utf8') > MAX_STRUCTURE_RESPONSE_BYTES) throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'query result exceeds the response byte limit')\n return { status: result.status, handle: record.descriptor.handle, version: record.descriptor.version, queryId, captures, truncated: Boolean(result.truncated || (result.matches?.length ?? 0) > limit), processed: captures.length, errors: publicErrors(result.errors) }\n }\n\n async span(record: SnapshotRecord, scope: SnapshotScope, nodeHandle: string, maxChars = MAX_SPAN_CHARS): Promise<StructureSpanResult> {\n const handle = this.nodeHandles.get(nodeHandle)\n if (!handle || handle.snapshotHandle !== record.descriptor.handle || handle.scopeKey !== scopeIdentity(scope))\n throw new WebstackLspError('LSP_STALE_SNAPSHOT', 'node handle is stale or belongs to another owner')\n if (!Number.isSafeInteger(maxChars) || maxChars < 1 || maxChars > MAX_SPAN_CHARS)\n throw new WebstackLspError('LSP_STRUCTURE_LIMIT', `maxChars must be between 1 and ${MAX_SPAN_CHARS}`)\n const full = record.source.text.slice(handle.startIndex, handle.endIndex)\n const codePoints = Array.from(full)\n const truncated = codePoints.length > maxChars\n const text = codePoints.slice(0, maxChars).join('')\n if (Buffer.byteLength(text, 'utf8') > MAX_STRUCTURE_RESPONSE_BYTES) throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'span result exceeds the response byte limit')\n return { status: truncated ? 'partial' : 'ok', text, truncated, range: handle.range }\n }\n\n releaseSnapshot(handle: string): void {\n for (const [nodeHandle, node] of this.nodeHandles) if (node.snapshotHandle === handle) this.nodeHandles.delete(nodeHandle)\n this.snapshotOwners.delete(handle)\n this.workers.releaseSnapshot(handle)\n }\n\n releaseSnapshotForOwner(scope: SnapshotScope, handle: string): void {\n if (this.snapshotOwners.get(handle) === scopeIdentity(scope)) this.releaseSnapshot(handle)\n }\n\n snapshotForNode(scope: SnapshotScope, nodeHandle: string): string {\n const record = this.nodeHandles.get(nodeHandle)\n if (!record || record.scopeKey !== scopeIdentity(scope)) throw new WebstackLspError('LSP_STALE_SNAPSHOT', 'node handle is stale or belongs to another owner')\n return record.snapshotHandle\n }\n\n releaseOwner(scope: SnapshotScope): void {\n const owner = scopeIdentity(scope)\n for (const [nodeHandle, node] of this.nodeHandles) if (node.scopeKey === owner) this.nodeHandles.delete(nodeHandle)\n for (const [snapshotHandle, snapshotOwner] of this.snapshotOwners) {\n if (snapshotOwner === owner) this.releaseSnapshot(snapshotHandle)\n }\n }\n\n capabilities(): Array<{ language: StructureLanguage; extensions: string[]; available: boolean; abiVersion: number | null; lastError?: string }> {\n return [\n this.capability('javascript', ['.js', '.jsx', '.mjs', '.cjs'], 15),\n this.capability('typescript', ['.ts', '.mts', '.cts'], 14),\n this.capability('tsx', ['.tsx'], 14),\n ]\n }\n\n async dispose(): Promise<void> { this.nodeHandles.clear(); this.snapshotOwners.clear(); await this.workers.dispose() }\n\n private async runMatches(language: StructureLanguage, record: SnapshotRecord, queryId: string, limit: number, range?: { startIndex: number; endIndex: number }, signal?: AbortSignal) {\n const querySource = getRegisteredQuery(language, queryId)\n if (!querySource) throw new WebstackLspError('LSP_STRUCTURE_UNSUPPORTED', `query ${queryId} is not registered for ${language}`)\n return this.runWorker(language, { operation: 'matches', language, text: record.source.text, querySource, limit, snapshotHandle: record.descriptor.handle, ...(range ?? {}) }, signal)\n }\n\n private capability(language: StructureLanguage, extensions: string[], abiVersion: number) {\n const lastError = this.parserFailures.get(language)\n return { language, extensions, available: !lastError, abiVersion, ...(lastError ? { lastError } : {}) }\n }\n\n private async runWorker(language: StructureLanguage, request: Parameters<StructureWorkerPool['execute']>[0], signal?: AbortSignal) {\n try {\n const result = await this.workers.execute(request, signal)\n this.parserFailures.delete(language)\n return result\n } catch (error) {\n if (error instanceof WebstackLspError && ['LSP_STRUCTURE_TIMEOUT', 'LSP_STRUCTURE_UNAVAILABLE'].includes(error.code))\n this.parserFailures.set(language, error.message.slice(0, 128))\n throw error\n }\n }\n\n private outlineResult(record: SnapshotRecord, declarations: StructureNode[], result: Awaited<ReturnType<StructureWorkerPool['execute']>>): StructureOutlineResult {\n const truncated = Boolean(result.truncated || declarations.length > MAX_OUTLINE)\n const selected = declarations.slice(0, MAX_OUTLINE)\n const jsonBytes = Buffer.byteLength(JSON.stringify(selected), 'utf8')\n if (jsonBytes > MAX_STRUCTURE_RESPONSE_BYTES) throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'outline result exceeds the response byte limit')\n return { status: result.status, handle: record.descriptor.handle, version: record.descriptor.version, declarations: selected, truncated, processed: selected.length, errors: publicErrors(result.errors) }\n }\n\n private node(record: SnapshotRecord, scope: SnapshotScope, kind: string, startIndex: number, endIndex: number, name?: string, childCount?: number, coordinates = new Utf16Coordinates(record.source.text)): StructureNode {\n if (this.nodeHandles.size >= MAX_NODE_HANDLES) throw new WebstackLspError('LSP_SNAPSHOT_LIMIT', 'node handle capacity is full; release a snapshot and retry')\n const handle = randomUUID()\n const range = coordinates.indicesToRange(startIndex, endIndex)\n this.nodeHandles.set(handle, { scopeKey: scopeIdentity(scope), snapshotHandle: record.descriptor.handle, startIndex, endIndex, kind, range })\n return { handle, kind: publicNodeKind(kind), range, ...(name ? { name } : {}), ...(childCount === undefined ? {} : { childCount }) }\n }\n}\n\nfunction positiveLimit(value: number | undefined, maximum: number, label: string): number {\n const limit = value ?? maximum\n if (!Number.isSafeInteger(limit) || limit < 1 || limit > maximum) throw new WebstackLspError('LSP_STRUCTURE_LIMIT', `${label} must be between 1 and ${maximum}`)\n return limit\n}\n\nfunction publicErrors(errors: StructureErrorSummary): StructureErrorSummary { return { ...errors } }\n\nfunction publicNodeKind(kind: string): string {\n return ({ function_declaration: 'function', class_declaration: 'class', interface_declaration: 'interface', type_alias_declaration: 'type', enum_declaration: 'enum', method_definition: 'method', variable_declarator: 'variable' } as Record<string, string>)[kind] ?? kind\n}\n","import { WebstackLspError } from '../errors.js'\nimport { DocumentSnapshotStore } from './snapshots.js'\nimport type { SnapshotRecord } from './snapshots.js'\nimport { StructureEngine, MAX_CAPTURES, MAX_OUTLINE, MAX_SPAN_CHARS, MAX_STRUCTURE_RESPONSE_BYTES } from './engine.js'\nimport type { CodeIntelligenceCapabilities, CodeIntelligenceToolServiceV1, SemanticQuery, SemanticResult, SnapshotScope, StructureEnclosingResult, StructureOutlineResult, StructureQueryResult, StructureSpanResult } from './types.js'\nimport type { CompletionResult, DiagnosticsResult, NavigationResult } from '../service.js'\n\nexport interface CodeIntelligenceServiceOptions {\n snapshots: DocumentSnapshotStore\n semanticQuery(scope: SnapshotScope, snapshot: SnapshotRecord, request: SemanticQuery, signal: AbortSignal): Promise<CompletionResult | DiagnosticsResult | NavigationResult>\n}\n\nexport class CodeIntelligenceRuntime implements CodeIntelligenceToolServiceV1 {\n readonly version = 1 as const\n readonly snapshot: CodeIntelligenceToolServiceV1['snapshot']\n readonly structure: CodeIntelligenceToolServiceV1['structure']\n readonly semantic: CodeIntelligenceToolServiceV1['semantic']\n private readonly store: DocumentSnapshotStore\n private readonly engine: StructureEngine\n\n constructor(options: CodeIntelligenceServiceOptions) {\n this.store = options.snapshots\n this.engine = new StructureEngine()\n\n this.snapshot = {\n open: async (scope, filePath, signal) => {\n const record = await this.store.open(scope, filePath, signal)\n try {\n const parser = await this.engine.inspect(record, signal)\n await this.store.current(scope, record.descriptor.handle, signal)\n return { status: 'ok', ...record.descriptor, parserAvailable: parser.available, parseErrors: parser.parseErrors }\n } catch (error) {\n this.store.release(scope, record.descriptor.handle)\n this.engine.releaseSnapshot(record.descriptor.handle)\n throw error\n }\n },\n release: async (scope, handle) => {\n const released = this.store.release(scope, handle)\n if (released) this.engine.releaseSnapshot(handle)\n return { released }\n },\n }\n\n this.structure = {\n outline: (scope, handle, request, signal) => this.withSnapshot(scope, handle, signal, record => this.engine.outline(record, scope, request, signal)) as Promise<StructureOutlineResult>,\n enclosing: (scope, handle, position, request, signal) => this.withSnapshot(scope, handle, signal, record => this.engine.enclosing(record, scope, position, request?.kinds, signal)) as Promise<StructureEnclosingResult>,\n query: (scope, handle, queryId, request, signal) => this.withSnapshot(scope, handle, signal, record => this.engine.query(record, scope, queryId, request, signal)) as Promise<StructureQueryResult>,\n span: (scope, nodeHandle, maxChars, signal) => this.span(scope, nodeHandle, maxChars, signal),\n }\n\n this.semantic = {\n query: async (scope, handle, request, signal) => {\n validateSemanticQuery(request)\n return this.withSnapshot(scope, handle, signal, async record => {\n const raw = await options.semanticQuery(scope, record, request, signal ?? new AbortController().signal)\n await this.store.current(scope, handle, signal)\n const bounded = limitSemanticResult(raw, request.maxResults ?? 200)\n const truncated = 'truncated' in bounded && Boolean(bounded.truncated)\n const status = semanticIsPartial(bounded) || truncated ? 'partial' : 'ok'\n const value: SemanticResult = { status, operation: request.operation, result: bounded, ...(truncated ? { truncated: true, omitted: 'omitted' in bounded && typeof bounded.omitted === 'number' ? bounded.omitted : 0 } : {}) }\n if (Buffer.byteLength(JSON.stringify(value), 'utf8') > MAX_STRUCTURE_RESPONSE_BYTES)\n throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'semantic result exceeds the response byte limit')\n return value\n }) as Promise<SemanticResult>\n },\n }\n }\n\n capabilities(): CodeIntelligenceCapabilities {\n const parsers = this.engine.capabilities().map(parser => ({\n ...parser,\n runtimeAbi: { minimum: 13, current: 15 },\n }))\n return {\n version: 1,\n parsers,\n sourceKind: 'disk',\n overlay: 'unavailable',\n limits: {\n maxDocumentBytes: Math.min(this.store.documentByteLimit, 2 * 1024 * 1024),\n maxCaptures: MAX_CAPTURES,\n maxOutline: MAX_OUTLINE,\n maxSpanChars: MAX_SPAN_CHARS,\n maxResponseBytes: MAX_STRUCTURE_RESPONSE_BYTES,\n },\n incrementalParsing: true,\n }\n }\n\n async releaseOwner(scope: SnapshotScope): Promise<number> {\n this.engine.releaseOwner(scope)\n return this.store.releaseOwner(scope)\n }\n\n async dispose(): Promise<void> { this.store.clear(); await this.engine.dispose() }\n\n private async span(scope: SnapshotScope, nodeHandle: string, maxChars = MAX_SPAN_CHARS, signal?: AbortSignal): Promise<StructureSpanResult> {\n const snapshotHandle = this.engine.snapshotForNode(scope, nodeHandle)\n return this.withSnapshot(scope, snapshotHandle, signal, record => this.engine.span(record, scope, nodeHandle, maxChars)) as Promise<StructureSpanResult>\n }\n\n private async withSnapshot<T>(scope: SnapshotScope, handle: string, signal: AbortSignal | undefined, execute: (record: Awaited<ReturnType<DocumentSnapshotStore['current']>>) => Promise<T>): Promise<T> {\n let record: Awaited<ReturnType<DocumentSnapshotStore['current']>>\n try { record = await this.store.current(scope, handle, signal) }\n catch (error) {\n if (error instanceof WebstackLspError && error.code === 'LSP_STALE_SNAPSHOT') this.engine.releaseSnapshotForOwner(scope, handle)\n throw error\n }\n try {\n const result = await execute(record)\n await this.store.current(scope, handle, signal)\n return result\n } catch (error) {\n if (error instanceof WebstackLspError && error.code === 'LSP_STALE_SNAPSHOT') this.engine.releaseSnapshotForOwner(scope, handle)\n throw error\n }\n }\n\n}\n\nexport function createCodeIntelligenceToolServiceV1(options: CodeIntelligenceServiceOptions): CodeIntelligenceToolServiceV1 {\n return new CodeIntelligenceRuntime(options)\n}\n\nfunction validateSemanticQuery(request: SemanticQuery): void {\n if (!request || !['definition', 'references', 'implementation', 'hover', 'diagnostics', 'completion'].includes(request.operation))\n throw new WebstackLspError('LSP_UNSUPPORTED_OPERATION', 'semantic operation is not supported')\n if (request.operation !== 'diagnostics' && !request.position)\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'semantic position is required for this operation')\n if (request.position && (!Number.isSafeInteger(request.position.line) || !Number.isSafeInteger(request.position.character) || request.position.line < 0 || request.position.character < 0))\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'semantic position must be a zero-based UTF-16 position')\n if (request.servers && (!Array.isArray(request.servers) || request.servers.length > 6 || request.servers.some(server => typeof server !== 'string' || server.length > 64)))\n throw new WebstackLspError('LSP_WORKSPACE_REQUIRED', 'semantic server filter is invalid')\n if (request.maxResults !== undefined && (!Number.isSafeInteger(request.maxResults) || request.maxResults < 1 || request.maxResults > 200))\n throw new WebstackLspError('LSP_STRUCTURE_LIMIT', 'maxResults must be between 1 and 200')\n}\n\nfunction semanticIsPartial(result: CompletionResult | DiagnosticsResult | NavigationResult): boolean {\n if ('diagnostics' in result) return Boolean(result.omittedServers?.length || result.truncated)\n if ('items' in result) return Boolean(result.truncated)\n if (result.kind === 'locations') return Boolean(result.truncated)\n return false\n}\n\nfunction limitSemanticResult(result: CompletionResult | DiagnosticsResult | NavigationResult, limit: number): CompletionResult | DiagnosticsResult | NavigationResult {\n if ('items' in result) {\n if (result.items.length <= limit) return result\n return { ...result, items: result.items.slice(0, limit), truncated: { items: result.items.length - limit, characters: 0 } }\n }\n if ('diagnostics' in result) {\n if (result.diagnostics.length <= limit) return result\n return { ...result, diagnostics: result.diagnostics.slice(0, limit), truncated: { diagnostics: result.diagnostics.length - limit, characters: 0 } }\n }\n if (result.kind === 'locations' && result.locations.length > limit)\n return { ...result, locations: result.locations.slice(0, limit), truncated: true, omitted: result.locations.length - limit }\n return result\n}\n"],"mappings":";;;;;;AAMA,MAAa,kBAAkB,IAAI;AACnC,MAAa,yBAAyB;AACtC,MAAa,qBAAqB,KAAK,OAAO;AAC9C,MAAa,+BAA+B,IAAI,OAAO;AAevD,MAAMA,qBAAwD;CAC5D,OAAO;CAAc,QAAQ;CAAc,QAAQ;CAAc,QAAQ;CACzE,OAAO;CAAc,QAAQ;CAAc,QAAQ;CACnD,QAAQ;CACT;AAED,IAAa,wBAAb,MAAmC;CACjC,AAAiB,0BAAU,IAAI,KAA6B;CAC5D,AAAiB,2BAAW,IAAI,KAA4B;CAE5D,YAAY,AAAiBC,YAA4B,AAAiBC,kBAA0B;EAAvE;EAA6C;;CAE1E,MAAM,KAAK,OAAsB,UAAkB,QAA+C;AAChG,gBAAc,MAAM;EACpB,MAAM,iBAAiB,sBAAsB,SAAS;AACtD,UAAQ,gBA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