dsh-lark-bot 0.6.0 → 0.7.0

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 CHANGED
@@ -28,107 +28,53 @@
28
28
 
29
29
  ## 快速开始 | Quick Start(普通用户先看这里 | for end users)
30
30
 
31
- ### 1. 安装 | Install
31
+ ### 1. 安装(唯一路径)| Install (the only path)
32
32
 
33
- 两个包名内容完全一致,任选一个即可:
33
+ 本项目以 **dsh 标准 profile bundle** 交付:一行命令把它装进一个 dsh profile,dsh 启动时以
34
+ 标准插件方式加载桥接引擎(`dsh.bundle.patch` 已声明,`dsh plugin add` 可直接安装)。
34
35
 
35
- Both package names ship identical content pick either one:
36
+ This project ships as a **standard dsh profile bundle**: one command installs it into a dsh
37
+ profile, and dsh loads the bridge engine as a standard plugin on boot (the package declares
38
+ `dsh.bundle.patch`, so `dsh plugin add` works directly).
36
39
 
37
40
  ```bash
38
- # 推荐 | Recommended
39
- npm install -g dsh-lark-bot
40
-
41
- # 或飞书命名版本 | or the Feishu-named edition
42
- npm install -g dsh-feishu-bot
41
+ # 唯一安装命令(无需先全局安装任何东西)| the only install command (no prior global install)
42
+ npx dsh-lark-bot@latest setup --profile dsh-lark
43
43
  ```
44
44
 
45
- 安装完成后,对应命令分别为 `dsh-lark-bot` `dsh-feishu-bot`。
46
-
47
- After installation, the commands are `dsh-lark-bot` and `dsh-feishu-bot` respectively.
45
+ `setup` 会自动完成:发现本机 dsh → 预批准 pnpm 构建策略 → 执行标准的
46
+ `dsh plugin --profile dsh-lark add dsh-lark-bot`。
48
47
 
49
- 也可以作为 **dsh 标准 profile bundle** 安装到任意 dsh profile(`dsh.bundle.patch` 已声明):
48
+ `setup` automatically: locates your dsh install pre-approves pnpm's build policy → runs the
49
+ standard `dsh plugin --profile dsh-lark add dsh-lark-bot`.
50
50
 
51
- It is also installable as a **standard dsh profile bundle** (the package declares
52
- `dsh.bundle.patch`):
51
+ ### 2. 启动并扫码绑定 | Start and bind with one scan
53
52
 
54
53
  ```bash
55
- dsh plugin --profile <name> add dsh-lark-bot
54
+ dsh --profile dsh-lark
56
55
  ```
57
56
 
58
- 安装后 profile 启动时会装配 `dsh-lark-bot/plugin`(在 `ctx.larkBridge` 暴露 bridge 后台服务的
59
- status / start / restart / stop,不阻塞 profile 启动;`DSH_LARK_AUTOSTART=1` 可在 profile
60
- 启动时自动拉起 bridge)。SDK / ACP runtime 还会自动装配 `lark_notify` 工具(见下文)。
61
-
62
- The profile then mounts `dsh-lark-bot/plugin` on boot — it exposes `ctx.larkBridge`
63
- (status / start / restart / stop of the standalone bridge service) without blocking boot; set
64
- `DSH_LARK_AUTOSTART=1` to start the bridge when the profile boots. The SDK / ACP runtimes also
65
- auto-mount the `lark_notify` tool (see below).
57
+ 首次启动会在终端打印二维码:用飞书 / Lark App 扫码创建或选择 PersonalAgent 应用,绑定后
58
+ dsh-lark-bot 的桥接引擎即在 dsh 进程内运行(飞书通道、会话/工作区、卡片、通知回调),
59
+ 私聊直接发消息,群聊 / 话题里 `@bot`。常驻与守护由 dsh 自己负责。
66
60
 
67
- > pnpm 10 默认拒绝依赖构建脚本:若 `dsh plugin add` `ERR_PNPM_IGNORED_BUILDS`
68
- > (protobufjs 等),按官方指引在 profile 目录的 `pnpm-workspace.yaml`
69
- > `allowBuilds:\n protobufjs: true` 后重试(与官方 `dsh-lark-channel` 相同的处理方式)。
61
+ On first boot the terminal prints a QR code: scan it with the Feishu / Lark app to create or
62
+ choose a PersonalAgent app. After binding, the bridge engine runs **inside the dsh process**
63
+ (Feishu channel, sessions/workspaces, cards, notify callback); message it directly in private
64
+ chat, or use `@bot` in groups/topics. dsh owns the daemon lifecycle.
70
65
 
71
- > pnpm 10 blocks dependency build scripts by default: if `dsh plugin add` reports
72
- > `ERR_PNPM_IGNORED_BUILDS` (e.g. protobufjs), add `allowBuilds:\n protobufjs: true` to the
73
- > profile's `pnpm-workspace.yaml` and retry — the same handling as the official
74
- > `dsh-lark-channel`.
75
-
76
- ### 2. 启动后台服务并绑定飞书 | Start the background service and bind Feishu
77
-
78
- ```bash
79
- dsh-lark-bot start
80
- ```
66
+ 已有 PersonalAgent 应用时可在 profile 环境变量中直接提供凭据跳过扫码(见「配置」):
81
67
 
82
- 或: | or:
68
+ With an existing PersonalAgent app, provide credentials via profile env to skip the QR step
69
+ (see Configuration):
83
70
 
84
71
  ```bash
85
- dsh-feishu-bot start
72
+ DSH_LARK_APP_ID=cli_xxx DSH_LARK_APP_SECRET=<secret> DSH_LARK_TENANT=feishu \
73
+ dsh --profile dsh-lark
86
74
  ```
87
75
 
88
- `start` 会自动在本机安装一个**后台服务**:加入系统开机自启列表,并在进程退出、崩溃或出错时自动重启。首次启动会:
89
-
90
- `start` automatically installs a **background service** locally: it joins the OS autostart
91
- list and restarts automatically whenever the process exits, crashes or errors. On first launch:
92
-
93
- 1. 在终端显示二维码。
94
- 2. 用飞书 / Lark App 扫码。
95
- 3. 选择或创建 PersonalAgent 应用。
96
- 4. 绑定成功后,bot 会向你的私聊发送欢迎卡片。
97
- 5. 私聊直接发消息;群聊或话题里 `@bot`。
98
-
99
- 1. A QR code is shown in the terminal.
100
- 2. Scan it with the Feishu / Lark app.
101
- 3. Choose or create a PersonalAgent app.
102
- 4. Once bound, the bot sends a welcome card to your private chat.
103
- 5. Message it directly in private chat; use `@bot` in group chats or topics.
104
-
105
- 绑定完成后 bot 转入后台运行,终端可以随时关闭。
106
-
107
- After binding, the bot runs in the background; you can close the terminal anytime.
108
-
109
- 如果你已经有 PersonalAgent 应用,也可以跳过扫码:
110
-
111
- If you already have a PersonalAgent app, you can skip the QR step:
112
-
113
- ```bash
114
- dsh-lark-bot start \
115
- --app-id cli_xxx \
116
- --app-secret <secret> \
117
- --tenant feishu
118
- ```
119
-
120
- ### 3. 服务管理命令 | Service management commands
121
-
122
- | 命令 Command | 作用 Description |
123
- | :--- | :--- |
124
- | `dsh-lark-bot start` | 安装后台服务、加入开机自启并启动(首次运行会先扫码绑定)<br>Install the background service, enable autostart and start it (first run prompts QR binding) |
125
- | `dsh-lark-bot status` | 查看服务状态(退出码 0=运行中,1=未运行)<br>Show service status (exit code 0=running, 1=not running) |
126
- | `dsh-lark-bot restart` | 重启后台服务(保留开机自启)<br>Restart the background service (keeps autostart) |
127
- | `dsh-lark-bot stop` | 停止后台服务并移出开机自启<br>Stop the background service and remove autostart |
128
-
129
- 后台服务的运行日志写入 `~/.dsh-lark/profiles/<profile>/logs/bot.log`。
130
-
131
- Background service logs are written to `~/.dsh-lark/profiles/<profile>/logs/bot.log`.
76
+ > 卸载:`dsh plugin --profile dsh-lark remove dsh-lark-bot`。
77
+ > Uninstall: `dsh plugin --profile dsh-lark remove dsh-lark-bot`.
132
78
 
133
79
  ### 4. 基本使用 | Basic usage
134
80
 
@@ -268,11 +214,14 @@ logs and troubleshooting.
268
214
 
269
215
  ## 目标 | Goals
270
216
 
271
- - **一条命令启动**:clone 后一键安装运行,已发布到 npm,`npm i -g dsh-lark-bot && dsh-lark-bot start` 即可拉起后台服务。
217
+ - **一条命令安装部署**:`npx dsh-lark-bot@latest setup --profile dsh-lark` 装进 dsh profile,
218
+ 随后 `dsh --profile dsh-lark` 启动并扫码,桥接引擎作为标准插件在 dsh 进程内运行。
272
219
  - **飞书原生体验**:流式卡片、交互按钮、图片 / 文件,全程双语(文档评论为规划中能力)。
273
220
  - **完整工作区管理**:多项目隔离、git worktree、项目级规则注入、上下文持久化。
274
221
 
275
- - **One-command start**: clone and run in one step, published to npm — `npm i -g dsh-lark-bot && dsh-lark-bot start`.
222
+ - **One-command install & deploy**: `npx dsh-lark-bot@latest setup --profile dsh-lark`, then
223
+ `dsh --profile dsh-lark` and scan once — the bridge engine runs as a standard plugin inside
224
+ the dsh process.
276
225
  - **Native Feishu experience**: streaming cards, interactive buttons, images / files, doc comments.
277
226
  - **Full workspace management**: multi-project isolation, git worktrees, per-project rules, persistent context.
278
227
 
@@ -420,11 +369,11 @@ Common issues:
420
369
  is reachable; with an existing App ID/Secret you can skip scanning via `--app-id` /
421
370
  `--app-secret`.
422
371
 
423
- 以后台服务方式运行时,日志写入 `~/.dsh-lark/profiles/<profile>/logs/bot.log`(JSON Lines
424
- stdout 与 stderr 合并);当前进程的 stderr 仍为 JSON Lines。
372
+ 桥接引擎日志写入 `~/.dsh-lark/profiles/<profile>/logs/bot.log`(JSON Lines);dsh 宿主日志走
373
+ dsh 自己的日志体系。
425
374
 
426
- When running as a background service, logs go to `~/.dsh-lark/profiles/<profile>/logs/bot.log`
427
- (JSON Lines, stdout and stderr merged); the current process's stderr is still JSON Lines.
375
+ The bridge engine logs to `~/.dsh-lark/profiles/<profile>/logs/bot.log` (JSON Lines); the dsh
376
+ host uses its own logging.
428
377
 
429
378
  ## 开发 | Development
430
379
 
@@ -527,12 +476,11 @@ The core idea: **decouple the Feishu channel from the agent backend**. The bridg
527
476
  | `src/card/` | 流式卡片状态与渲染<br>Streaming card state & rendering |
528
477
  | `src/bot/` | 运行注册、消息排队、审批/问答注册表<br>Run registry, queueing, approval/question registries |
529
478
  | `src/commands/` | 斜杠命令(/cd /ws /new …)<br>Slash commands |
530
- | `src/cli/` | CLI 入口与 start / status / restart / stop / doctor 命令<br>CLI entry & service commands |
479
+ | `src/cli/` | CLI 入口:`setup`(唯一安装命令)/ `doctor`(诊断)/ 隐藏 `run`<br>CLI entry: setup / doctor / hidden run |
531
480
  | `src/config/` | profile / 配置 / 访问白名单 / dsh 配置管理<br>Profile, config, access & dsh config management |
532
481
  | `src/core/` | 结构化日志<br>Structured logging |
533
482
  | `src/media/` | 附件下载与文本注入<br>Attachment download & text injection |
534
483
  | `src/platform/` | 跨平台原子写入<br>Cross-platform atomic writes |
535
- | `src/service/` | 后台服务管理(systemd / launchd / 计划任务 / 便携 supervisor)<br>Background service management |
536
484
  | `docs/` | 架构、路线图等文档<br>Architecture, roadmap & docs |
537
485
  | `reference/` | 参考研究用的克隆仓库(不提交)<br>Cloned reference repos (not committed) |
538
486
 
package/SECURITY.md CHANGED
@@ -40,9 +40,8 @@
40
40
 
41
41
  - 本地配置 `~/.dsh-lark/config.json` 以 `0600` 权限写入。
42
42
  - 飞书凭据明文保存在本机配置文件;日志与卡片不输出真实密钥。
43
- - 后台服务把 `DEEPSEEK_API_KEY`、`DSH_LARK_*`、`PATH` 等环境快照到
44
- `~/.dsh-lark/service/service.env`(`0600`);systemd / launchd 单元文件中的 `EnvironmentFile`
45
- 只引用该文件,不内联密钥。
43
+ - 桥接引擎在 dsh 宿主进程内运行,凭据与 `DSH_LARK_*` 环境直接随 dsh 进程提供,无独立服务
44
+ 环境快照文件;敏感值不进日志与卡片。
46
45
  - 后台运行日志写入 `~/.dsh-lark/profiles/<profile>/logs/bot.log`(JSON Lines,密钥字段脱敏后输出)。
47
46
  - 聊天命令管理的 dsh 配置按官方存储协议写入:`~/.dsh/settings.yaml`(只存 `apiKeyEnv`
48
47
  引用,不落字面密钥)与 `~/.dsh/.credentials.yaml`(目录 0700、文件 0600)。bot 永不回显
package/cordis.patch.yml CHANGED
@@ -1,12 +1,30 @@
1
1
  # dsh-lark-bot as a profile bundle.
2
2
 
3
- # Installed with `dsh plugin --profile <name> add dsh-lark-bot`. The row
4
- # mounts the bridge-management plugin (`dsh-lark-bot/plugin`) and exposes
5
- # `ctx.larkBridge` without blocking profile boot. Set DSH_LARK_AUTOSTART=1
6
- # to start the standalone bridge when the profile boots.
3
+ # Installed with `dsh plugin --profile <name> add dsh-lark-bot` (or the
4
+ # single `dsh-lark-bot setup` command), dsh appends this package to the profile's
5
+ # `dsh.profile.bundles` and applies this patch on boot:
6
+ # - `dsh-lark-bot/plugin` starts the full bridge engine IN-PROCESS (Feishu
7
+ # channel, workspace/session layers, notify server, nested dsh SDK
8
+ # runtime) and exposes `ctx.larkBridge` (status / stop).
9
+ # - `dsh-lark-bot/notify` mounts the `lark_notify` tool for the host agent.
10
+ # First boot without credentials prints a QR code for one-time binding.
11
+ # Set DSH_LARK_DISABLED=1 to keep the engine stopped.
7
12
 
8
13
  - insert:
9
14
  - id: dsh-lark-bot
10
15
  name: 'dsh-lark-bot/plugin'
11
16
  config:
12
- autostart: !!js process.env.DSH_LARK_AUTOSTART === '1'
17
+ home: !!js process.env.DSH_LARK_HOME
18
+ tenant: !!js process.env.DSH_LARK_TENANT ?? 'feishu'
19
+ appId: !!js process.env.DSH_LARK_APP_ID
20
+ appSecret: !!js process.env.DSH_LARK_APP_SECRET
21
+ workspace: !!js process.env.DSH_LARK_WORKSPACE
22
+ adapter: !!js process.env.DSH_LARK_ADAPTER
23
+ model: !!js process.env.DSH_LARK_MODEL
24
+ disabled: !!js process.env.DSH_LARK_DISABLED === '1'
25
+
26
+ - id: lark-notify
27
+ name: 'dsh-lark-bot/notify'
28
+ config:
29
+ endpoint: !!js process.env.DSH_LARK_NOTIFY_URL
30
+ token: !!js process.env.DSH_LARK_NOTIFY_TOKEN