Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion context-mode/server/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<BinarySource, string>> = {
bundled: "Update the Context Mode plugin in Paseo",
settings: "Upgrade the Context Mode install configured in settings",
Expand All @@ -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] };
Expand Down
18 changes: 18 additions & 0 deletions context-mode/tests/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => ({
Expand Down
Loading