@coze-arch/cli 0.0.14 → 0.0.15-alpha.a0f5b9
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/lib/__templates__/nextjs/scripts/prepare.sh +3 -0
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +3 -0
- package/lib/__templates__/pi-agent/.coze +10 -0
- package/lib/__templates__/pi-agent/AGENTS.md +140 -0
- package/lib/__templates__/pi-agent/README.md +172 -0
- package/lib/__templates__/pi-agent/_gitignore +3 -0
- package/lib/__templates__/pi-agent/_npmrc +23 -0
- package/lib/__templates__/pi-agent/docs/project-overview.md +356 -0
- package/lib/__templates__/pi-agent/docs/user/getting-started.md +47 -0
- package/lib/__templates__/pi-agent/package.json +60 -0
- package/lib/__templates__/pi-agent/pi-resources/SYSTEM.md +15 -0
- package/lib/__templates__/pi-agent/pi-resources/extensions/preference-memory/index.ts +355 -0
- package/lib/__templates__/pi-agent/pi-resources/extensions/test-ping.ts +19 -0
- package/lib/__templates__/pi-agent/pi-resources/prompts/test-prompt.md +11 -0
- package/lib/__templates__/pi-agent/pi-resources/skills/coze-asr/SKILL.md +36 -0
- package/lib/__templates__/pi-agent/pi-resources/skills/coze-asr/scripts/asr.mjs +9 -0
- package/lib/__templates__/pi-agent/pi-resources/skills/coze-image-gen/SKILL.md +41 -0
- package/lib/__templates__/pi-agent/pi-resources/skills/coze-image-gen/scripts/gen.mjs +9 -0
- package/lib/__templates__/pi-agent/pi-resources/skills/coze-tts/SKILL.md +85 -0
- package/lib/__templates__/pi-agent/pi-resources/skills/coze-tts/scripts/tts.mjs +9 -0
- package/lib/__templates__/pi-agent/pi-resources/skills/coze-video-gen/SKILL.md +53 -0
- package/lib/__templates__/pi-agent/pi-resources/skills/coze-video-gen/scripts/gen.mjs +9 -0
- package/lib/__templates__/pi-agent/pnpm-lock.yaml +8285 -0
- package/lib/__templates__/pi-agent/scripts/dev.sh +14 -0
- package/lib/__templates__/pi-agent/scripts/prepare.sh +2 -0
- package/lib/__templates__/pi-agent/src/agent.ts +363 -0
- package/lib/__templates__/pi-agent/src/channels/feishu/index.ts +760 -0
- package/lib/__templates__/pi-agent/src/channels/feishu/streaming-card.ts +297 -0
- package/lib/__templates__/pi-agent/src/channels/wechat/index.ts +171 -0
- package/lib/__templates__/pi-agent/src/config.ts +596 -0
- package/lib/__templates__/pi-agent/src/core.ts +218 -0
- package/lib/__templates__/pi-agent/src/dashboard/api/channels.ts +148 -0
- package/lib/__templates__/pi-agent/src/dashboard/api/docs.ts +204 -0
- package/lib/__templates__/pi-agent/src/dashboard/api/models.ts +141 -0
- package/lib/__templates__/pi-agent/src/dashboard/api/overview.ts +33 -0
- package/lib/__templates__/pi-agent/src/dashboard/config-store.ts +64 -0
- package/lib/__templates__/pi-agent/src/dashboard/index.ts +39 -0
- package/lib/__templates__/pi-agent/src/dashboard/server.ts +622 -0
- package/lib/__templates__/pi-agent/src/dashboard/types.ts +25 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/index.html +13 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/postcss.config.cjs +7 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/app-layout.tsx +186 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/page-title.tsx +17 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/ui/alert.tsx +22 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/ui/badge.tsx +25 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/ui/button.tsx +40 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/ui/card.tsx +29 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/ui/input.tsx +18 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/ui/label.tsx +8 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/ui/select.tsx +80 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/components/ui/separator.tsx +23 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/hooks/use-fetch.ts +32 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/hooks/use-local-storage-state.ts +23 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/main.tsx +30 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/pages/channels-page.tsx +188 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/pages/chat-page.tsx +451 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/pages/docs-page.tsx +65 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/pages/models-page.tsx +122 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/pages/overview-page.tsx +134 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/services/chat-ws-service.ts +167 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/styles.css +294 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/src/utils/index.ts +11 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/tsconfig.json +13 -0
- package/lib/__templates__/pi-agent/src/dashboard/web/vite.config.ts +17 -0
- package/lib/__templates__/pi-agent/src/index.ts +123 -0
- package/lib/__templates__/pi-agent/src/pi-resources.ts +125 -0
- package/lib/__templates__/pi-agent/src/session-store.ts +223 -0
- package/lib/__templates__/pi-agent/src/tools/common/format-coze-error.ts +12 -0
- package/lib/__templates__/pi-agent/src/tools/index.ts +2 -0
- package/lib/__templates__/pi-agent/src/tools/web-fetch/index.ts +195 -0
- package/lib/__templates__/pi-agent/src/tools/web-search/index.ts +206 -0
- package/lib/__templates__/pi-agent/template.config.js +45 -0
- package/lib/__templates__/pi-agent/tests/config.test.ts +315 -0
- package/lib/__templates__/pi-agent/tests/dashboard-docs-api.test.ts +125 -0
- package/lib/__templates__/pi-agent/tests/dashboard-models-api.test.ts +171 -0
- package/lib/__templates__/pi-agent/tests/feishu-channel.test.ts +149 -0
- package/lib/__templates__/pi-agent/tests/feishu-streaming-card.test.ts +15 -0
- package/lib/__templates__/pi-agent/tests/pi-resources.test.ts +73 -0
- package/lib/__templates__/pi-agent/tests/preference-memory.test.ts +43 -0
- package/lib/__templates__/pi-agent/tests/session-store.test.ts +61 -0
- package/lib/__templates__/pi-agent/tests/smoke/run-smoke.ts +275 -0
- package/lib/__templates__/pi-agent/tests/web-fetch.test.ts +157 -0
- package/lib/__templates__/pi-agent/tests/web-search.test.ts +208 -0
- package/lib/__templates__/pi-agent/tsconfig.json +21 -0
- package/lib/__templates__/pi-agent/types/larksuiteoapi-node-sdk.d.ts +113 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +24 -14
- package/lib/__templates__/taro/server/package.json +0 -2
- package/lib/__templates__/templates.json +24 -0
- package/lib/__templates__/vite/scripts/prepare.sh +3 -0
- package/lib/cli.js +106 -8
- package/package.json +1 -1
|
@@ -7,3 +7,6 @@ cd "${COZE_WORKSPACE_PATH}"
|
|
|
7
7
|
|
|
8
8
|
echo "Installing dependencies..."
|
|
9
9
|
pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
10
|
+
if command -v coze > /dev/null 2>&1 && coze check-bins --help > /dev/null 2>&1; then
|
|
11
|
+
coze check-bins --fix
|
|
12
|
+
fi
|
|
@@ -7,6 +7,9 @@ cd "${COZE_WORKSPACE_PATH}"
|
|
|
7
7
|
|
|
8
8
|
echo "Installing dependencies..."
|
|
9
9
|
pnpm install --prefer-frozen-lockfile --prefer-offline
|
|
10
|
+
if command -v coze > /dev/null 2>&1 && coze check-bins --help > /dev/null 2>&1; then
|
|
11
|
+
coze check-bins --fix
|
|
12
|
+
fi
|
|
10
13
|
|
|
11
14
|
echo "Preparing Nuxt project..."
|
|
12
15
|
pnpm exec nuxt prepare
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Pi Bot AGENTS Guide
|
|
2
|
+
|
|
3
|
+
## 1. 项目定位
|
|
4
|
+
|
|
5
|
+
- 这是一个基于 Pi 开发、已经可运行的 agent 项目,并且可以按需要继续扩展能力。
|
|
6
|
+
- 默认目标不是直接修改宿主实现,而是优先沿用 Pi 生态扩展方式交付需求。
|
|
7
|
+
- repo 内长期维护、应进入版本管理的 Pi 资源,统一放在 `pi-resources/`。
|
|
8
|
+
- `<%= workspaceDir %>/.pi/` 是本地覆盖层和调试层,不是 repo 内资源的主落点;除非用户明确要求做本地覆盖,否则不要把长期方案放进去。
|
|
9
|
+
|
|
10
|
+
## 2. 必读顺序
|
|
11
|
+
|
|
12
|
+
在进行较大修改前,优先按下面顺序理解项目:
|
|
13
|
+
|
|
14
|
+
1. `README.md`
|
|
15
|
+
2. `docs/project-overview.md`
|
|
16
|
+
3. `src/pi-resources.ts`
|
|
17
|
+
4. `pi-resources/` 下与需求相关的资源
|
|
18
|
+
5. 与改动相关的测试
|
|
19
|
+
|
|
20
|
+
## 3. 先做实现路径判断
|
|
21
|
+
|
|
22
|
+
默认按下面优先级选择落点,能在前一层解决就不要进入后一层:
|
|
23
|
+
|
|
24
|
+
- agent 的长期行为、角色、边界、默认协作方式、长期规则:
|
|
25
|
+
- `pi-resources/SYSTEM.md`
|
|
26
|
+
- 可复用 prompt 模板或调用模板:
|
|
27
|
+
- `pi-resources/prompts/`
|
|
28
|
+
- 可复用工作流、脚本型能力、操作指南:
|
|
29
|
+
- `pi-resources/skills/<skill-name>/`
|
|
30
|
+
- 生命周期钩子、tool 注册、记忆注入、runtime 增强、agent 侧能力:
|
|
31
|
+
- `pi-resources/extensions/<extension-name>/`
|
|
32
|
+
- 只有涉及宿主层时才改 `src/`:
|
|
33
|
+
- channel 协议适配、消息收发、路由 gating
|
|
34
|
+
- session key、transcript、持久化
|
|
35
|
+
- config schema、provider 解析、启动装配
|
|
36
|
+
- dashboard API / web UI
|
|
37
|
+
- `customTools` 装配
|
|
38
|
+
- 资源加载器本身
|
|
39
|
+
|
|
40
|
+
如果需求能通过 `pi-resources` 实现,就不要去改 `src/`。
|
|
41
|
+
|
|
42
|
+
## 4. 当前仓库里的 Pi 扩展事实
|
|
43
|
+
|
|
44
|
+
- `src/pi-resources.ts` 会把 repo 内的 `pi-resources/extensions/`、`pi-resources/skills/`、`pi-resources/prompts/`、`pi-resources/SYSTEM.md` 自动接入 runtime。
|
|
45
|
+
- runtime 显式关闭了 `AGENTS.md` 自动加载;不要假设 bot 运行时会读取工作区里的 `AGENTS.md`。
|
|
46
|
+
- `<%= workspaceDir %>/.pi/SYSTEM.md` 的优先级高于 repo 的 `pi-resources/SYSTEM.md`,但它是覆盖层,不是版本管理主落点。
|
|
47
|
+
- extension 的自动发现规则不是“目录存在就会生效”:
|
|
48
|
+
- 顶层 `*.ts` / `*.js` 文件会被加载
|
|
49
|
+
- 子目录里只有 `package.json` 的 `pi.extensions` 指向文件,或存在 `index.ts` / `index.js` 时,才会被加载
|
|
50
|
+
- 当前可参考的 extension 示例:
|
|
51
|
+
- `pi-resources/extensions/test-ping.ts`
|
|
52
|
+
- `pi-resources/extensions/preference-memory/index.ts`
|
|
53
|
+
- 当前可参考的 skill 示例:
|
|
54
|
+
- `pi-resources/skills/coze-asr/`
|
|
55
|
+
- `pi-resources/skills/coze-image-gen/`
|
|
56
|
+
- `pi-resources/skills/coze-tts/`
|
|
57
|
+
- `pi-resources/skills/coze-video-gen/`
|
|
58
|
+
|
|
59
|
+
## 5. 宿主层边界
|
|
60
|
+
|
|
61
|
+
- 不要在 `src/channels/*`、`src/index.ts`、消息入口、路由层或其他 host 代码里,通过关键词匹配、意图判断或硬编码分支,手动把请求分流到某个搜索器、抓取器、collector 或 workflow。
|
|
62
|
+
- 搜索、抓取、检索、知识注入、热点汇总、项目记忆、外部服务调用等能力,默认应作为 agent 可调用的 tool、extension、skill 或 prompt 提供。
|
|
63
|
+
- host 层只负责:
|
|
64
|
+
- 平台协议适配
|
|
65
|
+
- 消息归一化
|
|
66
|
+
- 路由 gating
|
|
67
|
+
- 会话归类
|
|
68
|
+
- 持久化
|
|
69
|
+
- config / provider 装配
|
|
70
|
+
- dashboard
|
|
71
|
+
- 如果某能力理论上能做成 `pi-resources/extensions/*`,就不要默认在 `src/tools/*` 和 `src/agent.ts` 里新增 `customTools`。
|
|
72
|
+
|
|
73
|
+
## 6. 修改策略
|
|
74
|
+
|
|
75
|
+
- 优先做小步、增量、可验证的修改。
|
|
76
|
+
- 新需求若能在 `pi-resources` 落地,不要顺手重构宿主代码。
|
|
77
|
+
- 如果用户需求涉及产出新的 `.md` 文件,默认把文件落在当前工作目录 `cwd`,不要放进 `src/` 或其他源码目录;只有当用户明确指定路径,或明确要求更新现有文档入口时,才放到对应位置。
|
|
78
|
+
- 若必须改 `src/`,最终说明里必须写清楚:
|
|
79
|
+
- 为什么 `pi-resources` 不足以承载
|
|
80
|
+
- 改动影响了哪些宿主职责
|
|
81
|
+
- 是否需要补测试和文档
|
|
82
|
+
|
|
83
|
+
## 7. 常见改动落点
|
|
84
|
+
|
|
85
|
+
- 调整 agent 默认行为:
|
|
86
|
+
- `pi-resources/SYSTEM.md`
|
|
87
|
+
- 新增 prompt 模板:
|
|
88
|
+
- `pi-resources/prompts/`
|
|
89
|
+
- 新增 skill:
|
|
90
|
+
- `pi-resources/skills/<skill-name>/SKILL.md`
|
|
91
|
+
- 必要的 `scripts/*`
|
|
92
|
+
- 用户要求新建 Markdown 文档、方案、总结、设计稿等 `.md` 文件:
|
|
93
|
+
- 默认放在 `cwd`
|
|
94
|
+
- 不要默认放进 `src/` 或其他源码目录
|
|
95
|
+
- 新增 extension / runtime tool:
|
|
96
|
+
- `pi-resources/extensions/<extension-name>/index.ts`
|
|
97
|
+
- 或 `pi-resources/extensions/*.ts`
|
|
98
|
+
- 修改资源装配逻辑本身:
|
|
99
|
+
- `src/pi-resources.ts`
|
|
100
|
+
- `tests/pi-resources.test.ts`
|
|
101
|
+
- 修改 provider、runtime、session、channel、dashboard:
|
|
102
|
+
- 对应 `src/*`
|
|
103
|
+
- 对应 `tests/*`
|
|
104
|
+
|
|
105
|
+
## 8. 验证要求
|
|
106
|
+
|
|
107
|
+
默认情况下:
|
|
108
|
+
|
|
109
|
+
- 任何改动都至少运行与改动直接相关的验证。
|
|
110
|
+
- 修改 `pi-resources`、资源装配、extensions、skills、SYSTEM 行为时,至少考虑运行:
|
|
111
|
+
- `npm test`
|
|
112
|
+
- `npm run typecheck`
|
|
113
|
+
- 修改 Dashboard 前端或其构建相关内容时,再运行:
|
|
114
|
+
- `npm run dashboard:build`
|
|
115
|
+
- 修改跨模块主链路,例如 config、channel、runtime、session、dashboard 联动时,再运行:
|
|
116
|
+
- `npm run smoke`
|
|
117
|
+
|
|
118
|
+
如果因为环境限制无法完成验证,需要在最终说明中明确指出未验证项、风险和建议的人工验证方式。
|
|
119
|
+
|
|
120
|
+
## 9. 高风险变更先确认
|
|
121
|
+
|
|
122
|
+
遇到以下改动,先暂停并与用户确认:
|
|
123
|
+
|
|
124
|
+
- 修改 `workspace/config.json` schema 或默认值语义
|
|
125
|
+
- 修改 `getSessionKey()` 规则
|
|
126
|
+
- 修改 session、transcript、index、archive 格式
|
|
127
|
+
- 修改默认 channel 路由或触发条件
|
|
128
|
+
- 删除现有 API、页面、配置项或持久化数据
|
|
129
|
+
- 把本可通过 `pi-resources` 完成的能力,改成宿主层硬编码方案
|
|
130
|
+
|
|
131
|
+
## 10. 目标
|
|
132
|
+
|
|
133
|
+
你的目标是在当前项目里持续交付用户需要的能力,同时尽量保证:
|
|
134
|
+
|
|
135
|
+
- 优先使用 Pi 生态扩展方式
|
|
136
|
+
- 尽量少动宿主层,只有必要时才动
|
|
137
|
+
- 行为可预测
|
|
138
|
+
- 配置与数据兼容
|
|
139
|
+
- 出问题时便于排查
|
|
140
|
+
- 后续继续二次开发时容易维护
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Pi Bot
|
|
2
|
+
|
|
3
|
+
这是一个基于 `pi-mono` / `@mariozechner/pi-coding-agent` 的 Bot 项目。
|
|
4
|
+
|
|
5
|
+
## 当前结构
|
|
6
|
+
|
|
7
|
+
- `src/config.ts`
|
|
8
|
+
- 项目唯一配置入口,读取 `config.json` 并装配 `BotAppConfig`
|
|
9
|
+
- `src/index.ts`
|
|
10
|
+
- 应用启动入口
|
|
11
|
+
- `src/agent.ts`
|
|
12
|
+
- agent runtime 封装
|
|
13
|
+
- `src/pi-resources.ts`
|
|
14
|
+
- repo 内置 Pi 资源装配,统一把源码目录接到 runtime
|
|
15
|
+
- `pi-resources/`
|
|
16
|
+
- 版本管理下的 skills / prompts / extensions / SYSTEM.md 源码目录
|
|
17
|
+
- `src/dashboard/config-store.ts`
|
|
18
|
+
- Dashboard 配置读写抽象,支持文件和内存两种存储
|
|
19
|
+
- `src/core.ts`
|
|
20
|
+
- 通用消息协议、共享类型和 helper
|
|
21
|
+
- `src/channels/feishu`
|
|
22
|
+
- 飞书 channel
|
|
23
|
+
- `src/channels/wechat`
|
|
24
|
+
- 微信 channel
|
|
25
|
+
- `tests/smoke`
|
|
26
|
+
- 基础 smoke test(使用内存配置存储验证 dashboard 配置读写链路)
|
|
27
|
+
- `tests/config.test.ts`
|
|
28
|
+
- config 解析与模型构建测试
|
|
29
|
+
- `types`
|
|
30
|
+
- 本地类型声明补充
|
|
31
|
+
- `docs/project-overview.md`
|
|
32
|
+
- 项目结构与实现介绍
|
|
33
|
+
- `docs/user/getting-started.md`
|
|
34
|
+
- 用户快速开始文档,Dashboard 的 `Docs` 页面会直接展示这份 Markdown
|
|
35
|
+
|
|
36
|
+
## Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install
|
|
40
|
+
npm run dev
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`npm run dev` 会先按顺序加载 `.env` 和 `.env.local`,然后启动 `src/index.ts`。
|
|
44
|
+
默认会使用 `pi` runtime;如果你只是想走本地 mock 链路,可以额外设置 `PI_BOT_AGENT_MODE=mock`。
|
|
45
|
+
|
|
46
|
+
## 用户文档
|
|
47
|
+
|
|
48
|
+
启动后,可以在 Dashboard 的 `Docs` 页面查看当前项目的用户指引,默认地址是:
|
|
49
|
+
|
|
50
|
+
```txt
|
|
51
|
+
http://127.0.0.1:5000/docs
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
用户文档的 Markdown 源文件位于 `docs/user/getting-started.md`。如果你修改了接入步骤或调整了用户可见行为,请同步更新这份文档。
|
|
55
|
+
|
|
56
|
+
## 常用命令
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm run dev
|
|
60
|
+
npm test
|
|
61
|
+
npm run smoke
|
|
62
|
+
npm run typecheck
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Agent 模式
|
|
66
|
+
|
|
67
|
+
- 默认情况下,`npm run dev` 使用 `PI_BOT_AGENT_MODE=pi`
|
|
68
|
+
- `PI_BOT_AGENT_MODE=mock`
|
|
69
|
+
- 使用 mock runtime,适合本地链路验证
|
|
70
|
+
- `PI_BOT_AGENT_MODE=pi`
|
|
71
|
+
- 使用真实 `pi-coding-agent` runtime
|
|
72
|
+
|
|
73
|
+
除 `PI_BOT_AGENT_MODE` 和飞书相关环境变量外,agent 的模型、provider、workspace、thinking level 都从 `<%= workspaceDir %>/config.json` 读取。
|
|
74
|
+
|
|
75
|
+
## Provider 配置
|
|
76
|
+
|
|
77
|
+
provider 不再通过项目内的特化实现硬编码,而是从 `<%= workspaceDir %>/config.json` 的 `models.providers` 读取。
|
|
78
|
+
|
|
79
|
+
如果你已经启动了本地 Dashboard,现在也可以直接在界面里切换默认模型:
|
|
80
|
+
|
|
81
|
+
- `http://127.0.0.1:5000/models`
|
|
82
|
+
- 选择默认模型(选择后会自动保存)
|
|
83
|
+
|
|
84
|
+
默认情况下,Dashboard 会通过文件型 `ConfigStore` 读写 `<%= workspaceDir %>/config.json`,保存后需要重启进程让配置生效。测试或嵌入场景也可以通过 `createBotApp(..., { dashboardConfigStore })` 注入内存型 `ConfigStore`,避免依赖真实配置文件。
|
|
85
|
+
|
|
86
|
+
## Pi 资源
|
|
87
|
+
|
|
88
|
+
项目内置的 Pi 资源统一维护在 `pi-resources/` 下,并在 runtime 初始化时以代码方式注入:
|
|
89
|
+
|
|
90
|
+
- `pi-resources/extensions/`
|
|
91
|
+
- `pi-resources/skills/`
|
|
92
|
+
- `pi-resources/prompts/`
|
|
93
|
+
- `pi-resources/SYSTEM.md`
|
|
94
|
+
|
|
95
|
+
`<%= workspaceDir %>/.pi/` 仍然可以作为本地调试覆盖层,但不再作为这些资源的源码真身。当前项目也会显式关闭 `AGENTS.md` 自动加载,避免工作区目录里的上下文文件混入 bot 运行时。
|
|
96
|
+
|
|
97
|
+
默认主模型来自:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"agents": {
|
|
102
|
+
"defaults": {
|
|
103
|
+
"thinkingLevel": "medium",
|
|
104
|
+
"model": {
|
|
105
|
+
"primary": "coze/glm-4-7-251222"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
provider 定义示例:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"models": {
|
|
117
|
+
"providers": {
|
|
118
|
+
"coze": {
|
|
119
|
+
"api": "openai-completions",
|
|
120
|
+
"apiKey": "${COZE_WORKLOAD_IDENTITY_API_KEY}",
|
|
121
|
+
"baseUrl": "${COZE_INTEGRATION_MODEL_BASE_URL}",
|
|
122
|
+
"models": [
|
|
123
|
+
{
|
|
124
|
+
"id": "glm-4-7-251222",
|
|
125
|
+
"name": "GLM 4.7",
|
|
126
|
+
"reasoning": false,
|
|
127
|
+
"input": ["text"],
|
|
128
|
+
"contextWindow": 200000,
|
|
129
|
+
"maxTokens": 8192,
|
|
130
|
+
"cost": {
|
|
131
|
+
"input": 0,
|
|
132
|
+
"output": 0,
|
|
133
|
+
"cacheRead": 0,
|
|
134
|
+
"cacheWrite": 0
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
后续要扩展新的 openai-compatible provider,只需要在 `<%= workspaceDir %>/config.json` 里新增一个 provider 配置和模型定义即可。
|
|
145
|
+
|
|
146
|
+
当前 Dashboard 的模型配置页仅用于切换默认模型,不支持编辑 Provider 或模型参数。如果要扩展或修改 provider/model,仍然建议直接编辑 `<%= workspaceDir %>/config.json`。
|
|
147
|
+
|
|
148
|
+
## Feishu Debug
|
|
149
|
+
|
|
150
|
+
如果你在联调真实飞书机器人,并想排查重复回复或事件重试问题,可开启:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
export PI_BOT_DEBUG_FEISHU=1
|
|
154
|
+
npm run dev
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
飞书 channel 会输出收到事件、过滤原因、去重结果和发送回复等关键日志。
|
|
158
|
+
|
|
159
|
+
默认情况下,飞书 channel 会在 bot 开始处理消息时给原消息加一个 `OneSecond` reaction,并在发送回复前移除它。这里的 `emojiType` 需要填写飞书文档里的 `emoji_type` 枚举值,比如 `OneSecond`、`MUSCLE`。你也可以在 `<%= workspaceDir %>/config.json` 里覆盖这个行为:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"channels": {
|
|
164
|
+
"feishu": {
|
|
165
|
+
"thinkingReaction": {
|
|
166
|
+
"enabled": true,
|
|
167
|
+
"emojiType": "OneSecond"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
loglevel=error
|
|
2
|
+
registry=https://registry.npmmirror.com
|
|
3
|
+
|
|
4
|
+
strictStorePkgContentCheck=false
|
|
5
|
+
verifyStoreIntegrity=false
|
|
6
|
+
|
|
7
|
+
# 网络优化
|
|
8
|
+
network-concurrency=16
|
|
9
|
+
fetch-retries=3
|
|
10
|
+
fetch-timeout=60000
|
|
11
|
+
|
|
12
|
+
# 严格使用 peer dependencies
|
|
13
|
+
strict-peer-dependencies=false
|
|
14
|
+
|
|
15
|
+
# 自动生成 lockfile
|
|
16
|
+
auto-install-peers=true
|
|
17
|
+
|
|
18
|
+
# lockfile 配置
|
|
19
|
+
lockfile=true
|
|
20
|
+
prefer-frozen-lockfile=true
|
|
21
|
+
|
|
22
|
+
# 如果 lockfile 存在但过期,更新而不是失败
|
|
23
|
+
resolution-mode=highest
|