@flatkey-ai/cli 0.1.4 → 0.1.6
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/LICENSE +21 -0
- package/README.md +215 -13
- package/package.json +5 -1
- package/src/api.js +89 -6
- package/src/cli.js +78 -4
- package/src/config.js +3 -3
- package/src/help.js +153 -5
- package/src/models.js +5 -2
- package/.github/workflows/npm-publish.yml +0 -36
- package/docs/superpowers/plans/2026-07-17-flatkey-cli.md +0 -90
- package/docs/superpowers/specs/2026-07-17-flatkey-cli-design.md +0 -209
- package/release/deb/README.md +0 -16
- package/release/homebrew/flatkey.rb +0 -16
- package/release/msi/README.md +0 -15
- package/test/animation.test.js +0 -30
- package/test/api.test.js +0 -232
- package/test/artifacts.test.js +0 -108
- package/test/cli.test.js +0 -105
- package/test/config.test.js +0 -62
- package/test/help.test.js +0 -29
- package/test/integration.test.js +0 -204
- package/test/live-flatkey.test.js +0 -91
- package/test/models.test.js +0 -56
- package/test/package.test.js +0 -29
package/src/help.js
CHANGED
|
@@ -3,6 +3,7 @@ export function getAiHelp() {
|
|
|
3
3
|
|
|
4
4
|
Setup:
|
|
5
5
|
- Prefer env: FLATKEY_API_KEY=<key>
|
|
6
|
+
- Create a key at https://console.flatkey.ai/keys
|
|
6
7
|
- Or save key: flatkey onboard --api-key <key>
|
|
7
8
|
- Use --json for machine-readable output.
|
|
8
9
|
|
|
@@ -13,8 +14,11 @@ JSON mode:
|
|
|
13
14
|
|
|
14
15
|
Commands:
|
|
15
16
|
- flatkey image generate --prompt "<prompt>" --json [--model <model>] [--output image.png]
|
|
16
|
-
- flatkey video generate --prompt "<prompt>" --json [--model seedance2] [--output video.mp4]
|
|
17
|
-
- flatkey audio generate --prompt "<
|
|
17
|
+
- flatkey video generate --prompt "<prompt>" --json [--model seedance2] [--ratio 16:9] [--resolution 720p] [--output video.mp4]
|
|
18
|
+
- flatkey audio generate --prompt "<text>" --json [--voice-id <voice_id>] [--model eleven_multilingual_v2] [--output speech.mp3]
|
|
19
|
+
- flatkey audio sfx --prompt "<sound>" --json [--duration <seconds>] [--output sfx.mp3]
|
|
20
|
+
- flatkey audio music --prompt "<music prompt>" --json [--music-length-ms <ms>] [--output music.mp3]
|
|
21
|
+
- flatkey audio voices --json
|
|
18
22
|
- flatkey text generate --prompt "<prompt>" --json [--model gpt-5.5] [--output text.txt]
|
|
19
23
|
- flatkey credits --json
|
|
20
24
|
- flatkey status --json
|
|
@@ -26,8 +30,9 @@ Environment:
|
|
|
26
30
|
- Default router: https://router.flatkey.ai
|
|
27
31
|
|
|
28
32
|
Recovery:
|
|
29
|
-
- Missing key: run flatkey onboard --api-key <key> or set FLATKEY_API_KEY.
|
|
33
|
+
- Missing key: create one at https://console.flatkey.ai/keys, then run flatkey onboard --api-key <key> or set FLATKEY_API_KEY.
|
|
30
34
|
- Unknown model: run flatkey models --json, then retry with a listed model id.
|
|
35
|
+
- Unknown voice: run flatkey audio voices --json, then retry with a listed voice_id.
|
|
31
36
|
- API failure: inspect stderr JSON or HTTP message, then retry only after fixing request or credits.
|
|
32
37
|
`;
|
|
33
38
|
}
|
|
@@ -36,10 +41,13 @@ export function getHumanHelp() {
|
|
|
36
41
|
return `Usage: flatkey <command> [options]
|
|
37
42
|
|
|
38
43
|
Commands:
|
|
39
|
-
onboard --api-key <key> Save Flatkey API key
|
|
44
|
+
onboard --api-key <key> Save Flatkey API key from https://console.flatkey.ai/keys
|
|
40
45
|
image generate --prompt <txt> Generate image
|
|
41
46
|
video generate --prompt <txt> Generate video
|
|
42
|
-
audio generate --prompt <txt> Generate
|
|
47
|
+
audio generate --prompt <txt> Generate speech with ElevenLabs voices
|
|
48
|
+
audio sfx --prompt <txt> Generate sound effects
|
|
49
|
+
audio music --prompt <txt> Generate music
|
|
50
|
+
audio voices List available voices
|
|
43
51
|
text generate --prompt <txt> Generate text
|
|
44
52
|
credits Show remaining credits
|
|
45
53
|
status Show usage/status
|
|
@@ -50,5 +58,145 @@ Global options:
|
|
|
50
58
|
--json Print machine-readable JSON
|
|
51
59
|
--output, -o <file> Write generated output to a local file
|
|
52
60
|
--base-url <url> Override Flatkey router URL
|
|
61
|
+
|
|
62
|
+
Video options:
|
|
63
|
+
--ratio <value> 16:9, 9:16, 4:3, 3:4, 21:9, or 1:1
|
|
64
|
+
--resolution <value> 480p, 720p, or 1080p
|
|
53
65
|
`;
|
|
54
66
|
}
|
|
67
|
+
|
|
68
|
+
const COMMAND_HELP = {
|
|
69
|
+
audio: `Usage: flatkey audio <action> [options]
|
|
70
|
+
|
|
71
|
+
Actions:
|
|
72
|
+
generate --prompt <txt> Generate speech
|
|
73
|
+
sfx --prompt <txt> Generate sound effects
|
|
74
|
+
music --prompt <txt> Generate music
|
|
75
|
+
voices List available voices
|
|
76
|
+
|
|
77
|
+
Options:
|
|
78
|
+
--json Print machine-readable JSON
|
|
79
|
+
--output, -o <file> Write generated output to a local file
|
|
80
|
+
--model <model> Override model id
|
|
81
|
+
--voice-id <voice_id> Voice id for speech generation
|
|
82
|
+
--duration <seconds> Duration for sound effects
|
|
83
|
+
--music-length-ms <ms> Music length in milliseconds
|
|
84
|
+
--help Show audio help`,
|
|
85
|
+
"audio generate": `Usage: flatkey audio generate --prompt <txt> [options]
|
|
86
|
+
|
|
87
|
+
Options:
|
|
88
|
+
--voice-id <voice_id> Voice id
|
|
89
|
+
--model <model> Model id, default eleven_multilingual_v2
|
|
90
|
+
--stability <0..1> Voice stability
|
|
91
|
+
--similarity-boost <0..1> Voice similarity boost
|
|
92
|
+
--style <0..1> Voice style
|
|
93
|
+
--output, -o <file> Write speech file
|
|
94
|
+
--json Print machine-readable JSON`,
|
|
95
|
+
"audio music": `Usage: flatkey audio music --prompt <txt> [options]
|
|
96
|
+
|
|
97
|
+
Options:
|
|
98
|
+
--music-length-ms <ms> Music length in milliseconds
|
|
99
|
+
--output, -o <file> Write music file
|
|
100
|
+
--json Print machine-readable JSON`,
|
|
101
|
+
"audio sfx": `Usage: flatkey audio sfx --prompt <txt> [options]
|
|
102
|
+
|
|
103
|
+
Options:
|
|
104
|
+
--duration <seconds> Sound effect duration
|
|
105
|
+
--output, -o <file> Write sound effect file
|
|
106
|
+
--json Print machine-readable JSON`,
|
|
107
|
+
"audio voices": `Usage: flatkey audio voices [options]
|
|
108
|
+
|
|
109
|
+
Options:
|
|
110
|
+
--json Print machine-readable JSON`,
|
|
111
|
+
credits: `Usage: flatkey credits [options]
|
|
112
|
+
|
|
113
|
+
Options:
|
|
114
|
+
--json Print machine-readable JSON`,
|
|
115
|
+
help: `Usage: flatkey help [command] [options]
|
|
116
|
+
|
|
117
|
+
Options:
|
|
118
|
+
--ai Print agent-focused usage guide`,
|
|
119
|
+
image: `Usage: flatkey image generate --prompt <txt> [options]
|
|
120
|
+
|
|
121
|
+
Options:
|
|
122
|
+
--model <model> Model id
|
|
123
|
+
--size <size> Image size for OpenAI-style image models
|
|
124
|
+
--quality <quality> Image quality for supported models
|
|
125
|
+
--n <count> Number of images for supported models
|
|
126
|
+
--output, -o <file> Write image file
|
|
127
|
+
--json Print machine-readable JSON`,
|
|
128
|
+
"image generate": `Usage: flatkey image generate --prompt <txt> [options]
|
|
129
|
+
|
|
130
|
+
Options:
|
|
131
|
+
--model <model> Model id
|
|
132
|
+
--size <size> Image size for OpenAI-style image models
|
|
133
|
+
--quality <quality> Image quality for supported models
|
|
134
|
+
--n <count> Number of images for supported models
|
|
135
|
+
--output, -o <file> Write image file
|
|
136
|
+
--json Print machine-readable JSON`,
|
|
137
|
+
models: `Usage: flatkey models [options]
|
|
138
|
+
|
|
139
|
+
Options:
|
|
140
|
+
--type <type> Filter: image, video, audio, or text
|
|
141
|
+
--json Print machine-readable JSON`,
|
|
142
|
+
onboard: `Usage: flatkey onboard --api-key <key>
|
|
143
|
+
|
|
144
|
+
Create a Flatkey API key first:
|
|
145
|
+
https://console.flatkey.ai/keys
|
|
146
|
+
|
|
147
|
+
Options:
|
|
148
|
+
--api-key <key> Flatkey API key to save`,
|
|
149
|
+
status: `Usage: flatkey status [options]
|
|
150
|
+
|
|
151
|
+
Options:
|
|
152
|
+
--json Print machine-readable JSON`,
|
|
153
|
+
text: `Usage: flatkey text generate --prompt <txt> [options]
|
|
154
|
+
|
|
155
|
+
Options:
|
|
156
|
+
--model <model> Model id, default gpt-5.5
|
|
157
|
+
--output, -o <file> Write text file
|
|
158
|
+
--json Print machine-readable JSON`,
|
|
159
|
+
"text generate": `Usage: flatkey text generate --prompt <txt> [options]
|
|
160
|
+
|
|
161
|
+
Options:
|
|
162
|
+
--model <model> Model id, default gpt-5.5
|
|
163
|
+
--output, -o <file> Write text file
|
|
164
|
+
--json Print machine-readable JSON`,
|
|
165
|
+
version: `Usage: flatkey version [options]
|
|
166
|
+
|
|
167
|
+
Aliases:
|
|
168
|
+
flatkey --version
|
|
169
|
+
flatkey -v
|
|
170
|
+
|
|
171
|
+
Options:
|
|
172
|
+
--json Print machine-readable JSON`,
|
|
173
|
+
video: `Usage: flatkey video generate --prompt <txt> [options]
|
|
174
|
+
|
|
175
|
+
Options:
|
|
176
|
+
--model <model> Model id, default veo-3
|
|
177
|
+
--duration <seconds> Video duration
|
|
178
|
+
--ratio <value> 16:9, 9:16, 4:3, 3:4, 21:9, or 1:1
|
|
179
|
+
--resolution <value> 480p, 720p, or 1080p
|
|
180
|
+
--fps <fps> Frames per second
|
|
181
|
+
--output, -o <file> Write video file
|
|
182
|
+
--json Print machine-readable JSON`,
|
|
183
|
+
"video generate": `Usage: flatkey video generate --prompt <txt> [options]
|
|
184
|
+
|
|
185
|
+
Options:
|
|
186
|
+
--model <model> Model id, default veo-3
|
|
187
|
+
--duration <seconds> Video duration
|
|
188
|
+
--ratio <value> 16:9, 9:16, 4:3, 3:4, 21:9, or 1:1
|
|
189
|
+
--resolution <value> 480p, 720p, or 1080p
|
|
190
|
+
--fps <fps> Frames per second
|
|
191
|
+
--output, -o <file> Write video file
|
|
192
|
+
--json Print machine-readable JSON`,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export function getCommandHelp(group, action) {
|
|
196
|
+
const key = action ? `${group} ${action}` : group;
|
|
197
|
+
const help = COMMAND_HELP[key];
|
|
198
|
+
if (!help) {
|
|
199
|
+
throw new Error(`Unknown help topic: ${key}`);
|
|
200
|
+
}
|
|
201
|
+
return help;
|
|
202
|
+
}
|
package/src/models.js
CHANGED
|
@@ -6,8 +6,11 @@ const BUNDLED_MODELS = [
|
|
|
6
6
|
{ id: "veo-3-fast", type: "video" },
|
|
7
7
|
{ id: "seedance2", type: "video" },
|
|
8
8
|
{ id: "gpt-5.5", type: "text" },
|
|
9
|
-
{ id: "
|
|
10
|
-
{ id: "
|
|
9
|
+
{ id: "eleven_multilingual_v2", type: "audio" },
|
|
10
|
+
{ id: "eleven_turbo_v2_5", type: "audio" },
|
|
11
|
+
{ id: "eleven_flash_v2_5", type: "audio" },
|
|
12
|
+
{ id: "sound-generation", type: "audio" },
|
|
13
|
+
{ id: "music", type: "audio" },
|
|
11
14
|
];
|
|
12
15
|
|
|
13
16
|
export function getBundledModels(type) {
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
name: Publish npm
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
push:
|
|
6
|
-
tags:
|
|
7
|
-
- "v*"
|
|
8
|
-
|
|
9
|
-
permissions:
|
|
10
|
-
contents: read
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
publish:
|
|
14
|
-
name: Publish @flatkey-ai/cli
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- name: Checkout
|
|
19
|
-
uses: actions/checkout@v4
|
|
20
|
-
|
|
21
|
-
- name: Setup Node
|
|
22
|
-
uses: actions/setup-node@v4
|
|
23
|
-
with:
|
|
24
|
-
node-version: 22
|
|
25
|
-
registry-url: "https://registry.npmjs.org"
|
|
26
|
-
|
|
27
|
-
- name: Install dependencies
|
|
28
|
-
run: npm install
|
|
29
|
-
|
|
30
|
-
- name: Test
|
|
31
|
-
run: npm test
|
|
32
|
-
|
|
33
|
-
- name: Publish
|
|
34
|
-
run: npm publish --access public
|
|
35
|
-
env:
|
|
36
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# Flatkey CLI Implementation Plan
|
|
2
|
-
|
|
3
|
-
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
-
|
|
5
|
-
**Goal:** Build `@flatkey-ai/cli`, a Node.js CLI for Flatkey image, video, audio, credits, status, models, onboarding, and AI-first help.
|
|
6
|
-
|
|
7
|
-
**Architecture:** Use small ESM modules with dependency-injected `fetch`, filesystem paths, and streams so behavior can be tested without real Flatkey calls. The CLI parser converts argv into command objects, command handlers call provider functions, and output helpers keep human logs off stdout in JSON mode.
|
|
8
|
-
|
|
9
|
-
**Tech Stack:** Node.js ESM, npm package bin, built-in `node:test`, `assert/strict`, `fs/promises`, `child_process`, and global `fetch`.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## File Structure
|
|
14
|
-
|
|
15
|
-
- `package.json`: npm metadata, bin mapping, scripts, engines.
|
|
16
|
-
- `bin/flatkey.js`: executable entrypoint.
|
|
17
|
-
- `src/cli.js`: argv parsing, command dispatch, exit handling.
|
|
18
|
-
- `src/config.js`: API key/config resolution and onboarding writes.
|
|
19
|
-
- `src/api.js`: Flatkey HTTP requests and route selection.
|
|
20
|
-
- `src/artifacts.js`: save base64/data URL/url artifacts.
|
|
21
|
-
- `src/help.js`: human and AI help text.
|
|
22
|
-
- `src/models.js`: bundled fallback model list and remote normalization.
|
|
23
|
-
- `src/animation.js`: ASCII animation lifecycle.
|
|
24
|
-
- `test/*.test.js`: focused tests for each module and CLI subprocess behavior.
|
|
25
|
-
|
|
26
|
-
## Task 1: Package and Parser
|
|
27
|
-
|
|
28
|
-
- [ ] Write failing tests in `test/cli.test.js` for `parseArgv`, including `flatkey image generate --prompt x --json`, `flatkey credits --json`, unknown command, and `flatkey help --ai`.
|
|
29
|
-
- [ ] Run `npm test -- test/cli.test.js`; expect module-not-found or function-not-found failure.
|
|
30
|
-
- [ ] Create `package.json`, `bin/flatkey.js`, and `src/cli.js` with minimal parser and dispatch stubs.
|
|
31
|
-
- [ ] Run `npm test -- test/cli.test.js`; expect parser tests pass.
|
|
32
|
-
- [ ] Commit: `feat: add cli parser`
|
|
33
|
-
|
|
34
|
-
## Task 2: Config and Onboarding
|
|
35
|
-
|
|
36
|
-
- [ ] Write failing tests in `test/config.test.js` for API key precedence: option, `FLATKEY_API_KEY`, saved config, and missing key error.
|
|
37
|
-
- [ ] Write failing test for `writeConfig` creating config JSON with `apiKey`.
|
|
38
|
-
- [ ] Run `npm test -- test/config.test.js`; expect missing module failure.
|
|
39
|
-
- [ ] Create `src/config.js` and wire `onboard` command to write config.
|
|
40
|
-
- [ ] Run `npm test -- test/config.test.js test/cli.test.js`; expect pass.
|
|
41
|
-
- [ ] Commit: `feat: add flatkey config`
|
|
42
|
-
|
|
43
|
-
## Task 3: API Requests
|
|
44
|
-
|
|
45
|
-
- [ ] Write failing tests in `test/api.test.js` for Nano image route, OpenAI image route, video route, audio route, credits route, status route, and models route using injected fetch.
|
|
46
|
-
- [ ] Run `npm test -- test/api.test.js`; expect missing module failure.
|
|
47
|
-
- [ ] Create `src/api.js` with `FlatkeyError`, `generateImage`, `generateVideo`, `generateAudio`, `getCredits`, `getStatus`, and `getModels`.
|
|
48
|
-
- [ ] Run `npm test -- test/api.test.js`; expect pass.
|
|
49
|
-
- [ ] Commit: `feat: add flatkey api client`
|
|
50
|
-
|
|
51
|
-
## Task 4: Artifacts and Model Fallback
|
|
52
|
-
|
|
53
|
-
- [ ] Write failing tests in `test/artifacts.test.js` for saving base64, data URL, and preserving URL outputs.
|
|
54
|
-
- [ ] Write failing tests in `test/models.test.js` for bundled fallback shape and type filtering.
|
|
55
|
-
- [ ] Run targeted tests; expect missing module failures.
|
|
56
|
-
- [ ] Create `src/artifacts.js` and `src/models.js`.
|
|
57
|
-
- [ ] Run targeted tests; expect pass.
|
|
58
|
-
- [ ] Commit: `feat: add artifact and model helpers`
|
|
59
|
-
|
|
60
|
-
## Task 5: Help and Animation
|
|
61
|
-
|
|
62
|
-
- [ ] Write failing tests in `test/help.test.js` checking `help --ai` includes setup, JSON contract, image/video/audio examples, credits, status, and models.
|
|
63
|
-
- [ ] Write failing tests in `test/animation.test.js` checking no animation when JSON mode or non-TTY.
|
|
64
|
-
- [ ] Run targeted tests; expect missing module failures.
|
|
65
|
-
- [ ] Create `src/help.js` and `src/animation.js`.
|
|
66
|
-
- [ ] Run targeted tests; expect pass.
|
|
67
|
-
- [ ] Commit: `feat: add help and animation`
|
|
68
|
-
|
|
69
|
-
## Task 6: Command Integration
|
|
70
|
-
|
|
71
|
-
- [ ] Write failing subprocess tests in `test/integration.test.js` with a local HTTP server for `image generate --json`, `video generate --json`, `audio generate --json`, `credits --json`, `status --json`, and `models --json`.
|
|
72
|
-
- [ ] Run `npm test -- test/integration.test.js`; expect command behavior missing.
|
|
73
|
-
- [ ] Wire command handlers in `src/cli.js` to config, API, artifacts, models, help, and animation.
|
|
74
|
-
- [ ] Run `npm test`; expect pass.
|
|
75
|
-
- [ ] Commit: `feat: wire flatkey cli commands`
|
|
76
|
-
|
|
77
|
-
## Task 7: Release Metadata
|
|
78
|
-
|
|
79
|
-
- [ ] Write failing tests or static checks for package name `@flatkey-ai/cli`, bin `flatkey`, and executable bin file.
|
|
80
|
-
- [ ] Add `README.md` with install, auth, commands, and release channel notes.
|
|
81
|
-
- [ ] Add `release/homebrew/flatkey.rb`, `release/deb/README.md`, and `release/msi/README.md` as packaging stubs that wrap npm package release.
|
|
82
|
-
- [ ] Run `npm test`.
|
|
83
|
-
- [ ] Commit: `docs: add release notes`
|
|
84
|
-
|
|
85
|
-
## Final Verification
|
|
86
|
-
|
|
87
|
-
- [ ] Run `npm test`.
|
|
88
|
-
- [ ] Run `node bin/flatkey.js help --ai`.
|
|
89
|
-
- [ ] Run `node bin/flatkey.js models --json` without network key and confirm bundled fallback.
|
|
90
|
-
- [ ] Run `git status --short`.
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
# Flatkey CLI Design
|
|
2
|
-
|
|
3
|
-
## Goal
|
|
4
|
-
|
|
5
|
-
Build `@flatkey-ai/cli`, a cross-platform npm CLI for media workers and AI agents to use Flatkey as the most cost-effective practical AI API entrypoint for image, video, and audio generation. The CLI should make cost, credits, model choice, upload inputs, generation jobs, and saved artifacts visible from the terminal.
|
|
6
|
-
|
|
7
|
-
## Scope
|
|
8
|
-
|
|
9
|
-
The CLI provides:
|
|
10
|
-
|
|
11
|
-
- Image generation.
|
|
12
|
-
- Video generation.
|
|
13
|
-
- Audio generation.
|
|
14
|
-
- Cost estimation before generation.
|
|
15
|
-
- Generation job creation, listing, inspection, and waiting.
|
|
16
|
-
- Uploads for local image, video, and audio inputs.
|
|
17
|
-
- Credit balance and usage status.
|
|
18
|
-
- Recent credit transactions.
|
|
19
|
-
- AI-first help output.
|
|
20
|
-
- Available model listing.
|
|
21
|
-
- Model parameter inspection.
|
|
22
|
-
- Local onboarding for a Flatkey API key.
|
|
23
|
-
- A short ASCII animation during human-facing generation commands.
|
|
24
|
-
|
|
25
|
-
The first implementation is a Node.js npm package. It runs on Windows, Linux, and macOS through Node. Homebrew, apt/deb, and MSI packaging are release channels around the npm package, not separate native implementations.
|
|
26
|
-
|
|
27
|
-
## Package and Binary
|
|
28
|
-
|
|
29
|
-
Package name: `@flatkey-ai/cli`.
|
|
30
|
-
|
|
31
|
-
Primary binary: `flatkey`.
|
|
32
|
-
|
|
33
|
-
The package uses ESM JavaScript and keeps runtime dependencies minimal. It should run with the current active Node LTS line and newer.
|
|
34
|
-
|
|
35
|
-
## Command Surface
|
|
36
|
-
|
|
37
|
-
Top-level commands:
|
|
38
|
-
|
|
39
|
-
- `flatkey onboard [--api-key <key>]`
|
|
40
|
-
- `flatkey image generate --prompt "<prompt>" [options]`
|
|
41
|
-
- `flatkey video generate --prompt "<prompt>" [options]`
|
|
42
|
-
- `flatkey audio generate --prompt "<prompt>" [options]`
|
|
43
|
-
- `flatkey generate create <model> --prompt "<prompt>" [options]`
|
|
44
|
-
- `flatkey generate cost <model> --prompt "<prompt>" [options]`
|
|
45
|
-
- `flatkey generate get <job-id> [--json]`
|
|
46
|
-
- `flatkey generate list [--type image|video|audio] [--json]`
|
|
47
|
-
- `flatkey generate wait <job-id> [--json]`
|
|
48
|
-
- `flatkey upload create <file> [--json]`
|
|
49
|
-
- `flatkey upload list [--type image|video|audio] [--json]`
|
|
50
|
-
- `flatkey credits [--json]`
|
|
51
|
-
- `flatkey status [--json]`
|
|
52
|
-
- `flatkey transactions [--size <count>] [--json]`
|
|
53
|
-
- `flatkey models [--type image|video|audio] [--json]`
|
|
54
|
-
- `flatkey models get <model> [--json]`
|
|
55
|
-
- `flatkey help [--ai] [--json]`
|
|
56
|
-
- `flatkey version`
|
|
57
|
-
|
|
58
|
-
Shared generation options:
|
|
59
|
-
|
|
60
|
-
- `--model <model>`
|
|
61
|
-
- `--base-url <url>`
|
|
62
|
-
- `--api-key <key>`
|
|
63
|
-
- `--out <dir>`
|
|
64
|
-
- `--json`
|
|
65
|
-
|
|
66
|
-
Image-specific options:
|
|
67
|
-
|
|
68
|
-
- `--size <width>x<height>`
|
|
69
|
-
- `--aspect <ratio>`
|
|
70
|
-
- `--n <count>`
|
|
71
|
-
- `--quality <quality>`
|
|
72
|
-
|
|
73
|
-
Video-specific options:
|
|
74
|
-
|
|
75
|
-
- `--duration <seconds>`
|
|
76
|
-
- `--aspect <ratio>`
|
|
77
|
-
- `--fps <number>`
|
|
78
|
-
|
|
79
|
-
Audio-specific options:
|
|
80
|
-
|
|
81
|
-
- `--voice <voice>`
|
|
82
|
-
- `--format <mp3|wav|aac|flac>`
|
|
83
|
-
|
|
84
|
-
## Authentication and Config
|
|
85
|
-
|
|
86
|
-
Credential resolution order:
|
|
87
|
-
|
|
88
|
-
1. `--api-key`
|
|
89
|
-
2. `FLATKEY_API_KEY`
|
|
90
|
-
3. Saved config at `~/.config/flatkey/config.json`
|
|
91
|
-
|
|
92
|
-
`flatkey onboard` writes the config file with mode `0600` where supported. Windows should ignore chmod failures.
|
|
93
|
-
|
|
94
|
-
## Flatkey API Integration
|
|
95
|
-
|
|
96
|
-
Default base URL: `https://router.flatkey.ai`.
|
|
97
|
-
|
|
98
|
-
Image generation follows the proven `awesome-images` behavior:
|
|
99
|
-
|
|
100
|
-
- OpenAI-compatible image endpoint: `POST /v1/images/generations`
|
|
101
|
-
- Gemini-style Nano endpoint: `POST /v1beta/models/{model}:generateContent?key={apiKey}`
|
|
102
|
-
|
|
103
|
-
The CLI should default image generation to the Nano route when `--model` is omitted or starts with `nano`, and use `/v1/images/generations` for `gpt` or `gpt-image-*`.
|
|
104
|
-
|
|
105
|
-
Video, audio, cost, jobs, uploads, credits, status, transactions, and models are implemented through small provider functions with configurable endpoint paths. The initial default paths are:
|
|
106
|
-
|
|
107
|
-
- `POST /v1/videos/generations`
|
|
108
|
-
- `POST /v1/audio/generations`
|
|
109
|
-
- `POST /v1/generations`
|
|
110
|
-
- `POST /v1/generations/cost`
|
|
111
|
-
- `GET /v1/generations`
|
|
112
|
-
- `GET /v1/generations/{jobId}`
|
|
113
|
-
- `POST /v1/uploads`
|
|
114
|
-
- `GET /v1/uploads`
|
|
115
|
-
- `GET /v1/credits`
|
|
116
|
-
- `GET /v1/credits/transactions`
|
|
117
|
-
- `GET /v1/status`
|
|
118
|
-
- `GET /v1/models`
|
|
119
|
-
- `GET /v1/models/{model}`
|
|
120
|
-
|
|
121
|
-
If Flatkey router returns a different shape, adapters normalize results before printing or saving artifacts.
|
|
122
|
-
|
|
123
|
-
## Output and Artifacts
|
|
124
|
-
|
|
125
|
-
Default output directory: `flatkey-output`.
|
|
126
|
-
|
|
127
|
-
Generation commands save returned files when the API returns base64 or data URLs, and print remote URLs when the API returns URLs. JSON mode prints a machine-readable payload and suppresses animation/logging.
|
|
128
|
-
|
|
129
|
-
Artifact naming:
|
|
130
|
-
|
|
131
|
-
- `image-01.png`
|
|
132
|
-
- `video-01.mp4`
|
|
133
|
-
- `audio-01.mp3`
|
|
134
|
-
|
|
135
|
-
Extensions come from returned MIME types when available.
|
|
136
|
-
|
|
137
|
-
## AI-First Help
|
|
138
|
-
|
|
139
|
-
`flatkey help --ai` prints a compact protocol-style guide:
|
|
140
|
-
|
|
141
|
-
- Required setup.
|
|
142
|
-
- Commands.
|
|
143
|
-
- Arguments.
|
|
144
|
-
- Environment variables.
|
|
145
|
-
- JSON mode contract.
|
|
146
|
-
- Example calls for image, video, audio, cost, upload, job wait, credits, transactions, status, and models.
|
|
147
|
-
- Error recovery instructions for missing key, unknown model, and API failure.
|
|
148
|
-
|
|
149
|
-
Human `--help` remains readable but secondary.
|
|
150
|
-
|
|
151
|
-
## Models
|
|
152
|
-
|
|
153
|
-
`flatkey models` fetches remote model metadata when API key and network are available. If remote fetch fails, it falls back to bundled defaults:
|
|
154
|
-
|
|
155
|
-
- Image: `nano-banana-pro-preview`, `nano-banana-flash`, `gpt-image-2`
|
|
156
|
-
- Video: `veo-3`, `veo-3-fast`
|
|
157
|
-
- Audio: `tts-1`, `gpt-4o-mini-tts`
|
|
158
|
-
|
|
159
|
-
The fallback must mark `source: "bundled"` in JSON output.
|
|
160
|
-
|
|
161
|
-
## ASCII Animation
|
|
162
|
-
|
|
163
|
-
Human generation mode shows a short stderr animation before and during network calls. Requirements:
|
|
164
|
-
|
|
165
|
-
- Uses plain ASCII only.
|
|
166
|
-
- No animation in `--json`.
|
|
167
|
-
- Does not corrupt stdout artifact paths.
|
|
168
|
-
- Works in Windows terminals.
|
|
169
|
-
- Automatically falls back to simple log lines when stderr is not a TTY.
|
|
170
|
-
|
|
171
|
-
## Error Handling
|
|
172
|
-
|
|
173
|
-
Errors should be short and actionable:
|
|
174
|
-
|
|
175
|
-
- Missing key: explain `flatkey onboard` and `FLATKEY_API_KEY`.
|
|
176
|
-
- Unknown command: point to `flatkey help --ai`.
|
|
177
|
-
- HTTP failure: show API message when present, otherwise status code.
|
|
178
|
-
- Save failure: show output path and filesystem error.
|
|
179
|
-
|
|
180
|
-
JSON mode errors still exit non-zero and write error JSON to stderr.
|
|
181
|
-
|
|
182
|
-
## Testing
|
|
183
|
-
|
|
184
|
-
Use Node's built-in `node:test` and `assert/strict`.
|
|
185
|
-
|
|
186
|
-
Test coverage:
|
|
187
|
-
|
|
188
|
-
- Argument parsing.
|
|
189
|
-
- Config read/write and env precedence.
|
|
190
|
-
- Request building for image OpenAI and Nano routes.
|
|
191
|
-
- Request building for video/audio/credits/status/models.
|
|
192
|
-
- Artifact persistence from base64, data URL, and URL payloads.
|
|
193
|
-
- JSON mode suppresses animation/logging.
|
|
194
|
-
- CLI subprocess tests against local HTTP servers.
|
|
195
|
-
|
|
196
|
-
## Release Channels
|
|
197
|
-
|
|
198
|
-
Primary release is npm:
|
|
199
|
-
|
|
200
|
-
- `npm publish --access public`
|
|
201
|
-
- Users run `npx @flatkey-ai/cli` or install globally.
|
|
202
|
-
|
|
203
|
-
Secondary release assets:
|
|
204
|
-
|
|
205
|
-
- Homebrew formula that installs the npm package and exposes `flatkey`.
|
|
206
|
-
- Debian package wrapping the npm package and generated launcher.
|
|
207
|
-
- MSI package wrapping the npm package and generated Windows launcher.
|
|
208
|
-
|
|
209
|
-
Release automation should be added after the CLI is working and tested.
|
package/release/deb/README.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Debian Package
|
|
2
|
-
|
|
3
|
-
Build `.deb` as a wrapper around the published npm package.
|
|
4
|
-
|
|
5
|
-
Expected install behavior:
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
sudo apt-get install flatkey
|
|
9
|
-
flatkey help --ai
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Package contents:
|
|
13
|
-
|
|
14
|
-
- Node runtime dependency.
|
|
15
|
-
- Global install of `@flatkey-ai/cli`.
|
|
16
|
-
- `/usr/bin/flatkey` launcher.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class Flatkey < Formula
|
|
2
|
-
desc "Flatkey media generation CLI"
|
|
3
|
-
homepage "https://github.com/flatkey-ai/flatkey-cli"
|
|
4
|
-
license "MIT"
|
|
5
|
-
|
|
6
|
-
depends_on "node"
|
|
7
|
-
|
|
8
|
-
def install
|
|
9
|
-
system "npm", "install", "-g", "@flatkey-ai/cli", "--prefix", libexec
|
|
10
|
-
bin.install_symlink Dir["#{libexec}/bin/flatkey"].first
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
test do
|
|
14
|
-
system "#{bin}/flatkey", "help", "--ai"
|
|
15
|
-
end
|
|
16
|
-
end
|
package/release/msi/README.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Windows MSI
|
|
2
|
-
|
|
3
|
-
Build MSI as a wrapper around the published npm package.
|
|
4
|
-
|
|
5
|
-
Expected install behavior:
|
|
6
|
-
|
|
7
|
-
```powershell
|
|
8
|
-
flatkey help --ai
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Package contents:
|
|
12
|
-
|
|
13
|
-
- Node runtime prerequisite or bundled runtime.
|
|
14
|
-
- Install of `@flatkey-ai/cli`.
|
|
15
|
-
- `flatkey.cmd` on PATH.
|
package/test/animation.test.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { test } from "node:test";
|
|
3
|
-
|
|
4
|
-
import { createAnimation } from "../src/animation.js";
|
|
5
|
-
|
|
6
|
-
test("does not animate in json mode", () => {
|
|
7
|
-
let output = "";
|
|
8
|
-
const animation = createAnimation({
|
|
9
|
-
json: true,
|
|
10
|
-
stream: { isTTY: true, write: (chunk) => { output += chunk; } },
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
animation.start("image");
|
|
14
|
-
animation.stop();
|
|
15
|
-
|
|
16
|
-
assert.equal(output, "");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("uses single log line when stderr is not a tty", () => {
|
|
20
|
-
let output = "";
|
|
21
|
-
const animation = createAnimation({
|
|
22
|
-
json: false,
|
|
23
|
-
stream: { isTTY: false, write: (chunk) => { output += chunk; } },
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
animation.start("video");
|
|
27
|
-
animation.stop();
|
|
28
|
-
|
|
29
|
-
assert.equal(output, "flatkey video generation started\n");
|
|
30
|
-
});
|