fix project instruction review findings
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { homedir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { join, resolve } from 'node:path'
|
||||
|
||||
/** Directory name for the default DeepSeek Harness home under the OS home. */
|
||||
export const DSH_HOME_DIR_NAME = '.dsh'
|
||||
@@ -13,6 +13,9 @@ export const DSH_HOME_DIR_NAME = '.dsh'
|
||||
/** Stable user-facing display form for the default DeepSeek Harness home. */
|
||||
export const DEFAULT_DSH_HOME_DISPLAY = `~/${DSH_HOME_DIR_NAME}`
|
||||
|
||||
/** Environment variable that overrides the default DeepSeek Harness home. */
|
||||
export const DSH_HOME_ENV = 'DSH_HOME'
|
||||
|
||||
/** Resolve the default DeepSeek Harness home using Node's platform path rules. */
|
||||
export function defaultDshHome(): string {
|
||||
return join(homedir(), DSH_HOME_DIR_NAME)
|
||||
@@ -24,3 +27,9 @@ export function expandHomePath(path: string): string {
|
||||
if (path.startsWith('~/') || path.startsWith('~\\')) return join(homedir(), path.slice(2))
|
||||
return path
|
||||
}
|
||||
|
||||
/** Resolve an explicitly configured, env-selected, or default DSH home path. */
|
||||
export function resolveDshHome(configured?: string, env: Record<string, string | undefined> = process.env): string {
|
||||
const selected = configured ?? env[DSH_HOME_ENV] ?? defaultDshHome()
|
||||
return resolve(expandHomePath(selected))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
DSH_HOME_DIR_NAME,
|
||||
defaultDshHome,
|
||||
expandHomePath,
|
||||
resolveDshHome,
|
||||
} from '@deepseek-ai/dsh-paths'
|
||||
|
||||
describe('dsh path helpers', () => {
|
||||
@@ -22,4 +23,12 @@ describe('dsh path helpers', () => {
|
||||
expect(expandHomePath('/tmp/.dsh')).toBe('/tmp/.dsh')
|
||||
expect(expandHomePath('~other/.dsh')).toBe('~other/.dsh')
|
||||
})
|
||||
|
||||
it('resolves explicit DSH home before environment and default locations', () => {
|
||||
const envHome = join(homedir(), 'env-dsh')
|
||||
|
||||
expect(resolveDshHome(undefined, { DSH_HOME: '~/env-dsh' })).toBe(envHome)
|
||||
expect(resolveDshHome('/tmp/explicit-dsh', { DSH_HOME: '~/env-dsh' })).toBe('/tmp/explicit-dsh')
|
||||
expect(resolveDshHome(undefined, {})).toBe(defaultDshHome())
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user