@fefeding/aicmd 0.1.1 → 0.1.3

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
@@ -1,160 +1,236 @@
1
- # fTerm
1
+ # AICmd
2
2
 
3
- A web-based SSH remote terminal tool with support for rz/sz file transfer.
3
+ An AI-powered web SSH terminal that combines a full-featured terminal emulator with an autonomous AI agent. The AI understands your system environment, executes commands, analyzes logs, manages services — all through natural language conversation.
4
4
 
5
5
  ## Features
6
6
 
7
- - **Web SSH Terminal**: High-performance terminal experience based on xterm.js
8
- - **Local Shell Support**: Native local shell access via node-pty
9
- - **File Transfer**: Supports rz/sz (ZMODEM) file upload and download
10
- - **Multi-Session Management**: Manage multiple SSH/local shell sessions simultaneously
11
- - **Connection Management**: Visual connection configuration management (CRUD)
12
- - **Desktop App**: Packaged as a cross-platform desktop client via NW.js
7
+ ### AI Agent
8
+ - **Autonomous Operation**: AI agent directly executes commands in the terminal via tool calling (OpenAI function calling protocol). It observes output, makes decisions, and iterates until the task is done.
9
+ - **System Awareness**: Automatically detects OS, CPU, memory, disk, installed services, and available languages on first connection. The AI always knows what system it's working with.
10
+ - **Script Generation**: For complex multi-step tasks, the agent generates and executes scripts (Bash/Python/PowerShell) instead of running commands one by one.
11
+ - **Cross-Platform Intelligence**: Adapts commands based on target OS — uses `systemctl` on Linux, `launchctl` on macOS, `Get-Service` on Windows.
12
+
13
+ ### Skills System
14
+ - **Built-in Skills**: Pre-configured operational playbooks for common tasks:
15
+ - Server Health Check — comprehensive system metrics collection
16
+ - Log Analysis — error pattern detection with Python/awk scripts
17
+ - Docker Management — container lifecycle operations
18
+ - **Custom Skills**: Create your own skills as markdown files in `~/.aicmd/skills/`. Skills define domain-specific SOPs, project-specific knowledge, or any workflow the LLM doesn't already know.
19
+ - **Slash Commands**: Trigger skills with `/skill-name` in the chat input.
20
+
21
+ ### Terminal
22
+ - **SSH Remote Terminal**: Full SSH client based on xterm.js + ssh2 with 256-color support.
23
+ - **Local Shell**: Native local shell via node-pty (Bash/Zsh on macOS/Linux, PowerShell on Windows).
24
+ - **File Transfer**: rz/sz (ZMODEM) file upload and download with automatic binary handling.
25
+ - **Multi-Session**: Tab-based multi-session management with persistent state across restarts.
26
+ - **Auto-Reconnect**: One-click reconnection for dropped SSH sessions.
27
+ - **Session Persistence**: All sessions and chat history are persisted on the server side.
28
+
29
+ ### General
30
+ - **Connection Management**: Visual SSH connection configuration (CRUD) with key-based and password auth.
31
+ - **i18n**: Chinese / English UI with runtime language switching.
32
+ - **Desktop App**: Cross-platform desktop client via NW.js.
33
+ - **Chat History**: Persistent AI conversation history with browsing and restoration across sessions.
13
34
 
14
35
  ## Screenshot
15
36
 
16
- ![fterm Screenshot](./screenshot.png)
37
+ ![AICmd Screenshot](./screenshot.png)
17
38
 
18
39
  ## Tech Stack
19
40
 
20
- - **Frontend**: Vue 3 + TypeScript + Vite + Bootstrap 5 + xterm.js
21
- - **Backend**: Node.js + Express + WebSocket (ws)
22
- - **SSH/PTY**: ssh2 + node-pty
23
- - **Build Tools**: Vite + TypeScript + nw-builder
41
+ | Layer | Technology |
42
+ |-------|-----------|
43
+ | Frontend | Vue 3 + TypeScript + Vite + Bootstrap 5 + xterm.js |
44
+ | Backend | Node.js + Express + WebSocket (ws) |
45
+ | SSH/PTY | ssh2 + node-pty |
46
+ | AI | OpenAI-compatible API (supports any compatible endpoint) |
47
+ | Build | Vite + TypeScript + nw-builder |
24
48
 
25
49
  ## Quick Start
26
50
 
27
51
  ### Install
28
52
 
29
53
  ```bash
30
- npm install -g @fefeding/fterm
54
+ npm install -g @fefeding/aicmd
31
55
  # or
32
- pnpm add -g @fefeding/fterm
56
+ pnpm add -g @fefeding/aicmd
33
57
  ```
34
58
 
35
59
  ### Requirements
36
60
 
37
61
  - Node.js >= 18
38
- - pnpm
39
62
 
40
- ### Install Dependencies
63
+ ### Start Server
41
64
 
42
65
  ```bash
43
- pnpm install
44
- ```
45
-
46
- ### Development Mode
66
+ # Start (default port 9802, auto-finds available port)
67
+ aicmd start
47
68
 
48
- ```bash
49
- pnpm dev
50
- ```
69
+ # Custom port
70
+ aicmd start --port 3000
51
71
 
52
- Visit http://localhost:9801 after starting.
72
+ # Stop / Restart
73
+ aicmd stop
74
+ aicmd restart
53
75
 
54
- ### Build
76
+ # Version
77
+ aicmd -v
78
+ ```
55
79
 
56
- ```bash
57
- # Build frontend + backend
58
- pnpm build
80
+ Then open http://localhost:9802 in your browser.
59
81
 
60
- # Build frontend only
61
- pnpm run build-only
62
- ```
82
+ ### Configure AI
63
83
 
64
- ### Start Production Server
84
+ 1. Click the robot icon (bottom-left sidebar) or the gear icon in the AI chat header.
85
+ 2. Enter your API Key and base URL (supports OpenAI, DeepSeek, Qwen, or any compatible API).
86
+ 3. Choose a model (default: `gpt-4o-mini`).
87
+ 4. Save and start chatting.
65
88
 
66
- After global installation, use the `fterm` CLI command:
89
+ ### Development
67
90
 
68
91
  ```bash
69
- # Start the server (default port 9802)
70
- sudo fterm start
92
+ # Clone and install
93
+ git clone <repo-url>
94
+ pnpm install
71
95
 
72
- # Stop the server
73
- fterm stop
96
+ # Dev mode (with hot reload)
97
+ pnpm dev
98
+ # Visit http://localhost:9801
74
99
 
75
- # Restart the server
76
- fterm restart
100
+ # Build
101
+ pnpm build # Frontend + server
102
+ pnpm build-server # Server only
77
103
 
78
- # Show version
79
- fterm -v
104
+ # Start production
105
+ node server.js --port 3000
80
106
  ```
81
107
 
82
- You can also start directly with Node.js:
108
+ ### Desktop App (NW.js)
83
109
 
84
110
  ```bash
85
- node server.js
111
+ pnpm nw:dev # Dev mode
112
+ pnpm nw:build # Current platform
113
+ pnpm nw:build:win # Windows
114
+ pnpm nw:build:osx # macOS
115
+ pnpm nw:build:linux # Linux
86
116
  ```
87
117
 
88
- Or use npm scripts in the project directory:
89
-
90
- ```bash
91
- # Start the server
92
- npm start
93
-
94
- # Stop the server
95
- npm stop
118
+ ## AI Usage Examples
96
119
 
97
- # Restart the server
98
- npm restart
120
+ ### Natural Language Operations
99
121
  ```
122
+ You: Check if nginx is running and show recent error logs
123
+ AI: [executes systemctl status nginx, then reads error logs, provides analysis]
100
124
 
101
- Default port is 9802. You can specify a custom port via `--port` or the `PORT` environment variable:
125
+ You: Find the top 5 processes consuming memory
126
+ AI: [generates and runs a ps/sort script, presents results as a table]
102
127
 
103
- ```bash
104
- node server.js --port 3000
128
+ You: Clean up Docker images older than 7 days
129
+ AI: [runs docker system prune with filters, reports freed space]
105
130
  ```
106
131
 
107
- ### Desktop App (NW.js)
132
+ ### Using Skills
133
+ ```
134
+ You: /server-health-check
135
+ AI: [generates a comprehensive health check script, executes it, analyzes all metrics]
108
136
 
109
- ```bash
110
- # Development mode
111
- pnpm nw:dev
137
+ You: /log-analyze /var/log/nginx/error.log
138
+ AI: [creates a Python analysis script, shows error distribution and patterns]
139
+ ```
112
140
 
113
- # Build for all platforms
114
- pnpm nw:build # Current platform
115
- pnpm nw:build:win # Windows
116
- pnpm nw:build:osx # macOS
117
- pnpm nw:build:linux # Linux
141
+ ### Custom Skills
142
+
143
+ Create `~/.aicmd/skills/my-deploy.md`:
144
+ ```markdown
145
+ ---
146
+ name: Deploy My App
147
+ description: Deploy the production application with zero-downtime
148
+ tags: [deploy, ops]
149
+ ---
150
+
151
+ Steps to deploy:
152
+ 1. Pull latest code from git
153
+ 2. Run database migrations
154
+ 3. Build assets
155
+ 4. Restart with PM2 (graceful reload)
156
+ ...
118
157
  ```
119
158
 
159
+ Then trigger with `/deploy-my-app` in the chat.
160
+
120
161
  ## Project Structure
121
162
 
122
163
  ```
123
164
  .
124
- ├── bin/ # CLI entry
165
+ ├── bin/ # CLI entry (aicmd command)
166
+ ├── data/skills/ # Built-in AI skills
125
167
  ├── dist/ # Build output
126
168
  ├── public/ # Static assets
127
- ├── scripts/ # Build scripts
128
- ├── server/ # Server-side source (TypeScript)
169
+ ├── scripts/ # Build scripts (NW.js)
170
+ ├── server/ # Server source (TypeScript)
129
171
  │ ├── model/ # Entity definitions
130
- │ ├── service/ # Business logic
131
- │ └── index.ts # Server entry point
132
- ├── src/ # Frontend source
133
- │ ├── adapter/ # Data adapter layer
134
- │ ├── base/ # Base modules
172
+ │ ├── service/ # Business logic (AI, SSH, Skills)
173
+ │ └── index.ts # Server entry
174
+ ├── src/ # Frontend source (Vue 3)
135
175
  │ ├── components/ # Vue components
136
- │ ├── platform/ # Platform entry
137
- │ ├── service/ # Frontend services
176
+ │ │ ├── ai-chat/ # AI chat panel
177
+ │ │ ├── ai-settings/ # AI config modal
178
+ │ │ └── ... # Terminal, sidebar, etc.
179
+ │ ├── locales/ # i18n translations
180
+ │ ├── service/ # Frontend API services
138
181
  │ ├── stores/ # Pinia state management
139
- │ ├── utils/ # Utility functions
140
182
  │ └── views/ # Page views
141
183
  ├── view/ # HTML templates
142
- └── server.js # Production startup script
184
+ └── server.js # Production startup
143
185
  ```
144
186
 
145
- ## Development Notes
187
+ ## Data Storage
188
+
189
+ All data is stored locally on the server:
190
+
191
+ | Data | Path |
192
+ |------|------|
193
+ | Connections | `~/.aicmd/connections.json` |
194
+ | Sessions | `~/.aicmd/sessions.json` |
195
+ | AI Config | `~/.aicmd/ai-config.json` |
196
+ | Chat History | `~/.aicmd/ai-history/` |
197
+ | User Skills | `~/.aicmd/skills/*.md` |
198
+ | Trash Bin | `~/.aicmd/.trash/` |
199
+
200
+ Use `AICMD_DATA_DIR` environment variable to override the data directory.
201
+
202
+ ## Safety Mechanisms
203
+
204
+ The AI agent includes built-in command-level safety protections to reduce the risk of destructive operations:
205
+
206
+ ### Delete Protection (Trash Bin)
207
+ - All `rm` commands (Linux/macOS) are automatically rewritten to `mv` into `~/.aicmd/.trash/` instead of permanent deletion.
208
+ - Windows `Remove-Item`/`del`/`rd` commands are similarly rewritten to `Move-Item` into `%USERPROFILE%\.aicmd\.trash\`.
209
+ - Trashed files are timestamped (e.g. `_del_1716000000_filename`) to avoid naming conflicts.
210
+ - To recover a file, simply browse the trash directory and move it back.
211
+
212
+ ### Dangerous Operation Blocking
213
+ The following irreversible, destructive operations are blocked entirely:
146
214
 
147
- ### Server-Side Development
215
+ | Platform | Blocked Operations |
216
+ |----------|-------------------|
217
+ | Linux/macOS | `rm -rf /`, `mkfs.*` (disk formatting), `dd of=/dev/sd*` (disk overwrite), fork bombs |
218
+ | Windows | `format C:`, `Clear-Disk`, `Remove-Item C:\`, `rd /s C:\` |
148
219
 
149
- Server code is located in the `server/` directory, written in TypeScript. In development mode, Vite directly references the source code, so no manual compilation is needed.
220
+ ### Platform Awareness
221
+ The safety layer automatically detects the target session's OS (via systemContext) and applies the appropriate Unix or Windows rules — no manual configuration required.
150
222
 
151
- ### Frontend Development
223
+ ## Cross-Platform Support
152
224
 
153
- The frontend uses Vue 3 Composition API + Pinia for state management, with Bootstrap 5 as the UI framework.
225
+ The terminal and AI agent work on:
154
226
 
155
- ### Connection Configuration
227
+ | Platform | Shell | AI Scripting |
228
+ |----------|-------|-------------|
229
+ | Linux | bash/zsh | Bash + Python + Node.js |
230
+ | macOS | zsh/bash | Bash + Python + Node.js |
231
+ | Windows | PowerShell 7+/5.x | PowerShell + Python + Node.js |
156
232
 
157
- Connection information is persisted in local files on the server side.
233
+ The AI agent automatically detects the target OS and selects appropriate commands.
158
234
 
159
235
  ## License
160
236
 
package/README.zh.md CHANGED
@@ -1,160 +1,236 @@
1
- # fTerm
2
-
3
- Web SSH 远程终端工具,支持 rz/sz 文件传输。
4
-
5
- ## 特性
6
-
7
- - **Web SSH 终端**:基于 xterm.js 的高性能终端体验
8
- - **本地 Shell 支持**:通过 node-pty 提供原生本地 Shell 访问
9
- - **文件传输**:支持 rz/sz (ZMODEM) 文件上传下载
10
- - **多会话管理**:支持同时管理多个 SSH/本地 Shell 会话
11
- - **连接管理**:可视化的连接配置管理(增删改查)
12
- - **桌面应用**:支持 NW.js 打包为跨平台桌面客户端
1
+ # AICmd
2
+
3
+ AI 驱动的 Web SSH 终端工具,将全功能终端仿真器与自主 AI Agent 结合。AI 能理解系统环境、执行命令、分析日志、管理服务 —— 一切通过自然语言对话完成。
4
+
5
+ ## 功能特性
6
+
7
+ ### AI Agent
8
+ - **自主操作**:AI Agent 通过工具调用(OpenAI function calling)直接在终端执行命令,观察输出、做出决策、迭代执行直到任务完成
9
+ - **系统感知**:首次连接时自动检测操作系统、CPU、内存、磁盘、已安装服务和可用语言,AI 始终了解当前系统环境
10
+ - **脚本生成**:复杂多步骤任务时,Agent 自动生成并执行脚本(Bash/Python/PowerShell),而非逐条运行命令
11
+ - **跨平台智能**:根据目标系统自动适配命令 —— Linux 用 `systemctl`、macOS 用 `launchctl`、Windows 用 `Get-Service`
12
+
13
+ ### Skills 系统
14
+ - **内置 Skills**:预置常用运维操作模板:
15
+ - 服务器健康检查 —— 全面采集系统指标
16
+ - 日志分析 —— Python/awk 脚本进行错误模式检测
17
+ - Docker 管理 —— 容器生命周期操作
18
+ - **自定义 Skills**:在 `~/.aicmd/skills/` 创建 markdown 文件,定义特定领域的 SOP、项目专属知识或任何 LLM 不具备的工作流
19
+ - **斜杠命令**:在聊天输入框中用 `/skill-name` 快速触发 Skill
20
+
21
+ ### 终端
22
+ - **SSH 远程终端**:基于 xterm.js + ssh2 的完整 SSH 客户端,支持 256 色
23
+ - **本地 Shell**:通过 node-pty 提供原生本地 Shell(macOS/Linux 为 Bash/Zsh,Windows 为 PowerShell)
24
+ - **文件传输**:支持 rz/sz (ZMODEM) 文件上传下载,自动处理二进制数据
25
+ - **多会话管理**:基于标签页的多会话管理,状态跨重启持久化
26
+ - **自动重连**:SSH 断开后一键重连
27
+ - **会话持久化**:所有会话和对话历史在服务端持久化存储
28
+
29
+ ### 通用功能
30
+ - **连接管理**:可视化的 SSH 连接配置(增删改查),支持密钥和密码认证
31
+ - **国际化**:中文/英文界面,运行时切换
32
+ - **桌面应用**:通过 NW.js 打包为跨平台桌面客户端
33
+ - **对话历史**:AI 对话历史持久化,支持跨会话浏览和恢复
13
34
 
14
35
  ## 截图
15
36
 
16
- ![fterm 截图](./screenshot.png)
37
+ ![AICmd 截图](./screenshot.png)
17
38
 
18
39
  ## 技术栈
19
40
 
20
- - **前端**:Vue 3 + TypeScript + Vite + Bootstrap 5 + xterm.js
21
- - **后端**:Node.js + Express + WebSocket (ws)
22
- - **SSH/PTY**:ssh2 + node-pty
23
- - **构建工具**:Vite + TypeScript + nw-builder
41
+ | 层级 | 技术 |
42
+ |------|------|
43
+ | 前端 | Vue 3 + TypeScript + Vite + Bootstrap 5 + xterm.js |
44
+ | 后端 | Node.js + Express + WebSocket (ws) |
45
+ | SSH/PTY | ssh2 + node-pty |
46
+ | AI | OpenAI 兼容 API(支持任意兼容端点) |
47
+ | 构建 | Vite + TypeScript + nw-builder |
24
48
 
25
49
  ## 快速开始
26
50
 
27
51
  ### 安装
28
52
 
29
53
  ```bash
30
- npm install -g @fefeding/fterm
54
+ npm install -g @fefeding/aicmd
31
55
  # 或
32
- pnpm add -g @fefeding/fterm
56
+ pnpm add -g @fefeding/aicmd
33
57
  ```
34
58
 
35
59
  ### 环境要求
36
60
 
37
61
  - Node.js >= 18
38
- - pnpm
39
62
 
40
- ### 安装依赖
63
+ ### 启动服务
41
64
 
42
65
  ```bash
43
- pnpm install
44
- ```
66
+ # 启动(默认端口 9802,自动寻找可用端口)
67
+ aicmd start
45
68
 
46
- ### 开发模式
69
+ # 自定义端口
70
+ aicmd start --port 3000
47
71
 
48
- ```bash
49
- pnpm dev
50
- ```
51
-
52
- 启动后访问 http://localhost:9801
72
+ # 停止 / 重启
73
+ aicmd stop
74
+ aicmd restart
53
75
 
54
- ### 构建
76
+ # 查看版本
77
+ aicmd -v
78
+ ```
55
79
 
56
- ```bash
57
- # 构建前端 + 服务端
58
- pnpm build
80
+ 然后在浏览器打开 http://localhost:9802。
59
81
 
60
- # 仅构建前端
61
- pnpm run build-only
62
- ```
82
+ ### 配置 AI
63
83
 
64
- ### 启动生产服务
84
+ 1. 点击左下角侧边栏的机器人图标,或 AI 对话面板头部的齿轮图标
85
+ 2. 输入 API Key 和 Base URL(支持 OpenAI、DeepSeek、通义千问或任何兼容 API)
86
+ 3. 选择模型(默认 `gpt-4o-mini`)
87
+ 4. 保存后开始对话
65
88
 
66
- 全局安装后,使用 `fterm` CLI 命令:
89
+ ### 开发
67
90
 
68
91
  ```bash
69
- # 启动服务(默认端口 9802)
70
- sudo fterm start
92
+ # 克隆并安装
93
+ git clone <repo-url>
94
+ pnpm install
71
95
 
72
- # 停止服务
73
- fterm stop
96
+ # 开发模式(热更新)
97
+ pnpm dev
98
+ # 访问 http://localhost:9801
74
99
 
75
- # 重启服务
76
- fterm restart
100
+ # 构建
101
+ pnpm build # 前端 + 服务端
102
+ pnpm build-server # 仅服务端
77
103
 
78
- # 查看版本
79
- fterm -v
104
+ # 生产启动
105
+ node server.js --port 3000
80
106
  ```
81
107
 
82
- 也可以直接通过 Node.js 启动:
108
+ ### 桌面应用(NW.js)
83
109
 
84
110
  ```bash
85
- node server.js
111
+ pnpm nw:dev # 开发模式
112
+ pnpm nw:build # 当前平台
113
+ pnpm nw:build:win # Windows
114
+ pnpm nw:build:osx # macOS
115
+ pnpm nw:build:linux # Linux
86
116
  ```
87
117
 
88
- 或者在项目目录下使用 npm 脚本管理:
118
+ ## AI 使用示例
89
119
 
90
- ```bash
91
- # 启动服务
92
- npm start
93
-
94
- # 停止服务
95
- npm stop
96
-
97
- # 重启服务
98
- npm restart
120
+ ### 自然语言操作
99
121
  ```
122
+ 你: 检查 nginx 是否在运行,并显示最近的错误日志
123
+ AI: [执行 systemctl status nginx,读取错误日志,提供分析]
100
124
 
101
- 默认端口 9802,可通过 `--port` 或 `PORT` 环境变量指定:
125
+ 你: 找出内存占用最高的 5 个进程
126
+ AI: [生成并运行 ps/sort 脚本,以表格展示结果]
102
127
 
103
- ```bash
104
- node server.js --port 3000
128
+ 你: 清理 7 天前的 Docker 镜像
129
+ AI: [运行 docker system prune 并过滤,报告释放的空间]
105
130
  ```
106
131
 
107
- ### 桌面应用(NW.js)
132
+ ### 使用 Skills
133
+ ```
134
+ 你: /server-health-check
135
+ AI: [生成全面健康检查脚本,执行后分析所有指标]
108
136
 
109
- ```bash
110
- # 开发模式
111
- pnpm nw:dev
137
+ 你: /log-analyze /var/log/nginx/error.log
138
+ AI: [创建 Python 分析脚本,展示错误分布和模式]
139
+ ```
112
140
 
113
- # 构建各平台
114
- pnpm nw:build # 当前平台
115
- pnpm nw:build:win # Windows
116
- pnpm nw:build:osx # macOS
117
- pnpm nw:build:linux # Linux
141
+ ### 自定义 Skill
142
+
143
+ 创建 `~/.aicmd/skills/my-deploy.md`:
144
+ ```markdown
145
+ ---
146
+ name: 部署应用
147
+ description: 零停机部署生产应用
148
+ tags: [deploy, ops]
149
+ ---
150
+
151
+ 部署步骤:
152
+ 1. 从 git 拉取最新代码
153
+ 2. 运行数据库迁移
154
+ 3. 构建资源文件
155
+ 4. 使用 PM2 平滑重启
156
+ ...
118
157
  ```
119
158
 
159
+ 然后在对话中输入 `/deploy-my-app` 触发。
160
+
120
161
  ## 项目结构
121
162
 
122
163
  ```
123
164
  .
124
- ├── bin/ # CLI 入口
165
+ ├── bin/ # CLI 入口(aicmd 命令)
166
+ ├── data/skills/ # 内置 AI Skills
125
167
  ├── dist/ # 构建产物
126
168
  ├── public/ # 静态资源
127
- ├── scripts/ # 构建脚本
169
+ ├── scripts/ # 构建脚本(NW.js)
128
170
  ├── server/ # 服务端源码(TypeScript)
129
171
  │ ├── model/ # 实体定义
130
- │ ├── service/ # 业务逻辑
172
+ │ ├── service/ # 业务逻辑(AI、SSH、Skills)
131
173
  │ └── index.ts # 服务端入口
132
- ├── src/ # 前端源码
133
- │ ├── adapter/ # 数据适配层
134
- │ ├── base/ # 基础模块
174
+ ├── src/ # 前端源码(Vue 3)
135
175
  │ ├── components/ # Vue 组件
136
- │ ├── platform/ # 平台入口
137
- │ ├── service/ # 前端服务
176
+ │ │ ├── ai-chat/ # AI 对话面板
177
+ │ │ ├── ai-settings/ # AI 配置弹窗
178
+ │ │ └── ... # 终端、侧边栏等
179
+ │ ├── locales/ # 国际化翻译
180
+ │ ├── service/ # 前端 API 服务
138
181
  │ ├── stores/ # Pinia 状态管理
139
- │ ├── utils/ # 工具函数
140
182
  │ └── views/ # 页面视图
141
183
  ├── view/ # HTML 模板
142
- └── server.js # 生产环境启动脚本
184
+ └── server.js # 生产环境启动
143
185
  ```
144
186
 
145
- ## 开发说明
187
+ ## 数据存储
188
+
189
+ 所有数据本地存储在服务端:
190
+
191
+ | 数据 | 路径 |
192
+ |------|------|
193
+ | 连接配置 | `~/.aicmd/connections.json` |
194
+ | 会话数据 | `~/.aicmd/sessions.json` |
195
+ | AI 配置 | `~/.aicmd/ai-config.json` |
196
+ | 对话历史 | `~/.aicmd/ai-history/` |
197
+ | 用户 Skills | `~/.aicmd/skills/*.md` |
198
+ | 回收站 | `~/.aicmd/.trash/` |
199
+
200
+ 可通过 `AICMD_DATA_DIR` 环境变量自定义数据目录。
201
+
202
+ ## 安全机制
203
+
204
+ AI Agent 内置了命令级安全防护,降低误操作风险:
205
+
206
+ ### 删除保护(回收站)
207
+ - 所有 `rm` 命令(Linux/macOS)自动改写为 `mv` 到 `~/.aicmd/.trash/`,而非永久删除
208
+ - Windows 的 `Remove-Item`/`del`/`rd` 同样改写为 `Move-Item` 到 `%USERPROFILE%\.aicmd\.trash\`
209
+ - 回收站文件带时间戳命名(如 `_del_1716000000_filename`),不会冲突
210
+ - 需要恢复时,直接到回收站目录找回即可
211
+
212
+ ### 危险操作阻止
213
+ 以下不可恢复的破坏性操作会被直接阻止执行:
146
214
 
147
- ### 服务端开发
215
+ | 平台 | 被阻止的操作 |
216
+ |------|-------------|
217
+ | Linux/macOS | `rm -rf /`、`mkfs.*` 格式化磁盘、`dd of=/dev/sd*` 覆写磁盘、Fork bomb |
218
+ | Windows | `format C:`、`Clear-Disk`、`Remove-Item C:\`、`rd /s C:\` |
148
219
 
149
- 服务端代码位于 `server/` 目录,使用 TypeScript 编写。开发模式下 Vite 直接引用源码,无需手动编译。
220
+ ### 平台感知
221
+ 安全防护自动检测目标会话的操作系统(通过 systemContext),分别应用 Unix 或 Windows 规则,无需手动配置。
150
222
 
151
- ### 前端开发
223
+ ## 跨平台支持
152
224
 
153
- 前端使用 Vue 3 Composition API + Pinia 进行状态管理,UI 框架为 Bootstrap 5。
225
+ 终端和 AI Agent 支持以下平台:
154
226
 
155
- ### 连接配置
227
+ | 平台 | Shell | AI 脚本 |
228
+ |------|-------|---------|
229
+ | Linux | bash/zsh | Bash + Python + Node.js |
230
+ | macOS | zsh/bash | Bash + Python + Node.js |
231
+ | Windows | PowerShell 7+/5.x | PowerShell + Python + Node.js |
156
232
 
157
- 连接信息持久化存储在服务端本地文件中。
233
+ AI Agent 自动检测目标系统并选择对应命令。
158
234
 
159
235
  ## 许可证
160
236