Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

Commit f80821c

Browse files
authored
Merge pull request #3 from cardstack/feature/track-stop-symbols
Add track/stop commands and consistent local/remote symbols
2 parents 83d0f09 + bd52705 commit f80821c

18 files changed

Lines changed: 1751 additions & 312 deletions

.claude/CLAUDE.md

Lines changed: 168 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
# Boxel CLI - Claude Code Integration
22

3+
## GitHub Repository
4+
5+
**Official repo:** https://github.com/cardstack/boxel-cli
6+
7+
---
8+
39
## How to Run Boxel Commands
410

5-
**IMPORTANT:** In this development repo, the `boxel` CLI is not globally installed. Always run commands using:
11+
After `npm install && npm run build`, use `npx boxel`:
612

713
```bash
8-
npm run dev -- <command> [args]
14+
npx boxel sync .
15+
npx boxel history ./workspace
16+
npx boxel profile add
917
```
1018

11-
Examples:
19+
Or use `boxel` directly after `npm link`.
20+
21+
**For development** (no rebuild needed after code changes):
1222
```bash
13-
npm run dev -- sync . # NOT: boxel sync .
14-
npm run dev -- history ./workspace # NOT: boxel history ./workspace
15-
npm run dev -- milestone ./workspace 1 -n "Name"
23+
npm run dev -- <command>
1624
```
1725

18-
The `--` separates npm arguments from the CLI arguments. All documentation below shows `boxel <command>` for brevity, but always use `npm run dev -- <command>` when executing.
26+
All documentation below shows `boxel <command>` for brevity.
1927

2028
---
2129

@@ -43,67 +51,60 @@ The skill contains comprehensive Boxel development guidance including CardDef/Fi
4351

4452
## Onboarding Flow
4553

46-
When you detect a new user (no `.env` file or first interaction), guide them through setup:
54+
When you detect a new user (no profile configured), guide them through setup:
4755

48-
### Step 1: Check Environment
56+
### Step 1: Check Profile
4957
```bash
50-
# Check if .env exists and has content
51-
cat .env 2>/dev/null || echo "NOT_CONFIGURED"
58+
npx boxel profile
5259
```
5360

54-
### Step 2: Prompt for Environment Choice
55-
If not configured, ask:
61+
If no profile exists, run the interactive setup:
5662

63+
### Step 2: Add a Profile
64+
```bash
65+
npx boxel profile add
5766
```
58-
Welcome to Boxel CLI! Let's get you set up.
59-
60-
Which environment do you want to use?
61-
62-
1. **Production** (app.boxel.ai) - Live Boxel
63-
2. **Staging** (realms-staging.stack.cards) - Development/testing
6467

65-
You'll need your Boxel username and password (same as web login).
68+
This launches an interactive wizard that:
69+
1. Asks for environment (Production or Staging)
70+
2. Asks for username and password
71+
3. Creates the profile in `~/.boxel-cli/profiles.json`
6672

67-
Your username is your Boxel handle (e.g., `aallen90`, `ctse`). Find it in:
68-
- **Account panel**: shown as `@username:stack.cards`
69-
- **Workspace URLs**: `app.boxel.ai/username/workspace-name`
73+
**Non-interactive option (CI/automation only):**
74+
```bash
75+
# Use environment variable to avoid exposing password in shell history
76+
BOXEL_PASSWORD="password" npx boxel profile add -u @username:boxel.ai -n "My Prod Account"
7077
```
7178

72-
### Step 3: Create .env
73-
Based on their choice:
74-
75-
**Production:**
76-
```env
77-
MATRIX_URL=https://matrix.boxel.ai
78-
MATRIX_USERNAME=<ask for username>
79-
MATRIX_PASSWORD=<ask for password>
80-
REALM_SERVER_URL=https://app.boxel.ai/
81-
```
79+
> **Security Note:** Avoid passing passwords via `-p` flag as they appear in shell history and process listings. Use the interactive wizard or `BOXEL_PASSWORD` environment variable.
8280
83-
**Staging:**
84-
```env
85-
MATRIX_URL=https://matrix-staging.stack.cards
86-
MATRIX_USERNAME=<ask for username>
87-
MATRIX_PASSWORD=<ask for password>
88-
REALM_SERVER_URL=https://realms-staging.stack.cards/
81+
### Step 3: Verify & List Workspaces
82+
```bash
83+
npx boxel list
8984
```
9085

91-
### Step 4: Verify & List Workspaces
86+
### Step 4: First Sync
87+
Help them sync their first workspace:
9288
```bash
93-
npm install
94-
npm run dev -- list
89+
npx boxel sync @username/workspace ./workspace-name
9590
```
9691

97-
### Step 5: First Sync
98-
Help them sync their first workspace:
92+
### Switching Between Profiles
9993
```bash
100-
npm run dev -- sync @username/workspace ./workspace-name
94+
npx boxel profile list # See all profiles (★ = active)
95+
npx boxel profile switch username # Switch by partial match
10196
```
10297

10398
---
10499

105100
## Available Skills
106101

102+
### `/track` - Track Local Edits
103+
Starts `boxel track` to auto-checkpoint local file changes:
104+
- Creates checkpoints as you save files in IDE
105+
- **IMPORTANT:** Track creates LOCAL checkpoints only
106+
- **After editing, run `boxel sync . --prefer-local` to push to server**
107+
107108
### `/watch` - Smart Watch
108109
Starts `boxel watch` with intelligent interval based on context:
109110
- **Active development** (5s interval, 3s debounce): When editing files
@@ -119,7 +120,7 @@ Complete restore workflow:
119120

120121
### `/sync` - Smart Sync
121122
Context-aware bidirectional sync:
122-
- After local edits → `--prefer-local`
123+
- After local edits or track `--prefer-local`
123124
- After server changes → `--prefer-remote`
124125
- After restore → `--prefer-local` (essential for syncing deletions)
125126

@@ -145,7 +146,17 @@ boxel sync . --delete # Sync deletions both ways
145146
boxel sync . --dry-run # Preview only
146147
```
147148

148-
### Watch
149+
### Track ⇆ (Local File Watching)
150+
```bash
151+
boxel track . # Track local edits, auto-checkpoint as you save
152+
boxel track . -d 5 -i 30 # 5s debounce, 30s min between checkpoints
153+
boxel track . -q # Quiet mode
154+
```
155+
156+
**Use track when:** Editing locally in IDE/VS Code. Creates checkpoints as you save files.
157+
**Symbol:** ⇆ (horizontal arrows = local changes)
158+
159+
### Watch ⇅ (Remote Server Watching)
149160
```bash
150161
boxel watch # Watch all configured realms (from .boxel-workspaces.json)
151162
boxel watch . # Watch single workspace
@@ -154,6 +165,14 @@ boxel watch . -i 5 -d 3 # Active: 5s interval, 3s debounce
154165
boxel watch . -q # Quiet mode
155166
```
156167

168+
**Use watch when:** Others are editing in Boxel web UI. Pulls their changes and creates checkpoints.
169+
**Symbol:** ⇅ (vertical arrows = remote server changes)
170+
171+
### Stop
172+
```bash
173+
boxel stop # Stop all running watch (⇅) and track (⇆) processes
174+
```
175+
157176
**Multi-realm watching:** Useful when code lives in one realm and data in another. Each realm gets its own checkpoint tracking and debouncing.
158177

159178
### Realms (Multi-Realm Configuration)
@@ -175,6 +194,7 @@ boxel history . # View checkpoints
175194
boxel history . -r # Interactive restore
176195
boxel history . -r 3 # Quick restore to #3
177196
boxel history . -r abc123 # Restore by hash
197+
boxel history . -m "Message" # Create checkpoint with custom message
178198
```
179199

180200
### Skills
@@ -186,6 +206,23 @@ boxel skills --disable "Name" # Disable a skill
186206
boxel skills --export ./project # Export as Claude commands
187207
```
188208

209+
### Profile (Authentication)
210+
```bash
211+
boxel profile # Show current active profile
212+
boxel profile list # List all saved profiles (★ = active)
213+
boxel profile add # Interactive wizard to add profile (recommended)
214+
# Non-interactive: use BOXEL_PASSWORD env var instead of -p flag for security
215+
boxel profile switch <username> # Switch profile (partial match OK)
216+
boxel profile remove <profile-id> # Remove a profile
217+
boxel profile migrate # Migrate from old .env file
218+
```
219+
220+
**Profile IDs:** Use Matrix format `@username:domain`
221+
- Production: `@username:boxel.ai`
222+
- Staging: `@username:stack.cards`
223+
224+
**Storage:** Profiles stored in `~/.boxel-cli/profiles.json` (permissions: 0600)
225+
189226
### Other
190227
```bash
191228
boxel list # List workspaces
@@ -237,7 +274,19 @@ boxel skills --export . # Re-export to .claude/commands/
237274

238275
## Key Workflows
239276

240-
### Active Development Session
277+
### Local Development with Track (IDE/Agent Editing)
278+
```bash
279+
boxel track . # Start tracking local edits (auto-checkpoints)
280+
# ... edit files in IDE or with Claude ...
281+
# Track creates LOCAL checkpoints as you save
282+
283+
# IMPORTANT: When ready to push changes to Boxel server:
284+
boxel sync . --prefer-local # Push your local changes to server
285+
```
286+
287+
**Remember:** Track does NOT sync to server automatically - it only creates local checkpoints. Always run `sync --prefer-local` when you want your changes live on the server.
288+
289+
### Active Development Session (Watching Server)
241290
```bash
242291
/watch # Starts with 5s interval
243292
# ... edit in Boxel UI or locally ...
@@ -373,8 +422,8 @@ Watch waits for changes to settle:
373422
### 4. Checkpoint Classification
374423
- `[MAJOR]` - New files, deleted files, .gts changes, >3 files
375424
- `[minor]` - Small updates to existing .json files
376-
- `LOCAL` (↑) - Changes you pushed
377-
- `SERVER` (↓) - External changes from web UI
425+
- `LOCAL` - Changes from local edits (track command)
426+
- `SERVER` - External changes from web UI (watch command)
378427

379428
---
380429

@@ -403,6 +452,65 @@ Commands accept:
403452

404453
---
405454

455+
## Understanding Boxel URLs (Card IDs)
456+
457+
When a user shares a URL like:
458+
```
459+
https://app.boxel.ai/tribecaprep/employee-handbook/Document/d8341312-f3a0-442b-a2e5-49c5cdd84695
460+
```
461+
462+
**This is a Card ID, not a fetchable URL!**
463+
464+
### How to Parse Boxel URLs
465+
466+
| URL Part | Meaning |
467+
|----------|---------|
468+
| `app.boxel.ai` | Production server |
469+
| `tribecaprep` | User/organization |
470+
| `employee-handbook` | Realm/workspace name |
471+
| `Document/d8341312-...` | Card type and instance path |
472+
473+
### NEVER Use WebFetch on Boxel URLs
474+
475+
- Boxel realms are **usually private** and require Matrix authentication
476+
- WebFetch will fail with 401/403 errors
477+
- The user is referencing content **they expect you to have locally**
478+
479+
### Finding the Local Copy
480+
481+
If the user references a Boxel URL, the file is likely already synced to the local workspace:
482+
483+
1. **Parse the path**: `Document/d8341312-f3a0-442b-a2e5-49c5cdd84695` → local path is `Document/d8341312-f3a0-442b-a2e5-49c5cdd84695.json`
484+
485+
2. **Search the workspace**:
486+
```bash
487+
# Find by card ID
488+
find . -name "d8341312-f3a0-442b-a2e5-49c5cdd84695*"
489+
490+
# Or search for the card type folder
491+
ls ./Document/
492+
```
493+
494+
3. **Read the local file** using the Read tool
495+
496+
### Example Workflow
497+
498+
User says: "Check the handbook at https://app.boxel.ai/tribecaprep/employee-handbook/Document/abc123"
499+
500+
**Do this:**
501+
```
502+
# Look for local file
503+
Read ./Document/abc123.json
504+
```
505+
506+
**NOT this:**
507+
```
508+
# This will FAIL - private realm
509+
WebFetch https://app.boxel.ai/tribecaprep/employee-handbook/Document/abc123
510+
```
511+
512+
---
513+
406514
## API Reference
407515

408516
| Endpoint | Method | Purpose |
@@ -433,13 +541,15 @@ Headers:
433541
## Troubleshooting
434542

435543
### "Authentication failed"
436-
- Check credentials in `.env`
437-
- Verify you can log into Boxel web
438-
- For staging: use `matrix-staging.stack.cards`
544+
- Check active profile: `boxel profile`
545+
- Verify credentials: `boxel profile list`
546+
- Verify you can log into Boxel web with same credentials
547+
- For staging: ensure profile uses `@username:stack.cards`
439548

440549
### "No workspace found"
441550
- Run `boxel list` to see workspaces
442551
- Use full URL for first sync
552+
- Ensure correct profile is active for the environment
443553

444554
### Files keep reverting after restore
445555
- Stop watch before restoring
@@ -448,4 +558,8 @@ Headers:
448558
### Watch not detecting changes
449559
- Check interval setting
450560
- Verify server URL
451-
- Check JWT auth
561+
- Check active profile: `boxel profile`
562+
563+
### Switching environments (prod/staging)
564+
- Add profiles for each environment
565+
- Switch with: `boxel profile switch <username>`

0 commit comments

Comments
 (0)