Skip to content

Commit 4d07ade

Browse files
saravmajesticclaude
andcommitted
fix(auth): sign-out scans the same project configs the loader reads
- Outside git the loader's worktree is "/", so it reads config from every parent directory; `signOut` now walks to the filesystem root in that case instead of checking only the starting directory - Always include `~/.altimate-code`, which the loader reads for every session - Unit test for the outside-git and `~/.altimate-code` cases; docs updated Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ff2134c commit 4d07ade

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎docs/docs/configure/providers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Managed LLM access with dynamic routing across Sonnet 4.6, Opus 4.6, GPT-5.4, GP
4343

4444
For pricing, security, and data handling details, see the [Altimate LLM Gateway guide](https://help.altimate.ai/datamates/user-guide/components/llm-gateway/).
4545

46-
To sign out, run `altimate providers logout altimate-backend` (or `/logout` in the TUI). This deletes `~/.altimate/altimate.json` (`%USERPROFILE%\.altimate\altimate.json` on Windows), removes the auth-store entry, and removes remote MCP servers whose `Authorization` header carries the saved key, such as those added with `datamate add`. It checks the global config and the project config from the current directory up to the git root. New sessions stop using the key; restart any session that is already running, or run `/logout` inside it. MCP servers configured in other projects are not removed. If the saved key can't be read, logout fails and keeps the file so you can fix it and run logout again.
46+
To sign out, run `altimate providers logout altimate-backend` (or `/logout` in the TUI). This deletes `~/.altimate/altimate.json` (`%USERPROFILE%\.altimate\altimate.json` on Windows), removes the auth-store entry, and removes remote MCP servers whose `Authorization` header carries the saved key, such as those added with `datamate add`. It checks the same config files a session started in the current directory loads: the global config, `~/.altimate-code`, and project config from the current directory up to the git root (every parent directory outside git). New sessions stop using the key; restart any session that is already running, or run `/logout` inside it. MCP servers configured in other projects are not removed. If the saved key can't be read, logout fails and keeps the file so you can fix it and run logout again.
4747

4848
!!! tip "Automatic model selection"
4949
When Altimate credentials are configured and no model is explicitly chosen, the Altimate LLM Gateway is selected automatically. You can override this by setting `model` in your config or by restricting the `provider` section to specific providers only.

‎packages/opencode/src/altimate/api/client.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,13 @@ export namespace AltimateApi {
166166
await rm(credentialsPath(), { force: true })
167167
}
168168

169-
/** Directories whose project config a session in `directory` loads: `directory` up to the git root,
170-
* or `directory` alone outside git. Matches where `datamate add` writes project entries. */
169+
/** Directories whose project config a session in `directory` loads, mirroring `ConfigPaths`: `directory`
170+
* up to the git root (every ancestor outside git, where the worktree is "/"), plus `~/.altimate-code`. */
171171
async function projectConfigDirs(directory: string): Promise<string[]> {
172-
const dirs: string[] = []
172+
const dirs = [Global.Path.home]
173173
for (let dir = directory; ; dir = path.dirname(dir)) {
174174
dirs.push(dir)
175-
if (await Filesystem.exists(path.join(dir, ".git"))) return dirs
176-
if (path.dirname(dir) === dir) return [directory]
175+
if (path.dirname(dir) === dir || (await Filesystem.exists(path.join(dir, ".git")))) return [...new Set(dirs)]
177176
}
178177
}
179178

‎packages/opencode/test/altimate/sign-out.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ describe("AltimateApi.signOut", () => {
6060
expect(await AltimateApi.isConfigured()).toBe(false)
6161
})
6262

63+
test("outside git, removes entries in every ancestor config and in ~/.altimate-code", async () => {
64+
const plain = path.join(tmpRoot, "plain")
65+
const plainConfig = path.join(plain, ".altimate-code", "altimate-code.json")
66+
const homeConfig = path.join(home, ".altimate-code", "altimate-code.json")
67+
await writeJson(AltimateApi.credentialsPath(), {
68+
altimateUrl: "https://api.test",
69+
altimateInstanceName: "tenant",
70+
altimateApiKey: "gateway-test-key",
71+
})
72+
await writeJson(plainConfig, { mcp: { "datamate-sales": datamateEntry("gateway-test-key") } })
73+
await writeJson(homeConfig, { mcp: { "datamate-ops": datamateEntry("gateway-test-key") } })
74+
75+
const removed = await AltimateApi.signOut(path.join(plain, "a", "b"))
76+
77+
expect(removed).toContainEqual({ name: "datamate-sales", path: plainConfig })
78+
expect(removed).toContainEqual({ name: "datamate-ops", path: homeConfig })
79+
expect(await readJson(plainConfig)).toEqual({ mcp: {} })
80+
expect(await readJson(homeConfig)).toEqual({ mcp: {} })
81+
})
82+
6383
test("keeps the credential file and MCP entries when the saved key can't be read", async () => {
6484
delete process.env.SIGN_OUT_TEST_MISSING_KEY
6585
await writeJson(AltimateApi.credentialsPath(), {

0 commit comments

Comments
 (0)