From 3fed03d04773042ade883f4b2b742b170dfb97db Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 31 May 2026 00:29:09 +0900 Subject: [PATCH] fix: use bundled lsp runtime in packaged codex builds --- .../lsp/scripts/build-lsp-tools.mjs | 4 ++++ .../lsp/scripts/build-lsp-tools.test.mjs | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.mjs b/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.mjs index d93efc598..390ffe06d 100644 --- a/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.mjs +++ b/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.mjs @@ -20,6 +20,10 @@ if (!force && isBuildFresh(packageJson, requiredOutputs)) { } if (!existsSync(packageJson)) { + if (!force && requiredOutputs.every((path) => existsSync(path))) { + console.log("Using bundled lsp-tools-mcp dist."); + process.exit(0); + } console.error( `lsp-tools-mcp package metadata is missing at ${packageJson}; build packages/lsp-tools-mcp before codex-lsp`, ); diff --git a/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.test.mjs b/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.test.mjs index 6b24df49e..6848a2f82 100644 --- a/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.test.mjs +++ b/packages/omo-codex/plugin/components/lsp/scripts/build-lsp-tools.test.mjs @@ -1,5 +1,5 @@ import assert from "node:assert/strict"; -import { chmod, copyFile, mkdir, mkdtemp, readFile, utimes, writeFile } from "node:fs/promises"; +import { chmod, copyFile, mkdir, mkdtemp, readFile, rm, utimes, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { spawnSync } from "node:child_process"; @@ -84,3 +84,21 @@ test("#given force flag #when bootstrapping #then it rebuilds even when dist exi assert.equal(result.status, 0); assert.match(await readFile(fixture.npmLog, "utf8"), /ci\nrun build\n/u); }); + +test("#given packaged dist without package metadata #when bootstrapping #then it uses bundled runtime", async () => { + // given + const fixture = await makeFixture(); + await mkdir(join(fixture.root, "packages", "lsp-tools-mcp", "dist", "lsp"), { recursive: true }); + await writeFile(join(fixture.root, "packages", "lsp-tools-mcp", "dist", "lsp", "manager.js"), "manager\n"); + await writeFile(join(fixture.root, "packages", "lsp-tools-mcp", "dist", "tools.js"), "tools\n"); + await writeFile(fixture.npmLog, ""); + await rm(join(fixture.root, "packages", "lsp-tools-mcp", "package.json")); + + // when + const result = runScript(fixture.script, fixture.fakeBin); + + // then + assert.equal(result.status, 0, result.stderr); + assert.match(result.stdout, /Using bundled lsp-tools-mcp dist/); + assert.equal(await readFile(fixture.npmLog, "utf8"), ""); +});