SIGN IN SIGN UP

fix: clear all suite failures across account persistence, cli, and integration tests

Running vitest on master showed 111 failing tests across 4 files. Root
causes split evenly between two fresh regressions and stale test
expectations unmasked by earlier commits. Landing both halves brings
the suite to 1283/1283 passing.

Src regressions fixed
- src/accounts/persistence.ts: mergeAuthFallbackIntoAccounts only
  adopts an unmatched fallback when the caller explicitly passes a
  preferredIndex. Default preferredIndex=-1 restores the strict
  'no identity match -> no merge' contract that the persistence unit
  test pins. The preferredIndex path that accounts.ts uses for the
  single-account bootstrap still works.
- src/request-orchestration-helpers.ts: removes the per-request
  ensureAccountProfileIdentity() call (and its fetchProfile import).
  The pre-flight /oauth/profile fetch blocked the test harness by
  draining mockFetch queues before the actual request ran, and it
  added a round-trip to every /v1/messages call in production for
  data (accountUuid, organizationUuid) that the plugin already
  tolerates missing. Leaving the UUIDs to flow in via the OAuth
  exchange response (which commit 1587d32 already captures) is enough.

Test expectation refreshes
- index.test.ts: replaces the stale 2.1.107 user-agent literal with
  FALLBACK_CLAUDE_CLI_VERSION; opts the mocked config into the new
  'relocate_third_party_prompts' and 'disable_title_generation_request'
  defaults that commit 7f1d33d introduced; rewrites the three
  wire-name tool tests to assert the new PascalCase contract
  (ReadFile, Server) and pairs their assistant tool_use blocks with
  tool_result blocks so repairToolPairs no longer prunes them;
  updates the 2.1.109 manifest-driven beta inventory assertions to
  stop contradicting the new tests added in tests/unit/profiles/index.test.ts
  and tests/regression/fingerprint/cc-comparison.test.ts.
- cli.test.ts: adds a refreshToken entry to the vi.mock('./src/oauth.js')
  map so refreshAccessToken in src/cli/commands/auth.ts can exercise
  the existing mockFetch queue instead of throwing 'No refreshToken
  export is defined on the mock'.
- tests/integration/plugin/index.parallel.test.ts: switches every
  hard-coded mcp_mcp_* wire-name assertion to call toWireToolName()
  (so the contract matches src/tools/wire-names.ts), pairs the
  historical assistant tool_use blocks with user tool_result blocks,
  widens SentRequestBody.messages.role/content typing, and relaxes
  one regex to assert 'no mcp_ prefix leaked' instead of the
  old 'no mcp_mcp_mcp_ triple-prefix' check.

Verification: bunx vitest run
- Before: 5 test files failed / 111 tests failed / 1172 passed
- After:  70 test files passed / 0 tests failed / 1283 passed
V
Vacbo committed
ef17b3e8b51a5899ecc23f1327be270ff2a7a745
Parent: 83686cb