@cjhyy/code-shell 0.6.0-rc.11 → 0.6.0-rc.13
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/CHANGELOG.md +28 -0
- package/README.md +32 -18
- package/README.zh-CN.md +281 -0
- package/assets/codeshell-desktop-screenshot-en.png +0 -0
- package/assets/codeshell-dog-icon.png +0 -0
- package/assets/codeshell-promo.png +0 -0
- package/docs/architecture/images/overview-runtime-layers.png +0 -0
- package/package.json +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -115,6 +115,34 @@ breaking.
|
|
|
115
115
|
|
|
116
116
|
### Fixed
|
|
117
117
|
|
|
118
|
+
- **Cookie credentials now target the browser panel's per-session partition.**
|
|
119
|
+
The credential service was hardcoded to the shared `persist:browser`
|
|
120
|
+
partition while browser tabs run under per-session `persist:browser:<bucket>`
|
|
121
|
+
partitions, so captured/injected/switched cookies never reached the session
|
|
122
|
+
the user was actually driving. Capture, restore, and the AI-driven
|
|
123
|
+
`InjectCredential` path now resolve the active guest's real partition
|
|
124
|
+
(`restoreCookiesToBrowser` accepts a live `Session`), and the main-process
|
|
125
|
+
partition builder matches the renderer's cleaning rule exactly. Default
|
|
126
|
+
restore mode is now `merge` (only `clear` on an explicit "clean switch").
|
|
127
|
+
- **New-conversation Goal / permission / model toggles are no longer dropped on
|
|
128
|
+
the first send.** A draft's pre-send toggles live under the shared draft
|
|
129
|
+
bucket, but the first send read them from the freshly-created real session
|
|
130
|
+
bucket (empty) — so enabling Goal, then typing and sending, silently failed to
|
|
131
|
+
set the goal even though the Goal icon stayed lit. The send now reads the
|
|
132
|
+
draft bucket's overrides before migrating them onto the real session.
|
|
133
|
+
- **Compaction keeps shrinking when one summary pass isn't enough.** After a
|
|
134
|
+
summary compaction the context manager returned even if the re-estimated
|
|
135
|
+
token count was still over the gate; it now continues down the
|
|
136
|
+
snip → window → emergency ladder until under budget, using the real
|
|
137
|
+
prompt-token anchor when available instead of a pure heuristic.
|
|
138
|
+
- **Concurrent sessions no longer cross log session IDs.** `Engine.run()` no
|
|
139
|
+
longer writes a module-level `setCurrentSid` fallback before the
|
|
140
|
+
AsyncLocalStorage context is established, so two sessions running at once
|
|
141
|
+
can't overwrite each other's sid on disk vs. in the logs.
|
|
142
|
+
- **TUI `run` / `runs` honor the model connection's context window.** Both
|
|
143
|
+
non-REPL entry points now use the active model connection's
|
|
144
|
+
`maxContextTokens` (falling back to the global default) instead of always
|
|
145
|
+
using `settings.context.maxTokens`, matching the REPL path.
|
|
118
146
|
- Step-gap steering no longer leaves a duplicate user bubble: a queued
|
|
119
147
|
steer entry that is interrupted (or that survives into the next turn) is
|
|
120
148
|
withdrawn before the message is re-sent.
|
package/README.md
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="assets/codeshell-dog-icon.png" alt="CodeShell
|
|
2
|
+
<img src="assets/codeshell-dog-icon.png" alt="CodeShell mascot" width="120" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# CodeShell
|
|
6
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="README.md">English</a> · <a href="README.zh-CN.md">简体中文</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
7
11
|
<p align="center">
|
|
8
12
|
<strong>A general-purpose AI agent orchestration framework — terminal, headless, and a full desktop app.</strong>
|
|
9
13
|
</p>
|
|
10
14
|
|
|
11
15
|
<p align="center">
|
|
12
|
-
<img src="assets/codeshell-
|
|
16
|
+
<img src="assets/codeshell-promo.png" alt="CodeShell desktop AI agent orchestration promotional image" width="860" />
|
|
13
17
|
</p>
|
|
14
18
|
|
|
15
19
|
CodeShell is one orchestration engine wearing three faces:
|
|
@@ -20,7 +24,7 @@ CodeShell is one orchestration engine wearing three faces:
|
|
|
20
24
|
|
|
21
25
|
The core is deliberately **domain-agnostic**. The turn loop, context management, permissions, MCP integration, hooks, tasks, cron, sub-agents, sessions, and memory all stay generic; coding behavior is just a *preset* layered on top — not baked into the engine. (See `packages/core/CONTRIBUTING.md`: "core only carries mechanism, not policy.")
|
|
22
26
|
|
|
23
|
-
> Status: **0.
|
|
27
|
+
> Status: **0.6.0-rc.12**, preparing for beta. The desktop app is the headline product; the CLI and SDK share the same core engine.
|
|
24
28
|
|
|
25
29
|
---
|
|
26
30
|
|
|
@@ -63,6 +67,12 @@ bun run dev # launches the desktop app in dev mode
|
|
|
63
67
|
|
|
64
68
|
It gives you chat with streaming output, a side-by-side file / browser / terminal / diff panel dock, model & credential management, an extensions marketplace, automation/cron scheduling, persistent goals, memory, and a phone remote — all driving the same core engine via per-session agent worker processes.
|
|
65
69
|
|
|
70
|
+
### Desktop preview
|
|
71
|
+
|
|
72
|
+
<p align="center">
|
|
73
|
+
<img src="assets/codeshell-desktop-screenshot-en.png" alt="Actual CodeShell desktop app screenshot captured with Playwright" width="860" />
|
|
74
|
+
</p>
|
|
75
|
+
|
|
66
76
|
---
|
|
67
77
|
|
|
68
78
|
## Features
|
|
@@ -109,15 +119,17 @@ Presets select the system prompt, the built-in tool set, and permission defaults
|
|
|
109
119
|
|
|
110
120
|
### Built-in tools
|
|
111
121
|
|
|
112
|
-
|
|
122
|
+
The default `general` preset whitelists 47 built-ins. The CLI defaults to
|
|
123
|
+
`terminal-coding`, which adds coding extras. Runtime guards may hide tools that
|
|
124
|
+
need unavailable providers, credentials, cookies, or an active goal.
|
|
113
125
|
|
|
114
|
-
- **File**: `Read`, `Write`, `Edit`, `Glob`, `Grep`
|
|
115
|
-
- **
|
|
116
|
-
- **
|
|
117
|
-
- **Planning /
|
|
118
|
-
- **
|
|
119
|
-
- **
|
|
120
|
-
- **
|
|
126
|
+
- **File / workspace**: `Read`, `Write`, `Edit`, `ApplyPatch`, `Glob`, `Grep`
|
|
127
|
+
- **Shell / execution**: `Bash`, `BashOutput`, `KillShell`, `ListShells`, `PowerShell`, `REPL`, `Sleep`
|
|
128
|
+
- **Web / media / browser**: `browser_observe`, `browser_act`, `browser_navigate`, `WebSearch`, `WebFetch`, `GenerateImage`, `GenerateVideo`
|
|
129
|
+
- **Planning / orchestration**: `AskUserQuestion`, `EnterPlanMode`, `ExitPlanMode`, `ToolSearch`, `TodoWrite`, `Agent`, `AgentCancel`, `DriveAgent`, `DriveClaudeCode`, `CheckQuota`
|
|
130
|
+
- **Automation / integration**: `CronCreate`, `CronDelete`, `CronList`, `Config`, `Skill`, `MCPTool`, `ListMcpResources`, `ReadMcpResource`, `EditModelCatalog`
|
|
131
|
+
- **Memory / credentials / goals**: `MemoryList`, `MemoryRead`, `MemorySave`, `MemoryDelete`, `UseCredential`, `InjectCredential`, `complete_goal`, `cancel_goal`
|
|
132
|
+
- **Terminal-coding preset extras**: `EnterWorktree`, `ExitWorktree`, `NotebookEdit`, `LSP`, `Brief`, `Arena`
|
|
121
133
|
|
|
122
134
|
---
|
|
123
135
|
|
|
@@ -181,16 +193,16 @@ CodeShell's terminal UI defaults to **fullscreen** (alt-screen + ScrollBox) —
|
|
|
181
193
|
|
|
182
194
|
Opt out at startup with `CODESHELL_FULLSCREEN=0|false|off`, or toggle at runtime with `/fullscreen off`. Flow mode lets the transcript flow into the terminal's native scrollback (useful if you prefer keeping shell history above CodeShell visible).
|
|
183
195
|
|
|
184
|
-
### Stream idle watchdog (
|
|
196
|
+
### Stream idle watchdog (on by default)
|
|
185
197
|
|
|
186
|
-
|
|
198
|
+
The OpenAI-compatible provider aborts any LLM stream idle for `CODESHELL_STREAM_IDLE_TIMEOUT_MS` ms (default `90000`) without a chunk, then retries via the existing `withRetry` policy, capped by `CODESHELL_STREAM_WATCHDOG_RETRIES` (default `2`). This bounds upstream hangs at ~90 s instead of indefinitely. Set `CODESHELL_ENABLE_STREAM_WATCHDOG=0` to opt out. User-initiated aborts (Esc / Ctrl+C) are never retried.
|
|
187
199
|
|
|
188
200
|
---
|
|
189
201
|
|
|
190
202
|
## Architecture
|
|
191
203
|
|
|
192
204
|
<p align="center">
|
|
193
|
-
<img src="docs/
|
|
205
|
+
<img src="docs/architecture/images/overview-runtime-layers.png" alt="CodeShell runtime layering and protocol flow architecture diagram" width="860" />
|
|
194
206
|
</p>
|
|
195
207
|
|
|
196
208
|
At a high level, CodeShell routes CLI, headless, SDK, and desktop clients through the same engine runtime:
|
|
@@ -220,7 +232,7 @@ packages/
|
|
|
220
232
|
├── desktop/ # Electron desktop client + agent worker bridge + mobile remote app
|
|
221
233
|
└── cdp/ # Environment-agnostic CDP browser-action layer (no Playwright)
|
|
222
234
|
|
|
223
|
-
assets/ # README / product images (mascot, hero)
|
|
235
|
+
assets/ # README / product images (mascot, promo hero, Playwright desktop screenshots)
|
|
224
236
|
|
|
225
237
|
docs/
|
|
226
238
|
├── architecture/ # System architecture chapters + feature inventory (see architecture/README.md)
|
|
@@ -237,15 +249,17 @@ scripts/ # Build, release, and repo maintenance scripts
|
|
|
237
249
|
```bash
|
|
238
250
|
bun install
|
|
239
251
|
bun run build # build core + tui + meta package
|
|
240
|
-
bun run typecheck # core + tui
|
|
252
|
+
bun run typecheck # root core + tui check; currently not a clean gate
|
|
241
253
|
bun test # core / tui test suites
|
|
242
254
|
|
|
243
255
|
# Desktop has its OWN typecheck and build (the root checks do NOT cover it):
|
|
244
256
|
cd packages/desktop
|
|
245
|
-
|
|
246
|
-
bun run build
|
|
257
|
+
bun run typecheck
|
|
258
|
+
bun run build
|
|
247
259
|
```
|
|
248
260
|
|
|
261
|
+
> Current caveat: `bun run typecheck` at the repo root reports a pre-existing test typing error in `packages/core/src/tool-system/builtin/drive-claude-code.test.ts:158`. Use it for signal, but do not treat it as a clean gate until that is fixed.
|
|
262
|
+
|
|
249
263
|
`bun run dev` launches the desktop app. For the TUI in dev: `bun run dev:tui`.
|
|
250
264
|
|
|
251
265
|
> The desktop renderer uses **shadcn/ui + Tailwind v4** (zinc theme) and imports no core code — it is a thin client over `window.codeshell.*`. See `packages/desktop/CLAUDE.md` for renderer conventions.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/codeshell-dog-icon.png" alt="CodeShell mascot" width="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# CodeShell
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="README.md">English</a> · <a href="README.zh-CN.md">简体中文</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>一个通用 AI agent 编排框架:覆盖终端、headless 运行和完整桌面应用。</strong>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="assets/codeshell-promo.png" alt="CodeShell 桌面端 AI agent 编排宣传图" width="860" />
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
CodeShell 是同一个编排引擎的三种形态:
|
|
20
|
+
|
|
21
|
+
- **终端 CLI** (`code-shell`):用于交互式和 headless agent 运行;
|
|
22
|
+
- **Electron 桌面应用**:提供聊天、文件/浏览器/终端/diff 面板、模型与凭证管理、扩展市场、自动化和手机远程控制;
|
|
23
|
+
- **程序化 SDK** (`import { Engine } from "@cjhyy/code-shell"`):可把引擎嵌入你自己的产品。
|
|
24
|
+
|
|
25
|
+
核心引擎保持**领域无关**。turn loop、上下文管理、权限、MCP 集成、hooks、tasks、cron、sub-agents、sessions 和 memory 都是通用机制;“写代码助手”只是叠在引擎上的一个 preset,而不是写死在核心里。
|
|
26
|
+
|
|
27
|
+
> 状态:**0.6.0-rc.12**,正在准备 beta。桌面应用是当前主产品;CLI 和 SDK 共享同一个核心引擎。
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 为什么是 CodeShell
|
|
32
|
+
|
|
33
|
+
- **一个引擎,多种产品**:同一套 runtime 可以驱动编码、研究、自动化、浏览器任务和长期工作流。
|
|
34
|
+
- **终端优先,也适合 headless 和桌面**:可在终端交互运行,也可执行一次性 headless 任务,或者使用完整可视化桌面端。
|
|
35
|
+
- **默认具备权限意识**:写文件、shell、git 等高影响操作通过显式审批流程控制,并支持按 session/project 缓存规则。
|
|
36
|
+
- **端到端可扩展**:presets、内置工具、MCP servers、hooks、skills、plugins、sub-agents 和 cron jobs 都是一等能力。
|
|
37
|
+
- **本地优先与隐私友好**:sessions、transcripts、credentials 和 memory 存在 `~/.code-shell/`;凭证文件以 owner-only (`0o600`) 权限写入。
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 快速开始
|
|
42
|
+
|
|
43
|
+
### CLI
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 默认 CLI preset:终端编码助手(交互式 REPL)
|
|
47
|
+
npx @cjhyy/code-shell
|
|
48
|
+
|
|
49
|
+
# 作为通用编排器运行
|
|
50
|
+
npx @cjhyy/code-shell --preset general
|
|
51
|
+
|
|
52
|
+
# 一次性 / headless 执行
|
|
53
|
+
npx @cjhyy/code-shell run --preset general \
|
|
54
|
+
"Create a long-running research plan and track it with tasks"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
需要 **Node.js >= 20.10**。
|
|
58
|
+
|
|
59
|
+
### 桌面应用
|
|
60
|
+
|
|
61
|
+
桌面应用位于 `packages/desktop`。从源码启动:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
bun install
|
|
65
|
+
bun run dev # 以开发模式启动桌面应用
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
桌面端提供流式聊天、并排文件/浏览器/终端/diff 面板、模型与凭证管理、扩展市场、自动化/cron 调度、持久目标、memory 和手机远程控制。所有能力都通过每个 session 的 agent worker 进程驱动同一个核心引擎。
|
|
69
|
+
|
|
70
|
+
### 桌面预览
|
|
71
|
+
|
|
72
|
+
<p align="center">
|
|
73
|
+
<img src="assets/codeshell-desktop-screenshot-en.png" alt="使用 Playwright 捕获的 CodeShell 桌面应用真实截图" width="860" />
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 功能
|
|
79
|
+
|
|
80
|
+
### 核心引擎 (`@cjhyy/code-shell-core`)
|
|
81
|
+
|
|
82
|
+
- turn-based agent loop,支持流式输出和逐步生命周期事件;
|
|
83
|
+
- 上下文压缩与持久 session 存储;
|
|
84
|
+
- 带权限门禁的工具执行,支持 session/project 规则缓存和链式命令防护;
|
|
85
|
+
- hook pipeline 与完整 MCP client 集成;
|
|
86
|
+
- 一等支持 **tasks、sub-agents、cron 和 sleep**,适合长期、自我节奏化工作流;
|
|
87
|
+
- **Persistent goals**:通过 stop-hook judge 和显式 `complete_goal` 声明推进目标;
|
|
88
|
+
- **Memory + Dream**:每轮注入 memory,并通过 LLM consolidation 进行整理;
|
|
89
|
+
- **统一模型目录**:text / image / video providers 使用同一套 tag-based config;
|
|
90
|
+
- 后台 shell jobs、成本追踪和 turn-level 文件 undo/redo。
|
|
91
|
+
|
|
92
|
+
### Presets
|
|
93
|
+
|
|
94
|
+
| Preset | 用途 | 额外工具 |
|
|
95
|
+
|--------|------|----------|
|
|
96
|
+
| `general` | 通用编排、研究、自动化、长期任务 | 仅核心编排工具 |
|
|
97
|
+
| `terminal-coding` | 终端原生编码助手 | `EnterWorktree`, `ExitWorktree`, `NotebookEdit`, `LSP`, `Brief`, `Arena` |
|
|
98
|
+
|
|
99
|
+
Preset 决定 system prompt、内置工具集和权限默认值。可通过 SDK、CLI `--preset` 参数或 settings 配置。
|
|
100
|
+
|
|
101
|
+
### 终端体验 (`@cjhyy/code-shell-tui`)
|
|
102
|
+
|
|
103
|
+
- 基于 Ink 的交互式 REPL,支持 fullscreen/flow 模式、vim-mode 输入和输入历史;
|
|
104
|
+
- headless `run` 模式,以及 `repl`、`sessions`、`runs` 子命令;
|
|
105
|
+
- slash commands、`@` 文件/skill 搜索、命令补全和 REPL 内 cron 调度;
|
|
106
|
+
- `Shift+Tab` 切换权限模式、transcript 浏览、session resume 和成本/用量报告。
|
|
107
|
+
|
|
108
|
+
### 桌面应用 (`@cjhyy/code-shell-desktop`)
|
|
109
|
+
|
|
110
|
+
- **Chat**:流式输出、图片附件(上传/拖拽/粘贴)、运行时 steering/queue 模型;
|
|
111
|
+
- **Panel dock**:对话旁的 Files、Browser、Terminal、Diff/Review 面板;
|
|
112
|
+
- **Model catalog & connections**:providers/models 的完整 CRUD、按公司复用凭证、参数文档联动 UI;
|
|
113
|
+
- **Credentials**:API keys、浏览器 cookie 登录、多账号 cookie 凭证和权限 token/link gates;
|
|
114
|
+
- **Extensions**:plugin/skill/MCP 管理、marketplace、capability overview 和 sub-agent role 管理;
|
|
115
|
+
- **Automation**:cron/scheduled tasks、每个任务的 transcript/memory,以及长任务 runs 视图;
|
|
116
|
+
- **Persistent goals**、memory 管理、hooks 配置和中英文 i18n;
|
|
117
|
+
- **Phone remote**:通过本地 WebSocket 从手机控制桌面 session;
|
|
118
|
+
- onboarding、trust gate、app updater、command palette (`⌘K`)、跨项目 session 搜索 (`⌘P`) 和 transcript 搜索 (`⌘F`)。
|
|
119
|
+
|
|
120
|
+
### 内置工具
|
|
121
|
+
|
|
122
|
+
默认 `general` preset 白名单包含 47 个内置工具。CLI 默认使用
|
|
123
|
+
`terminal-coding` preset,并额外加入编码相关工具。运行时 guard 可能隐藏当前不可用的
|
|
124
|
+
provider、凭证、cookie 或 goal 相关工具。
|
|
125
|
+
|
|
126
|
+
- **File / workspace**:`Read`, `Write`, `Edit`, `ApplyPatch`, `Glob`, `Grep`
|
|
127
|
+
- **Shell / execution**:`Bash`, `BashOutput`, `KillShell`, `ListShells`, `PowerShell`, `REPL`, `Sleep`
|
|
128
|
+
- **Web / media / browser**:`browser_observe`, `browser_act`, `browser_navigate`, `WebSearch`, `WebFetch`, `GenerateImage`, `GenerateVideo`
|
|
129
|
+
- **Planning / orchestration**:`AskUserQuestion`, `EnterPlanMode`, `ExitPlanMode`, `ToolSearch`, `TodoWrite`, `Agent`, `AgentCancel`, `DriveAgent`, `DriveClaudeCode`, `CheckQuota`
|
|
130
|
+
- **Automation / integration**:`CronCreate`, `CronDelete`, `CronList`, `Config`, `Skill`, `MCPTool`, `ListMcpResources`, `ReadMcpResource`, `EditModelCatalog`
|
|
131
|
+
- **Memory / credentials / goals**:`MemoryList`, `MemoryRead`, `MemorySave`, `MemoryDelete`, `UseCredential`, `InjectCredential`, `complete_goal`, `cancel_goal`
|
|
132
|
+
- **Terminal-coding preset extras**:`EnterWorktree`, `ExitWorktree`, `NotebookEdit`, `LSP`, `Brief`, `Arena`
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 程序化 API
|
|
137
|
+
|
|
138
|
+
meta package 会重新导出核心引擎,所以旧的 SDK import 仍然可用:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { Engine } from "@cjhyy/code-shell";
|
|
142
|
+
|
|
143
|
+
const generalEngine = new Engine({
|
|
144
|
+
llm: {
|
|
145
|
+
provider: "openai",
|
|
146
|
+
model: "gpt-4.1",
|
|
147
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
148
|
+
},
|
|
149
|
+
preset: "general",
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const codingEngine = new Engine({
|
|
153
|
+
llm: {
|
|
154
|
+
provider: "openai",
|
|
155
|
+
model: "gpt-4.1",
|
|
156
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
157
|
+
},
|
|
158
|
+
preset: "terminal-coding",
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
所有内容都从 package root 导出:`import { ... } from "@cjhyy/code-shell"`,也可以直接从 `@cjhyy/code-shell-core` 导入。当前没有 `/run`、`/arena` 或 `/product` 这样的 subpath entry points。
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 配置
|
|
167
|
+
|
|
168
|
+
CLI preset 选择:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npx @cjhyy/code-shell --preset general
|
|
172
|
+
npx @cjhyy/code-shell --preset terminal-coding
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
settings 配置(`~/.code-shell/settings.json`,支持项目级覆盖):
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"agent": {
|
|
180
|
+
"preset": "general",
|
|
181
|
+
"enabledBuiltinTools": ["LSP"],
|
|
182
|
+
"disabledBuiltinTools": ["WebSearch"],
|
|
183
|
+
"appendSystemPrompt": "Prefer long-horizon planning and keep task state updated."
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
支持的 `agent` settings:`preset`、`enabledBuiltinTools`、`disabledBuiltinTools`、`customSystemPrompt`、`appendSystemPrompt`。
|
|
189
|
+
|
|
190
|
+
### Fullscreen mode (TUI)
|
|
191
|
+
|
|
192
|
+
CodeShell 的终端 UI 默认使用 **fullscreen**(alt-screen + ScrollBox)。可以用 `CODESHELL_FULLSCREEN=0|false|off` 在启动时关闭,或在运行时使用 `/fullscreen off` 切换。
|
|
193
|
+
|
|
194
|
+
### Stream idle watchdog(默认开启)
|
|
195
|
+
|
|
196
|
+
OpenAI-compatible provider 会中止在 `CODESHELL_STREAM_IDLE_TIMEOUT_MS` 毫秒内没有 chunk 的 LLM stream(默认 `90000`),然后交给现有 retry 策略重试,最多 `CODESHELL_STREAM_WATCHDOG_RETRIES` 次(默认 `2`)。设置 `CODESHELL_ENABLE_STREAM_WATCHDOG=0` 可关闭。用户主动中止(Esc / Ctrl+C)不会被重试。
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 架构
|
|
201
|
+
|
|
202
|
+
<p align="center">
|
|
203
|
+
<img src="docs/architecture/images/overview-runtime-layers.png" alt="CodeShell runtime layering and protocol flow architecture diagram" width="860" />
|
|
204
|
+
</p>
|
|
205
|
+
|
|
206
|
+
高层来看,CodeShell 让 CLI、headless、SDK 和桌面客户端都走同一个 engine runtime:
|
|
207
|
+
|
|
208
|
+
- **Preset resolution** 选择 system prompt、内置工具和权限默认值;
|
|
209
|
+
- **TurnLoop** 协调模型流式输出、上下文组装、工具执行和生命周期事件;
|
|
210
|
+
- **Tool system** 承载内置工具、MCP tools、permissions、hooks 和 cancellation;
|
|
211
|
+
- **Session / run layers** 持久化 transcripts、state、tasks、automation runs 和 memories。
|
|
212
|
+
|
|
213
|
+
桌面应用中,Electron main process 作为 IPC service layer:它本身不运行 Engine,而是为每个 session 启动核心 agent worker,把 stdout 流式传给 renderer,并提供文件、终端、凭证、插件、浏览器自动化 host 和 memory 等系统能力。Renderer 是只通过 `window.codeshell.*` 与 main 通信的 thin client。
|
|
214
|
+
|
|
215
|
+
设计原则:
|
|
216
|
+
|
|
217
|
+
- **Core first**:编排引擎保持领域无关;
|
|
218
|
+
- **Presets over hardcoding**:编码行为存在配置里;
|
|
219
|
+
- **Secure by default**:高影响动作默认经过权限门禁;
|
|
220
|
+
- **Long-running ready**:tasks、cron、sleep、sub-agents 和 persistent goals 都是一等能力。
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 项目结构
|
|
225
|
+
|
|
226
|
+
```text
|
|
227
|
+
packages/
|
|
228
|
+
├── core/ # Engine, context, tools, MCP, hooks, sessions, runs, presets, memory
|
|
229
|
+
├── tui/ # Terminal CLI, Ink-based UI, renderer, commands, approvals
|
|
230
|
+
├── desktop/ # Electron desktop client + agent worker bridge + mobile remote app
|
|
231
|
+
└── cdp/ # Environment-agnostic CDP browser-action layer (no Playwright)
|
|
232
|
+
|
|
233
|
+
assets/ # README / product images (mascot, promo hero, Playwright desktop screenshots)
|
|
234
|
+
|
|
235
|
+
docs/
|
|
236
|
+
├── architecture/ # System architecture chapters + feature inventory
|
|
237
|
+
├── todo/ # Roadmap + forward-looking design docs
|
|
238
|
+
└── archive/ # Superseded design docs, audits, and prior architecture set
|
|
239
|
+
|
|
240
|
+
scripts/ # Build, release, and repo maintenance scripts
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 开发
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
bun install
|
|
249
|
+
bun run build # build core + tui + meta package
|
|
250
|
+
bun run typecheck # root core + tui check; currently not a clean gate
|
|
251
|
+
bun test # core / tui test suites
|
|
252
|
+
|
|
253
|
+
# Desktop has its OWN typecheck and build (root checks do NOT cover it):
|
|
254
|
+
cd packages/desktop
|
|
255
|
+
bun run typecheck
|
|
256
|
+
bun run build
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
> 当前注意:repo root 的 `bun run typecheck` 会因 `packages/core/src/tool-system/builtin/drive-claude-code.test.ts:158` 的既有测试类型错误失败。它仍可提供信号,但在该错误修复前不要把它当成干净 gate。
|
|
260
|
+
|
|
261
|
+
`bun run dev` 会启动桌面应用。TUI 开发模式:`bun run dev:tui`。
|
|
262
|
+
|
|
263
|
+
> 桌面 renderer 使用 **shadcn/ui + Tailwind v4**(zinc theme),且不导入 core 代码;它是 `window.codeshell.*` 上的 thin client。Renderer 约定见 `packages/desktop/CLAUDE.md`。
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## 延伸阅读
|
|
268
|
+
|
|
269
|
+
- [Architecture & feature inventory](docs/architecture/README.md)
|
|
270
|
+
- [Roadmap & TODO](docs/todo/README.md)
|
|
271
|
+
- [Prior architecture documentation set (archived, pending rewrite)](docs/archive/architecture/README.md)
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 致谢
|
|
276
|
+
|
|
277
|
+
`ApplyPatch` tool(`packages/core/src/tool-system/builtin/apply-patch/`)改编自 [OpenAI Codex `codex-rs/apply-patch`](https://github.com/openai/codex/tree/main/codex-rs/apply-patch),使用 Apache License 2.0。详见该目录下的 `NOTICE.md` 和 `LICENSE-codex`。
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
MIT — see [LICENSE](LICENSE).
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cjhyy/code-shell",
|
|
3
|
-
"version": "0.6.0-rc.
|
|
3
|
+
"version": "0.6.0-rc.13",
|
|
4
4
|
"description": "Code Shell — meta package. Installs @cjhyy/code-shell-core and @cjhyy/code-shell-tui.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"format": "prettier --write 'packages/**/*.ts'"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@cjhyy/code-shell-core": "0.6.0-rc.
|
|
34
|
-
"@cjhyy/code-shell-tui": "0.6.0-rc.
|
|
33
|
+
"@cjhyy/code-shell-core": "0.6.0-rc.12",
|
|
34
|
+
"@cjhyy/code-shell-tui": "0.6.0-rc.12"
|
|
35
35
|
},
|
|
36
36
|
"workspaces": [
|
|
37
37
|
"packages/*"
|
|
@@ -54,9 +54,14 @@
|
|
|
54
54
|
"node": ">=20.10"
|
|
55
55
|
},
|
|
56
56
|
"files": [
|
|
57
|
+
"assets/codeshell-dog-icon.png",
|
|
58
|
+
"assets/codeshell-promo.png",
|
|
59
|
+
"assets/codeshell-desktop-screenshot-en.png",
|
|
60
|
+
"docs/architecture/images/overview-runtime-layers.png",
|
|
57
61
|
"dist",
|
|
58
62
|
"scripts/check-node.cjs",
|
|
59
63
|
"README.md",
|
|
64
|
+
"README.zh-CN.md",
|
|
60
65
|
"LICENSE",
|
|
61
66
|
"CHANGELOG.md"
|
|
62
67
|
],
|