diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..956508c --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,66 @@ +# 安装(本 fork,中文速查) + +把本仓库作为 DSH 插件栈装上手的完整步骤。英文版见 [docs/006-deployment.md](docs/006-deployment.md)(Install / Machine configuration / Start and stop)。 + +## 前置条件 + +- Node `^22.19.0 || >=24.0.0`(`package.json` engines)与 pnpm。 +- dsh CLI:`npm install -g @deepseek-ai/dsh`,版本需满足 `package.json` 的 `engines.dsh`(`^0.2.1-alpha.2`)。 +- git:Windows 上用 Git for Windows(实测 2.39 正常);MSYS/ucrt64 自带的 git 2.56 与 Gitea 的 http/2 智能协议交互挂起(clone 卡死),不要用。 + +## 安装主插件 + +```sh +git clone <本仓库> dsh-superagent && cd dsh-superagent +pnpm install && pnpm build +dsh superagent --from-default-profile web --dump-config > /dev/null # 仅首次建 profile;profile 已存在会连旧配置一起清掉! +dsh plugin --profile superagent add "link:$PWD" +``` + +Windows 上把 `$PWD` 换成本目录绝对路径(如 `"link:D:/Code/AI/dsh-superagent"`);`dsh` 即 PATH 里的 `dsh.cmd`。 + +## 机器配置 + +把 [examples/profile.cordis.patch.yml](examples/profile.cordis.patch.yml) 的内容写入 `~/.dsh/profiles/superagent/cordis.patch.yml`: + +- `webserver.port`:面板端口。 +- `stateDir`:必填,数据库/工单目录/命令 shim 都在这下面。Windows 支持盘符路径,YAML 用单引号包单反斜杠:`stateDir: 'C:\Users\me\.dsh\state\superagent'`。 +- 用 Gitea:取消 `dsh-superagent-gitea` 段的注释(`disabled: false`);用 GitHub 则不动。 + +## Gitea 侧准备 + +1. 给机器人建一个专用账号,加为目标仓库的协作者(write 即可;建 PR 需要)或 admin。 +2. 生成**细粒度访问令牌**:scope 按最小需要,本 fork 实跑用的组合是 `write:issue` + `write:notification` + `read:user` + `write:repository`。注意:Gitea 1.25 的部分实例 token 校验有问题(读 200 写 401),那种情况下可先用「登录名:密码」Basic(本 fork 支持);**1.26 起写路由一律拒绝密码 Basic**,必须 token。 +3. 启动服务前导出令牌环境变量:变量名与 Source 设置里 `tokenEnv` 填的一致(如 `GITEA_TOKEN`)。同一个 token 也用作 git push 的密码,两处一体。 +4. 启动后在面板 Sources → Gitea 填:`url`(实例直连地址;反代可能吞 Authorization 导致 401)、`repository`(owner/name)、`tokenEnv`;把不再用的 GitHub Source 置 `enabled: false`;在 policy 里把你自己加入 allowlist(填 Gitea 登录名)。 + +## 模型来源(必装其一) + +bundle 不自带 LLM。装一个 provider 插件并配好,例如 OpenAI 兼容端点: + +```sh +dsh plugin --profile superagent add dsh-llm-pi-ai +``` + +在 profile 的 `cordis.patch.yml` 里给 `dsh-llm-pi-ai` 配 providers(baseUrl/model/上下文长度,API key 用 `apiKeyEnv` 指到环境变量),然后在面板 Settings → 研判/执行 里选角色模型;顶栏也可以一键切部署默认模型(含思考强度)。 + +## 可选配套(本部署同款) + +```sh +dsh plugin --profile superagent add dsh-pocket # 远程访问面板(PIN 登录,Tailscale 内网可用) +dsh plugin --profile superagent add dsh-ws-deflate # WebSocket 压缩 +dsh plugin --profile superagent add dsh-session-keepwarm # 会话保温 +``` + +服务常驻(开机自启、崩溃拉起)请自行用系统机制托管 `dsh --profile superagent --no-open`;本机用的是 Windows 计划任务每分钟健康检查,属部署侧策略,不随仓库分发。 + +## 启动与验证 + +```sh +dsh --profile superagent --no-open +curl -H "x-orchestrator-request: 1" http://127.0.0.1:/orchestrator/api/overview +``` + +`problems` 为空、`liveness.polling` 为 true 即就绪。到已监听仓库的 Issue 里 `@机器人 <需求>`,面板出现 Trigger → 工单 → Worker 干活 → 回写评论即全链路通。 + +卸载:`dsh plugin --profile superagent remove dsh-superagent`(配置与会话数据留在 stateDir,自行清理)。 diff --git a/README.md b/README.md index 4651b9f..9d88e41 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Setup has many steps, so an agent does it with you. Ask your coding agent: It asks one short question at a time, shows the full plan once, and then installs and configures everything. [SETUP.md](SETUP.md) is what it follows. +For this fork there is also a hands-on Chinese quickstart covering plugin installation, the Gitea Source and model providers: [INSTALL.md](INSTALL.md). The English reference remains [docs/006-deployment.md](docs/006-deployment.md). + ## Documentation Read the numbered documents in order; each builds only on the ones before it. @@ -41,3 +43,20 @@ Read the numbered documents in order; each builds only on the ones before it. ## 本 fork 的改动 本仓库是上游 dsh-superagent 研究原型的 fork:新增 Gitea Source(自建 Gitea,纯轮询拉取,无 webhook、无需公网回调)、Windows 全面移植修复,以及默认模型头部快切、Source 活性上报、工单目录回收等部署运维改进。逐提交的动机与改动位置、部署实战要点和已知限制见 [CHANGES.md](CHANGES.md)。 + +## 安装本 fork 插件栈(速览) + +人话版安装步骤;英文版见 [docs/006-deployment.md](docs/006-deployment.md) 的 Install / Machine configuration。前提是已能使用 `dsh` CLI(没有就先 `npm install -g @deepseek-ai/dsh`,版本需满足 `package.json` 的 `engines.dsh`)。 + +```sh +git clone <本仓库> dsh-superagent && cd dsh-superagent +pnpm install && pnpm build +dsh superagent --from-default-profile web --dump-config > /dev/null # 仅首次:新建 profile,已存在会清掉它! +dsh plugin --profile superagent add "link:$PWD" +``` + +然后配置并启动: + +1. 按 [examples/profile.cordis.patch.yml](examples/profile.cordis.patch.yml) 写 `~/.dsh/profiles/superagent/cordis.patch.yml`(`webserver.port`、`stateDir` 必填;Windows 上 stateDir 支持盘符路径,YAML 里用单引号包反斜杠路径)。 +2. 用 Gitea 的话:取消示例中 `dsh-superagent-gitea` 的注释(`disabled: false`),启动后在面板 Sources 里填 `url`(直连实例地址,别走反代——反代可能吞 Authorization)、`repository`(owner/name)、`tokenEnv`(填环境变量名),并在启动环境里导出该变量=**细粒度访问令牌**(scope 例:`write:issue`、`write:notification`、`read:user`、`write:repository`;Gitea 1.26 起 API 写路由拒绝密码 Basic,见 CHANGES.md)。同时把不再使用的 GitHub Source 置 `enabled: false`。 +3. `dsh --profile superagent --no-open` 启动,打开 `http://127.0.0.1:/orchestrator/` 面板;让某人进 allowlist(Gitea 登录名),在 Issue 里 `@机器人` 提需求即开工。 diff --git a/docs/006-deployment.md b/docs/006-deployment.md index 456a472..dcf4a1d 100644 --- a/docs/006-deployment.md +++ b/docs/006-deployment.md @@ -88,7 +88,7 @@ Run the profile-creation command only for a new installation. If the profile alr ## Machine configuration -Copy [examples/profile.cordis.patch.yml](../examples/profile.cordis.patch.yml) to `~/.dsh/profiles/superagent/cordis.patch.yml`, replacing that file, and replace every ``. For Feishu, also enable the `dsh-superagent-feishu` entry there. The `webserver` entry sets the panel's port. +Copy [examples/profile.cordis.patch.yml](../examples/profile.cordis.patch.yml) to `~/.dsh/profiles/superagent/cordis.patch.yml`, replacing that file, and replace every ``. For Feishu or the Gitea Source of this fork, also enable the `dsh-superagent-feishu` / `dsh-superagent-gitea` entry there. The `webserver` entry sets the panel's port. | Key | Required | Meaning | | --- | --- | --- | diff --git a/examples/profile.cordis.patch.yml b/examples/profile.cordis.patch.yml index 74f0859..91cae31 100644 --- a/examples/profile.cordis.patch.yml +++ b/examples/profile.cordis.patch.yml @@ -10,3 +10,8 @@ # Feishu is optional: uncomment to enable its Source, then set the bot's lark-cli on the Feishu Source. # - id: dsh-superagent-feishu # disabled: false +# Gitea is optional (this fork): uncomment to enable its Source, then set url / repository / tokenEnv +# on the Gitea Source settings page. tokenEnv names an environment variable holding a fine-grained +# access token (Gitea 1.26+ rejects password Basic on API write routes; see CHANGES.md). +# - id: dsh-superagent-gitea +# disabled: false