Skip to content

fix: codex plugin install self-heals drifted [mcp_servers.bili] block (#638) - #652

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-09_codex-install-self-heal
Open

fix: codex plugin install self-heals drifted [mcp_servers.bili] block (#638)#652
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-09_codex-install-self-heal

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

bili plugin install codex could not repair an existing malformed [mcp_servers.bili] block. The already installed short-circuit in codexInstall() only compared the BILI_MCP_PROXY env line:

if (block.includes(`BILI_MCP_PROXY = ${JSON.stringify(proxyOriginForInstall())}`)) return `codex: already installed (${file})`;

So a block whose env line matched the current origin but whose args was written as a string (instead of an array) — valid TOML, but rejected by codex's schema (invalid type: string, expected a sequence in mcp_servers.bili.args) — was reported as already installed and left untouched. The upgrade/reinstall self-heal path (the most natural user recovery) was a silent no-op; only remove + install fixed it.

Fix

already installed now means the whole block matches the canonical one (codexBlock()), compared trailing-whitespace-normalized (handles the block-at-EOF vs block-followed-by-table trailing-newline difference). Only a byte-identical block reports already installed; any drift (args / command / origin / path) rewrites the block in place. The rewrite splices the canonical block back without disturbing surrounding tables.

This is the "simplest implementation" suggested in the issue: content is deterministic and naturally idempotent.

Tests

  • Added a regression test in tests/plugin-agent.test.ts: a block whose env line matches the origin but whose args is a string must be refreshed (args becomes a real array) and then report already installed on the next run.
  • Verified end-to-end with the built CLI: malformed block → first install rewrites args to an array + real node path → second install is idempotent.

Pre-flight

  • npm run typecheck — clean
  • npm test — 1239 pass, 1 fail (resolveClientCommand: codex/claude resolve to themselves) — pre-existing on clean master, unrelated to this change
  • npm run build — success

Fixes #638

…#638)

The 'already installed' short-circuit only compared the BILI_MCP_PROXY line,
so a block whose args/command drifted (e.g. args written as a string instead
of an array) was reported as already installed and never rewritten — making
the upgrade/reinstall self-heal path a silent no-op. Now the whole block is
compared against the canonical one (trailing-whitespace-normalized); only a
byte-identical block reports 'already installed', otherwise it is rewritten.

Adds a regression test for the malformed-args block.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

📦 Built Package Artifact

Branch: 2026-09-09_codex-install-self-heal (d213ace)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-652

Each push to this PR publishes a new version under the pr-652 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr652.tgz
npm install -g package

This comment is automatically updated on each push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: bili plugin install codex 无法修复已存在的畸形 [mcp_servers.bili] 块("already installed" 短路只比对 BILI_MCP_PROXY 行)

1 participant