fix: complete config path and review follow-ups (#3348)

This commit is contained in:
Bohdan Triapitsyn
2026-09-05 02:19:59 +03:00
committed by GitHub
parent 0543b954c3
commit 260bfe666b
14 changed files with 119 additions and 29 deletions
@@ -421,7 +421,7 @@ an authoritative loopback callback URL even when OpenChamber binds port `0`.
## Storage and configuration
- Provider auth: `~/.local/share/opencode/auth.json`.
- User config: `~/.config/opencode/opencode.json`.
- User config: `$XDG_CONFIG_HOME/opencode/opencode.json`, falling back to `~/.config/opencode/opencode.json` when unset or blank.
- Project config: `<workingDirectory>/.opencode/opencode.json` or `opencode.json`.
- Custom config: `OPENCODE_CONFIG` env var path.
- Rate limit config: `OPENCHAMBER_RATE_LIMIT_MAX_ATTEMPTS`, `OPENCHAMBER_RATE_LIMIT_NO_IP_MAX_ATTEMPTS` env vars.
@@ -433,3 +433,7 @@ an authoritative loopback callback URL even when OpenChamber binds port `0`.
- Config merging follows priority: custom > project > user.
- UI auth uses scrypt for password hashing with constant-time comparison.
- Tunnel auth treats `host.docker.internal` as local-only when the socket remote IP is private/loopback.
The behavior `GET /api/behavior/agents-md` response includes `path`, the effective
server-side filename, whether or not the file exists. Settings displays this
path without deriving a directory from the browser environment.
@@ -99,10 +99,18 @@ describe('OpenCode global config paths', () => {
routes.registerOpenCodeRoutes(app, {});
const response = { json: vi.fn(), status: vi.fn(() => response) };
await handlers.get('GET /api/behavior/agents-md')({}, response);
expect(response.json).toHaveBeenLastCalledWith({
content: '', exists: false, path: path.join(process.env.XDG_CONFIG_HOME, 'opencode', 'AGENTS.md'),
});
await handlers.get('PUT /api/behavior/agents-md')({ body: { content: 'Global behavior' } }, response);
expect(fs.readFileSync(path.join(process.env.XDG_CONFIG_HOME, 'opencode', 'AGENTS.md'), 'utf8')).toBe('Global behavior');
expect(response.json).toHaveBeenCalled();
await handlers.get('GET /api/behavior/agents-md')({}, response);
expect(response.json).toHaveBeenLastCalledWith({
content: 'Global behavior', exists: true, path: path.join(process.env.XDG_CONFIG_HOME, 'opencode', 'AGENTS.md'),
});
fs.rmSync(root, { recursive: true, force: true });
});
});
+2 -2
View File
@@ -815,10 +815,10 @@ ${desktopReturn ? `<a class="return" href="openchamber://focus/mcp-auth">Return
try {
await fs.promises.access(AGENTS_MD_PATH);
} catch {
return res.json({ content: '', exists: false });
return res.json({ content: '', exists: false, path: AGENTS_MD_PATH });
}
const content = await fs.promises.readFile(AGENTS_MD_PATH, 'utf8');
return res.json({ content, exists: true });
return res.json({ content, exists: true, path: AGENTS_MD_PATH });
} catch (error) {
console.error('Failed to read AGENTS.md:', error);
return res.status(500).json({ error: 'Failed to read AGENTS.md' });