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

Commit e8ba8ae

Browse files
christseclaude
andcommitted
Address PR review feedback
- Fix track.ts file filtering: use `filename !== '.realm.json'` instead of `!filename.startsWith('.realm.json')` - Add Windows compatibility check in stop.ts with helpful message - Improve stop.ts process matching to handle both dev (tsx) and installed (boxel, node) modes - Add BOXEL_PASSWORD env var support in profile.ts for secure non-interactive usage - Fix touch.ts missing sync() method implementation - Add profile manager integration to check.ts, create.ts, list.ts, skills.ts, status.ts (was using old env var approach) - Update docs to use `npx boxel` as default command pattern - Add security notes about avoiding `-p` flag for passwords in shell history - Add Claude Code note at top of README with link to claude.ai/code - Streamline installation section in README Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6557f6d commit e8ba8ae

12 files changed

Lines changed: 589 additions & 132 deletions

File tree

.claude/CLAUDE.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@
88

99
## How to Run Boxel Commands
1010

11-
**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`:
1212

1313
```bash
14-
npm run dev -- <command> [args]
14+
npx boxel sync .
15+
npx boxel history ./workspace
16+
npx boxel profile add
1517
```
1618

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

24-
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.
2527

2628
---
2729

@@ -53,45 +55,44 @@ When you detect a new user (no profile configured), guide them through setup:
5355

5456
### Step 1: Check Profile
5557
```bash
56-
npm run dev -- profile
58+
npx boxel profile
5759
```
5860

5961
If no profile exists, run the interactive setup:
6062

6163
### Step 2: Add a Profile
6264
```bash
63-
npm run dev -- profile add
65+
npx boxel profile add
6466
```
6567

6668
This launches an interactive wizard that:
6769
1. Asks for environment (Production or Staging)
6870
2. Asks for username and password
6971
3. Creates the profile in `~/.boxel-cli/profiles.json`
7072

71-
**Non-interactive option:**
73+
**Non-interactive option (CI/automation only):**
7274
```bash
73-
# Production
74-
npm run dev -- profile add -u @username:boxel.ai -p "password" -n "My Prod Account"
75-
76-
# Staging
77-
npm run dev -- profile add -u @username:stack.cards -p "password" -n "My Staging Account"
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"
7877
```
7978

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.
80+
8081
### Step 3: Verify & List Workspaces
8182
```bash
82-
npm run dev -- list
83+
npx boxel list
8384
```
8485

8586
### Step 4: First Sync
8687
Help them sync their first workspace:
8788
```bash
88-
npm run dev -- sync @username/workspace ./workspace-name
89+
npx boxel sync @username/workspace ./workspace-name
8990
```
9091

9192
### Switching Between Profiles
9293
```bash
93-
npm run dev -- profile list # See all profiles (★ = active)
94-
npm run dev -- profile switch username # Switch by partial match
94+
npx boxel profile list # See all profiles (★ = active)
95+
npx boxel profile switch username # Switch by partial match
9596
```
9697

9798
---
@@ -203,8 +204,8 @@ boxel skills --export ./project # Export as Claude commands
203204
```bash
204205
boxel profile # Show current active profile
205206
boxel profile list # List all saved profiles (★ = active)
206-
boxel profile add # Interactive wizard to add profile
207-
boxel profile add -u @user:boxel.ai -p pass -n "Name" # Non-interactive
207+
boxel profile add # Interactive wizard to add profile (recommended)
208+
# Non-interactive: use BOXEL_PASSWORD env var instead of -p flag for security
208209
boxel profile switch <username> # Switch profile (partial match OK)
209210
boxel profile remove <profile-id> # Remove a profile
210211
boxel profile migrate # Migrate from old .env file

.claude/commands/setup.md

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,91 @@ Guide new users through Boxel CLI setup.
55
## Trigger
66
Run this automatically when:
77
- User first opens the repo
8-
- No `.env` file exists
8+
- No profile is configured (`npx boxel profile` shows nothing)
99
- User asks about setup or getting started
1010

1111
## Flow
1212

1313
### 1. Check Current State
1414
```bash
15-
cat .env 2>/dev/null || echo "NOT_CONFIGURED"
16-
npm list 2>/dev/null || echo "NOT_INSTALLED"
15+
npx boxel profile
1716
```
1817

19-
### 2. Ask Environment Choice
20-
Present options:
18+
If no profile exists, proceed with setup.
2119

22-
**Production (app.boxel.ai)**
23-
- For live Boxel usage
24-
- Your real workspaces
20+
### 2. Add a Profile
2521

26-
**Staging (realms-staging.stack.cards)**
27-
- For development/testing
28-
- Experimental features
22+
**Option A: Interactive (recommended)**
23+
```bash
24+
npx boxel profile add
25+
```
26+
27+
This wizard will:
28+
1. Ask for environment (Production or Staging)
29+
2. Ask for username and password
30+
3. Create the profile automatically
2931

30-
### 3. Collect Credentials
31-
Ask for:
32+
**Option B: Non-interactive (CI/automation)**
33+
34+
Ask the user for:
35+
- **Environment**: Production (app.boxel.ai) or Staging (realms-staging.stack.cards)
3236
- **Username**: Their Boxel handle (e.g., `aallen90`, `ctse`). Found in Account panel as `@username:stack.cards` or in workspace URLs like `app.boxel.ai/username/workspace-name`
3337
- **Password**: Same as Boxel web login
3438

35-
### 4. Create .env File
39+
Then run (using environment variable for security):
3640

3741
**Production:**
38-
```env
39-
MATRIX_URL=https://matrix.boxel.ai
40-
MATRIX_USERNAME=<username>
41-
MATRIX_PASSWORD=<password>
42-
REALM_SERVER_URL=https://app.boxel.ai/
42+
```bash
43+
BOXEL_PASSWORD="password" npx boxel profile add -u @username:boxel.ai -n "Production"
4344
```
4445

4546
**Staging:**
46-
```env
47-
MATRIX_URL=https://matrix-staging.stack.cards
48-
MATRIX_USERNAME=<username>
49-
MATRIX_PASSWORD=<password>
50-
REALM_SERVER_URL=https://realms-staging.stack.cards/
47+
```bash
48+
BOXEL_PASSWORD="password" npx boxel profile add -u @username:stack.cards -n "Staging"
5149
```
5250

53-
### 5. Install & Verify
51+
> **Security Note:** Avoid passing passwords via `-p` flag as they appear in shell history.
52+
53+
### 3. Verify
5454
```bash
55-
npm install
56-
npm run dev -- list
55+
npx boxel list
5756
```
5857

59-
### 6. First Sync
58+
### 4. First Sync
6059
Help them sync a workspace:
6160
```bash
62-
npm run dev -- sync @username/workspace
61+
npx boxel sync @username/workspace ./workspace-name
62+
```
63+
64+
## Profile Management
65+
66+
**List profiles:**
67+
```bash
68+
npx boxel profile list
69+
```
70+
71+
**Switch profile:**
72+
```bash
73+
npx boxel profile switch <username>
74+
```
75+
76+
**Migrate from old .env:**
77+
```bash
78+
npx boxel profile migrate
6379
```
6480

6581
## Success Message
6682
```
6783
Setup complete! You can now:
68-
- `boxel list` - See your workspaces
69-
- `boxel sync @username/workspace` - Sync a workspace
70-
- `boxel watch .` - Monitor for changes
71-
- `boxel history .` - View/restore checkpoints
84+
- `npx boxel list` - See your workspaces
85+
- `npx boxel sync @username/workspace` - Sync a workspace
86+
- `npx boxel watch .` - Monitor for changes
87+
- `npx boxel history .` - View/restore checkpoints
88+
89+
Profile management:
90+
- `npx boxel profile` - Show active profile
91+
- `npx boxel profile list` - List all profiles
92+
- `npx boxel profile switch <name>` - Switch profiles
7293
7394
For AI-assisted development, try:
7495
- `/watch` - Smart watch with auto intervals

README.md

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,50 @@
44

55
Edit Boxel cards locally with your IDE or AI agent, sync changes instantly, and collaborate seamlessly between web UI and local development.
66

7-
### Features
7+
> **Note:** Boxel CLI is developed and tested with [Claude Code](https://claude.ai/code). For the best experience, install Claude Code first and let it guide you through setup.
8+
9+
---
10+
11+
## Installation
12+
13+
```bash
14+
git clone https://github.com/cardstack/boxel-cli.git
15+
cd boxel-cli
16+
npm install && npm run build
17+
```
18+
19+
Now you can use `npx boxel` (or `boxel` after `npm link`):
20+
21+
```bash
22+
npx boxel profile add # Set up your account
23+
npx boxel list # List your workspaces
24+
npx boxel sync @user/workspace . # Sync a workspace locally
25+
```
26+
27+
### With Claude Code (Recommended)
28+
29+
If you have [Claude Code](https://docs.anthropic.com/en/docs/claude-code) installed, just start it in the repo:
30+
31+
```bash
32+
claude
33+
```
34+
35+
Claude will detect the Boxel CLI project and guide you through setup automatically.
36+
37+
### Global Command (Optional)
38+
39+
To use `boxel` directly without `npx`:
40+
41+
```bash
42+
npm link
43+
boxel profile add
44+
boxel list
45+
boxel sync .
46+
```
47+
48+
---
49+
50+
## Features
851

952
- **Bidirectional Sync** - Push local changes, pull remote updates, resolve conflicts
1053
- **Track Mode** - Auto-checkpoint local edits as you type in your IDE
@@ -108,33 +151,20 @@ flowchart TB
108151

109152
---
110153

111-
## Quick Start
112-
113-
```bash
114-
# Install
115-
git clone https://github.com/cardstack/boxel-cli.git
116-
cd boxel-cli && npm install
117-
118-
# Setup profile (interactive)
119-
npm run dev -- profile add
120-
121-
# List workspaces
122-
npm run dev -- list
123-
124-
# Sync a workspace
125-
npm run dev -- sync @username/workspace ./local-dir
126-
```
127-
128154
## Authentication
129155

130156
### Option 1: Profile Manager (Recommended)
131157
```bash
132-
boxel profile add # Interactive setup
133-
boxel profile add -u @user:boxel.ai -p "pass" -n "Prod" # Non-interactive
158+
boxel profile add # Interactive setup (recommended)
134159
boxel profile list # Show profiles (★ = active)
135160
boxel profile switch username # Switch profile
161+
162+
# Non-interactive (CI/automation only - avoid in shell history)
163+
BOXEL_PASSWORD="pass" boxel profile add -u @user:boxel.ai -n "Prod"
136164
```
137165

166+
> **Security Note:** Avoid passing passwords directly via `-p` flag as they may be exposed in shell history and process listings. Use the interactive wizard or environment variables for credentials.
167+
138168
Profiles stored in `~/.boxel-cli/profiles.json`
139169

140170
### Option 2: Environment Variables
@@ -486,7 +516,7 @@ npm test # Run tests
486516
npm run lint # Check code style
487517
```
488518

489-
> **Note:** Use `npm run dev -- <command>` during development. After global install, use `boxel <command>`.
519+
> **Note:** Use `npm run dev -- <command>` during development (no rebuild needed). After build, use `npx boxel` or `boxel` (after `npm link`).
490520
491521
### Claude Code Integration
492522

src/commands/check.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from 'path';
33
import * as crypto from 'crypto';
44
import { MatrixClient } from '../lib/matrix-client.js';
55
import { RealmAuthClient } from '../lib/realm-auth-client.js';
6+
import { getProfileManager, formatProfileBadge } from '../lib/profile-manager.js';
67

78
interface SyncManifest {
89
workspaceUrl: string;
@@ -18,15 +19,22 @@ export async function checkCommand(
1819
filePath: string,
1920
options: { sync?: boolean }
2021
): Promise<void> {
21-
const matrixUrl = process.env.MATRIX_URL;
22-
const matrixUsername = process.env.MATRIX_USERNAME;
23-
const matrixPassword = process.env.MATRIX_PASSWORD;
22+
// Get credentials from profile manager (falls back to env vars)
23+
const profileManager = getProfileManager();
24+
const credentials = await profileManager.getActiveCredentials();
2425

25-
if (!matrixUrl || !matrixUsername || !matrixPassword) {
26-
console.error('Missing Matrix credentials in environment variables');
26+
if (!credentials) {
27+
console.error('No credentials found. Run "boxel profile add" or set environment variables.');
2728
process.exit(1);
2829
}
2930

31+
const { matrixUrl, username: matrixUsername, password: matrixPassword, profileId } = credentials;
32+
33+
// Show active profile if using one
34+
if (profileId) {
35+
console.log(`${formatProfileBadge(profileId)}\n`);
36+
}
37+
3038
// Resolve the file path
3139
const absolutePath = path.resolve(filePath);
3240

src/commands/create.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { MatrixClient } from '../lib/matrix-client.js';
2+
import { getProfileManager, formatProfileBadge } from '../lib/profile-manager.js';
23

34
interface CreateOptions {
45
background?: string;
@@ -41,16 +42,23 @@ export async function createCommand(
4142
name: string,
4243
options: CreateOptions,
4344
): Promise<void> {
44-
const matrixUrl = process.env.MATRIX_URL;
45-
const username = process.env.MATRIX_USERNAME;
46-
const password = process.env.MATRIX_PASSWORD;
45+
// Get credentials from profile manager (falls back to env vars)
46+
const profileManager = getProfileManager();
47+
const credentials = await profileManager.getActiveCredentials();
4748

48-
if (!matrixUrl || !username || !password) {
49-
console.error('Missing Matrix credentials in environment variables');
49+
if (!credentials) {
50+
console.error('No credentials found. Run "boxel profile add" or set environment variables.');
5051
process.exit(1);
5152
}
5253

53-
let realmServerUrl = process.env.REALM_SERVER_URL;
54+
const { matrixUrl, username, password, realmServerUrl: baseRealmServerUrl, profileId } = credentials;
55+
56+
// Show active profile if using one
57+
if (profileId) {
58+
console.log(`${formatProfileBadge(profileId)}\n`);
59+
}
60+
61+
let realmServerUrl = baseRealmServerUrl;
5462
if (!realmServerUrl) {
5563
const matrixUrlObj = new URL(matrixUrl);
5664
if (matrixUrlObj.hostname.startsWith('matrix-')) {

0 commit comments

Comments
 (0)