codelark 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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +193 -0
  3. package/SECURITY.md +34 -0
  4. package/SKILL.md +67 -0
  5. package/agents/openai.yaml +4 -0
  6. package/dist/cli.mjs +8794 -0
  7. package/dist/daemon.mjs +47172 -0
  8. package/dist/ui-server.mjs +22165 -0
  9. package/package.json +73 -0
  10. package/schemas/config.v1.schema.json +259 -0
  11. package/schemas/data/audit.v1.schema.json +44 -0
  12. package/schemas/data/auto-tasks.v1.schema.json +94 -0
  13. package/schemas/data/channel-chats.v1.schema.json +159 -0
  14. package/schemas/data/channel-default-targets.v1.schema.json +43 -0
  15. package/schemas/data/messages.v1.schema.json +23 -0
  16. package/schemas/data/number-map.v1.schema.json +9 -0
  17. package/schemas/data/permissions.v1.schema.json +35 -0
  18. package/schemas/data/sessions.v1.schema.json +330 -0
  19. package/schemas/data/string-map.v1.schema.json +9 -0
  20. package/schemas/manifest.json +121 -0
  21. package/scripts/analyze-bridge-log.js +838 -0
  22. package/scripts/build-preflight.d.ts +21 -0
  23. package/scripts/build-preflight.js +70 -0
  24. package/scripts/build.js +53 -0
  25. package/scripts/check-npm-pack.js +46 -0
  26. package/scripts/daemon.ps1 +16 -0
  27. package/scripts/daemon.sh +206 -0
  28. package/scripts/doctor.ps1 +27 -0
  29. package/scripts/doctor.sh +185 -0
  30. package/scripts/hot-update-bridge.sh +298 -0
  31. package/scripts/install-codex-skills.sh +127 -0
  32. package/scripts/install-codex.sh +10 -0
  33. package/scripts/migrate-bindings-to-channel-chats.js +228 -0
  34. package/scripts/patch-codex-sdk-windows-hide.js +96 -0
  35. package/scripts/real-feishu-e2e.ts +5804 -0
  36. package/scripts/run-tests.js +83 -0
  37. package/scripts/setup-wizard-real-e2e.ts +195 -0
  38. package/scripts/supervisor-linux.sh +49 -0
  39. package/scripts/supervisor-macos.sh +167 -0
  40. package/scripts/supervisor-windows.ps1 +481 -0
  41. package/skills/codelark/SKILL.md +67 -0
  42. package/skills/codelark-auto/SKILL.md +80 -0
  43. package/skills/codelark-question/SKILL.md +54 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2025 op7418
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,193 @@
1
+ # CodeLark
2
+
3
+ <p align="center">
4
+ <img src="docs/assets/readme/codelark-logo.png" alt="CodeLark logo" width="280">
5
+ </p>
6
+
7
+ > 你的下一次Vibe Coding,何必从终端开始?以一流的 UI 界面和智能体协作,work ALL in 飞书。
8
+
9
+ - 代码仓库:https://github.com/huiyeruzhou/codelark
10
+ - 文档站:https://huiyeruzhou.github.io/site/codelark/
11
+
12
+ ## 核心能力
13
+
14
+ | 能力 | 怎么用 | 入口 |
15
+ | --- | --- | --- |
16
+ | 共享本地 runtime 会话 | 在飞书上继续本地 Codex / Claude Code 对话,用可视化面板选择要接管的线程。 | `/t` |
17
+ | 流式卡片输出 | 将模型思考、工具调用、长任务进度和最终结果渲染成飞书卡片,对话留痕且可追踪。 | 普通消息 |
18
+ | 群聊 = Session | 一个群聊对应一个 session,用群聊名称管理任务;多线并行时一键拉起新群。 | `/new`、`/t rename <名称>` |
19
+ | 云文档驱动开发 | 模型可以生成云文档;在云文档评论中 `@bot` 在线对话,也可以 `@bot /new` 发起长线群聊任务,结束后再更新云文档。 | 云文档评论 |
20
+
21
+ ## Showcase
22
+
23
+ > 更完整的产品功能、使用场景、设计模块和源码入口说明见 [CodeLark 产品文档](https://huiyeruzhou.github.io/site/codelark/product/)。
24
+
25
+
26
+ <table>
27
+ <tr>
28
+ <td width="50%" align="center">
29
+ <img src="docs/assets/readme/showcase-cloud-document-chat.png" alt="CodeLark 云文档评论入口与群聊协作" style="width: 100%; max-width: 420px;">
30
+ </td>
31
+ <td width="50%" align="center">
32
+ <img src="docs/assets/readme/showcase-workbench-card.png" alt="CodeLark 飞书工作台与流式卡片" style="width: 100%; max-width: 420px;">
33
+ </td>
34
+ </tr>
35
+ <tr>
36
+ <td colspan="2" align="center">
37
+ <img src="docs/assets/readme/showcase-session-management.jpg" alt="CodeLark 会话管理" style="width: 100%; max-width: 840px;">
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <td width="50%" align="center">
42
+ <img src="docs/assets/readme/showcase-session-control.png" alt="CodeLark Session 控制面板" style="width: 100%; max-width: 420px;">
43
+ </td>
44
+ <td width="50%" align="center">
45
+ <img src="docs/assets/readme/shocase-runtime-control.png" alt="CodeLark Runtime 控制面板" style="width: 100%; max-width: 420px;">
46
+ </td>
47
+ </tr>
48
+ </table>
49
+
50
+
51
+ ## 快速开始
52
+
53
+ ### 依赖
54
+
55
+ - Node.js 24+
56
+ - 全局环境中已有 `codex` / `claude-code-router` / `claude-code` 其中之一,或当前系统用户已有对应登录态/API 凭据。
57
+
58
+ ### 安装
59
+
60
+ > 如果你通过环境变量配置模型、代理或 API Key,需要在启动 `codelark` 前 export。
61
+
62
+ ```bash
63
+ npx -y codelark@latest run
64
+ ```
65
+
66
+ ```bash
67
+ # export OPENAI_API_KEY=sk-xxx
68
+ npm install -g codelark
69
+ codelark run
70
+ ```
71
+
72
+ `codelark run` 会在启动 bridge 前为当前 CodeLark 配置初始化专属 lark-cli 运行环境:把飞书/Lark App 配置投影到 `~/.codelark/runtime/lark-cli-source/config.json`,绑定到 `~/.codelark/runtime/lark-cli/`,并把 `LARK_CHANNEL_CONFIG` 与 `LARKSUITE_CLI_CONFIG_DIR` 注入 bridge/agent 进程。如果默认 lark-cli 配置里已有同 App 的用户授权,启动时会复制到专属目录并切换为 user-default。这样 bridge 内部和 agent 调用 `lark-cli` 时会使用 CodeLark 当前配置,而不是误读默认用户 HOME 下的其他 lark-cli 配置。
73
+
74
+ 默认工作台地址是 `http://127.0.0.1:4781`,端口被占用时会自动切到可用端口。查看当前状态和地址:
75
+
76
+ ```bash
77
+ codelark status
78
+ codelark url
79
+ ```
80
+
81
+ `setup` 向导的主要工作是:
82
+
83
+ - 飞书鉴权:
84
+ - 默认引导:使用 `lark-cli` 扫码创建或导入机器人配置。
85
+ - 手动引导:直接粘贴飞书 `App ID` 和 `App Secret`。
86
+ - 配置:
87
+ - 选择默认 runtime:优先使用 `~/.codex`;检测到 `~/.claude-code-router` 会推荐 Claude Code Router;都没有时默认 Claude Code。
88
+ - 之后选择默认工作目录,默认是运行 `codelark setup` 时的当前目录。
89
+ - 以上内容会保存到 `~/.codelark/config.json`,并更新 `config.env`。`config.json` 是系统实际使用的配置文件;`config.env` 方便人工配置,也可通过环境变量覆盖,系统启动时会用 env 覆盖 json。`codelark run` / `codelark start` 会再把当前配置绑定到 CodeLark 专属 lark-cli 运行目录。
90
+
91
+ - 安装 skills:安装向导会说明并默认勾选这些 skill,也可以逐个关闭或全部取消。手动安装可运行:
92
+
93
+ ```bash
94
+ codelark install-skills
95
+ ```
96
+
97
+ ## 典型使用方式
98
+
99
+ ### 1. 接管本地会话
100
+
101
+ 在 Web 工作台里新增好飞书通道实例后,启动 bridge。
102
+ 然后在 IM 中发送:
103
+
104
+ ```text
105
+ /t
106
+ ```
107
+
108
+ `/t` 默认显示最近 20 条本地 Codex / Claude Code 会话。需要更多时发送:
109
+
110
+ ```text
111
+ /t all
112
+ ```
113
+
114
+ 查看最多 100 条本地 Codex / Claude Code 会话。
115
+ 再通过:
116
+
117
+ ```text
118
+ /t 1
119
+ ```
120
+
121
+ 切到对应线程。
122
+
123
+ ### 2. 继续对话
124
+
125
+ 绑定成功后,直接发送普通消息即可继续当前线程。
126
+
127
+ - Codex 的默认后端是 tmux,所以你可以发送 `<enter>` 或 `<C-c>`,CodeLark 会解释为控制键;卡权限时很有用。
128
+ - Codex CLI/Desktop 或 Claude Code 继续操作这条共享会话时,结果也会通过对应 JSONL mirror 同步到 IM。
129
+
130
+ > 也就是说,你可以回到电脑继续在 TUI 中和 Agent 协作,再回到飞书时依旧能看到完整对话记录。
131
+
132
+ ### 3. 新建群聊任务
133
+
134
+ ```text
135
+ /new
136
+ ```
137
+
138
+ 会发送创建表单,让你填写群聊名称和工作目录。表单会默认带出当前会话的工作目录;临时草稿线程也有自己的工作目录,可以直接作为默认目录。当前聊天还没有绑定会话时,会使用全局默认工作目录。
139
+
140
+ 也可以用纯文本直接指定名称,或同时指定名称和目录:
141
+
142
+ ```text
143
+ /new my-thread
144
+ /new my-thread ./my-project
145
+ /new my-thread D:\work\my-project
146
+ ```
147
+
148
+ 名称或路径包含空格时,请使用英文双引号 `"` 或英文单引号 `'`,例如 `/new "my thread" ./my-project`。
149
+
150
+ `/clear [名称] [路径]` 会在当前聊天上下文创建一个新的对话,并把当前聊天绑定过去;名称或路径包含空格时,请使用英文双引号 `"` 或英文单引号 `'`。之后可用 `/t` 重新附加到之前的对话。若当前 SDK 任务、共享镜像状态或 tmux TUI 追加输入仍显示运行中,会先询问是否终止旧对话;确认后再切换。群聊通道会同步重命名群聊,真实群名会自动带 `[botname]` 前缀。
151
+
152
+ ## 常用命令
153
+
154
+ ### 会话
155
+
156
+ - `/t`:查看最近 20 条本地 Codex / Claude Code 会话。
157
+ - 表格标记:绿色表示当前聊天绑定;灰色表示其他聊天已绑定。
158
+ - `/t rename <名称>`:重命名当前线程;群聊通道会同步修改群聊名称,真实群名会自动带 `[botname]` 前缀。
159
+ - `/new`:发送创建表单,填写名称和工作目录后创建新的 IM 群聊会话。
160
+ - `/clear [名称] [路径]`:在当前聊天上下文创建新的对话并绑定过去,之后仍可用 `/t` 找回旧对话。
161
+
162
+ ### 运行设置
163
+
164
+ - `/`:查看/配置当前聊天,包括模型、模式、思考级别、共享镜像状态。
165
+ - `/r <1-5>`:切换思考级别。
166
+ - `/mode <normal|yolo>`:切换运行模式,自动映射到 Codex 和 Claude Code 的对应模式。
167
+ - `/model <模型名>`:切换当前 IM 会话模型。
168
+ - `/require-at`:查看当前飞书通道的群聊 @bot 要求;`/require-at on|off` 可切换是否必须 @bot。
169
+ - `/set`:查看全局配置,然后用 `/set <key> <value>` 修改。
170
+
171
+ ### 对话与诊断
172
+
173
+ - `//...`:向模型发送以 `/` 开头的文本,例如 `//status` 会作为 `/status` 发给模型。
174
+ - 特别常用:`//goal`!
175
+ - `/tmux-screen`:诊断 Codex 的运行情况。
176
+ - `<enter>`:向 Codex 对话发送回车。
177
+ - `<C-c>`:向 Codex 对话发送终止。
178
+ - `/p tmux`:重启 Codex 会话。
179
+ - `/his [N]`:把当前线程最近消息渲染成卡片发送。
180
+ - `/his json`:直接发送原始 Codex / Claude Code session JSONL 文件,不做二次包装或后处理。
181
+ - `/stop`:停止当前任务;tmux Provider 中已有运行中 TUI turn 时会向 tmux 发送 `<C-c>`。
182
+
183
+ ## 社区
184
+
185
+ | 微信 | 飞书 |
186
+ | --- | --- |
187
+ | <img src="docs/assets/community/wechat-qr.png" alt="微信群二维码" width="180"> | <img src="docs/assets/community/feishu-qr.png" alt="飞书群二维码" width="180"> |
188
+
189
+ ## 致谢
190
+
191
+ 深受以下项目的启发,并感谢作者们的开源
192
+ - codex-to-im
193
+ - lark-coding-agent-bridge
package/SECURITY.md ADDED
@@ -0,0 +1,34 @@
1
+ # Security
2
+
3
+ ## Credential Storage
4
+
5
+ CodeLark credentials are stored in `~/.codelark/config.env` and the local runtime data under `~/.codelark/`.
6
+
7
+ This repository never stores secrets in source control.
8
+
9
+ ## Log Redaction
10
+
11
+ Tokens and secrets should be masked in logs and workbench output. Only short tail fragments of secrets should ever be shown for confirmation or diagnosis.
12
+
13
+ ## Operational Model
14
+
15
+ CodeLark is a local single-user bridge:
16
+
17
+ - The bridge runs on the user's machine
18
+ - The web workbench is local-only
19
+ - IM authentication is delegated to each IM platform
20
+ - Access control is enforced through configured allowlists and channel bindings
21
+
22
+ ## Rotation Guidance
23
+
24
+ If a token is rotated or suspected to be exposed:
25
+
26
+ 1. Revoke the old credential on the IM platform
27
+ 2. Update the value in the local `codelark` workbench
28
+ 3. Restart the bridge from the workbench
29
+ 4. Review recent logs under `~/.codelark/logs/`
30
+
31
+ ## Home Directory
32
+
33
+ Current builds read and write only `~/.codelark/`.
34
+ If a legacy home directory from older releases still exists on a machine, treat it as historical leftover data rather than an active runtime home.
package/SKILL.md ADDED
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: codelark
3
+ description: Use this skill when working through CodeLark and you need Codex to send a local image or file back to the current IM chat. It teaches the attachment-send protocol and when to use it.
4
+ ---
5
+
6
+ # CodeLark attachment sending
7
+
8
+ Use this skill only when the user is chatting through CodeLark and wants you to send a generated or existing local artifact back to the IM chat.
9
+
10
+ ## What this skill does
11
+
12
+ CodeLark can send local files back to the chat after your reply. You trigger that by including one or more `<clk-send>...</clk-send>` blocks in your final answer.
13
+
14
+ Supported artifact kinds:
15
+
16
+ - `image`
17
+ - `file`
18
+
19
+ ## Required format
20
+
21
+ Output valid JSON inside the block, with no markdown fence.
22
+
23
+ Single artifact:
24
+
25
+ ```text
26
+ <clk-send>
27
+ {"type":"image","path":"D:\\path\\to\\result.png","caption":"optional caption"}
28
+ </clk-send>
29
+ ```
30
+
31
+ or
32
+
33
+ ```text
34
+ <clk-send>
35
+ {"type":"file","path":"D:\\path\\to\\report.pdf","caption":"optional caption"}
36
+ </clk-send>
37
+ ```
38
+
39
+ Multiple artifacts:
40
+
41
+ ```text
42
+ <clk-send>
43
+ {"items":[
44
+ {"type":"image","path":"D:\\path\\to\\result.png"},
45
+ {"type":"file","path":"D:\\path\\to\\report.pdf"}
46
+ ]}
47
+ </clk-send>
48
+ ```
49
+
50
+ ## Rules
51
+
52
+ - The `path` must be an absolute local path.
53
+ - The file must already exist before you emit the block.
54
+ - Keep normal user-facing explanation outside the `<clk-send>` block.
55
+ - Do not invent artifacts that were not actually created or found.
56
+ - If you are unsure whether the file exists, verify first.
57
+ - If the channel probably does not support the artifact well, explain that plainly instead of inventing a successful send.
58
+
59
+ ## When to use
60
+
61
+ Use this protocol when the user asks you to:
62
+
63
+ - send a generated chart, diagram, screenshot, or edited image
64
+ - send a report, archive, patch, PDF, spreadsheet, or other output file
65
+ - send the final result as an attachment instead of only pasting text
66
+
67
+ Do not use it for ordinary text replies.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "CodeLark"
3
+ short_description: "Help Codex send local files back to IM chats"
4
+ default_prompt: "Use $codelark when you need to send a generated image or file back to the current CodeLark chat."