From 32276c47b36392856aa1dc2cdc9fcd082d04ea41 Mon Sep 17 00:00:00 2001 From: NagyVikt Date: Sat, 11 Apr 2026 19:00:13 +0200 Subject: [PATCH] Install codex-auth switcher automatically so setup can complete account-tooling bootstrap Users rely on gx status and gx setup to validate and provision the required global toolchain. This change adds @imdeadpool/codex-account-switcher to the tracked global package set so status surfaces it and setup/init install it whenever it is missing. The setup checklist/help copy and README references were updated to keep the documented install command aligned with runtime behavior, and tests now cover the expanded package set and missing-package install path. Constraint: Setup/install behavior must remain backward compatible with existing OMX/OpenSpec checks Rejected: Add a separate one-off codex-auth install command | would duplicate setup responsibilities and drift from status detection Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep GLOBAL_TOOLCHAIN_PACKAGES and setup/checklist docs in sync whenever global dependencies change Tested: npm test (49/49); node --check bin/multiagent-safety.js Not-tested: Real networked npm global install path on a machine missing codex-account-switcher --- README.md | 11 ++++++----- bin/multiagent-safety.js | 12 ++++++++---- test/install.test.js | 11 +++++++---- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ec1ff53..7ba002d 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Related tools: - [oh-my-codex (OMX)](https://github.com/Yeachan-Heo/oh-my-codex) - [OpenSpec](https://github.com/Fission-AI/OpenSpec) +- [codex-account-switcher-cli](https://github.com/recodeecom/codex-account-switcher-cli) ## Fast setup (recommended) @@ -62,7 +63,7 @@ gx init That one command runs: -1. detects whether OMX/OpenSpec are already globally installed, +1. detects whether OMX/OpenSpec/codex-auth are already globally installed, 2. asks strict Y/N approval only if something is missing, 3. installs guardrail scripts/hooks, 4. repairs common safety problems, @@ -221,9 +222,9 @@ Use this exact checklist to setup multi-agent safety in this repository for Code gx setup # alias: gx init - - Setup detects global OMX/OpenSpec first. + - Setup detects global OMX/OpenSpec/codex-auth first. - If one is missing and setup asks for approval, reply explicitly: - - y = run: npm i -g oh-my-codex @fission-ai/openspec (missing ones only) + - y = run: npm i -g oh-my-codex @fission-ai/openspec @imdeadpool/codex-account-switcher (missing ones only) - n = skip global installs 3) If setup reports warnings/errors, repair + re-check: @@ -274,12 +275,12 @@ bash scripts/openspec/init-plan-workspace.sh # optional OpenSpec p ``` No command defaults to `gx status` (non-mutating health/status view). -`gx status` reports CLI/runtime info, global OMX/OpenSpec service status, and repo safety service state. +`gx status` reports CLI/runtime info, global OMX/OpenSpec/codex-auth service status, and repo safety service state. `gx init` is an alias of `gx setup`. When run in an interactive terminal, default `GuardeX` checks npm for a newer version first and asks `[y/N]` whether to update immediately (default is `N`). -- Interactive setup: prompts for Y/N approval before global OMX/OpenSpec install. +- Interactive setup: prompts for Y/N approval before global OMX/OpenSpec/codex-auth install. - Interactive prompt is strict (`[y/n]`) and waits for explicit answer. - Non-interactive setup: skips global installs by default; use `--yes-global-install` to force. diff --git a/bin/multiagent-safety.js b/bin/multiagent-safety.js index a58420c..82366b0 100755 --- a/bin/multiagent-safety.js +++ b/bin/multiagent-safety.js @@ -10,7 +10,11 @@ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); const TOOL_NAME = 'guardex'; const SHORT_TOOL_NAME = 'gx'; const LEGACY_NAMES = ['musafety', 'multiagent-safety']; -const GLOBAL_TOOLCHAIN_PACKAGES = ['oh-my-codex', '@fission-ai/openspec']; +const GLOBAL_TOOLCHAIN_PACKAGES = [ + 'oh-my-codex', + '@fission-ai/openspec', + '@imdeadpool/codex-account-switcher', +]; const MAINTAINER_RELEASE_REPO = path.resolve( process.env.MUSAFETY_RELEASE_REPO || '/tmp/multiagent-safety', ); @@ -132,9 +136,9 @@ const AI_SETUP_PROMPT = `Use this exact checklist to setup GuardeX (Guardian T-R gx setup # alias: gx init - - Setup detects global OMX/OpenSpec first. + - Setup detects global OMX/OpenSpec/codex-auth first. - If one is missing and setup asks for approval, reply explicitly: - - y = run: npm i -g oh-my-codex @fission-ai/openspec (missing ones only) + - y = run: npm i -g oh-my-codex @fission-ai/openspec @imdeadpool/codex-account-switcher (missing ones only) - n = skip global installs 3) If setup reports warnings/errors, repair + re-check: @@ -1993,7 +1997,7 @@ function setup(rawArgs) { `[${TOOL_NAME}] ✅ Global tools installed (${(globalInstallStatus.packages || []).join(', ')}).`, ); } else if (globalInstallStatus.status === 'already-installed') { - console.log(`[${TOOL_NAME}] ✅ OMX/OpenSpec global tools already installed. Skipping.`); + console.log(`[${TOOL_NAME}] ✅ OMX/OpenSpec/codex-auth global tools already installed. Skipping.`); } else if (globalInstallStatus.status === 'failed') { console.log( `[${TOOL_NAME}] ⚠️ Global install failed: ${globalInstallStatus.reason}\n` + diff --git a/test/install.test.js b/test/install.test.js index 38778c0..bbb64e0 100644 --- a/test/install.test.js +++ b/test/install.test.js @@ -1197,7 +1197,10 @@ test('copy-prompt outputs AI setup instructions', () => { const result = runNode(['copy-prompt'], repoDir); assert.equal(result.status, 0, result.stderr || result.stdout); assert.match(result.stdout, /npm i -g @imdeadpool\/guardex/); - assert.match(result.stdout, /npm i -g oh-my-codex @fission-ai\/openspec/); + assert.match( + result.stdout, + /npm i -g oh-my-codex @fission-ai\/openspec @imdeadpool\/codex-account-switcher/, + ); assert.match(result.stdout, /gx setup/); assert.match(result.stdout, /gx init/); assert.match(result.stdout, /Codex or Claude/); @@ -1229,13 +1232,13 @@ test('setup dry-run accepts explicit global install approval flags', () => { assert.match(result.stdout, /Dry run setup done/); }); -test('setup skips global install when OMX/OpenSpec are already installed', () => { +test('setup skips global install when OMX/OpenSpec/codex-auth are already installed', () => { const repoDir = initRepo(); const marker = path.join(repoDir, '.global-install-called'); const fakeNpm = createFakeNpmScript(` if [[ "$1" == "list" ]]; then cat <<'JSON' -{"dependencies":{"oh-my-codex":{"version":"1.0.0"},"@fission-ai/openspec":{"version":"1.0.0"}}} +{"dependencies":{"oh-my-codex":{"version":"1.0.0"},"@fission-ai/openspec":{"version":"1.0.0"},"@imdeadpool/codex-account-switcher":{"version":"1.0.0"}}} JSON exit 0 fi @@ -1282,7 +1285,7 @@ exit 1 assert.equal(result.status, 0, result.stderr || result.stdout); assert.equal(fs.existsSync(marker), true, 'global install should run for missing package'); const args = fs.readFileSync(marker, 'utf8').trim(); - assert.equal(args, 'i -g @fission-ai/openspec'); + assert.equal(args, 'i -g @fission-ai/openspec @imdeadpool/codex-account-switcher'); }); test('worktree prune removes merged agent worktrees and branches', () => {