mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 16:03:26 +00:00
fix(opencode): honor scanner config directory
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -21,9 +21,55 @@ describe('opencodeDiscoveries', () => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('discovers local storage from the OpenCode XDG data directory', async () => {
|
||||
it('prefers the OpenCode config directory for local storage', async () => {
|
||||
vi.stubEnv('XDG_DATA_HOME', '/xdg/data')
|
||||
vi.stubEnv('OPENCODE_CONFIG_DIR', '/opencode/config')
|
||||
vi.stubEnv('OPENCODE_CONFIG_DIR', ' /opencode/config ')
|
||||
listOpenCodeDatabasesMock.mockResolvedValue([])
|
||||
discoverOpenCodeSessionsMock.mockResolvedValue({
|
||||
agent: 'opencode',
|
||||
rootDir: '/opencode/config/storage',
|
||||
files: []
|
||||
})
|
||||
const issues = []
|
||||
|
||||
await Promise.all(opencodeDiscoveries({}, [], 25, issues))
|
||||
|
||||
expect(discoverOpenCodeSessionsMock).toHaveBeenCalledWith({
|
||||
storageDir: join('/opencode/config', 'storage'),
|
||||
dbPaths: [],
|
||||
limitPerAgent: 25,
|
||||
issues
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps WSL discovery on the guest data path', async () => {
|
||||
vi.stubEnv('OPENCODE_CONFIG_DIR', '/windows/opencode/config')
|
||||
discoverOpenCodeSessionsMock.mockResolvedValue({
|
||||
agent: 'opencode',
|
||||
rootDir: '/home/wsl/.local/share/opencode/storage',
|
||||
files: []
|
||||
})
|
||||
const issues = []
|
||||
|
||||
await Promise.all(opencodeDiscoveries({ opencodeDbPaths: [] }, ['/home/wsl'], 25, issues))
|
||||
|
||||
expect(discoverOpenCodeSessionsMock).toHaveBeenNthCalledWith(1, {
|
||||
storageDir: join('/windows/opencode/config', 'storage'),
|
||||
dbPaths: [],
|
||||
limitPerAgent: 25,
|
||||
issues
|
||||
})
|
||||
expect(discoverOpenCodeSessionsMock).toHaveBeenNthCalledWith(2, {
|
||||
storageDir: join('/home/wsl', '.local', 'share', 'opencode', 'storage'),
|
||||
dbPaths: [],
|
||||
limitPerAgent: 25,
|
||||
issues
|
||||
})
|
||||
})
|
||||
|
||||
it('falls back to the OpenCode XDG data directory', async () => {
|
||||
vi.stubEnv('XDG_DATA_HOME', '/xdg/data')
|
||||
vi.stubEnv('OPENCODE_CONFIG_DIR', ' ')
|
||||
listOpenCodeDatabasesMock.mockResolvedValue([])
|
||||
discoverOpenCodeSessionsMock.mockResolvedValue({
|
||||
agent: 'opencode',
|
||||
|
||||
@@ -38,9 +38,24 @@ describe('resolveOpenCodeDataDirectory', () => {
|
||||
}
|
||||
)
|
||||
|
||||
it('derives legacy storage from the same data directory', () => {
|
||||
expect(resolveOpenCodeStorageDirectory({}, '/users/test')).toBe(
|
||||
join('/users/test', '.local', 'share', 'opencode', 'storage')
|
||||
)
|
||||
it('prefers OPENCODE_CONFIG_DIR for legacy storage', () => {
|
||||
expect(
|
||||
resolveOpenCodeStorageDirectory(
|
||||
{
|
||||
OPENCODE_CONFIG_DIR: ' /custom/config ',
|
||||
XDG_DATA_HOME: '/custom/data'
|
||||
},
|
||||
'/users/test'
|
||||
)
|
||||
).toBe(join('/custom/config', 'storage'))
|
||||
})
|
||||
|
||||
it('derives legacy storage from the data directory without a config override', () => {
|
||||
expect(
|
||||
resolveOpenCodeStorageDirectory(
|
||||
{ OPENCODE_CONFIG_DIR: ' ', XDG_DATA_HOME: '/custom/data' },
|
||||
'/users/test'
|
||||
)
|
||||
).toBe(join('/custom/data', 'opencode', 'storage'))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -13,5 +13,9 @@ export function resolveOpenCodeStorageDirectory(
|
||||
environment: NodeJS.ProcessEnv = process.env,
|
||||
homeDirectory = homedir()
|
||||
): string {
|
||||
return join(resolveOpenCodeDataDirectory(environment, homeDirectory), 'storage')
|
||||
const configDirectory = environment.OPENCODE_CONFIG_DIR?.trim()
|
||||
return join(
|
||||
configDirectory || resolveOpenCodeDataDirectory(environment, homeDirectory),
|
||||
'storage'
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user