Merge branch 'master' into sync branch
This commit is contained in:
commit
f51b6bd331
21 files changed
+398
-34
No files matched your search
+2
-2
@@ -9,8 +9,8 @@
|
||||
en: fa4d3622fb18dd58
|
||||
zh: 2b98640594c8344b
|
||||
/agent-note-one-harness-home-resolver/decision:
|
||||
en: 816e5109718bc4ae
|
||||
zh: af3f08f07c3cb761
|
||||
en: a9d9f7bf051341e9
|
||||
zh: cc1fed8d2b606276
|
||||
/agent-note-one-harness-home-resolver/alternatives-considered:
|
||||
en: b1c9535540171d47
|
||||
zh: 7df816d42945db94
|
||||
|
||||
@@ -21,9 +21,9 @@ One resolver owns the harness home, in `@deepseek-ai/dsh-home-paths`, single-roo
|
||||
explicit configured path > $DSH_HOME > ~/.dsh
|
||||
```
|
||||
|
||||
An empty or whitespace-only `$DSH_HOME` is treated as unset; otherwise `resolve('')` would silently place the home at the current working directory. The harness keeps all user data under one root; there is no XDG config/data/cache split. `dshHomePath(...segments)` joins deployment-owned children onto that root, and `dsh-app-boot` exposes it to Loader `!!js` config expressions before mounting entries, so shipped compositions derive `sessions` and `storages` without copying the resolver. `dshHomeDisplay()` names a resolved root symbolically for user-facing paths — `~/.dsh` for the default home, `$DSH_HOME` for any configured home — so the user-global `AGENTS.md` label never leaks an absolute machine path. It replaces agent-instructions's bespoke default-vs-`$DSH_HOME` check. Home is process policy rather than row configuration: `dsh-agent-instructions` accepts no home override, so a composition cannot point instruction loading at a root that sessions, skills, and storage would not read. `resolveAgentsHome()` and `agentsHomeDisplay()` apply the same precedence, tilde expansion, and symbolic labelling to the shared agent configuration root (`$DSH_AGENTS_HOME` or `~/.agents`), which stays outside the harness home because other agent tools share it ([shared agents root](2026-10-05-shared-agents-root-instructions.md)); `dsh-skill-filesystem` still accepts its own `dshHome` and `agentsHome` fields, which select its own skill roots and resolve through the shared resolver in the instruction-loading change.
|
||||
An empty or whitespace-only `$DSH_HOME` is treated as unset; otherwise `resolve('')` would silently place the home at the current working directory. The harness keeps all user data under one root; there is no split into separate XDG roots. `dshHomePath(...segments)` joins deployment-owned children onto that root, and `dsh-app-boot` exposes it to Loader `!!js` config expressions before mounting entries, so shipped compositions derive `sessions` and `storages` without copying the resolver. `dshHomeDisplay()` names a resolved root symbolically for user-facing paths — `~/.dsh` for the default home, `$DSH_HOME` for any configured home — so the user-global `AGENTS.md` label never leaks an absolute machine path. It replaces agent-instructions's bespoke default-vs-`$DSH_HOME` check. Home is process policy rather than row configuration: `dsh-agent-instructions` accepts no home override, so a composition cannot point instruction loading at a root that sessions, skills, and storage would not read. `resolveAgentsHome()` and `agentsHomeDisplay()` apply the same precedence, tilde expansion, and symbolic labelling to the shared agent configuration root (`$DSH_AGENTS_HOME` or `~/.agents`), which stays outside the harness home because other agent tools share it ([shared agents root](2026-10-05-shared-agents-root-instructions.md)); `dsh-skill-filesystem` still accepts its own `dshHome` and `agentsHome` fields, which select its own skill roots and resolve through the shared resolver in the instruction-loading change.
|
||||
|
||||
`dshCachePath(...segments)` derives paths below the resolved home's `cache` directory. An initial `{ dshHome }` option preserves a provider's explicit home override. It resolves paths without creating directories; callers own directory creation. `attachment-local` uses this helper for regenerable request-image variants while retaining durable attachment objects in their versioned storage tree, so clearing the cache cannot remove Session attachments. Existing request-image cache entries are left in place and are not read or copied; a cache miss regenerates the variant from its durable attachment.
|
||||
`dshPath(category, ...segments)` derives paths below a `config`, `data`, `state`, `cache`, or `backup` directory of that one root, and app-boot exposes it to Loader `!!js` expressions beside `dshHomePath`; the [home path categories proposal](../../proposed/architecture/2026-11-04-dsh-home-path-categories.md) owns the categories and which existing entries keep their top-level locations. `dshCachePath(...segments)` is `dshPath('cache', ...segments)`. An initial `{ dshHome }` option preserves a provider's explicit home override. It resolves paths without creating directories; callers own directory creation. `attachment-local` uses this helper for regenerable request-image variants while retaining durable attachment objects in their versioned storage tree, so clearing the cache cannot remove Session attachments. Existing request-image cache entries are left in place and are not read or copied; a cache miss regenerates the variant from its durable attachment.
|
||||
|
||||
`@deepseek-ai/dsh-home` is deleted. Home-owning providers and boot packages import `resolveDshHome` from `dsh-home-paths`; composition bundles contain only the resolved configuration rows.
|
||||
|
||||
|
||||
+2
-2
@@ -21,9 +21,9 @@ Status: implemented
|
||||
explicit configured path > $DSH_HOME > ~/.dsh
|
||||
```
|
||||
|
||||
空或仅含空白的 `$DSH_HOME` 被当作未设置处理;否则,`resolve('')` 会悄悄把 home 落在当前工作目录。harness 把所有用户数据都放在同一个根目录下;不存在 XDG 的 config/data/cache 拆分。`dshHomePath(...segments)` 将部署负责的子路径拼接到该根目录下,`dsh-app-boot` 在挂载条目前向 Loader `!!js` 配置表达式暴露它,因此出厂组合无需复制解析器即可派生 `sessions` 和 `storages`。`dshHomeDisplay()` 为面向用户的路径以符号形式命名已解析的根目录——默认 home 显示为 `~/.dsh`,任何已配置的 home 显示为 `$DSH_HOME`——这样用户全局的 `AGENTS.md` 标签就绝不会泄露机器上的绝对路径。它取代了 agent-instructions 中自定义的「默认值 vs `$DSH_HOME`」判断。home 属于进程策略而非配置行:`dsh-agent-instructions` 不接受 home 覆盖,因此组合无法把指令加载指向会话、skill 与存储不会读取的根目录。`resolveAgentsHome()` 与 `agentsHomeDisplay()` 对共享 agent 配置根目录(`$DSH_AGENTS_HOME` 或 `~/.agents`)采用相同的优先级、波浪号展开与符号化标签;该根目录位于 harness home 之外,因为其他 agent 工具会共享它([共享 agents 根目录](2026-10-05-shared-agents-root-instructions.zh.md));`dsh-skill-filesystem` 仍接受自己的 `dshHome` 与 `agentsHome` 字段,用于选择它自己的 skill 根目录,并在指令加载改动中改用共享解析器。
|
||||
空或仅含空白的 `$DSH_HOME` 被当作未设置处理;否则,`resolve('')` 会悄悄把 home 落在当前工作目录。harness 把所有用户数据都放在同一个根目录下;不拆分到各自独立的 XDG 根目录。`dshHomePath(...segments)` 将部署负责的子路径拼接到该根目录下,`dsh-app-boot` 在挂载条目前向 Loader `!!js` 配置表达式暴露它,因此出厂组合无需复制解析器即可派生 `sessions` 和 `storages`。`dshHomeDisplay()` 为面向用户的路径以符号形式命名已解析的根目录——默认 home 显示为 `~/.dsh`,任何已配置的 home 显示为 `$DSH_HOME`——这样用户全局的 `AGENTS.md` 标签就绝不会泄露机器上的绝对路径。它取代了 agent-instructions 中自定义的「默认值 vs `$DSH_HOME`」判断。home 属于进程策略而非配置行:`dsh-agent-instructions` 不接受 home 覆盖,因此组合无法把指令加载指向会话、skill 与存储不会读取的根目录。`resolveAgentsHome()` 与 `agentsHomeDisplay()` 对共享 agent 配置根目录(`$DSH_AGENTS_HOME` 或 `~/.agents`)采用相同的优先级、波浪号展开与符号化标签;该根目录位于 harness home 之外,因为其他 agent 工具会共享它([共享 agents 根目录](2026-10-05-shared-agents-root-instructions.zh.md));`dsh-skill-filesystem` 仍接受自己的 `dshHome` 与 `agentsHome` 字段,用于选择它自己的 skill 根目录,并在指令加载改动中改用共享解析器。
|
||||
|
||||
`dshCachePath(...segments)` 在解析出的主目录下的 `cache` 目录中派生路径。首个 `{ dshHome }` 选项保留提供方显式配置的主目录覆盖值。它只解析路径,不创建目录;目录创建由调用方负责。`attachment-local` 将此函数用于可重新生成的请求图片版本,持久附件对象仍保留在其带版本的存储树中,因此清空缓存不会删除 Session 附件。已有请求图片缓存条目保留在原处,不再读取或复制;缓存未命中时从持久附件重新生成请求版本。
|
||||
`dshPath(category, ...segments)` 在该根目录下的 `config`、`data`、`state`、`cache` 或 `backup` 目录中派生路径,app-boot 将它与 `dshHomePath` 一并暴露给 Loader `!!js` 表达式;类别定义以及哪些现有条目保留顶层位置由 [home 路径类别提案](../../proposed/architecture/2026-11-04-dsh-home-path-categories.zh.md)负责。`dshCachePath(...segments)` 等同于 `dshPath('cache', ...segments)`。首个 `{ dshHome }` 选项保留提供方显式配置的主目录覆盖值。它只解析路径,不创建目录;目录创建由调用方负责。`attachment-local` 将此函数用于可重新生成的请求图片版本,持久附件对象仍保留在其带版本的存储树中,因此清空缓存不会删除 Session 附件。已有请求图片缓存条目保留在原处,不再读取或复制;缓存未命中时从持久附件重新生成请求版本。
|
||||
|
||||
`@deepseek-ai/dsh-home` 被删除。拥有 home 配置的提供方与 boot 包从 `dsh-home-paths` 导入 `resolveDshHome`;组合包只包含解析后的配置行。
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Bilingual-pair consistency record for 2026-11-04-dsh-home-path-categories.md (docs/i18n/README.md): per heading
|
||||
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write .agents/notes/proposed/architecture/2026-11-04-dsh-home-path-categories.md
|
||||
/agent-note-harness-home-path-categories:
|
||||
en: 007593701a0d6bf5
|
||||
zh: 3bf266378e3bba08
|
||||
/agent-note-harness-home-path-categories/problem:
|
||||
en: 3e98d90944daeb05
|
||||
zh: 596f750e878f3e69
|
||||
/agent-note-harness-home-path-categories/proposal:
|
||||
en: 76abf280dfdba9bc
|
||||
zh: 0ad29c3c67208086
|
||||
/agent-note-harness-home-path-categories/proposal/path-helper:
|
||||
en: 6f34630c5b05b0d7
|
||||
zh: 2106fdbf4f5ca852
|
||||
/agent-note-harness-home-path-categories/proposal/conventional-top-level-entries:
|
||||
en: 940f404152322a33
|
||||
zh: 5668927394d05723
|
||||
/agent-note-harness-home-path-categories/proposal/other-existing-entries:
|
||||
en: a8242fc3bbe3fe7a
|
||||
zh: b90f9e9deda18e78
|
||||
/agent-note-harness-home-path-categories/proposal/outside-the-home:
|
||||
en: 9d78c323d3f9d159
|
||||
zh: e11a87b74fe11e5c
|
||||
/agent-note-harness-home-path-categories/alternatives-considered:
|
||||
en: cfa4bc5557af4117
|
||||
zh: 7971e54d5770d9aa
|
||||
/agent-note-harness-home-path-categories/acceptance-criteria:
|
||||
en: bf87d444099ebb2b
|
||||
zh: 8315e6ddc07fe3c7
|
||||
/agent-note-harness-home-path-categories/risks:
|
||||
en: aa70b3a0243a1853
|
||||
zh: 64c74b62d3a42472
|
||||
@@ -0,0 +1,83 @@
|
||||
# Agent Note: Harness home path categories
|
||||
|
||||
Status: proposed
|
||||
|
||||
English | [中文](2026-11-04-dsh-home-path-categories.zh.md)
|
||||
|
||||
## Problem
|
||||
|
||||
Each package builds its own path under `$DSH_HOME` (default `~/.dsh`), so the home root mixes user configuration, durable records, logs, indexes, and downloads. A new service or plugin has no rule for where its files belong, and some owners resolve the home by hand: [liveshare](../../../../packages/experimental/liveshare/src/host/share-host.ts) reads `process.env.DSH_HOME` directly, and [migrate-sessions-to-v4](../../../../scripts/migrate-sessions-to-v4.ts) defaults to `~/.dsh/sessions` without reading `DSH_HOME`.
|
||||
|
||||
## Proposal
|
||||
|
||||
Group paths under `$DSH_HOME` by the kinds the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir/latest/) uses. Every category stays inside `$DSH_HOME`; the harness does not read `XDG_*` variables.
|
||||
|
||||
| Category | Holds | Losing it |
|
||||
|---|---|---|
|
||||
| `config` | Files a person writes or edits to configure the harness | Loses the user's configuration |
|
||||
| `data` | Durable records: user work, sign-ins, installed software | Loses user work, sign-ins, or installed software |
|
||||
| `state` | Records that persist across runs but are not user work: logs, indexes, ids, retained outputs | Resets history; the harness keeps working |
|
||||
| `cache` | Content the harness can rebuild or download again | Costs time or bandwidth only |
|
||||
| `backup` | Backup archives the harness writes, such as compressed copies of the home or a profile | Nothing; the archives are not read during normal operation |
|
||||
|
||||
There is no `runtime` category, the XDG kind for sockets and pid files, because no owner needs one under the home: locks sit beside the file they protect, and live sockets stay in the operating-system temporary directory because Unix socket paths have a length limit. `backup` is not an XDG kind: it gives backup archives one directory that users and cleanup tools can empty at any time without affecting a running harness or the records the archives copy.
|
||||
|
||||
### Path helper
|
||||
|
||||
[`dshPath(category, ...segments)`](../../../../packages/util/home-paths/src/index.ts) in `@deepseek-ai/dsh-home-paths` returns `<home>/<category>/<segments>` without creating directories; `dshPath({ category, dshHome }, ...segments)` resolves an explicit configured home. Loader `!!js` config expressions receive the same function beside `dshHomePath`. A new path under the home uses `dshPath` and passes its owner's directory name, normally the package name without the `@deepseek-ai/dsh-` prefix, as the first segment. `dshHomePath` remains for the existing top-level entries, and `dshCachePath` is `dshPath('cache', ...)`.
|
||||
|
||||
### Conventional top-level entries
|
||||
|
||||
Users open, edit, and script against these entries directly, and documentation across the repository names them, so they keep their current top-level locations and are not candidates for moving:
|
||||
|
||||
| Path under `$DSH_HOME` | Owner | Kind |
|
||||
|---|---|---|
|
||||
| `.env` | [app-boot](../../../../packages/boot/app-boot/README.md) environment layer | config |
|
||||
| `cordis.patch.yml` | [app-boot](../../../../packages/boot/app-boot/README.md) home patch layer | config |
|
||||
| `AGENTS.md` | [agent-instructions](../../../../packages/context/agent-instructions/README.md) | config |
|
||||
| `skills/` | [skill-filesystem](../../../../packages/skill/skill-filesystem/README.md) | config |
|
||||
| `.credentials.yaml` | [credentials-local](../../../../packages/credentials/credentials-local/README.md) | data |
|
||||
| `profiles/<name>/` | [app-boot](../../../../packages/boot/app-boot/README.md), plugin-manager, Desktop (`desktop` profile and its `lock`) | data |
|
||||
| `sessions/` | session-persistence-jsonl root in the base and sdk-minimal bundles | data |
|
||||
| `cache/` | already the `cache` category | cache |
|
||||
|
||||
Files inside a profile directory, such as `node_modules/`, `pnpm-lock.yaml`, `compatibility.json`, `.plugin-manager/`, `.plugin-market/repositories/`, `created-plugins/`, and `cua-*.lock`, stay with their profile because pnpm and the profile tools address them relative to it. The legacy `settings.yaml` importer keeps reading the home root because that file is the import source.
|
||||
|
||||
### Other existing entries
|
||||
|
||||
These entries have no user-facing convention. Each row names the category it belongs to; moving it is a separate change that needs a data migration plan:
|
||||
|
||||
| Current path under `$DSH_HOME` | Category | Owner | Why |
|
||||
|---|---|---|---|
|
||||
| `storages/` | `data` | storage-json root in the base bundle | Workspace, schedule, and other domain records; its `session_projcache` unit is a rebuildable cache, but storage-json has one root |
|
||||
| `attachments/v1/` | `data` | [attachment-local](../../../../packages/attachment/attachment-local/README.md) | User attachments; Session history records their absolute paths |
|
||||
| `dsh-runtimes/` | `data` | Desktop offline runtimes ([workspace-dependencies](../../../../packages/bundle/web-app/cordis.patch.yml)) | Installed software that may hold user additions |
|
||||
| `liveshare/` | `data` | [liveshare](../../../../packages/experimental/liveshare/README.md) owner state and credential | Holds management tokens |
|
||||
| `.anonymous-user-id` | `state` | [anonymous-user-id](../../../../packages/identity/anonymous-user-id/README.md) | Losing it only issues a new id |
|
||||
| `logs/` | `state` | CLI startup failure reports | Logs |
|
||||
| `llm-deepseek/files-v3.json` | `state` | [llm-deepseek](../../../../packages/llm/llm-deepseek/README.md) upload index | Derived index |
|
||||
| `office-kit/outputs/` | `state` | [office-kit](../../../../packages/document/office-kit/README.md) | Retained conversion outputs removed after their retention period |
|
||||
| `speech-to-text/sensevoice/` | `cache` | voice-input-bundle | Downloadable models |
|
||||
| `cache/attachments/` | `cache` | attachment-local request images | Already in `cache` |
|
||||
|
||||
### Outside the home
|
||||
|
||||
These locations are out of scope: `~/.agents` (`DSH_AGENTS_HOME`), shared with other agent tools; Electron `userData` and `logs`, managed by Electron; the Python SDK resource cache `~/.cache/deepseek-harness/resources` (`DSH_RESOURCE_CACHE`), shared across homes; spill and subprocess output directories under the operating-system temporary directory; and developer or release script state such as `~/.dsh-desktop-signing`.
|
||||
|
||||
## Alternatives considered
|
||||
|
||||
**Move every entry now.** A first draft moved all entries, including the conventional ones, into category directories with no fallback. It made every existing home look empty after an upgrade, broke absolute attachment paths recorded in Sessions, and renamed files users edit by hand. The conventional entries above now stay, and the remaining moves wait for a migration plan.
|
||||
|
||||
**Read `XDG_*` variables.** Splitting the home across `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, and similar roots would scatter one installation across several directories and break the single `DSH_HOME` override that tests, the SDK, and Desktop rely on; the [single harness home resolver](../../implemented/architecture/2026-07-24-single-harness-home-resolver.md) already rejected separate roots. The proposal borrows only the classification, inside that one root.
|
||||
|
||||
**Add a `runtime` category.** No current owner needs one; adding it would publish an unused value.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- New paths under `$DSH_HOME` are built with `dshPath` and land in one category directory.
|
||||
- Each move of an entry from "Other existing entries" ships with a migration that preserves existing user data, plus an upgrade guide.
|
||||
- The conventional top-level entries keep their locations.
|
||||
|
||||
## Risks
|
||||
|
||||
Until migrations land, the home holds both category directories and legacy top-level entries. Moving `attachments/` invalidates absolute paths in Session history unless the migration keeps the old location readable. Owners that resolve the home by hand do not pick up the helper until they are changed.
|
||||
@@ -0,0 +1,83 @@
|
||||
# Agent Note: harness home 路径类别
|
||||
|
||||
Status: proposed
|
||||
|
||||
[English](2026-11-04-dsh-home-path-categories.md) | 中文
|
||||
|
||||
## 问题
|
||||
|
||||
各个包在 `$DSH_HOME`(默认 `~/.dsh`)下自行构造路径,因此 home 根目录混杂着用户配置、持久记录、日志、索引和下载内容。新的服务或插件没有规则可以确定其文件应放在哪里,部分负责方还会手动解析 home:[liveshare](../../../../packages/experimental/liveshare/src/host/share-host.ts) 直接读取 `process.env.DSH_HOME`,[migrate-sessions-to-v4](../../../../scripts/migrate-sessions-to-v4.ts) 默认使用 `~/.dsh/sessions`,不读取 `DSH_HOME`。
|
||||
|
||||
## 方案
|
||||
|
||||
按照 [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir/latest/) 使用的类型,对 `$DSH_HOME` 下的路径分组。每个类别都位于 `$DSH_HOME` 内;harness 不读取 `XDG_*` 变量。
|
||||
|
||||
| 类别 | 存放内容 | 丢失后果 |
|
||||
|---|---|---|
|
||||
| `config` | 用户为配置 harness 而编写或编辑的文件 | 丢失用户配置 |
|
||||
| `data` | 持久记录:用户工作成果、登录信息、已安装的软件 | 丢失用户工作成果、登录信息或已安装的软件 |
|
||||
| `state` | 跨运行保留但不属于用户工作成果的记录:日志、索引、id、保留的输出 | 历史被重置;harness 仍可正常工作 |
|
||||
| `cache` | harness 可以重新构建或重新下载的内容 | 仅耗费时间或带宽 |
|
||||
| `backup` | harness 写入的备份压缩包,例如 home 或 profile 的压缩副本 | 无影响;正常运行时不会读取这些压缩包 |
|
||||
|
||||
不设 `runtime` 类别(XDG 中用于 socket 和 pid 文件的类型),因为没有负责方需要在 home 下使用它:锁文件放在其保护的文件旁边,而活动的 socket 留在操作系统临时目录中,因为 Unix socket 路径有长度限制。`backup` 不是 XDG 的类型:它为备份压缩包提供一个目录,用户和清理工具可以随时清空,不影响运行中的 harness,也不影响被备份的记录。
|
||||
|
||||
### 路径辅助函数
|
||||
|
||||
`@deepseek-ai/dsh-home-paths` 中的 [`dshPath(category, ...segments)`](../../../../packages/util/home-paths/src/index.ts) 返回 `<home>/<category>/<segments>`,不创建目录;`dshPath({ category, dshHome }, ...segments)` 基于显式配置的 home 解析路径。Loader `!!js` 配置表达式在 `dshHomePath` 之外也可以使用同一个函数。home 下的新路径使用 `dshPath`,并把负责方的目录名作为第一个路径段传入,该目录名通常是去掉 `@deepseek-ai/dsh-` 前缀的包名。`dshHomePath` 继续用于现有的顶层条目,`dshCachePath` 等同于 `dshPath('cache', ...)`。
|
||||
|
||||
### 约定的顶层条目
|
||||
|
||||
用户会直接打开、编辑这些条目并在脚本中引用它们,仓库中的文档也提到它们,因此它们保留当前的顶层位置,不在迁移候选之列:
|
||||
|
||||
| `$DSH_HOME` 下的路径 | 负责方 | 类型 |
|
||||
|---|---|---|
|
||||
| `.env` | [app-boot](../../../../packages/boot/app-boot/README.zh.md) 环境层 | config |
|
||||
| `cordis.patch.yml` | [app-boot](../../../../packages/boot/app-boot/README.zh.md) home patch 层 | config |
|
||||
| `AGENTS.md` | [agent-instructions](../../../../packages/context/agent-instructions/README.zh.md) | config |
|
||||
| `skills/` | [skill-filesystem](../../../../packages/skill/skill-filesystem/README.zh.md) | config |
|
||||
| `.credentials.yaml` | [credentials-local](../../../../packages/credentials/credentials-local/README.zh.md) | data |
|
||||
| `profiles/<name>/` | [app-boot](../../../../packages/boot/app-boot/README.zh.md)、plugin-manager、Desktop(`desktop` profile 及其 `lock`) | data |
|
||||
| `sessions/` | base 和 sdk-minimal bundle 中的 session-persistence-jsonl 根目录 | data |
|
||||
| `cache/` | 已经是 `cache` 类别 | cache |
|
||||
|
||||
profile 目录内的文件,例如 `node_modules/`、`pnpm-lock.yaml`、`compatibility.json`、`.plugin-manager/`、`.plugin-market/repositories/`、`created-plugins/` 和 `cua-*.lock`,随所属 profile 保留,因为 pnpm 和 profile 工具按相对于 profile 的路径访问它们。旧版 `settings.yaml` 导入器继续读取 home 根目录,因为该文件是导入来源。
|
||||
|
||||
### 其他现有条目
|
||||
|
||||
这些条目没有面向用户的约定。每一行给出该条目所属的类别;迁移它属于单独的变更,需要数据迁移方案:
|
||||
|
||||
| `$DSH_HOME` 下的当前路径 | 类别 | 负责方 | 原因 |
|
||||
|---|---|---|---|
|
||||
| `storages/` | `data` | base bundle 中的 storage-json 根目录 | Workspace、schedule 及其他领域记录;其中 `session_projcache` 单元是可重建的缓存,但 storage-json 只有一个根目录 |
|
||||
| `attachments/v1/` | `data` | [attachment-local](../../../../packages/attachment/attachment-local/README.zh.md) | 用户附件;Session 历史记录了它们的绝对路径 |
|
||||
| `dsh-runtimes/` | `data` | Desktop 离线运行时([workspace-dependencies](../../../../packages/bundle/web-app/cordis.patch.yml)) | 已安装的软件,可能包含用户添加的内容 |
|
||||
| `liveshare/` | `data` | [liveshare](../../../../packages/experimental/liveshare/README.zh.md) 的所有者状态和凭据 | 存放管理令牌 |
|
||||
| `.anonymous-user-id` | `state` | [anonymous-user-id](../../../../packages/identity/anonymous-user-id/README.zh.md) | 丢失后只会生成新的 id |
|
||||
| `logs/` | `state` | CLI 启动失败报告 | 日志 |
|
||||
| `llm-deepseek/files-v3.json` | `state` | [llm-deepseek](../../../../packages/llm/llm-deepseek/README.zh.md) 上传索引 | 派生索引 |
|
||||
| `office-kit/outputs/` | `state` | [office-kit](../../../../packages/document/office-kit/README.zh.md) | 保留的转换输出,超过保留期后删除 |
|
||||
| `speech-to-text/sensevoice/` | `cache` | voice-input-bundle | 可下载的模型 |
|
||||
| `cache/attachments/` | `cache` | attachment-local 请求图片 | 已位于 `cache` 中 |
|
||||
|
||||
### home 之外
|
||||
|
||||
以下位置不在本提案范围内:`~/.agents`(`DSH_AGENTS_HOME`),与其他 agent 工具共享;Electron 的 `userData` 和 `logs`,由 Electron 管理;Python SDK 资源缓存 `~/.cache/deepseek-harness/resources`(`DSH_RESOURCE_CACHE`),在多个 home 之间共享;操作系统临时目录下的 spill 和子进程输出目录;以及开发者或发布脚本的状态,例如 `~/.dsh-desktop-signing`。
|
||||
|
||||
## 备选方案
|
||||
|
||||
**立即迁移所有条目。** 最初的草案把所有条目(包括约定的条目)都移入类别目录,且不提供回退。这样做会使每个现有 home 在升级后看起来为空,使 Session 中记录的附件绝对路径失效,并重命名用户手动编辑的文件。上述约定条目现在保持不动,其余迁移等待迁移方案。
|
||||
|
||||
**读取 `XDG_*` 变量。** 把 home 拆分到 `XDG_CONFIG_HOME`、`XDG_DATA_HOME` 等多个根目录,会让一次安装分散到多个目录,并破坏测试、SDK 和 Desktop 所依赖的单一 `DSH_HOME` 覆盖;[单一 harness home 解析器](../../implemented/architecture/2026-07-24-single-harness-home-resolver.zh.md)已经否决了拆分根目录。本提案只借用分类方式,并且仍在这一个根目录之内。
|
||||
|
||||
**增加 `runtime` 类别。** 当前没有负责方需要它;增加它会发布一个未使用的值。
|
||||
|
||||
## 验收标准
|
||||
|
||||
- `$DSH_HOME` 下的新路径使用 `dshPath` 构造,并落在某一个类别目录中。
|
||||
- 每次迁移“其他现有条目”中的条目时,都附带一个保留现有用户数据的迁移,以及一份升级指南。
|
||||
- 约定的顶层条目保留其位置。
|
||||
|
||||
## 风险
|
||||
|
||||
在迁移落地之前,home 中同时存在类别目录和旧的顶层条目。迁移 `attachments/` 会使 Session 历史中的绝对路径失效,除非迁移保持旧位置可读。手动解析 home 的负责方在被修改之前不会使用该辅助函数。
|
||||
@@ -28,7 +28,7 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
|
||||
| `api-session/error` | `emit` | [`packages/api/session-controller/src/types.ts:712`](../packages/api/session-controller/src/types.ts) | `session-controller` (`emit`) | `remotes` |
|
||||
| `api-session/removed` | `emit` | [`packages/api/session-controller/src/types.ts:691`](../packages/api/session-controller/src/types.ts) | `session-controller` (`emit`) | `remotes` |
|
||||
| `api-session/status` | `emit` | [`packages/api/session-controller/src/types.ts:698`](../packages/api/session-controller/src/types.ts) | `session-controller` (`emit`) | `remotes` |
|
||||
| `app-boot/config-reload` | `emit` | [`packages/boot/app-boot/src/index.ts:55`](../packages/boot/app-boot/src/index.ts) | [`app-boot`](../packages/boot/app-boot) (`emit`) | [`settings`](../packages/settings/settings) |
|
||||
| `app-boot/config-reload` | `emit` | [`packages/boot/app-boot/src/index.ts:57`](../packages/boot/app-boot/src/index.ts) | [`app-boot`](../packages/boot/app-boot) (`emit`) | [`settings`](../packages/settings/settings) |
|
||||
| `approval/request` | `waterfall` | [`packages/interaction/user-approval/src/types.ts:87`](../packages/interaction/user-approval/src/types.ts) | [`user-approval`](../packages/interaction/user-approval) (`waterfall`) | [`acp`](../packages/acp/acp), `remotes`, `server` |
|
||||
| `authorization/settled` | `emit` | [`packages/credentials/authorization/src/index.ts:57`](../packages/credentials/authorization/src/index.ts) | [`authorization`](../packages/credentials/authorization) (`events.dispatch`) | - |
|
||||
| `commands/change` | `emit` | [`packages/interaction/commands/src/types.ts:89`](../packages/interaction/commands/src/types.ts) | [`commands`](../packages/interaction/commands) (`events.dispatch`) | `remotes` |
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
| `api-session/error` | `emit` | [`packages/api/session-controller/src/types.ts:712`](../packages/api/session-controller/src/types.ts) | `session-controller` (`emit`) | `remotes` |
|
||||
| `api-session/removed` | `emit` | [`packages/api/session-controller/src/types.ts:691`](../packages/api/session-controller/src/types.ts) | `session-controller` (`emit`) | `remotes` |
|
||||
| `api-session/status` | `emit` | [`packages/api/session-controller/src/types.ts:698`](../packages/api/session-controller/src/types.ts) | `session-controller` (`emit`) | `remotes` |
|
||||
| `app-boot/config-reload` | `emit` | [`packages/boot/app-boot/src/index.ts:55`](../packages/boot/app-boot/src/index.ts) | [`app-boot`](../packages/boot/app-boot) (`emit`) | [`settings`](../packages/settings/settings) |
|
||||
| `app-boot/config-reload` | `emit` | [`packages/boot/app-boot/src/index.ts:57`](../packages/boot/app-boot/src/index.ts) | [`app-boot`](../packages/boot/app-boot) (`emit`) | [`settings`](../packages/settings/settings) |
|
||||
| `approval/request` | `waterfall` | [`packages/interaction/user-approval/src/types.ts:87`](../packages/interaction/user-approval/src/types.ts) | [`user-approval`](../packages/interaction/user-approval) (`waterfall`) | [`acp`](../packages/acp/acp), `remotes`, `server` |
|
||||
| `authorization/settled` | `emit` | [`packages/credentials/authorization/src/index.ts:57`](../packages/credentials/authorization/src/index.ts) | [`authorization`](../packages/credentials/authorization) (`events.dispatch`) | - |
|
||||
| `commands/change` | `emit` | [`packages/interaction/commands/src/types.ts:89`](../packages/interaction/commands/src/types.ts) | [`commands`](../packages/interaction/commands) (`events.dispatch`) | `remotes` |
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Context, type Fiber, type FiberState } from '@deepseek-ai/cordis'
|
||||
import Loader, { type Entry, type EntryGroup, type EntryOptions } from '@deepseek-ai/cordis-plugin-loader'
|
||||
import Include, { applyEntryPatches, entryListSchema, type PatchOptions } from '@deepseek-ai/cordis-plugin-include'
|
||||
import Group from '@deepseek-ai/cordis-plugin-group'
|
||||
import { dshHomePath, resolveDshHome } from '@deepseek-ai/dsh-home-paths'
|
||||
import { dshHomePath, dshPath, resolveDshHome } from '@deepseek-ai/dsh-home-paths'
|
||||
import { createLaunchEnvironmentSnapshot, type LaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
|
||||
export { readBundlePatches, readProfilePatches, resolveTelemetryPatch, type ProfileContext, type ProfilePnpmInvocation } from './profile-context.ts'
|
||||
export { sanitizeProfile } from './profile-sanitize.ts'
|
||||
@@ -44,6 +44,8 @@ declare module '@deepseek-ai/cordis' {
|
||||
interface Context {
|
||||
/** Harness-home path resolver available to Loader `!!js` config expressions. */
|
||||
dshHomePath?: typeof dshHomePath
|
||||
/** Harness-home category path resolver available to Loader `!!js` config expressions. */
|
||||
dshPath?: typeof dshPath
|
||||
}
|
||||
|
||||
interface Events {
|
||||
@@ -1241,6 +1243,7 @@ export async function boot(
|
||||
try {
|
||||
ctx.baseUrl = pathToFileURL(dirname(absoluteConfigPath)).href + '/'
|
||||
ctx.provide('dshHomePath', dshHomePath)
|
||||
ctx.provide('dshPath', dshPath)
|
||||
await ctx.plugin(Loader)
|
||||
await prepare?.(ctx)
|
||||
stage = 'plugin tree failed to load'
|
||||
|
||||
@@ -1068,7 +1068,7 @@ describe('boot', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('exposes dshHomePath to Loader config expressions', async () => {
|
||||
it('exposes dshHomePath and dshPath to Loader config expressions', async () => {
|
||||
const dir = tmp()
|
||||
const dshHome = join(dir, 'home')
|
||||
vi.stubEnv('DSH_HOME', dshHome)
|
||||
@@ -1076,6 +1076,7 @@ describe('boot', () => {
|
||||
'export const name = "capture"',
|
||||
'export function apply(ctx, config) {',
|
||||
' ctx.provide("capturedPath", config.path)',
|
||||
' ctx.provide("capturedStatePath", config.state)',
|
||||
'}',
|
||||
'',
|
||||
].join('\n'))
|
||||
@@ -1084,12 +1085,14 @@ describe('boot', () => {
|
||||
' name: ./capture.mjs',
|
||||
' config:',
|
||||
" path: !!js dshHomePath('sessions')",
|
||||
" state: !!js dshPath('state', 'capture')",
|
||||
'',
|
||||
].join('\n'))
|
||||
let ctx: Context | undefined
|
||||
try {
|
||||
ctx = await boot(NAME, join(dir, 'cordis.yml'))
|
||||
expect(ctx.get('capturedPath')).toBe(join(dshHome, 'sessions'))
|
||||
expect(ctx.get('capturedStatePath')).toBe(join(dshHome, 'state', 'capture'))
|
||||
} finally {
|
||||
await ctx?.fiber.dispose()
|
||||
vi.unstubAllEnvs()
|
||||
|
||||
@@ -227,11 +227,32 @@ describe('MessageItem arms', () => {
|
||||
expect(exec).toHaveBeenCalledWith('copy')
|
||||
})
|
||||
|
||||
it('user copy succeeds through execCommand when the host refuses the async write', async () => {
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
configurable: true,
|
||||
value: { writeText: vi.fn().mockRejectedValue(new Error('denied')) },
|
||||
})
|
||||
const exec = vi.fn().mockReturnValue(true)
|
||||
Object.defineProperty(document, 'execCommand', { configurable: true, value: exec })
|
||||
render(
|
||||
<MessageItem t={t} node={{
|
||||
kind: 'user', seq: 1, time: 1_000,
|
||||
content: [{ type: 'text', text: 'refused body' }] as never,
|
||||
source: null,
|
||||
}}
|
||||
/>,
|
||||
)
|
||||
fireEvent.click(screen.getByRole('button', { name: '复制' }))
|
||||
expect(await screen.findByRole('button', { name: '复制成功' })).toBeTruthy()
|
||||
expect(exec).toHaveBeenCalledWith('copy')
|
||||
})
|
||||
|
||||
it('user copy never claims success when the host rejects the write', async () => {
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
configurable: true,
|
||||
value: { writeText: vi.fn().mockRejectedValue(new Error('denied')) },
|
||||
})
|
||||
Object.defineProperty(document, 'execCommand', { configurable: true, value: vi.fn(() => false) })
|
||||
render(
|
||||
<MessageItem t={t} node={{
|
||||
kind: 'user', seq: 1, time: 1_000,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// Host clipboard write shared by Web UI copy controls. Success feedback stays
|
||||
// with each control; this helper only reports whether the host accepted a write.
|
||||
// with each control; this helper reports whether the host accepted a write and
|
||||
// leaves focus where it found it.
|
||||
|
||||
/**
|
||||
* Write text to the host clipboard, preferring the async Clipboard API and
|
||||
* falling back to `execCommand('copy')` on hosts (jsdom, insecure contexts)
|
||||
* that omit it.
|
||||
* falling back to `execCommand('copy')` when that API is missing (jsdom,
|
||||
* insecure contexts) or refuses the write (for example, a denied clipboard
|
||||
* permission). The fallback replaces the page selection and succeeds only while
|
||||
* the triggering user gesture's transient activation is still valid.
|
||||
* @param text - the exact text to place on the clipboard.
|
||||
* @returns true only when the host accepted the write.
|
||||
*/
|
||||
@@ -16,32 +19,33 @@ export async function writeClipboard(text: string): Promise<boolean> {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
return true
|
||||
} catch {
|
||||
// Denied permissions / iframe policy — do not claim success.
|
||||
return false
|
||||
} catch (_error) {
|
||||
// A denied permission can block the async API while execCommand still works; try it below.
|
||||
}
|
||||
}
|
||||
// jsdom and older hosts: best-effort execCommand path when present.
|
||||
// execCommand('copy') is the only clipboard fallback where the async API
|
||||
// is missing; deprecated but deliberately retained.
|
||||
// is missing or refused; deprecated but deliberately retained.
|
||||
/* oxlint-disable typescript/no-deprecated */
|
||||
const exec = typeof document.execCommand === 'function'
|
||||
? document.execCommand.bind(document)
|
||||
: undefined
|
||||
if (exec === undefined) return false
|
||||
// Selecting the textarea moves focus; return it so a keyboard user stays on the copy control.
|
||||
const focused = document.activeElement
|
||||
const el = document.createElement('textarea')
|
||||
el.value = text
|
||||
el.setAttribute('readonly', '')
|
||||
el.style.position = 'fixed'
|
||||
el.style.left = '-9999px'
|
||||
document.body.appendChild(el)
|
||||
el.select()
|
||||
try {
|
||||
document.body.appendChild(el)
|
||||
el.select()
|
||||
return exec('copy')
|
||||
} catch {
|
||||
return false
|
||||
} finally {
|
||||
el.remove()
|
||||
if (focused instanceof HTMLElement) focused.focus({ preventScroll: true })
|
||||
}
|
||||
/* oxlint-enable typescript/no-deprecated */
|
||||
}
|
||||
@@ -448,14 +448,32 @@ describe('writeClipboard', () => {
|
||||
expect(writeText).toHaveBeenCalledWith('payload')
|
||||
})
|
||||
|
||||
it('reports false when the Clipboard API rejects', async () => {
|
||||
it('reports false when the Clipboard API rejects and no fallback exists', async () => {
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
configurable: true,
|
||||
value: { writeText: vi.fn().mockRejectedValue(new Error('denied')) },
|
||||
})
|
||||
Object.defineProperty(document, 'execCommand', { configurable: true, value: undefined })
|
||||
await expect(writeClipboard('payload')).resolves.toBe(false)
|
||||
})
|
||||
|
||||
it('falls back to execCommand when the Clipboard API rejects', async () => {
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
configurable: true,
|
||||
value: { writeText: vi.fn().mockRejectedValue(new Error('denied')) },
|
||||
})
|
||||
let selected: string | undefined
|
||||
const exec = vi.fn(() => {
|
||||
selected = document.querySelector<HTMLTextAreaElement>('textarea[readonly]')?.value
|
||||
return true
|
||||
})
|
||||
Object.defineProperty(document, 'execCommand', { configurable: true, value: exec })
|
||||
await expect(writeClipboard('payload')).resolves.toBe(true)
|
||||
expect(exec).toHaveBeenCalledWith('copy')
|
||||
expect(selected).toBe('payload')
|
||||
expect(document.querySelector('textarea')).toBeNull()
|
||||
})
|
||||
|
||||
it('selects a detached textarea for the execCommand fallback and removes it after', async () => {
|
||||
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: undefined })
|
||||
let selected: string | undefined
|
||||
@@ -470,6 +488,25 @@ describe('writeClipboard', () => {
|
||||
expect(document.querySelector('textarea')).toBeNull()
|
||||
})
|
||||
|
||||
it('returns focus to the copy control after the execCommand fallback', async () => {
|
||||
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: undefined })
|
||||
Object.defineProperty(document, 'execCommand', { configurable: true, value: vi.fn(() => true) })
|
||||
const button = document.createElement('button')
|
||||
document.body.appendChild(button)
|
||||
button.focus()
|
||||
await expect(writeClipboard('payload')).resolves.toBe(true)
|
||||
expect(document.activeElement).toBe(button)
|
||||
button.remove()
|
||||
})
|
||||
|
||||
it('copies through the fallback when nothing had focus', async () => {
|
||||
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: undefined })
|
||||
Object.defineProperty(document, 'execCommand', { configurable: true, value: vi.fn(() => true) })
|
||||
const activeElement = vi.spyOn(document, 'activeElement', 'get').mockReturnValue(null)
|
||||
await expect(writeClipboard('payload')).resolves.toBe(true)
|
||||
activeElement.mockRestore()
|
||||
})
|
||||
|
||||
it('reports execCommand\'s own refusal verbatim', async () => {
|
||||
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: undefined })
|
||||
Object.defineProperty(document, 'execCommand', { configurable: true, value: vi.fn(() => false) })
|
||||
|
||||
@@ -407,6 +407,8 @@ describe('ui-workspace apply', () => {
|
||||
if (!accepted) throw new Error('clipboard denied')
|
||||
})
|
||||
vi.stubGlobal('navigator', { clipboard: { writeText } })
|
||||
// This spec has no DOM; give the fallback a document without execCommand so a refused write stays refused.
|
||||
vi.stubGlobal('document', {})
|
||||
onTestFinished(() => { vi.unstubAllGlobals() })
|
||||
await action.copySessionId(sid('cold-session'))
|
||||
expect(writeText).toHaveBeenCalledExactlyOnceWith('cold-session')
|
||||
|
||||
@@ -131,6 +131,7 @@ describe('Typert-backed Cordis catalog', () => {
|
||||
// plugin that provides it" for a key where no such plugin exists.
|
||||
expect(byKey.has('headlessIo')).toBe(false)
|
||||
expect(byKey.has('dshHomePath')).toBe(false)
|
||||
expect(byKey.has('dshPath')).toBe(false)
|
||||
expect(byKey.has('launcherEnvironment')).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -3,8 +3,8 @@
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/util/home-paths/README.md
|
||||
/:
|
||||
en: 412be6dc9650b620
|
||||
zh: 2a8c5a9f8567823e
|
||||
en: f9a4cf8ae5a00fa2
|
||||
zh: a7fccbffa7e63ae5
|
||||
/deepseek-ai-dsh-home-paths:
|
||||
en: 6a18bcb84ce35987
|
||||
zh: f26144b659925421
|
||||
@@ -18,8 +18,11 @@
|
||||
en: 5322022224da2f27
|
||||
zh: d5cba67f4ea3e429
|
||||
/deepseek-ai-dsh-home-paths/use-this-package/resolving-the-home:
|
||||
en: e681c83a7977404f
|
||||
zh: 618c04e09385c417
|
||||
en: da3b53cf08826d46
|
||||
zh: a0d25c8932307bbd
|
||||
/deepseek-ai-dsh-home-paths/use-this-package/choosing-a-category-for-a-new-path:
|
||||
en: b067146c36447eee
|
||||
zh: a3c1c4955842ddf4
|
||||
/deepseek-ai-dsh-home-paths/use-this-package/resolving-the-shared-agents-root:
|
||||
en: 899c53a36b4a77cd
|
||||
zh: 216532c8876d201d
|
||||
@@ -39,8 +42,8 @@
|
||||
en: 584610e67c4aa386
|
||||
zh: 766f77e35c65193d
|
||||
/deepseek-ai-dsh-home-paths/understand-the-implementation/resolution-rules:
|
||||
en: 0315e0bd66f98ac6
|
||||
zh: ba3a26a19e0bda5c
|
||||
en: f8935bcc43a7749e
|
||||
zh: 863e3f58eb88b342
|
||||
/deepseek-ai-dsh-home-paths/understand-the-implementation/canonicalization-mechanics:
|
||||
en: a79aecd162317dc2
|
||||
zh: 342f9bae0231c3de
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
description: "Shared resolution of the DeepSeek Harness home and the shared agent configuration root, plus user-data paths, tilde expansion, and stable watch paths."
|
||||
description: "Shared resolution of the DeepSeek Harness home, its config, data, state, cache, and backup category paths, and the shared agent configuration root, plus tilde expansion and stable watch paths."
|
||||
kind: "package-library"
|
||||
---
|
||||
|
||||
@@ -40,6 +40,20 @@ An explicit configured path has the highest precedence, then `$DSH_HOME`, then t
|
||||
|
||||
`dshCachePath(...segments)` derives paths from the resolved home's `cache` directory. With no segments it returns the cache directory itself. Pass an initial options object, `dshCachePath({ dshHome: home }, ...segments)`, to use an explicit configured home with the same precedence and tilde expansion. It returns an absolute path without creating directories.
|
||||
|
||||
<a id="choosing-a-category"></a>
|
||||
### Choosing a category for a new path
|
||||
|
||||
```ts
|
||||
import { dshPath } from '@deepseek-ai/dsh-home-paths'
|
||||
|
||||
const index = dshPath('state', 'my-plugin', 'index.json') // $DSH_HOME/state/my-plugin/index.json
|
||||
const models = dshPath({ category: 'cache', dshHome: '~/other-dsh' }, 'my-plugin') // ~/other-dsh/cache/my-plugin
|
||||
```
|
||||
|
||||
A new file under the home uses `dshPath(category, ...segments)` and passes its owner's directory name, normally the package name without the `@deepseek-ai/dsh-` prefix, as the first segment. Use `config` for files a person writes to configure the harness, `data` for records whose loss loses user work, sign-ins, or installed software, `state` for logs, indexes, ids, and other records the harness can lose without losing user work, `cache` for content it can rebuild or download again, and `backup` for backup archives, which users can delete at any time without affecting the harness. Loader `!!js` config expressions receive the same function, for example `root: !!js dshPath('data', 'my-plugin')`. `dshPath` returns an absolute path without creating directories.
|
||||
|
||||
Existing entries keep their current locations: conventional top-level entries such as `sessions/`, `profiles/`, `skills/`, `AGENTS.md`, `.env`, and `.credentials.yaml` stay at the top level, and the [home path categories proposal](../../../.agents/notes/proposed/architecture/2026-11-04-dsh-home-path-categories.md) lists the category of every other existing path.
|
||||
|
||||
### Resolving the shared agents root
|
||||
|
||||
```ts
|
||||
@@ -81,7 +95,7 @@ The package is built on one principle: harness user data lives under one root, a
|
||||
|
||||
### Resolution rules
|
||||
|
||||
`resolveDshHome` reads the explicit override, then `$DSH_HOME`, then falls back to the operating-system home joined with `.dsh`. `resolveAgentsHome` reads the same three levels for `$DSH_AGENTS_HOME` and `~/.agents`. The chosen value is tilde-expanded and normalized to an absolute path; `dshHomePath` joins child segments with Node's platform path rules. `dshHomeDisplay` and `agentsHomeDisplay` compare the resolved path against the default root and return the symbolic label, so a configured root never leaks its absolute path.
|
||||
`resolveDshHome` reads the explicit override, then `$DSH_HOME`, then falls back to the operating-system home joined with `.dsh`. `resolveAgentsHome` reads the same three levels for `$DSH_AGENTS_HOME` and `~/.agents`. The chosen value is tilde-expanded and normalized to an absolute path; `dshHomePath` and `dshPath` join child segments with Node's platform path rules. `dshHomeDisplay` and `agentsHomeDisplay` compare the resolved path against the default root and return the symbolic label, so a configured root never leaks its absolute path.
|
||||
|
||||
### Canonicalization mechanics
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
description: "DeepSeek Harness 主目录与共享 agent 配置根目录的共享解析,以及用户数据路径、波浪号展开与稳定监听路径。"
|
||||
description: "DeepSeek Harness 主目录、其 config、data、state、cache 与 backup 类别路径以及共享 agent 配置根目录的共享解析,以及波浪号展开与稳定监听路径。"
|
||||
kind: "package-library"
|
||||
---
|
||||
|
||||
@@ -40,6 +40,20 @@ const cache = dshCachePath('models') // $DSH_HOME/cache/models, default
|
||||
|
||||
`dshCachePath(...segments)` 从解析出的主目录下的 `cache` 目录派生路径。不传路径段时返回缓存目录本身。传入首个选项对象 `dshCachePath({ dshHome: home }, ...segments)` 可使用显式配置的主目录,遵循相同的优先级与波浪号展开规则。它返回绝对路径,不会创建目录。
|
||||
|
||||
<a id="choosing-a-category"></a>
|
||||
### 为新路径选择类别
|
||||
|
||||
```ts
|
||||
import { dshPath } from '@deepseek-ai/dsh-home-paths'
|
||||
|
||||
const index = dshPath('state', 'my-plugin', 'index.json') // $DSH_HOME/state/my-plugin/index.json
|
||||
const models = dshPath({ category: 'cache', dshHome: '~/other-dsh' }, 'my-plugin') // ~/other-dsh/cache/my-plugin
|
||||
```
|
||||
|
||||
主目录下的新文件使用 `dshPath(category, ...segments)`,并把负责方的目录名作为第一个路径段传入,该目录名通常是去掉 `@deepseek-ai/dsh-` 前缀的包名。`config` 用于用户为配置 harness 而编写的文件;`data` 用于丢失后会导致用户工作成果、登录信息或已安装软件丢失的记录;`state` 用于日志、索引、id,以及 harness 丢失后不会导致用户工作成果丢失的其他记录;`cache` 用于 harness 可以重新构建或重新下载的内容,`backup` 用于备份压缩包,用户可以随时删除,不影响 harness 运行。Loader `!!js` 配置表达式也可以使用同一个函数,例如 `root: !!js dshPath('data', 'my-plugin')`。`dshPath` 返回绝对路径,不会创建目录。
|
||||
|
||||
现有条目保留当前位置:`sessions/`、`profiles/`、`skills/`、`AGENTS.md`、`.env` 和 `.credentials.yaml` 等约定的顶层条目保留在顶层,其他每个现有路径所属的类别由 [home 路径类别提案](../../../.agents/notes/proposed/architecture/2026-11-04-dsh-home-path-categories.zh.md)列出。
|
||||
|
||||
### 解析共享 agents 根目录
|
||||
|
||||
```ts
|
||||
@@ -81,7 +95,7 @@ agentsHomeDisplay(agents) // ~/.agents, or $DSH_AGENTS_HOME for any c
|
||||
|
||||
### 解析规则
|
||||
|
||||
`resolveDshHome` 先读显式覆盖值,然后读 `$DSH_HOME`,最后回退到操作系统主目录拼接 `.dsh`。`resolveAgentsHome` 对 `$DSH_AGENTS_HOME` 与 `~/.agents` 读取同样的三层值。选中的值经过波浪号展开并规范化为绝对路径;`dshHomePath` 用 Node 的平台路径规则拼接子路径段。`dshHomeDisplay` 与 `agentsHomeDisplay` 把解析出的路径与默认根目录比较并返回符号标签,因此已配置的根目录绝不泄露其绝对路径。
|
||||
`resolveDshHome` 先读显式覆盖值,然后读 `$DSH_HOME`,最后回退到操作系统主目录拼接 `.dsh`。`resolveAgentsHome` 对 `$DSH_AGENTS_HOME` 与 `~/.agents` 读取同样的三层值。选中的值经过波浪号展开并规范化为绝对路径;`dshHomePath` 与 `dshPath` 用 Node 的平台路径规则拼接子路径段。`dshHomeDisplay` 与 `agentsHomeDisplay` 把解析出的路径与默认根目录比较并返回符号标签,因此已配置的根目录绝不泄露其绝对路径。
|
||||
|
||||
### 规范化机制
|
||||
|
||||
|
||||
@@ -153,7 +153,8 @@ export function resolveAgentsHome(configured?: string, env: Record<string, strin
|
||||
}
|
||||
|
||||
/**
|
||||
* Join path segments onto the resolved DeepSeek Harness home.
|
||||
* Join path segments onto the resolved DeepSeek Harness home. It addresses the
|
||||
* existing top-level entries; a new path uses {@link dshPath} with its category.
|
||||
* @param segments - path segments appended to the Harness home; an empty list returns the home itself.
|
||||
* @returns the normalized absolute joined path.
|
||||
*/
|
||||
@@ -168,8 +169,48 @@ export function dshHomePath(...segments: string[]): string {
|
||||
* @returns the normalized absolute cache path.
|
||||
*/
|
||||
export function dshCachePath(optionsOrSegment: { dshHome?: string } | string = {}, ...segments: string[]): string {
|
||||
if (typeof optionsOrSegment === 'string') return dshHomePath('cache', optionsOrSegment, ...segments)
|
||||
return join(resolveDshHome(optionsOrSegment.dshHome), 'cache', ...segments)
|
||||
if (typeof optionsOrSegment === 'string') return dshPath('cache', optionsOrSegment, ...segments)
|
||||
return dshPath({ category: 'cache', dshHome: optionsOrSegment.dshHome }, ...segments)
|
||||
}
|
||||
|
||||
/**
|
||||
* Category directory under the Harness home, named after the XDG Base Directory
|
||||
* kinds. A new file kept under `$DSH_HOME` belongs to exactly one category, and
|
||||
* the category directory name equals the category. Existing top-level entries,
|
||||
* such as `sessions/`, `profiles/`, and `.credentials.yaml`, keep their current
|
||||
* locations; the [home path categories proposal](../../../../.agents/notes/proposed/architecture/2026-11-04-dsh-home-path-categories.md)
|
||||
* lists every path and its category:
|
||||
*
|
||||
* - `config`: files a person writes or edits to configure the harness.
|
||||
* - `data`: durable records whose loss loses user work, sign-ins, or installed
|
||||
* software, such as Sessions, profiles, attachments, credentials, and runtimes.
|
||||
* - `state`: records that persist across runs but whose loss only resets
|
||||
* history or derived indexes, such as logs, upload indexes, and ids.
|
||||
* - `cache`: content that can be rebuilt or downloaded again.
|
||||
* - `backup`: backup archives the harness writes; deleting them never affects
|
||||
* a running harness or the records they copy.
|
||||
*/
|
||||
export type DshHomeCategory = 'config' | 'data' | 'state' | 'cache' | 'backup'
|
||||
|
||||
/** A category directory under an explicitly configured Harness home. */
|
||||
export interface DshPathLocation {
|
||||
/** Category directory to join under. */
|
||||
category: DshHomeCategory
|
||||
/** Explicit harness-home override, resolved by {@link resolveDshHome}; omission uses `$DSH_HOME`, then `~/.dsh`. */
|
||||
dshHome?: string | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Join path segments onto one category directory of the Harness home without
|
||||
* creating it. An owner passes its own directory name, normally its package
|
||||
* name without the `@deepseek-ai/dsh-` prefix, as the first segment.
|
||||
* @param location - category under the resolved home, or a category with an explicit home override.
|
||||
* @param segments - path segments appended to the category directory; an empty list returns the directory itself.
|
||||
* @returns the normalized absolute path.
|
||||
*/
|
||||
export function dshPath(location: DshHomeCategory | DshPathLocation, ...segments: string[]): string {
|
||||
const { category, dshHome } = typeof location === 'string' ? { category: location, dshHome: undefined } : location
|
||||
return join(resolveDshHome(dshHome), category, ...segments)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
dshCachePath,
|
||||
dshHomeDisplay,
|
||||
dshHomePath,
|
||||
dshPath,
|
||||
expandHomePath,
|
||||
resolveAgentsHome,
|
||||
resolveDshHome,
|
||||
@@ -114,6 +115,25 @@ describe('dsh path helpers', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it.each([
|
||||
[undefined, join(homedir(), '.dsh')],
|
||||
['', join(homedir(), '.dsh')],
|
||||
['~/env-dsh', join(homedir(), 'env-dsh')],
|
||||
['./relative-dsh', resolve('./relative-dsh')],
|
||||
] as const)('resolves category paths with DSH_HOME=%j', (home, expectedHome) => {
|
||||
vi.stubEnv('DSH_HOME', home)
|
||||
for (const category of ['config', 'data', 'state', 'cache', 'backup'] as const) {
|
||||
expect(dshPath(category)).toBe(join(expectedHome, category))
|
||||
expect(dshPath(category, 'owner', 'file.json')).toBe(join(expectedHome, category, 'owner', 'file.json'))
|
||||
}
|
||||
})
|
||||
|
||||
it('resolves a configured category home before the environment', () => {
|
||||
vi.stubEnv('DSH_HOME', '~/env-dsh')
|
||||
expect(dshPath({ category: 'state', dshHome: '~/explicit-dsh' }, 'logs')).toBe(join(homedir(), 'explicit-dsh', 'state', 'logs'))
|
||||
expect(dshPath({ category: 'data', dshHome: undefined })).toBe(join(homedir(), 'env-dsh', 'data'))
|
||||
})
|
||||
|
||||
it('canonicalizes a watcher ancestor while preserving a missing suffix', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'dsh-watch-path-'))
|
||||
const target = join(root, 'target')
|
||||
|
||||
@@ -195,6 +195,7 @@ export const SERVICE_WALK_EXEMPTIONS: Record<string, string> = {
|
||||
configuredAgentIdentities: 'not a service: launcher-provided boot-context value (ConfiguredAgentIdentities | undefined) — packages/core/agent-loop/README.md owns this launcher contract',
|
||||
launcherSessionQueryPath: 'not a service: launcher-provided boot-context value (string | undefined) — packages/session-query/session-query-sqlite/README.md owns this launcher contract',
|
||||
dshHomePath: 'not a service: boot-provided root accessor function (typeof dshHomePath | undefined) for Loader !!js config expressions — packages/boot/app-boot/README.md owns the boot contract',
|
||||
dshPath: 'not a service: boot-provided root accessor function (typeof dshPath | undefined) for Loader !!js config expressions — packages/boot/app-boot/README.md owns the boot contract',
|
||||
launchEnvironment: 'not a service: launcher-provided root accessor value (LaunchEnvironmentSnapshot | undefined) — packages/util/launch-environment/README.md owns this launcher contract',
|
||||
pluginPackages: 'profile-boot-owned package resolver service used by optional consumers — packages/boot/app-boot/README.md owns this internal API',
|
||||
fileUpload: 'client-side browser upload service — packages/client/file-upload/README.md owns the API',
|
||||
|
||||
Reference in new issue
Block a user