diff --git a/context-mode/server/actions.ts b/context-mode/server/actions.ts index 542976ebc..17d77dbd5 100644 --- a/context-mode/server/actions.ts +++ b/context-mode/server/actions.ts @@ -42,6 +42,9 @@ const INFORMATIONAL_CHECK = /^D(3|5b?)\b/; /** Upstream's fix for an outdated runtime; the plugin offers no in-place upgrade. */ const UPGRADE_FIX = "run ctx_upgrade"; +/** D1's detail on an outdated runtime; since 2.1.7 its fix is the host's update command. */ +const UPDATE_AVAILABLE = "update available"; + const UPGRADE_ADVICE: Readonly> = { bundled: "Update the Context Mode plugin in Paseo", settings: "Upgrade the Context Mode install configured in settings", @@ -58,7 +61,8 @@ function doctorRow( if (INFORMATIONAL_CHECK.test(check)) { return { ...row, status: status === "ok" ? "ok" : "warning" }; } - if (upstreamFix === UPGRADE_FIX) { + const outdated = /^D1\b/.test(check) && detail.includes(UPDATE_AVAILABLE); + if (outdated || upstreamFix === UPGRADE_FIX) { // A bundled runtime that trails npm is expected until the next plugin release. const upgradeStatus = runtime === "bundled" ? "warning" : status; return { ...row, status: upgradeStatus, fix: UPGRADE_ADVICE[runtime] }; diff --git a/context-mode/tests/actions.test.ts b/context-mode/tests/actions.test.ts index 2b12f769c..7a7e02ae9 100644 --- a/context-mode/tests/actions.test.ts +++ b/context-mode/tests/actions.test.ts @@ -96,6 +96,24 @@ describe("structured actions", () => { }); }); + test("replaces the host update command that 2.1.7 and later print for an outdated runtime", () => { + // Rows as Context Mode 2.1.10 prints them for Claude Code and Copilot. + const outdated = [ + "| D1 version | WARN | 2.1.10 (877eebc): update available, latest on npm is 2.2.0 | Fix: claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode |", + "| D1 version | WARN | 2.1.10 (877eebc): update available, latest on npm is 2.2.0 | Fix: npm i -g context-mode && context-mode setup --agents copilot-cli |", + ].join("\n"); + const detail = "2.1.10 (877eebc): update available, latest on npm is 2.2.0"; + const row = { status: "warning", check: "D1 version", detail }; + expect(parseContextModeDoctorOutput(outdated, "bundled")).toEqual([ + { ...row, fix: "Update the Context Mode plugin in Paseo" }, + { ...row, fix: "Update the Context Mode plugin in Paseo" }, + ]); + expect(parseContextModeDoctorOutput(outdated, "settings")[1]).toEqual({ + ...row, + fix: "Upgrade the Context Mode install configured in settings", + }); + }); + test("runs ctx_doctor against the plugin-owned probe store", async () => { const handlers = createContextModeActionHandlers(settingsHandle(), { resolveBinary: async () => ({