@jiawei666/codesk 0.2.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/LICENSE +201 -0
- package/NOTICE +6 -0
- package/README.md +245 -0
- package/bin/codesk.js +48 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 OpenAI
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# CODESK
|
|
2
|
+
|
|
3
|
+
CODESK 是一个用 Rust + Ratatui 编写的终端工作台,用来在一个终端窗口里组织本机的 Codex 会话、查看工作区文件和浏览 Git 变更。
|
|
4
|
+
|
|
5
|
+
它不是 `codex-rs` 的编译版本,也不把 Codex 的代码嵌入自身。CODESK 运行时调用本机已经安装的 `codex` CLI:中间栏通过 PTY 承载 Codex 原生界面,左右两栏负责会话、项目和文件工作区。
|
|
6
|
+
|
|
7
|
+
## 当前界面
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
┌─ PROJECTS / SESSIONS ─┬─ CODEX ─────────────────────────┬─ FILES / CHANGES ─┐
|
|
11
|
+
│ 项目和会话 │ Codex 原生 PTY │ 文件树、预览、diff │
|
|
12
|
+
│ AGENT STATUS │ │ 编辑器 │
|
|
13
|
+
└────────────────────────┴──────────────────────────────────┴────────────────────┘
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- 左栏:按工作目录分组的 Codex 会话列表,以及 App Server 状态和额度信息。
|
|
17
|
+
- 中间栏:Codex 的原生终端界面,包括输入、审批、命令输出和会话历史。
|
|
18
|
+
- 右栏:当前项目的文件导航、Git changes、文件预览、彩色 diff 和受限编辑器。
|
|
19
|
+
- 底部:当前工作目录、Git 分支和当前焦点面板的快捷键提示。
|
|
20
|
+
|
|
21
|
+
面板外框始终存在;焦点面板只会切换标题和边框的高亮色。鼠标可以用于终端或文件区域的选择、滚动和点击,但不会因为鼠标移动而自动改变键盘焦点。键盘焦点由 `Tab`、`Shift-Tab`、`Ctrl-Tab`、`F7` 和 `F8` 控制。
|
|
22
|
+
|
|
23
|
+
## 已实现功能
|
|
24
|
+
|
|
25
|
+
### Codex PTY
|
|
26
|
+
|
|
27
|
+
- 启动 `codex --no-alt-screen -C <工作目录>`,恢复会话时额外传入 `--session <SESSION_ID>`。
|
|
28
|
+
- 保留 Codex 原生键盘、颜色、鼠标协议、审批交互和终端布局。
|
|
29
|
+
- 每个打开的会话拥有自己的 PTY 和虚拟终端 scrollback,最多保留 10,000 行历史。
|
|
30
|
+
- 新建会话首次打开时显示 CODESK 启动画面;恢复已有会话时直接进入 Codex 内容。
|
|
31
|
+
- CODESK 退出时只停止自己创建的 Codex PTY,不主动停止共享的 Codex App Server。
|
|
32
|
+
|
|
33
|
+
### 项目与会话
|
|
34
|
+
|
|
35
|
+
- 通过 `codex app-server proxy` 读取本机 App Server 的会话列表。
|
|
36
|
+
- 如果 App Server 尚未运行,会尝试执行 `codex app-server daemon start` 后重试。
|
|
37
|
+
- 会话按工作目录分组,项目按路径排序;同一项目下的会话按 `updatedAt` 从新到旧排列。
|
|
38
|
+
- 项目可折叠。项目收起后,仍会在项目行旁显示最新子会话状态。
|
|
39
|
+
- 状态只有三种有意义的显示:运行中的动态 spinner、完成后的 `✓` 和错误的 `×`;这两种终态标记都会保留约 3 秒后自动隐藏,无法识别的状态不额外占用状态位。
|
|
40
|
+
- 左栏初次加载、刷新和删除会话都有明确的进行中反馈;`Delete` 异步删除当前选中的会话。
|
|
41
|
+
- `Ctrl-N` 打开新会话目录对话框,默认填入左栏指针所在项目或会话的工作目录;支持路径编辑和 `Tab` 补全。
|
|
42
|
+
- 左栏当前选中行有底色;当焦点离开左栏时,蓝色指针会回到当前活动会话,不会产生第二条指针。
|
|
43
|
+
|
|
44
|
+
App Server 会话列表默认每 5 秒刷新一次,单次最多读取 100 个未归档会话。`AGENT STATUS` 显示连接状态、5 小时额度和周额度;如果 App Server 没有返回某项数据,就显示动态加载或 `--`,不会伪造百分比。
|
|
45
|
+
|
|
46
|
+
### 文件、Git changes 与预览
|
|
47
|
+
|
|
48
|
+
- 右栏从当前工作目录开始导航,不关闭文件树即可在旁边打开文件预览或 diff。
|
|
49
|
+
- `g` 在完整文件树和 Git changes 之间切换;文件名旁显示 Git 状态标记。
|
|
50
|
+
- `d` 查看当前文件的 `git diff HEAD`;未跟踪文件会生成对应的新文件 diff。
|
|
51
|
+
- diff 对新增行、删除行和 hunk 标记使用不同的背景色和前景色。
|
|
52
|
+
- 普通文本预览使用 `two-face` 提供的 `syntect` 语法定义和 Catppuccin Mocha 主题,按文件后缀及常见无后缀文件名识别多种语言;无法识别时安全退回纯文本。
|
|
53
|
+
- 目录导航和代码/ diff 阅读区各自维护独立选区。当前焦点面板按 `Ctrl-C` 只复制自己的选区,不会把两个面板拼接或互相覆盖。
|
|
54
|
+
- 右栏打开预览后,文件树保持可见;`Esc` 先关闭编辑器或预览,再次按下才关闭右栏。
|
|
55
|
+
- `Ctrl-F` 在右栏打开搜索面板,默认搜索文件名和路径;结果按目录树展示。
|
|
56
|
+
- 搜索面板支持文件搜索和全局代码搜索。代码结果按目录、文件和匹配行分组,打开结果后会定位到目标行并高亮匹配内容。
|
|
57
|
+
- 搜索通过后台 `ripgrep` 任务执行,输入变化会取消旧任务,结果会流式显示且最多保留 500 条,不阻塞中间 PTY。
|
|
58
|
+
|
|
59
|
+
### 受限编辑器
|
|
60
|
+
|
|
61
|
+
- 在普通文件预览中按 `e` 进入编辑;diff 视图不能直接编辑。
|
|
62
|
+
- 支持插入、删除、方向移动、分页、行号、保存和从磁盘重新加载。
|
|
63
|
+
- `Ctrl-S` 保存,`Ctrl-Shift-R` 放弃本地修改并从磁盘重载。
|
|
64
|
+
- 文件必须位于当前工作区内,禁止编辑符号链接、二进制文件和超过 256 KiB 的文件。
|
|
65
|
+
- 保存前会检查磁盘快照;文件被其他进程修改后,CODESK 会拒绝覆盖并要求先重载。
|
|
66
|
+
|
|
67
|
+
## 运行要求
|
|
68
|
+
|
|
69
|
+
- Rust 工具链,能够编译 Rust 2024 edition。
|
|
70
|
+
- 本机可以执行 `codex --version`;如果 `codex` 不在 `PATH`,使用 `--codex-path` 指定路径。
|
|
71
|
+
- 当前工作目录最好是 Git 仓库;Git 用于分支、文件状态和 diff,缺少 Git 时这些信息会退化为空状态。
|
|
72
|
+
- 全局代码搜索依赖 `rg`(ripgrep)在 `PATH` 中可执行;缺少时右栏会显示搜索启动错误。
|
|
73
|
+
- 系统需要能够提供终端剪贴板能力;终端选择和文件选择复制都使用系统剪贴板。
|
|
74
|
+
|
|
75
|
+
## 本地运行
|
|
76
|
+
|
|
77
|
+
在仓库根目录执行:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
cargo run --
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
常用启动参数:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# 指定工作目录
|
|
87
|
+
cargo run -- --cwd /path/to/project
|
|
88
|
+
|
|
89
|
+
# 指定 Codex 可执行文件
|
|
90
|
+
cargo run -- --codex-path /path/to/codex
|
|
91
|
+
|
|
92
|
+
# 启动并恢复已有会话
|
|
93
|
+
cargo run -- --cwd /path/to/project --session SESSION_ID
|
|
94
|
+
|
|
95
|
+
# 查看参数说明
|
|
96
|
+
cargo run -- --help
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
编译 release 二进制:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cargo build --release
|
|
103
|
+
./target/release/codesk --cwd /path/to/project
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
命令行参数只有以下三项:
|
|
107
|
+
|
|
108
|
+
| 参数 | 说明 | 默认值 |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| `--codex-path PATH` | Codex CLI 的可执行文件路径 | `codex` |
|
|
111
|
+
| `--cwd DIR` | 初始工作目录 | 当前目录 |
|
|
112
|
+
| `--session SESSION_ID` | 要恢复的 Codex 会话 ID | 新建会话 |
|
|
113
|
+
|
|
114
|
+
## 快捷键
|
|
115
|
+
|
|
116
|
+
### 全局与面板焦点
|
|
117
|
+
|
|
118
|
+
| 快捷键 | 作用 |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `Tab` | 顺时针切换已打开的面板;中间栏正在输入 `/...` 命令时交给 Codex 补全 |
|
|
121
|
+
| `Shift-Tab` | 反向切换面板;中间栏正在输入 `/...` 命令时交给 Codex |
|
|
122
|
+
| `Ctrl-Tab` / `Ctrl-Shift-Tab` | 强制切换面板,即使中间栏正在输入 slash command |
|
|
123
|
+
| `F7` | 显示/隐藏左侧项目和会话栏 |
|
|
124
|
+
| `F8` | 显示/隐藏右侧文件栏 |
|
|
125
|
+
| `Ctrl-F` | 打开右侧搜索面板,默认进入文件搜索 |
|
|
126
|
+
| `Ctrl-←` / `Ctrl-→` | 在文件搜索和代码搜索之间切换 |
|
|
127
|
+
| `Esc` | 左栏焦点返回中间栏;右栏按层关闭编辑器、预览和右栏 |
|
|
128
|
+
| `Ctrl-Q` | 打开退出确认;`Enter`/`y` 确认,`Esc`/`n` 取消 |
|
|
129
|
+
| `Ctrl-N` | 打开新建会话目录对话框;不会在左栏常驻 `New session` 行 |
|
|
130
|
+
|
|
131
|
+
### 中间 Codex 面板
|
|
132
|
+
|
|
133
|
+
| 快捷键/操作 | 作用 |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| 普通键盘输入 | 原样发送给 Codex PTY |
|
|
136
|
+
| `Alt-↑/↓` | 上下滚动 PTY 历史 |
|
|
137
|
+
| `Alt-PageUp/PageDown` | 按页滚动 PTY 历史 |
|
|
138
|
+
| `Alt-Home/End` | 跳到 PTY 历史顶部/当前屏幕 |
|
|
139
|
+
| 鼠标左键拖拽 | 选择终端文本;没有选区时点击仍交给 Codex 的鼠标协议 |
|
|
140
|
+
| 鼠标滚轮 | 优先滚动中间栏自己的终端历史 |
|
|
141
|
+
| `Ctrl-C` | 有终端选区时复制;没有选区时发送给 Codex |
|
|
142
|
+
| `Ctrl-Shift-C` | 有终端选区时复制 |
|
|
143
|
+
|
|
144
|
+
### 左侧项目与会话栏
|
|
145
|
+
|
|
146
|
+
| 快捷键/操作 | 作用 |
|
|
147
|
+
| --- | --- |
|
|
148
|
+
| `↑` / `↓` | 选择项目或会话 |
|
|
149
|
+
| `Home` / `End` | 跳到列表首尾 |
|
|
150
|
+
| `←` / `→` | 折叠/展开当前项目;会话行上也会作用于其所属项目 |
|
|
151
|
+
| `Enter` | 恢复选中的会话;在项目行打开以该项目目录为默认值的新会话弹窗 |
|
|
152
|
+
| `Delete` | 异步删除选中的已有会话 |
|
|
153
|
+
| `r` | 从 App Server 刷新会话列表 |
|
|
154
|
+
| 鼠标滚轮 | 按列表方向移动选择 |
|
|
155
|
+
| 鼠标左键 | 选择并打开会话 |
|
|
156
|
+
|
|
157
|
+
### 右侧文件栏
|
|
158
|
+
|
|
159
|
+
| 快捷键/操作 | 作用 |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| `↑` / `↓` | 选择文件或目录 |
|
|
162
|
+
| `PageUp` / `PageDown` | 按页移动选择或预览滚动 |
|
|
163
|
+
| `←` / `Backspace` | 返回父目录;在根目录关闭预览 |
|
|
164
|
+
| `→` / `Enter` | 进入目录或打开文件预览 |
|
|
165
|
+
| `g` | 切换完整文件树 / Git changes |
|
|
166
|
+
| `d` | 打开当前文件的 diff;预览中切换文件 / diff |
|
|
167
|
+
| `r` | 刷新目录或重新读取当前预览 |
|
|
168
|
+
| `e` | 在普通文件预览中进入编辑器 |
|
|
169
|
+
| 预览中的 `Esc` / `Backspace` | 关闭当前预览;编辑器用 `Esc`(无未保存修改时)关闭 |
|
|
170
|
+
| `Ctrl-S` | 保存编辑器内容 |
|
|
171
|
+
| `Ctrl-Shift-R` | 从磁盘重载并丢弃本地编辑 |
|
|
172
|
+
| 鼠标左键拖拽 | 选择目录文本或代码文本 |
|
|
173
|
+
| `Ctrl-C` | 复制当前右栏选区 |
|
|
174
|
+
|
|
175
|
+
搜索面板打开时:
|
|
176
|
+
|
|
177
|
+
| 快捷键/操作 | 作用 |
|
|
178
|
+
| --- | --- |
|
|
179
|
+
| `Tab` / `Shift-Tab` | 在模式标签、搜索框和结果树之间切换焦点 |
|
|
180
|
+
| `Ctrl-←` / `Ctrl-→` | 切换文件搜索 / 代码搜索 |
|
|
181
|
+
| `↑` / `↓` | 选择搜索结果 |
|
|
182
|
+
| `Enter` | 文件搜索打开文件;代码搜索打开文件并定位匹配行 |
|
|
183
|
+
| `Esc` | 关闭搜索面板并恢复普通文件树 |
|
|
184
|
+
| 鼠标点击模式标签 | 切换搜索方式 |
|
|
185
|
+
|
|
186
|
+
## 项目结构
|
|
187
|
+
|
|
188
|
+
```text
|
|
189
|
+
codesk/
|
|
190
|
+
├── src/main.rs # 参数解析和程序入口
|
|
191
|
+
├── src/app.rs # TUI 生命周期、焦点、会话切换
|
|
192
|
+
├── src/app_server.rs # App Server proxy、会话和额度读取
|
|
193
|
+
├── src/terminal.rs # Codex PTY、虚拟终端和终端选区
|
|
194
|
+
├── src/search.rs # 右栏搜索面板和搜索结果树
|
|
195
|
+
├── src/search_engine.rs # 后台 ripgrep 搜索任务和结果解析
|
|
196
|
+
├── src/files.rs # 文件树、Git 状态、预览、diff 和复制
|
|
197
|
+
├── src/editor.rs # 工作区边界内的轻量编辑器
|
|
198
|
+
├── src/syntax.rs # 文件预览语法着色
|
|
199
|
+
├── src/ui.rs # 三栏布局、状态标记和快捷键提示
|
|
200
|
+
├── src/theme.rs # CODESK 和代码预览颜色
|
|
201
|
+
├── bin/codesk.js # npm 主包的跨平台 launcher
|
|
202
|
+
├── scripts/ # npm 平台包生成和版本检查脚本
|
|
203
|
+
├── package.json # npm 主包元数据
|
|
204
|
+
└── .codex/skills/ # 项目级 Codex 工作流 skill
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## 开发检查
|
|
208
|
+
|
|
209
|
+
提交 Rust 代码前建议执行:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
cargo fmt --all
|
|
213
|
+
cargo test
|
|
214
|
+
cargo build --release
|
|
215
|
+
git diff --check
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
UI 行为、快捷键、文件预览和会话状态的变化应优先补充对应的 Rust 测试;当前测试位于各源码模块的 `#[cfg(test)]` 区域。
|
|
219
|
+
|
|
220
|
+
## 发布方式
|
|
221
|
+
|
|
222
|
+
CODESK 的发行方式是统一使用 npm 分发跨平台预编译二进制:
|
|
223
|
+
|
|
224
|
+
- 主 npm 包提供 `codesk` 命令入口;
|
|
225
|
+
- 平台 npm 包分别承载 Linux、macOS 和 Windows 的 Rust 二进制;
|
|
226
|
+
- 主包根据运行平台选择对应平台包;
|
|
227
|
+
- GitHub 用于源码、版本 tag 和可选 Release,用户安装入口仍然是 npm。
|
|
228
|
+
|
|
229
|
+
当前仓库已经包含 npm 主包 launcher 和平台包生成脚本。发布流程在本地完成:先构建并检查五个平台包,再按顺序发布平台包和主包;平台包不会提交到 Git,而是在本地发布前生成。
|
|
230
|
+
|
|
231
|
+
npm 二进制包的版本同步、平台矩阵、`npm pack --dry-run`、认证和发布顺序由项目级 skill 约束:
|
|
232
|
+
[`github-npm-release`](.codex/skills/github-npm-release/SKILL.md)。首个 `v0.1.0` npm 版本完成发布前,本地仍使用上面的 `cargo run` 和 `cargo build --release`;发布完成后,用户安装命令为:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
npm install -g @jiawei666/codesk
|
|
236
|
+
codesk
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## 设计边界
|
|
240
|
+
|
|
241
|
+
- CODESK 不编译或修改 `codex-rs`。
|
|
242
|
+
- CODESK 不接管 Codex 的会话存储;会话元数据通过 App Server 读取。
|
|
243
|
+
- App Server 是会话和额度的控制/元数据平面,PTY 是中间栏的交互/渲染平面。
|
|
244
|
+
- 右侧文件操作始终受当前工作区边界限制,不提供任意路径编辑能力。
|
|
245
|
+
- CODESK 只负责自己创建的 PTY;退出时不杀掉其他 Codex 客户端或共享 daemon。
|
package/bin/codesk.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("node:child_process");
|
|
4
|
+
|
|
5
|
+
const platformPackages = {
|
|
6
|
+
"darwin-arm64": "@jiawei666/codesk-darwin-arm64",
|
|
7
|
+
"darwin-x64": "@jiawei666/codesk-darwin-x64",
|
|
8
|
+
"linux-arm64": "@jiawei666/codesk-linux-arm64",
|
|
9
|
+
"linux-x64": "@jiawei666/codesk-linux-x64",
|
|
10
|
+
"win32-x64": "@jiawei666/codesk-win32-x64"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
14
|
+
const packageName = platformPackages[platformKey];
|
|
15
|
+
|
|
16
|
+
if (!packageName) {
|
|
17
|
+
console.error(`CODESK does not provide a binary for ${platformKey}.`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const binaryName = process.platform === "win32" ? "codesk.exe" : "codesk";
|
|
22
|
+
let binaryPath;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
binaryPath = require.resolve(`${packageName}/bin/${binaryName}`);
|
|
26
|
+
} catch {
|
|
27
|
+
console.error(`The CODESK binary package ${packageName} is not installed.`);
|
|
28
|
+
console.error("Reinstall @jiawei666/codesk to restore the platform binary.");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
33
|
+
stdio: "inherit",
|
|
34
|
+
windowsHide: false
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
child.on("error", (error) => {
|
|
38
|
+
console.error(`Failed to start CODESK: ${error.message}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
child.on("exit", (code, signal) => {
|
|
43
|
+
if (signal) {
|
|
44
|
+
process.kill(process.pid, signal);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
process.exit(code ?? 1);
|
|
48
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jiawei666/codesk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A Rust terminal workbench for the installed Codex CLI.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"bin": {
|
|
7
|
+
"codesk": "bin/codesk.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"NOTICE"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/jiawei666/codesk.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/jiawei666/codesk/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/jiawei666/codesk#readme",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"codex",
|
|
25
|
+
"tui",
|
|
26
|
+
"terminal",
|
|
27
|
+
"rust",
|
|
28
|
+
"cli"
|
|
29
|
+
],
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18"
|
|
33
|
+
},
|
|
34
|
+
"optionalDependencies": {
|
|
35
|
+
"@jiawei666/codesk-darwin-arm64": "0.2.0",
|
|
36
|
+
"@jiawei666/codesk-darwin-x64": "0.2.0",
|
|
37
|
+
"@jiawei666/codesk-linux-arm64": "0.2.0",
|
|
38
|
+
"@jiawei666/codesk-linux-x64": "0.2.0",
|
|
39
|
+
"@jiawei666/codesk-win32-x64": "0.2.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"registry": "https://registry.npmjs.org/"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"check:release": "node scripts/check-release-version.mjs",
|
|
47
|
+
"pack:check": "npm pack --dry-run"
|
|
48
|
+
}
|
|
49
|
+
}
|