@akira-tl/forgerelay 0.4.2 → 0.4.3

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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable ForgeRelay changes are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.4.3] - 2026-08-11
8
+
9
+ ### Added
10
+
11
+ - Added `documentSymbols` code intelligence with hierarchy-preserving normalization for LSP `DocumentSymbol` trees and flat handling for legacy `SymbolInformation` responses.
12
+ - Added bounded `workspaceSymbols` semantic search over one selected Language service, with normalized flat symbol metadata and External location handling.
13
+
14
+ ### Changed
15
+
16
+ - Symbol collection limits reuse the 100 default / 1000 hard maximum budget. Document-symbol limits count tree nodes while preserving required ancestors; workspace-symbol results expose `returned`, `truncated`, and known `total` like references.
17
+ - Workspace-symbol requests use a workspace-relative `path` to select and synchronize the Language project/service before applying the project-wide `query`; ForgeRelay does not silently merge nested Language services.
18
+
7
19
  ## [0.4.2] - 2026-08-11
8
20
 
9
21
  ### Added
@@ -4,10 +4,12 @@ Use the `code.intelligence` Capability for read-only semantic code navigation ba
4
4
 
5
5
  ForgeRelay does not install Language servers. It discovers supported executables when available and accepts explicit definitions from the global ForgeRelay config or `<workspace>/.forgerelay/language-servers.json`. Project definitions override global definitions, and global definitions override built-in discovery. An explicit definition may disable discovery with `enabled: false`.
6
6
 
7
- ForgeRelay 0.4.2 supports `definition`, `hover`, and `references`. Position-based operations accept a workspace-relative source `path` plus 1-based `line` and `column` values. Columns are Unicode code-point positions; ForgeRelay converts them to the position encoding negotiated with the Language server.
7
+ ForgeRelay 0.4.3 supports `definition`, `hover`, `references`, `documentSymbols`, and `workspaceSymbols`. Position-based operations accept a workspace-relative source `path` plus 1-based `line` and `column` values. `documentSymbols` needs only `path` and an optional bounded `limit`. `workspaceSymbols` uses `path` to select the Language project/service and accepts a `query` plus optional `limit`; it does not merge multiple nested Language services. Columns are Unicode code-point positions; ForgeRelay converts them to the position encoding negotiated with the Language server.
8
8
 
9
9
  Code-intelligence results use ForgeRelay-owned shapes rather than raw LSP wire types. Definition returns normalized locations. Hover returns one `contents` string, an optional legacy `language`, and an optional ForgeRelay-normalized `range`; plaintext, Markdown `MarkupContent`, and supported legacy `MarkedString` payloads are normalized before reaching the Agent. References uses the same normalized location shape, defaults to `limit: 100`, and accepts limits up to 1000. Its result reports `returned`, `truncated`, and `total` when the complete Language-server response makes the total known.
10
10
 
11
+ Document symbols preserve hierarchical server responses as a tree and keep flat `SymbolInformation` responses flat. Names, stable symbol-kind names, ranges, selection ranges, details, container names, and children are normalized without exposing LSP union types. Workspace symbols are always returned as a flat list with stable symbol metadata and normalized locations. Symbol limits use the same default 100 / hard maximum 1000 collection budget; document-symbol limits count total tree nodes, while workspace-symbol results report the server response total directly when known.
12
+
11
13
  Semantic locations may identify External code locations outside the Workspace, but that does not expand ForgeRelay's allowed roots or grant the file tools permission to read those paths.
12
14
 
13
15
  Language-server definitions use structured process configuration rather than shell command strings. A project configuration entry may contain `command`, `args`, `env`, `languages`, `extensions`, `languageIdByExtension`, `projectMarkers`, and `enabled` fields. Use `languageIdByExtension` when one server definition covers multiple language IDs whose extensions do not map one-to-one by array position. The server command is launched directly without a shell.
@@ -129,6 +129,17 @@ export function createCapabilityRegistry(dependencies) {
129
129
  ...positionInput,
130
130
  limit: z.number().int().min(1).max(MAX_CODE_INTELLIGENCE_RESULT_LIMIT).optional(),
131
131
  }).strict(),
132
+ z.object({
133
+ operation: z.literal("documentSymbols"),
134
+ path: z.string().min(1),
135
+ limit: z.number().int().min(1).max(MAX_CODE_INTELLIGENCE_RESULT_LIMIT).optional(),
136
+ }).strict(),
137
+ z.object({
138
+ operation: z.literal("workspaceSymbols"),
139
+ path: z.string().min(1),
140
+ query: z.string(),
141
+ limit: z.number().int().min(1).max(MAX_CODE_INTELLIGENCE_RESULT_LIMIT).optional(),
142
+ }).strict(),
132
143
  ]);
133
144
  return new CapabilityRegistry([
134
145
  {
@@ -3,12 +3,13 @@ import { readFile, realpath } from "node:fs/promises";
3
3
  import { basename, resolve } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import { createMessageConnection } from "vscode-jsonrpc/node";
6
- import { DefinitionRequest, DidChangeTextDocumentNotification, DidCloseTextDocumentNotification, DidOpenTextDocumentNotification, ExitNotification, HoverRequest, InitializeRequest, ReferencesRequest, InitializedNotification, MarkupKind, PositionEncodingKind, ShutdownRequest, TextDocumentSyncKind, } from "vscode-languageserver-protocol";
6
+ import { DefinitionRequest, DocumentSymbolRequest, DidChangeTextDocumentNotification, DidCloseTextDocumentNotification, DidOpenTextDocumentNotification, ExitNotification, HoverRequest, InitializeRequest, ReferencesRequest, InitializedNotification, MarkupKind, PositionEncodingKind, ShutdownRequest, TextDocumentSyncKind, WorkspaceSymbolRequest, } from "vscode-languageserver-protocol";
7
7
  import { LanguageServerConfigurationError, } from "./language-server-config.js";
8
8
  import { terminateProcessTree } from "../process-platform.js";
9
9
  import { CodeIntelligenceError } from "./code-intelligence-error.js";
10
10
  import { DEFAULT_CODE_INTELLIGENCE_RESULT_LIMIT } from "./code-intelligence-types.js";
11
11
  import { normalizeHoverContents } from "./normalization/hover.js";
12
+ import { normalizeDocumentSymbols, normalizeWorkspaceSymbols, } from "./normalization/symbols.js";
12
13
  import { isWithin, locationEntries, normalizeLocations, workspaceDisplayPath, } from "./normalization/locations.js";
13
14
  import { lspPositionFromUser, rangeFromLsp, wholeDocumentRange } from "./position-encoding.js";
14
15
  export { CodeIntelligenceError } from "./code-intelligence-error.js";
@@ -147,6 +148,54 @@ export class LanguageService {
147
148
  throw new CodeIntelligenceError("code.server_crashed", `Language server ${this.project.definition.id} failed: ${errorMessage(error)}${this.stderrSuffix()}`);
148
149
  }
149
150
  }
151
+ async documentSymbols(input) {
152
+ try {
153
+ await this.ensureStarted();
154
+ if (!this.capabilities?.documentSymbolProvider) {
155
+ throw new CodeIntelligenceError("code.operation_unsupported", `Language server ${this.project.definition.id} does not advertise document-symbol support.`);
156
+ }
157
+ const sourcePath = await workspaceSourcePath(this.workspaceRoot, input.path);
158
+ const document = await this.syncDocument(sourcePath);
159
+ const response = await withTimeout(this.connection.sendRequest(DocumentSymbolRequest.type, {
160
+ textDocument: { uri: document.uri },
161
+ }), this.policy.requestTimeoutMs, () => new CodeIntelligenceError("code.request_timeout", `Document-symbol request timed out for ${input.path}.`));
162
+ const normalized = normalizeDocumentSymbols(response, document.text, this.positionEncoding, input.limit ?? DEFAULT_CODE_INTELLIGENCE_RESULT_LIMIT);
163
+ return {
164
+ operation: "documentSymbols",
165
+ selectedServer: this.project.definition.id,
166
+ projectRoot: workspaceDisplayPath(this.workspaceRoot, this.project.projectRoot),
167
+ ...normalized,
168
+ };
169
+ }
170
+ catch (error) {
171
+ if (error instanceof CodeIntelligenceError)
172
+ throw error;
173
+ throw new CodeIntelligenceError("code.server_crashed", `Language server ${this.project.definition.id} failed: ${errorMessage(error)}${this.stderrSuffix()}`);
174
+ }
175
+ }
176
+ async workspaceSymbols(input) {
177
+ try {
178
+ await this.ensureStarted();
179
+ if (!this.capabilities?.workspaceSymbolProvider) {
180
+ throw new CodeIntelligenceError("code.operation_unsupported", `Language server ${this.project.definition.id} does not advertise workspace-symbol support.`);
181
+ }
182
+ const sourcePath = await workspaceSourcePath(this.workspaceRoot, input.path);
183
+ await this.syncDocument(sourcePath);
184
+ const response = await withTimeout(this.connection.sendRequest(WorkspaceSymbolRequest.type, { query: input.query }), this.policy.requestTimeoutMs, () => new CodeIntelligenceError("code.request_timeout", `Workspace-symbol request timed out for ${JSON.stringify(input.query)}.`));
185
+ const normalized = await normalizeWorkspaceSymbols(response, this.workspaceRoot, this.positionEncoding, input.limit ?? DEFAULT_CODE_INTELLIGENCE_RESULT_LIMIT);
186
+ return {
187
+ operation: "workspaceSymbols",
188
+ selectedServer: this.project.definition.id,
189
+ projectRoot: workspaceDisplayPath(this.workspaceRoot, this.project.projectRoot),
190
+ ...normalized,
191
+ };
192
+ }
193
+ catch (error) {
194
+ if (error instanceof CodeIntelligenceError)
195
+ throw error;
196
+ throw new CodeIntelligenceError("code.server_crashed", `Language server ${this.project.definition.id} failed: ${errorMessage(error)}${this.stderrSuffix()}`);
197
+ }
198
+ }
150
199
  async shutdown() {
151
200
  if (this.closed)
152
201
  return;
@@ -251,6 +300,9 @@ export class LanguageService {
251
300
  workspace: {
252
301
  workspaceFolders: true,
253
302
  configuration: true,
303
+ symbol: {
304
+ dynamicRegistration: false,
305
+ },
254
306
  },
255
307
  textDocument: {
256
308
  synchronization: {
@@ -268,6 +320,10 @@ export class LanguageService {
268
320
  references: {
269
321
  dynamicRegistration: false,
270
322
  },
323
+ documentSymbol: {
324
+ dynamicRegistration: false,
325
+ hierarchicalDocumentSymbolSupport: true,
326
+ },
271
327
  },
272
328
  },
273
329
  };
@@ -0,0 +1,90 @@
1
+ import { SymbolKind, } from "vscode-languageserver-protocol";
2
+ import { CodeIntelligenceError } from "../code-intelligence-error.js";
3
+ import { normalizeLocations } from "./locations.js";
4
+ import { rangeFromLsp } from "../position-encoding.js";
5
+ export function normalizeDocumentSymbols(response, text, encoding, limit) {
6
+ if (!response || response.length === 0) {
7
+ return { hierarchical: true, symbols: [], returned: 0, truncated: false, total: 0 };
8
+ }
9
+ if (isFlatSymbolInformation(response[0])) {
10
+ const flat = response;
11
+ const selected = flat.slice(0, limit).map((symbol) => ({
12
+ name: symbol.name,
13
+ kind: symbolKindName(symbol.kind),
14
+ ...(symbol.containerName ? { containerName: symbol.containerName } : {}),
15
+ range: rangeFromLsp(text, symbol.location.range, encoding),
16
+ }));
17
+ return {
18
+ hierarchical: false,
19
+ symbols: selected,
20
+ returned: selected.length,
21
+ truncated: flat.length > selected.length,
22
+ total: flat.length,
23
+ };
24
+ }
25
+ const hierarchical = response;
26
+ const total = countDocumentSymbols(hierarchical);
27
+ const budget = { remaining: limit, returned: 0 };
28
+ const symbols = takeDocumentSymbols(hierarchical, text, encoding, budget);
29
+ return {
30
+ hierarchical: true,
31
+ symbols,
32
+ returned: budget.returned,
33
+ truncated: total > budget.returned,
34
+ total,
35
+ };
36
+ }
37
+ function takeDocumentSymbols(symbols, text, encoding, budget) {
38
+ const normalized = [];
39
+ for (const symbol of symbols) {
40
+ if (budget.remaining <= 0)
41
+ break;
42
+ budget.remaining -= 1;
43
+ budget.returned += 1;
44
+ const children = symbol.children?.length
45
+ ? takeDocumentSymbols(symbol.children, text, encoding, budget)
46
+ : [];
47
+ normalized.push({
48
+ name: symbol.name,
49
+ kind: symbolKindName(symbol.kind),
50
+ ...(symbol.detail ? { detail: symbol.detail } : {}),
51
+ range: rangeFromLsp(text, symbol.range, encoding),
52
+ selectionRange: rangeFromLsp(text, symbol.selectionRange, encoding),
53
+ ...(children.length ? { children } : {}),
54
+ });
55
+ }
56
+ return normalized;
57
+ }
58
+ function countDocumentSymbols(symbols) {
59
+ return symbols.reduce((total, symbol) => total + 1 + (symbol.children ? countDocumentSymbols(symbol.children) : 0), 0);
60
+ }
61
+ function isFlatSymbolInformation(symbol) {
62
+ return "location" in symbol;
63
+ }
64
+ export async function normalizeWorkspaceSymbols(response, workspaceRoot, encoding, limit) {
65
+ const all = response ?? [];
66
+ const selected = all.slice(0, limit);
67
+ const locationEntries = selected.map((symbol) => {
68
+ if (!("range" in symbol.location)) {
69
+ throw new CodeIntelligenceError("code.result_outside_policy", `Language server returned unresolved workspace symbol ${symbol.name} without a range.`);
70
+ }
71
+ return { uri: symbol.location.uri, range: symbol.location.range };
72
+ });
73
+ const locations = await normalizeLocations(locationEntries, workspaceRoot, encoding);
74
+ const symbols = selected.map((symbol, index) => ({
75
+ name: symbol.name,
76
+ kind: symbolKindName(symbol.kind),
77
+ ...(symbol.containerName ? { containerName: symbol.containerName } : {}),
78
+ location: locations[index],
79
+ }));
80
+ return {
81
+ symbols,
82
+ returned: symbols.length,
83
+ truncated: all.length > symbols.length,
84
+ total: all.length,
85
+ };
86
+ }
87
+ export function symbolKindName(kind) {
88
+ const entry = Object.entries(SymbolKind).find(([, value]) => value === kind);
89
+ return entry ? entry[0].toLowerCase() : `unknown:${kind}`;
90
+ }
@@ -56,6 +56,10 @@ export class CodeIntelligenceManager {
56
56
  return await service.hover(input);
57
57
  case "references":
58
58
  return await service.references(input);
59
+ case "documentSymbols":
60
+ return await service.documentSymbols(input);
61
+ case "workspaceSymbols":
62
+ return await service.workspaceSymbols(input);
59
63
  }
60
64
  }
61
65
  finally {
@@ -154,16 +154,21 @@ force a Host to invalidate its cached schema.
154
154
  ### LSP code intelligence
155
155
 
156
156
  ForgeRelay advertises `code.intelligence` through the Capability Gateway; it does
157
- not add language-specific top-level MCP tools. ForgeRelay 0.4.2 supports
158
- `definition`, `hover`, and `references`. Position-based operations accept the same
159
- workspace-relative source position. Hover results normalize plaintext, Markdown,
160
- and supported legacy LSP payloads into one `contents` string with optional
161
- `language` and normalized `range` metadata. References use the same normalized
162
- location shape as definition, default to 100 returned locations, and accept a
163
- `limit` from 1 through 1000; results report `returned`, `truncated`, and the real
164
- `total` when the complete Language-server response makes it known. Language Servers
165
- are external dependencies: ForgeRelay may discover an executable already installed
166
- on the machine, but it never downloads or installs one automatically.
157
+ not add language-specific top-level MCP tools. ForgeRelay 0.4.3 supports
158
+ `definition`, `hover`, `references`, `documentSymbols`, and `workspaceSymbols`.
159
+ Position-based operations accept the same workspace-relative source position. Hover
160
+ results normalize plaintext, Markdown, and supported legacy LSP payloads into one
161
+ `contents` string with optional `language` and normalized `range` metadata.
162
+ References use the same normalized location shape as definition, default to 100
163
+ returned locations, and accept a `limit` from 1 through 1000. Document symbols use
164
+ `path` plus optional `limit`, preserve server hierarchy when present, and keep flat
165
+ legacy symbol responses flat. Workspace symbols use `path` to select the Language
166
+ project/service, then apply a `query` with an optional bounded `limit`; ForgeRelay
167
+ does not silently merge results from multiple nested Language services. Bounded
168
+ collection results report `returned`, `truncated`, and the real `total` when the
169
+ complete Language-server response makes it known. Language Servers are external
170
+ dependencies: ForgeRelay may discover an executable already installed on the
171
+ machine, but it never downloads or installs one automatically.
167
172
 
168
173
  Effective Language-server definitions resolve in this order:
169
174
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akira-tl/forgerelay",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Local development control plane for MCP coding agents.",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/Akira-TL/forgerelay#readme",
@@ -42,7 +42,7 @@
42
42
  "debug:accept": "node scripts/debug/accept.mjs",
43
43
  "postinstall": "node scripts/fix-node-pty-permissions.mjs",
44
44
  "start": "node dist/cli.js serve",
45
- "test": "tsx src/config.test.ts && tsx src/lsp/language-server-config.test.ts && tsx src/lsp/normalization/hover.test.ts && tsx src/lsp/references.server.test.ts && tsx src/logger.test.ts && tsx src/proxy-trust.test.ts && tsx src/mcp-app-template.test.ts && tsx src/hooks.test.ts && tsx src/capability-registry.test.ts && tsx src/mcp/server-instructions.test.ts && tsx src/request-meta.test.ts && tsx src/incoming-artifacts.test.ts && tsx src/artifact-download.test.ts && tsx src/ui/card-types.test.ts && tsx src/ui/patch-display.test.ts && tsx src/ui/tool-display.test.ts && tsx src/apply-patch.test.ts && tsx src/process-platform.test.ts && tsx src/process-sessions.test.ts && tsx src/mcp-sessions.test.ts && tsx src/server-shutdown.test.ts && tsx src/local-agent-runtime.test.ts && tsx src/local-agent-adapters.test.ts && tsx src/local-agent-availability.test.ts && tsx src/local-agent-profiles.test.ts && tsx src/local-agent-targets.test.ts && tsx src/local-agent-store.test.ts && tsx src/roots.test.ts && tsx src/file-mutations.test.ts && tsx src/skills.test.ts && tsx src/workspace-store.test.ts && tsx src/workspaces.test.ts && tsx src/workspace-conversation.test.ts && tsx src/review-checkpoints.test.ts && tsx src/lsp/code-intelligence.server.test.ts && tsx src/server.test.ts && tsx src/oauth-store.test.ts && tsx src/cli.test.ts",
45
+ "test": "tsx src/config.test.ts && tsx src/lsp/language-server-config.test.ts && tsx src/lsp/normalization/hover.test.ts && tsx src/lsp/references.server.test.ts && tsx src/lsp/operations/document-symbols.server.test.ts && tsx src/lsp/operations/workspace-symbols.server.test.ts && tsx src/logger.test.ts && tsx src/proxy-trust.test.ts && tsx src/mcp-app-template.test.ts && tsx src/hooks.test.ts && tsx src/capability-registry.test.ts && tsx src/mcp/server-instructions.test.ts && tsx src/request-meta.test.ts && tsx src/incoming-artifacts.test.ts && tsx src/artifact-download.test.ts && tsx src/ui/card-types.test.ts && tsx src/ui/patch-display.test.ts && tsx src/ui/tool-display.test.ts && tsx src/apply-patch.test.ts && tsx src/process-platform.test.ts && tsx src/process-sessions.test.ts && tsx src/mcp-sessions.test.ts && tsx src/server-shutdown.test.ts && tsx src/local-agent-runtime.test.ts && tsx src/local-agent-adapters.test.ts && tsx src/local-agent-availability.test.ts && tsx src/local-agent-profiles.test.ts && tsx src/local-agent-targets.test.ts && tsx src/local-agent-store.test.ts && tsx src/roots.test.ts && tsx src/file-mutations.test.ts && tsx src/skills.test.ts && tsx src/workspace-store.test.ts && tsx src/workspaces.test.ts && tsx src/workspace-conversation.test.ts && tsx src/review-checkpoints.test.ts && tsx src/lsp/code-intelligence.server.test.ts && tsx src/server.test.ts && tsx src/oauth-store.test.ts && tsx src/cli.test.ts",
46
46
  "typecheck": "tsc -p tsconfig.json --noEmit",
47
47
  "release:check": "node scripts/release-version.mjs check",
48
48
  "release:tag-check": "node scripts/release-version.mjs tag",
@@ -336,13 +336,19 @@ try {
336
336
  assert.ok(Array.isArray(codeIntelligenceSchema.oneOf));
337
337
  assert.deepEqual(
338
338
  codeIntelligenceSchema.oneOf.map((variant) => variant.properties.operation.const),
339
- ["definition", "hover", "references"],
339
+ ["definition", "hover", "references", "documentSymbols", "workspaceSymbols"],
340
340
  );
341
- const referencesSchema = codeIntelligenceSchema.oneOf.find(
342
- (variant) => variant.properties.operation.const === "references",
341
+ for (const operation of ["references", "documentSymbols", "workspaceSymbols"]) {
342
+ const boundedSchema = codeIntelligenceSchema.oneOf.find(
343
+ (variant) => variant.properties.operation.const === operation,
344
+ );
345
+ assert.equal(boundedSchema.properties.limit.minimum, 1);
346
+ assert.equal(boundedSchema.properties.limit.maximum, 1000);
347
+ }
348
+ const workspaceSymbolsSchema = codeIntelligenceSchema.oneOf.find(
349
+ (variant) => variant.properties.operation.const === "workspaceSymbols",
343
350
  );
344
- assert.equal(referencesSchema.properties.limit.minimum, 1);
345
- assert.equal(referencesSchema.properties.limit.maximum, 1000);
351
+ assert.ok(workspaceSymbolsSchema.required.includes("query"));
346
352
  if (process.platform === "linux") {
347
353
  const describedArtifact = callTool(oauth.accessToken, sessionId, 82, "capability", {
348
354
  workspaceId,