fix: tighten project instruction path handling

This commit is contained in:
Yichen Jiang
2026-06-29 21:42:23 +08:00
parent 234ffe4604
commit 21ae734839
20 changed files with 247 additions and 30 deletions

View File

@@ -5,5 +5,6 @@ Zero-dependency primitives shared across the other groups. A package lands here
| Package | Role |
|---|---|
| `brand/` | The type-only `Branded<B>` nominal-typing primitive (no runtime code, no harness deps) |
| `paths/` | Shared filesystem path constants and helpers for harness user data |
`dsh-brand` is the canonical case: it owns ONLY the `Branded<B>` helper, so a capability package can brand the ids it owns (`dsh-bash`'s `BashTaskId`/`OwnerToken`, `dsh-session`'s `SessionId`, …) by depending on `dsh-brand` alone, without pulling in an unrelated package just to reach `Branded`.

View 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.

View 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"
}
}

View 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
}

View 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')
})
})

View File

@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/types"
},
"include": [
"src"
],
"references": []
}