ai-cli-online 2.9.9 → 3.0.2

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/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
5
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-green.svg)](https://nodejs.org/)
6
6
 
7
- A lightweight web terminal for accessing Claude Code / Codex or any CLI from your browser.
7
+ An AI-powered development environment that runs in your browser. Persistent terminal sessions, structured task lifecycle, and autonomous execution all through a single Node.js process.
8
8
 
9
- Ideal for **unstable networks** where SSH drops frequently, or as a **local stateful terminal** that preserves sessions, layouts, and drafts across refreshes.
9
+ Built for running Claude Code, Codex CLI, Gemini CLI, or any other AI CLI over unstable networks. tmux keeps everything alive when connections drop; the browser UI provides planning, annotation, and chat panels alongside the terminal.
10
10
 
11
11
  **npm:** https://www.npmjs.com/package/ai-cli-online | **GitHub:** https://github.com/huacheng/ai-cli-online
12
12
 
@@ -14,49 +14,110 @@ Ideal for **unstable networks** where SSH drops frequently, or as a **local stat
14
14
 
15
15
  ![screenshot](screenshot.jpg)
16
16
 
17
- ## Features
17
+ ## What It Does
18
18
 
19
- - **Full Web Terminal** xterm.js with WebGL rendering, binary protocol for ultra-low latency
20
- - **Session Persistence** — tmux keeps processes alive through disconnects; fixed socket path ensures auto-reconnect even after server restarts
21
- - **Multi-Tab** — independent terminal groups with layout persistence across browser refreshes
19
+ **Terminal + Planning + Execution in one screen:**
20
+
21
+ ```
22
+ ┌─ Tabs ──────────────────────────────────────────────────────┐
23
+ │ ┌─ Plan Panel ──────┬─ Terminal ────────────────────────┐ │
24
+ │ │ AiTasks/ browser │ │ │
25
+ │ │ Markdown viewer │ $ /ai-cli-task auto my-feature │ │
26
+ │ │ Inline annotations │ ▶ planning... │ │
27
+ │ │ (insert/delete/ │ ▶ check(post-plan): PASS │ │
28
+ │ │ replace/comment) │ ▶ executing step 1/4... │ │
29
+ │ │ │ ▶ executing step 2/4... │ │
30
+ │ │ Mermaid diagrams │ ... │ │
31
+ │ │ ├───────────────────────────────────┤ │
32
+ │ │ │ Chat Editor │ │
33
+ │ │ │ Multi-line Markdown + /commands │ │
34
+ │ └────────────────────┴───────────────────────────────────┘ │
35
+ └──────────────────────────────────────────────────────────────┘
36
+ ```
37
+
38
+ - **Plan Panel** — browse `AiTasks/` files, annotate documents with 4 annotation types, send structured feedback to AI
39
+ - **Terminal** — full xterm.js with WebGL rendering, binary protocol for ultra-low latency
40
+ - **Chat Editor** — multi-line Markdown editor with slash commands, server-side draft persistence
41
+ - All three panels can be open simultaneously, each independently resizable
42
+
43
+ ## AI Task Lifecycle
44
+
45
+ The `ai-cli-task` plugin provides an 8-skill lifecycle for structured AI task execution:
46
+
47
+ ```
48
+ init → plan → check → exec → check → merge → report
49
+ ↑ ↓
50
+ re-plan ←──┘ (on issues)
51
+ ```
52
+
53
+ | Skill | What it does |
54
+ |-------|-------------|
55
+ | **init** | Create task module (`AiTasks/<name>/`), git branch, optional worktree |
56
+ | **plan** | Generate implementation plan or process human annotations |
57
+ | **check** | Evaluate feasibility at 3 checkpoints (post-plan / mid-exec / post-exec) |
58
+ | **exec** | Execute plan steps with per-step verification |
59
+ | **merge** | Merge task branch to main with conflict resolution (up to 3 retries) |
60
+ | **report** | Generate completion report, distill lessons to experience database |
61
+ | **auto** | Run the full lifecycle autonomously in a single Claude session |
62
+ | **cancel** | Stop execution, set status to cancelled, optional cleanup |
63
+
64
+ ### Auto Mode
65
+
66
+ ```bash
67
+ /ai-cli-task auto my-feature
68
+ ```
69
+
70
+ One command triggers the entire lifecycle. A single Claude session runs plan → check → exec → merge → report internally, sharing context across all steps. A daemon monitors progress via `.auto-signal` files, enforces timeouts, and detects stalls.
71
+
72
+ ### Task Structure
73
+
74
+ ```
75
+ AiTasks/
76
+ ├── .index.md # Module listing
77
+ ├── .experience/ # Cross-task knowledge base (by domain type)
78
+ │ ├── software.md
79
+ │ └── <type>.md
80
+ └── my-feature/
81
+ ├── .index.md # Status, phase, timestamps, dependencies (YAML)
82
+ ├── .target.md # Requirements (human-authored)
83
+ ├── .summary.md # Condensed context (prevents context overflow)
84
+ ├── .analysis/ # Evaluation history
85
+ ├── .test/ # Test criteria & results
86
+ ├── .bugfix/ # Issue history
87
+ ├── .notes/ # Research findings
88
+ ├── .report.md # Completion report
89
+ └── plan.md # Implementation plan
90
+ ```
91
+
92
+ ### Type-Aware Execution
93
+
94
+ Tasks are classified by domain type (`software`, `dsp`, `ml`, `literary`, `science:physics`, etc.). Each type adapts planning methodology, execution tools, and verification criteria. Completed task lessons are stored in `.experience/<type>.md` and referenced by future tasks of the same type.
95
+
96
+ ## Terminal Features
97
+
98
+ - **Session Persistence** — tmux keeps processes alive through disconnects; fixed socket path ensures auto-reconnect after server restarts
99
+ - **Multi-Tab** — independent terminal groups with layout persistence across refreshes
22
100
  - **Split Panes** — horizontal / vertical splits, arbitrarily nested
23
- - **Mermaid Diagrams** — Gantt charts, flowcharts, and other Mermaid diagrams render inline with dark theme; CDN fallback for reliability
24
- - **Plan Annotations** — 4 annotation types (insert / delete / replace / comment) on document content with persistent storage; selection float button group for quick action
25
- - **Editor Panel** — multi-line editing with server-side draft persistence (SQLite), undo stack, and slash commands (`/history`, etc.)
26
- - **Copy & Paste** — mouse selection auto-copies to clipboard; right-click pastes into terminal
27
- - **File Transfer** — upload files to CWD, browse and download via REST API
28
- - **Scroll History** — capture-pane scrollback viewer with ANSI color preservation
29
- - **Session Management** — sidebar to restore, delete, rename sessions, and close individual terminals (with confirmation)
30
- - **CJK Font Support** — LXGW WenKai Mono via CDN with unicode-range subsetting; browser loads only needed CJK glyphs on demand
31
- - **Font Size Control** — adjustable terminal font size (A−/A+) with server-side persistence
32
- - **Version Display** — current version shown in header, auto-injected from `package.json` at build time
33
- - **Network Indicator** real-time RTT latency display with signal bars
34
- - **Auto Reconnect** — exponential backoff with jitter to prevent thundering herd
35
- - **Secure Auth** token authentication with timing-safe comparison
36
- - **Security Hardening** — symlink traversal protection, unauthenticated WebSocket connection limits, TOCTOU download guard, CSP headers (frame-ancestors, base-uri, form-action)
37
-
38
- ## Comparison: AI-Cli Online vs OpenClaw
39
-
40
- | Dimension | AI-Cli Online | OpenClaw |
41
- |-----------|--------------|----------|
42
- | **Positioning** | Lightweight web terminal | AI agent orchestration platform |
43
- | **Core Use Case** | Browser-based remote terminal access | Multi-channel AI assistant |
44
- | **Terminal Emulation** | xterm.js + WebGL | None |
45
- | **Session Persistence** | tmux (survives disconnects) | Gateway in-memory state |
46
- | **Multi-Tab / Split** | Tabs + arbitrarily nested panes | None |
47
- | **Message Channels** | WebSocket (single channel) | 16+ (WhatsApp / Telegram / Slack / Discord...) |
48
- | **Native Apps** | None (pure web) | macOS + iOS + Android |
49
- | **Voice Interaction** | None | Voice Wake + Talk Mode |
50
- | **AI Agent** | None built-in (run any CLI) | Pi Agent runtime + multi-agent routing |
51
- | **Canvas / UI** | Plan annotations (Markdown) | A2UI real-time visual workspace |
52
- | **File Transfer** | REST API upload / download | Channel-native media |
53
- | **Security Model** | Token auth + timing-safe | Device pairing + DM policy + Docker sandbox |
54
- | **Extensibility** | Shell scripts | 33 extensions + 60+ skills + ClawHub |
55
- | **Transport** | Binary frames (ultra-low latency) | JSON WebSocket |
56
- | **Deployment** | Single-node Node.js | Single-node + Tailscale Serve/Funnel |
57
- | **Tech Stack** | React + Express + node-pty | Lit + Express + Pi Agent |
58
- | **Package Size** | ~1 MB | ~300 MB+ |
59
- | **Install** | `npx ai-cli-online` | `npm i -g openclaw && openclaw onboard` |
101
+ - **Binary Protocol** — 1-byte prefix frames for terminal I/O, TCP Nagle disabled, WebSocket compression
102
+ - **WebGL Rendering** — 3-10x throughput vs canvas
103
+ - **Copy & Paste** — mouse selection auto-copies; right-click pastes
104
+ - **Scroll History** — capture-pane scrollback with ANSI color preservation
105
+ - **File Transfer** — upload/download files, browse directories, download CWD as tar.gz
106
+ - **Network Indicator** — real-time RTT latency with signal bars
107
+ - **Auto Reconnect** — exponential backoff with jitter
108
+
109
+ ## Annotation System
110
+
111
+ The Plan panel provides 4 annotation types for structured AI feedback:
112
+
113
+ | Type | Icon | Description |
114
+ |------|------|------------|
115
+ | **Insert** | `+` | Add content at a specific location |
116
+ | **Delete** | `−` | Mark text for removal |
117
+ | **Replace** | `↔` | Substitute old text with new |
118
+ | **Comment** | `?` | Ask questions or leave notes |
119
+
120
+ Annotations are persisted (localStorage + SQLite) and sent to the AI as structured JSON. The `plan` skill processes them — triaging by impact, applying changes, and updating task files.
60
121
 
61
122
  ## Quick Start
62
123
 
@@ -106,49 +167,64 @@ See `server/.env.example` for all available options.
106
167
  ## Architecture
107
168
 
108
169
  ```
109
- Browser (xterm.js + WebGL) <-- WebSocket binary/JSON --> Express (node-pty) <--> tmux session --> shell
170
+ Browser (xterm.js + WebGL)
171
+ ├── Plan Panel (annotation editor)
172
+ ├── Chat Editor (Markdown + /commands)
173
+ └── Terminal View (WebGL renderer)
174
+
175
+ ↕ WebSocket binary/JSON + REST API
176
+
177
+ Express Server (Node.js)
178
+ ├── WebSocket ↔ PTY relay
179
+ ├── tmux session manager
180
+ ├── File transfer API
181
+ ├── SQLite (drafts, annotations, settings)
182
+ └── Route modules (sessions, files, editor, settings)
183
+
184
+ ↕ PTY / tmux sockets
185
+
186
+ tmux sessions → shell → Claude Code / AI agents
187
+ └── AiTasks/ lifecycle (init/plan/check/exec/merge/report/auto)
110
188
  ```
111
189
 
112
- - **Frontend**: React + Zustand + xterm.js (WebGL renderer)
190
+ - **Frontend**: React + Zustand + xterm.js (WebGL)
113
191
  - **Backend**: Node.js + Express + node-pty + WebSocket + better-sqlite3
114
192
  - **Session Manager**: tmux (persistent terminal sessions)
115
- - **Layout System**: Tabs + recursive tree structure (LeafNode / SplitNode)
193
+ - **Layout**: Tabs + recursive split tree (LeafNode / SplitNode)
116
194
  - **Transport**: Binary frames (hot path) + JSON (control messages)
117
- - **Data Persistence**: SQLite (editor drafts)
118
-
119
- ### Performance
120
-
121
- - **Binary protocol** — 1-byte prefix frames for terminal I/O, eliminating JSON overhead
122
- - **TCP Nagle disabled** — `setNoDelay(true)` removes up to 40 ms keystroke delay
123
- - **WebSocket compression** — `perMessageDeflate` (level 1, threshold 128 B), 50-70% bandwidth reduction
124
- - **WebGL renderer** — 3-10x rendering throughput vs canvas
125
- - **Parallel initialization** — PTY creation, tmux config, and resize run concurrently
126
- - **Smart re-render** — responsive layout hook, conditional Zustand selectors, batched stat calls
195
+ - **Task System**: 8-skill plugin with state machine, dependency gates, and experience database
127
196
 
128
197
  ## Project Structure
129
198
 
130
199
  ```
131
200
  ai-cli-online/
132
- ├── shared/ # Shared type definitions (ClientMessage, ServerMessage)
133
- ├── server/ # Backend (TypeScript)
134
- └── src/
135
- ├── index.ts # Main entry (HTTP + WebSocket + REST API)
136
- ├── websocket.ts # WebSocket <-> PTY relay (binary + JSON)
137
- ├── tmux.ts # tmux session management
138
- ├── files.ts # File operations
139
- ├── pty.ts # node-pty wrapper
140
- ├── db.ts # SQLite database (draft persistence)
141
- ├── auth.ts # Auth utilities
142
- └── types.ts # Type definitions
143
- ├── web/ # Frontend (React + Vite)
144
- └── src/
145
- ├── App.tsx # Main app component
146
- ├── store.ts # Zustand state management
147
- ├── components/ # UI components
148
- ├── hooks/ # React hooks
149
- └── api/ # API client
150
- ├── start.sh # Production start script
151
- └── package.json # Monorepo config
201
+ ├── shared/ # Shared type definitions
202
+ ├── server/src/
203
+ ├── index.ts # Main entry (middleware + routes + server)
204
+ ├── websocket.ts # WebSocket PTY relay (binary + JSON)
205
+ ├── tmux.ts # tmux session management
206
+ ├── files.ts # File operations + path validation
207
+ ├── pty.ts # node-pty wrapper
208
+ ├── db.ts # SQLite database
209
+ ├── auth.ts # Auth utilities
210
+ ├── middleware/ # Auth middleware
211
+ └── routes/ # REST API routes (sessions, files, editor, settings)
212
+ ├── web/src/
213
+ ├── App.tsx # Main app (Login / TabBar / Terminal / Theme)
214
+ ├── store/ # Zustand store (modular slices)
215
+ ├── components/
216
+ ├── TerminalPane.tsx # 2D grid layout (Plan + Terminal + Chat)
217
+ ├── TerminalView.tsx # xterm.js terminal
218
+ │ ├── PlanPanel.tsx # Plan annotation panel
219
+ │ │ ├── PlanAnnotationRenderer.tsx # Markdown + inline annotations
220
+ │ │ ├── PlanFileBrowser.tsx # AiTasks/ file browser
221
+ │ │ ├── MarkdownEditor.tsx # Chat editor
222
+ │ │ └── ...
223
+ │ ├── hooks/ # React hooks (WebSocket, file stream, resize, etc.)
224
+ │ └── api/ # Typed API client modules
225
+ ├── bin/ # npx entry point
226
+ ├── start.sh # Production start script
227
+ └── install-service.sh # systemd + nginx installer
152
228
  ```
153
229
 
154
230
  ## Development
@@ -177,6 +253,15 @@ The install script will:
177
253
  2. Detect nginx and optionally configure reverse proxy (WebSocket support, SSL, `client_max_body_size`)
178
254
  3. Auto-set `HTTPS_ENABLED=false` and `TRUST_PROXY=1` in `server/.env` when nginx is enabled
179
255
 
256
+ ## Security
257
+
258
+ - Token authentication with timing-safe comparison
259
+ - Symlink traversal protection on all file operations
260
+ - Unauthenticated WebSocket connection limits
261
+ - TOCTOU download guard (streaming size check)
262
+ - CSP headers (frame-ancestors, base-uri, form-action)
263
+ - Rate limiting (configurable read/write thresholds)
264
+
180
265
  ## License
181
266
 
182
267
  MIT
package/README.zh-CN.md CHANGED
@@ -4,9 +4,9 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
5
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-green.svg)](https://nodejs.org/)
6
6
 
7
- 轻量级 Web 终端,在浏览器中访问 Claude Code / Codex 或任意 CLI。
7
+ 在浏览器中运行的 AI 开发环境。持久化终端会话、结构化任务生命周期、自主执行 单个 Node.js 进程即可运行。
8
8
 
9
- 适合**网络不稳定、SSH 经常断线**的场景,也可作为**本地有状态终端**使用 会话、布局和草稿在刷新后自动恢复。
9
+ 专为在不稳定网络下运行 Claude Code、Codex CLI、Gemini CLI 或任意 AI CLI 而构建。tmux 保证断网后进程存活;浏览器 UI 在终端旁提供规划、批注和对话面板。
10
10
 
11
11
  **npm:** https://www.npmjs.com/package/ai-cli-online | **GitHub:** https://github.com/huacheng/ai-cli-online
12
12
 
@@ -14,49 +14,110 @@
14
14
 
15
15
  ![screenshot](screenshot.jpg)
16
16
 
17
- ## 功能特性
17
+ ## 核心能力
18
+
19
+ **终端 + 规划 + 执行,一屏完成:**
20
+
21
+ ```
22
+ ┌─ 标签页 ────────────────────────────────────────────────────┐
23
+ │ ┌─ Plan 面板 ──────┬─ 终端 ─────────────────────────────┐ │
24
+ │ │ AiTasks/ 文件浏览 │ │ │
25
+ │ │ Markdown 查看器 │ $ /ai-cli-task auto my-feature │ │
26
+ │ │ 内联批注 │ ▶ 规划中... │ │
27
+ │ │ (插入/删除/ │ ▶ 检查(post-plan): 通过 │ │
28
+ │ │ 替换/评注) │ ▶ 执行步骤 1/4... │ │
29
+ │ │ │ ▶ 执行步骤 2/4... │ │
30
+ │ │ Mermaid 图表 │ ... │ │
31
+ │ │ ├────────────────────────────────────┤ │
32
+ │ │ │ Chat 编辑器 │ │
33
+ │ │ │ 多行 Markdown + /命令 │ │
34
+ │ └───────────────────┴────────────────────────────────────┘ │
35
+ └──────────────────────────────────────────────────────────────┘
36
+ ```
37
+
38
+ - **Plan 面板** — 浏览 `AiTasks/` 文件,4 种批注类型标注文档,向 AI 发送结构化反馈
39
+ - **终端** — 完整 xterm.js + WebGL 渲染,二进制协议实现超低延迟
40
+ - **Chat 编辑器** — 多行 Markdown 编辑器,斜杠命令,草稿服务端持久化
41
+ - 三个面板可同时打开,各自独立调整大小
42
+
43
+ ## AI 任务生命周期
44
+
45
+ `ai-cli-task` 插件提供 8 个 skill 的完整任务执行生命周期:
46
+
47
+ ```
48
+ init → plan → check → exec → check → merge → report
49
+ ↑ ↓
50
+ re-plan ←──┘ (遇到问题时)
51
+ ```
52
+
53
+ | Skill | 功能 |
54
+ |-------|------|
55
+ | **init** | 创建任务模块 (`AiTasks/<name>/`),git 分支,可选 worktree |
56
+ | **plan** | 生成实施计划或处理人工批注 |
57
+ | **check** | 在 3 个检查点评估可行性 (post-plan / mid-exec / post-exec) |
58
+ | **exec** | 逐步执行计划,每步验证 |
59
+ | **merge** | 合并任务分支到主干,冲突解决(最多 3 次重试) |
60
+ | **report** | 生成完成报告,提炼经验到知识库 |
61
+ | **auto** | 在单个 Claude 会话中自主运行完整生命周期 |
62
+ | **cancel** | 停止执行,设为已取消,可选清理 |
63
+
64
+ ### 自主模式
65
+
66
+ ```bash
67
+ /ai-cli-task auto my-feature
68
+ ```
69
+
70
+ 一条命令触发完整生命周期。单个 Claude 会话在内部依次运行 plan → check → exec → merge → report,所有步骤共享上下文。守护进程通过 `.auto-signal` 文件监控进度,强制超时,检测停滞。
71
+
72
+ ### 任务结构
73
+
74
+ ```
75
+ AiTasks/
76
+ ├── .index.md # 模块索引
77
+ ├── .experience/ # 跨任务知识库(按领域类型分类)
78
+ │ ├── software.md
79
+ │ └── <type>.md
80
+ └── my-feature/
81
+ ├── .index.md # 状态、阶段、时间戳、依赖 (YAML)
82
+ ├── .target.md # 需求描述(人工编写)
83
+ ├── .summary.md # 浓缩上下文(防止上下文溢出)
84
+ ├── .analysis/ # 评估历史
85
+ ├── .test/ # 测试标准与结果
86
+ ├── .bugfix/ # 问题历史
87
+ ├── .notes/ # 研究发现
88
+ ├── .report.md # 完成报告
89
+ └── plan.md # 实施计划
90
+ ```
91
+
92
+ ### 类型感知执行
93
+
94
+ 任务按领域类型分类(`software`、`dsp`、`ml`、`literary`、`science:physics` 等)。每种类型会调整规划方法、执行工具和验证标准。已完成任务的经验存储在 `.experience/<type>.md` 中,供同类型的后续任务参考。
95
+
96
+ ## 终端特性
18
97
 
19
- - **完整 Web 终端** — xterm.js + WebGL 渲染,二进制协议实现超低延迟
20
98
  - **会话持久化** — tmux 保证断网后进程存活;固定 socket 路径,服务重启后自动重连
21
99
  - **Tab 多标签页** — 独立终端分组,布局跨刷新持久化
22
100
  - **分屏布局** — 水平/垂直任意嵌套分割
23
- - **Mermaid 图表** 甘特图、流程图等 Mermaid 图表暗色主题内联渲染,CDN 双源容错
24
- - **Plan 批注**4 种批注类型(插入/删除/替换/评注),选中文本弹出浮动按钮组,持久化存储
25
- - **编辑器面板**多行编辑 + 草稿服务端持久化 (SQLite) + undo 撤销栈 + 斜杠命令(`/history` 等)
26
- - **复制粘贴** — 鼠标选中自动复制到剪贴板,右键粘贴到终端
27
- - **文件传输** — 上传文件到 CWD,浏览/下载通过 REST API
101
+ - **二进制协议**1 字节前缀帧用于终端 I/O,TCP Nagle 禁用,WebSocket 压缩
102
+ - **WebGL 渲染**吞吐量比 canvas 提升 3-10 倍
103
+ - **复制粘贴**鼠标选中自动复制,右键粘贴
28
104
  - **滚动历史** — capture-pane 回看,保留 ANSI 颜色
29
- - **会话管理**侧边栏管理 session(恢复/删除/重命名)
30
- - **中文等宽字体**通过 CDN 加载霞鹜文楷等宽 (LXGW WenKai Mono),unicode-range 按需分片,浏览器仅下载实际用到的字符
31
- - **字体大小控制** — 可调节终端字体大小 (A−/A+),设置服务端持久化
32
- - **版本号显示** — Header 显示当前版本号,构建时从 `package.json` 自动注入
33
- - **网络指示器** — 实时 RTT 延迟显示 + 信号条
105
+ - **文件传输**上传/下载文件,浏览目录,CWD 打包下载为 tar.gz
106
+ - **网络指示器**实时 RTT 延迟 + 信号条
34
107
  - **自动重连** — 指数退避 + jitter 防雷群效应
35
- - **安全认证** — Token 认证 + timing-safe 比较
36
- - **安全加固** — symlink 穿越防护、未认证 WebSocket 连接限制、TOCTOU 下载防护、CSP Headers (frame-ancestors / base-uri / form-action)
37
-
38
- ## 功能对比:AI-Cli Online vs OpenClaw
39
-
40
- | 维度 | AI-Cli Online | OpenClaw |
41
- |------|--------------|----------|
42
- | **定位** | 轻量 Web 终端 | AI Agent 编排平台 |
43
- | **核心用途** | 浏览器远程终端访问 | 多渠道 AI 助手 |
44
- | **终端仿真** | xterm.js + WebGL | |
45
- | **会话持久化** | tmux(断网存活) | Gateway 内存状态 |
46
- | **多标签/分屏** | Tab + 任意嵌套分屏 | 无 |
47
- | **消息渠道** | WebSocket 单通道 | 16+(WhatsApp / Telegram / Slack / Discord...) |
48
- | **原生应用** | 无(纯 Web) | macOS + iOS + Android |
49
- | **语音交互** | 无 | Voice Wake + Talk Mode |
50
- | **AI Agent** | 无内置(运行任意 CLI) | Pi Agent 运行时 + 多 Agent 路由 |
51
- | **Canvas/UI** | Plan 批注系统(Markdown) | A2UI 实时可视化工作区 |
52
- | **文件传输** | REST API 上传/下载 | 渠道原生媒体 |
53
- | **安全模型** | Token auth + timing-safe | 设备配对 + DM 策略 + Docker 沙箱 |
54
- | **可扩展性** | Shell 脚本 | 33 扩展 + 60+ Skills + ClawHub |
55
- | **传输协议** | 二进制帧(超低延迟) | JSON WebSocket |
56
- | **部署** | 单机 Node.js | 单机 + Tailscale Serve/Funnel |
57
- | **技术栈** | React + Express + node-pty | Lit + Express + Pi Agent |
58
- | **包大小** | ~1 MB | ~300 MB+ |
59
- | **安装** | `npx ai-cli-online` | `npm i -g openclaw && openclaw onboard` |
108
+
109
+ ## 批注系统
110
+
111
+ Plan 面板提供 4 种批注类型,用于向 AI 发送结构化反馈:
112
+
113
+ | 类型 | 图标 | 说明 |
114
+ |------|------|------|
115
+ | **插入** | `+` | 在指定位置添加内容 |
116
+ | **删除** | `−` | 标记待删除的文本 |
117
+ | **替换** | `↔` | 用新文本替换旧文本 |
118
+ | **评注** | `?` | 提问或留下备注 |
119
+
120
+ 批注双层持久化(localStorage + SQLite),以结构化 JSON 发送给 AI。`plan` skill 处理批注 按影响分级、应用变更、更新任务文件。
60
121
 
61
122
  ## 快速开始
62
123
 
@@ -106,49 +167,64 @@ TRUST_PROXY=1 # nginx 反代时设为 1
106
167
  ## 架构
107
168
 
108
169
  ```
109
- 浏览器 (xterm.js + WebGL) <-- WebSocket binary/JSON --> Express (node-pty) <--> tmux session --> shell
170
+ 浏览器 (xterm.js + WebGL)
171
+ ├── Plan 面板 (批注编辑器)
172
+ ├── Chat 编辑器 (Markdown + /命令)
173
+ └── 终端视图 (WebGL 渲染器)
174
+
175
+ ↕ WebSocket binary/JSON + REST API
176
+
177
+ Express 服务 (Node.js)
178
+ ├── WebSocket ↔ PTY relay
179
+ ├── tmux 会话管理
180
+ ├── 文件传输 API
181
+ ├── SQLite (草稿、批注、设置)
182
+ └── 路由模块 (sessions, files, editor, settings)
183
+
184
+ ↕ PTY / tmux sockets
185
+
186
+ tmux sessions → shell → Claude Code / AI agents
187
+ └── AiTasks/ 生命周期 (init/plan/check/exec/merge/report/auto)
110
188
  ```
111
189
 
112
- - **前端**: React + Zustand + xterm.jsWebGL 渲染)
190
+ - **前端**: React + Zustand + xterm.js (WebGL)
113
191
  - **后端**: Node.js + Express + node-pty + WebSocket + better-sqlite3
114
192
  - **会话管理**: tmux(持久化终端会话)
115
- - **布局系统**: Tab 标签页 + 递归树形结构(LeafNode / SplitNode)
193
+ - **布局系统**: Tab 标签页 + 递归分割树(LeafNode / SplitNode)
116
194
  - **传输协议**: 二进制帧(热路径)+ JSON(控制消息)
117
- - **数据持久化**: SQLite(编辑器草稿)
118
-
119
- ### 性能优化
120
-
121
- - **二进制协议** — 1 字节前缀帧用于终端 I/O,消除 JSON 序列化开销
122
- - **TCP Nagle 禁用** — `setNoDelay(true)` 消除最多 40 ms 按键延迟
123
- - **WebSocket 压缩** — `perMessageDeflate`(level 1,threshold 128 B),带宽减少 50-70%
124
- - **WebGL 渲染器** — 渲染吞吐量提升 3-10 倍
125
- - **并行初始化** — PTY 创建、tmux 配置、resize 并行执行
126
- - **智能重渲染** — 响应式布局 hook、条件 Zustand selector、分批 stat 调用
195
+ - **任务系统**: 8-skill 插件,状态机 + 依赖门控 + 经验知识库
127
196
 
128
197
  ## 项目结构
129
198
 
130
199
  ```
131
200
  ai-cli-online/
132
- ├── shared/ # 共享类型定义 (ClientMessage, ServerMessage)
133
- ├── server/ # 后端服务 (TypeScript)
134
- └── src/
135
- ├── index.ts # 主入口 (HTTP + WebSocket + REST API)
136
- ├── websocket.ts # WebSocket <-> PTY 双向 relay (二进制 + JSON)
137
- ├── tmux.ts # tmux 会话管理
138
- ├── files.ts # 文件操作
139
- ├── pty.ts # node-pty 封装
140
- ├── db.ts # SQLite 数据库 (草稿持久化)
141
- ├── auth.ts # 认证工具
142
- └── types.ts # 类型定义
143
- ├── web/ # 前端应用 (React + Vite)
144
- └── src/
145
- ├── App.tsx # 主应用组件
146
- ├── store.ts # Zustand 状态管理
147
- ├── components/ # UI 组件
148
- ├── hooks/ # React Hooks
149
- └── api/ # API 客户端
150
- ├── start.sh # 生产启动脚本
151
- └── package.json # Monorepo 配置
201
+ ├── shared/ # 共享类型定义
202
+ ├── server/src/
203
+ ├── index.ts # 主入口 (中间件 + 路由 + 服务)
204
+ ├── websocket.ts # WebSocket PTY relay (二进制 + JSON)
205
+ ├── tmux.ts # tmux 会话管理
206
+ ├── files.ts # 文件操作 + 路径校验
207
+ ├── pty.ts # node-pty 封装
208
+ ├── db.ts # SQLite 数据库
209
+ ├── auth.ts # 认证工具
210
+ ├── middleware/ # 认证中间件
211
+ └── routes/ # REST API 路由 (sessions, files, editor, settings)
212
+ ├── web/src/
213
+ ├── App.tsx # 主应用 (登录 / TabBar / 终端 / 主题)
214
+ ├── store/ # Zustand 状态管理 (模块化切片)
215
+ ├── components/
216
+ ├── TerminalPane.tsx # 2D 网格布局 (Plan + 终端 + Chat)
217
+ ├── TerminalView.tsx # xterm.js 终端
218
+ │ ├── PlanPanel.tsx # Plan 批注面板
219
+ │ │ ├── PlanAnnotationRenderer.tsx # Markdown + 内联批注
220
+ │ │ ├── PlanFileBrowser.tsx # AiTasks/ 文件浏览器
221
+ │ │ ├── MarkdownEditor.tsx # Chat 编辑器
222
+ │ │ └── ...
223
+ │ ├── hooks/ # React Hooks (WebSocket, 文件流, resize 等)
224
+ │ └── api/ # 类型化 API 客户端模块
225
+ ├── bin/ # npx 入口
226
+ ├── start.sh # 生产启动脚本
227
+ └── install-service.sh # systemd + nginx 安装器
152
228
  ```
153
229
 
154
230
  ## 开发
@@ -177,6 +253,15 @@ sudo journalctl -u ai-cli-online -f # 查看日志
177
253
  2. 检测 nginx 并可选配置反向代理(WebSocket 支持、SSL、`client_max_body_size`)
178
254
  3. nginx 启用时自动设置 `HTTPS_ENABLED=false` 和 `TRUST_PROXY=1`
179
255
 
256
+ ## 安全
257
+
258
+ - Token 认证 + timing-safe 比较
259
+ - 所有文件操作的 symlink 穿越防护
260
+ - 未认证 WebSocket 连接限制
261
+ - TOCTOU 下载防护(流式大小检查)
262
+ - CSP Headers (frame-ancestors, base-uri, form-action)
263
+ - 限速(可配置读/写阈值)
264
+
180
265
  ## License
181
266
 
182
267
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-cli-online",
3
- "version": "2.9.9",
3
+ "version": "3.0.2",
4
4
  "description": "AI-Cli Online - Web Terminal for Claude Code via xterm.js + tmux",
5
5
  "license": "MIT",
6
6
  "bin": {