@cjhyy/code-shell 0.6.0-rc.9 → 0.7.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/CHANGELOG.md CHANGED
@@ -10,6 +10,14 @@ breaking.
10
10
 
11
11
  ### Added
12
12
 
13
+ #### Unified input attachments
14
+
15
+ - The desktop composer now uses one attachment pipeline for paste, drag/drop,
16
+ file and directory mentions, and local image inputs, so files and screenshots
17
+ reach the agent consistently across entry points.
18
+ - Local image attachments can flow through the same request path as other
19
+ inputs for vision-capable model runs.
20
+
13
21
  #### Reusable sub-agent roles (`.code-shell/agents`)
14
22
 
15
23
  - The `Agent` tool now accepts an optional `agent_type` parameter. When set, it
@@ -23,7 +31,7 @@ breaking.
23
31
  synchronous sub-agents have a wall-clock timeout (default 5 minutes).
24
32
  - Sub-agent spawns emit `subagent_start` / `subagent_finish` / `subagent_error`
25
33
  lifecycle events through the existing `notification` hook.
26
- - Ships sample roles under `examples/agents/`: `researcher` and `explorer`
34
+ - Ships sample roles under `packages/desktop/resources/agents/`: `researcher` and `explorer`
27
35
  (read-only), `planner` (read-only planning), and `general-purpose` (full
28
36
  tools). Their `model` is left unset so they reuse the parent model — set
29
37
  `model:` in the frontmatter to route a role to a specific pool key.
@@ -34,7 +42,7 @@ breaking.
34
42
  vendor, parameters declared in the catalog drive both the UI controls and the
35
43
  tool description). Built-in entries ship in core; user entries live in
36
44
  `~/.code-shell/model-catalog.user.json`. The connections page supports
37
- multiple instances and credential reuse (`apiKeyRef`) with a per-tag default.
45
+ multiple instances and credential reuse (`credentialId`) with a per-tag default.
38
46
  - New `EditModelCatalog` builtin tool lets the agent add/update a user catalog
39
47
  entry and echoes a structured summary (every param's options/default) so you
40
48
  can verify it against the provider's official docs.
@@ -115,6 +123,38 @@ breaking.
115
123
 
116
124
  ### Fixed
117
125
 
126
+ - Addressed the latest core/desktop architecture review findings around stream
127
+ routing, permission/session scoping, and event coalescing, reducing
128
+ wrong-session routing, duplicated events, and hard-to-cancel operations in
129
+ multi-session desktop use.
130
+ - **Cookie credentials now target the browser panel's per-session partition.**
131
+ The credential service was hardcoded to the shared `persist:browser`
132
+ partition while browser tabs run under per-session `persist:browser:<bucket>`
133
+ partitions, so captured/injected/switched cookies never reached the session
134
+ the user was actually driving. Capture, restore, and the AI-driven
135
+ `InjectCredential` path now resolve the active guest's real partition
136
+ (`restoreCookiesToBrowser` accepts a live `Session`), and the main-process
137
+ partition builder matches the renderer's cleaning rule exactly. Default
138
+ restore mode is now `merge` (only `clear` on an explicit "clean switch").
139
+ - **New-conversation Goal / permission / model toggles are no longer dropped on
140
+ the first send.** A draft's pre-send toggles live under the shared draft
141
+ bucket, but the first send read them from the freshly-created real session
142
+ bucket (empty) — so enabling Goal, then typing and sending, silently failed to
143
+ set the goal even though the Goal icon stayed lit. The send now reads the
144
+ draft bucket's overrides before migrating them onto the real session.
145
+ - **Compaction keeps shrinking when one summary pass isn't enough.** After a
146
+ summary compaction the context manager returned even if the re-estimated
147
+ token count was still over the gate; it now continues down the
148
+ snip → window → emergency ladder until under budget, using the real
149
+ prompt-token anchor when available instead of a pure heuristic.
150
+ - **Concurrent sessions no longer cross log session IDs.** `Engine.run()` no
151
+ longer writes a module-level `setCurrentSid` fallback before the
152
+ AsyncLocalStorage context is established, so two sessions running at once
153
+ can't overwrite each other's sid on disk vs. in the logs.
154
+ - **TUI `run` / `runs` honor the model connection's context window.** Both
155
+ non-REPL entry points now use the active model connection's
156
+ `maxContextTokens` (falling back to the global default) instead of always
157
+ using `settings.context.maxTokens`, matching the REPL path.
118
158
  - Step-gap steering no longer leaves a duplicate user bubble: a queued
119
159
  steer entry that is interrupted (or that survives into the next turn) is
120
160
  withdrawn before the message is re-sent.
@@ -132,6 +172,33 @@ breaking.
132
172
  payload whose `messages` is not an array — the history replay guards the
133
173
  shape before mapping.
134
174
 
175
+ ### Changed
176
+
177
+ - Refreshed beta-release documentation and repository hygiene: README badges and
178
+ status copy now reflect the public beta track, obsolete handoff notes are
179
+ archived under `docs/archive/`, and generated build artifacts are covered by
180
+ `.gitignore`.
181
+
182
+ ## [0.6.0-rc.14]
183
+
184
+ ### Fixed
185
+
186
+ - **Cross-session message misdelivery**: a message typed in one session could be
187
+ delivered to another if you sent it while switching sessions. Sends now pin the
188
+ source session's bucket at submit time; the queued-input steer path also
189
+ resolves the engine session from the active bucket instead of the last-started
190
+ run.
191
+ - **Historical `view_image` by number**: image-bearing tool results are now
192
+ persisted to the transcript and restored on resume, so retrieving a past image
193
+ by number returns the correct image instead of a missing/misnumbered one.
194
+ - **File tree auto-scroll**: the files panel no longer snaps back to the selected
195
+ file on every refresh — it scrolls into view only when a file becomes selected.
196
+ - Mobile approval card / composer layout hardening.
197
+
198
+ ### Added
199
+
200
+ - The update settings row now shows the current app version.
201
+
135
202
  ## [0.5.0-rc.0] - 2026-05-23
136
203
 
137
204
  > ⚠️ Breaking. The repo is now a monorepo with three published packages.
package/README.md CHANGED
@@ -1,15 +1,27 @@
1
1
  <p align="center">
2
- <img src="assets/codeshell-dog-icon.png" alt="CodeShell dog mascot" width="120" />
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-hero.png" alt="CodeShell terminal agent orchestration hero image" width="860" />
16
+ <a href="https://www.npmjs.com/package/%40cjhyy%2Fcode-shell"><img src="https://img.shields.io/npm/v/%40cjhyy%2Fcode-shell" alt="npm version" /></a>
17
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license" /></a>
18
+ <a href="package.json"><img src="https://img.shields.io/badge/node-%3E%3D20.10-339933" alt="Node.js >=20.10" /></a>
19
+ <a href="tsconfig.json"><img src="https://img.shields.io/badge/TypeScript-5.x-3178C6?logo=typescript&amp;logoColor=white" alt="TypeScript" /></a>
20
+ <a href=".github/workflows/release.yml"><img src="https://img.shields.io/badge/platform-macOS%20%7C%20Windows%20%7C%20Linux-555" alt="macOS, Windows, and Linux" /></a>
21
+ </p>
22
+
23
+ <p align="center">
24
+ <img src="assets/codeshell-promo.png" alt="CodeShell desktop AI agent orchestration promotional image" width="860" />
13
25
  </p>
14
26
 
15
27
  CodeShell is one orchestration engine wearing three faces:
@@ -20,7 +32,7 @@ CodeShell is one orchestration engine wearing three faces:
20
32
 
21
33
  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
34
 
23
- > Status: **0.5.0-rc.2**, preparing for beta. The desktop app is the headline product; the CLI and SDK share the same core engine.
35
+ > Status: **0.6.x, entering beta**. The desktop app is the headline product; the CLI and SDK share the same core engine.
24
36
 
25
37
  ---
26
38
 
@@ -63,6 +75,12 @@ bun run dev # launches the desktop app in dev mode
63
75
 
64
76
  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
77
 
78
+ ### Desktop preview
79
+
80
+ <p align="center">
81
+ <img src="assets/codeshell-desktop-screenshot-en.png" alt="Actual CodeShell desktop app screenshot captured with Playwright" width="860" />
82
+ </p>
83
+
66
84
  ---
67
85
 
68
86
  ## Features
@@ -109,15 +127,17 @@ Presets select the system prompt, the built-in tool set, and permission defaults
109
127
 
110
128
  ### Built-in tools
111
129
 
112
- A broad orchestration toolbox is available across presets:
130
+ The default `general` preset whitelists 48 built-ins. The CLI defaults to
131
+ `terminal-coding`, which adds coding extras. Runtime guards may hide tools that
132
+ need unavailable providers, credentials, cookies, or an active goal.
113
133
 
114
- - **File**: `Read`, `Write`, `Edit`, `Glob`, `Grep`
115
- - **Execution**: `Bash`, `PowerShell`, `REPL`
116
- - **Coordination**: `TaskCreate`, `TaskUpdate`, `TaskList`, `TaskGet`, `TaskOutput`, `Agent`, `SendMessage`, `Sleep`
117
- - **Planning / runtime**: `EnterPlanMode`, `ExitPlanMode`, `CronCreate`, `CronDelete`, `CronList`
118
- - **Discovery / integration**: `ToolSearch`, `Skill`, `MCPTool`, `ListMcpResources`, `ReadMcpResource`
119
- - **Generation**: `GenerateImage`, `GenerateVideo` (image/video providers via the unified catalog)
120
- - **Coding preset extras**: `EnterWorktree`, `ExitWorktree`, `NotebookEdit`, `LSP`, `Brief`, `Arena`
134
+ - **File / workspace**: `Read`, `Write`, `Edit`, `ApplyPatch`, `Glob`, `Grep`
135
+ - **Shell / execution**: `Bash`, `BashOutput`, `KillShell`, `ListShells`, `PowerShell`, `REPL`, `Sleep`
136
+ - **Web / media / browser**: `browser_observe`, `browser_act`, `browser_navigate`, `WebSearch`, `WebFetch`, `GenerateImage`, `GenerateVideo`
137
+ - **Planning / orchestration**: `AskUserQuestion`, `EnterPlanMode`, `ExitPlanMode`, `ToolSearch`, `TodoWrite`, `Agent`, `AgentCancel`, `DriveAgent`, `DriveClaudeCode`, `CheckQuota`
138
+ - **Automation / integration**: `CronCreate`, `CronDelete`, `CronList`, `Config`, `Skill`, `AddMarketplace`, `MCPTool`, `ListMcpResources`, `ReadMcpResource`, `EditModelCatalog`
139
+ - **Memory / credentials / goals**: `MemoryList`, `MemoryRead`, `MemorySave`, `MemoryDelete`, `UseCredential`, `InjectCredential`, `complete_goal`, `cancel_goal`
140
+ - **Terminal-coding preset extras**: `EnterWorktree`, `ExitWorktree`, `NotebookEdit`, `LSP`, `Brief`, `Arena`
121
141
 
122
142
  ---
123
143
 
@@ -181,16 +201,16 @@ CodeShell's terminal UI defaults to **fullscreen** (alt-screen + ScrollBox) —
181
201
 
182
202
  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
203
 
184
- ### Stream idle watchdog (opt-in)
204
+ ### Stream idle watchdog (on by default)
185
205
 
186
- When `CODESHELL_ENABLE_STREAM_WATCHDOG=1`, the openai provider aborts any LLM stream idle for `CODESHELL_STREAM_IDLE_TIMEOUT_MS` ms (default `90000`) without a chunk. The engine 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. User-initiated aborts (Esc / Ctrl+C) are never retried. Disabled by default.
206
+ 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
207
 
188
208
  ---
189
209
 
190
210
  ## Architecture
191
211
 
192
212
  <p align="center">
193
- <img src="docs/archive/architecture/images/00-framework-overview.png" alt="CodeShell framework overview architecture diagram" width="860" />
213
+ <img src="docs/architecture/images/overview-runtime-layers.png" alt="CodeShell runtime layering and protocol flow architecture diagram" width="860" />
194
214
  </p>
195
215
 
196
216
  At a high level, CodeShell routes CLI, headless, SDK, and desktop clients through the same engine runtime:
@@ -220,7 +240,7 @@ packages/
220
240
  ├── desktop/ # Electron desktop client + agent worker bridge + mobile remote app
221
241
  └── cdp/ # Environment-agnostic CDP browser-action layer (no Playwright)
222
242
 
223
- assets/ # README / product images (mascot, hero)
243
+ assets/ # README / product images (mascot, promo hero, Playwright desktop screenshots)
224
244
 
225
245
  docs/
226
246
  ├── architecture/ # System architecture chapters + feature inventory (see architecture/README.md)
@@ -237,15 +257,17 @@ scripts/ # Build, release, and repo maintenance scripts
237
257
  ```bash
238
258
  bun install
239
259
  bun run build # build core + tui + meta package
240
- bun run typecheck # core + tui (tsc --noEmit)
260
+ bun run typecheck # root core + tui check; currently not a clean gate
241
261
  bun test # core / tui test suites
242
262
 
243
263
  # Desktop has its OWN typecheck and build (the root checks do NOT cover it):
244
264
  cd packages/desktop
245
- bunx tsc --noEmit
246
- bun run build:renderer
265
+ bun run typecheck
266
+ bun run build
247
267
  ```
248
268
 
269
+ > 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.
270
+
249
271
  `bun run dev` launches the desktop app. For the TUI in dev: `bun run dev:tui`.
250
272
 
251
273
  > 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.
@@ -0,0 +1,289 @@
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
+ <a href="https://www.npmjs.com/package/%40cjhyy%2Fcode-shell"><img src="https://img.shields.io/npm/v/%40cjhyy%2Fcode-shell" alt="npm version" /></a>
17
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license" /></a>
18
+ <a href="package.json"><img src="https://img.shields.io/badge/node-%3E%3D20.10-339933" alt="Node.js >=20.10" /></a>
19
+ <a href="tsconfig.json"><img src="https://img.shields.io/badge/TypeScript-5.x-3178C6?logo=typescript&amp;logoColor=white" alt="TypeScript" /></a>
20
+ <a href=".github/workflows/release.yml"><img src="https://img.shields.io/badge/platform-macOS%20%7C%20Windows%20%7C%20Linux-555" alt="macOS、Windows 和 Linux" /></a>
21
+ </p>
22
+
23
+ <p align="center">
24
+ <img src="assets/codeshell-promo.png" alt="CodeShell 桌面端 AI agent 编排宣传图" width="860" />
25
+ </p>
26
+
27
+ CodeShell 是同一个编排引擎的三种形态:
28
+
29
+ - **终端 CLI** (`code-shell`):用于交互式和 headless agent 运行;
30
+ - **Electron 桌面应用**:提供聊天、文件/浏览器/终端/diff 面板、模型与凭证管理、扩展市场、自动化和手机远程控制;
31
+ - **程序化 SDK** (`import { Engine } from "@cjhyy/code-shell"`):可把引擎嵌入你自己的产品。
32
+
33
+ 核心引擎保持**领域无关**。turn loop、上下文管理、权限、MCP 集成、hooks、tasks、cron、sub-agents、sessions 和 memory 都是通用机制;“写代码助手”只是叠在引擎上的一个 preset,而不是写死在核心里。
34
+
35
+ > 状态:**0.6.x,进入 beta 阶段**。桌面应用是当前主产品;CLI 和 SDK 共享同一个核心引擎。
36
+
37
+ ---
38
+
39
+ ## 为什么是 CodeShell
40
+
41
+ - **一个引擎,多种产品**:同一套 runtime 可以驱动编码、研究、自动化、浏览器任务和长期工作流。
42
+ - **终端优先,也适合 headless 和桌面**:可在终端交互运行,也可执行一次性 headless 任务,或者使用完整可视化桌面端。
43
+ - **默认具备权限意识**:写文件、shell、git 等高影响操作通过显式审批流程控制,并支持按 session/project 缓存规则。
44
+ - **端到端可扩展**:presets、内置工具、MCP servers、hooks、skills、plugins、sub-agents 和 cron jobs 都是一等能力。
45
+ - **本地优先与隐私友好**:sessions、transcripts、credentials 和 memory 存在 `~/.code-shell/`;凭证文件以 owner-only (`0o600`) 权限写入。
46
+
47
+ ---
48
+
49
+ ## 快速开始
50
+
51
+ ### CLI
52
+
53
+ ```bash
54
+ # 默认 CLI preset:终端编码助手(交互式 REPL)
55
+ npx @cjhyy/code-shell
56
+
57
+ # 作为通用编排器运行
58
+ npx @cjhyy/code-shell --preset general
59
+
60
+ # 一次性 / headless 执行
61
+ npx @cjhyy/code-shell run --preset general \
62
+ "Create a long-running research plan and track it with tasks"
63
+ ```
64
+
65
+ 需要 **Node.js >= 20.10**。
66
+
67
+ ### 桌面应用
68
+
69
+ 桌面应用位于 `packages/desktop`。从源码启动:
70
+
71
+ ```bash
72
+ bun install
73
+ bun run dev # 以开发模式启动桌面应用
74
+ ```
75
+
76
+ 桌面端提供流式聊天、并排文件/浏览器/终端/diff 面板、模型与凭证管理、扩展市场、自动化/cron 调度、持久目标、memory 和手机远程控制。所有能力都通过每个 session 的 agent worker 进程驱动同一个核心引擎。
77
+
78
+ ### 桌面预览
79
+
80
+ <p align="center">
81
+ <img src="assets/codeshell-desktop-screenshot-en.png" alt="使用 Playwright 捕获的 CodeShell 桌面应用真实截图" width="860" />
82
+ </p>
83
+
84
+ ---
85
+
86
+ ## 功能
87
+
88
+ ### 核心引擎 (`@cjhyy/code-shell-core`)
89
+
90
+ - turn-based agent loop,支持流式输出和逐步生命周期事件;
91
+ - 上下文压缩与持久 session 存储;
92
+ - 带权限门禁的工具执行,支持 session/project 规则缓存和链式命令防护;
93
+ - hook pipeline 与完整 MCP client 集成;
94
+ - 一等支持 **tasks、sub-agents、cron 和 sleep**,适合长期、自我节奏化工作流;
95
+ - **Persistent goals**:通过 stop-hook judge 和显式 `complete_goal` 声明推进目标;
96
+ - **Memory + Dream**:每轮注入 memory,并通过 LLM consolidation 进行整理;
97
+ - **统一模型目录**:text / image / video providers 使用同一套 tag-based config;
98
+ - 后台 shell jobs、成本追踪和 turn-level 文件 undo/redo。
99
+
100
+ ### Presets
101
+
102
+ | Preset | 用途 | 额外工具 |
103
+ |--------|------|----------|
104
+ | `general` | 通用编排、研究、自动化、长期任务 | 仅核心编排工具 |
105
+ | `terminal-coding` | 终端原生编码助手 | `EnterWorktree`, `ExitWorktree`, `NotebookEdit`, `LSP`, `Brief`, `Arena` |
106
+
107
+ Preset 决定 system prompt、内置工具集和权限默认值。可通过 SDK、CLI `--preset` 参数或 settings 配置。
108
+
109
+ ### 终端体验 (`@cjhyy/code-shell-tui`)
110
+
111
+ - 基于 Ink 的交互式 REPL,支持 fullscreen/flow 模式、vim-mode 输入和输入历史;
112
+ - headless `run` 模式,以及 `repl`、`sessions`、`runs` 子命令;
113
+ - slash commands、`@` 文件/skill 搜索、命令补全和 REPL 内 cron 调度;
114
+ - `Shift+Tab` 切换权限模式、transcript 浏览、session resume 和成本/用量报告。
115
+
116
+ ### 桌面应用 (`@cjhyy/code-shell-desktop`)
117
+
118
+ - **Chat**:流式输出、图片附件(上传/拖拽/粘贴)、运行时 steering/queue 模型;
119
+ - **Panel dock**:对话旁的 Files、Browser、Terminal、Diff/Review 面板;
120
+ - **Model catalog & connections**:providers/models 的完整 CRUD、按公司复用凭证、参数文档联动 UI;
121
+ - **Credentials**:API keys、浏览器 cookie 登录、多账号 cookie 凭证和权限 token/link gates;
122
+ - **Extensions**:plugin/skill/MCP 管理、marketplace、capability overview 和 sub-agent role 管理;
123
+ - **Automation**:cron/scheduled tasks、每个任务的 transcript/memory,以及长任务 runs 视图;
124
+ - **Persistent goals**、memory 管理、hooks 配置和中英文 i18n;
125
+ - **Phone remote**:通过本地 WebSocket 从手机控制桌面 session;
126
+ - onboarding、trust gate、app updater、command palette (`⌘K`)、跨项目 session 搜索 (`⌘P`) 和 transcript 搜索 (`⌘F`)。
127
+
128
+ ### 内置工具
129
+
130
+ 默认 `general` preset 白名单包含 48 个内置工具。CLI 默认使用
131
+ `terminal-coding` preset,并额外加入编码相关工具。运行时 guard 可能隐藏当前不可用的
132
+ provider、凭证、cookie 或 goal 相关工具。
133
+
134
+ - **File / workspace**:`Read`, `Write`, `Edit`, `ApplyPatch`, `Glob`, `Grep`
135
+ - **Shell / execution**:`Bash`, `BashOutput`, `KillShell`, `ListShells`, `PowerShell`, `REPL`, `Sleep`
136
+ - **Web / media / browser**:`browser_observe`, `browser_act`, `browser_navigate`, `WebSearch`, `WebFetch`, `GenerateImage`, `GenerateVideo`
137
+ - **Planning / orchestration**:`AskUserQuestion`, `EnterPlanMode`, `ExitPlanMode`, `ToolSearch`, `TodoWrite`, `Agent`, `AgentCancel`, `DriveAgent`, `DriveClaudeCode`, `CheckQuota`
138
+ - **Automation / integration**:`CronCreate`, `CronDelete`, `CronList`, `Config`, `Skill`, `AddMarketplace`, `MCPTool`, `ListMcpResources`, `ReadMcpResource`, `EditModelCatalog`
139
+ - **Memory / credentials / goals**:`MemoryList`, `MemoryRead`, `MemorySave`, `MemoryDelete`, `UseCredential`, `InjectCredential`, `complete_goal`, `cancel_goal`
140
+ - **Terminal-coding preset extras**:`EnterWorktree`, `ExitWorktree`, `NotebookEdit`, `LSP`, `Brief`, `Arena`
141
+
142
+ ---
143
+
144
+ ## 程序化 API
145
+
146
+ meta package 会重新导出核心引擎,所以旧的 SDK import 仍然可用:
147
+
148
+ ```ts
149
+ import { Engine } from "@cjhyy/code-shell";
150
+
151
+ const generalEngine = new Engine({
152
+ llm: {
153
+ provider: "openai",
154
+ model: "gpt-4.1",
155
+ apiKey: process.env.OPENAI_API_KEY,
156
+ },
157
+ preset: "general",
158
+ });
159
+
160
+ const codingEngine = new Engine({
161
+ llm: {
162
+ provider: "openai",
163
+ model: "gpt-4.1",
164
+ apiKey: process.env.OPENAI_API_KEY,
165
+ },
166
+ preset: "terminal-coding",
167
+ });
168
+ ```
169
+
170
+ 所有内容都从 package root 导出:`import { ... } from "@cjhyy/code-shell"`,也可以直接从 `@cjhyy/code-shell-core` 导入。当前没有 `/run`、`/arena` 或 `/product` 这样的 subpath entry points。
171
+
172
+ ---
173
+
174
+ ## 配置
175
+
176
+ CLI preset 选择:
177
+
178
+ ```bash
179
+ npx @cjhyy/code-shell --preset general
180
+ npx @cjhyy/code-shell --preset terminal-coding
181
+ ```
182
+
183
+ settings 配置(`~/.code-shell/settings.json`,支持项目级覆盖):
184
+
185
+ ```json
186
+ {
187
+ "agent": {
188
+ "preset": "general",
189
+ "enabledBuiltinTools": ["LSP"],
190
+ "disabledBuiltinTools": ["WebSearch"],
191
+ "appendSystemPrompt": "Prefer long-horizon planning and keep task state updated."
192
+ }
193
+ }
194
+ ```
195
+
196
+ 支持的 `agent` settings:`preset`、`enabledBuiltinTools`、`disabledBuiltinTools`、`customSystemPrompt`、`appendSystemPrompt`。
197
+
198
+ ### Fullscreen mode (TUI)
199
+
200
+ CodeShell 的终端 UI 默认使用 **fullscreen**(alt-screen + ScrollBox)。可以用 `CODESHELL_FULLSCREEN=0|false|off` 在启动时关闭,或在运行时使用 `/fullscreen off` 切换。
201
+
202
+ ### Stream idle watchdog(默认开启)
203
+
204
+ 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)不会被重试。
205
+
206
+ ---
207
+
208
+ ## 架构
209
+
210
+ <p align="center">
211
+ <img src="docs/architecture/images/overview-runtime-layers.png" alt="CodeShell runtime layering and protocol flow architecture diagram" width="860" />
212
+ </p>
213
+
214
+ 高层来看,CodeShell 让 CLI、headless、SDK 和桌面客户端都走同一个 engine runtime:
215
+
216
+ - **Preset resolution** 选择 system prompt、内置工具和权限默认值;
217
+ - **TurnLoop** 协调模型流式输出、上下文组装、工具执行和生命周期事件;
218
+ - **Tool system** 承载内置工具、MCP tools、permissions、hooks 和 cancellation;
219
+ - **Session / run layers** 持久化 transcripts、state、tasks、automation runs 和 memories。
220
+
221
+ 桌面应用中,Electron main process 作为 IPC service layer:它本身不运行 Engine,而是为每个 session 启动核心 agent worker,把 stdout 流式传给 renderer,并提供文件、终端、凭证、插件、浏览器自动化 host 和 memory 等系统能力。Renderer 是只通过 `window.codeshell.*` 与 main 通信的 thin client。
222
+
223
+ 设计原则:
224
+
225
+ - **Core first**:编排引擎保持领域无关;
226
+ - **Presets over hardcoding**:编码行为存在配置里;
227
+ - **Secure by default**:高影响动作默认经过权限门禁;
228
+ - **Long-running ready**:tasks、cron、sleep、sub-agents 和 persistent goals 都是一等能力。
229
+
230
+ ---
231
+
232
+ ## 项目结构
233
+
234
+ ```text
235
+ packages/
236
+ ├── core/ # Engine, context, tools, MCP, hooks, sessions, runs, presets, memory
237
+ ├── tui/ # Terminal CLI, Ink-based UI, renderer, commands, approvals
238
+ ├── desktop/ # Electron desktop client + agent worker bridge + mobile remote app
239
+ └── cdp/ # Environment-agnostic CDP browser-action layer (no Playwright)
240
+
241
+ assets/ # README / product images (mascot, promo hero, Playwright desktop screenshots)
242
+
243
+ docs/
244
+ ├── architecture/ # System architecture chapters + feature inventory
245
+ ├── todo/ # Roadmap + forward-looking design docs
246
+ └── archive/ # Superseded design docs, audits, and prior architecture set
247
+
248
+ scripts/ # Build, release, and repo maintenance scripts
249
+ ```
250
+
251
+ ---
252
+
253
+ ## 开发
254
+
255
+ ```bash
256
+ bun install
257
+ bun run build # build core + tui + meta package
258
+ bun run typecheck # root core + tui check; currently not a clean gate
259
+ bun test # core / tui test suites
260
+
261
+ # Desktop has its OWN typecheck and build (root checks do NOT cover it):
262
+ cd packages/desktop
263
+ bun run typecheck
264
+ bun run build
265
+ ```
266
+
267
+ > 当前注意:repo root 的 `bun run typecheck` 会因 `packages/core/src/tool-system/builtin/drive-claude-code.test.ts:158` 的既有测试类型错误失败。它仍可提供信号,但在该错误修复前不要把它当成干净 gate。
268
+
269
+ `bun run dev` 会启动桌面应用。TUI 开发模式:`bun run dev:tui`。
270
+
271
+ > 桌面 renderer 使用 **shadcn/ui + Tailwind v4**(zinc theme),且不导入 core 代码;它是 `window.codeshell.*` 上的 thin client。Renderer 约定见 `packages/desktop/CLAUDE.md`。
272
+
273
+ ---
274
+
275
+ ## 延伸阅读
276
+
277
+ - [Architecture & feature inventory](docs/architecture/README.md)
278
+ - [Roadmap & TODO](docs/todo/README.md)
279
+ - [Prior architecture documentation set (archived, pending rewrite)](docs/archive/architecture/README.md)
280
+
281
+ ---
282
+
283
+ ## 致谢
284
+
285
+ `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`。
286
+
287
+ ## License
288
+
289
+ MIT — see [LICENSE](LICENSE).
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.9",
3
+ "version": "0.7.0",
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.9",
34
- "@cjhyy/code-shell-tui": "0.6.0-rc.9"
33
+ "@cjhyy/code-shell-core": "0.7.0",
34
+ "@cjhyy/code-shell-tui": "0.7.0"
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
  ],