@askdkc/dsh-lsp-server 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +8 -0
  2. package/lib/code-intelligence-DvhxPnpu.js +890 -0
  3. package/lib/code-intelligence-DvhxPnpu.js.map +1 -0
  4. package/lib/code-intelligence-contracts-CWXTofdI.js +8 -0
  5. package/lib/code-intelligence-contracts-CWXTofdI.js.map +1 -0
  6. package/lib/code-intelligence-contracts.js +3 -0
  7. package/lib/code-intelligence.js +5 -0
  8. package/lib/errors-DtyWAUi0.js.map +1 -1
  9. package/lib/extra-tool.js +135 -7
  10. package/lib/extra-tool.js.map +1 -1
  11. package/lib/grammars/manifest.json +40 -0
  12. package/lib/grammars/tree-sitter-javascript.wasm +0 -0
  13. package/lib/grammars/tree-sitter-tsx.wasm +0 -0
  14. package/lib/grammars/tree-sitter-typescript.wasm +0 -0
  15. package/lib/launch-ByUvgkVv.js.map +1 -1
  16. package/lib/parser-worker.mjs +200 -0
  17. package/lib/provider.js +639 -41
  18. package/lib/provider.js.map +1 -1
  19. package/lib/types/code-intelligence-contracts.d.ts +113 -0
  20. package/lib/types/code-intelligence.d.ts +5 -0
  21. package/lib/types/errors.d.ts +1 -1
  22. package/lib/types/extra-tool.d.ts +2 -1
  23. package/lib/types/provider.d.ts +4 -0
  24. package/lib/types/runtime/webstack-runtime.d.ts +13 -1
  25. package/lib/types/service.d.ts +16 -0
  26. package/lib/types/structure/code-intelligence.d.ts +23 -0
  27. package/lib/types/structure/coordinates.d.ts +14 -0
  28. package/lib/types/structure/engine.d.ts +49 -0
  29. package/lib/types/structure/protocol.d.ts +19 -0
  30. package/lib/types/structure/queries.d.ts +4 -0
  31. package/lib/types/structure/snapshots.d.ts +37 -0
  32. package/lib/types/structure/types.d.ts +147 -0
  33. package/lib/types/structure/worker-pool.d.ts +66 -0
  34. package/package.json +17 -4
@@ -0,0 +1,113 @@
1
+ /** Side-effect-free V1 protocol shared with protected Lisp adapters. */
2
+ export declare const CODE_INTELLIGENCE_SERVICE: "codeIntelligence";
3
+ export declare const CODE_INTELLIGENCE_VERSION: 1;
4
+ export type CodeStatus = 'ok' | 'partial' | 'unsupported' | 'unavailable' | 'stale' | 'cancelled' | 'timeout' | 'limit_exceeded';
5
+ export interface CodePosition {
6
+ line: number;
7
+ character: number;
8
+ }
9
+ export interface CodeRange {
10
+ start: CodePosition;
11
+ end: CodePosition;
12
+ }
13
+ export type CodeSemanticKind = 'definition' | 'references' | 'implementation' | 'hover' | 'diagnostics' | 'completion';
14
+ export type CodeQueryId = 'declarations' | 'calls' | 'imports';
15
+ export type CodeRequestV1 = {
16
+ method: 'capabilities';
17
+ } | {
18
+ method: 'snapshot.open';
19
+ path: string;
20
+ } | {
21
+ method: 'snapshot.release';
22
+ handle: string;
23
+ } | {
24
+ method: 'structure.outline';
25
+ handle: string;
26
+ range?: CodeRange;
27
+ limit?: number;
28
+ } | {
29
+ method: 'structure.enclosing';
30
+ handle: string;
31
+ position: CodePosition;
32
+ kinds?: string[];
33
+ } | {
34
+ method: 'structure.query';
35
+ handle: string;
36
+ queryId: CodeQueryId;
37
+ range?: CodeRange;
38
+ limit?: number;
39
+ } | {
40
+ method: 'structure.span';
41
+ nodeHandle: string;
42
+ maxChars?: number;
43
+ } | {
44
+ method: 'semantic.query';
45
+ handle: string;
46
+ kind: CodeSemanticKind;
47
+ position?: CodePosition;
48
+ limit?: number;
49
+ };
50
+ export interface CodeCapabilitiesV1 {
51
+ version: 1;
52
+ capabilities: Array<'snapshots' | 'structure' | 'semantic'>;
53
+ languages: string[];
54
+ queryIds: CodeQueryId[];
55
+ semanticReady: boolean;
56
+ sourceKinds: ['disk'];
57
+ languageCapabilities: Array<{
58
+ language: string;
59
+ structure: boolean;
60
+ semantic: CodeSemanticKind[];
61
+ semanticReady: boolean;
62
+ reason?: string;
63
+ }>;
64
+ limits: {
65
+ documentBytes: number;
66
+ captureItems: number;
67
+ outlineItems: number;
68
+ spanChars: number;
69
+ responseBytes: number;
70
+ files: number;
71
+ inputBytes: number;
72
+ outputBytes: number;
73
+ calls: number;
74
+ batchMs: number;
75
+ structureMs: number;
76
+ semanticMs: number;
77
+ };
78
+ }
79
+ export interface CodeResponseV1 {
80
+ protocol: 'code-intelligence/v1';
81
+ status: CodeStatus;
82
+ reason?: string;
83
+ sourceKind: 'disk';
84
+ freshness: 'pinned' | 'current' | 'unknown' | 'stale';
85
+ snapshotVersion?: string;
86
+ truncated: boolean;
87
+ omitted: number;
88
+ inputBytes?: number;
89
+ data?: unknown;
90
+ }
91
+ /** Authority comes from the host binding, never from code primitive arguments. */
92
+ export interface CodeHostBindingV1 {
93
+ owner: {
94
+ agentId: string;
95
+ sessionId: string;
96
+ };
97
+ workspaceRoot: string;
98
+ scope: object;
99
+ context: {
100
+ get(name: string, strict?: boolean): unknown;
101
+ };
102
+ assertCurrent(): void | Promise<void>;
103
+ }
104
+ export interface CodeLeaseV1 {
105
+ request(input: CodeRequestV1, signal: AbortSignal): Promise<CodeResponseV1>;
106
+ dispose(): Promise<void>;
107
+ }
108
+ export interface CodeIntelligenceServiceV1 {
109
+ version: 1;
110
+ capabilities: readonly ('snapshots' | 'structure' | 'semantic')[];
111
+ bind(binding: CodeHostBindingV1, signal: AbortSignal): Promise<CodeLeaseV1>;
112
+ dispose?(): Promise<void>;
113
+ }
@@ -0,0 +1,5 @@
1
+ export { CODE_INTELLIGENCE_SERVICE, CODE_INTELLIGENCE_VERSION } from './code-intelligence-contracts.js';
2
+ export type { CodeCapabilitiesV1, CodeHostBindingV1, CodeIntelligenceServiceV1, CodeLeaseV1, CodePosition, CodeQueryId, CodeRange, CodeRequestV1, CodeResponseV1, CodeSemanticKind, CodeStatus } from './code-intelligence-contracts.js';
3
+ export type { CodeIntelligenceCapabilities, CodeIntelligenceStatus, SemanticOperation, SemanticQuery, SemanticResult, SnapshotDescriptor, SnapshotOpenResult, SnapshotReleaseResult, SnapshotScope, SourceKind, StructureCapture, StructureEnclosingResult, StructureErrorSummary, StructureLanguage, StructureNode, StructureOutlineResult, StructureQueryResult, StructureSpanResult } from './structure/types.js';
4
+ export { createCodeIntelligenceToolServiceV1 } from './structure/code-intelligence.js';
5
+ export type { CodeIntelligenceToolServiceV1 } from './structure/types.js';
@@ -1,5 +1,5 @@
1
1
  import { LspError } from '@deepseek-ai/dsh-lsp';
2
- export type WebstackErrorCode = 'LSP_UNAVAILABLE' | 'LSP_UNSUPPORTED_OPERATION' | 'LSP_DISPOSED' | 'LSP_MALFORMED_RESPONSE' | 'LSP_CONFLICT' | 'LSP_WORKSPACE_REQUIRED' | 'LSP_WEBSTACK_CONFIG_INVALID';
2
+ export type WebstackErrorCode = 'LSP_UNAVAILABLE' | 'LSP_UNSUPPORTED_OPERATION' | 'LSP_DISPOSED' | 'LSP_MALFORMED_RESPONSE' | 'LSP_CONFLICT' | 'LSP_WORKSPACE_REQUIRED' | 'LSP_WEBSTACK_CONFIG_INVALID' | 'LSP_STALE_SNAPSHOT' | 'LSP_SNAPSHOT_LIMIT' | 'LSP_STRUCTURE_BUSY' | 'LSP_STRUCTURE_TIMEOUT' | 'LSP_STRUCTURE_LIMIT' | 'LSP_STRUCTURE_UNAVAILABLE' | 'LSP_STRUCTURE_UNSUPPORTED' | 'LSP_CODE_INTELLIGENCE_UNAVAILABLE';
3
3
  export declare class WebstackLspError extends LspError {
4
4
  readonly code: WebstackErrorCode;
5
5
  constructor(code: WebstackErrorCode, message: string, options?: ErrorOptions);
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
3
3
  import type { WebstackLspService } from './service.js';
4
+ import type { CodeIntelligenceToolServiceV1 } from './structure/types.js';
4
5
  export declare const name = "lsp_extra";
5
6
  export declare const inject: string[];
6
7
  export interface Config {
@@ -9,5 +10,5 @@ export interface Config {
9
10
  maxResultChars?: number;
10
11
  timeoutMs?: number;
11
12
  }
12
- export declare function createExtraTool(service: WebstackLspService, config?: Config): ToolDefinition;
13
+ export declare function createExtraTool(service: WebstackLspService, codeIntelligence?: CodeIntelligenceToolServiceV1, config?: Config): ToolDefinition;
13
14
  export declare function apply(ctx: Context, config?: Config): void;
@@ -2,6 +2,8 @@ import type { Context } from '@deepseek-ai/cordis';
2
2
  import type { LspProvider, LspProviderQuery, LspQueryResult } from '@deepseek-ai/dsh-lsp';
3
3
  import type { Config as PluginConfig, ResolvedConfig } from './config.js';
4
4
  import type { WebstackLspService } from './service.js';
5
+ import type { CodeIntelligenceServiceV1 } from './code-intelligence-contracts.js';
6
+ import type { CodeIntelligenceToolServiceV1 } from './structure/types.js';
5
7
  export type { LspProvider, LspProviderQuery, LspQueryResult };
6
8
  export type Config = PluginConfig;
7
9
  export declare const name = "lsp-webstack-provider";
@@ -9,6 +11,8 @@ export declare const inject: string[];
9
11
  declare module '@deepseek-ai/cordis' {
10
12
  interface Context {
11
13
  webstackLsp: WebstackLspService;
14
+ codeIntelligence: CodeIntelligenceServiceV1;
15
+ codeIntelligenceRuntime: CodeIntelligenceToolServiceV1;
12
16
  }
13
17
  }
14
18
  export declare const OUTER_EXTENSION_MAP: {
@@ -3,12 +3,18 @@ import type { SubprocessRuntime } from '@deepseek-ai/dsh-subprocess';
3
3
  import type { ResolvedConfig } from '../config.js';
4
4
  import { type HostFileSystem } from '../host/dsh.js';
5
5
  import type { CompletionRequest, CompletionResult, DiagnosticsRequest, DiagnosticsResult, WebstackLspStatus } from '../service.js';
6
+ import type { CodeIntelligenceServiceV1 } from '../code-intelligence-contracts.js';
7
+ import type { CodeIntelligenceToolServiceV1 } from '../structure/types.js';
6
8
  export type HostSubprocess = Pick<SubprocessRuntime, 'spawn' | 'resolveExecutable'>;
7
9
  export declare class WebstackLspRuntime {
8
10
  private readonly config;
9
11
  private readonly fs;
10
12
  private readonly subprocess;
11
13
  private readonly pool;
14
+ private readonly snapshots;
15
+ readonly codeIntelligence: CodeIntelligenceServiceV1;
16
+ readonly codeIntelligenceRuntime: CodeIntelligenceToolServiceV1;
17
+ private readonly semanticOperations;
12
18
  private readonly workspaces;
13
19
  private readonly lifetime;
14
20
  private readonly live;
@@ -16,12 +22,18 @@ export declare class WebstackLspRuntime {
16
22
  private readonly restarts;
17
23
  constructor(config: ResolvedConfig, fs: HostFileSystem, subprocess: HostSubprocess);
18
24
  navigation(request: LspProviderQuery, signal?: AbortSignal): Promise<LspQueryResult>;
25
+ private navigationFromSource;
19
26
  completion(request: CompletionRequest, signal?: AbortSignal): Promise<CompletionResult>;
27
+ private completionFromSource;
20
28
  diagnostics(request: DiagnosticsRequest, signal?: AbortSignal): Promise<DiagnosticsResult>;
21
- status(): Promise<WebstackLspStatus>;
29
+ private diagnosticsFromSource;
30
+ private semanticFromSnapshot;
31
+ status(signal?: AbortSignal): Promise<WebstackLspStatus>;
32
+ private codeCapabilities;
22
33
  dispose(): Promise<void>;
23
34
  private signal;
24
35
  private prepare;
36
+ private rememberWorkspace;
25
37
  private validatePosition;
26
38
  private useTailwind;
27
39
  private document;
@@ -43,6 +43,22 @@ export interface NormalizedCompletionItem {
43
43
  insertTextFormat?: number;
44
44
  deprecated?: boolean;
45
45
  }
46
+ export type NavigationResult = {
47
+ kind: 'locations';
48
+ locations: ReadonlyArray<{
49
+ uri: string;
50
+ range: LspRange;
51
+ }>;
52
+ resolvedWorkspaceUri: string;
53
+ truncated?: boolean;
54
+ omitted?: number;
55
+ } | {
56
+ kind: 'hover';
57
+ hover: {
58
+ contents: string;
59
+ range?: LspRange;
60
+ } | null;
61
+ };
46
62
  /** A skipped diagnostic query is unverified; an empty diagnostics array alone is not evidence of a clean file. */
47
63
  export interface DiagnosticsResult {
48
64
  skipped?: {
@@ -0,0 +1,23 @@
1
+ import { DocumentSnapshotStore } from './snapshots.js';
2
+ import type { SnapshotRecord } from './snapshots.js';
3
+ import type { CodeIntelligenceCapabilities, CodeIntelligenceToolServiceV1, SemanticQuery, SnapshotScope } from './types.js';
4
+ import type { CompletionResult, DiagnosticsResult, NavigationResult } from '../service.js';
5
+ export interface CodeIntelligenceServiceOptions {
6
+ snapshots: DocumentSnapshotStore;
7
+ semanticQuery(scope: SnapshotScope, snapshot: SnapshotRecord, request: SemanticQuery, signal: AbortSignal): Promise<CompletionResult | DiagnosticsResult | NavigationResult>;
8
+ }
9
+ export declare class CodeIntelligenceRuntime implements CodeIntelligenceToolServiceV1 {
10
+ readonly version: 1;
11
+ readonly snapshot: CodeIntelligenceToolServiceV1['snapshot'];
12
+ readonly structure: CodeIntelligenceToolServiceV1['structure'];
13
+ readonly semantic: CodeIntelligenceToolServiceV1['semantic'];
14
+ private readonly store;
15
+ private readonly engine;
16
+ constructor(options: CodeIntelligenceServiceOptions);
17
+ capabilities(): CodeIntelligenceCapabilities;
18
+ releaseOwner(scope: SnapshotScope): Promise<number>;
19
+ dispose(): Promise<void>;
20
+ private span;
21
+ private withSnapshot;
22
+ }
23
+ export declare function createCodeIntelligenceToolServiceV1(options: CodeIntelligenceServiceOptions): CodeIntelligenceToolServiceV1;
@@ -0,0 +1,14 @@
1
+ import type { LspPosition, LspRange } from '../service.js';
2
+ /** web-tree-sitter 0.27.1 exposes JS-string indices as UTF-16 code-unit offsets. */
3
+ export declare class Utf16Coordinates {
4
+ private readonly text;
5
+ private readonly lines;
6
+ constructor(text: string);
7
+ positionToIndex(position: LspPosition): number;
8
+ indexToPosition(index: number): LspPosition;
9
+ rangeToIndices(range: LspRange): {
10
+ startIndex: number;
11
+ endIndex: number;
12
+ };
13
+ indicesToRange(startIndex: number, endIndex: number): LspRange;
14
+ }
@@ -0,0 +1,49 @@
1
+ import { type SnapshotRecord } from './snapshots.js';
2
+ import { StructureWorkerPool } from './worker-pool.js';
3
+ import type { SnapshotScope, StructureEnclosingResult, StructureLanguage, StructureNode, StructureOutlineResult, StructureQueryResult, StructureSpanResult } from './types.js';
4
+ export declare const MAX_CAPTURES = 200;
5
+ export declare const MAX_OUTLINE = 100;
6
+ export declare const MAX_SPAN_CHARS = 8000;
7
+ export declare const MAX_STRUCTURE_RESPONSE_BYTES: number;
8
+ export declare class StructureEngine {
9
+ private readonly workers;
10
+ private readonly nodeHandles;
11
+ private readonly snapshotOwners;
12
+ private readonly parserFailures;
13
+ constructor(workers?: StructureWorkerPool);
14
+ inspect(record: SnapshotRecord, signal?: AbortSignal): Promise<{
15
+ available: boolean;
16
+ parseErrors: boolean;
17
+ reason?: string;
18
+ }>;
19
+ outline(record: SnapshotRecord, scope: SnapshotScope, options?: {
20
+ range?: StructureNode['range'];
21
+ limit?: number;
22
+ }, signal?: AbortSignal): Promise<StructureOutlineResult>;
23
+ enclosing(record: SnapshotRecord, scope: SnapshotScope, position: {
24
+ line: number;
25
+ character: number;
26
+ }, kinds?: string[], signal?: AbortSignal): Promise<StructureEnclosingResult>;
27
+ query(record: SnapshotRecord, scope: SnapshotScope, queryId: string, options?: {
28
+ range?: StructureNode['range'];
29
+ limit?: number;
30
+ }, signal?: AbortSignal): Promise<StructureQueryResult>;
31
+ span(record: SnapshotRecord, scope: SnapshotScope, nodeHandle: string, maxChars?: number): Promise<StructureSpanResult>;
32
+ releaseSnapshot(handle: string): void;
33
+ releaseSnapshotForOwner(scope: SnapshotScope, handle: string): void;
34
+ snapshotForNode(scope: SnapshotScope, nodeHandle: string): string;
35
+ releaseOwner(scope: SnapshotScope): void;
36
+ capabilities(): Array<{
37
+ language: StructureLanguage;
38
+ extensions: string[];
39
+ available: boolean;
40
+ abiVersion: number | null;
41
+ lastError?: string;
42
+ }>;
43
+ dispose(): Promise<void>;
44
+ private runMatches;
45
+ private capability;
46
+ private runWorker;
47
+ private outlineResult;
48
+ private node;
49
+ }
@@ -0,0 +1,19 @@
1
+ import type { CodeCapabilitiesV1, CodeHostBindingV1, CodeIntelligenceServiceV1, CodeLeaseV1 } from '../code-intelligence-contracts.js';
2
+ import type { CodeIntelligenceToolServiceV1 } from './types.js';
3
+ export interface CodeIntelligenceProtocolOptions {
4
+ backend: CodeIntelligenceToolServiceV1;
5
+ fs: unknown;
6
+ subprocess: unknown;
7
+ capabilities(signal: AbortSignal): Promise<CodeCapabilitiesV1>;
8
+ }
9
+ /** Host-bound V1 facade. Each lease owns its handles and cumulative evaluation budget. */
10
+ export declare class CodeIntelligenceProtocolService implements CodeIntelligenceServiceV1 {
11
+ private readonly options;
12
+ readonly version: 1;
13
+ readonly capabilities: readonly ["snapshots", "structure", "semantic"];
14
+ private readonly leases;
15
+ private closed;
16
+ constructor(options: CodeIntelligenceProtocolOptions);
17
+ bind(binding: CodeHostBindingV1, signal: AbortSignal): Promise<CodeLeaseV1>;
18
+ dispose(): Promise<void>;
19
+ }
@@ -0,0 +1,4 @@
1
+ import type { StructureLanguage } from './types.js';
2
+ export type RegisteredQueryId = 'declarations' | 'calls' | 'imports';
3
+ export declare function getRegisteredQuery(language: StructureLanguage, queryId: string): string | undefined;
4
+ export declare function isRegisteredQueryId(value: string): value is RegisteredQueryId;
@@ -0,0 +1,37 @@
1
+ import type { HostSource } from '../host/dsh.js';
2
+ import type { SnapshotDescriptor, SnapshotScope, StructureLanguage } from './types.js';
3
+ export declare const SNAPSHOT_TTL_MS: number;
4
+ export declare const SNAPSHOT_MAX_DOCUMENTS = 32;
5
+ export declare const SNAPSHOT_MAX_BYTES: number;
6
+ export declare const STRUCTURE_MAX_DOCUMENT_BYTES: number;
7
+ export interface SnapshotRecord {
8
+ readonly descriptor: SnapshotDescriptor;
9
+ readonly scopeKey: string;
10
+ readonly source: HostSource;
11
+ readonly previousSnapshotHandle?: string;
12
+ readonly openedAt: number;
13
+ lastUsedAt: number;
14
+ }
15
+ export type SnapshotReader = (workspaceRoot: string, filePath: string, maxBytes: number, signal?: AbortSignal) => Promise<HostSource>;
16
+ export declare class DocumentSnapshotStore {
17
+ private readonly readSource;
18
+ private readonly maxDocumentBytes;
19
+ private readonly records;
20
+ private readonly versions;
21
+ constructor(readSource: SnapshotReader, maxDocumentBytes: number);
22
+ open(scope: SnapshotScope, filePath: string, signal?: AbortSignal): Promise<SnapshotRecord>;
23
+ current(scope: SnapshotScope, handle: string, signal?: AbortSignal): Promise<SnapshotRecord>;
24
+ readFresh(scope: SnapshotScope, filePath: string, signal?: AbortSignal): Promise<HostSource>;
25
+ release(scope: SnapshotScope, handle: string): boolean;
26
+ releaseOwner(scope: SnapshotScope): number;
27
+ clear(): void;
28
+ get size(): number;
29
+ get documentByteLimit(): number;
30
+ private totalBytes;
31
+ private rememberVersion;
32
+ private evictExpired;
33
+ }
34
+ export declare function languageForPath(filePath: string): StructureLanguage | null;
35
+ export declare function validateScope(scope: SnapshotScope): void;
36
+ export declare function normalizeRelativePath(filePath: string): string;
37
+ export declare function scopeIdentity(scope: SnapshotScope): string;
@@ -0,0 +1,147 @@
1
+ import type { CompletionResult, DiagnosticsResult, LspPosition, LspRange, NavigationResult } from '../service.js';
2
+ export type StructureLanguage = 'javascript' | 'typescript' | 'tsx';
3
+ export type CodeIntelligenceStatus = 'ok' | 'partial' | 'unsupported' | 'unavailable' | 'stale' | 'cancelled' | 'timeout' | 'limit_exceeded';
4
+ export type SourceKind = 'disk' | 'overlay';
5
+ /** Values are created by the trusted host adapter, never from model arguments. */
6
+ export interface SnapshotScope {
7
+ ownerId: string;
8
+ sessionId: string;
9
+ workspaceRoot: string;
10
+ }
11
+ export interface SnapshotDescriptor {
12
+ handle: string;
13
+ version: number;
14
+ filePath: string;
15
+ language: StructureLanguage | null;
16
+ sourceKind: SourceKind;
17
+ contentHash: string;
18
+ sourceBytes: number;
19
+ }
20
+ export interface SnapshotOpenResult extends SnapshotDescriptor {
21
+ status: 'ok';
22
+ parserAvailable: boolean;
23
+ parseErrors: boolean;
24
+ }
25
+ export interface SnapshotReleaseResult {
26
+ released: boolean;
27
+ }
28
+ export interface StructureNode {
29
+ handle: string;
30
+ kind: string;
31
+ range: LspRange;
32
+ name?: string;
33
+ childCount?: number;
34
+ }
35
+ export interface StructureErrorSummary {
36
+ hasError: boolean;
37
+ errorNodes: number;
38
+ missingNodes: number;
39
+ truncated: boolean;
40
+ }
41
+ export interface StructureOutlineResult {
42
+ status: 'ok' | 'partial' | 'unsupported';
43
+ handle: string;
44
+ version: number;
45
+ declarations: StructureNode[];
46
+ truncated: boolean;
47
+ processed: number;
48
+ errors: StructureErrorSummary;
49
+ }
50
+ export interface StructureEnclosingResult {
51
+ status: 'ok' | 'partial' | 'unsupported';
52
+ handle: string;
53
+ version: number;
54
+ node?: StructureNode;
55
+ ancestors: StructureNode[];
56
+ errors?: StructureErrorSummary;
57
+ }
58
+ export interface StructureCapture {
59
+ capture: string;
60
+ kind: string;
61
+ range: LspRange;
62
+ nodeHandle: string;
63
+ name?: string;
64
+ }
65
+ export interface StructureQueryResult {
66
+ status: 'ok' | 'partial';
67
+ handle: string;
68
+ version: number;
69
+ queryId: string;
70
+ captures: StructureCapture[];
71
+ truncated: boolean;
72
+ processed: number;
73
+ errors: StructureErrorSummary;
74
+ }
75
+ export interface StructureSpanResult {
76
+ status: 'ok' | 'partial';
77
+ text: string;
78
+ truncated: boolean;
79
+ range: LspRange;
80
+ }
81
+ export type SemanticOperation = 'definition' | 'references' | 'implementation' | 'hover' | 'diagnostics' | 'completion';
82
+ export interface SemanticQuery {
83
+ operation: SemanticOperation;
84
+ position?: LspPosition;
85
+ severity?: 'all' | 'error' | 'warning';
86
+ servers?: string[];
87
+ maxResults?: number;
88
+ }
89
+ export interface SemanticResult {
90
+ status: 'ok' | 'partial' | 'unsupported' | 'unavailable' | 'stale' | 'cancelled' | 'timeout' | 'limit_exceeded';
91
+ operation: SemanticOperation;
92
+ result?: unknown;
93
+ truncated?: boolean;
94
+ omitted?: number;
95
+ }
96
+ export interface CodeIntelligenceCapabilities {
97
+ version: 1;
98
+ parsers: Array<{
99
+ language: StructureLanguage;
100
+ extensions: string[];
101
+ available: boolean;
102
+ abiVersion: number | null;
103
+ runtimeAbi: {
104
+ minimum: number;
105
+ current: number;
106
+ };
107
+ lastError?: string;
108
+ }>;
109
+ sourceKind: 'disk';
110
+ overlay: 'unavailable';
111
+ limits: {
112
+ maxDocumentBytes: number;
113
+ maxCaptures: number;
114
+ maxOutline: number;
115
+ maxSpanChars: number;
116
+ maxResponseBytes: number;
117
+ };
118
+ incrementalParsing: boolean;
119
+ }
120
+ export interface CodeIntelligenceToolServiceV1 {
121
+ readonly version: 1;
122
+ snapshot: {
123
+ open(scope: SnapshotScope, filePath: string, signal?: AbortSignal): Promise<SnapshotOpenResult>;
124
+ release(scope: SnapshotScope, handle: string): Promise<SnapshotReleaseResult>;
125
+ };
126
+ structure: {
127
+ outline(scope: SnapshotScope, handle: string, options?: {
128
+ range?: LspRange;
129
+ limit?: number;
130
+ }, signal?: AbortSignal): Promise<StructureOutlineResult>;
131
+ enclosing(scope: SnapshotScope, handle: string, position: LspPosition, options?: {
132
+ kinds?: string[];
133
+ }, signal?: AbortSignal): Promise<StructureEnclosingResult>;
134
+ query(scope: SnapshotScope, handle: string, queryId: string, options?: {
135
+ range?: LspRange;
136
+ limit?: number;
137
+ }, signal?: AbortSignal): Promise<StructureQueryResult>;
138
+ span(scope: SnapshotScope, nodeHandle: string, maxChars?: number, signal?: AbortSignal): Promise<StructureSpanResult>;
139
+ };
140
+ semantic: {
141
+ query(scope: SnapshotScope, handle: string, request: SemanticQuery, signal?: AbortSignal): Promise<SemanticResult>;
142
+ };
143
+ capabilities(): CodeIntelligenceCapabilities;
144
+ releaseOwner?(scope: SnapshotScope): Promise<number>;
145
+ dispose?(): Promise<void>;
146
+ }
147
+ export type SnapshotSemanticCallback = (scope: SnapshotScope, snapshot: SnapshotDescriptor, request: SemanticQuery, signal: AbortSignal) => Promise<CompletionResult | DiagnosticsResult | NavigationResult>;
@@ -0,0 +1,66 @@
1
+ import type { StructureLanguage } from './types.js';
2
+ export interface StructureWorkerRequest {
3
+ operation: 'matches' | 'enclosing' | 'inspect';
4
+ language: StructureLanguage;
5
+ text: string;
6
+ querySource: string;
7
+ limit: number;
8
+ snapshotHandle?: string;
9
+ previousSnapshotHandle?: string;
10
+ startIndex?: number;
11
+ endIndex?: number;
12
+ index?: number;
13
+ kinds?: string[];
14
+ }
15
+ export interface WorkerNodeSummary {
16
+ kind: string;
17
+ startIndex: number;
18
+ endIndex: number;
19
+ startPosition: {
20
+ row: number;
21
+ column: number;
22
+ };
23
+ endPosition: {
24
+ row: number;
25
+ column: number;
26
+ };
27
+ nameStartIndex?: number;
28
+ nameEndIndex?: number;
29
+ childCount: number;
30
+ }
31
+ export interface WorkerErrorSummary {
32
+ hasError: boolean;
33
+ errorNodes: number;
34
+ missingNodes: number;
35
+ truncated: boolean;
36
+ }
37
+ export interface WorkerMatch {
38
+ captures: Array<{
39
+ name: string;
40
+ } & WorkerNodeSummary>;
41
+ }
42
+ export interface StructureWorkerResult {
43
+ status: 'ok' | 'partial';
44
+ abiVersion?: number;
45
+ reusedTree?: boolean;
46
+ incremental?: boolean;
47
+ matches?: WorkerMatch[];
48
+ nodes?: WorkerNodeSummary[];
49
+ truncated?: boolean;
50
+ errors: WorkerErrorSummary;
51
+ }
52
+ /** CPU-bound parsing runs off the event loop; cancellation terminates the active worker. */
53
+ export declare class StructureWorkerPool {
54
+ private readonly slots;
55
+ private readonly queue;
56
+ private disposed;
57
+ execute(request: StructureWorkerRequest, signal?: AbortSignal): Promise<StructureWorkerResult>;
58
+ dispose(): Promise<void>;
59
+ releaseSnapshot(snapshotHandle: string): void;
60
+ get queued(): number;
61
+ get active(): number;
62
+ private pump;
63
+ private createWorker;
64
+ private retire;
65
+ private finishTask;
66
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askdkc/dsh-lsp-server",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Composite read-only LSP provider for DeepSeek Harness web stacks",
5
5
  "type": "module",
6
6
  "main": "./lib/provider.js",
@@ -18,6 +18,14 @@
18
18
  "types": "./lib/types/extra-tool.d.ts",
19
19
  "default": "./lib/extra-tool.js"
20
20
  },
21
+ "./code-intelligence": {
22
+ "types": "./lib/types/code-intelligence.d.ts",
23
+ "default": "./lib/code-intelligence.js"
24
+ },
25
+ "./code-intelligence-contracts": {
26
+ "types": "./lib/types/code-intelligence-contracts.d.ts",
27
+ "default": "./lib/code-intelligence-contracts.js"
28
+ },
21
29
  "./package.json": "./package.json",
22
30
  "./lsp": {
23
31
  "types": "./lib/types/lsp.d.ts",
@@ -45,7 +53,7 @@
45
53
  }
46
54
  },
47
55
  "scripts": {
48
- "build": "tsdown && tsc -p tsconfig.build.json",
56
+ "build": "tsdown && tsc -p tsconfig.build.json && node scripts/copy-structure-assets.mjs",
49
57
  "typecheck": "tsc --noEmit",
50
58
  "test": "vitest run",
51
59
  "test:e2e": "vitest run --config vitest.e2e.config.ts",
@@ -61,7 +69,8 @@
61
69
  "svelte-language-server": "0.17.15",
62
70
  "typescript": "5.7.3",
63
71
  "typescript-language-server": "4.3.3",
64
- "vscode-langservers-extracted": "4.10.0"
72
+ "vscode-langservers-extracted": "4.10.0",
73
+ "web-tree-sitter": "0.27.1"
65
74
  },
66
75
  "peerDependencies": {
67
76
  "@deepseek-ai/cordis": "~4.0.4",
@@ -96,6 +105,8 @@
96
105
  "@types/node": "22.10.5",
97
106
  "tailwindcss-v3": "npm:tailwindcss@3.4.17",
98
107
  "tailwindcss-v4": "npm:tailwindcss@4.1.13",
108
+ "tree-sitter-javascript": "0.25.0",
109
+ "tree-sitter-typescript": "0.23.2",
99
110
  "tsdown": "0.15.0",
100
111
  "typescript": "5.7.3",
101
112
  "vitest": "4.1.11"
@@ -111,7 +122,9 @@
111
122
  "overrides": {
112
123
  "tsdown>rolldown": "1.0.0-beta.38",
113
124
  "svelte-language-server>svelte": "5.55.7",
114
- "vite": "6.4.3"
125
+ "vite": "6.4.3",
126
+ "source-map-js": "1.2.2",
127
+ "postcss-selector-parser": "7.1.6"
115
128
  }
116
129
  },
117
130
  "license": "MIT",