@4ge/cli 0.1.0
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 +228 -0
- package/bin/dev.js +3 -0
- package/bin/run.js +3 -0
- package/dist/base.js +398 -0
- package/dist/commands/auth/login.js +197 -0
- package/dist/commands/auth/logout.js +31 -0
- package/dist/commands/auth/profile/delete.js +34 -0
- package/dist/commands/auth/profile/list.js +32 -0
- package/dist/commands/auth/profile/use.js +30 -0
- package/dist/commands/auth/status.js +107 -0
- package/dist/commands/config/get.js +37 -0
- package/dist/commands/config/index.js +9 -0
- package/dist/commands/config/manage.js +165 -0
- package/dist/commands/config/set.js +42 -0
- package/dist/commands/config/show.js +46 -0
- package/dist/commands/epic/index.js +10 -0
- package/dist/commands/epic/list.js +91 -0
- package/dist/commands/epic/pull.js +137 -0
- package/dist/commands/epic/show.js +67 -0
- package/dist/commands/epic/update.js +104 -0
- package/dist/commands/feature/index.js +2 -0
- package/dist/commands/feature/list.js +93 -0
- package/dist/commands/feature/pull.js +122 -0
- package/dist/commands/feature/show.js +60 -0
- package/dist/commands/feature/update.js +103 -0
- package/dist/commands/idea/create.js +88 -0
- package/dist/commands/idea/graduate.js +89 -0
- package/dist/commands/idea/index.js +5 -0
- package/dist/commands/idea/list.js +83 -0
- package/dist/commands/idea/show.js +86 -0
- package/dist/commands/idea/update.js +108 -0
- package/dist/commands/init.js +354 -0
- package/dist/commands/login.js +5 -0
- package/dist/commands/plan/index.js +10 -0
- package/dist/commands/plan/pull.js +104 -0
- package/dist/commands/plan/versions.js +64 -0
- package/dist/commands/project/create.js +84 -0
- package/dist/commands/project/index.js +9 -0
- package/dist/commands/project/info.js +74 -0
- package/dist/commands/project/list.js +78 -0
- package/dist/commands/project/pull.js +127 -0
- package/dist/commands/project/update.js +104 -0
- package/dist/commands/root.js +13 -0
- package/dist/commands/skill/index.js +8 -0
- package/dist/commands/skill/install.js +71 -0
- package/dist/commands/story/index.js +10 -0
- package/dist/commands/story/list.js +81 -0
- package/dist/commands/story/pull.js +125 -0
- package/dist/commands/story/show.js +57 -0
- package/dist/commands/story/update.js +103 -0
- package/dist/commands/template/create.js +72 -0
- package/dist/commands/template/delete.js +62 -0
- package/dist/commands/template/feature/create.js +70 -0
- package/dist/commands/template/feature/delete.js +75 -0
- package/dist/commands/template/feature/list.js +69 -0
- package/dist/commands/template/feature/update.js +82 -0
- package/dist/commands/template/info.js +52 -0
- package/dist/commands/template/list.js +76 -0
- package/dist/commands/template/pull.js +99 -0
- package/dist/commands/template/update.js +71 -0
- package/dist/commands/whoami.js +5 -0
- package/dist/core/api/action-hints.js +17 -0
- package/dist/core/api/index.js +3 -0
- package/dist/core/api/retry.js +95 -0
- package/dist/core/api/validate-response.js +41 -0
- package/dist/core/auth/api-client.js +156 -0
- package/dist/core/auth/config.js +3 -0
- package/dist/core/auth/credentials.js +143 -0
- package/dist/core/auth/email-auth.js +30 -0
- package/dist/core/auth/errors.js +20 -0
- package/dist/core/auth/index.js +6 -0
- package/dist/core/auth/realtime.js +82 -0
- package/dist/core/auth/resolution.js +63 -0
- package/dist/core/auth/state.js +9 -0
- package/dist/core/auth/token-refresh.js +100 -0
- package/dist/core/config/defaults.js +31 -0
- package/dist/core/config/index.js +3 -0
- package/dist/core/config/parser.js +213 -0
- package/dist/core/config/schema.js +29 -0
- package/dist/core/project/markdown.js +37 -0
- package/dist/core/skill/installer.js +59 -0
- package/dist/core/skill/paths.js +52 -0
- package/dist/generated/api/client/client.gen.js +217 -0
- package/dist/generated/api/client/index.js +6 -0
- package/dist/generated/api/client/types.gen.js +2 -0
- package/dist/generated/api/client/utils.gen.js +231 -0
- package/dist/generated/api/client.gen.js +3 -0
- package/dist/generated/api/core/auth.gen.js +14 -0
- package/dist/generated/api/core/bodySerializer.gen.js +57 -0
- package/dist/generated/api/core/params.gen.js +103 -0
- package/dist/generated/api/core/pathSerializer.gen.js +114 -0
- package/dist/generated/api/core/queryKeySerializer.gen.js +99 -0
- package/dist/generated/api/core/serverSentEvents.gen.js +136 -0
- package/dist/generated/api/core/types.gen.js +2 -0
- package/dist/generated/api/core/utils.gen.js +87 -0
- package/dist/generated/api/index.js +2 -0
- package/dist/generated/api/sdk.gen.js +556 -0
- package/dist/generated/api/types.gen.js +2 -0
- package/dist/generated/api/zod.gen.js +1262 -0
- package/dist/ui/components/action-hints.js +33 -0
- package/dist/ui/components/cli-header.js +91 -0
- package/dist/ui/components/confirm-prompt.js +28 -0
- package/dist/ui/components/data-table.js +35 -0
- package/dist/ui/components/detail-view.js +5 -0
- package/dist/ui/components/error-display.js +5 -0
- package/dist/ui/components/prompt-layout.js +6 -0
- package/dist/ui/components/select-prompt.js +28 -0
- package/dist/ui/components/spinner.js +14 -0
- package/dist/ui/components/success-message.js +5 -0
- package/dist/ui/components/text-input.js +29 -0
- package/dist/ui/hooks/use-action-hints.js +21 -0
- package/dist/ui/hooks/use-status.js +22 -0
- package/dist/ui/index.js +15 -0
- package/dist/ui/prompt-helpers.js +55 -0
- package/dist/ui/render.js +9 -0
- package/package.json +89 -0
- package/skills/4ge-cli.md +113 -0
- package/usage.md +320 -0
package/usage.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# 4ge CLI Usage Guide
|
|
2
|
+
|
|
3
|
+
> A Universal Interface for 4ge Resources
|
|
4
|
+
|
|
5
|
+
## Installation & Setup
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
- Node.js >= 24
|
|
9
|
+
|
|
10
|
+
### Install (end users)
|
|
11
|
+
|
|
12
|
+
Install the published CLI globally from npm:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g @4ge/cli
|
|
16
|
+
4ge --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires Node.js 24+. The package ships prebuilt (`dist/` is built at publish
|
|
20
|
+
time via CI), so no build step runs on your machine.
|
|
21
|
+
|
|
22
|
+
Update later:
|
|
23
|
+
```bash
|
|
24
|
+
npm update -g @4ge/cli
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Install (contributors / from source)
|
|
28
|
+
|
|
29
|
+
Clone and install dependencies:
|
|
30
|
+
```bash
|
|
31
|
+
git clone git@github.com:Conflate-AI/4ge-cli.git
|
|
32
|
+
cd 4ge-cli
|
|
33
|
+
pnpm install
|
|
34
|
+
pnpm sync-api # sync Zod schemas + API client from the Core API OpenAPI spec
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Run
|
|
38
|
+
- **Production (installed)**: `4ge <command>`
|
|
39
|
+
- **Development (from source)**: `pnpm dev <command>`
|
|
40
|
+
- **Build only**: `pnpm build` (outputs `dist/`)
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
1. **Install**: `npm install -g @4ge/cli`
|
|
45
|
+
2. **Authenticate**: `4ge auth:login --token <your_api_key>`
|
|
46
|
+
3. **Initialize a project**: `4ge init`
|
|
47
|
+
4. **Check status**: `4ge whoami`
|
|
48
|
+
5. **Install the agent skill** (optional): `4ge skill:install`
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Authentication
|
|
52
|
+
|
|
53
|
+
### Overview
|
|
54
|
+
The 4ge CLI supports two primary authentication methods:
|
|
55
|
+
- **PAT (Personal Access Token)**: For headless, CI/CD, or AI agent use via the `--token` flag or environment variables.
|
|
56
|
+
- **OAuth (Future)**: Interactive browser-based login for human users (not yet available).
|
|
57
|
+
|
|
58
|
+
### Credential Resolution Order
|
|
59
|
+
The CLI resolves credentials in the following order of priority:
|
|
60
|
+
1. `4GE_API_KEY` environment variable
|
|
61
|
+
2. Local project configuration: `./.4ge/credentials.json`
|
|
62
|
+
3. Global profile configuration: `~/.4ge/credentials.json` (active profile)
|
|
63
|
+
|
|
64
|
+
### `4ge auth:login`
|
|
65
|
+
Authenticate and save credentials to your preferred scope.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Save to default global profile
|
|
69
|
+
4ge auth:login --token <api_key>
|
|
70
|
+
|
|
71
|
+
# Save to a specific named profile
|
|
72
|
+
4ge auth:login --token <api_key> --profile work
|
|
73
|
+
|
|
74
|
+
# Save to the current project (local override)
|
|
75
|
+
4ge auth:login --token <api_key> --local
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `4ge auth:status` / `4ge whoami`
|
|
79
|
+
Check the current authentication status and identify the active user.
|
|
80
|
+
|
|
81
|
+
**Human Output:**
|
|
82
|
+
```bash
|
|
83
|
+
$ 4ge whoami
|
|
84
|
+
Authenticated as: Matt (matt@example.com)
|
|
85
|
+
Source: Local config (./.4ge/credentials.json)
|
|
86
|
+
Workspace: 4ge-internal
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**JSON Output:**
|
|
90
|
+
```bash
|
|
91
|
+
$ 4ge whoami --json
|
|
92
|
+
{
|
|
93
|
+
"data": {
|
|
94
|
+
"authenticated": true,
|
|
95
|
+
"user": { "id": "uuid", "email": "matt@example.com", "name": "Matt" },
|
|
96
|
+
"source": "local",
|
|
97
|
+
"workspace": "4ge-internal"
|
|
98
|
+
},
|
|
99
|
+
"error": null,
|
|
100
|
+
"metadata": { "timestamp": "2026-05-23T10:00:00.000Z" }
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `4ge auth:logout`
|
|
105
|
+
Clear stored credentials from different scopes.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Clear active global profile
|
|
109
|
+
4ge auth:logout
|
|
110
|
+
|
|
111
|
+
# Clear local project credentials
|
|
112
|
+
4ge auth:logout --local
|
|
113
|
+
|
|
114
|
+
# Clear a specific named profile
|
|
115
|
+
4ge auth:logout --profile work
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Named Profiles
|
|
119
|
+
Manage multiple environments or accounts using the profile system.
|
|
120
|
+
|
|
121
|
+
- `4ge auth:profile:list` — List all stored profiles.
|
|
122
|
+
- `4ge auth:profile:use <name>` — Switch the active global profile.
|
|
123
|
+
- `4ge auth:profile:delete <name>` — Remove a profile from global storage.
|
|
124
|
+
|
|
125
|
+
**Credential File Format (`~/.4ge/credentials.json`):**
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"activeProfile": "default",
|
|
129
|
+
"profiles": {
|
|
130
|
+
"default": {
|
|
131
|
+
"token": "4ge_pat_...",
|
|
132
|
+
"baseUrl": "http://localhost:3000"
|
|
133
|
+
},
|
|
134
|
+
"work": {
|
|
135
|
+
"token": "4ge_pat_...",
|
|
136
|
+
"baseUrl": "https://api.4ge.io"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Project Initialization
|
|
143
|
+
|
|
144
|
+
### `4ge init`
|
|
145
|
+
Sets up the current directory as a 4ge project. This is an interactive process:
|
|
146
|
+
1. Validates authentication.
|
|
147
|
+
2. Prompts for workspace selection.
|
|
148
|
+
3. Prompts for project selection.
|
|
149
|
+
4. Creates `.4ge/config.yaml`.
|
|
150
|
+
5. Updates `.4ge/.gitignore` to exclude secrets.
|
|
151
|
+
6. Offers to install the AI agent skill (default: No).
|
|
152
|
+
|
|
153
|
+
**Non-interactive (JSON) mode:**
|
|
154
|
+
To run `init` in automation, you must provide the workspace and project IDs:
|
|
155
|
+
```bash
|
|
156
|
+
4ge init --json --workspace <uuid> --project <uuid>
|
|
157
|
+
```
|
|
158
|
+
To auto-install the agent skill non-interactively, add `--skill`:
|
|
159
|
+
```bash
|
|
160
|
+
4ge init --json --workspace <uuid> --project <uuid> --skill
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Agent Skill
|
|
164
|
+
|
|
165
|
+
The CLI ships an agent-facing skill document (`skills/4ge-cli.md` in the package)
|
|
166
|
+
that teaches AI agents how to use the CLI. Install it into a project so your
|
|
167
|
+
agent (pi, Cursor, Claude Code, Codex, etc.) picks it up automatically.
|
|
168
|
+
|
|
169
|
+
Install mirrors the [`npx skills`](https://github.com/vercel-labs/skills)
|
|
170
|
+
directory convention:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Default: universal project scope -> .agents/skills/4ge-cli/SKILL.md
|
|
174
|
+
4ge skill:install
|
|
175
|
+
|
|
176
|
+
# Target a specific agent harness
|
|
177
|
+
4ge skill:install --agent pi # -> .pi/skills/4ge-cli/SKILL.md
|
|
178
|
+
4ge skill:install --agent claude-code # -> .claude/skills/4ge-cli/SKILL.md
|
|
179
|
+
|
|
180
|
+
# Install to user (global) scope
|
|
181
|
+
4ge skill:install --global
|
|
182
|
+
|
|
183
|
+
# Overwrite an existing install
|
|
184
|
+
4ge skill:install --force
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Supported agents: `universal` (default, shared by Cursor/Cline/Codex/Gemini
|
|
188
|
+
CLI/GitHub Copilot/OpenCode), `pi`, `claude-code`, `cursor`, `codex`,
|
|
189
|
+
`gemini-cli`, `windsurf`, `continue`.
|
|
190
|
+
|
|
191
|
+
`4ge init` also offers to install the skill on completion (prompt in pretty
|
|
192
|
+
mode, or `--skill` flag for automation).
|
|
193
|
+
|
|
194
|
+
### `.4ge/` Directory Structure
|
|
195
|
+
```
|
|
196
|
+
.4ge/
|
|
197
|
+
├── config.yaml # Project configuration (committed to git)
|
|
198
|
+
├── credentials.json # Local credential override (gitignored)
|
|
199
|
+
└── .env # Environment overrides (gitignored)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### `.4ge/config.yaml` Reference
|
|
203
|
+
The primary configuration file for project-specific behavior.
|
|
204
|
+
|
|
205
|
+
```yaml
|
|
206
|
+
project_id: "00000000-0000-0000-0000-000000000000"
|
|
207
|
+
workspace_id: "11111111-1111-1111-1111-111111111111"
|
|
208
|
+
project_name: "My Awesome Project"
|
|
209
|
+
workspace_name: "Personal Workspace"
|
|
210
|
+
hierarchy:
|
|
211
|
+
default_roadmap_filter: "now" # now | next | later | all
|
|
212
|
+
recursive_pull: true
|
|
213
|
+
pull:
|
|
214
|
+
generate_stubs: false
|
|
215
|
+
include_brief_deps: false
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## JSON Mode (for AI Agents & Automation)
|
|
219
|
+
|
|
220
|
+
### Overview
|
|
221
|
+
Use the `--json` flag for deterministic, machine-readable output.
|
|
222
|
+
- Suppresses all interactive prompts (TUI/Ink).
|
|
223
|
+
- Outputs a standardized JSON envelope to `stdout`.
|
|
224
|
+
- Sends `X-Client-Type: 4ge-agent` header to the API.
|
|
225
|
+
|
|
226
|
+
### JSON Envelope Structure
|
|
227
|
+
Every successful command returns:
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"data": { ... },
|
|
231
|
+
"error": null,
|
|
232
|
+
"metadata": {
|
|
233
|
+
"timestamp": "2026-05-23T10:00:00.000Z"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Error Envelope
|
|
239
|
+
When a command fails in `--json` mode:
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"data": null,
|
|
243
|
+
"error": {
|
|
244
|
+
"message": "Not authenticated",
|
|
245
|
+
"code": "NO_CREDENTIALS"
|
|
246
|
+
},
|
|
247
|
+
"metadata": {
|
|
248
|
+
"timestamp": "2026-05-23T10:00:00.000Z"
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Error Codes
|
|
254
|
+
- `NO_CREDENTIALS` — No authentication found in any scope.
|
|
255
|
+
- `ALREADY_INITIALIZED` — Project already contains `.4ge/config.yaml`.
|
|
256
|
+
- `MISSING_REQUIRED_FLAGS` — Required flags (like `--workspace`) missing in `--json` mode.
|
|
257
|
+
- `INVALID_TOKEN` — Token validation against the API failed.
|
|
258
|
+
- `PROFILE_NOT_FOUND` — The specified named profile does not exist.
|
|
259
|
+
|
|
260
|
+
## Environment Variables
|
|
261
|
+
|
|
262
|
+
| Variable | Description |
|
|
263
|
+
|----------|-------------|
|
|
264
|
+
| `4GE_API_KEY` | API key for headless auth (highest priority). |
|
|
265
|
+
| `4GE_API_URL` | Override base API URL (default: `http://localhost:3000`). |
|
|
266
|
+
|
|
267
|
+
## Security
|
|
268
|
+
|
|
269
|
+
### Credential Storage
|
|
270
|
+
- **Global credentials**: `~/.4ge/credentials.json` (saved with mode `0o600`).
|
|
271
|
+
- **Local credentials**: `./.4ge/credentials.json` (saved with mode `0o600`).
|
|
272
|
+
- **Config directories**: Config directories are created with mode `0o700`.
|
|
273
|
+
- **Git Safety**: `4ge init` automatically adds `.4ge/credentials.json` and `.4ge/.env` to your `.gitignore`.
|
|
274
|
+
|
|
275
|
+
### Best Practices
|
|
276
|
+
- Use `4GE_API_KEY` environment variables for CI/CD environments.
|
|
277
|
+
- Use named profiles for switching between different 4ge workspaces/accounts.
|
|
278
|
+
- Use `--local` for project-specific credentials if you are collaborating on a shared machine.
|
|
279
|
+
- **Never commit `credentials.json` or `.env` to version control.**
|
|
280
|
+
|
|
281
|
+
## Command Reference
|
|
282
|
+
|
|
283
|
+
All commands support `--json` (machine output), `--dry-run` (mutations),
|
|
284
|
+
`--retry <n>` (transient failures). Pull commands support `--recursive`,
|
|
285
|
+
`--roadmap`, `--status`, `--save`, `--stdout`. Run `<command> --help` for
|
|
286
|
+
full flag details.
|
|
287
|
+
|
|
288
|
+
| Namespace | Commands |
|
|
289
|
+
|-----------|----------|
|
|
290
|
+
| `init` | Initialize a project (offers agent skill install) |
|
|
291
|
+
| `whoami` / `auth:status` | Current auth status |
|
|
292
|
+
| `auth:login` / `auth:logout` | Authenticate / clear credentials |
|
|
293
|
+
| `auth:profile:list` / `:use` / `:delete` | Manage named profiles |
|
|
294
|
+
| `project` | `create` `info` `list` `pull` `update` |
|
|
295
|
+
| `epic` | `list` `show` `pull` `update` |
|
|
296
|
+
| `story` | `list` `show` `pull` `update` |
|
|
297
|
+
| `feature` | `list` `show` `pull` `update` |
|
|
298
|
+
| `idea` | `create` `graduate` `list` `show` `update` |
|
|
299
|
+
| `plan` | `pull` `versions` |
|
|
300
|
+
| `template` | `create` `delete` `info` `list` `pull` `update` |
|
|
301
|
+
| `template:feature` | `create` `delete` `list` `update` |
|
|
302
|
+
| `config` | `set` `get` `show` `manage` |
|
|
303
|
+
| `skill` | `install` — install the agent skill for an AI harness |
|
|
304
|
+
|
|
305
|
+
> `flow:*` commands are planned (not yet shipped).
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
## Troubleshooting
|
|
309
|
+
|
|
310
|
+
### "Not authenticated" error
|
|
311
|
+
**Solution**: Run `4ge auth:login --token <api_key>` or set the `4GE_API_KEY` environment variable.
|
|
312
|
+
|
|
313
|
+
### "Already initialized" error
|
|
314
|
+
**Solution**: Edit `.4ge/config.yaml` directly if you need to change settings, or delete it and re-run `4ge init`.
|
|
315
|
+
|
|
316
|
+
### "Module not found" warnings in dev mode
|
|
317
|
+
**Explanation**: When running in `pnpm dev` mode, oclif v4 may emit `SINGLE_COMMAND_CLI` or loader warnings. These are harmless and do not affect functionality.
|
|
318
|
+
|
|
319
|
+
### Token validation fails but credentials are saved
|
|
320
|
+
**Explanation**: The CLI attempts to validate tokens against the API during login. If the API is unreachable (e.g., local dev server is down), credentials are still saved as a graceful fallback. Check your `4GE_API_URL` and network connection.
|