fix: tighten project instruction path handling
This commit is contained in:
13
packages/util/paths/README.md
Normal file
13
packages/util/paths/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# dsh-paths
|
||||
|
||||
Shared filesystem path helpers for DeepSeek Harness user data.
|
||||
|
||||
## DSH home
|
||||
|
||||
`DSH_HOME_DIR_NAME` owns the default user-data directory name: `.dsh`.
|
||||
|
||||
`defaultDshHome()` returns the default DeepSeek Harness home by joining the operating-system home directory with `.dsh`, using Node's platform path rules.
|
||||
|
||||
`expandHomePath()` expands `~`, `~/...`, and Windows-style `~\...` prefixes against the operating-system home directory. It leaves non-tilde paths and `~user/...` untouched.
|
||||
|
||||
This package is intentionally small and harness-dep-free so product packages can share user-data path conventions without depending on one another.
|
||||
30
packages/util/paths/package.json
Normal file
30
packages/util/paths/package.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@deepseek-ai/dsh-paths",
|
||||
"description": "Shared filesystem path helpers for the DeepSeek Harness",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./lib/types/index.d.ts",
|
||||
"default": "./lib/index.js"
|
||||
},
|
||||
"./src/*": "./src/*",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"lib/index.js",
|
||||
"lib/types/**/*.d.ts",
|
||||
"lib/types/**/*.d.ts.map",
|
||||
"src"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"peerDependencies": {
|
||||
"cordis": "^4.0.0-rc.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cordis": "^4.0.0-rc.6"
|
||||
}
|
||||
}
|
||||
26
packages/util/paths/src/index.ts
Normal file
26
packages/util/paths/src/index.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Shared filesystem path helpers for DeepSeek Harness user data.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-paths
|
||||
*/
|
||||
|
||||
import { homedir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
|
||||
/** Directory name for the default DeepSeek Harness home under the OS home. */
|
||||
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}`
|
||||
|
||||
/** Resolve the default DeepSeek Harness home using Node's platform path rules. */
|
||||
export function defaultDshHome(): string {
|
||||
return join(homedir(), DSH_HOME_DIR_NAME)
|
||||
}
|
||||
|
||||
/** Expand `~`, `~/...`, and Windows-style `~\...` prefixes against the OS home. */
|
||||
export function expandHomePath(path: string): string {
|
||||
if (path === '~') return homedir()
|
||||
if (path.startsWith('~/') || path.startsWith('~\\')) return join(homedir(), path.slice(2))
|
||||
return path
|
||||
}
|
||||
25
packages/util/paths/tests/paths.spec.ts
Normal file
25
packages/util/paths/tests/paths.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { homedir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
DEFAULT_DSH_HOME_DISPLAY,
|
||||
DSH_HOME_DIR_NAME,
|
||||
defaultDshHome,
|
||||
expandHomePath,
|
||||
} 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')
|
||||
})
|
||||
})
|
||||
11
packages/util/paths/tsconfig.json
Normal file
11
packages/util/paths/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "lib/types"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"references": []
|
||||
}
|
||||
Reference in New Issue
Block a user