api2cli 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +259 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,259 @@
1
+ # api2cli
2
+
3
+ Turn any REST API into a standardized, agent-ready CLI in minutes.
4
+
5
+ One CLI pattern. Every API. Any AI agent can use it.
6
+
7
+ ## The Problem
8
+
9
+ There are 10,000+ SaaS products with REST APIs. AI agents can only interact with a tiny fraction of them because:
10
+
11
+ - **No CLI exists** for most APIs (Typefully, Dub, Mercury, Front, etc.)
12
+ - **No MCP server** for 97% of APIs
13
+ - **No standardization** across the CLIs that do exist
14
+ - **No agent skills** that work across platforms
15
+
16
+ ## The Solution
17
+
18
+ `api2cli` generates standardized CLIs from any API. Every generated CLI follows the exact same patterns, so an agent that learns one CLI knows them all.
19
+
20
+ ```
21
+ api2cli create <app> → scaffold + build + link → <app>-cli ready to use
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ ```bash
27
+ # Install
28
+ bun install -g api2cli
29
+
30
+ # Create a CLI for any API
31
+ api2cli create typefully \
32
+ --base-url https://api.typefully.com \
33
+ --auth-type bearer
34
+
35
+ # Build and link to PATH
36
+ api2cli bundle typefully
37
+ api2cli link typefully
38
+
39
+ # Use it
40
+ typefully-cli auth set "typ_xxx"
41
+ typefully-cli drafts list
42
+ typefully-cli drafts create --text "Hello world" --platform x
43
+ ```
44
+
45
+ ## How It Works
46
+
47
+ ### 1. Create a CLI scaffold
48
+
49
+ ```bash
50
+ api2cli create <app> [options]
51
+ ```
52
+
53
+ | Flag | Description | Default |
54
+ |------|-------------|---------|
55
+ | `--base-url <url>` | API base URL | `https://api.example.com` |
56
+ | `--auth-type <type>` | `bearer`, `api-key`, `basic`, `custom` | `bearer` |
57
+ | `--auth-header <name>` | Auth header name | `Authorization` |
58
+ | `--docs <url>` | API docs URL (for agent-driven generation) | - |
59
+ | `--openapi <url>` | OpenAPI/Swagger spec URL | - |
60
+ | `--force` | Overwrite existing CLI | `false` |
61
+
62
+ This creates `~/.cli/<app>-cli/` with:
63
+ - HTTP client with retry/backoff
64
+ - Auth module (tokens in `~/.config/tokens/`)
65
+ - Multi-format output (text, JSON, CSV, YAML)
66
+ - Example resource file to copy
67
+
68
+ ### 2. Add resources
69
+
70
+ Create a file in `~/.cli/<app>-cli/src/resources/` for each API resource:
71
+
72
+ ```typescript
73
+ import { Command } from "commander";
74
+ import { client } from "../lib/client.js";
75
+ import { output } from "../lib/output.js";
76
+ import { handleError } from "../lib/errors.js";
77
+
78
+ export const draftsResource = new Command("drafts")
79
+ .description("Manage drafts");
80
+
81
+ draftsResource
82
+ .command("list")
83
+ .description("List all drafts")
84
+ .option("--limit <n>", "Max results", "20")
85
+ .option("--json", "Output as JSON")
86
+ .action(async (opts) => {
87
+ try {
88
+ const data = await client.get("/drafts", { limit: opts.limit });
89
+ output(data, { json: opts.json });
90
+ } catch (err) {
91
+ handleError(err, opts.json);
92
+ }
93
+ });
94
+ ```
95
+
96
+ Register it in `src/index.ts`:
97
+
98
+ ```typescript
99
+ import { draftsResource } from "./resources/drafts.js";
100
+ program.addCommand(draftsResource);
101
+ ```
102
+
103
+ ### 3. Build and link
104
+
105
+ ```bash
106
+ api2cli bundle <app> # Build the CLI (~5KB JS bundle)
107
+ api2cli link <app> # Add to PATH (updates .bashrc/.zshrc)
108
+ ```
109
+
110
+ ### 4. Use it
111
+
112
+ ```bash
113
+ <app>-cli auth set "your-token"
114
+ <app>-cli auth test
115
+ <app>-cli <resource> list --json
116
+ ```
117
+
118
+ ## All Commands
119
+
120
+ ### CLI Manager (`api2cli`)
121
+
122
+ | Command | Description |
123
+ |---------|-------------|
124
+ | `api2cli create <app>` | Generate a new CLI from API docs |
125
+ | `api2cli bundle <app>` | Build a CLI from source |
126
+ | `api2cli bundle --all` | Build all installed CLIs |
127
+ | `api2cli link <app>` | Add a CLI to PATH |
128
+ | `api2cli link --all` | Link all CLIs |
129
+ | `api2cli unlink <app>` | Remove from PATH |
130
+ | `api2cli list` | List all installed CLIs |
131
+ | `api2cli tokens` | List all configured tokens (masked) |
132
+ | `api2cli remove <app>` | Remove a CLI entirely |
133
+ | `api2cli doctor` | Check system requirements |
134
+ | `api2cli install <app>` | Install from registry (coming soon) |
135
+ | `api2cli publish <app>` | Publish to registry (coming soon) |
136
+ | `api2cli update <app>` | Re-sync with API changes |
137
+
138
+ ### Generated CLIs (`<app>-cli`)
139
+
140
+ Every generated CLI follows these exact conventions:
141
+
142
+ ```bash
143
+ # Authentication
144
+ <app>-cli auth set <token> # Save token (chmod 600)
145
+ <app>-cli auth show # Display masked token
146
+ <app>-cli auth show --raw # Display full token
147
+ <app>-cli auth test # Verify token works
148
+ <app>-cli auth remove # Delete token
149
+
150
+ # Resources (CRUD)
151
+ <app>-cli <resource> list # GET /resource
152
+ <app>-cli <resource> get <id> # GET /resource/:id
153
+ <app>-cli <resource> create # POST /resource
154
+ <app>-cli <resource> update <id> # PATCH /resource/:id
155
+ <app>-cli <resource> delete <id> # DELETE /resource/:id
156
+
157
+ # Global flags
158
+ --json # JSON output {ok, data, meta}
159
+ --format <text|json|csv|yaml> # Output format
160
+ --verbose # Debug logging
161
+ --no-color # Disable colors
162
+ --no-header # Omit table headers (for piping)
163
+
164
+ # Deep help at every level
165
+ <app>-cli --help
166
+ <app>-cli <resource> --help
167
+ <app>-cli <resource> <action> --help
168
+ ```
169
+
170
+ ### Output Formats
171
+
172
+ **Text (default):** Pretty tables for humans
173
+
174
+ ```
175
+ id status created_at
176
+ ──────────────────── ──────── ──────────
177
+ abc123 draft 2026-03-07
178
+ def456 published 2026-03-06
179
+ ```
180
+
181
+ **JSON (`--json`):** Structured envelope for agents
182
+
183
+ ```json
184
+ {
185
+ "ok": true,
186
+ "data": [...],
187
+ "meta": { "total": 42 }
188
+ }
189
+ ```
190
+
191
+ **CSV (`--format csv`):** For spreadsheets and piping
192
+
193
+ **YAML (`--format yaml`):** For config files
194
+
195
+ ## Agent Integration
196
+
197
+ ### AgentSkills (Claude Code, Cursor, Gemini CLI, etc.)
198
+
199
+ The repo includes `skills/api2cli/SKILL.md` following the [AgentSkills](https://agentskills.io) open standard. Install it in your agent:
200
+
201
+ ```bash
202
+ # Claude Code
203
+ cp -r skills/api2cli ~/.claude/skills/
204
+
205
+ # OpenClaw
206
+ cp -r skills/api2cli ~/.openclaw/workspace/skills/
207
+
208
+ # Or use skills-cli
209
+ npx skills-cli add api2cli
210
+ ```
211
+
212
+ Once installed, just tell your agent:
213
+
214
+ > "Create a CLI for the Typefully API"
215
+
216
+ The agent reads the skill, discovers the API, generates resources, builds, and links -- all automatically.
217
+
218
+ ### Supported Agents
219
+
220
+ Works with any tool that supports AgentSkills:
221
+ Claude Code, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenClaw, Goose, OpenHands, Junie, Amp, OpenCode, Letta, Firebender, Mux, Autohand
222
+
223
+ ## Project Structure
224
+
225
+ ```
226
+ api2cli/
227
+ ├── packages/
228
+ │ ├── cli/ # api2cli manager (create, bundle, link...)
229
+ │ └── template/ # CLI scaffold (gets cloned per API)
230
+ ├── apps/
231
+ │ └── web/ # api2cli.dev marketplace (Next.js + Neon)
232
+ ├── skills/
233
+ │ └── api2cli/ # AgentSkills SKILL.md
234
+ ├── biome.json # Linter + formatter
235
+ ├── tsconfig.base.json # Shared TypeScript config
236
+ └── TODO.md # Roadmap
237
+ ```
238
+
239
+ ## Tech Stack
240
+
241
+ - **Runtime:** [Bun](https://bun.sh) (fast startup, built-in bundler)
242
+ - **Language:** TypeScript (strict mode)
243
+ - **CLI Framework:** [Commander.js](https://github.com/tj/commander.js)
244
+ - **Linter:** [Biome](https://biomejs.dev)
245
+ - **Web:** Next.js + Neon (PostgreSQL)
246
+ - **Standard:** [AgentSkills](https://agentskills.io)
247
+
248
+ ## Token Storage
249
+
250
+ All tokens are stored in `~/.config/tokens/<app>-cli.txt` with `chmod 600`.
251
+
252
+ ```bash
253
+ api2cli tokens # List all tokens (masked)
254
+ api2cli tokens --show # Show full tokens
255
+ ```
256
+
257
+ ## License
258
+
259
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api2cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Turn any REST API into a standardized, agent-ready CLI",
5
5
  "type": "module",
6
6
  "bin": {