@chenglu.she/sandy 1.0.3 → 1.0.4

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
@@ -31,7 +31,7 @@ mkdir -p ~/treedome && cd ~/treedome
31
31
  sandy init
32
32
  ```
33
33
 
34
- 会交互式询问飞书 / Cursor / Agent 等项,并写入当前目录的 `config.yaml`。也可参考 [config.yaml.example](./config.yaml.example) 手改。
34
+ 会交互式询问飞书 / Cursor / Agent 等项,并写入当前目录的 `config.yaml`。人设模板见 [templates/sandy.mdc](./templates/sandy.mdc),可复制到 `.cursor/rules/`。
35
35
 
36
36
  必填项:
37
37
 
@@ -68,14 +68,16 @@ Agent 通过 `settingSources: ["project"]` 加载这些规则。人设、业务
68
68
 
69
69
  1. **应用能力** → 开通 **机器人**
70
70
  2. **权限**(开通后**发布新版本**才生效),至少:
71
- - 消息:获取与发送单聊/群消息、上传图片、上传文件、下载文件(如 `im:message`、`im:resource`)
72
- - 文档:读正文、创建文档、编辑文档(如 `docx:document:readonly`、`docx:document` / write)
73
- - 若要把新建文档放到指定文件夹:Drive 文件夹相关权限,并填 `feishuDocsFolder`
74
- 3. **版本管理**:发布;可用范围包含你自己
75
- 4. **事件与回调** → 订阅方式选 **长连接**(先让 bot 进程在线再保存)
76
- 5. 事件:`im.message.receive_v1`
77
- 6. 回调:`card.action.trigger`(Agent 选择题卡片用)
78
- 7. **读写已有文档**:在飞书文档里把机器人加为协作者(读/编辑),仅开通 API 权限不够
71
+ - **单聊**:`im:message.p2p_msg:readonly`(只有群聊 @ 能回、私聊没反应,通常是缺这个)
72
+ - **群聊 @**:`im:message.group_at_msg:readonly`
73
+ - **发消息**:`im:message`
74
+ - 文件:上传/下载(`im:resource` 等)
75
+ - 文档:读/写 docx(按需)
76
+ 3. **版本管理**:发布;**可用范围**包含你自己
77
+ 4. **事件与回调** → 长连接(先 `sandy` 在线再保存)
78
+ 5. 事件 `im.message.receive_v1`:点进去确认 **单聊消息**、**群聊 @ 机器人** 子开关都已开通
79
+ 6. 回调:`card.action.trigger`
80
+ 7. **读写已有文档**:把机器人加为文档协作者
79
81
 
80
82
  ### 5. 启动
81
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenglu.she/sandy",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Feishu long-connection bot that drives Cursor agents via @cursor/sdk",
@@ -26,7 +26,8 @@
26
26
  "assets",
27
27
  "README.md",
28
28
  "LICENSE",
29
- "config.yaml.example"
29
+ "config.yaml.example",
30
+ "templates"
30
31
  ],
31
32
  "scripts": {
32
33
  "dev": "tsx watch src/cli.ts",
package/src/index.ts CHANGED
@@ -218,9 +218,14 @@ async function handleMessage(raw: Parameters<typeof parseIncomingMessage>[0]) {
218
218
  const { text, mentionedBot } = extractText(msg, botOpenId ?? "");
219
219
 
220
220
  if (!shouldHandleMessage(msg, mentionedBot)) {
221
+ console.log(
222
+ `[handle] ignored chat_type=${msg.chatType} message_type=${msg.messageType} mentionedBot=${mentionedBot}`,
223
+ );
221
224
  return;
222
225
  }
223
226
 
227
+ console.log(`[handle] chat_type=${msg.chatType} message_id=${msg.messageId}`);
228
+
224
229
  const sessionKey = msg.chatId;
225
230
 
226
231
  let attachmentPrompt: string | undefined;
@@ -36,10 +36,15 @@ export const INIT_FIELD_GUIDES = {
36
36
  title: "飞书后台还需完成(init 不会替你操作)",
37
37
  lines: [
38
38
  "1. 应用能力 → 开通「机器人」",
39
- "2. 权限管理 → 开通消息 / 文件 / 文档等权限,并发布新版本",
40
- "3. 事件与回调 → 订阅方式选「长连接」",
41
- " 事件:im.message.receive_v1;回调:card.action.trigger",
42
- "4. 先在本机运行 sandy,看到 ws client ready 后再在后台保存长连接配置",
39
+ "2. 权限管理(缺一不可,改完必须发布新版本):",
40
+ " · 读取用户发给机器人的单聊消息 im:message.p2p_msg:readonly",
41
+ " · 获取用户在群组中@机器人的消息 im:message.group_at_msg:readonly",
42
+ " · 获取与发送单聊、群组消息 im:message",
43
+ " · 文件 / 文档权限按需开通",
44
+ "3. 事件与回调 → 长连接;订阅 im.message.receive_v1",
45
+ " 点进该事件,确认「单聊消息」「群聊 @ 机器人」等子项均为已开通",
46
+ "4. 可用范围包含测试账号;先运行 sandy(ws client ready)再保存长连接",
47
+ "5. 群聊能回、私聊不回 → 几乎总是缺 p2p 权限或事件子开关未开",
43
48
  ],
44
49
  links: [
45
50
  { label: "事件订阅(长连接)", url: "https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/event-subscription-guide/long-connection-mode" },
@@ -29,7 +29,6 @@ export function writeHookPolicy(): string {
29
29
  const payload = {
30
30
  updatedAt: new Date().toISOString(),
31
31
  allowedRoots: [...new Set(roots)],
32
- protectedWriteGlobs: [".cursor/rules", ".rules"],
33
32
  };
34
33
  fs.writeFileSync(policyPath, JSON.stringify(payload, null, 2), "utf8");
35
34
  return policyPath;
@@ -0,0 +1,22 @@
1
+ ---
2
+ description: Sandy 松鼠 — 通用飞书 Cursor Agent 人设模板
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Sandy 松鼠
7
+
8
+ 你是 **Sandy 松鼠**,开发与运维助手。
9
+
10
+ ## 职责
11
+
12
+ - 协助写代码、排障、运维与部署
13
+ - 在飞书里回答简洁、可执行;需要选择时用选择题
14
+ - 可在 `AGENT_CWD/.cursor/rules/` 下创建或更新规则,沉淀领域约定与协作习惯
15
+ - 文件修改范围以 `config.yaml` 里的 `agent.cwd` / `agent.dirs` 白名单为准
16
+ - 可使用本机 shell(SSH / git / 项目脚本),除非 `agent.sandbox=true`
17
+
18
+ ## 风格
19
+
20
+ - 自称:Sandy 松鼠
21
+ - 直接、靠谱、少废话;先给结论再展开
22
+ - 领域约定写在同目录其它 rules 里,按需维护