# linkai-cli **Repository Path**: devai/linkai-cli ## Basic Information - **Project Name**: linkai-cli - **Description**: LinkAI CLI 是 LinkAI 平台的命令行工具,让 Agent 和人类都可以在终端中调用 LinkAI 的全部能力(模型、应用、知识库、数据库、工作流、插件、账号等),为 Agent 提供丰富的基础设施资源,扩展 Agent 的能力边界。 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: https://www.cnblogs.com/zhayujie/p/21524003/cli-for-agents - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-07-17 - **Last Updated**: 2026-07-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
The command-line interface for the LinkAI agent platform.
English · 中文
**LinkAI CLI** brings the full LinkAI platform to the terminal for both agents and people — models, apps, knowledge bases, databases, workflows, plugins, and accounts. It gives AI agents a rich set of platform capabilities as infrastructure, extending what they can do. ## Capabilities The CLI exposes two kinds of capabilities: **platform resources** (manage and use the resources you've configured on LinkAI) and **model capabilities** (call models to generate content). **📦 Platform resources** | Resource | Command | Description | |----------|---------|-------------| | Apps | `app` | List, inspect, create, update, and delete AI apps | | Knowledge | `knowledge` | Vector-search private knowledge bases; import files and manage bases | | Database | `database` | Query databases and schemas, run SQL, create builtin databases and tables | | Workflow | `workflow` | Run workflows orchestrated on LinkAI; create, update, and delete them | | Plugin | `plugin` | List, inspect, and run platform plugins | | Account | `account` | Account profile, credits, and recharge | **🧠 Model capabilities** | Capability | Command | Description | |------------|---------|-------------| | Chat | `chat` | Talk to an AI app or language model, with multi-turn sessions | | Image | `image` | Text-to-image; returns an image URL | | Video | `video` | Text-to-video, with built-in polling until the result is ready | | Speech | `audio` | Text-to-speech (TTS), optionally saved to a file | | Models | `model` | List available models (LLM / IMAGE / VIDEO) | > Run `linkai` | Chat with an app; `--session` for multi-turn |
| `knowledge list` / `files` / `search` / `create` / `import` / `delete` | Query, import, and manage knowledge bases |
| `database list` / `tables` / `describe` / `exec` / `create` / `create-table` | Query, run SQL, and create builtin databases/tables |
| `workflow list` / `run --input ""` / `create` / `update` / `delete` | List, run, and manage workflows |
| `plugin list` / `detail` / `exec ` | List and run plugins |
| `image gen ""` | Text-to-image |
| `video gen ""` | Text-to-video (waits for completion) |
| `audio speech "" [--output a.mp3]` | Text-to-speech, optionally downloaded |
| `model list [--type LLM\|IMAGE\|VIDEO]` | List available models |
| `account info` | Account profile and credit balance |
| `account credits` / `recharge` / `orders` | Credit packages, recharge, and orders |
> See `linkai --help` for each command's full flags.
## Permissions
Permissions are requested at login via `--scope`, in `resource:action` form. Read and content-generation scopes are granted by default; write scopes must be requested explicitly.
| Scope | Description | Default |
|-------|-------------|:---:|
| `app:read` | List and inspect apps | ✅ |
| `app:create` | Create apps | ✅ |
| `user:read` | Read user info | ✅ |
| `chat:send` | Chat with apps | ✅ |
| `knowledge:read` | Query knowledge bases | ✅ |
| `knowledge:create` | Create knowledge bases / add files | ✅ |
| `db:read` | Query databases / run SELECT | ✅ |
| `image:gen` / `video:gen` / `audio:gen` | Generate images / video / speech | ✅ |
| `plugin:read` / `plugin:run` | List / run plugins | ✅ |
| `workflow:read` / `workflow:run` | List / run workflows | ✅ |
| `workflow:create` | Create workflows | ✅ |
| `score:read` / `score:buy` | View / purchase credits | ✅ |
| `app:update` / `app:delete` | Update / delete apps | ❌ |
| `knowledge:update` / `knowledge:delete` | Update / delete knowledge bases | ❌ |
| `workflow:update` / `workflow:delete` | Update / delete workflows | ❌ |
| `db:write` | Database writes (INSERT/UPDATE/DELETE) | ❌ |
Request extra scopes by logging in again, for example:
```bash
linkai auth login --scope "db:read db:write knowledge:update knowledge:delete"
```
## More
Security
- **Tokens:** opaque tokens stored server-side and revocable; `access` lasts 2h, `refresh` lasts 7d, refreshed automatically before expiry; `logout` revokes them server-side.
- **Device binding:** every request carries `X-Device-ID`, and the server binds tokens to the device.
- **Local storage:** tokens go into the macOS Keychain (service `linkai-cli`), with a `0600` file fallback on other platforms; config lives in `~/.linkai/`.
- **Input / output hardening:** dangerous Unicode is rejected, DDL is blocked in the database commands, and ANSI is stripped from table output.
- **Resilience:** 5xx responses are retried with exponential backoff; exit codes are structured (0 ok / 1 general / 2 validation / 3 auth / 4 network).
Shell completion
```bash
source <(linkai completion bash) # Bash
source <(linkai completion zsh) # Zsh
linkai completion fish | source # Fish
```
Development
```bash
make build # build (with version injection)
make test # run tests
make lint # golangci-lint
```
To add a command, follow the pattern in `cmd/database/`, register it in `cmd/root.go`, and declare its scope via `permission.RequiredKey`.
## License
[MIT](./LICENSE)