@happy-vibecode/cli 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.
package/README.md ADDED
@@ -0,0 +1,407 @@
1
+ # @happy-vibecode/cli
2
+
3
+ ![Version](https://img.shields.io/badge/version-0.1.1-blue)
4
+ ![Runtime](https://img.shields.io/badge/runtime-Bun%20%7C%20Node-green)
5
+ ![License](https://img.shields.io/badge/license-MIT-green)
6
+
7
+ Command-line interface for the Happy Vibecode platform. Connects local AI agents (Gemini CLI, Claude Code, Codex, Kilo, Cline, and more) to the Happy Vibecode cloud service, enabling remote control of your coding agents from the web dashboard or mobile app via WebSocket bridges.
8
+
9
+ ## Table of Contents
10
+
11
+ - [Getting Started](#getting-started)
12
+ - [Features](#features)
13
+ - [Commands](#commands)
14
+ - [Supported Agents](#supported-agents)
15
+ - [Architecture](#architecture)
16
+ - [Project Structure](#project-structure)
17
+ - [Configuration](#configuration)
18
+ - [Dependencies](#dependencies)
19
+ - [Scripts](#scripts)
20
+ - [Examples](#examples)
21
+ - [Troubleshooting](#troubleshooting)
22
+ - [Contributing](#contributing)
23
+ - [License](#license)
24
+
25
+ ## Getting Started
26
+
27
+ ### Installation
28
+
29
+ #### From npm (once published)
30
+
31
+ ```bash
32
+ npm install -g @happy-vibecode/cli
33
+
34
+ # Or use the shorthand
35
+ npm install -g @happy-vibecode/cli
36
+ # Then run via:
37
+ happy <command>
38
+ vibe <command>
39
+ ```
40
+
41
+ #### From source (development)
42
+
43
+ ```bash
44
+ # From the monorepo root
45
+ bun install
46
+ bun run -F @happy-vibecode/cli build
47
+
48
+ # Run directly
49
+ node packages/cli/dist/index.js <command>
50
+
51
+ # Or via bun
52
+ cd packages/cli
53
+ bun run start <command>
54
+ ```
55
+
56
+ ### Quick Start
57
+
58
+ ```bash
59
+ # 1. Authenticate with the Happy Vibecode platform
60
+ happy login
61
+
62
+ # 2. Initialize default agent configuration
63
+ happy init
64
+
65
+ # 3. Check your setup
66
+ happy doctor
67
+
68
+ # 4. Connect your first agent
69
+ happy connect gemini
70
+ ```
71
+
72
+ ## Features
73
+
74
+ - **Multi-agent support** — Works with Gemini, Claude Code, Codex, OpenCode AI, GitHub Copilot, Kilo, Cline, and custom agents
75
+ - **WebSocket bridge** — Real-time bidirectional communication between local agents and the cloud
76
+ - **Workspace management** — Configure and switch between project directories
77
+ - **Configuration management** — Show, set, and reset CLI configuration
78
+ - **Diagnostics** — `happy doctor` checks for common configuration issues
79
+ - **Status monitoring** — View server health and active sessions
80
+ - **Auth management** — Login, verify tokens, check identity
81
+
82
+ ## Commands
83
+
84
+ ### Authentication
85
+
86
+ | Command | Description |
87
+ | -------------- | ----------------------------------------------------------------- |
88
+ | `happy login` | Register a new account or authenticate with an existing API token |
89
+ | `happy whoami` | Show current authenticated user and server status |
90
+
91
+ ### Agent Connection
92
+
93
+ | Command | Description |
94
+ | ----------------------- | ------------------------------------------------------------------- |
95
+ | `happy connect <agent>` | Connect a local AI agent to the Happy Vibecode bridge via WebSocket |
96
+ | `happy init` | Create a default `agents.json` configuration file |
97
+
98
+ ### Workspace Management
99
+
100
+ | Command | Description |
101
+ | ----------------------------------- | ---------------------------------------------- |
102
+ | `happy workspace list` | List all configured workspaces |
103
+ | `happy workspace add <name> <path>` | Add a new workspace |
104
+ | `happy workspace remove <id>` | Remove a workspace |
105
+ | `happy workspace set-default <id>` | Set default provider and model for a workspace |
106
+ | `happy workspace activate <id>` | Set a workspace as the active workspace |
107
+
108
+ ### Configuration
109
+
110
+ | Command | Description |
111
+ | -------------------------------- | ----------------------------------- |
112
+ | `happy config show` | Display current configuration |
113
+ | `happy config set <key> <value>` | Set a configuration value |
114
+ | `happy config unset <key>` | Remove a configuration value |
115
+ | `happy config reset` | Reset all configuration to defaults |
116
+
117
+ ### Diagnostics
118
+
119
+ | Command | Description |
120
+ | -------------- | --------------------------------------------- |
121
+ | `happy doctor` | Diagnose configuration and connection issues |
122
+ | `happy status` | Show server health status and active sessions |
123
+
124
+ ## Supported Agents
125
+
126
+ | Agent | Provider | Command | Prompt Flag | Model Flag |
127
+ | ----------- | ------------ | ------------ | ------------ | ------------ |
128
+ | Gemini | Google | `gemini` | `-p` | — |
129
+ | Claude | Anthropic | `claude` | `-p` | `-m` |
130
+ | Codex | OpenAI | `codex` | `-p` | — |
131
+ | OpenCode AI | OpenCode | `opencode` | `--prompt` | — |
132
+ | Copilot | GitHub | `copilot` | `-p` | — |
133
+ | Kilo | Kilocode | `kilo` | `--prompt` | — |
134
+ | Cline | Cline | `cline` | `-p` | — |
135
+ | Custom | User-defined | Configurable | Configurable | Configurable |
136
+
137
+ ## Architecture
138
+
139
+ ```
140
+ CLI (this package)
141
+
142
+ ├── happy login ──→ POST /api/auth/register ──→ D1
143
+ ├── happy connect <agent>
144
+ │ │
145
+ │ ├── Spawns local agent process (e.g., gemini -p)
146
+ │ ├── Opens WebSocket to BridgeAgent Durable Object
147
+ │ └── Relays stdin/stdout ↔ WebSocket messages
148
+
149
+ ├── happy status ──→ GET /api/health + GET /api/sessions
150
+ └── happy doctor ──→ Local config validation
151
+ ```
152
+
153
+ ### Connection Flow
154
+
155
+ 1. `happy connect <agent>` reads the agent configuration from `agents.json`
156
+ 2. The CLI spawns the local agent process (e.g., `gemini -p`)
157
+ 3. A WebSocket connection opens to `wss://<server>/agents/BridgeAgent/<room-id>`
158
+ 4. The CLI relays prompts from the WebSocket to the agent's stdin
159
+ 5. Agent output (stdout/stderr) is relayed back through the WebSocket
160
+ 6. The web/mobile client can send prompts and receive responses in real-time
161
+
162
+ ## Project Structure
163
+
164
+ ```
165
+ packages/cli/
166
+ ├── src/
167
+ │ ├── index.ts # CLI entry — registers all commands via Commander
168
+ │ ├── config.ts # HappyConfig, readConfig/writeConfig, bridge code generation
169
+ │ ├── commands/
170
+ │ │ ├── login.ts # happy login
171
+ │ │ ├── connect.ts # happy connect <agent>
172
+ │ │ ├── init.ts # happy init
173
+ │ │ ├── workspace.ts # happy workspace (list/add/remove/set-default/activate)
174
+ │ │ ├── config.ts # happy config (show/set/unset/reset)
175
+ │ │ ├── doctor.ts # happy doctor
176
+ │ │ ├── status.ts # happy status
177
+ │ │ └── whoami.ts # happy whoami
178
+ │ ├── config/
179
+ │ │ └── workspace.ts # Workspace CRUD operations
180
+ │ ├── types/
181
+ │ │ └── llm-provider.ts # LLMProvider, PROVIDER_CONFIGS, AgentDefinition, etc.
182
+ │ └── utils/
183
+ │ ├── agents-config.ts # DEFAULT_AGENTS from PROVIDER_CONFIGS
184
+ │ └── log.ts # Debug logging (setDebug, debug, debugTime, debugFetch)
185
+ ├── dist/ # Built output (gitignored)
186
+ ├── tsconfig.json
187
+ ├── eslint.config.ts
188
+ └── package.json
189
+ ```
190
+
191
+ ## Configuration
192
+
193
+ ### HappyConfig
194
+
195
+ Stored at `~/.happy-vibecode/config.json` (or platform-appropriate config location):
196
+
197
+ | Field | Type | Description |
198
+ | ------------ | --------- | ----------------------------------------------- |
199
+ | `apiToken` | `string` | API authentication token |
200
+ | `serverUrl` | `string` | Happy Vibecode server URL (default: production) |
201
+ | `userId` | `string?` | Authenticated user ID |
202
+ | `bridgeCode` | `string?` | Bridge connection code |
203
+
204
+ ### Agents Configuration (`agents.json`)
205
+
206
+ Created by `happy init`. Defines available agents and workspaces:
207
+
208
+ ```typescript
209
+ interface AgentsConfig {
210
+ agents: AgentDefinition[]
211
+ workspaces?: WorkspaceConfig[]
212
+ }
213
+
214
+ interface AgentDefinition {
215
+ name: string // Display name
216
+ command: string // CLI command to execute
217
+ args?: string[] // Default arguments
218
+ promptFlag?: string // Flag for passing prompts
219
+ modelFlag?: string // Flag for passing model names
220
+ description?: string // Human-readable description
221
+ }
222
+
223
+ interface WorkspaceConfig {
224
+ name: string // Workspace name
225
+ path: string // Filesystem path
226
+ defaultProvider?: LLMProvider
227
+ defaultModel?: string
228
+ }
229
+ ```
230
+
231
+ ### Debug Logging
232
+
233
+ Enable debug mode for verbose output:
234
+
235
+ ```bash
236
+ # Via environment variable
237
+ DEBUG=1 happy connect gemini
238
+
239
+ # Or programmatically
240
+ import { setDebug } from "./utils/log";
241
+ setDebug(true);
242
+ ```
243
+
244
+ ## Dependencies
245
+
246
+ ### Internal
247
+
248
+ | Package | Purpose |
249
+ | -------------------------------------- | ----------------------------------- |
250
+ | [`@happy-vibecode/shared`](../shared/) | Shared types and validation schemas |
251
+
252
+ ### External
253
+
254
+ | Package | Purpose |
255
+ | ------------------- | --------------------------------------- |
256
+ | `commander` ^14.0.0 | CLI framework and command parsing |
257
+ | `execa` latest | Spawn and manage local agent processes |
258
+ | `ora` ^6.3.1 | Terminal spinner for loading states |
259
+ | `ws` ^8.18.2 | WebSocket client for bridge connections |
260
+
261
+ ## Scripts
262
+
263
+ | Script | Command | Description |
264
+ | ---------------- | --------------------------------------------------------------- | ------------------------ |
265
+ | `build` | `bun build ./src/index.ts --outfile dist/index.js --target bun` | Build for production |
266
+ | `dev` | `bun run --watch src/index.ts` | Run in watch mode |
267
+ | `start` | `bun run ./src/index.ts` | Run CLI directly |
268
+ | `lint` | `eslint .` | Lint source files |
269
+ | `lint:fix` | `eslint . --fix` | Lint and auto-fix |
270
+ | `typecheck` | `tsc --noEmit` | TypeScript type checking |
271
+ | `prepublishOnly` | `bun run lint:fix && bun run typecheck && bun run build` | Pre-publish checks |
272
+
273
+ ## Examples
274
+
275
+ ### Complete Setup Flow
276
+
277
+ ```bash
278
+ # Authenticate
279
+ happy login
280
+ # Enter your API token when prompted
281
+
282
+ # Initialize agent config
283
+ happy init
284
+
285
+ # Add a workspace
286
+ happy workspace add my-project /path/to/project
287
+
288
+ # Check everything is working
289
+ happy doctor
290
+
291
+ # View your identity
292
+ happy whoami
293
+
294
+ # Check server status
295
+ happy status
296
+ ```
297
+
298
+ ### Connecting Different Agents
299
+
300
+ ```bash
301
+ # Connect Gemini
302
+ happy connect gemini
303
+
304
+ # Connect Claude Code
305
+ happy connect claude
306
+
307
+ # Connect Codex
308
+ happy connect codex
309
+ ```
310
+
311
+ ### Managing Configuration
312
+
313
+ ```bash
314
+ # View all config
315
+ happy config show
316
+
317
+ # Set server URL (for self-hosted)
318
+ happy config set serverUrl https://my-instance.example.com
319
+
320
+ # Reset to defaults
321
+ happy config reset
322
+ ```
323
+
324
+ ### Using Debug Mode
325
+
326
+ ```bash
327
+ # Enable verbose logging
328
+ DEBUG=1 happy connect gemini
329
+
330
+ # Output includes WebSocket frames, HTTP requests, and timing
331
+ ```
332
+
333
+ ## Troubleshooting
334
+
335
+ ### `command not found: happy`
336
+
337
+ After installing globally, ensure the npm global bin directory is in your `PATH`:
338
+
339
+ ```bash
340
+ npm config get prefix
341
+ # Add <prefix>/bin to your PATH
342
+ ```
343
+
344
+ When running from source, use `node dist/index.js` or `bun run start`.
345
+
346
+ ### `ENOENT` when connecting an agent
347
+
348
+ The agent CLI binary is not installed or not on `PATH`. Install the required agent:
349
+
350
+ ```bash
351
+ # Gemini
352
+ npm install -g @anthropic-ai/gemini-cli # (example, check actual package)
353
+
354
+ # Claude Code
355
+ npm install -g @anthropic-ai/claude-code
356
+ ```
357
+
358
+ Then verify it's available:
359
+
360
+ ```bash
361
+ which gemini
362
+ which claude
363
+ ```
364
+
365
+ ### `ECONNREFUSED` on connect
366
+
367
+ The Happy Vibecode server is unreachable. Check:
368
+
369
+ 1. Your internet connection
370
+ 2. The `serverUrl` in config: `happy config show`
371
+ 3. Server status: `happy status`
372
+
373
+ ### `401 Unauthorized`
374
+
375
+ Your API token is invalid or expired. Re-authenticate:
376
+
377
+ ```bash
378
+ happy login
379
+ ```
380
+
381
+ ### `happy doctor` reports issues
382
+
383
+ The doctor command checks:
384
+
385
+ - Config file existence and validity
386
+ - API token presence
387
+ - Server connectivity
388
+ - Agent binary availability
389
+
390
+ Follow the suggestions in the output to resolve each issue.
391
+
392
+ ## Contributing
393
+
394
+ See the root [CONTRIBUTING.md](../../README.md#contributing) for general guidelines.
395
+
396
+ For this package specifically:
397
+
398
+ - One command file per command in `src/commands/`
399
+ - Use Commander.js patterns for argument parsing
400
+ - Use `ora` for all async operations that may take time
401
+ - Use `execa` for process spawning (not raw `child_process`)
402
+ - Add new agent support by extending `PROVIDER_CONFIGS` in `src/types/llm-provider.ts`
403
+ - Run `bun run typecheck` and `bun run lint` before submitting changes
404
+
405
+ ## License
406
+
407
+ This project is part of the [Happy Vibecode](../../README.md) monorepo. See the root LICENSE file for details.