focalapi-cli 0.1.1 → 0.2.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/CHANGELOG.md +10 -0
- package/LICENSE +202 -202
- package/README.md +155 -209
- package/dist/cli.js +795 -217
- package/package.json +53 -50
- package/scripts/postinstall.cjs +41 -0
- package/skills/focalapi/SKILL.md +54 -43
- package/skills/focalapi-auth/SKILL.md +30 -50
- package/skills/focalapi-chat/SKILL.md +32 -29
- package/skills/focalapi-gen/SKILL.md +53 -79
- package/skills/focalapi-models/SKILL.md +49 -0
- package/skills/focalapi-task/SKILL.md +25 -0
- package/skills/focalapi-usage/SKILL.md +27 -36
package/README.md
CHANGED
|
@@ -1,209 +1,155 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# focalapi-cli
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/focalapi-cli)
|
|
8
|
-
[](./LICENSE)
|
|
9
|
-
[](https://nodejs.org)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
focalapi
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
focalapi --
|
|
52
|
-
|
|
53
|
-
#
|
|
54
|
-
focalapi
|
|
55
|
-
|
|
56
|
-
#
|
|
57
|
-
focalapi
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#
|
|
86
|
-
focalapi
|
|
87
|
-
focalapi
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
focalapi
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
focalapi
|
|
131
|
-
focalapi
|
|
132
|
-
focalapi
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
##
|
|
147
|
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
|
|
153
|
-
##
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|---|---|
|
|
157
|
-
| 登录 / 状态 / 登出 | `focalapi auth login / status / logout` |
|
|
158
|
-
| DeepSeek 文本辅助 | `focalapi chat` |
|
|
159
|
-
| 图片 / 视频生成 | `focalapi gen image / gen video` |
|
|
160
|
-
| 任务查询与产物下载 | `focalapi task status / download`(图像任务使用 status 读取 `data[].url`) |
|
|
161
|
-
| 语音转写 / 合成 | `focalapi audio transcribe / speech` |
|
|
162
|
-
| 模型查询 | `focalapi models list / get` |
|
|
163
|
-
| 额度用量 | `focalapi usage` |
|
|
164
|
-
| 诊断排障 | `focalapi doctor` |
|
|
165
|
-
| Agent 接入 | `focalapi connect list / install / uninstall` |
|
|
166
|
-
| 版本与更新检查 | `focalapi version / update` |
|
|
167
|
-
| 原始只读 API 请求 | `focalapi request get /v1/models` |
|
|
168
|
-
|
|
169
|
-
每个命令都自带帮助:`focalapi <command> --help`。
|
|
170
|
-
|
|
171
|
-
### 原始只读请求
|
|
172
|
-
|
|
173
|
-
优先使用语义化命令(如 `models`、`chat`、`gen`)。当服务新增尚未封装的读取端点时,可使用:
|
|
174
|
-
|
|
175
|
-
```shell
|
|
176
|
-
focalapi request get /v1/models --json
|
|
177
|
-
focalapi request head /v1/models --json
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
该入口只接受站内路径与 `GET` / `HEAD`,不会隐藏任何写入操作。`--json` 时高阶命令通常直通上游响应;`request` 固定返回 `{ method, path, status, content_type, data }` 信封,错误仍为 `{ error: { code, message, hint? } }`,且不会输出完整 API Key。
|
|
181
|
-
|
|
182
|
-
## 配置
|
|
183
|
-
|
|
184
|
-
- 配置文件:`~/.focalapi/config.json`(权限 600),支持多 profile(`--profile`)
|
|
185
|
-
- 环境变量:`FOCALAPI_API_KEY`、`FOCALAPI_BASE_URL`、`FOCALAPI_MODEL`、`FOCALAPI_CONFIG_DIR`
|
|
186
|
-
- 优先级:命令行 flag > 环境变量 > 配置文件
|
|
187
|
-
|
|
188
|
-
## 本地 e2e 验证清单(需要真实 Key)
|
|
189
|
-
|
|
190
|
-
```shell
|
|
191
|
-
focalapi auth login --key sk-xxxx
|
|
192
|
-
focalapi doctor # 全 ✓
|
|
193
|
-
focalapi chat "你好" -m focal-rehearsal-chat # 免费演练模型
|
|
194
|
-
focalapi gen image "测试图" -m <图像模型> -o ./out
|
|
195
|
-
focalapi gen video "测试视频" -m <视频模型> --no-wait --json
|
|
196
|
-
focalapi task download <task_id>
|
|
197
|
-
focalapi connect install && focalapi connect uninstall # 幂等且清理干净
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## 链接
|
|
201
|
-
|
|
202
|
-
- focalapi:<https://focalapi.com>
|
|
203
|
-
- Gitee:<https://gitee.com/xnn-ai/focalapi-cli>
|
|
204
|
-
- npm:<https://www.npmjs.com/package/focalapi-cli>
|
|
205
|
-
- 内置 Skills:[`./skills`](./skills)
|
|
206
|
-
|
|
207
|
-
## License
|
|
208
|
-
|
|
209
|
-
[Apache-2.0](./LICENSE)
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# focalapi-cli
|
|
4
|
+
|
|
5
|
+
**让任意 AI Agent 直接调用 focalapi 创作模型**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/focalapi-cli)
|
|
8
|
+
[](./LICENSE)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
npm i -g focalapi-cli
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
focalapi-cli 把 focalapi 的创作模型中转能力变成 Agent 可直接执行的命令和
|
|
18
|
+
Skills。用户只需描述目标;Agent 不需要先试模型、猜参数、手写请求或切换平台。
|
|
19
|
+
|
|
20
|
+
它不会把 focalapi 配成 Agent 自身的主模型/provider。Codex、Claude Code、
|
|
21
|
+
Cursor 等 Agent 保持原来的推理模型,只在图片、视频等创作任务中调用 focalapi。
|
|
22
|
+
|
|
23
|
+
## 三步接入
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
# 1. 安装;安装器允许 lifecycle script 时会自动同步 Skills
|
|
27
|
+
npm i -g focalapi-cli
|
|
28
|
+
|
|
29
|
+
# 2. 配置 focalapi Key
|
|
30
|
+
focalapi auth login --key sk-xxxx
|
|
31
|
+
|
|
32
|
+
# 3. 接入全部已检测 Agent(幂等,自动安装过也可重复执行)并验证
|
|
33
|
+
focalapi connect
|
|
34
|
+
focalapi connect verify --json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Key 在 <https://focalapi.com/console/token> 创建。CI/沙箱可使用
|
|
38
|
+
`FOCALAPI_API_KEY`,私有化部署可设置 `FOCALAPI_BASE_URL`。
|
|
39
|
+
|
|
40
|
+
如 npm 的安全策略阻止 lifecycle script,显式执行上面的 `focalapi connect` 即可;
|
|
41
|
+
这也是稳定的接入入口。如需主动跳过安装后的自动接入,设置
|
|
42
|
+
`FOCALAPI_SKIP_POSTINSTALL=1`。
|
|
43
|
+
|
|
44
|
+
## Agent 零试错调用
|
|
45
|
+
|
|
46
|
+
不指定模型时,CLI 会读取当前 Key 的实时模型池与单模型详情契约,选择
|
|
47
|
+
focalapi 维护的默认模型;只产生一次真实生成请求。
|
|
48
|
+
|
|
49
|
+
```shell
|
|
50
|
+
# 自动选择当前可用的默认图像模型
|
|
51
|
+
focalapi gen image "产品主视觉,工作室柔光" -o ./out --json
|
|
52
|
+
|
|
53
|
+
# 自动选择当前可用的默认视频模型,立即返回任务 ID
|
|
54
|
+
focalapi gen video "海浪拍打礁石,电影感" --no-wait -o ./out --json
|
|
55
|
+
|
|
56
|
+
# 沿生成结果里的 next_command 续取,不重复提交
|
|
57
|
+
focalapi task status <task-id> --json
|
|
58
|
+
focalapi task download <task-id> -o ./out --json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
用户明确指定模型时,先读取权威契约:
|
|
62
|
+
|
|
63
|
+
```shell
|
|
64
|
+
focalapi models get <model-id> --json
|
|
65
|
+
focalapi gen image "<prompt>" -m <model-id> [契约允许的参数] -o ./out --json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
也可以只让 CLI 选模、暂不生成:
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
focalapi models resolve image --json
|
|
72
|
+
focalapi models resolve video --json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`resolve` 返回精确 `model.id`、已确认的 `endpoint_type`、完整
|
|
76
|
+
`supported_params`、候选模型与 `next_command`。模型列表摘要和详情不一致时,
|
|
77
|
+
详情契约始终是权威。
|
|
78
|
+
|
|
79
|
+
## Agent 接入
|
|
80
|
+
|
|
81
|
+
```shell
|
|
82
|
+
focalapi connect # 安装/修复全部已检测 Agent
|
|
83
|
+
focalapi connect list # 只读查看支持、检测与安装状态
|
|
84
|
+
focalapi connect install codex cursor # 指定 Agent
|
|
85
|
+
focalapi connect install --path <dir> # 未收录 Agent / 项目级 Skills 目录
|
|
86
|
+
focalapi connect verify --json # Skills 完整性 + 认证就绪状态
|
|
87
|
+
focalapi connect uninstall # 只移除未被用户修改的托管 Skills
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
当前内置 44 个 Agent 目标,覆盖 Claude Code、Codex、Cursor、Gemini CLI、
|
|
91
|
+
GitHub Copilot、OpenCode、OpenClaw、Cline、Windsurf、Warp、Trae、Qwen Code、
|
|
92
|
+
Kimi CLI、Hermes 等。Codex、Cline、Pi、Warp 等共享 `~/.agents/skills` 的目标
|
|
93
|
+
会按路径自动去重,只安装一份。
|
|
94
|
+
|
|
95
|
+
安装采用事务式更新:当前 `focalapi-*` catalog 整体写入,任一步失败会回滚;
|
|
96
|
+
manifest 记录每个 Skill 的 SHA-256 目录摘要。默认卸载仅删除摘要未变化的托管
|
|
97
|
+
Skills,用户修改过的内容保留。
|
|
98
|
+
|
|
99
|
+
Skills 的路由契约明确要求:
|
|
100
|
+
|
|
101
|
+
- 用户没点名 focalapi 也会在创作任务中自动触发;
|
|
102
|
+
- 未指定模型时省略 `--model`,由 CLI 自动选择,不先生成测试样例;
|
|
103
|
+
- 指定模型时只按 `models get` 的实时参数契约调用;
|
|
104
|
+
- 异步任务复用原 `task_id`,不因 `pending` 重复扣费;
|
|
105
|
+
- 业务命令报鉴权错误时完成登录后回到原任务,不停在排障步骤。
|
|
106
|
+
|
|
107
|
+
## 当前能力边界
|
|
108
|
+
|
|
109
|
+
当前已闭环验证的自动生成入口是图片和视频,包括图片编辑、参考图创作、文生
|
|
110
|
+
视频和图生视频。CLI 仍保留文本、音频等命令,但只有实时模型详情与 CLI 帮助
|
|
111
|
+
共同给出可执行契约时 Agent 才会调用;不会根据模型名字猜测未来的音频、3D 或
|
|
112
|
+
其他模态能力。
|
|
113
|
+
|
|
114
|
+
## 面向 Agent 的稳定输出
|
|
115
|
+
|
|
116
|
+
- 所有自动化命令支持 `--json`,stdout 只输出 JSON,进度与诊断走 stderr;
|
|
117
|
+
- 错误统一为 `{ error: { code, message, hint, request_id? } }`;
|
|
118
|
+
- API Key 始终脱敏;
|
|
119
|
+
- 图片结果返回本地 `files`,视频异步结果返回 `task_id` 与 `next_command`;
|
|
120
|
+
- 本地校验会在发请求前拒绝已知的非法计费乘数和模型参数。
|
|
121
|
+
|
|
122
|
+
## 命令入口
|
|
123
|
+
|
|
124
|
+
| 任务 | 命令 |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| 自动/指定模型生成图片 | `focalapi gen image` |
|
|
127
|
+
| 自动/指定模型生成视频 | `focalapi gen video` |
|
|
128
|
+
| 自动选模与实时契约 | `focalapi models resolve/get/search/list` |
|
|
129
|
+
| 异步任务查询与下载 | `focalapi task status/download` |
|
|
130
|
+
| 登录与 Key 状态 | `focalapi auth login/status/logout` |
|
|
131
|
+
| 额度、用量与诊断 | `focalapi usage`, `focalapi doctor` |
|
|
132
|
+
| Agent Skills 接入 | `focalapi connect` |
|
|
133
|
+
| 只读原始 API | `focalapi request get/head` |
|
|
134
|
+
|
|
135
|
+
每个命令都有内置帮助:`focalapi <command> --help`。
|
|
136
|
+
|
|
137
|
+
## 开发验证
|
|
138
|
+
|
|
139
|
+
```shell
|
|
140
|
+
npm install
|
|
141
|
+
npx tsc --noEmit
|
|
142
|
+
npm run build
|
|
143
|
+
npm test
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 链接
|
|
147
|
+
|
|
148
|
+
- focalapi:<https://focalapi.com>
|
|
149
|
+
- Gitee:<https://gitee.com/xnn-ai/focalapi-cli>
|
|
150
|
+
- npm:<https://www.npmjs.com/package/focalapi-cli>
|
|
151
|
+
- 内置 Skills:[`./skills`](./skills)
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
[Apache-2.0](./LICENSE)
|