From 4c27440257ad18cf88930e7f23db0cf8ddcca2af Mon Sep 17 00:00:00 2001 From: "Alex V." <119082209+Retengart@users.noreply.github.com> Date: Fri, 26 Jun 2026 14:58:22 +0300 Subject: [PATCH 1/2] fix(codex): install local plugin cache during setup --- src/npx-cli/commands/install.ts | 1 + src/services/integrations/CodexCliInstaller.ts | 6 +++--- tests/install-non-tty.test.ts | 14 +++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/npx-cli/commands/install.ts b/src/npx-cli/commands/install.ts index bd45b77edd..3aabcbcb4a 100644 --- a/src/npx-cli/commands/install.ts +++ b/src/npx-cli/commands/install.ts @@ -1599,6 +1599,7 @@ async function runInstallCommandInner(options: InstallOptions, summary: InstallS } writeInstallMarker(cacheDir, version, bunVersion, uvVersion); } + writeInstallMarker(join(marketplaceDirectory(), 'plugin'), version, bunVersion, uvVersion); return `Runtime ready (Bun ${bunVersion}, uv ${uvVersion}) ${pc.green('OK')}`; }, }, diff --git a/src/services/integrations/CodexCliInstaller.ts b/src/services/integrations/CodexCliInstaller.ts index 62a7c86616..3b27abaa80 100644 --- a/src/services/integrations/CodexCliInstaller.ts +++ b/src/services/integrations/CodexCliInstaller.ts @@ -420,9 +420,9 @@ export async function installCodexCli(marketplaceRootOverride?: string): Promise registerCodexMarketplace(marketplaceRoot); enableCodexPluginConfig(); runCodexBestEffort( - ['plugin', 'marketplace', 'upgrade', MARKETPLACE_NAME], - 'Refreshed Codex marketplace and installed plugin cache.', - 'Could not refresh Codex marketplace cache; reinstall or upgrade claude-mem from /plugins if Codex still uses old MCP config', + ['plugin', 'add', CODEX_PLUGIN_ID], + 'Installed Codex plugin cache.', + `Could not install Codex plugin cache; run: codex plugin add ${CODEX_PLUGIN_ID}`, ); if (!cleanupLegacyCodexAgentsMdContext()) { console.warn(` Native Codex hooks registered, but failed to remove legacy AGENTS.md context from ${CODEX_AGENTS_MD_PATH}.`); diff --git a/tests/install-non-tty.test.ts b/tests/install-non-tty.test.ts index 576784f8c3..0673ee3a91 100644 --- a/tests/install-non-tty.test.ts +++ b/tests/install-non-tty.test.ts @@ -147,13 +147,21 @@ describe('Install Non-TTY Support', () => { expect(installSource).toContain('installCodexCli(marketplaceDirectory())'); }); - it('refreshes Codex marketplace cache after registration', () => { + it('installs the Codex plugin cache after local marketplace registration', () => { const installRegion = codexInstallerSource.slice( codexInstallerSource.indexOf('export async function installCodexCli'), codexInstallerSource.indexOf('export function uninstallCodexCli'), ); - expect(installRegion).toContain("['plugin', 'marketplace', 'upgrade', MARKETPLACE_NAME]"); - expect(installRegion).toContain('installed plugin cache'); + expect(installRegion).toContain("['plugin', 'add', CODEX_PLUGIN_ID]"); + expect(installRegion).not.toContain("['plugin', 'marketplace', 'upgrade', MARKETPLACE_NAME]"); + }); + + it('copies the install marker into the bundled marketplace plugin before Codex installs it', () => { + const runtimeSetupRegion = installSource.slice( + installSource.indexOf("title: 'Setting up runtime"), + installSource.indexOf("return `Runtime ready"), + ); + expect(runtimeSetupRegion).toContain("writeInstallMarker(join(marketplaceDirectory(), 'plugin'), version, bunVersion, uvVersion)"); }); it('replaces stale Codex marketplace registrations from a different source', () => { From acc25759dba5b519d752647f2f017c8f3241ca0f Mon Sep 17 00:00:00 2001 From: "Alex V." <119082209+Retengart@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:11:40 +0300 Subject: [PATCH 2/2] fix(codex): fail when plugin cache install fails --- .../integrations/CodexCliInstaller.ts | 19 ++----------------- tests/install-non-tty.test.ts | 4 +++- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/services/integrations/CodexCliInstaller.ts b/src/services/integrations/CodexCliInstaller.ts index 3b27abaa80..d890cc9cd7 100644 --- a/src/services/integrations/CodexCliInstaller.ts +++ b/src/services/integrations/CodexCliInstaller.ts @@ -126,18 +126,6 @@ function runCodex(args: string[]): void { } } -function runCodexBestEffort(args: string[], successMessage: string, failureMessage: string): boolean { - try { - runCodex(args); - console.log(` ${successMessage}`); - return true; - } catch (error) { - const message = error instanceof Error ? error.message : String(error); - console.warn(` ${failureMessage}: ${message}`); - return false; - } -} - function isMarketplaceDifferentSourceError(error: unknown): boolean { const message = error instanceof Error ? error.message : String(error); return message.includes(`marketplace '${MARKETPLACE_NAME}' is already added from a different source`) @@ -419,11 +407,8 @@ export async function installCodexCli(marketplaceRootOverride?: string): Promise console.log(` Registering Codex plugin marketplace: ${marketplaceRoot}`); registerCodexMarketplace(marketplaceRoot); enableCodexPluginConfig(); - runCodexBestEffort( - ['plugin', 'add', CODEX_PLUGIN_ID], - 'Installed Codex plugin cache.', - `Could not install Codex plugin cache; run: codex plugin add ${CODEX_PLUGIN_ID}`, - ); + runCodex(['plugin', 'add', CODEX_PLUGIN_ID]); + console.log(' Installed Codex plugin cache.'); if (!cleanupLegacyCodexAgentsMdContext()) { console.warn(` Native Codex hooks registered, but failed to remove legacy AGENTS.md context from ${CODEX_AGENTS_MD_PATH}.`); } diff --git a/tests/install-non-tty.test.ts b/tests/install-non-tty.test.ts index 0673ee3a91..cb9b0ab6ab 100644 --- a/tests/install-non-tty.test.ts +++ b/tests/install-non-tty.test.ts @@ -152,7 +152,9 @@ describe('Install Non-TTY Support', () => { codexInstallerSource.indexOf('export async function installCodexCli'), codexInstallerSource.indexOf('export function uninstallCodexCli'), ); - expect(installRegion).toContain("['plugin', 'add', CODEX_PLUGIN_ID]"); + expect(installRegion).toContain("runCodex(['plugin', 'add', CODEX_PLUGIN_ID])"); + expect(installRegion).toContain('Installed Codex plugin cache.'); + expect(installRegion).not.toContain('runCodexBestEffort('); expect(installRegion).not.toContain("['plugin', 'marketplace', 'upgrade', MARKETPLACE_NAME]"); });