codemode-lsp 0.3.0 → 0.3.2

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
@@ -117,6 +117,9 @@ reads and writes alike.
117
117
  - `Reference.isWriteAccess` is always `false` (not exposed over standard LSP).
118
118
  - `getDependencies` is syntactic — a local variable shadowing an import can
119
119
  produce a false positive.
120
+ - A file created mid-script reports spurious "Cannot find module" errors for
121
+ tsconfig path aliases until it is flushed to disk; those diagnostics carry
122
+ `likelyFalsePositive: true` so verification gates can skip them.
120
123
 
121
124
  ## Eval
122
125
 
package/dist/index.js CHANGED
@@ -207819,6 +207819,9 @@ class TransactionalBuffer {
207819
207819
  }
207820
207820
  return false;
207821
207821
  }
207822
+ isPendingCreation(absPath) {
207823
+ return this.files.get(absPath)?.state === "created";
207824
+ }
207822
207825
  getText(absPath, relPath) {
207823
207826
  const tracked = this.track(absPath);
207824
207827
  if (tracked.state === "deleted") {
@@ -207941,6 +207944,10 @@ class TransactionalBuffer {
207941
207944
  } else if (file2.state === "created") {
207942
207945
  mkdirSync(dirname(absPath), { recursive: true });
207943
207946
  writeFileSync(absPath, file2.current ?? "", "utf8");
207947
+ if (file2.lspVisible) {
207948
+ this.client.didClose(absPath);
207949
+ this.client.didOpen(absPath, file2.current ?? "");
207950
+ }
207944
207951
  changes.push({
207945
207952
  absPath,
207946
207953
  kind: "created",
@@ -209130,12 +209137,24 @@ ${text}`
209130
209137
  const workspacePath = this.workspacePathFromUri(uri);
209131
209138
  if (!workspacePath)
209132
209139
  return [];
209133
- return diagnostics.map((diagnostic) => ({
209134
- file: workspacePath.relPath,
209135
- range: diagnostic.range,
209136
- message: typeof diagnostic.message === "string" ? diagnostic.message : diagnostic.message.value,
209137
- severity: severityName(diagnostic.severity)
209138
- }));
209140
+ const pendingCreation = this.buffer?.isPendingCreation(workspacePath.absPath);
209141
+ return diagnostics.map((diagnostic) => {
209142
+ let message = typeof diagnostic.message === "string" ? diagnostic.message : diagnostic.message.value;
209143
+ let likelyFalsePositive = false;
209144
+ if (pendingCreation && /Cannot find module/i.test(message)) {
209145
+ likelyFalsePositive = true;
209146
+ message += " [likely a FALSE POSITIVE: this file is newly created and not yet " + "on disk, so tsconfig path aliases do not resolve in it until the " + "script succeeds and it is flushed. If an existing file imports the " + "same module without errors, ignore this; verify with " + "getDiagnostics in a follow-up call after the flush.]";
209147
+ }
209148
+ const converted = {
209149
+ file: workspacePath.relPath,
209150
+ range: diagnostic.range,
209151
+ message,
209152
+ severity: severityName(diagnostic.severity)
209153
+ };
209154
+ if (likelyFalsePositive)
209155
+ converted.likelyFalsePositive = true;
209156
+ return converted;
209157
+ });
209139
209158
  }
209140
209159
  lineLooksExported(text, zeroBasedLine) {
209141
209160
  return /^\s*export\b/.test(lineContext(text, zeroBasedLine));
@@ -215353,6 +215372,8 @@ interface Diagnostic {
215353
215372
  range: Range;
215354
215373
  message: string;
215355
215374
  severity: "error" | "warning" | "info" | "hint";
215375
+ /** True when this is probably spurious (e.g. path-alias resolution on a file created this script) — exclude these from any abort/rollback gate. */
215376
+ likelyFalsePositive?: boolean;
215356
215377
  }
215357
215378
 
215358
215379
  interface Position {
@@ -215369,7 +215390,7 @@ var LSP_WRITE_INTERFACES = `interface WriteResult {
215369
215390
  file: string;
215370
215391
  /** All files affected — rename can fan out to many. */
215371
215392
  filesChanged: string[];
215372
- /** Fresh diagnostics for the affected files; check for "error" severity. */
215393
+ /** Fresh diagnostics for the affected files; gate on severity "error" but skip likelyFalsePositive ones. */
215373
215394
  diagnostics: Diagnostic[];
215374
215395
  }`;
215375
215396
  var LSP_READ_OP_SIGNATURES = ` /** File contents as a raw string (no line numbers). */
@@ -215539,6 +215560,14 @@ script's last expression, JSON-serialized.
215539
215560
  rejected.
215540
215561
  - Diagnostics cover files touched this session only, never the whole project.
215541
215562
  \`Diagnostic.range\` is zero-based; every other line/column is 1-based.
215563
+ - On a file CREATED this script, "Cannot find module" for tsconfig path
215564
+ aliases (\`@/...\`) is usually spurious — the file joins the TS project only
215565
+ once flushed to disk. Such diagnostics carry \`likelyFalsePositive: true\`;
215566
+ exclude them from any abort gate:
215567
+ \`d.severity === "error" && !d.likelyFalsePositive\`. For a strict
215568
+ verify-or-rollback workflow, split it across calls: do the writes in one
215569
+ script (so they flush), then check diagnostics — and restore originals if
215570
+ real errors remain — in a follow-up script.
215542
215571
 
215543
215572
  ## API
215544
215573
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemode-lsp",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Semantic code intelligence + refactoring MCP for TypeScript/JS: one LSP-backed execute tool — call graphs, impact analysis, symbol dependencies, atomic multi-file refactors",
5
5
  "keywords": [
6
6
  "mcp",
@@ -33,7 +33,7 @@
33
33
  "prepublishOnly": "bun run check && bun run build",
34
34
  "generate:types": "bun run scripts/generate-types.ts",
35
35
  "eval": "bun run scripts/eval.ts",
36
- "check": "bun run typecheck && bun run lint && bun test",
36
+ "check": "bun run typecheck && bun run lint && bun test --parallel=4",
37
37
  "typecheck": "tsc --noEmit",
38
38
  "lint": "biome check .",
39
39
  "fix": "biome check --write .",