{"id":50758608,"url":"https://github.com/fefeding/ai-cmd","last_synced_at":"2026-06-11T08:00:30.230Z","repository":{"id":360652685,"uuid":"1250868333","full_name":"fefeding/ai-cmd","owner":"fefeding","description":"AI-powered web SSH terminal with autonomous agent, skills, and file transfer","archived":false,"fork":false,"pushed_at":"2026-06-09T09:46:03.000Z","size":1756,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-09T11:21:46.595Z","etag":null,"topics":["agent","ai","shell"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fefeding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-27T03:24:28.000Z","updated_at":"2026-06-09T09:52:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fefeding/ai-cmd","commit_stats":null,"previous_names":["fefeding/fterm","fefeding/ai-cmd"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fefeding/ai-cmd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fai-cmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fai-cmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fai-cmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fai-cmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fefeding","download_url":"https://codeload.github.com/fefeding/ai-cmd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fefeding%2Fai-cmd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34188272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","shell"],"created_at":"2026-06-11T08:00:23.628Z","updated_at":"2026-06-11T08:00:30.210Z","avatar_url":"https://github.com/fefeding.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AICmd\n\n**[中文文档](./README.zh.md)**\n\nAn 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.\n\n## Features\n\n### AI Agent\n- **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.\n- **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.\n- **Language Adaptation**: AI automatically responds in the same language as the user's message. Falls back to the UI locale when the message language is ambiguous.\n- **Script Generation**: For complex multi-step tasks, the agent generates and executes scripts (Bash/Python/PowerShell) instead of running commands one by one.\n- **Cross-Platform Intelligence**: Adapts commands based on target OS — uses `systemctl` on Linux, `launchctl` on macOS, `Get-Service` on Windows.\n\n### Skills System\n- **Built-in Skills**: Pre-configured operational playbooks for common tasks:\n  - Server Health Check — comprehensive system metrics collection\n  - Log Analysis — error pattern detection with Python/awk scripts\n  - Docker Management — container lifecycle operations\n- **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.\n- **Slash Commands**: Trigger skills with `/skill-name` in the chat input.\n\n### Command Audit \u0026 Replay\n- **Full Audit Trail**: Every command executed by the AI agent is automatically recorded with timestamp, session, command, output, duration, and status (success/error/blocked/rewritten).\n- **Timeline View**: Browse audit logs by date with keyword search and status filtering.\n- **Statistics Dashboard**: Overview of total commands, success/error/blocked counts.\n- **Export**: Export audit logs as JSON or CSV for compliance and incident review.\n- **Real-time Updates**: New audit entries appear instantly in the Audit panel via WebSocket.\n- **Auto Cleanup**: Logs older than 30 days are automatically purged.\n\n### Real-time Log Monitoring + AI Anomaly Detection\n- **One-Click Tail**: Monitor any log file (`tail -f`) on remote SSH servers or local machine.\n- **Pattern Detection**: Automatically detects ERROR, FATAL, CRITICAL, Exception, Traceback, and other anomaly patterns.\n- **Alert System**: Categorized alerts (critical/error/warning) with timestamps and highlighted log lines.\n- **AI Analysis**: Send recent log lines to the AI agent for intelligent anomaly analysis and recommendations.\n- **Color-Coded Output**: Error lines in red, warnings in yellow, debug in dimmed — easy to scan.\n\n### Batch Operations (Multi-Server)\n- **Parallel Execution**: Select multiple active SSH sessions and execute the same command on all of them simultaneously.\n- **Aggregated Results**: View per-server results with success/failure status, output, and execution time.\n- **Server Selector**: Multi-select UI with Select All / Clear options, showing session names and connection types.\n- **Expandable Details**: Click any result to see full command output, with copy-to-clipboard support.\n- **Task History**: Recent batch tasks are stored for review.\n\n### Jump Host \u0026 SSH Agent Forwarding\n- **Startup Script**: Configure a per-connection script that runs automatically after SSH login — ideal for jump host scenarios (e.g., `ssh target-server` to hop to the final destination).\n- **SSH Agent Forwarding**: Forward your local SSH agent to the remote server, enabling key-based authentication for subsequent SSH hops without storing keys on intermediate servers.\n- **Auto-Detection**: Automatically detects the local SSH agent socket (`SSH_AUTH_SOCK` on Linux/macOS, OpenSSH agent pipe on Windows).\n- **Smart System Info**: For jump host sessions, system information is actively collected from the target server (not the jump host) when the AI needs it.\n- See [Jump Host Guide](./docs/jump-host.md) for detailed setup instructions.\n\n### Terminal\n- **SSH Remote Terminal**: Full SSH client based on xterm.js + ssh2 with 256-color support.\n- **Local Shell**: Native local shell via node-pty (Bash/Zsh on macOS/Linux, PowerShell on Windows).\n- **File Transfer**: rz/sz (ZMODEM) file upload and download with automatic binary handling.\n- **Multi-Session**: Tab-based multi-session management with persistent state across restarts.\n- **Auto-Reconnect**: One-click reconnection for dropped SSH sessions.\n- **Session Persistence**: All sessions and chat history are persisted on the server side.\n- **Adaptive Layout**: Terminal automatically resizes when the AI chat panel is toggled, maintaining proper column count.\n\n### General\n- **Connection Management**: Visual SSH connection configuration (CRUD) with key-based, password, and auto auth. Supports startup scripts and agent forwarding for jump host workflows.\n- **i18n**: Chinese / English UI with runtime language switching.\n- **Desktop App**: Cross-platform desktop client via Electron (Windows, macOS, Linux).\n- **Chat History**: Persistent AI conversation history with browsing and restoration across sessions.\n- **CI/CD**: Automated multi-platform builds via GitHub Actions — push a version tag to generate installers for all platforms.\n\n## Screenshot\n\n![AICmd Screenshot](./screenshot.jpeg)\n\n## Tech Stack\n\n| Layer | Technology |\n|-------|-----------|\n| Frontend | Vue 3 + TypeScript + Vite + Bootstrap 5 + xterm.js |\n| Backend | Node.js + Express + WebSocket (ws) |\n| SSH/PTY | ssh2 + node-pty |\n| AI | OpenAI-compatible API (supports any compatible endpoint) |\n| Build | Vite + TypeScript + electron-builder |\n\n## Quick Start\n\n### Install\n\n```bash\nnpm install -g @fefeding/aicmd\n# or\npnpm add -g @fefeding/aicmd\n```\n\n### Requirements\n\n- Node.js \u003e= 18\n\n### Start Server\n\n```bash\n# Start (default port 9802, auto-finds available port)\naicmd start\n\n# Custom port\naicmd start --port 3000\n\n# Stop / Restart\naicmd stop\naicmd restart\n\n# Version\naicmd -v\n```\n\nThen open http://localhost:9802 in your browser.\n\n### Configure AI\n\n1. Click the robot icon (bottom-left sidebar) or the gear icon in the AI chat header.\n2. Enter your API Key and base URL (supports OpenAI, DeepSeek, Qwen, or any compatible API).\n3. Choose a model (default: `gpt-4o-mini`).\n4. Save and start chatting.\n\n### Development\n\n```bash\n# Clone and install\ngit clone \u003crepo-url\u003e\npnpm install\n\n# Dev mode (with hot reload)\npnpm dev\n# Visit http://localhost:9801\n\n# Build\npnpm build          # Frontend + server\npnpm build-server   # Server only\n\n# Start production\nnode server.js --port 3000\n```\n\n### Desktop App (Electron)\n\nPre-built installers are available from [GitHub Releases](https://github.com/fefeding/ai-cmd/releases), or build from source:\n\n```bash\npnpm electron:dev          # Dev mode\npnpm electron:build        # Current platform\npnpm electron:build:win    # Windows (NSIS installer)\npnpm electron:build:mac    # macOS (DMG, x64 + arm64)\npnpm electron:build:linux  # Linux (AppImage)\n```\n\n### Automated Builds (CI/CD)\n\nPush a version tag to trigger multi-platform builds:\n\n```bash\ngit tag v0.1.6\ngit push origin v0.1.6\n# GitHub Actions builds for Windows, macOS, Linux and creates a Release\n```\n\nOr trigger manually from the **Actions** tab with platform selection.\n\n## AI Usage Examples\n\n### Natural Language Operations\n```\nYou: Check if nginx is running and show recent error logs\nAI: [executes systemctl status nginx, then reads error logs, provides analysis]\n\nYou: Find the top 5 processes consuming memory\nAI: [generates and runs a ps/sort script, presents results as a table]\n\nYou: Clean up Docker images older than 7 days\nAI: [runs docker system prune with filters, reports freed space]\n```\n\n### Using Skills\n```\nYou: /server-health-check\nAI: [generates a comprehensive health check script, executes it, analyzes all metrics]\n\nYou: /log-analyze /var/log/nginx/error.log\nAI: [creates a Python analysis script, shows error distribution and patterns]\n```\n\n### AI Analysis\n```\nYou: [Switch to Monitor tab, enter /var/log/nginx/error.log, click Start]\nAI: [Real-time log streaming with anomaly detection]\n    [Alert: CRITICAL - OutOfMemoryError detected at 14:23:05]\n    [Click AI Analyze → AI summarizes error patterns and suggests fixes]\n```\n\n### Batch Operations\n```\n[Click the server rack icon in sidebar → Select 5 servers]\nCommand: systemctl status nginx\n→ All 5 servers respond simultaneously with status output\n→ Failed servers are highlighted in red with error details\n```\n\n### Custom Skills\n\nCreate `~/.aicmd/skills/my-deploy.md`:\n```markdown\n---\nname: Deploy My App\ndescription: Deploy the production application with zero-downtime\ntags: [deploy, ops]\n---\n\nSteps to deploy:\n1. Pull latest code from git\n2. Run database migrations\n3. Build assets\n4. Restart with PM2 (graceful reload)\n...\n```\n\nThen trigger with `/deploy-my-app` in the chat.\n\n## Documentation\n\n- [Architecture Design](./docs/ARCHITECTURE.md) — Core architecture, Agent loop, skills system, MCP integration\n- [Jump Host Guide](./docs/jump-host.md) — SSH jump host and agent forwarding configuration\n- [Deployment Guide](./docs/deployment.md) — Docker, npm, Electron, and CI/CD deployment\n- [Custom Skills Guide](./docs/skills-guide.md) — How to create and author custom AI skills\n\n## Project Structure\n\n```\n.\n├── .github/workflows/ # GitHub Actions CI/CD\n├── bin/              # CLI entry (aicmd command)\n├── data/skills/      # Built-in AI skills\n├── dist/             # Build output\n├── docs/             # Documentation\n├── electron/         # Electron main process \u0026 preload\n├── public/           # Static assets\n├── scripts/          # Build scripts (Electron)\n├── server/           # Server source (TypeScript)\n│   ├── model/        # Entity definitions\n│   ├── service/      # Business logic (AI, SSH, Skills, Audit, Monitor, Batch)\n│   └── index.ts      # Server entry\n├── src/              # Frontend source (Vue 3)\n│   ├── components/   # Vue components\n│   │   ├── ai-chat/  # AI chat panel (Chat / Audit tabs)\n│   │   ├── ai-settings/ # AI config modal\n│   │   ├── audit-panel/ # Command audit timeline\n│   │   ├── batch-panel/ # Multi-server batch operations\n│   │   ├── connection-editor/ # Connection config (jump host, agent forwarding)\n│   │   └── ...       # Terminal, sidebar, etc.\n│   ├── locales/      # i18n translations\n│   ├── service/      # Frontend API services\n│   ├── stores/       # Pinia state management\n│   └── views/        # Page views\n├── view/             # HTML templates\n└── server.js         # Production startup\n```\n\n## Data Storage\n\nAll data is stored locally on the server:\n\n| Data | Path |\n|------|------|\n| Connections | `~/.aicmd/connections.json` |\n| Sessions | `~/.aicmd/sessions.json` |\n| AI Config | `~/.aicmd/ai-config.json` |\n| Chat History | `~/.aicmd/ai-history/` |\n| Audit Logs | `~/.aicmd/audit/YYYY-MM-DD.jsonl` |\n| User Skills | `~/.aicmd/skills/*.md` |\n| Trash Bin | `~/.aicmd/.trash/` |\n\nUse `AICMD_DATA_DIR` environment variable to override the data directory.\n\n## Safety Mechanisms\n\nThe AI agent includes built-in command-level safety protections to reduce the risk of destructive operations:\n\n### Delete Protection (Trash Bin)\n- All `rm` commands (Linux/macOS) are automatically rewritten to `mv` into `~/.aicmd/.trash/` instead of permanent deletion.\n- Windows `Remove-Item`/`del`/`rd` commands are similarly rewritten to `Move-Item` into `%USERPROFILE%\\.aicmd\\.trash\\`.\n- Trashed files are timestamped (e.g. `_del_1716000000_filename`) to avoid naming conflicts.\n- To recover a file, simply browse the trash directory and move it back.\n\n### Dangerous Operation Blocking\nThe following irreversible, destructive operations are blocked entirely:\n\n| Platform | Blocked Operations |\n|----------|-------------------|\n| Linux/macOS | `rm -rf /`, `mkfs.*` (disk formatting), `dd of=/dev/sd*` (disk overwrite), fork bombs |\n| Windows | `format C:`, `Clear-Disk`, `Remove-Item C:\\`, `rd /s C:\\` |\n\n### Platform Awareness\nThe safety layer automatically detects the target session's OS (via systemContext) and applies the appropriate Unix or Windows rules — no manual configuration required.\n\n## Cross-Platform Support\n\nThe terminal and AI agent work on:\n\n| Platform | Shell | AI Scripting |\n|----------|-------|-------------|\n| Linux | bash/zsh | Bash + Python + Node.js |\n| macOS | zsh/bash | Bash + Python + Node.js |\n| Windows | PowerShell 7+/5.x | PowerShell + Python + Node.js |\n\nThe AI agent automatically detects the target OS and selects appropriate commands.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffefeding%2Fai-cmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffefeding%2Fai-cmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffefeding%2Fai-cmd/lists"}