@forloop-cc/forloop-cli 0.2.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,636 @@
1
+ # @forloop-cc/forloop-cli
2
+
3
+ Command-line interface for the [ForLoop](https://forloop.cc) AI development platform. Manage sprints, stories, files, AI agents, and organizations without leaving your terminal.
4
+
5
+ ## Table of Contents
6
+
7
+ - [What is ForLoop?](#what-is-forloop)
8
+ - [Installation](#installation)
9
+ - [Quick Start](#quick-start)
10
+ - [Authentication](#authentication)
11
+ - [Environments](#environments)
12
+ - [Commands](#commands)
13
+ - [Sprint Operations](#sprint-operations)
14
+ - [Story Operations](#story-operations)
15
+ - [Template Operations](#template-operations)
16
+ - [Agent Operations](#agent-operations)
17
+ - [Organization Operations](#organization-operations)
18
+ - [User & Quota Operations](#user--quota-operations)
19
+ - [File Operations](#file-operations)
20
+ - [Folder Operations](#folder-operations)
21
+ - [Sync Operations](#sync-operations)
22
+ - [Global Flags](#global-flags)
23
+ - [Environment Variables](#environment-variables)
24
+ - [Common Workflows](#common-workflows)
25
+ - [Start Working on a Sprint](#start-working-on-a-sprint)
26
+ - [Plan and Dispatch a Sprint](#plan-and-dispatch-a-sprint)
27
+ - [Sync Files Between Local and S3](#sync-files-between-local-and-s3)
28
+ - [CI/CD Automation](#cicd-automation)
29
+ - [Configuration](#configuration)
30
+ - [Troubleshooting](#troubleshooting)
31
+ - [License](#license)
32
+
33
+ ---
34
+
35
+ ## What is ForLoop?
36
+
37
+ [ForLoop](https://forloop.cc) is an AI agent platform for autonomous development and deployment. Think of it as your team's command center — a shared space where AI agents and humans collaborate on sprints, stories, and shipping code.
38
+
39
+ **With this CLI you can:**
40
+ - Plan sprints and create stories from your terminal
41
+ - Check what AI developer agents are building in real time
42
+ - Trigger AI agents to implement sprint stories automatically
43
+ - Upload and download project files to/from sprint storage
44
+ - Manage organizations, user profiles, and quotas
45
+ - Integrate ForLoop into shell scripts and CI/CD pipelines
46
+
47
+ ---
48
+
49
+ ## Installation
50
+
51
+ ### Prerequisites
52
+
53
+ - **Node.js** 18 or later
54
+ - **npm** (comes with Node.js)
55
+
56
+ ### Install Globally
57
+
58
+ ```bash
59
+ npm install -g @forloop-cc/forloop-cli
60
+ ```
61
+
62
+ ### Verify Installation
63
+
64
+ ```bash
65
+ forloop --version
66
+ # Output: forloop 0.2.0
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Quick Start
72
+
73
+ In about 30 seconds, you'll be connected:
74
+
75
+ ```bash
76
+ # 1. Create an API token at https://forloop.cc/profile?tab=api-tokens
77
+ # (copy the token — it starts with "floop_")
78
+
79
+ # 2. Authenticate
80
+ forloop auth login --api-key floop_xxxxx
81
+
82
+ # 3. See your sprints
83
+ forloop sprint list
84
+
85
+ # 4. Dive into a sprint
86
+ forloop sprint get --id 66
87
+
88
+ # 5. Check what your AI agents are doing
89
+ forloop agent developer-status --sprint 66
90
+ ```
91
+
92
+ That's it. You're connected.
93
+
94
+ ---
95
+
96
+ ## Authentication
97
+
98
+ ### Getting an API Token
99
+
100
+ Visit the ForLoop settings page to generate a token:
101
+
102
+ | Environment | URL |
103
+ |-------------|-----|
104
+ | Production | https://forloop.cc/profile?tab=api-tokens |
105
+ | Development | https://dev.forloop.cc/profile?tab=api-tokens |
106
+
107
+ Tokens start with `floop_`. Create a token with at least these scopes:
108
+ - `sprint:read`, `sprint:write`
109
+ - `story:read`, `story:write`
110
+ - `agent:query`, `agent:read`
111
+ - `profile:read`
112
+
113
+ ### Setting Your Token
114
+
115
+ **Method 1: Login command (recommended)**
116
+ ```bash
117
+ forloop auth login --api-key floop_xxxxx
118
+ ```
119
+ Your token is saved to `~/.config/forloop/tokens.json` with restricted file permissions (0600).
120
+
121
+ **Method 2: Environment variable**
122
+ ```bash
123
+ export FORLOOP_API_KEY=floop_xxxxx
124
+ ```
125
+
126
+ ### Managing Authentication
127
+
128
+ ```bash
129
+ forloop auth status # Check: "Token: floop_ab...xxxx, Format: valid"
130
+ forloop auth logout # Remove saved token
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Environments
136
+
137
+ ForLoop has two environments — **Production** and **Development**. By default, the CLI connects to production. Use the development environment when you want to test features or work on staging data without affecting production.
138
+
139
+ ### Production (default)
140
+
141
+ No extra setup needed. The CLI connects to `https://api.forloop.cc` automatically.
142
+
143
+ ```bash
144
+ forloop sprint list
145
+ ```
146
+
147
+ ### Development
148
+
149
+ The development environment connects to `https://api.dev.forloop.cc`. You need two things:
150
+
151
+ 1. **A dev API token** — create one at https://dev.forloop.cc/profile?tab=api-tokens
152
+ 2. **Environment variables** — the CLI requires explicit opt-in for security:
153
+
154
+ ```bash
155
+ export FORLOOP_ENV=development
156
+ export FORLOOP_ALLOW_DEV=true
157
+ forloop auth login --api-key floop_xxxxx
158
+ ```
159
+
160
+ > **Security note:** `FORLOOP_ALLOW_DEV=true` is required because dev API tokens have fewer restrictions. This flag prevents accidentally using a dev token against production data. Set it only when you intend to use the dev environment.
161
+
162
+ ### One-Liner for Dev
163
+
164
+ ```bash
165
+ FORLOOP_ENV=development FORLOOP_ALLOW_DEV=true forloop sprint list
166
+ ```
167
+
168
+ ### Persistent Dev Setup
169
+
170
+ To always use dev for a specific project, add an `opencode.json` in your project root:
171
+
172
+ ```json
173
+ {
174
+ "forloop": {
175
+ "apiUrl": "https://api.dev.forloop.cc",
176
+ "allowDev": true
177
+ }
178
+ }
179
+ ```
180
+
181
+ Or set it globally in `~/.config/opencode/config.json`:
182
+
183
+ ```json
184
+ {
185
+ "forloop": {
186
+ "apiUrl": "https://api.dev.forloop.cc",
187
+ "allowDev": true
188
+ }
189
+ }
190
+ ```
191
+
192
+ | Question | Answer |
193
+ |----------|--------|
194
+ | What happens if I don't set `FORLOOP_ALLOW_DEV=true`? | The CLI will ignore your dev URL and connect to production instead, with a warning message |
195
+ | Can I switch between prod and dev per-command? | Yes, the `--api-url` flag or `FORLOOP_ENV` env var overrides the config |
196
+ | Do I need separate tokens for prod and dev? | Yes — create one token at each environment's settings page |
197
+
198
+ ---
199
+
200
+ ## Commands
201
+
202
+ ### Sprint Operations
203
+
204
+ Work with sprints — the containers that hold your stories and track development cycles.
205
+
206
+ ```bash
207
+ # List all sprints you have access to
208
+ forloop sprint list
209
+ forloop sprint list --org-id 1
210
+
211
+ # Get sprint details, including all stories
212
+ forloop sprint get --id 66
213
+ forloop sprint get --id 66 --no-stories # Exclude stories
214
+ forloop sprint get --id 66 --no-files # Exclude files
215
+
216
+ # Create a new sprint
217
+ forloop sprint create \
218
+ --title "Sprint 15" \
219
+ --start-date 2026-06-09 \
220
+ --end-date 2026-06-23 \
221
+ --description "Auth system implementation" \
222
+ --org-id 1
223
+
224
+ # Update sprint details
225
+ forloop sprint update --id 66 --title "Updated Title"
226
+ forloop sprint update --id 66 --description "New goals for this sprint"
227
+
228
+ # Delete a sprint (destructive — requires --confirm)
229
+ forloop sprint delete --id 66 --confirm
230
+ ```
231
+
232
+ > **Tip:** The CLI auto-detects your sprint from `FORLOOP_SPRINT_ID` env var or a git branch named `sprint-66`. You can often omit `--id` and the right sprint will be chosen.
233
+
234
+ ### Story Operations
235
+
236
+ Stories are the work items inside sprints. Create them from templates for consistent structure.
237
+
238
+ ```bash
239
+ # Create a task story (code, features, bug fixes)
240
+ forloop story create \
241
+ --title "Implement user authentication" \
242
+ --sprint 66 \
243
+ --type basic-task \
244
+ --priority high \
245
+ --points 5 \
246
+ --assignee-agent forLoopDeveloper
247
+
248
+ # Create a note story (docs, research, planning)
249
+ forloop story create \
250
+ --title "Architecture decisions" \
251
+ --sprint 66 \
252
+ --type basic-note
253
+
254
+ # Create a doc folder for organizing files (no --type needed)
255
+ forloop story create \
256
+ --title "Project Documents" \
257
+ --sprint 66
258
+
259
+ # Read story details, including developer comments
260
+ forloop story get --id 229
261
+ forloop story get --id 229 --no-comments
262
+
263
+ # Update a story
264
+ forloop story update --id 229 --status in_progress
265
+ forloop story update --id 229 --priority critical --points 8
266
+
267
+ # Delete a story (requires --confirm)
268
+ forloop story delete --id 229 --confirm
269
+ ```
270
+
271
+ > **Story types explained:** `basic-task` is for implementation work — AI agents pick these up. `basic-note` is for documentation and notes. Doc folders are containers for uploaded files.
272
+
273
+ ### Template Operations
274
+
275
+ Templates define the structure of your stories. List available templates to see what story types are available.
276
+
277
+ ```bash
278
+ forloop template list
279
+ # Output shows: Basic Task, Basic Note, Schedule Meeting, New Folder
280
+ ```
281
+
282
+ ### Agent Operations
283
+
284
+ Interact with ForLoop's AI agents — check their progress, trigger new work, and review past conversations.
285
+
286
+ ```bash
287
+ # See what AI agents have discussed in the past
288
+ forloop agent history --sprint 66 --limit 20
289
+
290
+ # Check if a developer task is running, completed, or failed
291
+ forloop agent developer-status --sprint 66
292
+ # Output: "Developer Task: SUCCEEDED — Progress: 21/22 done"
293
+
294
+ # Trigger the developer agent to start implementing stories
295
+ forloop agent developer-sprint --sprint 66
296
+ forloop agent developer-sprint --sprint 66 \
297
+ --message "Start with the high-priority auth module stories"
298
+ ```
299
+
300
+ > **What happens when you trigger a developer sprint?** The ForLoop server launches an AI agent that picks up your `todo` stories, writes code, creates commits, and opens pull requests — all automatically. You get notified by email when it's done.
301
+
302
+ ### Organization Operations
303
+
304
+ Organizations group sprints and control access for teams.
305
+
306
+ ```bash
307
+ # List organizations you belong to
308
+ forloop org list
309
+ forloop org list --owned-only # Only orgs you own
310
+
311
+ # View organization details
312
+ forloop org get --id 1
313
+
314
+ # Create an organization (requires Team or Enterprise tier)
315
+ forloop org create \
316
+ --name "Engineering Team" \
317
+ --description "Core engineering organization"
318
+
319
+ # Update organization details
320
+ forloop org update --id 1 --name "New Name"
321
+ ```
322
+
323
+ ### User & Quota Operations
324
+
325
+ Check your profile, limits, and usage.
326
+
327
+ ```bash
328
+ # View your profile
329
+ forloop user profile
330
+ # Output: User: TOSHI WORKSHOP JP, Email: ..., Tier: free
331
+
332
+ # Check your quota limits and current usage
333
+ forloop user quotas
334
+ # Output: Stories used: 23/100, Storage used: 17KB/3GB, etc.
335
+
336
+ # Check quota usage for a specific organization
337
+ forloop org quotas --org-id 1
338
+ ```
339
+
340
+ ### File Operations
341
+
342
+ Upload files to sprint storage, list them, and generate download links. Files are stored on S3.
343
+
344
+ ```bash
345
+ # Upload a file to a sprint
346
+ forloop file upload --path ./report.pdf --sprint 66
347
+ forloop file upload --path ./mockup.png --sprint 66 --folder designs
348
+
349
+ # List all files in a sprint
350
+ forloop file list --sprint 66
351
+
352
+ # Generate a download link
353
+ forloop file download --id 84
354
+
355
+ # Delete a file permanently (requires --confirm)
356
+ forloop file delete --id 84 --confirm
357
+ ```
358
+
359
+ ### Folder Operations
360
+
361
+ Create document folders to organize your sprint files.
362
+
363
+ ```bash
364
+ # Create a folder with team-level access
365
+ forloop folder create \
366
+ --title "Design Documents" \
367
+ --sprint 66 \
368
+ --description "UI mockups and wireframes" \
369
+ --permissions team
370
+ ```
371
+
372
+ ### Sync Operations
373
+
374
+ Synchronize files between your local machine (`~/.forloop/sprint-{id}/`) and the sprint's S3 storage. Useful for persisting plan documents, task breakdowns, and knowledge files across opencode sessions.
375
+
376
+ ```bash
377
+ # Step 1: Ensure the sync folder exists on the server
378
+ forloop sync aivy-folder --sprint 66
379
+
380
+ # Step 2: Get the folder's story ID (needed for uploads)
381
+ forloop sync aivy-doc-get --sprint 66
382
+
383
+ # Step 3: Download sprint files from S3 to your local machine
384
+ forloop sync s3-to-local --sprint 66
385
+ forloop sync s3-to-local --sprint 66 --no-tasks --overwrite
386
+
387
+ # Step 4: Upload a local file back to S3
388
+ forloop sync local-to-s3 \
389
+ --path ~/.forloop/sprint-66/plan/my-plan.md \
390
+ --sprint 66 \
391
+ --folder project/plans
392
+ ```
393
+
394
+ > **Local file structure:** `~/.forloop/sprint-{id}/knowledge/`, `~/.forloop/sprint-{id}/plan/`, `~/.forloop/sprint-{id}/task/`. The sync commands map these folders to S3 paths automatically.
395
+
396
+ ---
397
+
398
+ ## Global Flags
399
+
400
+ These flags work with every command:
401
+
402
+ | Flag | Description |
403
+ |------|-------------|
404
+ | `--api-key <key>` | Override the saved API token for this command |
405
+ | `--api-url <url>` | Override the API base URL |
406
+ | `--output <format>` | Output format: `text` (default) or `json` |
407
+ | `--timeout <seconds>` | Request timeout in seconds (default: 60) |
408
+ | `--quiet` | Suppress non-essential output — useful in scripts |
409
+ | `--verbose` | Print HTTP request/response details — useful for debugging |
410
+ | `--no-color` | Disable ANSI colors in output |
411
+ | `--non-interactive` | Disable interactive prompts — useful in CI |
412
+ | `--help` | Show help for any command |
413
+ | `--version` | Print the CLI version |
414
+
415
+ ---
416
+
417
+ ## Environment Variables
418
+
419
+ | Variable | Purpose |
420
+ |----------|---------|
421
+ | `FORLOOP_API_KEY` | API token (alternative to `forloop auth login`) |
422
+ | `FORLOOP_API_URL` | Override the API base URL |
423
+ | `FORLOOP_ENV` | Set to `production` or `development` |
424
+ | `FORLOOP_ALLOW_DEV` | Set to `true` to enable dev environment URLs |
425
+ | `FORLOOP_SPRINT_ID` | Default sprint ID for commands that auto-detect it |
426
+
427
+ ---
428
+
429
+ ## Common Workflows
430
+
431
+ ### Start Working on a Sprint
432
+
433
+ A typical session start — load context, check progress, and understand what's happening.
434
+
435
+ ```bash
436
+ # 1. Make sure you're authenticated
437
+ forloop auth status
438
+
439
+ # 2. Find your sprint
440
+ forloop sprint list
441
+
442
+ # 3. Load the full picture — stories, status, AI agents
443
+ forloop sprint get --id 66
444
+
445
+ # 4. Is the developer agent already running?
446
+ forloop agent developer-status --sprint 66
447
+
448
+ # 5. Review recent AI conversations for context
449
+ forloop agent history --sprint 66 --limit 10
450
+
451
+ # 6. Sync files from S3 so you have the latest plans
452
+ forloop sync s3-to-local --sprint 66
453
+ ```
454
+
455
+ ### Plan and Dispatch a Sprint
456
+
457
+ Create a sprint, add stories, and let AI agents implement them.
458
+
459
+ ```bash
460
+ # 1. Create the sprint
461
+ forloop sprint create \
462
+ --title "Feature X" \
463
+ --start-date 2026-06-09 \
464
+ --end-date 2026-06-23
465
+
466
+ # 2. Break the work into stories
467
+ forloop story create \
468
+ --title "Set up project structure" \
469
+ --sprint 67 --type basic-task --priority high --points 2
470
+ forloop story create \
471
+ --title "Build API endpoints" \
472
+ --sprint 67 --type basic-task --priority high --points 5 --assignee-agent forLoopDeveloper
473
+ forloop story create \
474
+ --title "Create UI components" \
475
+ --sprint 67 --type basic-task --priority medium --points 3 --assignee-agent forLoopDeveloper
476
+
477
+ # 3. Upload any planning documents
478
+ forloop sync aivy-folder --sprint 67
479
+ forloop sync local-to-s3 \
480
+ --path ~/.forloop/sprint-67/plan/plan.md \
481
+ --sprint 67 --folder project/plans
482
+
483
+ # 4. Dispatch the developer agent
484
+ forloop agent developer-sprint --sprint 67
485
+
486
+ # 5. Monitor progress
487
+ forloop agent developer-status --sprint 67
488
+ forloop sprint get --id 67
489
+ ```
490
+
491
+ ### Sync Files Between Local and S3
492
+
493
+ Keep your local planning files in sync with the sprint's S3 storage.
494
+
495
+ ```bash
496
+ # Download everything from S3
497
+ forloop sync s3-to-local --sprint 66
498
+
499
+ # Files are now at ~/.forloop/sprint-66/knowledge/
500
+ # ~/.forloop/sprint-66/plan/
501
+ # ~/.forloop/sprint-66/task/
502
+
503
+ # Edit a plan file locally
504
+ vim ~/.forloop/sprint-66/plan/my-plan.md
505
+
506
+ # Upload it back to S3
507
+ forloop sync local-to-s3 \
508
+ --path ~/.forloop/sprint-66/plan/my-plan.md \
509
+ --sprint 66 --folder project/plans
510
+
511
+ # Verify it's on the server
512
+ forloop file list --sprint 66
513
+ ```
514
+
515
+ ### CI/CD Automation
516
+
517
+ Use the CLI in shell scripts to automate sprint management.
518
+
519
+ ```bash
520
+ #!/bin/bash
521
+ set -e
522
+
523
+ # Authenticate via environment variable
524
+ export FORLOOP_API_KEY="$FORLOOP_TOKEN"
525
+
526
+ # Check if a developer task is already running
527
+ STATUS=$(forloop agent developer-status --sprint "$SPRINT_ID")
528
+ echo "$STATUS"
529
+
530
+ # Trigger a new developer sprint if none is active
531
+ if echo "$STATUS" | grep -q "No active"; then
532
+ forloop agent developer-sprint \
533
+ --sprint "$SPRINT_ID" \
534
+ --message "CI-triggered implementation"
535
+ fi
536
+
537
+ # Wait for completion (poll every 60 seconds)
538
+ while forloop agent developer-status --sprint "$SPRINT_ID" | grep -q "RUNNING"; do
539
+ echo "Still running..."
540
+ sleep 60
541
+ done
542
+
543
+ echo "Sprint $SPRINT_ID completed."
544
+ ```
545
+
546
+ ---
547
+
548
+ ## Configuration
549
+
550
+ The CLI resolves configuration from these sources, in priority order:
551
+
552
+ ```
553
+ 1. Environment variables (highest priority)
554
+ 2. Project config (./opencode.json under "forloop" key)
555
+ 3. Global config (~/.config/opencode/config.json)
556
+ 4. Defaults (production API)
557
+ ```
558
+
559
+ ### Project Config (`./opencode.json`)
560
+
561
+ ```json
562
+ {
563
+ "forloop": {
564
+ "apiUrl": "https://api.dev.forloop.cc",
565
+ "allowDev": true
566
+ }
567
+ }
568
+ ```
569
+
570
+ ### Global Config (`~/.config/opencode/config.json`)
571
+
572
+ ```json
573
+ {
574
+ "forloop": {
575
+ "apiUrl": "https://api.forloop.cc",
576
+ "allowDev": false
577
+ }
578
+ }
579
+ ```
580
+
581
+ ### Token Storage
582
+
583
+ API tokens are stored at `~/.config/forloop/tokens.json` with restricted permissions (`chmod 600`). The file is ForLoop-specific and not shared with other tools.
584
+
585
+ ---
586
+
587
+ ## Troubleshooting
588
+
589
+ ### "No ForLoop API key configured"
590
+
591
+ You need to authenticate:
592
+
593
+ ```bash
594
+ forloop auth login --api-key floop_xxxxx
595
+ # or
596
+ export FORLOOP_API_KEY=floop_xxxxx
597
+ ```
598
+
599
+ ### "Invalid token format"
600
+
601
+ Tokens must start with `floop_`. Double-check you copied the entire token from https://forloop.cc/profile?tab=api-tokens.
602
+
603
+ ### "Dev API URL ignored"
604
+
605
+ The CLI refuses dev URLs unless you explicitly opt in:
606
+
607
+ ```bash
608
+ export FORLOOP_ALLOW_DEV=true
609
+ export FORLOOP_ENV=development
610
+ ```
611
+
612
+ This is a security measure — dev tokens should never accidentally hit production APIs.
613
+
614
+ ### "Forbidden" or "Not Found" on Specific Resources
615
+
616
+ Some resources (organizations, stories, files) return 403/404 when you don't have access or they don't exist in your current environment. Try:
617
+ - Checking you're in the right environment (prod vs dev)
618
+ - Verifying the resource ID exists with `forloop sprint get --id <id>`
619
+ - Checking that your token has the required scopes
620
+
621
+ ### Verbose Debugging
622
+
623
+ When something isn't working, use `--verbose` to see the raw HTTP requests:
624
+
625
+ ```bash
626
+ forloop sprint get --id 66 --verbose
627
+ # Output:
628
+ # > GET https://api.forloop.cc/api/opencode/sprints/66
629
+ # < 200 OK
630
+ ```
631
+
632
+ ---
633
+
634
+ ## License
635
+
636
+ MIT