mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
Every surface that persists or lists sessions resolves one directory under the Harness home, so history is shared across working directories instead of scattered per project.
57 lines
2.2 KiB
TypeScript
57 lines
2.2 KiB
TypeScript
import { homedir } from 'node:os'
|
|
import { join, resolve } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
DEFAULT_DSH_HOME_DISPLAY,
|
|
DSH_HOME_DIR_NAME,
|
|
SESSIONS_DIR_NAME,
|
|
defaultDshHome,
|
|
dshHomeDisplay,
|
|
expandHomePath,
|
|
resolveDshHome,
|
|
resolveSessionsRoot,
|
|
} from '@deepseek-ai/dsh-paths'
|
|
|
|
describe('dsh path helpers', () => {
|
|
it('owns the shared default DSH home directory name', () => {
|
|
expect(DSH_HOME_DIR_NAME).toBe('.dsh')
|
|
expect(DEFAULT_DSH_HOME_DISPLAY).toBe('~/.dsh')
|
|
expect(defaultDshHome()).toBe(join(homedir(), '.dsh'))
|
|
})
|
|
|
|
it('expands tilde paths without changing non-tilde paths', () => {
|
|
expect(expandHomePath('~')).toBe(homedir())
|
|
expect(expandHomePath('~/.dsh')).toBe(join(homedir(), '.dsh'))
|
|
expect(expandHomePath('~\\.dsh')).toBe(join(homedir(), '.dsh'))
|
|
expect(expandHomePath('/tmp/.dsh')).toBe('/tmp/.dsh')
|
|
expect(expandHomePath('~other/.dsh')).toBe('~other/.dsh')
|
|
})
|
|
|
|
it('resolves explicit path before DSH_HOME and the default', () => {
|
|
const envHome = join(homedir(), 'env-dsh')
|
|
|
|
expect(resolveDshHome('/tmp/explicit-dsh', { DSH_HOME: '~/env-dsh' })).toBe(resolve('/tmp/explicit-dsh'))
|
|
expect(resolveDshHome(undefined, { DSH_HOME: '~/env-dsh' })).toBe(envHome)
|
|
expect(resolveDshHome(undefined, {})).toBe(defaultDshHome())
|
|
})
|
|
|
|
it('treats an empty or whitespace-only DSH_HOME as unset', () => {
|
|
expect(resolveDshHome(undefined, { DSH_HOME: '' })).toBe(defaultDshHome())
|
|
expect(resolveDshHome(undefined, { DSH_HOME: ' ' })).toBe(defaultDshHome())
|
|
})
|
|
|
|
it('resolves the session store under the home it was given, by the same precedence', () => {
|
|
expect(SESSIONS_DIR_NAME).toBe('sessions')
|
|
expect(resolveSessionsRoot('/tmp/explicit-dsh', { DSH_HOME: '~/env-dsh' }))
|
|
.toBe(join(resolve('/tmp/explicit-dsh'), 'sessions'))
|
|
expect(resolveSessionsRoot(undefined, { DSH_HOME: '~/env-dsh' }))
|
|
.toBe(join(homedir(), 'env-dsh', 'sessions'))
|
|
expect(resolveSessionsRoot(undefined, {})).toBe(join(defaultDshHome(), 'sessions'))
|
|
})
|
|
|
|
it('labels a resolved home by whether it is the default root', () => {
|
|
expect(dshHomeDisplay(resolve(defaultDshHome()))).toBe('~/.dsh')
|
|
expect(dshHomeDisplay('/some/other/root')).toBe('$DSH_HOME')
|
|
})
|
|
})
|