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..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', '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', - ); + 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 576784f8c3..cb9b0ab6ab 100644 --- a/tests/install-non-tty.test.ts +++ b/tests/install-non-tty.test.ts @@ -147,13 +147,23 @@ 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("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]"); + }); + + 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', () => {