Skip to content

Commit 10ba54c

Browse files
anandgupta42claude
andcommitted
fix: clarify warehouse_list hint and clear the test-injection flag on load
- Hint: the OS credential store is used only when available; `ALTIMATE_CODE_CONN_*` must be set before the process starts. - `load()` clears the `setConfigs()` injection flag, so a real load can still re-read when empty. - Hint tests isolate ambient `ALTIMATE_CODE_CONN_*` variables. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 434a319 commit 10ba54c

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎packages/opencode/src/altimate/native/connections/registry.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ export function load(includeProjectConfig = true): void {
224224

225225
if (configs.has(SCRATCH_NAME)) Log.Default.warn(SCRATCH_NAME_CONFLICT)
226226
loaded = true
227+
// altimate_change start — real sources were read, so the registry is no longer test-injected
228+
injected = false
229+
// altimate_change end
227230
}
228231

229232
/** Ensure configs are loaded. */

‎packages/opencode/src/altimate/tools/warehouse-list.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export function noConnectionsMessage(): string {
1313
return [
1414
"No warehouse connections configured.",
1515
"",
16-
"Preferred: use the warehouse_add tool. It stores passwords and keys in the OS credential store instead of a plaintext file.",
16+
`Preferred: use the warehouse_add tool. It stores passwords and keys in the OS credential store when one is available; otherwise it keeps them out of the file for this session only, so use ${CONN_ENV_PREFIX}<NAME> to make them persistent.`,
1717
"",
1818
"Alternatively, connections are read from these sources (later ones override earlier ones):",
1919
` 1. ${globalConfigPath()} (global)`,
2020
...(projectConfigApplies() ? [` 2. ${localConfigPath()} (this project)`] : []),
21-
` ${projectConfigApplies() ? 3 : 2}. ${CONN_ENV_PREFIX}<NAME> environment variables, each holding one connection's config as JSON (read when the process starts)`,
21+
` ${projectConfigApplies() ? 3 : 2}. ${CONN_ENV_PREFIX}<NAME> environment variables, each holding one connection's config as JSON (set them in the shell before starting altimate-code; a running process cannot see variables exported later)`,
2222
"",
2323
"After adding the first connection file, call warehouse_list again. Edits to an existing connections.json take effect after a restart. Example connections.json:",
2424
"{",

‎packages/opencode/test/altimate/warehouse-list-hint.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ function toolCtx() {
2323

2424
let project: string
2525
let prevCwd: string
26+
let ambientConnEnv: Record<string, string>
2627

2728
beforeEach(() => {
29+
// Ambient connection env vars would make the empty-registry assertions depend on the caller's shell.
30+
ambientConnEnv = {}
31+
for (const [key, value] of Object.entries(process.env)) {
32+
if (!key.startsWith(Registry.CONN_ENV_PREFIX) || value === undefined) continue
33+
ambientConnEnv[key] = value
34+
delete process.env[key]
35+
}
2836
prevCwd = process.cwd()
2937
project = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "whl-hint-")))
3038
process.chdir(project)
@@ -36,6 +44,7 @@ afterEach(() => {
3644
process.chdir(prevCwd)
3745
Registry.reset()
3846
fs.rmSync(project, { recursive: true, force: true })
47+
Object.assign(process.env, ambientConnEnv)
3948
})
4049

4150
describe("warehouse_list no-connections hint", () => {

0 commit comments

Comments
 (0)