Files
orca/src/shared/opencode-config-directory.ts
T
8ff6ec9fb1 Install OpenCode hooks in the terminal's config directory (#25296)
* test: reproduce OpenCode plugin installation in the wrong config root

* fix: install OpenCode hooks in the execution config directory

* test: isolate config installation from CLI version probing

* style: format consumer config installation controls

* fix: use checked startup environment and supported relay shell context

* fix: install OpenCode hooks using the selected execution shell

* test(opencode): assert consumer config root in PTY fixtures

---------

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Orca <orca@stably.ai>
2026-10-04 15:20:07 -07:00

15 lines
536 B
TypeScript

import { homedir } from 'node:os'
import { join } from 'node:path'
/** OpenCode's Global.config follows XDG_CONFIG_HOME on every supported host. */
export function resolveOpenCodeConfigDirectory(
environment: NodeJS.ProcessEnv | Record<string, string> = process.env,
homeDirectory = homedir()
): string {
const executionHome = process.platform === 'win32' ? environment.USERPROFILE : environment.HOME
return join(
environment.XDG_CONFIG_HOME?.trim() || join(executionHome || homeDirectory, '.config'),
'opencode'
)
}