@fefeding/aicmd 0.1.1 → 0.1.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 +139 -85
- package/README.zh.md +141 -87
- package/bin/{fterm.js → aicmd.js} +11 -11
- package/dist/public/index.js +7 -7
- package/dist/public/views.css +32 -32
- package/dist/public/views.js +130 -173
- package/dist/public/vue.js +1 -1
- package/dist/server/model/connection.entity.d.ts +1 -1
- package/dist/server/model/connection.entity.js +1 -1
- package/dist/server/model/connection.entity.ts +1 -1
- package/dist/server/service/ai.service.d.ts +16 -0
- package/dist/server/service/ai.service.d.ts.map +1 -1
- package/dist/server/service/ai.service.js +122 -14
- package/dist/server/service/ai.service.js.map +1 -1
- package/dist/server/service/ai.service.ts +131 -14
- package/dist/server/service/connection.service.d.ts +1 -1
- package/dist/server/service/connection.service.js +2 -2
- package/dist/server/service/connection.service.ts +2 -2
- package/dist/server/service/skill.service.d.ts +1 -1
- package/dist/server/service/skill.service.js +3 -3
- package/dist/server/service/skill.service.ts +3 -3
- package/dist/server/service/ssh.service.js +1 -1
- package/dist/server/service/ssh.service.ts +1 -1
- package/dist/view/index.html +1 -1
- package/package.json +8 -8
- package/server.js +2 -2
package/README.md
CHANGED
|
@@ -1,160 +1,214 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AICmd
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
|
|
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
|
-

|
|
17
38
|
|
|
18
39
|
## Tech Stack
|
|
19
40
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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/
|
|
54
|
+
npm install -g @fefeding/aicmd
|
|
31
55
|
# or
|
|
32
|
-
pnpm add -g @fefeding/
|
|
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
|
-
###
|
|
63
|
+
### Start Server
|
|
41
64
|
|
|
42
65
|
```bash
|
|
43
|
-
|
|
44
|
-
|
|
66
|
+
# Start (default port 9802, auto-finds available port)
|
|
67
|
+
aicmd start
|
|
45
68
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
pnpm dev
|
|
50
|
-
```
|
|
69
|
+
# Custom port
|
|
70
|
+
aicmd start --port 3000
|
|
51
71
|
|
|
52
|
-
|
|
72
|
+
# Stop / Restart
|
|
73
|
+
aicmd stop
|
|
74
|
+
aicmd restart
|
|
53
75
|
|
|
54
|
-
|
|
76
|
+
# Version
|
|
77
|
+
aicmd -v
|
|
78
|
+
```
|
|
55
79
|
|
|
56
|
-
|
|
57
|
-
# Build frontend + backend
|
|
58
|
-
pnpm build
|
|
80
|
+
Then open http://localhost:9802 in your browser.
|
|
59
81
|
|
|
60
|
-
|
|
61
|
-
pnpm run build-only
|
|
62
|
-
```
|
|
82
|
+
### Configure AI
|
|
63
83
|
|
|
64
|
-
|
|
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
|
-
|
|
89
|
+
### Development
|
|
67
90
|
|
|
68
91
|
```bash
|
|
69
|
-
#
|
|
70
|
-
|
|
92
|
+
# Clone and install
|
|
93
|
+
git clone <repo-url>
|
|
94
|
+
pnpm install
|
|
71
95
|
|
|
72
|
-
#
|
|
73
|
-
|
|
96
|
+
# Dev mode (with hot reload)
|
|
97
|
+
pnpm dev
|
|
98
|
+
# Visit http://localhost:9801
|
|
74
99
|
|
|
75
|
-
#
|
|
76
|
-
|
|
100
|
+
# Build
|
|
101
|
+
pnpm build # Frontend + server
|
|
102
|
+
pnpm build-server # Server only
|
|
77
103
|
|
|
78
|
-
#
|
|
79
|
-
|
|
104
|
+
# Start production
|
|
105
|
+
node server.js --port 3000
|
|
80
106
|
```
|
|
81
107
|
|
|
82
|
-
|
|
108
|
+
### Desktop App (NW.js)
|
|
83
109
|
|
|
84
110
|
```bash
|
|
85
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
104
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
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
|
|
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
|
-
│ ├──
|
|
137
|
-
│ ├──
|
|
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
|
|
184
|
+
└── server.js # Production startup
|
|
143
185
|
```
|
|
144
186
|
|
|
145
|
-
##
|
|
187
|
+
## Data Storage
|
|
188
|
+
|
|
189
|
+
All data is stored locally on the server:
|
|
146
190
|
|
|
147
|
-
|
|
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` |
|
|
148
198
|
|
|
149
|
-
|
|
199
|
+
Use `AICMD_DATA_DIR` environment variable to override the data directory.
|
|
150
200
|
|
|
151
|
-
|
|
201
|
+
## Cross-Platform Support
|
|
152
202
|
|
|
153
|
-
The
|
|
203
|
+
The terminal and AI agent work on:
|
|
154
204
|
|
|
155
|
-
|
|
205
|
+
| Platform | Shell | AI Scripting |
|
|
206
|
+
|----------|-------|-------------|
|
|
207
|
+
| Linux | bash/zsh | Bash + Python + Node.js |
|
|
208
|
+
| macOS | zsh/bash | Bash + Python + Node.js |
|
|
209
|
+
| Windows | PowerShell 7+/5.x | PowerShell + Python + Node.js |
|
|
156
210
|
|
|
157
|
-
|
|
211
|
+
The AI agent automatically detects the target OS and selects appropriate commands.
|
|
158
212
|
|
|
159
213
|
## License
|
|
160
214
|
|
package/README.zh.md
CHANGED
|
@@ -1,160 +1,214 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
Web SSH
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
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
|
-

|
|
17
38
|
|
|
18
39
|
## 技术栈
|
|
19
40
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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/
|
|
54
|
+
npm install -g @fefeding/aicmd
|
|
31
55
|
# 或
|
|
32
|
-
pnpm add -g @fefeding/
|
|
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
|
-
|
|
44
|
-
|
|
66
|
+
# 启动(默认端口 9802,自动寻找可用端口)
|
|
67
|
+
aicmd start
|
|
45
68
|
|
|
46
|
-
|
|
69
|
+
# 自定义端口
|
|
70
|
+
aicmd start --port 3000
|
|
47
71
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
72
|
+
# 停止 / 重启
|
|
73
|
+
aicmd stop
|
|
74
|
+
aicmd restart
|
|
51
75
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
76
|
+
# 查看版本
|
|
77
|
+
aicmd -v
|
|
78
|
+
```
|
|
55
79
|
|
|
56
|
-
|
|
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
|
-
|
|
89
|
+
### 开发
|
|
67
90
|
|
|
68
91
|
```bash
|
|
69
|
-
#
|
|
70
|
-
|
|
92
|
+
# 克隆并安装
|
|
93
|
+
git clone <repo-url>
|
|
94
|
+
pnpm install
|
|
71
95
|
|
|
72
|
-
#
|
|
73
|
-
|
|
96
|
+
# 开发模式(热更新)
|
|
97
|
+
pnpm dev
|
|
98
|
+
# 访问 http://localhost:9801
|
|
74
99
|
|
|
75
|
-
#
|
|
76
|
-
|
|
100
|
+
# 构建
|
|
101
|
+
pnpm build # 前端 + 服务端
|
|
102
|
+
pnpm build-server # 仅服务端
|
|
77
103
|
|
|
78
|
-
#
|
|
79
|
-
|
|
104
|
+
# 生产启动
|
|
105
|
+
node server.js --port 3000
|
|
80
106
|
```
|
|
81
107
|
|
|
82
|
-
|
|
108
|
+
### 桌面应用(NW.js)
|
|
83
109
|
|
|
84
110
|
```bash
|
|
85
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# 启动服务
|
|
92
|
-
npm start
|
|
118
|
+
## AI 使用示例
|
|
93
119
|
|
|
94
|
-
|
|
95
|
-
npm stop
|
|
96
|
-
|
|
97
|
-
# 重启服务
|
|
98
|
-
npm restart
|
|
120
|
+
### 自然语言操作
|
|
99
121
|
```
|
|
122
|
+
你: 检查 nginx 是否在运行,并显示最近的错误日志
|
|
123
|
+
AI: [执行 systemctl status nginx,读取错误日志,提供分析]
|
|
100
124
|
|
|
101
|
-
|
|
125
|
+
你: 找出内存占用最高的 5 个进程
|
|
126
|
+
AI: [生成并运行 ps/sort 脚本,以表格展示结果]
|
|
102
127
|
|
|
103
|
-
|
|
104
|
-
|
|
128
|
+
你: 清理 7 天前的 Docker 镜像
|
|
129
|
+
AI: [运行 docker system prune 并过滤,报告释放的空间]
|
|
105
130
|
```
|
|
106
131
|
|
|
107
|
-
###
|
|
132
|
+
### 使用 Skills
|
|
133
|
+
```
|
|
134
|
+
你: /server-health-check
|
|
135
|
+
AI: [生成全面健康检查脚本,执行后分析所有指标]
|
|
108
136
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
137
|
+
你: /log-analyze /var/log/nginx/error.log
|
|
138
|
+
AI: [创建 Python 分析脚本,展示错误分布和模式]
|
|
139
|
+
```
|
|
112
140
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
│ ├──
|
|
137
|
-
│ ├──
|
|
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
|
+
所有数据本地存储在服务端:
|
|
146
190
|
|
|
147
|
-
|
|
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` |
|
|
148
198
|
|
|
149
|
-
|
|
199
|
+
可通过 `AICMD_DATA_DIR` 环境变量自定义数据目录。
|
|
150
200
|
|
|
151
|
-
|
|
201
|
+
## 跨平台支持
|
|
152
202
|
|
|
153
|
-
|
|
203
|
+
终端和 AI Agent 支持以下平台:
|
|
154
204
|
|
|
155
|
-
|
|
205
|
+
| 平台 | Shell | AI 脚本 |
|
|
206
|
+
|------|-------|---------|
|
|
207
|
+
| Linux | bash/zsh | Bash + Python + Node.js |
|
|
208
|
+
| macOS | zsh/bash | Bash + Python + Node.js |
|
|
209
|
+
| Windows | PowerShell 7+/5.x | PowerShell + Python + Node.js |
|
|
156
210
|
|
|
157
|
-
|
|
211
|
+
AI Agent 自动检测目标系统并选择对应命令。
|
|
158
212
|
|
|
159
213
|
## 许可证
|
|
160
214
|
|
|
@@ -9,11 +9,11 @@ const os = require('os');
|
|
|
9
9
|
const projectRoot = path.resolve(__dirname, '..');
|
|
10
10
|
|
|
11
11
|
function getPidFilePath() {
|
|
12
|
-
const dataDir = process.env.
|
|
12
|
+
const dataDir = process.env.AICMD_DATA_DIR || path.join(os.homedir(), '.aicmd');
|
|
13
13
|
if (!fs.existsSync(dataDir)) {
|
|
14
14
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
15
15
|
}
|
|
16
|
-
return path.join(dataDir, '
|
|
16
|
+
return path.join(dataDir, 'aicmd.server.pid');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function readPid() {
|
|
@@ -64,11 +64,11 @@ async function findAvailablePort(startPort) {
|
|
|
64
64
|
if (await isPortAvailable(port)) return port;
|
|
65
65
|
port++;
|
|
66
66
|
}
|
|
67
|
-
throw new Error(
|
|
67
|
+
throw new Error(`Cannot find available port, tried 100 times`);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
async function startProject() {
|
|
71
|
-
console.log('Starting
|
|
71
|
+
console.log('Starting aicmd...');
|
|
72
72
|
|
|
73
73
|
const pid = readPid();
|
|
74
74
|
if (pid) {
|
|
@@ -113,11 +113,11 @@ async function startProject() {
|
|
|
113
113
|
writePid(child.pid);
|
|
114
114
|
|
|
115
115
|
console.log('Server started with PID:', child.pid);
|
|
116
|
-
console.log(`
|
|
116
|
+
console.log(`aicmd is running at http://localhost:${port}`);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
function stopProject() {
|
|
120
|
-
console.log('Stopping
|
|
120
|
+
console.log('Stopping aicmd...');
|
|
121
121
|
const pid = readPid();
|
|
122
122
|
if (!pid) {
|
|
123
123
|
console.log('No server process found');
|
|
@@ -151,12 +151,12 @@ function showVersion() {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
function showHelp() {
|
|
154
|
-
console.log('
|
|
154
|
+
console.log('aicmd - AI-powered SSH Terminal');
|
|
155
155
|
console.log('');
|
|
156
156
|
console.log('Usage:');
|
|
157
|
-
console.log('
|
|
158
|
-
console.log('
|
|
159
|
-
console.log('
|
|
160
|
-
console.log('
|
|
157
|
+
console.log(' aicmd start Start the server');
|
|
158
|
+
console.log(' aicmd stop Stop the server');
|
|
159
|
+
console.log(' aicmd restart Restart the server');
|
|
160
|
+
console.log(' aicmd -v Show version');
|
|
161
161
|
console.log('');
|
|
162
162
|
}
|