feishu-devops 0.1.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 ADDED
@@ -0,0 +1,118 @@
1
+ # feishu-devops
2
+
3
+ 飞书消息收发测试项目。参考 [lark-coding-agent-bridge](https://github.com/zarazhangrui/feishu-claude-code-bridge),但**不对接 LLM**,仅做固定内容回复。
4
+
5
+ ## 功能
6
+
7
+ - 首次运行通过扫码创建 PersonalAgent 飞书应用(`@larksuite/channel` 的 `registerApp`)
8
+ - 用户授权后通过 WebSocket 接收消息
9
+ - 固定回复规则:
10
+ - 收到 `ping` → 回复 `pong`
11
+ - 其他消息 → 回复 `hello world`(可在配置中修改 `preferences.defaultReply`)
12
+ - 斜杠命令:
13
+ - `/cmd <shell>` — 在本机执行 shell 命令并返回输出(如 `/cmd pwd`);长命令会先在同一条消息显示「正在执行…」并刷新耗时,完成后原地替换为结果
14
+ - `/help` — 显示命令帮助
15
+
16
+ ## 环境要求
17
+
18
+ - Node.js >= 20.12
19
+
20
+ ## 快速开始
21
+
22
+ ```bash
23
+ # 安装依赖
24
+ npm install
25
+
26
+ # 开发运行(直接执行 TypeScript 源码,无需 build)
27
+ npm run dev
28
+ # 或单次运行
29
+ npm start
30
+ ```
31
+
32
+ `npm run dev` 会监听 `src/` 变更并自动重启;改代码后保存即可,不用手动 build。
33
+
34
+ 生产/发布前再打包:
35
+
36
+ ```bash
37
+ npm run build
38
+ npm run start:dist
39
+ ```
40
+
41
+ 扫码完成后,配置会保存到 `~/.feishu-devops/config.json`。
42
+
43
+ 在飞书中找到刚创建的应用,发私聊消息或在群里 @ 机器人:
44
+
45
+ - 发 `ping` → 收到 `pong`
46
+ - 发任意其他内容 → 收到 `hello world`
47
+
48
+ ## 使用已有应用
49
+
50
+ ```bash
51
+ node bin/feishu-devops.mjs run \
52
+ --app-id cli_xxxxxxxxxxxx \
53
+ --app-secret <your-secret> \
54
+ --tenant feishu
55
+ ```
56
+
57
+ 国际版 Lark:
58
+
59
+ ```bash
60
+ node bin/feishu-devops.mjs run --app-id cli_xxx --app-secret <secret> --tenant lark
61
+ ```
62
+
63
+ ## 配置
64
+
65
+ 配置文件默认路径:`~/.feishu-devops/config.json`
66
+
67
+ 可通过环境变量 `FEISHU_DEVOPS_HOME` 修改数据目录。
68
+
69
+ ```json
70
+ {
71
+ "accounts": {
72
+ "app": {
73
+ "id": "cli_xxxxxxxxxxxx",
74
+ "secret": "xxxxxxxx",
75
+ "tenant": "feishu"
76
+ }
77
+ },
78
+ "preferences": {
79
+ "requireMentionInGroup": true,
80
+ "defaultReply": "hello world"
81
+ }
82
+ }
83
+ ```
84
+
85
+ - `requireMentionInGroup`:群中是否必须 @ 机器人才响应(默认 `true`);私聊始终响应
86
+ - `defaultReply`:非 `ping` 消息时的固定回复内容
87
+ - `cmdEnabled`:是否允许 `/cmd`(默认 `true`)
88
+ - `cmdTimeoutSeconds`:`/cmd` 超时秒数(默认 `300`,最大 `1800`)
89
+ - `cmdProgressIntervalSeconds`:`/cmd` 执行中状态刷新间隔(默认 `5` 秒;设为 `0` 则只显示初始「正在执行」不周期性刷新,最大 `60`)
90
+
91
+ > **安全提示**:`/cmd` 会在运行 bot 的本机执行任意 shell 命令,仅建议在可信环境使用。
92
+
93
+ ## 项目结构
94
+
95
+ ```
96
+ src/
97
+ ├── bot/
98
+ │ ├── wizard.ts # 扫码创建应用(来自 lark-coding-agent-bridge)
99
+ │ ├── channel.ts # WebSocket 连接与消息处理
100
+ │ └── reply.ts # 固定回复逻辑
101
+ ├── cli/
102
+ │ ├── index.ts # CLI 入口
103
+ │ ├── start.ts # 启动流程
104
+ │ └── bootstrap.ts # 配置引导
105
+ ├── config/ # 配置读写
106
+ ├── platform/ # 原子写入
107
+ └── utils/
108
+ └── feishu-auth.ts # 凭证校验
109
+ ```
110
+
111
+ ## 与参考项目的差异
112
+
113
+ | 参考项目 (lark-coding-agent-bridge) | 本项目 |
114
+ |-------------------------------------|--------|
115
+ | Claude/Codex agent 适配 | 无 LLM,固定文本回复 |
116
+ | 多 profile、加密 keystore | 单配置文件,明文 secret(0600 权限) |
117
+ | 流式卡片、slash 命令 | 简单 text 回复 |
118
+ | lark-cli 预检、后台 daemon | 仅前台 `run` 命令 |
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.js';