dsh-paoding 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README_en.md +3 -3
- package/docs/installation.md +4 -3
- package/docs/installation_en.md +4 -3
- package/package.json +1 -1
- package/plugins/paoding-config-ui/api-core.mjs +89 -22
- package/plugins/paoding-config-ui/package.json +1 -1
- package/presets/orchestrator/agent.cordis.yml +5 -2
- package/presets/orchestrator/role-restrict.mjs +78 -0
- package/tools/lib/compose.mjs +286 -2
- package/tools/lib/doctor.mjs +44 -4
- package/tools/lib/preset-system.mjs +193 -32
- package/tools/lib/state.mjs +18 -10
- package/tools/lib/util.mjs +4 -2
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ dsh-paoding(中文品牌「庖丁」,典出《庄子》——庖丁顺纹理
|
|
|
26
26
|
- **面板中英双语**:界面文案 zh/en 全覆盖,语言自动识别(显式选择 → 中文信号优先:浏览器语言、宿主页面语言、中文时区),「更多」菜单一键切换并记住。
|
|
27
27
|
- **版本更新有提醒,面板一键升级**:面板会对比 npm registry(npmmirror 镜像、GitHub release 依次兜底)上的最新版本,发现新版就地提示并附上发布页链接;点「升级」就地换上新版(profile 自动探测:普通 profile 走 `dsh plugin update dsh-paoding`;desktop profile 被 dsh CLI 的 Electron 专属守卫挡住,改在 profile 目录直跑 `pnpm add dsh-paoding@<版本>`,pnpm 找不到时自动回落 `corepack pnpm`),重启 DSH 后生效,编排预设会在重启时按新版自动重生成。开发检出的 link 形态无法就地升级,面板会提示切回 registry 版的办法;检测失败时页头留一行「版本检测失败 · 重试」(完整原因与代理排查提示在悬浮提示里),不弹窗打扰。
|
|
28
28
|
- **来去自由**:不改 DSH 一行源码;装完新会话即用,卸载即删目录。
|
|
29
|
-
- **两代宿主都兼容**:DSH 0.1.5 – 0.2.
|
|
29
|
+
- **两代宿主都兼容**:DSH 0.1.5 – 0.2.1 全支持(0.1.5 / 0.1.6 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1 / 0.2.0-rc.2 / 0.2.1-rc.2+)——两代宿主发现预设的机制不同(目录扫描 vs patch 声明行),安装器自动检测宿主版本选对落点;编排组合里的 workflow worker 行也按宿主版本自动适配(0.1.5 用 workflow-worker-thread,0.1.6+ 换 workflow-ptc——旧包 0.1.6 起已删除,残留行正是 0.2.0 面板上「加载失败」的元凶);DSH 0.2.1 起角色委派行同步换代(0.2.1 的 dsh-tool-subagent 拒绝内联 persona/toolFilter——人设与工具面改挂各角色的 AgentPreset,spawn 子代理按 agentPreset 选择子预设;0.2.0 及以下保持内联形状),宿主升级、降级后的首次保存/自愈自动迁移(工作区专属预设 orchestrator-<slug> 随同轮自愈一并换代),全程无感;0.2.1 的 prerelease 再细分——tool-subagent 守卫自 0.2.1-rc.2 落地,rc.0/rc.1 仍按内联形状生成。
|
|
30
30
|
|
|
31
31
|
## 插件截图
|
|
32
32
|
|
|
@@ -34,7 +34,7 @@ dsh-paoding(中文品牌「庖丁」,典出《庄子》——庖丁顺纹理
|
|
|
34
34
|
|
|
35
35
|
## 快速开始
|
|
36
36
|
|
|
37
|
-
前置:**Node.js ≥ 18**、**pnpm** 与一台已装好的 DSH host(**@deepseek-ai/dsh 0.1.5 – 0.2.
|
|
37
|
+
前置:**Node.js ≥ 18**、**pnpm** 与一台已装好的 DSH host(**@deepseek-ai/dsh 0.1.5 – 0.2.1** 全支持,预设落点与角色委派行形态自动适配宿主版本)。
|
|
38
38
|
|
|
39
39
|
**官方插件通道(唯一安装入口)**——不用克隆仓库,一条命令,装完重启即用:
|
|
40
40
|
|
|
@@ -95,7 +95,7 @@ curl http://127.0.0.1:19387/api/paoding/presets
|
|
|
95
95
|
| 文档 | 内容 |
|
|
96
96
|
|---|---|
|
|
97
97
|
| [架构](docs/architecture.md) | 为什么这样设计——概述、成本账、角色与工具、对应 DSH 原生机制、Token 治理、已知边界。 |
|
|
98
|
-
| [安装](docs/installation.md) | 官方插件通道一条命令安装、版本支持与预设落点双轨(DSH 0.1.5 – 0.2.
|
|
98
|
+
| [安装](docs/installation.md) | 官方插件通道一条命令安装、版本支持与预设落点双轨(DSH 0.1.5 – 0.2.1)、首装自动化与版本标记、升级、开发检出自装、host patch 检测机制、庖丁配置面板、卸载、排查。 |
|
|
99
99
|
| [编排](docs/orchestration.md) | 编排总览、失败如何呈现与三层处理、one-shot vs continuable、上下文隔离。 |
|
|
100
100
|
| [配置](docs/configuration.md) | 配置键全参考、工具条目通配符、内置角色微调、主 agent 工具与技能、自定义角色、按角色分模型、角色会话与启动方式、场景模板、配置导出导入、检查提示、HTTP 接口。 |
|
|
101
101
|
|
package/README_en.md
CHANGED
|
@@ -26,7 +26,7 @@ dsh-paoding (Chinese brand 「庖丁」/ Pao Ding, from the Zhuangzi parable of
|
|
|
26
26
|
- **Panel in English and Chinese**: every UI string ships in both languages, auto-detected (explicit choice first, then Chinese signals — browser language, host page language, Chinese time zones — outrank English ones, since the Electron shell pins navigator to en-US regardless of the OS), switchable from the More menu and remembered.
|
|
27
27
|
- **Notified of new releases, one-click upgrade in the panel**: the panel compares your local version against the latest npm registry publish (npmmirror and GitHub release as successive fallbacks) and points to the release page when a newer one is out. The Upgrade button swaps in the new version in place (profile auto-detected): regular profiles go through `dsh plugin update dsh-paoding`, while the Electron-owned desktop profile — which the dsh CLI guards against — gets a direct `pnpm add dsh-paoding@<version>` run in the profile directory, falling back to `corepack pnpm` when no bare pnpm is on PATH; a DSH restart applies it, and the orchestrator preset regenerates itself against the new version on startup. A dev checkout in link: form cannot be upgraded in place — the panel tells you how to switch back to the registry version. If the check fails (offline, rate-limited), a subdued "version check failed · retry" row stays in the header (full causes and proxy hints in its tooltip) without popping anything up.
|
|
28
28
|
- **Installs and uninstalls cleanly**: no DSH source changes; active in a new session right after install, gone when you delete one directory.
|
|
29
|
-
- **Works on both host generations**: DSH 0.1.5 through 0.2.
|
|
29
|
+
- **Works on both host generations**: DSH 0.1.5 through 0.2.1 are all supported (0.1.5 / 0.1.6 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1 / 0.2.0-rc.2 / 0.2.1-rc.2+) — the two generations discover presets differently (directory scan vs patch declaration rows), and the installer picks the right landing automatically; from 0.2.0 the workflow worker row in the orchestration composition also adapts to the host version at generation time (0.1.5 uses workflow-worker-thread, 0.1.6+ swaps to workflow-ptc); from DSH 0.2.1 the role delegation rows migrate too (0.2.1's dsh-tool-subagent rejects inline persona/toolFilter — each role gets an AgentPreset holding its persona and a role-restrict tool-surface plugin, selected via agentPreset on the spawn delegation; 0.2.0 and below keep the inline shape). Migration happens on the first save/self-heal after a host upgrade or downgrade (workspace presets, orchestrator-<slug>, are regenerated in the same self-heal pass), all without user action; the 0.2.1 prereleases are subdivided further — the tool-subagent guard landed in 0.2.1-rc.2, so rc.0/rc.1 keep the inline shape.
|
|
30
30
|
|
|
31
31
|
## Screenshots
|
|
32
32
|
|
|
@@ -34,7 +34,7 @@ dsh-paoding (Chinese brand 「庖丁」/ Pao Ding, from the Zhuangzi parable of
|
|
|
34
34
|
|
|
35
35
|
## Quick Start
|
|
36
36
|
|
|
37
|
-
Prerequisites: **Node.js ≥ 18**, **pnpm**, and a working DSH host (**@deepseek-ai/dsh 0.1.5 – 0.2.
|
|
37
|
+
Prerequisites: **Node.js ≥ 18**, **pnpm**, and a working DSH host (**@deepseek-ai/dsh 0.1.5 – 0.2.1**, all supported — the preset landing and role-row shape adapt to the host version automatically).
|
|
38
38
|
|
|
39
39
|
**The official plugin channel (the only install route)** — no clone needed; one command, then a restart:
|
|
40
40
|
|
|
@@ -95,7 +95,7 @@ Writes go through the same generation pipeline and write lock as the panel's Sav
|
|
|
95
95
|
| Document | Contents |
|
|
96
96
|
|---|---|
|
|
97
97
|
| [Architecture](docs/architecture_en.md) | Why it is designed this way — overview, the cost ledger, roles and tools, mapping to DSH's native mechanisms, token governance, known limits. |
|
|
98
|
-
| [Installation](docs/installation_en.md) | The single official channel (`dsh plugin add`), version support and the dual preset landing (DSH 0.1.5 – 0.2.
|
|
98
|
+
| [Installation](docs/installation_en.md) | The single official channel (`dsh plugin add`), version support and the dual preset landing (DSH 0.1.5 – 0.2.1), first-install automation and the version marker, upgrading, dev-checkout install, host patch detection, the Paoding Config panel, uninstalling, troubleshooting. |
|
|
99
99
|
| [Orchestration](docs/orchestration_en.md) | Orchestration overview, how failures surface and the three recovery layers, one-shot vs continuable, context isolation. |
|
|
100
100
|
| [Configuration](docs/configuration_en.md) | The full key reference, tool-entry wildcards, tuning built-in roles, main-agent tools and skills, custom roles, per-role models, per-role session and start modes, scenario templates, config export/import, health-check hints, the HTTP API. |
|
|
101
101
|
|
package/docs/installation.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
- **Node.js ≥ 18**。DSH host 与插件链路都跑在 Node 上;版本过低时 `dsh` 本身就起不来。可用 `node --version` 自查。
|
|
14
14
|
- **pnpm 可用**。`dsh plugin` 是 pnpm 的透明转发器:插件包装进 profile 时由 pnpm 完成。缺失时安装命令会报 pnpm 相关错误,装好 pnpm(`npm i -g pnpm` 或 `corepack enable`)后重试。
|
|
15
|
-
- **已安装 DSH host**(`dsh` 可用,含其 Web/agent 运行时;**@deepseek-ai/dsh 0.1.5 – 0.2.
|
|
15
|
+
- **已安装 DSH host**(`dsh` 可用,含其 Web/agent 运行时;**@deepseek-ai/dsh 0.1.5 – 0.2.1** 全支持,安装器自动适配宿主版本(预设落点与角色委派行形态),详见第 2 节「版本支持与预设落点双轨」)。本插件不改 DSH 源码,只往 DSH 的 preset roster 写入编排预设、并把「庖丁配置」面板挂进 Web 左侧栏,因此先要有可用的 DSH 家目录。
|
|
16
16
|
- **路径事实**(生成管线内建常量,写死前先了解它们):
|
|
17
17
|
|
|
18
18
|
| 项 | 默认值 | 说明 |
|
|
@@ -50,9 +50,9 @@ dsh plugin --profile web add dsh-paoding
|
|
|
50
50
|
|
|
51
51
|
`--profile web` 决定插件装进哪个 profile:「庖丁配置」面板只在以该 profile 启动的 DSH Web 里出现。`web` 是 `dsh web` 的默认 profile,多数机器无需改动;多 profile 用户对每个需要的 profile 各执行一次 `dsh plugin add`。编排预设本体落在 `$DSH_HOME/.agent-presets/`,全机共享、不随 profile 走——DSH ≥ 0.1.7 的声明行写在 home 层 `$DSH_HOME/cordis.patch.yml`,同样与 profile 无关——在任何 profile 的面板里「保存并应用」,写的都是同一份预设。
|
|
52
52
|
|
|
53
|
-
### 版本支持与预设落点双轨(DSH 0.1.5 – 0.2.
|
|
53
|
+
### 版本支持与预设落点双轨(DSH 0.1.5 – 0.2.1)
|
|
54
54
|
|
|
55
|
-
本插件兼容两代宿主:**DSH 0.1.5 / 0.1.6 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1 / 0.2.0-rc.2 全部支持**,安装与使用流程完全一致。插件 0.3.4 起,package.json 显式声明 `peerDependencies: @deepseek-ai/dsh >= 0.1.5`——0.1.7 起宿主装插件前做兼容性预检,无声明等于默认放行,显式声明后按真实兼容面把关;0.1.5 / 0.1.6 不读这个字段,声明纯属元数据,不影响安装。
|
|
55
|
+
本插件兼容两代宿主:**DSH 0.1.5 / 0.1.6 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1 / 0.2.0-rc.2 / 0.2.1-rc.2+ 全部支持**,安装与使用流程完全一致。插件 0.3.4 起,package.json 显式声明 `peerDependencies: @deepseek-ai/dsh >= 0.1.5`——0.1.7 起宿主装插件前做兼容性预检,无声明等于默认放行,显式声明后按真实兼容面把关;0.1.5 / 0.1.6 不读这个字段,声明纯属元数据,不影响安装。
|
|
56
56
|
|
|
57
57
|
两代宿主发现「本地 authored preset」的机制不同,安装器据此分双轨落点,宿主检测全自动、用户无感:
|
|
58
58
|
|
|
@@ -70,6 +70,7 @@ dsh plugin --profile web add dsh-paoding
|
|
|
70
70
|
|
|
71
71
|
- **降级自愈(0.1.7 → 0.1.6)**:0.1.6 不认识声明行,声明行留在 patch 里会让 profile 启动失败——安装器自动撤下 home patch 里的托管块;目录轨产物本就齐全,预设无缝回到目录扫描。
|
|
72
72
|
- **升级迁移(0.1.6 → 0.1.7)**:安装器自动补写托管块;`.agent-presets/` 里按旧轨生成的 preset 会话(`agentPreset: orchestrator`)在新轨下按 `config.id` 继续对上,老会话恢复不断档。
|
|
73
|
+
- **角色委派行换代(0.2.0 → 0.2.1)**:0.2.1 起 dsh-tool-subagent 拒绝配置里的内联 persona / toolFilter(出现即抛错,挂编排预设的新建会话直接失败),自愈整盘重生成把人设与工具面迁到各角色的 AgentPreset(`agentPreset: paoding-role-<角色名>`);工作区专属预设(orchestrator-<slug>)随同轮自愈一并换代。0.2.1 的 prerelease 再细分——守卫自 0.2.1-rc.2 落地,rc.0 / rc.1 仍按内联形状生成。
|
|
73
74
|
|
|
74
75
|
另有两处跨版本行为对齐,同样自动完成、无需用户动作:
|
|
75
76
|
|
package/docs/installation_en.md
CHANGED
|
@@ -12,7 +12,7 @@ Check the following before installing:
|
|
|
12
12
|
|
|
13
13
|
- **Node.js ≥ 18**. The DSH host and the plugin chain both run on Node; with an older version `dsh` won't start in the first place. Check with `node --version`.
|
|
14
14
|
- **pnpm available**. `dsh plugin` is a transparent pass-through to pnpm: installing a plugin package into a profile is done by pnpm. If pnpm is missing the install command fails with a pnpm error — install pnpm (`npm i -g pnpm` or `corepack enable`) and retry.
|
|
15
|
-
- **A working DSH host** (the `dsh` command, including its Web/agent runtime; **@deepseek-ai/dsh 0.1.5 – 0.2.
|
|
15
|
+
- **A working DSH host** (the `dsh` command, including its Web/agent runtime; **@deepseek-ai/dsh 0.1.5 – 0.2.1**, all supported — the installer adapts to the host version automatically (preset landing and role-row shape); see §2 "Version support and the dual preset landing"). This plugin does not modify DSH source code; it only writes the orchestrator preset into DSH's preset roster and mounts the Paoding Config page into the Web sidebar, so a usable DSH home directory must exist first.
|
|
16
16
|
- **Path facts** (constants built into the generation pipeline; know them before customizing):
|
|
17
17
|
|
|
18
18
|
| Item | Default | Description |
|
|
@@ -50,9 +50,9 @@ The orchestrator preset needs no separate install — the plugin fills it in aut
|
|
|
50
50
|
|
|
51
51
|
`--profile web` decides which profile the plugin is installed into: the Paoding Config page appears only in a DSH Web launched with that profile. `web` is the default profile of `dsh web`, so most machines need no change; multi-profile users run `dsh plugin add` once per profile they want it in. The orchestrator preset itself lives under `$DSH_HOME/.agent-presets/` and is shared machine-wide, independent of profiles — under DSH ≥ 0.1.7 the declaration rows go into the home-layer `$DSH_HOME/cordis.patch.yml`, equally profile-independent — Save & Apply from any profile's panel writes the same preset.
|
|
52
52
|
|
|
53
|
-
### Version support and the dual preset landing (DSH 0.1.5 – 0.2.
|
|
53
|
+
### Version support and the dual preset landing (DSH 0.1.5 – 0.2.1)
|
|
54
54
|
|
|
55
|
-
The plugin supports two host generations: **DSH 0.1.5 / 0.1.6 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1 / 0.2.0-rc.2 are all supported**, with an identical install and usage flow. As of plugin 0.3.4, package.json declares `peerDependencies: @deepseek-ai/dsh >= 0.1.5` explicitly — from 0.1.7 the host runs a plugin-compatibility precheck before installing: no declaration meant a default pass, an explicit one gets checked against the real compatibility surface; 0.1.5 / 0.1.6 never read the field, where the declaration is pure metadata and changes nothing about the install.
|
|
55
|
+
The plugin supports two host generations: **DSH 0.1.5 / 0.1.6 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1 / 0.2.0-rc.2 / 0.2.1-rc.2+ are all supported**, with an identical install and usage flow. As of plugin 0.3.4, package.json declares `peerDependencies: @deepseek-ai/dsh >= 0.1.5` explicitly — from 0.1.7 the host runs a plugin-compatibility precheck before installing: no declaration meant a default pass, an explicit one gets checked against the real compatibility surface; 0.1.5 / 0.1.6 never read the field, where the declaration is pure metadata and changes nothing about the install.
|
|
56
56
|
|
|
57
57
|
The two generations discover "local authored presets" differently, so the installer maintains a dual landing, detecting the host automatically — nothing for the user to do:
|
|
58
58
|
|
|
@@ -70,6 +70,7 @@ The first save/self-heal after the host version changes migrates automatically,
|
|
|
70
70
|
|
|
71
71
|
- **Downgrade self-heal (0.1.7 → 0.1.6)**: 0.1.6 does not understand declaration rows — leaving them in the patch breaks profile startup — so the installer removes the managed block from the home patch automatically; the directory-track artifacts are already complete, and the preset slips back to directory scanning seamlessly.
|
|
72
72
|
- **Upgrade migration (0.1.6 → 0.1.7)**: the installer writes the managed block automatically; sessions on presets generated under the old track (`.agent-presets/`, `agentPreset: orchestrator`) keep matching under the new track by `config.id`, so old sessions resume without a gap.
|
|
73
|
+
- **Role delegation row migration (0.2.0 → 0.2.1)**: from 0.2.1 dsh-tool-subagent rejects inline persona / toolFilter in the configuration (present means thrown error; new sessions on the orchestrator preset fail outright), and self-heal regenerates the whole preset, moving each role's persona and tool surface into a per-role AgentPreset (`agentPreset: paoding-role-<role>`); workspace presets (orchestrator-<slug>) are regenerated in the same self-heal pass. The 0.2.1 prereleases are subdivided further — the guard landed in 0.2.1-rc.2, so rc.0 / rc.1 keep the inline shape.
|
|
73
74
|
|
|
74
75
|
Two cross-version behavior alignments happen the same automatic way, with no user action:
|
|
75
76
|
|
package/package.json
CHANGED
|
@@ -15,17 +15,21 @@ import { autoAssignments, baseAssignments } from '../../tools/lib/alloc.mjs'
|
|
|
15
15
|
import { loadConfig, normalizeConfig, normalizeTargetFields, saveConfig, serializeConfig, stripNonTargetKeys } from '../../tools/lib/config.mjs'
|
|
16
16
|
import { parseYamlSubset, preprocessPatchText } from '../../tools/lib/yaml.mjs'
|
|
17
17
|
import { captureWarnings, healthCheck } from '../../tools/lib/health.mjs'
|
|
18
|
+
import { warn } from '../../tools/lib/util.mjs'
|
|
18
19
|
import {
|
|
19
20
|
backfillHomePatchRows,
|
|
20
|
-
|
|
21
|
+
detectAgentRolesFlavor,
|
|
22
|
+
detectHostVersionInfo,
|
|
21
23
|
detectPresetSystem,
|
|
22
24
|
formatGeneratorMarker,
|
|
23
25
|
isPtcWorkerHost,
|
|
24
26
|
listOrchestratorPresetIds,
|
|
25
27
|
parseGeneratorMarker,
|
|
28
|
+
presetRolesFlavorOf,
|
|
26
29
|
presetRowId,
|
|
27
30
|
readHomePatchRows,
|
|
28
31
|
stripHomePatchRows,
|
|
32
|
+
ROLES_AGENT_PRESET,
|
|
29
33
|
WORKER_PTC,
|
|
30
34
|
WORKER_WORKER_THREAD,
|
|
31
35
|
} from '../../tools/lib/preset-system.mjs'
|
|
@@ -35,6 +39,12 @@ function workerFlavorOf(hostVersionTriple) {
|
|
|
35
39
|
return isPtcWorkerHost(hostVersionTriple) ? WORKER_PTC : WORKER_WORKER_THREAD
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
/** 宿主版本信息 → 角色委派行标记行(生成产物行的形态,与 compose 对齐;
|
|
43
|
+
* prerelease 透传——0.2.1 守卫 0.2.1-rc.2 落地,rc.0/rc.1 按内联形态对账)。 */
|
|
44
|
+
function rolesFlavorOf(hostVersionTriple, prerelease) {
|
|
45
|
+
return presetRolesFlavorOf(hostVersionTriple, prerelease)
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
/**
|
|
39
49
|
* 标记 worker 行与当前宿主形态是否兼容:只有「产物形态」与「宿主所需形态」在
|
|
40
50
|
* ptc/worker-thread 上分叉(其中一边是 ptc)才算换代——null(v2/v1 旧标记)与
|
|
@@ -46,6 +56,16 @@ function workerFlavorCompatible(markerWorker, currentWorker) {
|
|
|
46
56
|
return (markerWorker === WORKER_PTC) === (currentWorker === WORKER_PTC)
|
|
47
57
|
}
|
|
48
58
|
|
|
59
|
+
/**
|
|
60
|
+
* 标记角色行与当前宿主形态是否兼容(workerFlavorCompatible 同款语义):分叉 =
|
|
61
|
+
* 其中一边是 agent-preset;null(v3/v2 旧标记)与 inline 同侧——0.2.1 宿主上
|
|
62
|
+
* 旧插件版本的 inline 产物重生成也产不出新形状,重生成无意义;插件升级后版本
|
|
63
|
+
* 不符走整盘重生成,新形状经那条路径落地。
|
|
64
|
+
*/
|
|
65
|
+
function rolesFlavorCompatible(markerRoles, currentRoles) {
|
|
66
|
+
return (markerRoles === ROLES_AGENT_PRESET) === (currentRoles === ROLES_AGENT_PRESET)
|
|
67
|
+
}
|
|
68
|
+
|
|
49
69
|
export function resolveDshHome() {
|
|
50
70
|
return process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
|
|
51
71
|
}
|
|
@@ -403,11 +423,12 @@ export function deleteWorkspacePreset(state, workspacePath) {
|
|
|
403
423
|
//
|
|
404
424
|
// 唯一官方安装通道是插件通道(dsh plugin add dsh-paoding),包不再携带 CLI:
|
|
405
425
|
// preset 的落盘改由插件启动时自愈。对账基准是 preset 目录里的 .generator-version
|
|
406
|
-
// 标记文件(
|
|
407
|
-
//
|
|
408
|
-
//
|
|
409
|
-
// preset 还是旧版产物」「升 dsh 后 preset
|
|
410
|
-
//
|
|
426
|
+
// 标记文件(v4 起内容 = 生成器版本 + 预设安装轨道 + workflow worker 形态 +
|
|
427
|
+
// 角色委派行形态四行):插件包版本变、或宿主轨道翻转 / worker 形态换代 / 角色
|
|
428
|
+
// 行换代(只升 dsh 不动插件——升级最常见路径,旧标记缺行时同样解析为不符)→
|
|
429
|
+
// 下次启动自动自愈,一举解决「升级后 preset 还是旧版产物」「升 dsh 后 preset
|
|
430
|
+
// 静默消失」「升 dsh 后 worker 行失配 never started」与「升 dsh 0.2.1 后内联
|
|
431
|
+
// persona/toolFilter 被 apply 拒绝、新建会话即抛错」四类漂移。
|
|
411
432
|
|
|
412
433
|
// 生成器版本(标记对账基准):插件包根 package.json 读一次即缓存。读失败兜底
|
|
413
434
|
// '0.0.0'——最坏后果只是每次启动多重生成一次 preset,不会装坏任何东西。
|
|
@@ -423,6 +444,45 @@ export function pluginVersion() {
|
|
|
423
444
|
return cachedGeneratorVersion ?? '0.0.0'
|
|
424
445
|
}
|
|
425
446
|
|
|
447
|
+
/**
|
|
448
|
+
* 工作区预设(orchestrator-<slug>)角色行形态迁移:基础 preset 整盘重生成后,
|
|
449
|
+
* 磁盘上各工作区产物的角色行形态若与宿主所需不符(典型:宿主刚升 0.2.1,工作区
|
|
450
|
+
* 产物还是旧内联形状——声明行又在场,挂该预设的新建会话照样被 tool-subagent
|
|
451
|
+
* 守卫拒绝),按该工作区在配置 workspaces 段里最后一次应用的条目就地重生成
|
|
452
|
+
*(顶层配置兜底合入,落盘不回写配置)。产物缺失(从未生成过)与形态判不出的
|
|
453
|
+
*(角色被清空)一律跳过——不自作主张替用户代生成;单个工作区失败只 warn,
|
|
454
|
+
* 绝不拖垮整体自愈。返回完成换代的工作区 presetId 列表。
|
|
455
|
+
*/
|
|
456
|
+
function migrateWorkspacePresetRoles({ dshHome, state }) {
|
|
457
|
+
const wanted = presetRolesFlavorOf(state.hostVersionTriple, state.hostPrerelease)
|
|
458
|
+
const wsEntries = state.existing?.workspaces ?? {}
|
|
459
|
+
const wsPaths = Object.keys(wsEntries)
|
|
460
|
+
if (wsPaths.length === 0) return []
|
|
461
|
+
const slugs = assignSlugs(wsPaths)
|
|
462
|
+
const migrated = []
|
|
463
|
+
for (const wsPath of wsPaths) {
|
|
464
|
+
const presetId = presetIdOf(slugs.get(wsPath))
|
|
465
|
+
let flavor = null
|
|
466
|
+
try {
|
|
467
|
+
flavor = detectAgentRolesFlavor(readFileSync(path.join(dshHome, '.agent-presets', presetId, 'agent.cordis.yml'), 'utf8'))
|
|
468
|
+
} catch {
|
|
469
|
+
continue // 目录 / 产物缺失:该工作区从未生成过,保持沉默(生成是显式动作)
|
|
470
|
+
}
|
|
471
|
+
if (flavor === null || flavor === wanted) continue
|
|
472
|
+
try {
|
|
473
|
+
// 该工作区最后一次应用的条目优先,顶层字段兜底(条目缺键时回落全局值);
|
|
474
|
+
// saveConfigOnWrite=false——配置 workspaces 段原样保留,只换代产物。
|
|
475
|
+
const merged = { ...normalizeTargetFields(state.existing), ...normalizeTargetFields(wsEntries[wsPath]) }
|
|
476
|
+
const assignments = autoAssignments({ existing: merged, suggested: state.suggested, staticBase: state.staticBase })
|
|
477
|
+
generateAndInstall(state, assignments, { dryRun: false, saveConfigOnWrite: false, workspacePath: wsPath })
|
|
478
|
+
migrated.push(presetId)
|
|
479
|
+
} catch (err) {
|
|
480
|
+
warn(`工作区预设角色行换代失败(${presetId},可对该工作区重新「保存并应用」修复): ${err?.message ?? err}`)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return migrated
|
|
484
|
+
}
|
|
485
|
+
|
|
426
486
|
// dispose 中止时的返回理由(记 reason 而非 error:不算失败,调用方不打日志)。
|
|
427
487
|
const PRESET_ENSURE_ABORTED = '插件已卸载(dispose),本次 preset 生成中止'
|
|
428
488
|
|
|
@@ -431,9 +491,10 @@ const PRESET_ENSURE_ABORTED = '插件已卸载(dispose),本次 preset 生
|
|
|
431
491
|
*
|
|
432
492
|
* 判定(满足其一即动盘):
|
|
433
493
|
* - preset 目录 / 标记缺失,或标记版本与 generatorVersion 不符 → 整盘重生成;
|
|
434
|
-
* - 版本一致但标记 worker
|
|
435
|
-
*
|
|
436
|
-
*
|
|
494
|
+
* - 版本一致但标记 worker 形态或角色行形态与当前宿主所需分叉(宿主跨过
|
|
495
|
+
* 0.1.5/0.1.6 worker 边界或 0.2.0/0.2.1 角色行边界;旧格式标记在真实
|
|
496
|
+
* ptc/agent-preset 宿主上同样分叉)→ 整盘重生成(这些行长在产物正文里,
|
|
497
|
+
* 轻量路径覆盖不到);
|
|
437
498
|
* - 版本 worker 都一致但标记轨道与当前宿主轨道不符(只升 dsh 不动插件 /
|
|
438
499
|
* 旧格式标记)→ 轻量迁移:声明轨上按磁盘产物补写缺失声明行(内容字节
|
|
439
500
|
* 不动,不重生成),directory 轨上落回整盘重生成(残留声明行会让 0.1.6
|
|
@@ -467,12 +528,14 @@ export async function ensurePresetInstalled({ dshHome = resolveDshHome(), genera
|
|
|
467
528
|
|
|
468
529
|
if (marker !== null && marker.version === generatorVersion) {
|
|
469
530
|
// 版本一致:内容原则上无需重生成,但宿主可能已随 dsh 升降级翻转轨道或
|
|
470
|
-
// 跨过 workflow worker
|
|
471
|
-
//
|
|
472
|
-
//
|
|
473
|
-
//
|
|
474
|
-
const
|
|
475
|
-
|
|
531
|
+
// 跨过 workflow worker 形态 / 角色委派行形态边界(只升 dsh 不动插件是升级
|
|
532
|
+
// 常态),声明行也可能被外部动过——这里做轻量对账。worker 形态或角色行
|
|
533
|
+
// 形态不符(v3/v2/v1 旧标记缺行,一律视为不符)不能走轻量路径:这些行
|
|
534
|
+
// 长在产物正文里,补行/撤行覆盖不到,必须整盘重生成——落到下方重生成分支。
|
|
535
|
+
const hostInfo = detectHostVersionInfo()
|
|
536
|
+
const currentWorker = workerFlavorOf(hostInfo?.triple ?? null)
|
|
537
|
+
const currentRoles = rolesFlavorOf(hostInfo?.triple ?? null, hostInfo?.prerelease ?? null)
|
|
538
|
+
if (workerFlavorCompatible(marker.worker, currentWorker) && rolesFlavorCompatible(marker.roles, currentRoles)) {
|
|
476
539
|
const system = await detectPresetSystem({ dshHome })
|
|
477
540
|
if (shouldAbort?.()) return { installed: false, reason: PRESET_ENSURE_ABORTED }
|
|
478
541
|
const presetIds = listOrchestratorPresetIds(dshHome)
|
|
@@ -481,7 +544,7 @@ export async function ensurePresetInstalled({ dshHome = resolveDshHome(), genera
|
|
|
481
544
|
if (marker.track === 'declarative' && backfilled.length === 0) {
|
|
482
545
|
return { installed: false, reason: 'preset 已由当前版本生成器产出,无需重生成' }
|
|
483
546
|
}
|
|
484
|
-
writeFileSync(markerFile, formatGeneratorMarker(generatorVersion, 'declarative', currentWorker), 'utf8')
|
|
547
|
+
writeFileSync(markerFile, formatGeneratorMarker(generatorVersion, 'declarative', currentWorker, currentRoles), 'utf8')
|
|
485
548
|
return backfilled.length > 0
|
|
486
549
|
? { installed: false, backfilled, reason: `宿主已切换声明行轨,补写 ${backfilled.length} 条预设声明行(preset 内容未重生成)` }
|
|
487
550
|
: { installed: false, reason: '预设安装轨道标记已更新为声明行轨(内容无需重生成)' }
|
|
@@ -492,12 +555,12 @@ export async function ensurePresetInstalled({ dshHome = resolveDshHome(), genera
|
|
|
492
555
|
if (marker.track === 'directory') {
|
|
493
556
|
return { installed: false, reason: 'preset 已由当前版本生成器产出,无需重生成' }
|
|
494
557
|
}
|
|
495
|
-
writeFileSync(markerFile, formatGeneratorMarker(generatorVersion, 'directory', currentWorker), 'utf8')
|
|
558
|
+
writeFileSync(markerFile, formatGeneratorMarker(generatorVersion, 'directory', currentWorker, currentRoles), 'utf8')
|
|
496
559
|
return { installed: false, reason: '预设安装轨道标记已升级为带轨道格式(内容无需重生成)' }
|
|
497
560
|
}
|
|
498
561
|
// 声明行残留 + directory 宿主:落到下方整盘重生成
|
|
499
562
|
}
|
|
500
|
-
// worker
|
|
563
|
+
// worker 形态或角色行形态不符(含旧格式标记升级到 v4):落到下方整盘重生成
|
|
501
564
|
}
|
|
502
565
|
|
|
503
566
|
if (shouldAbort?.()) return { installed: false, reason: PRESET_ENSURE_ABORTED }
|
|
@@ -525,16 +588,20 @@ export async function ensurePresetInstalled({ dshHome = resolveDshHome(), genera
|
|
|
525
588
|
if (shouldAbort?.()) return { installed: false, reason: PRESET_ENSURE_ABORTED }
|
|
526
589
|
mkdirSync(presetDir, { recursive: true })
|
|
527
590
|
const track = result.presetSystem === 'declarative' ? 'declarative' : 'directory'
|
|
528
|
-
writeFileSync(markerFile, formatGeneratorMarker(generatorVersion, track, workerFlavorOf(state.hostVersionTriple)), 'utf8')
|
|
591
|
+
writeFileSync(markerFile, formatGeneratorMarker(generatorVersion, track, workerFlavorOf(state.hostVersionTriple), rolesFlavorOf(state.hostVersionTriple, state.hostPrerelease)), 'utf8')
|
|
529
592
|
// 声明轨上整盘重生成只重建本 preset 的行:其余工作区 preset 目录若在而
|
|
530
593
|
// 声明行缺(轨道翻转后首次触发本路径),一并补齐。
|
|
531
594
|
const backfilled = track === 'declarative' ? backfillHomePatchRows(dshHome, listOrchestratorPresetIds(dshHome)) : []
|
|
595
|
+
// 工作区预设角色行形态换代(宿主跨 0.2.1 边界后的存量 orchestrator-<slug>
|
|
596
|
+
// 产物):基础重生成只换了全局预设,工作区产物不跟手就会继续被守卫拒绝。
|
|
597
|
+
const migratedPresets = migrateWorkspacePresetRoles({ dshHome, state })
|
|
532
598
|
return {
|
|
533
599
|
installed: true,
|
|
534
600
|
...(backfilled.length > 0 ? { backfilled } : {}),
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
: 'preset 缺失或由旧版生成器产出,已写入基础模板'
|
|
601
|
+
...(migratedPresets.length > 0 ? { migratedPresets } : {}),
|
|
602
|
+
reason:
|
|
603
|
+
(state.existing ? 'preset 缺失或由旧版生成器产出,已按现有配置重新生成' : 'preset 缺失或由旧版生成器产出,已写入基础模板') +
|
|
604
|
+
(migratedPresets.length > 0 ? `;工作区预设角色行已换代:${migratedPresets.join('、')}` : ''),
|
|
538
605
|
}
|
|
539
606
|
} catch (err) {
|
|
540
607
|
// 绝不抛:首装自愈是锦上添花,失败只带回 error 交调用方记日志,不拖垮插件启动。
|
|
@@ -18,12 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
# ── identity ────────────────────────────────────────────────────────────────
|
|
20
20
|
|
|
21
|
-
# 编排人设:{{model}}
|
|
21
|
+
# 编排人设:{{model}} 由 agent 的 route 解析;{{cwd}} 禁用(见下)。
|
|
22
|
+
# 注意:作为 agent-preset-registry 选中 preset 挂部署主代理时,0.2.1 的
|
|
23
|
+
# deployment:persona-prefix 段只注册 provider/model——禁用 {{cwd}}(纯装饰,
|
|
24
|
+
# 工作目录已由宿主 env 上下文提供)。
|
|
22
25
|
- id: persona
|
|
23
26
|
name: '@deepseek-ai/dsh-persona'
|
|
24
27
|
config:
|
|
25
28
|
prefix: |-
|
|
26
|
-
You are the orchestrator agent powered by the {{model}} model.
|
|
29
|
+
You are the orchestrator agent powered by the {{model}} model.
|
|
27
30
|
|
|
28
31
|
Decompose the task, delegate to role agents, integrate results.
|
|
29
32
|
- Internal file questions (finding code, references, reading files): solve yourself with glob/grep/read (and codegraph if enabled) — never delegate them.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role tool-surface filter (role-restrict.mjs)
|
|
3
|
+
*
|
|
4
|
+
* Part of the dsh-paoding 编排模式 (orchestrator) preset — one copy is mounted
|
|
5
|
+
* inside every per-role AgentPreset (paoding-role-<toolName>) that the
|
|
6
|
+
* generator emits for DSH 0.2.1+ hosts. It hooks the `system-prompt/assemble`
|
|
7
|
+
* waterfall and narrows the MOUNTING agent's model-facing tool catalog to the
|
|
8
|
+
* role's `config.allow` list (the former inline `toolFilter.allow` of the
|
|
9
|
+
* delegation row, relocated here by the 0.2.1 migration — dsh-tool-subagent
|
|
10
|
+
* rejects inline persona / toolFilter since 0.2.1, so the role surface now
|
|
11
|
+
* lives in the preset's plugin composition instead).
|
|
12
|
+
*
|
|
13
|
+
* Semantics are the MIRROR of the orchestrator restrict.mjs: that one spares
|
|
14
|
+
* delegated children (origin: 'subagent') because it sits in the MAIN agent's
|
|
15
|
+
* preset; this one sits in the role agent's own preset, so it filters
|
|
16
|
+
* unconditionally — no delegated-child escape hatch, and no registration-time
|
|
17
|
+
* deny either (a role allow list may contain 'skill'; the skill directory
|
|
18
|
+
* injection guard runs at registration level and must keep passing).
|
|
19
|
+
*
|
|
20
|
+
* The filter is fail-open: any unexpected error returns the assembly
|
|
21
|
+
* unchanged so a filter bug can never brick a delegated run. It filters the
|
|
22
|
+
* POST-registration assembly (the same timing as restrict.mjs): every allow
|
|
23
|
+
* name has been resolved by the time the waterfall runs, so names that are
|
|
24
|
+
* not currently mounted are simply absent — never an error. Restricting
|
|
25
|
+
* during plugin apply() instead would validate allow names against a
|
|
26
|
+
* partially-mounted registry (MCP tools may register later) and wrongly
|
|
27
|
+
* reject role creation.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
31
|
+
export const name = 'paoding-role-restrict'
|
|
32
|
+
|
|
33
|
+
/** Prompt assembly and the tool registry must exist before this filter runs. */
|
|
34
|
+
export const inject = ['systemPrompt', 'tools']
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Default allow list. The generator always injects the role's explicit
|
|
38
|
+
* `config.allow`; this fallback only exists so a hand-mounted instance
|
|
39
|
+
* without config fails open to "no filtering" instead of stripping every
|
|
40
|
+
* tool from the role agent (an empty allow would brick every delegated run).
|
|
41
|
+
*/
|
|
42
|
+
const DEFAULT_ALLOW = null
|
|
43
|
+
|
|
44
|
+
/** Warn once so a misbehaving filter never spams the log per request. */
|
|
45
|
+
let warned = false
|
|
46
|
+
|
|
47
|
+
export function apply(ctx, config = {}) {
|
|
48
|
+
const allow = config.allow === undefined ? DEFAULT_ALLOW : new Set(config.allow)
|
|
49
|
+
if (allow === null || allow.size === 0) return
|
|
50
|
+
|
|
51
|
+
ctx.on(
|
|
52
|
+
'system-prompt/assemble',
|
|
53
|
+
async (_assembly, context, next) => {
|
|
54
|
+
// Downstream errors propagate untouched (the same contract as the
|
|
55
|
+
// orchestrator restrict.mjs): only this filter's own logic is guarded.
|
|
56
|
+
const assembled = await next()
|
|
57
|
+
try {
|
|
58
|
+
// Unconditional by design: this preset is only ever mounted for role
|
|
59
|
+
// agents (explicit agentPreset selection skips parent inheritance),
|
|
60
|
+
// so whatever agent assembles here IS the role agent.
|
|
61
|
+
const tools = Array.isArray(assembled.tools) ? assembled.tools : []
|
|
62
|
+
const filtered = tools.filter((tool) => allow.has(tool?.name))
|
|
63
|
+
if (!warned) {
|
|
64
|
+
ctx.logger.info(
|
|
65
|
+
`${name}: role agent tool surface ${tools.length} -> ${filtered.length} tools (allow=${[...allow].sort().join(', ')})`,
|
|
66
|
+
)
|
|
67
|
+
warned = true
|
|
68
|
+
}
|
|
69
|
+
return { ...assembled, tools: filtered }
|
|
70
|
+
} catch (error) {
|
|
71
|
+
// Fail open: a filter bug must never brick a delegated run.
|
|
72
|
+
ctx.logger.warn(`${name}: filter failed, exposing full catalog: ${String(error)}`)
|
|
73
|
+
return assembled
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{ prepend: true },
|
|
77
|
+
)
|
|
78
|
+
}
|