dsh-auto-flow 0.1.1 → 0.1.2

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 方世伟
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 方世伟
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,39 +1,40 @@
1
1
  # DeepSeek Harness 插件
2
2
 
3
- DeepSeek Harness 插件 Bundle(Host 半 + Client 半同包),演示通信设计:
4
-
5
- - **重通道:@Remote 严格模式**(`AutoFlowService`)——Host 服务,浏览器经 `ctx.remote.autoFlow` 调用,双向 zod 校验 + 完整类型,契约由 `pnpm typert:gen` 生成(`lib/typert.*`,提交进 git)。
6
- - **轻执行也走 @Remote**:`exec` 方法在宿主内经 `ctx.shell`(与 bash 工具同一执行器,绝不经过模型)执行命令行,返回结构化结果(`exitCode`/`signal`/`stdout`/`stderr` 等),**输出只回调用方 UI,不进会话日志、不动界面**;shell 是可选依赖,未组合 shell 提供方时 `exec` 报错、插件其余部分照常工作。
7
- - **注意**:内置 `ctx.remote.commands.execute` 是**会话命令通道**——结果会生成 durable 命令节点进会话并驱动界面(斜杠命令语义),仅用于"就是要当命令用"的场景;模板不拿它演示机器执行,以免污染会话。
8
- - **模型工具**:`plugin_auto_flow` 复用上面的服务。
9
- - **持久化只进 domain storage**:问候落 domain storage(与 session 日志隔离);不追加自定义会话事件(harness 持久化读路径会拒绝未知事件类型,且 `Session.append` 无法标记 `ignorable`)。
10
-
11
- > English TL;DR: A dsh plugin bundle demoing Host↔Client communication — strict `@Remote` RPC (`send`/`list` for heavy comms, `exec` for shell-backed lightweight execution whose output stays in the UI and never enters the session log). Run `pnpm typert:gen` to regenerate the RPC contract.
12
-
13
- ## 能力清单(每项都对齐官方实现)
14
-
15
- | 能力 | 官方参考 | 位置 |
16
- | ----------------------------------- | ------------------------------------- | -------------------------------------------------- |
17
- | `@Remote` 严格模式 | `goal`、`message-feedback` | `src/index.ts` 的 `send`/`list` |
18
- | `@Remote exec` 宿主 shell(轻执行) | `tool-bash`(shell seam) | `src/index.ts` 的 `exec` |
19
- | 模型工具 | `tool-bash`、`tool-todo` | `plugin_auto_flow`(`defineTool` + `presentCall`) |
20
- | 斜杠命令 | `commands` + `plan-mode` | `/auto-flow`(`ctx.commands.register`) |
21
- | 插件 Config + 设置 UI | `settings` + `llm-deepseek` | `installSection` + `settings.general.item` |
22
- | 持久化(domain storage) | `storage-domain` + `message-feedback` | `src/domain.ts` |
23
- | 客户端 UI 槽位(slots) | `ui-goal`、`ui-message-feedback` | `conversation.input.dock` 等三槽位 |
24
- | 多语言 locale | `ui-*` 的 `locales.ts` | `src/client/locales.ts` |
25
- | 跨插件服务协作 | Cordis `Service` | `dsh-auto-flow-core` 的 `autoFlowFormatter` |
3
+ DeepSeek Harness 插件 Bundle(Host 半 + Client 半同包),一个**确定性工作流插件**:
4
+
5
+ - **@Remote 严格模式**(`AutoFlowService`)——Host 服务,浏览器经 `ctx.remote.autoFlow` 调用,双向 zod 校验 + 完整类型,契约由 `pnpm typert:gen` 生成(`lib/typert.*`,提交进 git)。
6
+ - **工作流编辑器**:React Flow 画布 + 节点系统,画布经 `loadFlow`/`saveFlow` 落 domain storage。
7
+ - 编排节点:表单(数据源)/ 运行脚本(playwright-ag)/ 人工审批(屏障)。
8
+ - 值传递节点:文本模板 / AI 模型 / 图片识别 / 执行命令 / HTTP 请求 / 条件分支 / 输出,
9
+ 支持 `{{input.*}}`、`{{steps.<节点id>}}`、`{{current}}` 插值与 true/false 分支剪枝。
10
+ - **执行引擎**:按层级并发调度脚本节点(同层独立脚本并行),审批节点是串行人工屏障;脚本经 playwright-ag 运行,产物落 `<workspaceDir>/<runId>/<index>-<script>/`,人工在审批面板对产物做增删改查后放行/驳回。
11
+ - **可运行脚本目录**:脚本清单(展示名 / 描述 / 参数 / 产物装配规则)由 playwright-ag 脚本自描述、经 `listScripts` 下发;本插件对具体业务脚本零感知。
12
+
13
+ > English TL;DR: A dsh plugin bundle implementing a deterministic workflow editor + engine — strict `@Remote` RPC, a React Flow canvas with a node system (form / script / approval), concurrent script execution with serial human-approval gates, and workspace artifact CRUD. Scripts run via the playwright-ag plugin.
14
+
15
+ ## 能力清单
16
+
17
+ | 能力 | 位置 |
18
+ | ------------------------------ | -------------------------------------------------------------------------- |
19
+ | `@Remote` 严格模式 | `src/host/service.ts` 的 `loadFlow` / `saveFlow` / `runFlow` 等 |
20
+ | 执行引擎(并发 + 审批 + 取消) | `src/host/engine.ts` + `src/host/service.ts` 的 `cancelRun` |
21
+ | 环检测 | `src/workflow/pipeline.ts` 的 `detectCycle` |
22
+ | 脚本目录(playwright-ag) | `src/host/service.ts` 的 `listScripts` + `src/client/.../scriptCatalog.ts` |
23
+ | 插件 Config + 设置 UI | `src/host/config.ts`(workspaceDir)+ `features/settings` |
24
+ | 持久化(domain storage) | `src/host/domain.ts`(flows / runs) |
25
+ | 客户端 UI 槽位(slots) | `src/client/features/*`(`conversation.input.dock` 等) |
26
+ | 多语言 locale | `src/client/features/*/locales.ts` + `locales.ts` 聚合 |
26
27
 
27
28
  ## 开发
28
29
 
29
30
  ```sh
30
- pnpm install # 安装全部工作区依赖(含 devDependencies)
31
+ pnpm install # 安装全部工作区依赖
31
32
  pnpm typert:gen # 首次必跑:生成 @Remote 契约(lib/typert.*),之后改动签名时重跑
32
33
  pnpm dev # 开发:tsdown --watch 双段(含首次构建)
33
34
  pnpm typecheck # 三程序检查:Host + Client + 默认程序(tsconfig.json,均不 emit)
34
35
  pnpm test # 单测:Host 半 + 浏览器半 jsdom(需先跑过 typert:gen)
35
36
  pnpm build # 一次性构建产物(发布用)
36
- pnpm check # 一键门禁:lint + typecheck + test + build(发布前跑)
37
+ pnpm check # 一键门禁:typecheck + test + build(发布前跑)
37
38
  ```
38
39
 
39
40
  ### 热更新边界
@@ -58,41 +59,35 @@ dsh plugin --profile web add "<workspace>/packages/dsh-auto-flow"
58
59
 
59
60
  `@Remote` 走 Typert 严格模式。**改了方法签名、导出名或参数类型后**运行 `pnpm typert:gen`。
60
61
  生成器按工作区原生布局登记 `packages/*`;唯一适配是 `scripts/patch-typert-generator.mjs`
61
- 的 4 行协议归属补丁(生成器只把"工作区源码包"形式的 `@deepseek-ai/dsh-typert-protocol`
62
- 识别为协议符号,第三方仓库以 npm 依赖安装时需要此扩展)。生成器升级后由脚本内两处
63
- **锚点检查**拦截:协议归属锚点失配报 `cannot apply the single protocol-owner patch`,
64
- helper 插入点失配报 `cannot locate analyzer helper insertion point`——两种情况都按
65
- 报错更新该脚本的对应锚点即可)。
62
+ 的协议归属补丁(生成器升级后由脚本内锚点检查拦截失效并报错,按报错更新锚点即可)。
66
63
 
67
64
  产物 `lib/typert.*` 随发布提交(日常不提交 `lib/`,发布时 `git add -f packages/*/lib`),
68
65
  GitHub 安装免构建。
69
66
 
70
67
  ## 插件配置
71
68
 
72
- `src/index.ts` 的 `Config` 是插件配置,可在 Profile 的 `cordis.patch.yml` 里按行覆盖:
69
+ `src/host/config.ts` 的 `Config` 是插件配置,可在 Profile 的 `cordis.patch.yml` 里按行覆盖:
73
70
 
74
71
  ```yaml
75
72
  - id: dsh-auto-flow
76
73
  config:
77
- prefix: '你好'
78
- maxCommandBytes: 1024
74
+ workspaceDir: workflow-runs
79
75
  ```
80
76
 
81
77
  ## 对齐官方(验收线)
82
78
 
83
- - **结构 / 命名 / 依赖分层**:Host 半 default-export `class X extends TypertRemoteService`,Client 半 `inject` / `apply`;`dsh.bundle.patch` + `dsh.client` 双声明同包;exports / files 分层对齐 `goal` + `ui-goal`。
79
+ - **结构 / 命名 / 依赖分层**:Host 半 default-export `class X extends TypertRemoteService`,Client 半 `inject` / `apply`;`dsh.bundle.patch` + `dsh.client` 双声明同包;exports / files 分层对齐官方插件。
84
80
  - **两类 schema**:插件 `Config` 用 schemastery(`z`),持久化记录用 zod。
85
- - **注册即 effect**:每个贡献走 `ctx.effect` / 注册表返回的 disposer;可选 seam 用 `ctx.inject([...], cb)`;可选服务(shell)用 `ctx.get('shell')`。
86
- - **持久化只进 domain storage**:问候落 domain storage(与 session 日志隔离);不追加自定义会话事件(harness 持久化读路径会拒绝未知事件类型,且 `Session.append` 无法标记 `ignorable`)。
87
- - **Typed Remote 失败**:`RemoteErrorDetailsMap` 声明 `autoFlow/command-too-long`。
81
+ - **注册即 effect**:每个贡献走 `ctx.effect` / 注册表返回的 disposer;可选 seam 用 `ctx.inject([...], cb)`;可选服务(playwright-ag / storageDomain)用 `ctx.get(...)`。
82
+ - **持久化只进 domain storage**:运行快照落 domain storage(与 session 日志隔离);不追加自定义会话事件。
88
83
 
89
84
  ## 发布
90
85
 
91
86
  npm(每包独立版本)。**发布前两件事**:
92
87
 
93
- 1. **登录 npmjs**:`npm login --registry=https://registry.npmjs.org/`(你的全局 registry 若指向 npmmirror,未登录 npmjs 会导致 `pnpm publish` 报 E404)。
94
- 2. **包名可用性**:无 scope 的通用名(`dsh-*`)容易被占用/保留,`npm publish` 会以 E404 拒绝。建议生成时用**你有所有权的 scope**:`node src/index.mjs @你的scope/xxx --dir ...` → 包名 `@你的scope/xxx`(`publishConfig.access: public` 已配好);用户安装 `dsh plugin --profile web add "@你的scope/xxx"`。
95
- 3. **补全发布元数据**:正式发布前把 `package.json` 的 `repository` / `bugs` / `homepage` / `keywords` 换成你的真实仓库信息(模板不预填,避免假地址误导)。
88
+ 1. **登录 npmjs**:`npm login --registry=https://registry.npmjs.org/`。
89
+ 2. **包名可用性**:无 scope 的通用名(`dsh-*`)容易被占用/保留,建议用你有所有权的 scope(`publishConfig.access: public` 已配好)。
90
+ 3. **补全发布元数据**:把 `package.json` 的 `repository` / `bugs` / `homepage` / `keywords` 换成你的真实仓库信息。
96
91
 
97
92
  ```sh
98
93
  pnpm publish:npm # prepublishOnly 自动 typert:gen + test + build
@@ -108,20 +103,18 @@ git push --tags
108
103
 
109
104
  ## 安装(用户侧)
110
105
 
111
- 命令里的包名/git 地址统一用**双引号**包住:单引号在 cmd 里是字面量,裸 `@scope/包名` 在 PowerShell 里会触发 splatting,裸 `repo#path` 在 bash/zsh 里会把 `#` 当注释。
106
+ 命令里的包名/git 地址统一用**双引号**包住。
112
107
 
113
108
  ```sh
114
109
  dsh plugin --profile web add "dsh-auto-flow" # npm
115
110
  dsh plugin --profile web remove "dsh-auto-flow" # npm 卸载
116
111
  dsh plugin --profile web add "github:you/<repo>#dsh-auto-flow@v0.1.0" # GitHub(monorepo 子包)
117
- dsh plugin --profile web remove "dsh-auto-flow" # GitHub 卸载
118
112
  dsh plugin --profile web add "../<workspace>/packages/dsh-auto-flow" # 本地目录
119
113
  ```
120
114
 
121
115
  ## 常见问题
122
116
 
123
- - **为什么把 `lib/` 提交进 git?** dsh 经 GitHub 安装插件时不触发构建(pnpm 默认拦截 git 依赖的 prepare 脚本),提交产物让安装开箱即用(发布时 `git add -f`)。
124
- - **首次 `pnpm build` / `pnpm test` 报找不到 `<包名>/remote`?** 先运行 `pnpm typert:gen`(契约产物尚未生成;浏览器半 jsdom 测试同样依赖它)。
125
- - **`typert:gen` 报「cannot apply the single protocol-owner patch」?** 生成器升级后协议归属锚点失配,按报错更新 `scripts/patch-typert-generator.mjs` 的对应锚点。
126
- - **`typert:gen` 报「cannot locate analyzer helper insertion point」?** 生成器升级后 helper 插入点失配,按报错更新该脚本的插入点锚点。
127
- - **`pnpm publish:npm` 报 `E404 PUT ... - Not found`?** 两件事:① `npm login --registry=https://registry.npmjs.org/`(未登录 npmjs;全局 registry 若在 npmmirror 会误导);② 包名对 npmjs 不可创建(无 scope 通用名被占用/保留)——改用你有所有权的 scope 名(`@你的scope/xxx`)。
117
+ - **为什么把 `lib/` 提交进 git?** dsh 经 GitHub 安装插件时不触发构建,提交产物让安装开箱即用。
118
+ - **首次 `pnpm build` / `pnpm test` 报找不到 `<包名>/remote`?** 先运行 `pnpm typert:gen`。
119
+ - **运行工作流报 `playwright-missing`?** 未安装 playwright-ag 插件;装 `plugin_playwright_ag` 后重试。
120
+ - **运行报 `cycle-detected`?** 画布里存在环,检查连线后重跑。
package/cordis.patch.yml CHANGED
@@ -1,33 +1,12 @@
1
1
  # dsh-auto-flow 的 Bundle 补丁层:向 Profile 组合插入一个插件行。
2
+ # dsh plugin add 安装后,Loader 按这里的行挂载 Host 半;浏览器半由 dsh.client 声明自动接入。
2
3
  #
3
- # `dsh plugin add` 安装本包后,dsh 会按序应用每个 Bundle 的补丁;
4
- # 这里的行会被 Loader 挂载(`name` 指向本包,即 Host 半),
5
- # 浏览器半由包里的 dsh.client 声明自动接入,无需在此声明。
6
- #
7
- # 覆盖本插件配置示例(对应 src/index.ts 的 Config,取消注释即可用):
8
- #
4
+ # 覆盖本插件配置(对应 src/host/config.ts 的 Config):
9
5
  # - insert:
10
6
  # - id: dsh-auto-flow
11
7
  # name: 'dsh-auto-flow'
12
8
  # config:
13
- # prefix: '你好'
14
- #
15
- # 覆写其它插件配置(跨插件协作):补丁可以按 id 覆写组合里其它插件的配置,
16
- # 例如给 dsh 内置的视觉适配器声明一条 OpenAI 兼容路由(密钥走环境变量/ .env,
17
- # 不要写进 patch):
18
- #
19
- # - id: llm-pi-ai
20
- # config:
21
- # providers:
22
- # studio-vision:
23
- # displayName: Studio Vision
24
- # apiKeyEnv: YOUR_API_KEY
25
- # api: openai-completions
26
- # baseURL: https://your-gateway.example.com/v1
27
- # defaultInput: [text, image]
28
- # models:
29
- # - id: your-vl-model
30
- # input: [text, image]
9
+ # workspaceDir: workflow-runs
31
10
  - insert:
32
11
  - id: dsh-auto-flow
33
12
  name: 'dsh-auto-flow'