personal-bot 0.2.14 → 0.2.15
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/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/README.md +10 -11
- package/README.zh-CN.md +10 -11
- package/docs/README.md +2 -2
- package/docs/adr/0001-claude-skill-discovery.md +1 -1
- package/docs/agent-collaboration.md +3 -3
- package/docs/architecture-guidelines.md +1 -1
- package/docs/capability-design.md +2 -2
- package/docs/claude-code-design.md +10 -11
- package/docs/claude-code.md +8 -15
- package/docs/dsh.md +7 -8
- package/docs/file-storage.md +2 -3
- package/docs/installation-design.md +4 -5
- package/docs/interaction-design.md +1 -1
- package/docs/model-context.md +9 -10
- package/docs/release.md +5 -5
- package/docs/technical-design.md +16 -21
- package/docs/workspace-configuration.md +5 -8
- package/hooks/hooks.json +1 -4
- package/lib/client.js +3 -15
- package/lib/extension/acp-member.js +1 -3
- package/lib/extension/acp-worker.js +3 -22
- package/lib/extension/claude-hooks.d.ts +0 -6
- package/lib/extension/claude-hooks.js +5 -31
- package/lib/extension/dsh/acp-member.js +1 -2
- package/lib/extension/dsh/command.js +2 -7
- package/lib/extension/dsh/management.d.ts +1 -1
- package/lib/extension/dsh/management.js +3 -3
- package/lib/extension/dsh/workspace.d.ts +1 -9
- package/lib/extension/dsh/workspace.js +4 -29
- package/lib/extension/setup-cli.js +4 -4
- package/lib/integrations/dsh/resources.d.ts +1 -5
- package/lib/integrations/dsh/resources.js +2 -5
- package/lib/integrations/installation/processes.js +0 -15
- package/lib/ui/dsh/management.js +1 -9
- package/lib/ui/dsh/styles.d.ts +1 -1
- package/lib/ui/dsh/styles.js +2 -2
- package/lib/ui/presentation.js +1 -1
- package/package.json +1 -4
- package/resources/claude/skills/pbot/SKILL.md +2 -3
- package/resources/prompts/workspace.md +1 -1
- package/resources/references/compute.md +6 -8
- package/scripts/README.md +2 -6
- package/src/extension/acp-member.ts +1 -3
- package/src/extension/acp-worker.ts +3 -12
- package/src/extension/claude-hooks.ts +5 -25
- package/src/extension/command.ts +7 -16
- package/src/extension/dsh/acp-member.ts +1 -2
- package/src/extension/dsh/command.ts +2 -6
- package/src/extension/dsh/management.ts +3 -3
- package/src/extension/dsh/workspace.ts +5 -25
- package/src/extension/events.ts +2 -11
- package/src/extension/lifecycle.ts +8 -23
- package/src/extension/setup-cli.ts +4 -4
- package/src/extension/subagent-entry.ts +6 -12
- package/src/integrations/dsh/resources.ts +2 -5
- package/src/integrations/installation/processes.ts +0 -13
- package/src/integrations/pi/pi-agents.ts +12 -5
- package/src/pbot.ts +1 -2
- package/src/ui/dsh/management.ts +2 -8
- package/src/ui/dsh/styles.ts +2 -2
- package/src/ui/presentation.ts +1 -1
- package/lib/integrations/process.d.ts +0 -14
- package/lib/integrations/process.js +0 -48
- package/lib/integrations/python-activation.d.ts +0 -2
- package/lib/integrations/python-activation.js +0 -29
- package/lib/services/workspace/python-environment-service.d.ts +0 -21
- package/lib/services/workspace/python-environment-service.js +0 -66
- package/python/README.md +0 -72
- package/python/requirements.lock +0 -38
- package/scripts/setup-python.py +0 -170
- package/src/integrations/process.ts +0 -40
- package/src/integrations/python-activation.ts +0 -23
- package/src/services/workspace/python-environment-service.ts +0 -61
package/docs/model-context.md
CHANGED
|
@@ -23,7 +23,7 @@ Personal Bot 分别接入 Pi、dsh 和 Claude Code 原生主会话。Pi/dsh 也
|
|
|
23
23
|
|
|
24
24
|
## Pi
|
|
25
25
|
|
|
26
|
-
工作区通过 `.pbot/config.json` 显式启用后,主会话保留 Pi 原生系统提示、工具、AGENTS、技能目录和 cwd,再加入公共约定、协调者职责、Pi/dsh
|
|
26
|
+
工作区通过 `.pbot/config.json` 显式启用后,主会话保留 Pi 原生系统提示、工具、AGENTS、技能目录和 cwd,再加入公共约定、协调者职责、Pi/dsh 操作导航、工作区补充及工作区与资源路径。未启用时只保留状态和初始化入口,不创建 pbot 实例,不注册业务工具、提示词或包内技能。专家使用 general-purpose 职责;原生资料由专家 cwd 决定,pbot 职责补充从原工作区读取。
|
|
27
27
|
|
|
28
28
|
已启用的 Pi 主会话通过 `resources_discover` 提供包内技能路径,由原生加载器读取,遵守 CLI `--no-skills` 和包级过滤;专家使用自己的 noSkills 选项。技能与提示模板正文在读取或展开时加入。
|
|
29
29
|
|
|
@@ -49,29 +49,28 @@ Claude 自己加载原生系统提示、`CLAUDE.md`、用户规则、工具、
|
|
|
49
49
|
|
|
50
50
|
| 入口 | 加载行为 |
|
|
51
51
|
| --- | --- |
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
| SubagentStart | 仅对 `personal-bot:general-purpose` 加载公共约定、专家职责、工作区 `agents/general-purpose.md`、根资料与环境 |
|
|
52
|
+
| UserPromptSubmit | 已启用时读取公共约定、共有协调者职责、Claude 操作导航、工作区 `agents/coordinator.md`、根 `AGENTS.md` 及工作区与资源路径 |
|
|
53
|
+
| SubagentStart | 仅对 `personal-bot:general-purpose` 加载公共约定、专家职责、工作区 `agents/general-purpose.md`、根资料及工作区与资源路径 |
|
|
55
54
|
| PreToolUse / Skill、UserPromptExpansion | 检查模型调用和用户直接展开的 pbot 工作方法;未启用或配置无效时拦截并给出初始化入口,保留 `personal-bot:pbot` 初始化技能可用 |
|
|
56
55
|
|
|
57
56
|
`resources/claude/agents/general-purpose.md` 在构建时从共享职责生成,原生 Agent 负责启动与完成。SubagentStart 按确切 agent 类型补充工作区资料,不读取私有团队文件或父进程参数来推断身份。其他原生专家及团队沿用 Claude 自己的上下文规则。
|
|
58
57
|
|
|
59
58
|
根 `AGENTS.md` 通过 hook 提供,pbot 保留用户 `CLAUDE.md`。公共约定、职责与工作区补充在下一次相应 hook 执行时读取当前内容。插件不检查或解析私人 transcript。
|
|
60
59
|
|
|
61
|
-
原生 `/personal-bot:pbot init`、`status
|
|
60
|
+
原生 `/personal-bot:pbot init`、`status` 是技能请求,模型通过 Bash 调用 `node <plugin>/lib/claude.js` 的同名操作。需要确定性执行时可直接调用该 CLI。包内工作方法使用原生静态技能发现,未启用时仍可显示名称和简介。
|
|
62
61
|
|
|
63
|
-
Claude
|
|
62
|
+
Claude 环境提供 `workspaceRoot` 与 `resourceRoot`,脚本通过原生 Bash 按项目约定运行。Claude 会话、原生团队通信、完成通知与恢复由宿主管理;pbot 不采集或查询新的 Claude 历史,也不生成自动摘要。
|
|
64
63
|
|
|
65
64
|
## ACP 成员
|
|
66
65
|
|
|
67
|
-
Pi 和 dsh 的 ACP 成员使用专用入口加载公共约定、general-purpose
|
|
66
|
+
Pi 和 dsh 的 ACP 成员使用专用入口加载公共约定、general-purpose 职责、工作区补充及工作区与资源路径,并使用各自原生资源发现。入口不消费 pbot inbox,输入由 ACP worker 投递。Pi 的 before_agent_start 刷新 section;dsh 的 system-prompt/assemble 刷新原生 section。
|
|
68
67
|
|
|
69
|
-
Pi/dsh 委派的 Claude ACP 子代理通过协商后的 systemPrompt append
|
|
68
|
+
Pi/dsh 委派的 Claude ACP 子代理通过协商后的 systemPrompt append 加入同一公共约定、职责及工作区与资源路径。包内 `resources/skills/` 作为该子会话的原生本地插件注册,技能元数据进入 Claude 目录,正文按需读取;该插件清单只声明技能。原生 CLAUDE、用户与项目技能、工具由 Claude 自己加载。恢复时重新提供 pbot 内容和插件路径。ACP 成员只处理独立工作,不加入 pbot 团队上下文。
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
协议流中的 thought 和工具进度用于活动状态,Pi/dsh 的最终答复按原生完成边界提取,Claude 按消息 ID 和 prompt 完成边界定稿。
|
|
72
71
|
|
|
73
72
|
## 环境与历史
|
|
74
73
|
|
|
75
|
-
|
|
74
|
+
各宿主的 pbot 模型环境提供 `workspaceRoot` 与 `resourceRoot`,实际 cwd 由宿主提供。公共提示保留资料目录用途,计算方法按任务读取;解释器与依赖沿用项目约定。
|
|
76
75
|
|
|
77
76
|
Pi/dsh 历史摘要只接收 `resources/prompts/history-summary.md` 与当前问答或下层摘要,附带时段和未完成标记,不提供工具或普通会话上下文。长文本按预算分段汇总,完整原文保留;查询、面板和资源加载不触发摘要。
|
package/docs/release.md
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
|
|
18
18
|
Trusted Publisher 使用 GitHub OIDC,无需保存 NPM_TOKEN。首次包创建与授权条件见 [npm 官方说明](https://docs.npmjs.com/trusted-publishers/)。需要先创建包时,由维护者完成首次本机发布,再配置 Trusted Publisher。
|
|
19
19
|
|
|
20
|
-
provenance 所用 repository 元数据须与实际公开仓库匹配。若改为 scoped 包名,同步修改包与锁文件、工作流中的包名和 tarball
|
|
20
|
+
provenance 所用 repository 元数据须与实际公开仓库匹配。若改为 scoped 包名,同步修改包与锁文件、工作流中的包名和 tarball 名、安装说明。
|
|
21
21
|
|
|
22
22
|
## 准备候选包
|
|
23
23
|
|
|
24
|
-
使用 Linux
|
|
24
|
+
使用 Linux 和 Node.js 24.9+ 准备发布包并完成适用检查。Pi、独立 CLI 与 Claude Node hook/CLI 最低消费者检查使用 Node.js 22.19.0,Claude CLI 当前验证基线为 2.1.325。记录实际 OS、Node、Claude CLI 与 Pi/dsh 版本;运行 ACP 验证时另记目标及 SDK 版本。锁定开发依赖与实际运行结果分别记录。更新版本:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
npm version <新版本> --no-git-tag-version --ignore-scripts
|
|
@@ -40,11 +40,11 @@ npm pack
|
|
|
40
40
|
|
|
41
41
|
prepack 依次执行 check、build:cli、build:dsh、build:claude;CLI 构建清理 lib,因此保持该顺序。build:claude 用 tsc 编译 Node hook/CLI,从共享职责生成原生 agent,并同步根插件与 marketplace 的发布版本,发布前核对它们与 package.json 一致。
|
|
42
42
|
|
|
43
|
-
核对包清单包含 bin、lib(安装 CLI、dsh Host/Web、Claude Node 与 Pi/dsh ACP worker)、src、resources(含 dsh patch、Claude 原生 pbot 技能与 agent、ACP
|
|
43
|
+
核对包清单包含 bin、lib(安装 CLI、dsh Host/Web、Claude Node 与 Pi/dsh ACP worker)、src、resources(含 dsh patch、Claude 原生 pbot 技能与 agent、ACP 仅技能插件),以及隐藏的 .claude-plugin/plugin.json、marketplace.json 和 hooks/hooks.json。npm-shrinkwrap.json 仅保留在仓库用于开发和 CI;从发布包排除完整开发锁,避免 registry 安装展开开发宿主与构建依赖。另排除 dist、node_modules、凭据、原生测试会话与运行数据。核对 dsh 导出和元数据,以及 Claude command hooks 的 command/args、技能与 agent 路径;Claude 插件不发布 MCP 声明、mod 或类型快照。
|
|
44
44
|
|
|
45
45
|
依赖与产物规则见[技术设计](technical-design.md#工具与分发),安装包检查入口见[维护脚本](../scripts/README.md)。
|
|
46
46
|
|
|
47
|
-
使用隔离用户目录、宿主配置和临时工作区检查实际 tarball
|
|
47
|
+
使用隔离用户目录、宿主配置和临时工作区检查实际 tarball。Pi 检查扩展、技能、工具和初始化,dsh 检查 Host、Web 与 Remote。Claude consumer 脚本在独立 npm 目录实际安装 tarball 并执行原生 plugin validate,同时将包直接解压到另一个空目录,在没有 node_modules 的条件下执行 hooks、CLI 和启用工作区的资料读取,以覆盖原生 marketplace 缓存的运行方式。检查无需模型认证或宿主 SDK,不依赖仓库开发目录。
|
|
48
48
|
|
|
49
49
|
Claude 的实际首任务上下文、原生 pbot 与工作方法技能、`personal-bot:general-purpose` 专家仍需在明确批准的原生模型环境验证。使用专用认证、隔离配置和临时工作区;原生团队开关由运行者管理。默认 Node 测试及 plugin validate 的结果与模型验证分别报告,当前尚未完成原生模型验证。范围见[Claude 接入设计](claude-code-design.md)。
|
|
50
50
|
|
|
@@ -101,7 +101,7 @@ npm view personal-bot dist-tags --json --registry=https://registry.npmjs.org
|
|
|
101
101
|
|
|
102
102
|
按[dsh 使用说明](dsh.md),在独立 profile 安装公开 registry 的目标版本,核对 Host 启用、Web 管理页和 Remote 查询。
|
|
103
103
|
|
|
104
|
-
在独立 Claude 配置与临时工作区通过 `/plugin install personal-bot --marketplace realqiyan/personal-bot` 安装,核对原生 marketplace 实际解析的版本与发布包一致,再检查 Node CLI init/status 和原生资源发现。模型环境获批后验证 `/personal-bot:pbot
|
|
104
|
+
在独立 Claude 配置与临时工作区通过 `/plugin install personal-bot --marketplace realqiyan/personal-bot` 安装,核对原生 marketplace 实际解析的版本与发布包一致,再检查 Node CLI init/status 和原生资源发现。模型环境获批后验证 `/personal-bot:pbot`、工作方法技能、专家上下文及工作区与资源路径。升级保留用户环境、工作区资料、既有 Claude 归档与旧控制记录。
|
|
105
105
|
|
|
106
106
|
上传结果不明时先查询 registry。若上传完成但后续查询失败,手动运行 Publish npm,选择原版本 tag 并保持 verify_only=true。该模式重新执行检查与 registry 查询,不上传;目标版本已不是 latest 时会失败。不要直接重跑原上传作业,也不要移动已发布 tag。
|
|
107
107
|
|
package/docs/technical-design.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 技术设计
|
|
2
2
|
|
|
3
|
-
Personal Bot 提供按工作区加载的 Pi 扩展、原生 dsh Host/Web 接入及 Claude Code 标准插件。模型负责分析、协调和工具使用;Pi/dsh 提供专家协作与历史归档,Claude 通过标准 hooks
|
|
3
|
+
Personal Bot 提供按工作区加载的 Pi 扩展、原生 dsh Host/Web 接入及 Claude Code 标准插件。模型负责分析、协调和工具使用;Pi/dsh 提供专家协作与历史归档,Claude 通过标准 hooks、技能和原生专家复用资料与专业方法。安装与命令见[项目 README](../README.md)及 [Claude 使用指南](claude-code.md)。
|
|
4
4
|
|
|
5
5
|
## 模块与依赖
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ Claude command hooks / Node 命令
|
|
|
17
17
|
integrations
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
src/pbot.ts 装配 Pi,src/dsh.ts 装配 dsh Host,src/ui/dsh/index.ts 装配 Web 客户端。src/claude.ts 是 Claude 标准 command hook 与 Node 命令入口,src/extension/claude-hooks.ts
|
|
20
|
+
src/pbot.ts 装配 Pi,src/dsh.ts 装配 dsh Host,src/ui/dsh/index.ts 装配 Web 客户端。src/claude.ts 是 Claude 标准 command hook 与 Node 命令入口,src/extension/claude-hooks.ts 调用共用工作区服务。Claude 静态发现 Markdown 技能与专家,不装配 pbot 历史、ACP 或面板。各宿主共享资料与适用的业务服务。
|
|
21
21
|
|
|
22
22
|
src/extension/setup-cli.ts 装配独立 Pi 安装命令;`pbot setup` 通过原生 npm/Pi 准备工作区,再启动 Pi 执行 `/pbot init`。Claude 使用原生插件 marketplace。安装器顺序、来源保留与失败恢复由 services/installation 管理,详见[安装与升级](installation-design.md)。
|
|
23
23
|
|
|
@@ -26,21 +26,20 @@ src/extension/setup-cli.ts 装配独立 Pi 安装命令;`pbot setup` 通过原
|
|
|
26
26
|
| src/tools/ | 输入、输出、schema、执行适配和工具列表 |
|
|
27
27
|
| src/services/ | 业务规则、状态变更和操作顺序,按 agents、workspace、history、installation 聚合 |
|
|
28
28
|
| src/model/ | 业务数据类型与窄能力约定,不包含业务实现或宿主 SDK 类型 |
|
|
29
|
-
| src/integrations/ | Pi/dsh 原生会话、ACP
|
|
29
|
+
| src/integrations/ | Pi/dsh 原生会话、ACP 连接与进程 |
|
|
30
30
|
| src/storage/ | 原子 JSON、子会话、pbot 团队和历史文件 |
|
|
31
31
|
| src/extension/ | 命令、事件和资源生命周期 |
|
|
32
32
|
| src/ui/ | 确认队列、对话框和专家展示 |
|
|
33
33
|
| src/common/ | JSON、校验、文件、包路径和版本辅助逻辑 |
|
|
34
34
|
| resources/ | 角色、技能、提示词、模板和参考资料 |
|
|
35
35
|
|
|
36
|
-
服务不依赖宿主 SDK
|
|
36
|
+
服务不依赖宿主 SDK、工具、UI 或接入层实现,宿主能力通过窄接口传入。接入层可引用服务类型;命令和工具通过服务执行状态变更。模型层用 interface/type 描述普通数据和窄能力契约;数据以普通对象进入 JSON、存储和工具结果。
|
|
37
37
|
|
|
38
|
-
Claude command hook 是独立 Node 进程,只使用 Node
|
|
38
|
+
Claude command hook 是独立 Node 进程,只使用 Node 内置模块和共用工作区服务。通用断言保留在 common/validation,依赖 Ajv 的 JSON Schema 编译放在 common/schema,由 Pi/dsh 工具适配显式引用,避免资料和配置读取加载第三方模块。hook 的 stdout 输出标准 JSON,诊断写 stderr;不加载宿主 SDK、mod API 或内部 MCP。
|
|
39
39
|
|
|
40
40
|
| 主体 | 管理内容 |
|
|
41
41
|
| --- | --- |
|
|
42
42
|
| initializeWorkspace / prepareWorkspace | 初始化依次准备资料并写入共用启用配置;资料准备补建目录与根 AGENTS.md |
|
|
43
|
-
| PythonEnvironmentService | venv 准备、依赖检查、状态与取消等待 |
|
|
44
43
|
| AgentService / AgentRun / AcpAgentRun | 专家实例、启动预约、代次、inbox、领取/进入/消费/完成与交付资格;ACP prompt 收尾、固定报告与确认关联;拒绝向被团队占用的成员发送私人任务 |
|
|
45
44
|
| TeamService | Pi/dsh 的固定成员、公共消息、有限轮次、团队占用与暂停规则 |
|
|
46
45
|
| HistoryService | 三来源问答索引、四叉摘要、查询、来源写锁与精确输入提交核验 |
|
|
@@ -48,27 +47,27 @@ Claude command hook 是独立 Node 进程,只使用 Node 内置模块和共用
|
|
|
48
47
|
|
|
49
48
|
## Claude 标准插件入口
|
|
50
49
|
|
|
51
|
-
`hooks/hooks.json` 声明
|
|
50
|
+
`hooks/hooks.json` 声明 UserPromptSubmit、SubagentStart、PreToolUse/Skill 和 UserPromptExpansion 的 command handlers,使用独立 `command` 与 `args`,不经 shell 拼接路径。stdin 只消费公开事件字段,stdout 返回标准 hook JSON。固定根目录取 `CLAUDE_PROJECT_DIR`,普通 Node 命令无该变量时使用 cwd。
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
UserPromptSubmit 重读共用配置、公共约定、角色、根 AGENTS 与工作区职责补充,连同工作区和资源路径加入上下文;宿主提供子代理身份时使用专家职责。SubagentStart 只为插件的原生专家添加资料。未启用时不加入业务资料,PreToolUse/Skill 与 UserPromptExpansion 分别检查模型调用和用户直接展开的 pbot 方法,拦截时返回初始化入口,管理技能仍可调用。
|
|
54
53
|
|
|
55
|
-
`node <插件>/lib/claude.js init|status
|
|
54
|
+
`node <插件>/lib/claude.js init|status` 调用共用工作区服务;`/personal-bot:pbot` 是执行同一入口的原生技能,会调用模型。原生专家 Markdown 由共用职责生成。Claude 不读取内部 transcript、团队配置、启动参数或消息收据,不注册 pbot 模型工具或管理面板。
|
|
56
55
|
|
|
57
56
|
## 加载与关闭
|
|
58
57
|
|
|
59
58
|
宿主原生配置决定插件加载范围,工作区根目录下的 `.pbot/config.json` 决定业务实例是否启动。`services/workspace/workspace-config` 为三种宿主读取同一 JSON;缺失、false 或无效配置保持未启用,错误由状态入口报告,不向父目录继承。规则与修改生效方式见[工作区配置](workspace-configuration.md)。
|
|
60
59
|
|
|
61
|
-
Pi 的 session_start 读取启动目录配置,仅在 enabled 为 true
|
|
60
|
+
Pi 的 session_start 读取启动目录配置,仅在 enabled 为 true 时创建实例和注册工具。未启用时保留状态和初始化入口,不注册包内技能,也不注入 pbot 提示词;状态栏显示未启用或已启动。加载本身不开展模型任务。
|
|
62
61
|
|
|
63
62
|
Pi 的 `/pbot` 打开原生菜单,状态与长记录使用只读阅读页;dsh 使用独立工作台。见[界面设计](interaction-design.md)。
|
|
64
63
|
|
|
65
|
-
`/pbot init` 先准备资料,再将共用配置中的 enabled 设为 true,保留其他字段;无效配置在写入前报错。Pi 从未启用状态初始化后调用原生 ctx.reload,让实例、工具、技能和新建根 AGENTS 一起生效;已启动会话仅补建资料,新建 AGENTS 经 `/reload` 加载。`/pbot status`
|
|
64
|
+
`/pbot init` 先准备资料,再将共用配置中的 enabled 设为 true,保留其他字段;无效配置在写入前报错。Pi 从未启用状态初始化后调用原生 ctx.reload,让实例、工具、技能和新建根 AGENTS 一起生效;已启动会话仅补建资料,新建 AGENTS 经 `/reload` 加载。`/pbot status` 展示运行状态、路径和版本;模型环境提供 `workspaceRoot` 与 `resourceRoot`,实际 cwd 由宿主提供。
|
|
66
65
|
|
|
67
|
-
Pi 主 reload
|
|
66
|
+
Pi 主 reload 在配置仍启用时保留子进程并重新关联,但暂停团队,不继续安排旧批次;配置关闭或损坏时停止所属专家;退出或切换会话时清理子进程。关闭操作幂等。子会话的分支归属、通知和恢复规则见[专家协作](agent-collaboration.md)。
|
|
68
67
|
|
|
69
|
-
dsh 为原生 registry 中的每个根 Agent 读取其原始 cwd 下的配置,仅对已启用根目录建立协调者工作区。关闭的工作区保留只读状态和初始化入口,其余业务命令与 Remote 查询拒绝进入;init
|
|
68
|
+
dsh 为原生 registry 中的每个根 Agent 读取其原始 cwd 下的配置,仅对已启用根目录建立协调者工作区。关闭的工作区保留只读状态和初始化入口,其余业务命令与 Remote 查询拒绝进入;init 写入配置后重新打开同一根目录下尚未启用的主会话,按目录合并并发初始化。专家使用同进程独立 Agent/Session;组件或所属父 Agent 关闭时取消预约、暂停安排并等待自己拥有的执行资源释放。打开页面、轮询、重连不恢复专家或启动模型,已接纳工作不归浏览器生命周期所有。原生存在但由其他实例持有的专家不能替换或假称已释放。
|
|
70
69
|
|
|
71
|
-
Claude 在每次用户提交和适用 hook 中读取固定根目录的配置。hook
|
|
70
|
+
Claude 在每次用户提交和适用 hook 中读取固定根目录的配置。hook 没有常驻实例、租约、心跳或后台摘要;配置停用后不再加入业务资料。宿主关闭与原生会话恢复由 Claude 自己管理。实现边界见[Claude 接入](claude-code-design.md)。
|
|
72
71
|
|
|
73
72
|
## 资源加载
|
|
74
73
|
|
|
@@ -145,15 +144,11 @@ Pi/dsh 的 pbot 团队采用独立 team.json,不改动旧 AgentMessage、Agent
|
|
|
145
144
|
|
|
146
145
|
Web 拥有草稿、上传和查询;接纳后的命令归服务端。命令不重复记录私人输入正文,人工对话要求团队暂停成功后才进入 inbox。原生工具成功读取或上下文实际消费才确认通知;PTC 内层 read 还要求根调用成功,页面读取不确认。
|
|
147
146
|
|
|
148
|
-
##
|
|
147
|
+
## 计算方法
|
|
149
148
|
|
|
150
|
-
|
|
149
|
+
计算通过宿主原生 Bash 和第三方库 API 执行,使用项目声明的解释器、依赖、工作目录、输入和输出。Python 版本及库的选择由项目和任务决定。Pi、dsh、Claude 与 ACP worker 沿用其启动环境,不修改 Python 相关进程变量。
|
|
151
150
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Pi/dsh 在当前宿主进程激活 PATH、VIRTUAL_ENV 和 Python 路径变量,供随后启动的 Bash 继承;同一 dsh 进程内工作区共用激活生命周期。恢复只修改仍由本实例持有的变量。Claude hooks 检查共享环境并给出 `python.executable` 完整路径,由 Bash 显式使用,不修改父宿主环境。环境更新会影响其他工作区,更新前应停止相关脚本。
|
|
155
|
-
|
|
156
|
-
计算通过原生 Bash 和第三方库 API 执行,使用项目自身的目录、输入和输出约定。路径、安装条件与许可见 [Python 说明](../python/README.md)。
|
|
151
|
+
通用方法保留在 `resources/references/compute.md`,指标与回测方法保留在 `compute-finance.md`,按任务读取。它们说明库的使用方法与影响结果的计算口径;项目依赖由项目管理,不增加 pbot 计算工具或统一库包装。
|
|
157
152
|
|
|
158
153
|
## 工具与分发
|
|
159
154
|
|
|
@@ -19,10 +19,9 @@ Pi 首次启用时自动重载;已运行时补建的根 AGENTS 经 `/reload`
|
|
|
19
19
|
```sh
|
|
20
20
|
node /absolute/path/to/plugin/lib/claude.js init
|
|
21
21
|
node /absolute/path/to/plugin/lib/claude.js status
|
|
22
|
-
node /absolute/path/to/plugin/lib/claude.js python setup
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
Claude CLI 从 `CLAUDE_PROJECT_DIR` 读取固定工作区根;在普通 shell
|
|
24
|
+
Claude CLI 从 `CLAUDE_PROJECT_DIR` 读取固定工作区根;在普通 shell 中未提供该变量时使用当前目录。需要显式指定工作区时,将它设为目标工作区的绝对路径。状态显示工作区与配置信息;Claude 没有独立的 `/pbot` 原生命令或管理面板。操作见[Claude 使用指南](claude-code.md)。
|
|
26
25
|
|
|
27
26
|
## 启用与停用
|
|
28
27
|
|
|
@@ -36,11 +35,11 @@ Claude CLI 从 `CLAUDE_PROJECT_DIR` 读取固定工作区根;在普通 shell
|
|
|
36
35
|
|
|
37
36
|
| 配置情况 | 行为 |
|
|
38
37
|
| --- | --- |
|
|
39
|
-
| `enabled: true` | Pi/dsh 启动业务实例;Claude hooks
|
|
38
|
+
| `enabled: true` | Pi/dsh 启动业务实例;Claude hooks 加载上下文 |
|
|
40
39
|
| 文件不存在、缺少 enabled 或 `enabled: false` | 保持未启用,提供状态与初始化入口;宿主原生功能继续使用 |
|
|
41
40
|
| JSON 损坏、字段类型错误或文件不可读取 | 保持未启用,报告具体错误;修复文件后再执行 `init` |
|
|
42
41
|
|
|
43
|
-
Pi/dsh 未启用时不注册包内技能,也不注入 pbot 提示词。Claude 静态技能名称、简介与原生 agent 仍可被宿主发现;PreToolUse 对 Skill 拦截 pbot 工作方法,保留 `personal-bot:pbot`
|
|
42
|
+
Pi/dsh 未启用时不注册包内技能,也不注入 pbot 提示词。Claude 静态技能名称、简介与原生 agent 仍可被宿主发现;PreToolUse 对 Skill 拦截 pbot 工作方法,保留 `personal-bot:pbot` 初始化技能可用。公共约定与角色加载受配置控制。用户自己的指令、技能与其他插件沿用宿主加载规则;已经进入聊天的内容作为历史保留。
|
|
44
43
|
|
|
45
44
|
只读取绑定工作区根目录,不向父目录查找。例如在 `~/workspace/projects/example` 单独建立会话时,该目录需要自己的配置。修改 Bash cwd 不改变绑定根目录;Claude 使用 `CLAUDE_PROJECT_DIR` 固定此根。Pi/dsh 受管专家沿用所属工作区的启用决定,其执行目录可以不同。
|
|
46
45
|
|
|
@@ -71,11 +70,9 @@ Pi/dsh 主会话可委派 Pi、dsh 或 Claude ACP 成员。先按[ACP 专家程
|
|
|
71
70
|
| --- | --- |
|
|
72
71
|
| Pi | 执行原生 `/reload`,或重新启动 Pi |
|
|
73
72
|
| dsh | 重启对应服务或桌面宿主 |
|
|
74
|
-
| Claude | 后续
|
|
73
|
+
| Claude | 后续 UserPromptSubmit、SubagentStart、Skill 调用与技能展开检查及 CLI 操作读取当前配置 |
|
|
75
74
|
|
|
76
|
-
Pi/dsh 在重载前保持原配置。停用生效后撤下后续业务工具与职责,释放所属执行和历史整理,并暂停团队调度。Claude 停止后续 pbot
|
|
77
|
-
|
|
78
|
-
所有已启用工作区共用用户级 Python venv。Pi/dsh 激活所在进程环境,dsh 的激活由整个 Host 组件持有。Claude 通过 Bash 使用 `python.executable` 完整路径,不修改 Claude PATH 或环境变量,禁用或卸载无需恢复环境。路径与排障见 [Python 指南](../python/README.md)。
|
|
75
|
+
Pi/dsh 在重载前保持原配置。停用生效后撤下后续业务工具与职责,释放所属执行和历史整理,并暂停团队调度。Claude 停止后续 pbot 上下文注入与工作方法技能调用;原生会话和团队继续由 Claude 管理。资料、历史与备份保留。重新启用可使用各宿主的 init 入口。
|
|
79
76
|
|
|
80
77
|
## 安装与更新
|
|
81
78
|
|
package/hooks/hooks.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"hooks": {
|
|
3
|
-
"SessionStart": [
|
|
4
|
-
{ "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 900 }] }
|
|
5
|
-
],
|
|
6
3
|
"UserPromptSubmit": [
|
|
7
|
-
{ "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout":
|
|
4
|
+
{ "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 30 }] }
|
|
8
5
|
],
|
|
9
6
|
"SubagentStart": [
|
|
10
7
|
{ "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 30 }] }
|
package/lib/client.js
CHANGED
|
@@ -116,9 +116,6 @@ var states = {
|
|
|
116
116
|
failed: "\u5931\u8D25",
|
|
117
117
|
cancelled: "\u5DF2\u53D6\u6D88",
|
|
118
118
|
interrupted: "\u5DF2\u4E2D\u65AD",
|
|
119
|
-
ready: "\u5DF2\u5C31\u7EEA",
|
|
120
|
-
preparing: "\u51C6\u5907\u4E2D",
|
|
121
|
-
unprepared: "\u672A\u51C6\u5907",
|
|
122
119
|
open: "\u5F85\u5B89\u6392",
|
|
123
120
|
closed: "\u5DF2\u5173\u95ED"
|
|
124
121
|
};
|
|
@@ -271,9 +268,9 @@ var managementStyles = `
|
|
|
271
268
|
.pbot-card > :is(h3, .pbot-between) { margin-bottom: 12px; }
|
|
272
269
|
.pbot-badge { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; color: var(--pbot-muted); background: var(--pbot-bg); padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
|
|
273
270
|
.pbot-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
|
|
274
|
-
.pbot-badge:is([data-state=busy],[data-state=running],[data-state=starting]
|
|
271
|
+
.pbot-badge:is([data-state=busy],[data-state=running],[data-state=starting]) { color: var(--pbot-accent); background: var(--pbot-tint); }
|
|
275
272
|
.pbot-badge:is([data-state=error],[data-state=failed]) { color: var(--pbot-danger); }
|
|
276
|
-
.pbot-badge
|
|
273
|
+
.pbot-badge[data-state=completed] { color: var(--dsw-alias-state-success-primary, #26834b); }
|
|
277
274
|
.pbot-badge:is([data-state=paused],[data-state=stopping]) { color: var(--dsw-alias-state-warn-label, #9a6500); }
|
|
278
275
|
.pbot-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 18px; margin: 12px 0; font-size: 13px; }
|
|
279
276
|
.pbot-facts dt { color: var(--pbot-muted); }
|
|
@@ -491,10 +488,6 @@ function showManagement(ctx, parentSessionId) {
|
|
|
491
488
|
const initializeButton = button(materials, "\u51C6\u5907\u76EE\u5F55", async () => {
|
|
492
489
|
await command("init", void 0, "\u5DE5\u4F5C\u533A\u5DF2\u521D\u59CB\u5316\u5E76\u542F\u7528\u3002");
|
|
493
490
|
});
|
|
494
|
-
const pythonCard = group(status, "pbot-setting"), pythonInfo = group(pythonCard);
|
|
495
|
-
const pythonButton = button(pythonCard, "\u51C6\u5907 Python", async () => {
|
|
496
|
-
await command("python setup", void 0, "Python \u51C6\u5907\u5B8C\u6210\u3002");
|
|
497
|
-
});
|
|
498
491
|
const diagnostic = details(status, "\u73AF\u5883\u8BE6\u60C5"), statusBody = block("");
|
|
499
492
|
statusBody.classList.add("pbot-raw");
|
|
500
493
|
diagnostic.append(statusBody);
|
|
@@ -986,12 +979,10 @@ function showManagement(ctx, parentSessionId) {
|
|
|
986
979
|
facts([["\u72B6\u6001", configuration.error ? "\u914D\u7F6E\u9519\u8BEF" : "\u672A\u542F\u7528"], ["\u5DE5\u4F5C\u533A", snapshot.workspaceRoot], ["\u914D\u7F6E\u6587\u4EF6", configuration.path]]),
|
|
987
980
|
note(configuration.error ? "\u4FEE\u590D\u914D\u7F6E\u6587\u4EF6\u540E\u6267\u884C /pbot init\u3002" : "\u6267\u884C /pbot init\uFF0C\u6216\u70B9\u51FB\u4E0B\u65B9\u6309\u94AE\u521D\u59CB\u5316\u5E76\u542F\u7528\u3002")
|
|
988
981
|
);
|
|
989
|
-
pythonInfo.replaceChildren(note("\u542F\u7528\u5DE5\u4F5C\u533A\u540E\u81EA\u52A8\u51C6\u5907\u5171\u4EAB Python \u73AF\u5883\u3002"));
|
|
990
982
|
materials.hidden = false;
|
|
991
983
|
initializeButton.textContent = "\u521D\u59CB\u5316\u5E76\u542F\u7528";
|
|
992
984
|
enabled(initializeButton, !configuration.error);
|
|
993
985
|
for (const [id, control] of tabs) enabled(control, id === "status");
|
|
994
|
-
enabled(pythonButton, false);
|
|
995
986
|
activate("status");
|
|
996
987
|
statusBody.textContent = JSON.stringify(snapshot, null, 2);
|
|
997
988
|
if (configuration.error) inform(text(configuration.error), "error");
|
|
@@ -1001,7 +992,7 @@ function showManagement(ctx, parentSessionId) {
|
|
|
1001
992
|
materials.hidden = false;
|
|
1002
993
|
initializeButton.textContent = "\u51C6\u5907\u76EE\u5F55";
|
|
1003
994
|
enabled(initializeButton, true);
|
|
1004
|
-
const agents = rows(snapshot.agents), teams2 = rows(snapshot.teams),
|
|
995
|
+
const agents = rows(snapshot.agents), teams2 = rows(snapshot.teams), history2 = record(snapshot.history);
|
|
1005
996
|
tabCounts.get("experts").textContent = text(agents.length);
|
|
1006
997
|
tabCounts.get("teams").textContent = text(teams2.length);
|
|
1007
998
|
const active = agents.filter((agent) => ["starting", "busy", "stopping"].includes(text(agent.state))).length;
|
|
@@ -1015,9 +1006,6 @@ function showManagement(ctx, parentSessionId) {
|
|
|
1015
1006
|
["Provider", model2.provider || "\u2014"],
|
|
1016
1007
|
["\u5386\u53F2", history2.organizing ? "\u6574\u7406\u4E2D" : history2.pending === null ? "\u67E5\u8BE2\u65F6\u66F4\u65B0\u7D22\u5F15" : `${history2.pending} \u9879\u5F85\u6574\u7406`]
|
|
1017
1008
|
]));
|
|
1018
|
-
pythonInfo.replaceChildren(element("h3", "Python"), badge(python.state));
|
|
1019
|
-
if (python.error) pythonInfo.append(element("p", text(python.error), "pbot-warning"));
|
|
1020
|
-
enabled(pythonButton, python.state !== "preparing");
|
|
1021
1009
|
const { agents: _agents, teams: _teams, ...summary } = snapshot;
|
|
1022
1010
|
statusBody.textContent = JSON.stringify(summary, null, 2);
|
|
1023
1011
|
const pending = rows(snapshot.permissions), nextPermissionKey = pending.map((request) => text(request.agentId) + ":" + text(request.requestId)).join(",");
|
|
@@ -24,9 +24,7 @@ export async function acpMember() {
|
|
|
24
24
|
};
|
|
25
25
|
const context = async () => {
|
|
26
26
|
const [workspace, role] = await Promise.all([readFile(join(resourceRoot, "prompts/workspace.md"), "utf8"), agentText("general-purpose", d.workspace)]);
|
|
27
|
-
|
|
28
|
-
const python = state === "ready" && process.env.VIRTUAL_ENV ? { state, directory: process.env.VIRTUAL_ENV } : { state };
|
|
29
|
-
return { workspace, role, environment: JSON.stringify({ workspaceRoot: d.workspace, resourceRoot, python }) };
|
|
27
|
+
return { workspace, role, environment: JSON.stringify({ workspaceRoot: d.workspace, resourceRoot }) };
|
|
30
28
|
};
|
|
31
29
|
return { files, d, id, generation, check, context,
|
|
32
30
|
input() {
|
|
@@ -8,8 +8,6 @@ import { acpExecutable } from "../integrations/acp/launch.js";
|
|
|
8
8
|
import { claudeOptions } from "../integrations/acp/claude.js";
|
|
9
9
|
import { acpContent } from "../integrations/acp/input.js";
|
|
10
10
|
import { agentText } from "../integrations/agent-resources.js";
|
|
11
|
-
import { activatePython } from "../integrations/python-activation.js";
|
|
12
|
-
import { PythonEnvironmentService } from "../services/workspace/python-environment-service.js";
|
|
13
11
|
import { resourceRoot } from "../common/paths.js";
|
|
14
12
|
import { requireThat } from "../common/validation.js";
|
|
15
13
|
import { packageVersion, releaseLine } from "../common/version.js";
|
|
@@ -22,24 +20,14 @@ requireThat(files.directory(id) === directory, "ACP worker 目录不匹配。");
|
|
|
22
20
|
const d = files.read(id, "descriptor.json", descriptor), reference = files.read(id, "acp-session.json", acpReference);
|
|
23
21
|
requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP worker 身份或版本不匹配。");
|
|
24
22
|
const validating = args.includes("--validate"), lifetime = new AbortController();
|
|
25
|
-
let execution
|
|
26
|
-
const python = new PythonEnvironmentService(d.workspace);
|
|
23
|
+
let execution;
|
|
27
24
|
const stop = () => { void execution?.stop().catch(error => lifetime.abort(error)); if (!execution)
|
|
28
25
|
lifetime.abort(); };
|
|
29
26
|
process.on("SIGTERM", stop);
|
|
30
27
|
process.on("SIGINT", stop);
|
|
31
28
|
async function main() {
|
|
32
29
|
requireThat(files.read(id, "launch.json", launch).generation === generation, "ACP worker 启动代次已失效。");
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const prepared = await python.setup(lifetime.signal);
|
|
36
|
-
restorePython = activatePython(prepared.directory);
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
lifetime.signal.throwIfAborted();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const env = { ...process.env, PBOT_ACP_PYTHON_STATE: validating ? "unavailable" : python.status.state, PBOT_SUBAGENT_RUN_ID: id, PBOT_SUBAGENT_DIR: directory, PBOT_SUBAGENT_GENERATION: generation,
|
|
30
|
+
const env = { ...process.env, PBOT_SUBAGENT_RUN_ID: id, PBOT_SUBAGENT_DIR: directory, PBOT_SUBAGENT_GENERATION: generation,
|
|
43
31
|
...(validating ? { PBOT_ACP_VALIDATE: "1" } : {}) };
|
|
44
32
|
const command = { ...reference, args: [...reference.args] };
|
|
45
33
|
const packageRoot = resolve(resourceRoot, "..");
|
|
@@ -55,8 +43,7 @@ async function main() {
|
|
|
55
43
|
let prompt;
|
|
56
44
|
if (reference.backend === "claude") {
|
|
57
45
|
prompt = [await readFile(join(resourceRoot, "prompts/workspace.md"), "utf8"), await agentText("general-purpose", d.workspace),
|
|
58
|
-
JSON.stringify({ workspaceRoot: d.workspace, resourceRoot
|
|
59
|
-
? { state: "ready", directory: process.env.VIRTUAL_ENV } : { state: python.status.state } })].join("\n\n");
|
|
46
|
+
JSON.stringify({ workspaceRoot: d.workspace, resourceRoot })].join("\n\n");
|
|
60
47
|
}
|
|
61
48
|
const saveSelection = (selection) => {
|
|
62
49
|
if (validating)
|
|
@@ -147,12 +134,6 @@ catch (error) {
|
|
|
147
134
|
}
|
|
148
135
|
finally {
|
|
149
136
|
lifetime.abort();
|
|
150
|
-
try {
|
|
151
|
-
await python.close();
|
|
152
|
-
}
|
|
153
|
-
finally {
|
|
154
|
-
restorePython?.();
|
|
155
|
-
}
|
|
156
137
|
if (process.connected)
|
|
157
138
|
process.disconnect();
|
|
158
139
|
// Keep child processes in this worker's process group so forced release covers descendants.
|
|
@@ -4,12 +4,6 @@ export declare function claudeCommand(args: readonly string[], cwd: string): Pro
|
|
|
4
4
|
workspaceRoot: string;
|
|
5
5
|
resourceRoot: string;
|
|
6
6
|
configuration: import("../model/workspace-config.js").WorkspaceConfiguration;
|
|
7
|
-
python: {
|
|
8
|
-
executable?: string;
|
|
9
|
-
state: "unprepared" | "preparing" | "ready" | "error";
|
|
10
|
-
directory?: string;
|
|
11
|
-
error?: string;
|
|
12
|
-
};
|
|
13
7
|
}>;
|
|
14
8
|
/** Standard command hooks consume documented stdin fields; native sessions remain entirely host-owned. */
|
|
15
9
|
export declare function claudeHook(value: unknown): Promise<Record<string, unknown>>;
|
|
@@ -5,7 +5,6 @@ import { resourceRoot } from "../common/paths.js";
|
|
|
5
5
|
import { packageVersion } from "../common/version.js";
|
|
6
6
|
import { requireThat } from "../common/validation.js";
|
|
7
7
|
import { agentText } from "../integrations/agent-resources.js";
|
|
8
|
-
import { PythonEnvironmentService } from "../services/workspace/python-environment-service.js";
|
|
9
8
|
import { readWorkspaceConfig } from "../services/workspace/workspace-config.js";
|
|
10
9
|
import { initializeWorkspace } from "../services/workspace/workspace-preparation.js";
|
|
11
10
|
export async function claudeWorkspaceRoot(cwd, projectDirectory = process.env.CLAUDE_PROJECT_DIR) {
|
|
@@ -15,38 +14,17 @@ export async function claudeWorkspaceRoot(cwd, projectDirectory = process.env.CL
|
|
|
15
14
|
requireThat((await stat(root)).isDirectory(), "Claude 工作区需要目录。");
|
|
16
15
|
return root;
|
|
17
16
|
}
|
|
18
|
-
async function pythonStatus(root, prepare, force = false) {
|
|
19
|
-
const python = new PythonEnvironmentService(root);
|
|
20
|
-
try {
|
|
21
|
-
if (force)
|
|
22
|
-
await python.setup();
|
|
23
|
-
else {
|
|
24
|
-
const current = await python.inspect();
|
|
25
|
-
if (prepare && current.state === "unprepared")
|
|
26
|
-
await python.setup();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
catch { /* The service retains the preparation or inspection error for status. */ }
|
|
30
|
-
finally {
|
|
31
|
-
await python.close();
|
|
32
|
-
}
|
|
33
|
-
const status = python.status;
|
|
34
|
-
return { ...status, ...(status.state === "ready" ? { executable: join(status.directory, "bin/python") } : {}) };
|
|
35
|
-
}
|
|
36
17
|
function disabled(configuration) {
|
|
37
18
|
return configuration.error ?? "Personal Bot 未在此工作区启用。运行 /personal-bot:pbot init;配置文件:" + configuration.path;
|
|
38
19
|
}
|
|
39
20
|
export async function claudeCommand(args, cwd) {
|
|
40
21
|
const root = await claudeWorkspaceRoot(cwd);
|
|
41
22
|
const action = args.join(" ");
|
|
42
|
-
requireThat(["init", "status"
|
|
23
|
+
requireThat(["init", "status"].includes(action), "用法:node <插件目录>/lib/claude.js init|status");
|
|
43
24
|
if (action === "init")
|
|
44
25
|
await initializeWorkspace(root);
|
|
45
26
|
const configuration = await readWorkspaceConfig(root);
|
|
46
|
-
|
|
47
|
-
requireThat(configuration.enabled, disabled(configuration));
|
|
48
|
-
return { version: packageVersion, workspaceRoot: root, resourceRoot, configuration,
|
|
49
|
-
python: configuration.enabled ? await pythonStatus(root, action !== "status", action === "python setup") : { state: "unprepared" } };
|
|
27
|
+
return { version: packageVersion, workspaceRoot: root, resourceRoot, configuration };
|
|
50
28
|
}
|
|
51
29
|
/** Standard command hooks consume documented stdin fields; native sessions remain entirely host-owned. */
|
|
52
30
|
export async function claudeHook(value) {
|
|
@@ -54,7 +32,7 @@ export async function claudeHook(value) {
|
|
|
54
32
|
if (process.env.PBOT_SUBAGENT_RUN_ID)
|
|
55
33
|
return {};
|
|
56
34
|
const event = value.hook_event_name;
|
|
57
|
-
requireThat(["
|
|
35
|
+
requireThat(["UserPromptSubmit", "SubagentStart", "PreToolUse", "UserPromptExpansion"].includes(event), "Claude hook 事件未支持。");
|
|
58
36
|
const skillCheck = event === "PreToolUse" || event === "UserPromptExpansion";
|
|
59
37
|
if (skillCheck) {
|
|
60
38
|
const skill = event === "UserPromptExpansion"
|
|
@@ -79,9 +57,6 @@ export async function claudeHook(value) {
|
|
|
79
57
|
};
|
|
80
58
|
if (event === "SubagentStart" && value.agent_type !== "personal-bot:general-purpose")
|
|
81
59
|
return {};
|
|
82
|
-
const python = await pythonStatus(root, event === "SessionStart" || event === "UserPromptSubmit");
|
|
83
|
-
if (event === "SessionStart")
|
|
84
|
-
return python.state === "error" ? { systemMessage: python.error } : {};
|
|
85
60
|
const member = event === "SubagentStart" || typeof value.agent_id === "string";
|
|
86
61
|
const role = event === "SubagentStart" ? readFile(join(root, "agents/general-purpose.md"), "utf8").catch(error => {
|
|
87
62
|
if (error.code === "ENOENT")
|
|
@@ -97,8 +72,7 @@ export async function claudeHook(value) {
|
|
|
97
72
|
throw error;
|
|
98
73
|
}),
|
|
99
74
|
]);
|
|
100
|
-
return {
|
|
101
|
-
|
|
102
|
-
workspace, duties, agents, JSON.stringify({ workspaceRoot: root, resourceRoot, python }),
|
|
75
|
+
return { hookSpecificOutput: { hookEventName: event, additionalContext: [
|
|
76
|
+
workspace, duties, agents, JSON.stringify({ workspaceRoot: root, resourceRoot }),
|
|
103
77
|
].filter(Boolean).join("\n\n") } };
|
|
104
78
|
}
|
|
@@ -25,8 +25,7 @@ export async function apply(ctx) {
|
|
|
25
25
|
await agent.ctx.plugin({ name: "pbot-acp-expert", inject, apply: async (scope) => {
|
|
26
26
|
registerDshSkills(scope, agent);
|
|
27
27
|
dshExpertTools(scope, agent, member.d.options);
|
|
28
|
-
await dshResources(scope, agent, member.d.workspace, "general-purpose",
|
|
29
|
-
? { state: "ready", directory: process.env.VIRTUAL_ENV } : { state: process.env.PBOT_ACP_PYTHON_STATE ?? "unavailable" }, member.check);
|
|
28
|
+
await dshResources(scope, agent, member.d.workspace, "general-purpose", member.check);
|
|
30
29
|
registerDshFileEvents(scope, agent, member.d.workspace, true, member.check);
|
|
31
30
|
let input, answer = "";
|
|
32
31
|
scope.on("session/event", (session, event) => {
|
|
@@ -15,10 +15,10 @@ const validChat = schema(chatSchema);
|
|
|
15
15
|
const approvalSchema = Type.Object({ agentId: Type.String({ minLength: 1 }), requestId: Type.String({ minLength: 1 }),
|
|
16
16
|
optionId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]) }, { additionalProperties: false });
|
|
17
17
|
const validApproval = schema(approvalSchema);
|
|
18
|
-
const usage = '用法:/pbot status | init |
|
|
18
|
+
const usage = '用法:/pbot status | init | agent {"action":…} | chat {"agentId":…,"text":…} | team {"action":…} | post {"teamId":…,"text":…} | history {"action":…} | records {"agentId":…}';
|
|
19
19
|
export function registerDshCommand(ctx, workspaces, management) {
|
|
20
20
|
ctx.commands.register({ name: "pbot", description: "Personal Bot 工作区与协作管理", recordInput: false,
|
|
21
|
-
input: { hint: "status | init |
|
|
21
|
+
input: { hint: "status | init | agent/chat/team/post/history/records JSON", attachments: true },
|
|
22
22
|
async handler({ agent, rawInput, signal, attachments, commandId }) {
|
|
23
23
|
signal.throwIfAborted();
|
|
24
24
|
const command = rawInput.trim(), split = command.search(/\s/);
|
|
@@ -38,11 +38,6 @@ export function registerDshCommand(ctx, workspaces, management) {
|
|
|
38
38
|
signal.throwIfAborted();
|
|
39
39
|
const verb = split < 0 ? command : command.slice(0, split);
|
|
40
40
|
requireThat(verb === "chat" || !attachments.length, "输入框附件仅用于 chat 人工对话。");
|
|
41
|
-
if (command === "python setup") {
|
|
42
|
-
const result = await workspaces.preparePython();
|
|
43
|
-
workspace.check();
|
|
44
|
-
return { kind: "success", text: JSON.stringify(result, null, 2) };
|
|
45
|
-
}
|
|
46
41
|
requireThat(split >= 0, usage);
|
|
47
42
|
const input = JSON.parse(command.slice(split));
|
|
48
43
|
requireThat(object(input), "命令参数必须是 JSON 对象。");
|
|
@@ -3,7 +3,7 @@ import type { Context } from "@deepseek-ai/cordis";
|
|
|
3
3
|
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
4
4
|
import { type Json } from "../../common/json.js";
|
|
5
5
|
import type { DshWorkspaces, DshWorkspace } from "./workspace.js";
|
|
6
|
-
export declare function dshStatus(
|
|
6
|
+
export declare function dshStatus(workspace: DshWorkspace): Json;
|
|
7
7
|
/** Status remains available when this workspace has not opted in. */
|
|
8
8
|
export declare function dshWorkspaceStatus(workspaces: DshWorkspaces, agent: Agent): Promise<Json>;
|
|
9
9
|
/** Native Remote owns transport and access checks. These workspace reads do not admit or cancel execution. */
|
|
@@ -104,11 +104,11 @@ const teamSchema = Type.Object({ teamId: Type.String({ minLength: 1 }), afterSeq
|
|
|
104
104
|
seq: Type.Optional(Type.Integer({ minimum: 1 })), offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
105
105
|
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 16000 })) }, { additionalProperties: false });
|
|
106
106
|
const validRequest = schema(requestSchema), validExpert = schema(expertSchema), validTeam = schema(teamSchema);
|
|
107
|
-
export function dshStatus(
|
|
107
|
+
export function dshStatus(workspace) {
|
|
108
108
|
workspace.check();
|
|
109
109
|
const agents = workspace.agents.list(workspace.owner);
|
|
110
110
|
return json({ host: "dsh", release: packageVersion, enabled: true, state: "running", workspaceRoot: workspace.root, sessionId: workspace.agent.id,
|
|
111
|
-
model: workspace.agent.model.current() ?? null,
|
|
111
|
+
model: workspace.agent.model.current() ?? null,
|
|
112
112
|
controlError: workspace.controlError ?? null, history: workspace.history.status,
|
|
113
113
|
agents, permissions: workspace.agents.pendingPermissions(workspace.owner), teams: workspace.teams.list(workspace.owner, agents) });
|
|
114
114
|
}
|
|
@@ -119,7 +119,7 @@ export async function dshWorkspaceStatus(workspaces, agent) {
|
|
|
119
119
|
return json({ host: "dsh", release: packageVersion, enabled: false,
|
|
120
120
|
state: configuration.error ? "error" : "disabled", nextStep: configuration.error ? configuration.error : "/pbot init",
|
|
121
121
|
workspaceRoot: root, sessionId: agent.id, configuration, model: agent.model.current() ?? null, agents: [], teams: [] });
|
|
122
|
-
return json({ ...dshStatus(
|
|
122
|
+
return json({ ...dshStatus(await workspaces.get(agent)), configuration });
|
|
123
123
|
}
|
|
124
124
|
/** Native Remote owns transport and access checks. These workspace reads do not admit or cancel execution. */
|
|
125
125
|
let PbotManagement = (() => {
|
|
@@ -9,7 +9,6 @@ import { TeamService } from "../../services/agents/team-service.js";
|
|
|
9
9
|
import { DshAgentRuntime } from "./agent-runtime.js";
|
|
10
10
|
import { DshHistoryWork } from "./history.js";
|
|
11
11
|
import type { HistoryService } from "../../services/history/history-service.js";
|
|
12
|
-
import { PythonEnvironmentService } from "../../services/workspace/python-environment-service.js";
|
|
13
12
|
import type { WorkspaceConfiguration } from "../../model/workspace-config.js";
|
|
14
13
|
export declare const dshDependencies: string[];
|
|
15
14
|
export declare class DshWorkspace {
|
|
@@ -17,7 +16,6 @@ export declare class DshWorkspace {
|
|
|
17
16
|
readonly ctx: Context;
|
|
18
17
|
readonly root: string;
|
|
19
18
|
readonly agent: Agent;
|
|
20
|
-
readonly python: PythonEnvironmentService;
|
|
21
19
|
readonly component: AbortSignal;
|
|
22
20
|
private readonly historyWork;
|
|
23
21
|
private readonly releaseHistory;
|
|
@@ -27,7 +25,7 @@ export declare class DshWorkspace {
|
|
|
27
25
|
readonly teams: TeamService;
|
|
28
26
|
readonly history: HistoryService;
|
|
29
27
|
readonly owner: AgentOwner;
|
|
30
|
-
constructor(ctx: Context, root: string, agent: Agent,
|
|
28
|
+
constructor(ctx: Context, root: string, agent: Agent, component: AbortSignal, historyWork: DshHistoryWork, releaseHistory: () => Promise<void>, acp?: AcpCommands);
|
|
31
29
|
check: () => void;
|
|
32
30
|
get controlError(): string | undefined;
|
|
33
31
|
open(): Promise<void>;
|
|
@@ -66,11 +64,9 @@ export declare class DshWorkspace {
|
|
|
66
64
|
expert(id: string): DshAgentRuntime;
|
|
67
65
|
close(): Promise<void>;
|
|
68
66
|
}
|
|
69
|
-
/** The execution component owns Python; closing one Session must not undo its activation. */
|
|
70
67
|
export declare class DshWorkspaces {
|
|
71
68
|
#private;
|
|
72
69
|
readonly ctx: Context;
|
|
73
|
-
readonly python: PythonEnvironmentService;
|
|
74
70
|
constructor(ctx: Context);
|
|
75
71
|
private history;
|
|
76
72
|
open(agent: Agent): Promise<DshWorkspace | undefined>;
|
|
@@ -80,9 +76,5 @@ export declare class DshWorkspaces {
|
|
|
80
76
|
configuration: WorkspaceConfiguration;
|
|
81
77
|
}>;
|
|
82
78
|
initialize(agent: Agent): Promise<DshWorkspace>;
|
|
83
|
-
preparePython(): Promise<{
|
|
84
|
-
directory: string;
|
|
85
|
-
python: string;
|
|
86
|
-
}>;
|
|
87
79
|
close(): Promise<void>;
|
|
88
80
|
}
|