@kkmila/cpc 1.0.0
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 +108 -0
- package/bin/cpc.mjs +16 -0
- package/package.json +51 -0
- package/registry.yaml +43 -0
- package/src/commands/provider.mjs +1576 -0
- package/src/lib/agents.mjs +36 -0
- package/src/lib/fs.mjs +75 -0
- package/src/lib/repo.mjs +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# cpc
|
|
2
|
+
|
|
3
|
+
Custom Provider CLI - 管理自定义 AI 模型提供商的命令行工具。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @custom-provider/cpc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 快速开始
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# 添加提供商
|
|
15
|
+
cpc add
|
|
16
|
+
|
|
17
|
+
# 列出提供商
|
|
18
|
+
cpc list
|
|
19
|
+
|
|
20
|
+
# 安装提供商到 Agent
|
|
21
|
+
cpc install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 命令
|
|
25
|
+
|
|
26
|
+
| 命令 | 说明 |
|
|
27
|
+
|------|------|
|
|
28
|
+
| `cpc add` | 添加新的模型提供商 |
|
|
29
|
+
| `cpc list` | 列出所有提供商 |
|
|
30
|
+
| `cpc models [name]` | 查看提供商的模型 |
|
|
31
|
+
| `cpc edit-model [name]` | 编辑模型配置 |
|
|
32
|
+
| `cpc fetch-models [name]` | 从 API 获取模型列表 |
|
|
33
|
+
| `cpc remove [name]` | 删除提供商 |
|
|
34
|
+
| `cpc install [name]` | 安装提供商到 Agent |
|
|
35
|
+
| `cpc test [name]` | 测试提供商连接 |
|
|
36
|
+
| `cpc export [name]` | 导出提供商配置 |
|
|
37
|
+
| `cpc import <file>` | 导入提供商配置 |
|
|
38
|
+
| `cpc list-installed` | 列出已安装的提供商 |
|
|
39
|
+
|
|
40
|
+
## 使用示例
|
|
41
|
+
|
|
42
|
+
### 添加 OpenAI 提供商
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cpc add --name openai --url https://api.openai.com/v1 --key sk-xxx --api openai-completions --fetch --all
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 交互式添加
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cpc add
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 安装到 Pi Agent
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cpc install openai --agent pi
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 测试连接
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cpc test openai
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 支持的 Agent
|
|
67
|
+
|
|
68
|
+
- claude-code
|
|
69
|
+
- pi
|
|
70
|
+
- hermes
|
|
71
|
+
- codex
|
|
72
|
+
- openclaw
|
|
73
|
+
- omp
|
|
74
|
+
- mimo-code
|
|
75
|
+
- cursor
|
|
76
|
+
|
|
77
|
+
## 配置文件
|
|
78
|
+
|
|
79
|
+
- `~/.config/cpc/providers.json` - 提供商配置
|
|
80
|
+
|
|
81
|
+
## API 类型
|
|
82
|
+
|
|
83
|
+
| 类型 | 说明 |
|
|
84
|
+
|------|------|
|
|
85
|
+
| `openai-completions` | OpenAI 兼容 API(默认) |
|
|
86
|
+
| `anthropic-messages` | Anthropic Messages API |
|
|
87
|
+
| `responses` | OpenAI Responses API |
|
|
88
|
+
|
|
89
|
+
## 开发
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# 克隆项目
|
|
93
|
+
git clone https://github.com/yourusername/custom-provider-cli.git
|
|
94
|
+
cd custom-provider-cli
|
|
95
|
+
|
|
96
|
+
# 安装依赖
|
|
97
|
+
npm install
|
|
98
|
+
|
|
99
|
+
# 本地开发
|
|
100
|
+
npm run dev
|
|
101
|
+
|
|
102
|
+
# 链接到全局
|
|
103
|
+
npm link
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 许可证
|
|
107
|
+
|
|
108
|
+
MIT
|
package/bin/cpc.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from "commander";
|
|
4
|
+
import { resolveRepoRoot } from "../src/lib/repo.mjs";
|
|
5
|
+
import { registerProvider } from "../src/commands/provider.mjs";
|
|
6
|
+
|
|
7
|
+
const repoRoot = resolveRepoRoot();
|
|
8
|
+
|
|
9
|
+
program
|
|
10
|
+
.name("cpc")
|
|
11
|
+
.description("Custom Provider CLI for managing model providers")
|
|
12
|
+
.version("1.0.0");
|
|
13
|
+
|
|
14
|
+
registerProvider(program, repoRoot);
|
|
15
|
+
|
|
16
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kkmila/cpc",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Custom Provider CLI for managing model providers",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"cpc": "./bin/cpc.mjs"
|
|
8
|
+
},
|
|
9
|
+
"main": "./src/commands/provider.mjs",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./src/commands/provider.mjs"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin",
|
|
15
|
+
"src",
|
|
16
|
+
"registry.yaml",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "node bin/cpc.mjs",
|
|
21
|
+
"test": "node --test src/**/*.test.mjs"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"cli",
|
|
25
|
+
"provider",
|
|
26
|
+
"ai",
|
|
27
|
+
"llm",
|
|
28
|
+
"openai",
|
|
29
|
+
"anthropic",
|
|
30
|
+
"model"
|
|
31
|
+
],
|
|
32
|
+
"author": "machuqiji",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/machuqiji/custom-provider-cli.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/machuqiji/custom-provider-cli/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/machuqiji/custom-provider-cli#readme",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"commander": "^12.0.0",
|
|
44
|
+
"@inquirer/prompts": "^7.0.0",
|
|
45
|
+
"js-yaml": "^4.1.0",
|
|
46
|
+
"chalk": "^5.3.0"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/registry.yaml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
|
|
3
|
+
# ── Agent Definitions ───────────────────────────────────────────────────
|
|
4
|
+
agents:
|
|
5
|
+
claude-code:
|
|
6
|
+
name: Claude Code
|
|
7
|
+
home: ~/.claude
|
|
8
|
+
description: "Anthropic Claude Code CLI"
|
|
9
|
+
|
|
10
|
+
pi:
|
|
11
|
+
name: Pi
|
|
12
|
+
home: ~/.pi/agent
|
|
13
|
+
description: "Pi coding agent"
|
|
14
|
+
|
|
15
|
+
hermes:
|
|
16
|
+
name: Hermes
|
|
17
|
+
home: ~/.hermes
|
|
18
|
+
description: "Hermes agent"
|
|
19
|
+
|
|
20
|
+
codex:
|
|
21
|
+
name: Codex
|
|
22
|
+
home: ~/.codex
|
|
23
|
+
description: "OpenAI Codex agent"
|
|
24
|
+
|
|
25
|
+
openclaw:
|
|
26
|
+
name: OpenClaw
|
|
27
|
+
home: ~/.openclaw
|
|
28
|
+
description: "OpenClaw agent"
|
|
29
|
+
|
|
30
|
+
omp:
|
|
31
|
+
name: OMP
|
|
32
|
+
home: ~/.omp/agent
|
|
33
|
+
description: "OMP agent"
|
|
34
|
+
|
|
35
|
+
mimo-code:
|
|
36
|
+
name: MimoCode
|
|
37
|
+
home: ~/.config/mimocode
|
|
38
|
+
description: "MimoCode agent"
|
|
39
|
+
|
|
40
|
+
cursor:
|
|
41
|
+
name: Cursor
|
|
42
|
+
home: .
|
|
43
|
+
description: "Cursor editor (project-level config)"
|