Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers

Brings `enter_worktree`. This layer adds a real-sandbox test: entering an
existing worktree under read-only policy runs only confined read commands and
moves the write boundary to the worktree, and leaving moves it back. The
boundary upgrade guide names the new tool.
This commit is contained in:
LegGasai committed 2026-11-13 20:30:20 +08:00
commit bc8544140a
48 files changed
+706 -183

No files matched your search

+1 -1
View File
@@ -1579,7 +1579,7 @@ export type PaidTranslationProvider = 'deepseek-account' | 'deepseek-official'
- `inject`: `workingDirectory` · `fs` · `subprocess` · `sandbox` · `sandboxPolicy` · `sessionProjections`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/experimental/worktree/src/index.ts:42`](../packages/experimental/worktree/src/index.ts)
- `source`: [`packages/experimental/worktree/src/index.ts:45`](../packages/experimental/worktree/src/index.ts)
```ts config-catalog
/** Worktree location, generated names, executables, subprocess resource limits, and the archive cleanup switch. */
+1 -1
View File
@@ -1581,7 +1581,7 @@ export type PaidTranslationProvider = 'deepseek-account' | 'deepseek-official'
- `inject`: `workingDirectory` · `fs` · `subprocess` · `sandbox` · `sandboxPolicy` · `sessionProjections`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/experimental/worktree/src/index.ts:42`](../packages/experimental/worktree/src/index.ts)
- `source`: [`packages/experimental/worktree/src/index.ts:45`](../packages/experimental/worktree/src/index.ts)
```ts config-catalog
/** Worktree location, generated names, executables, subprocess resource limits, and the archive cleanup switch. */
@@ -6,5 +6,5 @@
en: a11f106978c9dce7
zh: a11f106978c9dce7
/experimental-plugin-record-catalog:
en: 70a326c106662bf9
zh: 876f8036b96985d2
en: eb63e54f4ce301b7
zh: b2ec1013b131de5e
+1
View File
@@ -19,6 +19,7 @@ Shared Session event declarations and resolved schemas appear in the [Session pe
| `plugin:translator/request` | `@deepseek-ai/dsh-experimental-translator` | Provider-independent translation input, retained before dispatch. | <code>TranslationRequestRecord</code> · [`packages/experimental/translator/src/types.ts`](../packages/experimental/translator/src/types.ts) |
| `plugin:translator/result` | `@deepseek-ai/dsh-experimental-translator` | Successful translation, retained before it is returned to the consumer. | <code>TranslationResultRecord</code> · [`packages/experimental/translator/src/types.ts`](../packages/experimental/translator/src/types.ts) |
| `plugin:worktree/created` | `@deepseek-ai/dsh-experimental-worktree` | A checkout the worktree service created for the Session, which entered it in the same operation. | <code>CreatedWorktree</code> · [`packages/experimental/worktree/src/projection.ts`](../packages/experimental/worktree/src/projection.ts) |
| `plugin:worktree/entered` | `@deepseek-ai/dsh-experimental-worktree` | An existing checkout the Session entered, and the checkout it entered from. | <code>EnteredWorktree</code> · [`packages/experimental/worktree/src/projection.ts`](../packages/experimental/worktree/src/projection.ts) |
| `plugin:timeline/annotation` | `@deepseek-ai/dsh-timeline` | Record a discussion or control request from the user. | <code>{ version: 1; sessionId: SessionId; annotation: Annotation; }</code> · [`packages/experimental/timeline/src/records.ts`](../packages/experimental/timeline/src/records.ts) |
| `plugin:timeline/delivery` | `@deepseek-ai/dsh-timeline` | Record whether the agent accepted a control request. | <code>{ version: 1; sessionId: SessionId; id: Annotation['id']; delivery: 'accepted' &#124; 'unknown'; }</code> · [`packages/experimental/timeline/src/records.ts`](../packages/experimental/timeline/src/records.ts) |
| `plugin:timeline/failure` | `@deepseek-ai/dsh-timeline` | Record a failed interval report attempt. | <code>{ version: 1; sessionId: SessionId; id: IntervalReport['id']; message: string; }</code> · [`packages/experimental/timeline/src/records.ts`](../packages/experimental/timeline/src/records.ts) |
@@ -19,6 +19,7 @@
| `plugin:translator/request` | `@deepseek-ai/dsh-experimental-translator` | Provider-independent translation input, retained before dispatch. | <code>TranslationRequestRecord</code> · [`packages/experimental/translator/src/types.ts`](../packages/experimental/translator/src/types.ts) |
| `plugin:translator/result` | `@deepseek-ai/dsh-experimental-translator` | Successful translation, retained before it is returned to the consumer. | <code>TranslationResultRecord</code> · [`packages/experimental/translator/src/types.ts`](../packages/experimental/translator/src/types.ts) |
| `plugin:worktree/created` | `@deepseek-ai/dsh-experimental-worktree` | A checkout the worktree service created for the Session, which entered it in the same operation. | <code>CreatedWorktree</code> · [`packages/experimental/worktree/src/projection.ts`](../packages/experimental/worktree/src/projection.ts) |
| `plugin:worktree/entered` | `@deepseek-ai/dsh-experimental-worktree` | An existing checkout the Session entered, and the checkout it entered from. | <code>EnteredWorktree</code> · [`packages/experimental/worktree/src/projection.ts`](../packages/experimental/worktree/src/projection.ts) |
| `plugin:timeline/annotation` | `@deepseek-ai/dsh-timeline` | Record a discussion or control request from the user. | <code>{ version: 1; sessionId: SessionId; annotation: Annotation; }</code> · [`packages/experimental/timeline/src/records.ts`](../packages/experimental/timeline/src/records.ts) |
| `plugin:timeline/delivery` | `@deepseek-ai/dsh-timeline` | Record whether the agent accepted a control request. | <code>{ version: 1; sessionId: SessionId; id: Annotation['id']; delivery: 'accepted' &#124; 'unknown'; }</code> · [`packages/experimental/timeline/src/records.ts`](../packages/experimental/timeline/src/records.ts) |
| `plugin:timeline/failure` | `@deepseek-ai/dsh-timeline` | Record a failed interval report attempt. | <code>{ version: 1; sessionId: SessionId; id: IntervalReport['id']; message: string; }</code> · [`packages/experimental/timeline/src/records.ts`](../packages/experimental/timeline/src/records.ts) |
+6 -6
View File
@@ -3,11 +3,11 @@
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/subsystems/worktrees.md
/git-worktrees:
en: 3a3d69d2b12a78f9
zh: a7a7d12487968bbc
en: 2b8bd1769282a1b6
zh: 3da9c6b3459fbb2e
/git-worktrees/creation-and-retention:
en: 86c25f01f06bd6b8
zh: b1894904e2384a2a
en: ccf53e03d79d84de
zh: b44d1998ffd2cd50
/git-worktrees/request-and-result:
en: fbab866bf824d6e0
zh: 73d2a1ee350e1434
en: 5801c5909e1873a0
zh: 5c36a4c4ea97ecad
+47 -8
View File
@@ -2,7 +2,7 @@
English | [中文](worktrees.zh.md)
The experimental [`dsh-experimental-worktree`](../../packages/experimental/worktree/README.md) service provides `ctx.worktrees`. Its [`create_worktree`](../../packages/experimental/tool-worktree/README.md) consumer creates a new Git branch and checkout, then selects it through the [working-directory service](working-directory.md). The [Change requests & worktrees bundle](../../packages/experimental/forge-bundle/README.md#use-this-package) loads both packages through the GUI plugin manager and ships switched off. Other profiles can select the [standalone worktree bundle](../../packages/experimental/tool-worktree/README.md#use-this-package) or mount the two packages explicitly.
The experimental [`dsh-experimental-worktree`](../../packages/experimental/worktree/README.md) service provides `ctx.worktrees`. Its [`create_worktree`](../../packages/experimental/tool-worktree/README.md) consumer creates a new Git branch and checkout, then selects it through the [working-directory service](working-directory.md); `enter_worktree` selects an existing checkout of the pool, and `exit_worktree` returns to the checkout the Session came from. The [Change requests & worktrees bundle](../../packages/experimental/forge-bundle/README.md#use-this-package) loads both packages through the GUI plugin manager and ships switched off. Other profiles can select the [standalone worktree bundle](../../packages/experimental/tool-worktree/README.md#use-this-package) or mount the two packages explicitly.
## Creation and retention
@@ -10,11 +10,13 @@ The calling Session's current directory selects the source repository. Creation
The default destination is `<current checkout root>/.agents/worktrees/<name>`. `repositoryRoot` is the top-level directory of the caller’s current checkout; a linked checkout therefore contains its own pool. The service writes a `.gitignore` containing `*` and a trailing newline only when its allocation creates the configured pool directory. Existing files and ignore rules are preserved. The calling Session’s resolved sandbox policy must permit writes to the destination and shared Git administration directory; for a linked checkout the [sandbox policy](sandbox.md) grants that directory before creation writes. Successful Git setup precedes the working-directory change.
`ctx.worktrees.exit(agent)`, which the `exit_worktree` tool calls, returns the Session to the source checkout of the recorded worktree that contains its current directory; the checkout and branch remain. Nested worktrees exit one level at a time. Cancellation or failure can also retain partial artifacts; the error identifies their location. Worktree failures throw `WorktreeError` with a `WORKTREE_*` code; a failure after allocation keeps the wrapped error's `name` and `code`, and caller cancellation stays an `AbortError`. The service aborts and drains pending operations on disposal. The [package README](../../packages/experimental/worktree/README.md) owns configuration and Git requirements.
`ctx.worktrees.enter(agent, { name })`, which the `enter_worktree` tool calls, moves the Session into an existing worktree in the pool of the checkout it works in. The directory must lie inside that pool and be a registered worktree of the repository: a missing name, an unregistered directory, and a link that leaves the pool fail with `WORKTREE_NOT_FOUND`. Entry changes neither Git state nor files and records itself in the Session log.
`ctx.worktrees.exit(agent)`, which the `exit_worktree` tool calls, returns the Session from the recorded worktree that contains its current directory to the checkout it created or entered that worktree from; the checkout and branch remain. Nested worktrees exit one level at a time. Cancellation or failure can also retain partial artifacts; the error identifies their location. Worktree failures throw `WorktreeError` with a `WORKTREE_*` code; a failure after allocation keeps the wrapped error's `name` and `code`, and caller cancellation stays an `AbortError`. The service aborts and drains pending operations on disposal. The [package README](../../packages/experimental/worktree/README.md) owns configuration and Git requirements.
## Request and result
The request selects only the new name and local revision. The result identifies the created checkout and exact commit; it does not change the Session's original project or write permissions. An optional callback receives each stage of the creation before it begins. A restoration checks a removed checkout out again at its recorded directory, from its branch or, when the branch is gone, from its base commit.
The creation request selects only the new name and local revision. The result identifies the created checkout and exact commit; it does not change the Session's original project or write permissions. An entry request names a worktree inside the pool; its result identifies the checkout, the branch checked out there, and the checkout the Session entered from. An optional callback receives each stage of the creation before it begins. A restoration checks a removed checkout out again at its recorded directory, from its branch or, when the branch is gone, from its base commit.
```ts type-equiv
/** A new checkout from a locally available Git commit, branch, or tag. */
@@ -40,6 +42,26 @@ interface CreatedWorktree {
}
```
```ts type-equiv
/** An existing checkout in the worktree pool of the checkout the calling Session works in. */
interface EnterWorktreeRequest {
/** Checkout directory relative to the pool: the name `create` gave the worktree. */
name: string
}
```
```ts type-equiv
/** An existing checkout the calling Session entered. */
interface EnteredWorktree {
/** Canonical absolute checkout directory in the filesystem provider's execution world. */
path: string
/** Branch checked out there at entry; absent on a detached HEAD. */
branch?: string
/** Canonical root of the checkout whose pool holds the worktree; `exit` returns the Session there. */
repositoryRoot: string
}
```
```ts type-equiv
/**
* Stage of one creation or restoration, reported before it begins: `prepare`
@@ -109,7 +131,7 @@ Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnp
### `ctx.worktrees` — `WorktreeService`
Creates retained Git worktrees under the mounted filesystem and sandbox providers, records each creation in the Session log, and reclaims a clean, unreferenced checkout when the Session that created it is archived.
Creates retained Git worktrees under the mounted filesystem and sandbox providers, moves Sessions into and out of them, records each creation and entry in the Session log, and reclaims a clean, unreferenced checkout when the Session that created it is archived.
```ts cordis-catalog
/**
@@ -148,9 +170,26 @@ async create( agent: Agent, request: CreateWorktreeRequest = {}, signal?: AbortS
async restore( agent: Agent, request: RestoreWorktreeRequest, signal?: AbortSignal, onPhase?: (phase: CreateWorktreePhase) => void, ): Promise<RestoredWorktree>
/**
* Return the calling Session from the worktree it works in to the source checkout that worktree was
* created from. The worktree is the recorded creation, the Session's own or fork-inherited, with the
* longest directory containing the Session's current directory. Its checkout and branch remain.
* Move the calling Session into an existing worktree in the pool of the checkout it works in. The
* directory `name` selects must lie inside that pool and be a registered worktree of the repository;
* neither Git state nor files change. The Session's log records the entry, so {@link exit} returns it to
* the checkout it entered from. Archiving the Session never removes a checkout it only entered.
* @param agent - caller whose current directory selects the checkout and its pool.
* @param request - name of the worktree inside the pool.
* @param signal - cancellation of lookup and of the working-directory change.
* @returns the entered checkout, its branch, and the checkout the Session entered from.
* @throws {WorktreeError} `WORKTREE_INVALID_ARGUMENT` for a name that is not a relative path inside the pool,
* `WORKTREE_NOT_FOUND` when the pool holds no registered worktree of that name, a command failure, and
* `WORKTREE_UNAVAILABLE` after service disposal; or the working-directory service's error when the
* registered directory no longer exists.
*/
async enter(agent: Agent, request: EnterWorktreeRequest, signal?: AbortSignal): Promise<EnteredWorktree>
/**
* Return the calling Session from the worktree it works in to the checkout it entered that worktree
* from: the source checkout of a creation, or the checkout whose pool holds an entered worktree. The
* worktree is the recorded creation or entry, the Session's own or fork-inherited, with the longest
* directory containing the Session's current directory. Its checkout and branch remain.
* @param agent - caller whose current directory lies in a recorded worktree.
* @param signal - cancellation of directory validation and of the working-directory change.
* @returns the worktree the Session left; the Session now works in its `repositoryRoot`.
@@ -158,7 +197,7 @@ async restore( agent: Agent, request: RestoreWorktreeRequest, signal?: AbortSign
* `WORKTREE_UNAVAILABLE` after service disposal, or the working-directory service's error when the source
* checkout no longer exists.
*/
async exit(agent: Agent, signal?: AbortSignal): Promise<CreatedWorktree>
async exit(agent: Agent, signal?: AbortSignal): Promise<CreatedWorktree | EnteredWorktree>
/**
* Read the archive cleanup of a Session's created checkout; waiting never
+47 -8
View File
@@ -2,7 +2,7 @@
[English](worktrees.md) | 中文
实验性的 [`dsh-experimental-worktree`](../../packages/experimental/worktree/README.zh.md) 服务提供 `ctx.worktrees`。其消费方 [`create_worktree`](../../packages/experimental/tool-worktree/README.zh.md) 创建新的 Git 分支与检出目录,再通过[工作目录服务](working-directory.zh.md)选中它。[变更请求与工作树组合包](../../packages/experimental/forge-bundle/README.zh.md#use-this-package)通过 GUI 插件管理器一起加载这两个包,随安装提供但默认关闭。其他 profile 可以选择[独立工作树组合包](../../packages/experimental/tool-worktree/README.zh.md#use-this-package),或显式挂载这两个包。
实验性的 [`dsh-experimental-worktree`](../../packages/experimental/worktree/README.zh.md) 服务提供 `ctx.worktrees`。其消费方 [`create_worktree`](../../packages/experimental/tool-worktree/README.zh.md) 创建新的 Git 分支与检出目录,再通过[工作目录服务](working-directory.zh.md)选中它;`enter_worktree` 选中池中已有的检出目录,`exit_worktree` 回到 Session 来自的检出目录。[变更请求与工作树组合包](../../packages/experimental/forge-bundle/README.zh.md#use-this-package)通过 GUI 插件管理器一起加载这两个包,随安装提供但默认关闭。其他 profile 可以选择[独立工作树组合包](../../packages/experimental/tool-worktree/README.zh.md#use-this-package),或显式挂载这两个包。
## 创建与保留
@@ -10,11 +10,13 @@
默认目标为 `<current checkout root>/.agents/worktrees/<name>`。`repositoryRoot` 是调用方当前检出目录的顶层目录;因此,链接检出目录会在自身内部保存工作树父目录。仅当服务的分配操作创建了配置指定的父目录时,服务才会写入内容为 `*` 加换行符的 `.gitignore`。已有文件与忽略规则保持不变。调用方 Session 解析后的沙箱策略必须允许写入目标目录与共享 Git 管理目录;对于链接检出目录,[沙箱策略](sandbox.zh.md)会在创建写入之前授权该目录。Git 初始化成功后才改变工作目录。
`exit_worktree` 工具调用的 `ctx.worktrees.exit(agent)` 找到包含 Session 当前目录的已记录工作树,把 Session 送回它的源检出;检出目录与分支保留。嵌套的工作树每次退出一层。取消或失败也可能留下部分产物;错误会指出它们的位置。worktree 失败抛出带 `WORKTREE_*` code 的 `WorktreeError`;分配开始后的失败保留被包装错误的 `name` 与 `code`,调用方取消仍为 `AbortError`。服务销毁时会中止待完成操作并等待它们结束。[包 README](../../packages/experimental/worktree/README.zh.md)拥有配置与 Git 要求。
`enter_worktree` 工具调用的 `ctx.worktrees.enter(agent, { name })` 把 Session 移入它所在检出的池中已有的工作树。该目录必须位于池内,并且是仓库已登记的工作树:名称不存在、目录未登记、链接指向池外都以 `WORKTREE_NOT_FOUND` 失败。进入不改变 Git 状态和文件,并在 Session 日志中记录这次进入。
`exit_worktree` 工具调用的 `ctx.worktrees.exit(agent)` 找到包含 Session 当前目录的已记录工作树,把 Session 送回创建或进入该工作树时所在的检出;检出目录与分支保留。嵌套的工作树每次退出一层。取消或失败也可能留下部分产物;错误会指出它们的位置。worktree 失败抛出带 `WORKTREE_*` code 的 `WorktreeError`;分配开始后的失败保留被包装错误的 `name` 与 `code`,调用方取消仍为 `AbortError`。服务销毁时会中止待完成操作并等待它们结束。[包 README](../../packages/experimental/worktree/README.zh.md)拥有配置与 Git 要求。
## 请求与结果
请求只选择新名称与本地版本。结果标识创建的检出目录与确切提交;它不会改变 Session 的原始项目或写权限。可选的回调会在创建的每个阶段开始之前收到该阶段。恢复会在记录的目录重新检出已删除的检出目录:从它的分支检出;分支也已删除时,从它的基准提交检出。
创建请求只选择新名称与本地版本。结果标识创建的检出目录与确切提交;它不会改变 Session 的原始项目或写权限。进入请求给出池内工作树的名称;结果标识检出目录、其中检出的分支,以及 Session 进入前所在的检出。可选的回调会在创建的每个阶段开始之前收到该阶段。恢复会在记录的目录重新检出已删除的检出目录:从它的分支检出;分支也已删除时,从它的基准提交检出。
```ts type-equiv
/** A new checkout from a locally available Git commit, branch, or tag. */
@@ -40,6 +42,26 @@ interface CreatedWorktree {
}
```
```ts type-equiv
/** An existing checkout in the worktree pool of the checkout the calling Session works in. */
interface EnterWorktreeRequest {
/** Checkout directory relative to the pool: the name `create` gave the worktree. */
name: string
}
```
```ts type-equiv
/** An existing checkout the calling Session entered. */
interface EnteredWorktree {
/** Canonical absolute checkout directory in the filesystem provider's execution world. */
path: string
/** Branch checked out there at entry; absent on a detached HEAD. */
branch?: string
/** Canonical root of the checkout whose pool holds the worktree; `exit` returns the Session there. */
repositoryRoot: string
}
```
```ts type-equiv
/**
* Stage of one creation or restoration, reported before it begins: `prepare`
@@ -109,7 +131,7 @@ Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnp
### `ctx.worktrees` — `WorktreeService`
Creates retained Git worktrees under the mounted filesystem and sandbox providers, records each creation in the Session log, and reclaims a clean, unreferenced checkout when the Session that created it is archived.
Creates retained Git worktrees under the mounted filesystem and sandbox providers, moves Sessions into and out of them, records each creation and entry in the Session log, and reclaims a clean, unreferenced checkout when the Session that created it is archived.
```ts cordis-catalog
/**
@@ -148,9 +170,26 @@ async create( agent: Agent, request: CreateWorktreeRequest = {}, signal?: AbortS
async restore( agent: Agent, request: RestoreWorktreeRequest, signal?: AbortSignal, onPhase?: (phase: CreateWorktreePhase) => void, ): Promise<RestoredWorktree>
/**
* Return the calling Session from the worktree it works in to the source checkout that worktree was
* created from. The worktree is the recorded creation, the Session's own or fork-inherited, with the
* longest directory containing the Session's current directory. Its checkout and branch remain.
* Move the calling Session into an existing worktree in the pool of the checkout it works in. The
* directory `name` selects must lie inside that pool and be a registered worktree of the repository;
* neither Git state nor files change. The Session's log records the entry, so {@link exit} returns it to
* the checkout it entered from. Archiving the Session never removes a checkout it only entered.
* @param agent - caller whose current directory selects the checkout and its pool.
* @param request - name of the worktree inside the pool.
* @param signal - cancellation of lookup and of the working-directory change.
* @returns the entered checkout, its branch, and the checkout the Session entered from.
* @throws {WorktreeError} `WORKTREE_INVALID_ARGUMENT` for a name that is not a relative path inside the pool,
* `WORKTREE_NOT_FOUND` when the pool holds no registered worktree of that name, a command failure, and
* `WORKTREE_UNAVAILABLE` after service disposal; or the working-directory service's error when the
* registered directory no longer exists.
*/
async enter(agent: Agent, request: EnterWorktreeRequest, signal?: AbortSignal): Promise<EnteredWorktree>
/**
* Return the calling Session from the worktree it works in to the checkout it entered that worktree
* from: the source checkout of a creation, or the checkout whose pool holds an entered worktree. The
* worktree is the recorded creation or entry, the Session's own or fork-inherited, with the longest
* directory containing the Session's current directory. Its checkout and branch remain.
* @param agent - caller whose current directory lies in a recorded worktree.
* @param signal - cancellation of directory validation and of the working-directory change.
* @returns the worktree the Session left; the Session now works in its `repositoryRoot`.
@@ -158,7 +197,7 @@ async restore( agent: Agent, request: RestoreWorktreeRequest, signal?: AbortSign
* `WORKTREE_UNAVAILABLE` after service disposal, or the working-directory service's error when the source
* checkout no longer exists.
*/
async exit(agent: Agent, signal?: AbortSignal): Promise<CreatedWorktree>
async exit(agent: Agent, signal?: AbortSignal): Promise<CreatedWorktree | EnteredWorktree>
/**
* Read the archive cleanup of a Session's created checkout; waiting never
+9 -6
View File
@@ -9,8 +9,8 @@
en: 6cc2cd9ced70bb09
zh: 1c0e6cb4ba2ed637
/tool-schema-catalog/tool-package-map:
en: 56c5b98d1014acdf
zh: a4a89e68640bd6aa
en: 57f5bdf5d35d5bc5
zh: 41d4446d7b7f4eca
/tool-schema-catalog/deepseek-ai-dsh-plugin-manager:
en: e0143916bb634762
zh: e0143916bb634762
@@ -324,11 +324,14 @@
en: d5f5679abe86e316
zh: d5f5679abe86e316
/tool-schema-catalog/deepseek-ai-dsh-experimental-tool-worktree/create-worktree:
en: d06b107645e340bf
zh: 1b996d4980edf6fc
en: 5c3d354aa18e8d19
zh: 275bff3958cf465a
/tool-schema-catalog/deepseek-ai-dsh-experimental-tool-worktree/enter-worktree:
en: 644de5ca0bc1d312
zh: 7a2f4860089bfcb8
/tool-schema-catalog/deepseek-ai-dsh-experimental-tool-worktree/exit-worktree:
en: 499364c213893caf
zh: 1f08cbfce523be98
en: 834d21fd914b7211
zh: ea1501ee1fc8a754
/tool-schema-catalog/deepseek-ai-dsh-tool-workflow:
en: bb38a9d29f46563c
zh: bb38a9d29f46563c
+25 -4
View File
@@ -47,7 +47,7 @@ This table connects model-visible tool names to the plugin package and service s
| `@deepseek-ai/dsh-tool-jobs` | `job_kill`, `job_list`, `job_output` | `ctx.tools`, `ctx.jobs`, `ctx.systemPrompt` | `tool/call`, `tool/result`, `user/message via agent.inject() for background completion notices` | - | The kind-agnostic background-job controller: background bash commands and PTY sends are read, listed, and killed through the same three tools. Loading the plugin attaches the controller that arms producers' `ctx.jobs.start()`. |
| `@deepseek-ai/dsh-tool-agent-team` | `team_task_create`, `team_task_get`, `team_task_list`, `team_task_update` | `ctx.tools`, `ctx.systemPrompt`, `ctx.agentTeams`, `ctx.subagents`, `an exact live Team member Agent` | `tool/call`, `team/task`, `tool/result` | - | Four task-board tools share the subagent tree’s root Session. Enabling Team mode on the root Session adds task-board guidance alongside standard subagent delegation and control tools. Standard subagent controls provide required identity independently of Team mode. |
| `@deepseek-ai/dsh-tool-todo` | `todo_write` | `ctx.tools`, `owning Agent session` | `tool/call`, `todo/write`, `tool/result` | - | todo_write is session-owned state; UIs render the latest todo/write event as a checklist. `allowParallelInProgress` is required with no default, so the catalog states its choice: `true`, whose description invites several `in_progress` items. A deployment choosing `false` receives the same tool with a description asking for exactly one active task. |
| `@deepseek-ai/dsh-experimental-tool-worktree` | `create_worktree`, `exit_worktree` | `ctx.tools`, `ctx.worktrees`, `a calling Agent` | `tool/call`, `Git branch and checkout`, `workspace-root/change`, `tool/result` | - | Enabled through the Change requests & worktrees bundle on Web and Desktop; other profiles can select the standalone bundle. Creates a new branch and checkout from a pinned local commit under existing write permissions, then changes the Session directory. `exit_worktree` returns the Session to the source checkout; the branch and checkout remain. |
| `@deepseek-ai/dsh-experimental-tool-worktree` | `create_worktree`, `enter_worktree`, `exit_worktree` | `ctx.tools`, `ctx.worktrees`, `a calling Agent` | `tool/call`, `Git branch and checkout`, `workspace-root/change`, `tool/result` | - | Enabled through the Change requests & worktrees bundle on Web and Desktop; other profiles can select the standalone bundle. Creates a new branch and checkout from a pinned local commit under existing write permissions, then changes the Session directory. `enter_worktree` moves the Session into an existing worktree in the pool of the checkout it works in; `exit_worktree` returns the Session to the checkout it came from; the branch and checkout remain. |
| `@deepseek-ai/dsh-tool-workflow` | `workflow` | `ctx.tools`, `ctx.workflowEngine`, `ctx.systemPrompt`, `a calling Agent (exec.agent parents the script children)` | `tool/call`, `tool/result` | - | - |
| `@deepseek-ai/dsh-tool-workspace-dependencies` | `load_workspace_dependencies` | `ctx.tools` | `tool/call`, `tool/result` | - | - |
| `@deepseek-ai/dsh-tool-web` | `web_fetch`, `web_search` | `ctx.tools`, `ctx.web`, `ctx.systemPrompt` | `tool/call`, `tool/result` | - | web_search and web_fetch keep provider selection behind ctx.web so model-visible schemas stay stable across backend swaps. |
@@ -2643,7 +2643,7 @@ todo_write is session-owned state; UIs render the latest todo/write event as a c
### `create_worktree`
Create a new Git branch and worktree from a local commit, branch, or tag, then change this session's working directory to it. Uncommitted files stay in the source checkout. Existing names fail. exit_worktree returns to the source checkout.
Create a new Git branch and worktree from a local commit, branch, or tag, then change this session's working directory to it. Uncommitted files stay in the source checkout. Existing names fail; enter_worktree enters an existing worktree. exit_worktree returns to the source checkout.
```json
{
@@ -2663,9 +2663,30 @@ Create a new Git branch and worktree from a local commit, branch, or tag, then c
Source: [`packages/experimental/tool-worktree/src/index.ts`](../packages/experimental/tool-worktree/src/index.ts)
### `enter_worktree`
Change this session's working directory to an existing worktree that was created from the checkout this session is in. Branches and files stay as they are. exit_worktree returns to that checkout.
```json
{
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name the worktree was created with."
}
},
"required": [
"name"
]
}
```
Source: [`packages/experimental/tool-worktree/src/index.ts`](../packages/experimental/tool-worktree/src/index.ts)
### `exit_worktree`
Change this session's working directory from the worktree it is in back to the checkout that worktree was created from, and report the worktree left. The worktree and its branch remain.
Change this session's working directory from the worktree it is in back to the checkout it entered that worktree from, and report the worktree left. The worktree and its branch remain.
```json
{
@@ -2676,7 +2697,7 @@ Change this session's working directory from the worktree it is in back to the c
Source: [`packages/experimental/tool-worktree/src/index.ts`](../packages/experimental/tool-worktree/src/index.ts)
Enabled through the Change requests & worktrees bundle on Web and Desktop; other profiles can select the standalone bundle. Creates a new branch and checkout from a pinned local commit under existing write permissions, then changes the Session directory. `exit_worktree` returns the Session to the source checkout; the branch and checkout remain.
Enabled through the Change requests & worktrees bundle on Web and Desktop; other profiles can select the standalone bundle. Creates a new branch and checkout from a pinned local commit under existing write permissions, then changes the Session directory. `enter_worktree` moves the Session into an existing worktree in the pool of the checkout it works in; `exit_worktree` returns the Session to the checkout it came from; the branch and checkout remain.
<a id="deepseek-aidsh-tool-workflow"></a>
+25 -4
View File
@@ -51,7 +51,7 @@
| `@deepseek-ai/dsh-tool-jobs` | `job_kill`、`job_list`、`job_output` | `ctx.tools`、`ctx.jobs`、`ctx.systemPrompt` | `tool/call`、`tool/result`、`user/message via agent.inject() for background completion notices` | - | 与任务种类无关的后台任务控制器:后台 bash 命令与 PTY 发送 都通过相同的 3 个工具读取、列出和终止。加载该插件会挂接控制器,从而启用生产方的 `ctx.jobs.start()`。 |
| `@deepseek-ai/dsh-tool-agent-team` | `team_task_create`, `team_task_get`, `team_task_list`, `team_task_update` | `ctx.tools`, `ctx.systemPrompt`, `ctx.agentTeams`, `ctx.subagents`, `an exact live Team member Agent` | `tool/call`, `team/task`, `tool/result` | - | 四个任务板工具共享 subagent 树的根 Session。在根 Session 开启 Team 模式,会在标准 subagent 委派和控制工具之外增加任务板指导。标准 subagent 控制工具提供必需身份,不受 Team 模式影响。 |
| `@deepseek-ai/dsh-tool-todo` | `todo_write` | `ctx.tools`、`owning Agent session` | `tool/call`、`todo/write`、`tool/result` | - | todo_write 是会话所有的状态;UI 将最新的 todo/write 事件渲染为检查清单。`allowParallelInProgress` 是没有默认值的必填项,因此本目录明确选择 `true`,对应描述允许同时存在多个 `in_progress` 项。选择 `false` 的部署会获得同一工具,但描述会要求只能有 1 个活动任务。 |
| `@deepseek-ai/dsh-experimental-tool-worktree` | `create_worktree`, `exit_worktree` | `ctx.tools`, `ctx.worktrees`, `a calling Agent` | `tool/call`, `Git branch and checkout`, `workspace-root/change`, `tool/result` | - | 在 Web 和 Desktop 上通过变更请求与工作树组合包启用;其他 profile 可以选择独立组合包。在现有写权限下从固定的本地提交创建新分支与检出目录,再改变 Session 工作目录。`exit_worktree` 把 Session 送回源检出目录;分支与检出目录保留。 |
| `@deepseek-ai/dsh-experimental-tool-worktree` | `create_worktree`, `enter_worktree`, `exit_worktree` | `ctx.tools`, `ctx.worktrees`, `a calling Agent` | `tool/call`, `Git branch and checkout`, `workspace-root/change`, `tool/result` | - | 在 Web 和 Desktop 上通过变更请求与工作树组合包启用;其他 profile 可以选择独立组合包。在现有写权限下从固定的本地提交创建新分支与检出目录,再改变 Session 工作目录。`enter_worktree` 把 Session 移入它所在检出的池中已有的工作树;`exit_worktree` 把 Session 送回它来自的检出目录;分支与检出目录保留。 |
| `@deepseek-ai/dsh-tool-workflow` | `workflow` | `ctx.tools`、`ctx.workflowEngine`、`ctx.systemPrompt`、`a calling Agent (exec.agent parents the script children)` | `tool/call`、`tool/result` | - | - |
| `@deepseek-ai/dsh-tool-workspace-dependencies` | `load_workspace_dependencies` | `ctx.tools` | `tool/call`, `tool/result` | - | - |
| `@deepseek-ai/dsh-tool-web` | `web_fetch`、`web_search` | `ctx.tools`、`ctx.web`、`ctx.systemPrompt` | `tool/call`、`tool/result` | - | web_search 和 web_fetch 将提供方选择置于 ctx.web 之后,使模型可见 schema 在更换后端时保持稳定。 |
@@ -2649,7 +2649,7 @@ todo_write 是会话所有的状态;UI 将最新的 todo/write 事件渲染为
### `create_worktree`
从本地提交、分支或标签创建新的 Git 分支与工作树,再将本 Session 的工作目录切换到该位置。未提交文件保留在源检出目录中。名称已存在时失败。exit_worktree 返回源检出目录。
从本地提交、分支或标签创建新的 Git 分支与工作树,再将本 Session 的工作目录切换到该位置。未提交文件保留在源检出目录中。名称已存在时失败;enter_worktree 进入已有的工作树。exit_worktree 返回源检出目录。
```json
{
@@ -2669,9 +2669,30 @@ todo_write 是会话所有的状态;UI 将最新的 todo/write 事件渲染为
来源:[`packages/experimental/tool-worktree/src/index.ts`](../packages/experimental/tool-worktree/src/index.ts)
### `enter_worktree`
把本 Session 的工作目录切换到一个已有的工作树,该工作树须是从本 Session 所在的检出目录创建的。分支与文件保持原样。exit_worktree 返回该检出目录。
```json
{
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name the worktree was created with."
}
},
"required": [
"name"
]
}
```
来源:[`packages/experimental/tool-worktree/src/index.ts`](../packages/experimental/tool-worktree/src/index.ts)
### `exit_worktree`
把本 Session 的工作目录从所在的工作树切换回创建该工作树的检出目录,并报告所离开的工作树。工作树及其分支保留。
把本 Session 的工作目录从所在的工作树切换回进入该工作树时所在的检出目录,并报告所离开的工作树。工作树及其分支保留。
```json
{
@@ -2682,7 +2703,7 @@ todo_write 是会话所有的状态;UI 将最新的 todo/write 事件渲染为
来源:[`packages/experimental/tool-worktree/src/index.ts`](../packages/experimental/tool-worktree/src/index.ts)
在 Web 和 Desktop 上通过变更请求与工作树组合包启用;其他 profile 可以选择独立组合包。在现有写权限下从固定的本地提交创建新分支与检出目录,再改变 Session 工作目录。`exit_worktree` 把 Session 送回源检出目录;分支与检出目录保留。
在 Web 和 Desktop 上通过变更请求与工作树组合包启用;其他 profile 可以选择独立组合包。在现有写权限下从固定的本地提交创建新分支与检出目录,再改变 Session 工作目录。`enter_worktree` 把 Session 移入它所在检出的池中已有的工作树;`exit_worktree` 把 Session 送回它来自的检出目录;分支与检出目录保留。
<a id="deepseek-aidsh-tool-workflow"></a>
@@ -9,8 +9,8 @@
en: 9f20155a3198221f
zh: 4e8fbfcc6e819ac6
/the-working-directory-tool-and-the-subagent-cwd-parameter-are-removed/change:
en: 0f2e456440c8f4f1
zh: 723098d30ce5a077
en: 1a4d05e4e678a400
zh: 41dd47d57aaea5dc
/the-working-directory-tool-and-the-subagent-cwd-parameter-are-removed/migration:
en: 718c75ffcd864127
zh: 58e9ffd13646ef52
en: 7be13e241868a3c2
zh: 78fbf7a8ca905597
@@ -10,7 +10,7 @@ English | [中文](guide.zh.md)
The model tool `working_directory` and its package `@deepseek-ai/dsh-tool-working-directory` no longer exist; the `dsh-base` and `dsh-sdk-minimal` bundles no longer mount the `tool-working-directory` entry. The delegation tools registered by `@deepseek-ai/dsh-tool-subagent`, and `subagent_oar`, no longer accept `cwd`: a child starts in the caller's workspace directory.
A Session's directory now changes only through Host operations: `create_worktree`, the new `exit_worktree`, the forge panel, SDK `setWorkingDirectory` (`set_working_directory` in Python), and recovery when the directory disappears. Each change is recorded as `workspace-root/change`; the [persistence record](../../../persistence-changes/2026-11-13-workspace-root-change.md) covers stored logs and readers of earlier releases. A stored Session whose model changed the directory resumes in that directory. Its recorded `working_directory` calls remain history, and a new call returns `unknown tool "working_directory"`.
A Session's directory now changes only through Host operations: `create_worktree`, the new `enter_worktree` and `exit_worktree`, the forge panel, SDK `setWorkingDirectory` (`set_working_directory` in Python), and recovery when the directory disappears. Each change is recorded as `workspace-root/change`; the [persistence record](../../../persistence-changes/2026-11-13-workspace-root-change.md) covers stored logs and readers of earlier releases. A stored Session whose model changed the directory resumes in that directory. Its recorded `working_directory` calls remain history, and a new call returns `unknown tool "working_directory"`.
Who observes it: prompts, skills, and evaluation sets that expect the tool or the parameter in the tool list; profiles and patches that name the `tool-working-directory` entry or the package; Host plugins that pass a model-supplied path to `ctx.subagents.start({ cwd })` or `ctx.workingDirectory.set`, which now also moves the Session's workspace root.
@@ -18,6 +18,6 @@ Who observes it: prompts, skills, and evaluation sets that expect the tool or th
1. Remove `tool-working-directory` rows and `@deepseek-ai/dsh-tool-working-directory` dependencies from profiles, patches, and package manifests. A patch that still names the entry reports `patch: entry "tool-working-directory" not found` at load.
2. In prompts, skills, and scripted model turns, replace `working_directory({ cd })` with paths relative to the Session directory or absolute paths, and with the `workdir` argument of `bash` or `pwsh` for commands. The `Current working directory:` line of the user context replaces `working_directory()` as the way to read the directory.
3. To leave a worktree, call `exit_worktree()`. It returns the Session to the checkout the worktree was created from.
3. To leave a worktree, call `exit_worktree()`. It returns the Session to the checkout the worktree was created or entered from. To return to an existing worktree, call `enter_worktree({ name })` from the checkout it was created from.
4. Remove `cwd` from `subagent` and `subagent_oar` calls and name the subdirectory in the task. A Host that needs another start directory passes a path it chose itself to `ctx.subagents.start({ cwd })`.
5. Confirm: `dsh --profile headless --dump-config` lists no `tool-working-directory` entry, and the tool list of a first request contains neither `working_directory` nor a `cwd` property on `subagent`.
@@ -10,7 +10,7 @@ description: "模型工具 `working_directory`、它的包以及子代理工具
模型工具 `working_directory` 及其包 `@deepseek-ai/dsh-tool-working-directory` 不再存在;`dsh-base` 与 `dsh-sdk-minimal` 组合包不再挂载 `tool-working-directory` 条目。`@deepseek-ai/dsh-tool-subagent` 注册的委派工具以及 `subagent_oar` 不再接受 `cwd`:子代理从调用方的工作区目录启动。
Session 的目录现在只通过 Host 操作改变:`create_worktree`、新增的 `exit_worktree`、forge 面板、SDK 的 `setWorkingDirectory`(Python 中为 `set_working_directory`),以及目录消失时的恢复。每次变更都记录为 `workspace-root/change`;[持久化记录](../../../persistence-changes/2026-11-13-workspace-root-change.zh.md)说明已存储日志的读法和早期版本读者的行为。模型曾改变过目录的已存储 Session 会在该目录恢复。其中记录的 `working_directory` 调用仍是历史,新的调用返回 `unknown tool "working_directory"`。
Session 的目录现在只通过 Host 操作改变:`create_worktree`、新增的 `enter_worktree` 与 `exit_worktree`、forge 面板、SDK 的 `setWorkingDirectory`(Python 中为 `set_working_directory`),以及目录消失时的恢复。每次变更都记录为 `workspace-root/change`;[持久化记录](../../../persistence-changes/2026-11-13-workspace-root-change.zh.md)说明已存储日志的读法和早期版本读者的行为。模型曾改变过目录的已存储 Session 会在该目录恢复。其中记录的 `working_directory` 调用仍是历史,新的调用返回 `unknown tool "working_directory"`。
受影响的对象:期望工具列表中有该工具或该参数的提示词、技能与评测集;引用 `tool-working-directory` 条目或该包的 profile 与 patch;把模型提供的路径传给 `ctx.subagents.start({ cwd })` 或 `ctx.workingDirectory.set` 的 Host 插件,后者现在同时移动 Session 的工作区根。
@@ -18,6 +18,6 @@ Session 的目录现在只通过 Host 操作改变:`create_worktree`、新增
1. 从 profile、patch 和包清单中移除 `tool-working-directory` 行与 `@deepseek-ai/dsh-tool-working-directory` 依赖。仍然引用该条目的 patch 在加载时报告 `patch: entry "tool-working-directory" not found`。
2. 在提示词、技能和脚本化的模型轮次中,把 `working_directory({ cd })` 替换为相对 Session 目录的路径或绝对路径,命令使用 `bash` 或 `pwsh` 的 `workdir` 参数。读取目录改用用户上下文中的 `Current working directory:` 一行,不再调用 `working_directory()`。
3. 离开工作树时调用 `exit_worktree()`。它把 Session 送回创建该工作树的检出目录。
3. 离开工作树时调用 `exit_worktree()`。它把 Session 送回创建或进入该工作树时所在的检出目录。要回到已有的工作树,在创建它的检出目录中调用 `enter_worktree({ name })`。
4. 从 `subagent` 与 `subagent_oar` 调用中移除 `cwd`,把子目录写进任务。需要其他起始目录的 Host 把自己选定的路径传给 `ctx.subagents.start({ cwd })`。
5. 确认:`dsh --profile headless --dump-config` 不再列出 `tool-working-directory` 条目,首个请求的工具列表中既没有 `working_directory`,`subagent` 也没有 `cwd` 属性。
@@ -9,8 +9,8 @@
en: f107f8a828cf5629
zh: dfa17af46af54be9
/the-workspace-write-boundary-follows-the-session-s-workspace-root/change:
en: f27495bfb4b60c2e
zh: 710b9ab1a0af5531
en: 288101adfd181e87
zh: f87455fdf9472f73
/the-workspace-write-boundary-follows-the-session-s-workspace-root/migration:
en: 4609e3508ebae28d
zh: 1c9d6bb39f21f2a3
@@ -8,7 +8,7 @@ English | [中文](guide.zh.md)
## Change
`ctx.sandboxPolicy.resolve({ session })` returns the Session's workspace root as `workspaceRoot`: the checkout the Session works in. Before, it returned the original project recorded in the Session header for the whole Session. A Session that enters a worktree through `create_worktree` or the forge New worktree option can now write only inside that worktree; the original project is no longer writable as a whole. The boundary moves with every Host move of the Session's directory, including SDK `setWorkingDirectory` (`set_working_directory` in Python) and a child started through `ctx.subagents.start({ cwd })`; a `working-directory/change` recorded before this release does not move it.
`ctx.sandboxPolicy.resolve({ session })` returns the Session's workspace root as `workspaceRoot`: the checkout the Session works in. Before, it returned the original project recorded in the Session header for the whole Session. A Session that enters a worktree through `create_worktree`, `enter_worktree`, or the forge New worktree option can now write only inside that worktree; the original project is no longer writable as a whole. The boundary moves with every Host move of the Session's directory, including SDK `setWorkingDirectory` (`set_working_directory` in Python) and a child started through `ctx.subagents.start({ cwd })`; a `working-directory/change` recorded before this release does not move it.
For a linked worktree, the policy derives the repository's common directory from the checkout's `.git` pointer, accepting only the `<common>/worktrees/<name>` layout Git writes with its `commondir` and `gitdir` pointers, and adds it to `additionalWritableRoots`, so `git commit` and `git checkout` work inside a worktree under `workspace-write`. That grant also covers the shared `.git/hooks` and `.git/config`, as a Session in the main checkout already had. On Windows only the harness `write` and `edit` tools honor that grant; confined processes keep their workspace and private-temp permissions.
@@ -8,7 +8,7 @@ description: "workspace-write 边界跟随 Session 的工作区根而不是原
## 变更
`ctx.sandboxPolicy.resolve({ session })` 返回的 `workspaceRoot` 是 Session 的工作区根,即它所在的检出目录。此前整个 Session 期间返回的都是 Session header 记录的原始项目。通过 `create_worktree` 或 forge 的"新建工作树"选项进入 worktree 的 Session 现在只能在该 worktree 内写入;原始项目不再整体可写。Host 每次移动 Session 的目录,边界都随之移动,包括 SDK 的 `setWorkingDirectory`(Python 中为 `set_working_directory`)以及通过 `ctx.subagents.start({ cwd })` 启动的子代理;本版本之前记录的 `working-directory/change` 不移动边界。
`ctx.sandboxPolicy.resolve({ session })` 返回的 `workspaceRoot` 是 Session 的工作区根,即它所在的检出目录。此前整个 Session 期间返回的都是 Session header 记录的原始项目。通过 `create_worktree`、`enter_worktree` 或 forge 的"新建工作树"选项进入 worktree 的 Session 现在只能在该 worktree 内写入;原始项目不再整体可写。Host 每次移动 Session 的目录,边界都随之移动,包括 SDK 的 `setWorkingDirectory`(Python 中为 `set_working_directory`)以及通过 `ctx.subagents.start({ cwd })` 启动的子代理;本版本之前记录的 `working-directory/change` 不移动边界。
对于链接 worktree,策略从检出目录的 `.git` 指针推导出仓库公共目录,只接受 Git 写出的 `<common>/worktrees/<name>` 布局及其 `commondir`、`gitdir` 指针,并加入 `additionalWritableRoots`,因此在 `workspace-write` 下可以在 worktree 内运行 `git commit` 与 `git checkout`。该授权也覆盖共享的 `.git/hooks` 与 `.git/config`,与主检出目录中的 Session 此前拥有的权限相同。在 Windows 上只有 harness 的 `write` 与 `edit` 工具执行该授权;受限进程保留工作区与私有临时目录权限。