@flatkey-ai/cli 0.1.5 → 0.1.7

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/src/help.js CHANGED
@@ -2,7 +2,9 @@ export function getAiHelp() {
2
2
  return `Flatkey CLI protocol for agents
3
3
 
4
4
  Setup:
5
- - Prefer env: FLATKEY_API_KEY=<key>
5
+ - Prefer browser auth: flatkey login
6
+ - Or env: FLATKEY_API_KEY=<key>
7
+ - Create a key at https://console.flatkey.ai/keys
6
8
  - Or save key: flatkey onboard --api-key <key>
7
9
  - Use --json for machine-readable output.
8
10
 
@@ -13,7 +15,7 @@ JSON mode:
13
15
 
14
16
  Commands:
15
17
  - flatkey image generate --prompt "<prompt>" --json [--model <model>] [--output image.png]
16
- - flatkey video generate --prompt "<prompt>" --json [--model seedance2] [--output video.mp4]
18
+ - flatkey video generate --prompt "<prompt>" --json [--model seedance2] [--ratio 16:9] [--resolution 720p] [--output video.mp4]
17
19
  - flatkey audio generate --prompt "<text>" --json [--voice-id <voice_id>] [--model eleven_multilingual_v2] [--output speech.mp3]
18
20
  - flatkey audio sfx --prompt "<sound>" --json [--duration <seconds>] [--output sfx.mp3]
19
21
  - flatkey audio music --prompt "<music prompt>" --json [--music-length-ms <ms>] [--output music.mp3]
@@ -22,6 +24,9 @@ Commands:
22
24
  - flatkey credits --json
23
25
  - flatkey status --json
24
26
  - flatkey models --json [--type image|video|audio|text]
27
+ - flatkey login [--no-open] [--console-url <url>]
28
+ - flatkey logout
29
+ - flatkey auth status --json
25
30
  - flatkey help --ai
26
31
 
27
32
  Environment:
@@ -29,7 +34,7 @@ Environment:
29
34
  - Default router: https://router.flatkey.ai
30
35
 
31
36
  Recovery:
32
- - Missing key: run flatkey onboard --api-key <key> or set FLATKEY_API_KEY.
37
+ - Missing key: create one at https://console.flatkey.ai/keys, then run flatkey onboard --api-key <key> or set FLATKEY_API_KEY.
33
38
  - Unknown model: run flatkey models --json, then retry with a listed model id.
34
39
  - Unknown voice: run flatkey audio voices --json, then retry with a listed voice_id.
35
40
  - API failure: inspect stderr JSON or HTTP message, then retry only after fixing request or credits.
@@ -40,7 +45,10 @@ export function getHumanHelp() {
40
45
  return `Usage: flatkey <command> [options]
41
46
 
42
47
  Commands:
43
- onboard --api-key <key> Save Flatkey API key
48
+ login Authorize CLI in browser
49
+ logout Remove saved Flatkey API key
50
+ auth status Show saved auth state
51
+ onboard --api-key <key> Save Flatkey API key from https://console.flatkey.ai/keys
44
52
  image generate --prompt <txt> Generate image
45
53
  video generate --prompt <txt> Generate video
46
54
  audio generate --prompt <txt> Generate speech with ElevenLabs voices
@@ -57,5 +65,167 @@ Global options:
57
65
  --json Print machine-readable JSON
58
66
  --output, -o <file> Write generated output to a local file
59
67
  --base-url <url> Override Flatkey router URL
68
+ --console-url <url> Override Flatkey console URL for login
69
+
70
+ Video options:
71
+ --ratio <value> 16:9, 9:16, 4:3, 3:4, 21:9, or 1:1
72
+ --resolution <value> 480p, 720p, or 1080p
60
73
  `;
61
74
  }
75
+
76
+ const COMMAND_HELP = {
77
+ audio: `Usage: flatkey audio <action> [options]
78
+
79
+ Actions:
80
+ generate --prompt <txt> Generate speech
81
+ sfx --prompt <txt> Generate sound effects
82
+ music --prompt <txt> Generate music
83
+ voices List available voices
84
+
85
+ Options:
86
+ --json Print machine-readable JSON
87
+ --output, -o <file> Write generated output to a local file
88
+ --model <model> Override model id
89
+ --voice-id <voice_id> Voice id for speech generation
90
+ --duration <seconds> Duration for sound effects
91
+ --music-length-ms <ms> Music length in milliseconds
92
+ --help Show audio help`,
93
+ "audio generate": `Usage: flatkey audio generate --prompt <txt> [options]
94
+
95
+ Options:
96
+ --voice-id <voice_id> Voice id
97
+ --model <model> Model id, default eleven_multilingual_v2
98
+ --stability <0..1> Voice stability
99
+ --similarity-boost <0..1> Voice similarity boost
100
+ --style <0..1> Voice style
101
+ --output, -o <file> Write speech file
102
+ --json Print machine-readable JSON`,
103
+ "audio music": `Usage: flatkey audio music --prompt <txt> [options]
104
+
105
+ Options:
106
+ --music-length-ms <ms> Music length in milliseconds
107
+ --output, -o <file> Write music file
108
+ --json Print machine-readable JSON`,
109
+ "audio sfx": `Usage: flatkey audio sfx --prompt <txt> [options]
110
+
111
+ Options:
112
+ --duration <seconds> Sound effect duration
113
+ --output, -o <file> Write sound effect file
114
+ --json Print machine-readable JSON`,
115
+ "audio voices": `Usage: flatkey audio voices [options]
116
+
117
+ Options:
118
+ --json Print machine-readable JSON`,
119
+ credits: `Usage: flatkey credits [options]
120
+
121
+ Options:
122
+ --json Print machine-readable JSON`,
123
+ auth: `Usage: flatkey auth <action> [options]
124
+
125
+ Actions:
126
+ status Show saved auth state
127
+
128
+ Options:
129
+ --json Print machine-readable JSON`,
130
+ "auth status": `Usage: flatkey auth status [options]
131
+
132
+ Options:
133
+ --json Print machine-readable JSON`,
134
+ help: `Usage: flatkey help [command] [options]
135
+
136
+ Options:
137
+ --ai Print agent-focused usage guide`,
138
+ image: `Usage: flatkey image generate --prompt <txt> [options]
139
+
140
+ Options:
141
+ --model <model> Model id
142
+ --size <size> Image size for OpenAI-style image models
143
+ --quality <quality> Image quality for supported models
144
+ --n <count> Number of images for supported models
145
+ --output, -o <file> Write image file
146
+ --json Print machine-readable JSON`,
147
+ "image generate": `Usage: flatkey image generate --prompt <txt> [options]
148
+
149
+ Options:
150
+ --model <model> Model id
151
+ --size <size> Image size for OpenAI-style image models
152
+ --quality <quality> Image quality for supported models
153
+ --n <count> Number of images for supported models
154
+ --output, -o <file> Write image file
155
+ --json Print machine-readable JSON`,
156
+ models: `Usage: flatkey models [options]
157
+
158
+ Options:
159
+ --type <type> Filter: image, video, audio, or text
160
+ --json Print machine-readable JSON`,
161
+ login: `Usage: flatkey login [options]
162
+
163
+ Options:
164
+ --no-open Print approval URL without opening a browser
165
+ --console-url <url> Override Flatkey console URL
166
+ --json Print machine-readable JSON`,
167
+ logout: `Usage: flatkey logout [options]
168
+
169
+ Options:
170
+ --json Print machine-readable JSON`,
171
+ onboard: `Usage: flatkey onboard --api-key <key>
172
+
173
+ Create a Flatkey API key first:
174
+ https://console.flatkey.ai/keys
175
+
176
+ Options:
177
+ --api-key <key> Flatkey API key to save`,
178
+ status: `Usage: flatkey status [options]
179
+
180
+ Options:
181
+ --json Print machine-readable JSON`,
182
+ text: `Usage: flatkey text generate --prompt <txt> [options]
183
+
184
+ Options:
185
+ --model <model> Model id, default gpt-5.5
186
+ --output, -o <file> Write text file
187
+ --json Print machine-readable JSON`,
188
+ "text generate": `Usage: flatkey text generate --prompt <txt> [options]
189
+
190
+ Options:
191
+ --model <model> Model id, default gpt-5.5
192
+ --output, -o <file> Write text file
193
+ --json Print machine-readable JSON`,
194
+ version: `Usage: flatkey version [options]
195
+
196
+ Aliases:
197
+ flatkey --version
198
+ flatkey -v
199
+
200
+ Options:
201
+ --json Print machine-readable JSON`,
202
+ video: `Usage: flatkey video generate --prompt <txt> [options]
203
+
204
+ Options:
205
+ --model <model> Model id, default veo-3
206
+ --duration <seconds> Video duration
207
+ --ratio <value> 16:9, 9:16, 4:3, 3:4, 21:9, or 1:1
208
+ --resolution <value> 480p, 720p, or 1080p
209
+ --fps <fps> Frames per second
210
+ --output, -o <file> Write video file
211
+ --json Print machine-readable JSON`,
212
+ "video generate": `Usage: flatkey video generate --prompt <txt> [options]
213
+
214
+ Options:
215
+ --model <model> Model id, default veo-3
216
+ --duration <seconds> Video duration
217
+ --ratio <value> 16:9, 9:16, 4:3, 3:4, 21:9, or 1:1
218
+ --resolution <value> 480p, 720p, or 1080p
219
+ --fps <fps> Frames per second
220
+ --output, -o <file> Write video file
221
+ --json Print machine-readable JSON`,
222
+ };
223
+
224
+ export function getCommandHelp(group, action) {
225
+ const key = action ? `${group} ${action}` : group;
226
+ const help = COMMAND_HELP[key];
227
+ if (!help) {
228
+ throw new Error(`Unknown help topic: ${key}`);
229
+ }
230
+ return help;
231
+ }
@@ -1,50 +0,0 @@
1
- name: Bug report
2
- description: Report a Flatkey CLI bug.
3
- title: "[Bug]: "
4
- labels: ["bug"]
5
- body:
6
- - type: textarea
7
- id: summary
8
- attributes:
9
- label: Summary
10
- description: What happened?
11
- validations:
12
- required: true
13
- - type: textarea
14
- id: command
15
- attributes:
16
- label: Command
17
- description: Paste the command. Redact API keys.
18
- render: bash
19
- validations:
20
- required: true
21
- - type: textarea
22
- id: output
23
- attributes:
24
- label: Output
25
- description: Paste relevant stdout/stderr. Redact secrets.
26
- render: text
27
- - type: input
28
- id: version
29
- attributes:
30
- label: Version
31
- description: Run `flatkey --version`.
32
- placeholder: "0.1.4"
33
- - type: dropdown
34
- id: os
35
- attributes:
36
- label: OS
37
- options:
38
- - macOS
39
- - Linux
40
- - Windows
41
- - Other
42
- - type: checkboxes
43
- id: checks
44
- attributes:
45
- label: Checks
46
- options:
47
- - label: I removed API keys and secrets from this report.
48
- required: true
49
- - label: I tried the command again with `--dry-run` when applicable.
50
- required: false
@@ -1,34 +0,0 @@
1
- name: Feature request
2
- description: Request a Flatkey CLI feature.
3
- title: "[Feature]: "
4
- labels: ["enhancement"]
5
- body:
6
- - type: textarea
7
- id: problem
8
- attributes:
9
- label: Problem
10
- description: What workflow should be easier?
11
- validations:
12
- required: true
13
- - type: textarea
14
- id: proposal
15
- attributes:
16
- label: Proposal
17
- description: What command or behavior do you want?
18
- render: bash
19
- validations:
20
- required: true
21
- - type: dropdown
22
- id: area
23
- attributes:
24
- label: Area
25
- options:
26
- - image
27
- - video
28
- - audio
29
- - text
30
- - models
31
- - credits/status
32
- - packaging
33
- - docs
34
- - other
@@ -1,13 +0,0 @@
1
- ## Summary
2
-
3
- -
4
-
5
- ## Test
6
-
7
- ```bash
8
- npm test
9
- ```
10
-
11
- ## Notes
12
-
13
- - No API keys or generated media committed.
@@ -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 }}
package/CONTRIBUTING.md DELETED
@@ -1,37 +0,0 @@
1
- # Contributing
2
-
3
- Thanks for improving Flatkey CLI.
4
-
5
- ## Setup
6
-
7
- ```bash
8
- git clone https://github.com/flatkey-ai/flatkey-cli.git
9
- cd flatkey-cli
10
- npm install
11
- npm test
12
- ```
13
-
14
- ## Local CLI
15
-
16
- ```bash
17
- node bin/flatkey.js --version
18
- node bin/flatkey.js help --ai
19
- node bin/flatkey.js image generate --prompt "test" --dry-run --json
20
- ```
21
-
22
- ## Tests
23
-
24
- Run all tests before opening a PR:
25
-
26
- ```bash
27
- npm test
28
- ```
29
-
30
- Live tests require `FLATKEY_API_KEY` and can spend credits. Keep routine tests mocked or `--dry-run`.
31
-
32
- ## Pull Requests
33
-
34
- - Keep changes small and focused.
35
- - Add or update tests for behavior changes.
36
- - Do not commit API keys, generated media, or local config.
37
- - Use `--dry-run` examples when possible.
package/SECURITY.md DELETED
@@ -1,13 +0,0 @@
1
- # Security
2
-
3
- ## Reporting
4
-
5
- Please do not open public issues for security vulnerabilities.
6
-
7
- Report security concerns through Flatkey support at [flatkey.ai](https://flatkey.ai/?utm_source=github&utm_medium=security&utm_campaign=flatkey_cli).
8
-
9
- ## API Keys
10
-
11
- - Prefer `FLATKEY_API_KEY` for automation.
12
- - Never commit API keys.
13
- - Rotate keys if they appear in logs, screenshots, shell history, or public CI.
@@ -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`.