focalapi-cli 0.2.0 → 0.2.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 CHANGED
@@ -1,155 +1,141 @@
1
- <div align="center">
2
-
3
- # focalapi-cli
4
-
5
- **让任意 AI Agent 直接调用 focalapi 创作模型**
6
-
7
- [![npm](https://img.shields.io/npm/v/focalapi-cli?color=brightgreen&label=npm)](https://www.npmjs.com/package/focalapi-cli)
8
- [![license](https://img.shields.io/badge/license-Apache--2.0-blue)](./LICENSE)
9
- [![node](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](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)
1
+ <div align="center">
2
+
3
+ # focalapi-cli
4
+
5
+ **Give any AI Agent direct access to FocalAPI creative models**
6
+
7
+ [![npm](https://img.shields.io/npm/v/focalapi-cli?color=brightgreen&label=npm)](https://www.npmjs.com/package/focalapi-cli)
8
+ [![license](https://img.shields.io/badge/license-Apache--2.0-blue)](./LICENSE)
9
+ [![node](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
10
+
11
+ ```shell
12
+ npm i -g focalapi-cli
13
+ ```
14
+
15
+ </div>
16
+
17
+ focalapi-cli turns FocalAPI's creative-model gateway into commands and Skills that an Agent can run directly. Users describe the outcome they want; the Agent does not need to probe models, guess parameters, handcraft requests, or switch platforms first.
18
+
19
+ It does not configure FocalAPI as the Agent's primary model or provider. Agents such as Codex, Claude Code, and Cursor keep their existing reasoning models and call FocalAPI only for creative tasks such as image and video generation.
20
+
21
+ ## Connect in three steps
22
+
23
+ ```shell
24
+ # 1. Install. Skills are synchronized automatically when lifecycle scripts are allowed.
25
+ npm i -g focalapi-cli
26
+
27
+ # 2. Configure a FocalAPI key.
28
+ focalapi auth login --key sk-xxxx
29
+
30
+ # 3. Connect every detected Agent, then verify the installation. The operation is idempotent.
31
+ focalapi connect
32
+ focalapi connect verify --json
33
+ ```
34
+
35
+ Create a key at <https://focalapi.com/console/token>. CI and sandbox environments can use `FOCALAPI_API_KEY`; self-hosted deployments can set `FOCALAPI_BASE_URL`.
36
+
37
+ If an npm security policy blocks lifecycle scripts, run `focalapi connect` explicitly. This is also the stable manual integration entry point. Set `FOCALAPI_SKIP_POSTINSTALL=1` to intentionally skip automatic post-install integration.
38
+
39
+ ## Zero-guesswork Agent workflows
40
+
41
+ When no model is specified, the CLI reads the live model pool and detailed model contract available to the current key, selects the maintained FocalAPI default, and sends only one real generation request.
42
+
43
+ ```shell
44
+ # Automatically select the current default image model.
45
+ focalapi gen image "Product hero image, soft studio lighting" -o ./out --json
46
+
47
+ # Automatically select the current default video model and return a task ID immediately.
48
+ focalapi gen video "Ocean waves hitting rocks, cinematic" --no-wait -o ./out --json
49
+
50
+ # Continue from next_command in the generation response without resubmitting the task.
51
+ focalapi task status <task-id> --json
52
+ focalapi task download <task-id> -o ./out --json
53
+ ```
54
+
55
+ When the user specifies a model, read its authoritative contract first:
56
+
57
+ ```shell
58
+ focalapi models get <model-id> --json
59
+ focalapi gen image "<prompt>" -m <model-id> [contract-supported options] -o ./out --json
60
+ ```
61
+
62
+ The CLI can also resolve a model without generating anything:
63
+
64
+ ```shell
65
+ focalapi models resolve image --json
66
+ focalapi models resolve video --json
67
+ ```
68
+
69
+ `resolve` returns the exact `model.id`, verified `endpoint_type`, complete `supported_params`, candidate models, and a `next_command`. When a list summary and detailed contract disagree, the detailed contract is authoritative.
70
+
71
+ The maintained creative defaults are aligned with the current catalog: Seedream 5.0, GPT Image 2, Gemini 3.1 Image, Grok Imagine Image 2.0, Kling Image 3.0, Qwen Image 3.0, and Krea 2 for images; Seedance 2.5, Kling 3.0, Vidu Q3, Gemini Omni Flash, Grok Imagine Video 1.5, LTX 2.5, FLUX 3, and MiniMax H3 for video. Availability still depends on the current key, so runtime model details always take precedence over this overview.
72
+
73
+ ## Agent integration
74
+
75
+ ```shell
76
+ focalapi connect # Install or repair every detected Agent.
77
+ focalapi connect list # Inspect supported, detected, and installed targets.
78
+ focalapi connect install codex cursor # Install for selected Agents.
79
+ focalapi connect install --path <dir> # Install to an unlisted or project-level Skills directory.
80
+ focalapi connect verify --json # Verify Skill integrity and authentication readiness.
81
+ focalapi connect uninstall # Remove only managed Skills that the user has not modified.
82
+ ```
83
+
84
+ The built-in catalog currently covers 44 Agent targets, including Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, OpenClaw, Cline, Windsurf, Warp, Trae, Qwen Code, Kimi CLI, and Hermes. Targets such as Codex, Cline, Pi, and Warp that share `~/.agents/skills` are deduplicated by path, so the Skills are installed only once.
85
+
86
+ Installation is transactional: the current `focalapi-*` catalog is written as one unit, and any failed step rolls back the operation. The manifest records a SHA-256 directory digest for each Skill. By default, uninstall removes only managed Skills whose digest has not changed and preserves user-modified content.
87
+
88
+ The Skill routing contract requires Agents to:
89
+
90
+ - trigger FocalAPI for creative tasks even when the user does not name it;
91
+ - omit `--model` when no model is specified, letting the CLI select one without generating test samples;
92
+ - use only the live parameter contract returned by `models get` for an explicitly selected model;
93
+ - reuse the original `task_id` for asynchronous work instead of charging for duplicate submissions while a task is `pending`;
94
+ - return to the original task after resolving an authentication error rather than stopping at diagnostics.
95
+
96
+ ## Current capability boundary
97
+
98
+ The fully validated automatic generation paths currently cover images and video, including image editing, reference-image creation, text-to-video, and image-to-video. The CLI retains text and audio commands, but an Agent may use them only when both the live model details and CLI help expose an executable contract. It never infers future audio, 3D, or other modality support from model names alone.
99
+
100
+ ## Stable output for Agents
101
+
102
+ - All automation commands support `--json`; stdout contains JSON only, while progress and diagnostics go to stderr.
103
+ - Errors use `{ error: { code, message, hint, request_id? } }`.
104
+ - API keys are always redacted.
105
+ - Image results return local `files`; asynchronous video results return `task_id` and `next_command`.
106
+ - Local validation rejects known invalid billing multipliers and model parameters before sending a request.
107
+
108
+ ## Command map
109
+
110
+ | Task | Command |
111
+ | --- | --- |
112
+ | Generate images with automatic or explicit model selection | `focalapi gen image` |
113
+ | Generate video with automatic or explicit model selection | `focalapi gen video` |
114
+ | Resolve models and inspect live contracts | `focalapi models resolve/get/search/list` |
115
+ | Check and download asynchronous tasks | `focalapi task status/download` |
116
+ | Sign in and inspect key status | `focalapi auth login/status/logout` |
117
+ | Inspect quota, usage, and diagnostics | `focalapi usage`, `focalapi doctor` |
118
+ | Connect Agent Skills | `focalapi connect` |
119
+ | Make read-only raw API requests | `focalapi request get/head` |
120
+
121
+ Every command includes built-in help: `focalapi <command> --help`.
122
+
123
+ ## Development validation
124
+
125
+ ```shell
126
+ npm install
127
+ npx tsc --noEmit
128
+ npm run build
129
+ npm test
130
+ ```
131
+
132
+ ## Links
133
+
134
+ - FocalAPI: <https://focalapi.com>
135
+ - GitHub: <https://github.com/focalapi/focalapi-cli>
136
+ - npm: <https://www.npmjs.com/package/focalapi-cli>
137
+ - Bundled Skills: [`./skills`](./skills)
138
+
139
+ ## License
140
+
141
+ [Apache-2.0](./LICENSE)