codemode-lsp 0.1.2 → 0.1.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/README.md CHANGED
@@ -72,7 +72,10 @@ The API surface is 16 functions plus `getDiagnostics`: 8 read ops (`readFile`,
72
72
  `deleteSymbol`, `writeFile`, `deleteFile`). Symbols are addressed by
73
73
  slash-separated paths (`MyClass/myMethod`) discovered via `getSymbols`. The
74
74
  full type definitions are embedded in the tool description, generated straight
75
- from the source (`bun run generate:types`).
75
+ from the source (`bun run generate:types`). If a client truncates the
76
+ description, the script `await lsp.help()` returns the complete reference —
77
+ the description's first lines advertise this, so an agent can always recover
78
+ the full API without probing.
76
79
 
77
80
  See `PRD.md` for the complete spec.
78
81
 
package/dist/index.js CHANGED
@@ -46274,6 +46274,8 @@ async function runSandbox(code, options) {
46274
46274
  };
46275
46275
  const opNames = options.readonly ? [...READ_OP_NAMES] : [...READ_OP_NAMES, ...WRITE_OP_NAMES];
46276
46276
  sandbox.lsp = buildTracedLsp(options.lsp, trace, makeSandboxError, wrapAsync, opNames);
46277
+ const helpText = options.helpText ?? "No extended help is available; the tool description is the full reference.";
46278
+ sandbox.lsp.help = wrapAsync(async () => helpText);
46277
46279
  const { source, uncapturedLastStatement } = normalizeCode(code);
46278
46280
  const wrapped = `(async () => {
46279
46281
  ${source}
@@ -46416,11 +46418,11 @@ var LSP_READ_OP_SIGNATURES = ` /** File contents as a raw string (no line numbe
46416
46418
  getSymbolBody(file: string, symbolPath: string): Promise<string>;
46417
46419
  /** Document symbol tree (file outline). Every path is a usable handle. */
46418
46420
  getSymbols(file: string): Promise<SymbolInfo[]>;
46419
- /** Workspace-wide symbol search; the index warms lazily, so early calls may be empty getSymbols(file) is exhaustive. */
46421
+ /** Workspace-wide symbol search; matches substrings, so filter for exact \`name\`. The index warms lazily early calls may be empty; getSymbols(file) is exhaustive. */
46420
46422
  findSymbol(query: string): Promise<WorkspaceSymbolInfo[]>;
46421
46423
  /** All references to a symbol across the workspace (incl. the declaration). */
46422
46424
  findReferences(file: string, symbolPath: string): Promise<Reference[]>;
46423
- /** Jump to a symbol's definition. */
46425
+ /** Jump to the definition of a symbol DEFINED in \`file\` — imports/callees in a body are not addressable; resolve those names with findSymbol. */
46424
46426
  goToDefinition(file: string, symbolPath: string): Promise<Location>;
46425
46427
  /** Regex search across project files — escape metacharacters for literal text; optional second arg is a glob string. */
46426
46428
  searchText(pattern: string, glob?: string): Promise<SearchResult[]>;
@@ -46490,10 +46492,16 @@ function renderLspTypes(readonly3) {
46490
46492
  const interfaces = readonly3 ? LSP_COMMON_INTERFACES : `${LSP_COMMON_INTERFACES}
46491
46493
 
46492
46494
  ${LSP_WRITE_INTERFACES}`;
46493
- const ops = readonly3 ? LSP_READ_OP_SIGNATURES : `${LSP_READ_OP_SIGNATURES}
46495
+ const helpOp = ` /** This full API reference as a string — call it if this description was truncated. */
46496
+ help(): Promise<string>;`;
46497
+ const ops = readonly3 ? `${LSP_READ_OP_SIGNATURES}
46498
+
46499
+ ${helpOp}` : `${LSP_READ_OP_SIGNATURES}
46494
46500
 
46495
46501
  // Write operations — buffered, applied atomically when the script succeeds.
46496
- ${LSP_WRITE_OP_SIGNATURES}`;
46502
+ ${LSP_WRITE_OP_SIGNATURES}
46503
+
46504
+ ${helpOp}`;
46497
46505
  return `declare const lsp: {
46498
46506
  ${ops}
46499
46507
  };
@@ -46501,6 +46509,8 @@ ${ops}
46501
46509
  ${interfaces}`;
46502
46510
  }
46503
46511
  var TEMPLATE = `Execute JavaScript to perform semantic code operations via LSP (TypeScript).
46512
+ If this description looks truncated, run the script \`await lsp.help()\` — it
46513
+ returns this complete reference. Ops — {{opInventory}}.
46504
46514
 
46505
46515
  Write one script that chains lsp.* calls — filter, loop, and branch in code
46506
46516
  instead of across many tool calls. The sandbox provides \`lsp\`,
@@ -46530,6 +46540,10 @@ script's last expression, JSON-serialized.
46530
46540
  the write ops.
46531
46541
  - \`searchText\` patterns are regexes — escape metacharacters for literal text:
46532
46542
  \`searchText("new NotFoundError\\\\(")\`.
46543
+ - \`goToDefinition\` only addresses symbols DEFINED in the given file — it cannot
46544
+ follow an imported or called name into another module. To resolve a name to
46545
+ its definition anywhere in the workspace, use \`findSymbol(name)\` and filter
46546
+ for an exact \`name\` match (it also returns substring matches).
46533
46547
  - File paths are relative to the workspace root; anything outside it is
46534
46548
  rejected.
46535
46549
  - Diagnostics cover files touched this session only, never the whole project.
@@ -46558,7 +46572,8 @@ ${example.code}
46558
46572
  \`\`\``).join(`
46559
46573
 
46560
46574
  `);
46561
- return TEMPLATE.replace("{{types}}", renderLspTypes(readonly3)).replace("{{writeSemantics}}", readonly3 ? READONLY_SEMANTICS : WRITE_SEMANTICS).replace("{{examples}}", examples);
46575
+ const opInventory = readonly3 ? `read: ${READ_OP_NAMES.join(", ")}` : `read: ${READ_OP_NAMES.join(", ")}; write: ${WRITE_OP_NAMES.join(", ")}`;
46576
+ return TEMPLATE.replace("{{opInventory}}", opInventory).replace("{{types}}", renderLspTypes(readonly3)).replace("{{writeSemantics}}", readonly3 ? READONLY_SEMANTICS : WRITE_SEMANTICS).replace("{{examples}}", examples);
46562
46577
  }
46563
46578
 
46564
46579
  // src/mcp-server.ts
@@ -46595,7 +46610,8 @@ function createExecuteRunner(deps) {
46595
46610
  const { result, logs } = await runSandbox(code, {
46596
46611
  lsp: deps.api,
46597
46612
  timeoutMs: deps.timeoutMs,
46598
- readonly: deps.readonly
46613
+ readonly: deps.readonly,
46614
+ helpText: deps.helpText ?? buildToolDescription(deps.readonly ?? false)
46599
46615
  });
46600
46616
  const flushed = buffer.flush();
46601
46617
  const changes = flushed.map((change) => ({
@@ -46659,20 +46675,22 @@ function createServer(options = {}) {
46659
46675
  warmup.catch(() => {
46660
46676
  return;
46661
46677
  });
46678
+ const description = buildToolDescription(readonly3);
46662
46679
  const { execute } = createExecuteRunner({
46663
46680
  api: api2,
46664
46681
  client,
46665
46682
  timeoutMs,
46666
46683
  warmup,
46667
46684
  rootDir,
46668
- readonly: readonly3
46685
+ readonly: readonly3,
46686
+ helpText: description
46669
46687
  });
46670
46688
  const server = new McpServer({
46671
46689
  name: "codemode-lsp",
46672
46690
  version: "0.1.0"
46673
46691
  });
46674
46692
  server.registerTool("execute", {
46675
- description: buildToolDescription(readonly3),
46693
+ description,
46676
46694
  inputSchema: {
46677
46695
  code: exports_external.string().describe("JavaScript to run in the LSP sandbox. The last expression is the return value.")
46678
46696
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemode-lsp",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "MCP server exposing a single code-mode tool backed by LSP",
5
5
  "keywords": [
6
6
  "mcp",