CLI
Command-line interface for the platform, providing data ingestion and source reader workflows.
Structure
Section titled “Structure”apps/cli/├── index.ts # CLI entry point├── commands/ # Command definitions│ ├── personal.ts # Personal namespace│ ├── list/ # List commands│ │ ├── index.ts # List namespace│ │ ├── source.ts # Source management│ │ └── gmail.ts # Gmail ingestion workflow│ ├── worktree/ # Git worktree management│ │ ├── index.ts # Worktree namespace│ │ ├── create-worktree.ts│ │ ├── list-worktree.ts│ │ ├── remove-worktree.ts│ │ ├── pr/ # GitHub PR commands│ │ │ ├── index.ts│ │ │ ├── pr-list.ts│ │ │ ├── pr-create.ts│ │ │ ├── pr-checkout.ts│ │ │ ├── pr-status.ts│ │ │ └── pr-sync.ts│ │ └── lib/ # Worktree utilities│ │ ├── types.ts│ │ ├── git-worktree.ts│ │ ├── github-pr.ts│ │ ├── env-manager.ts│ │ ├── port-calculator.ts│ │ └── warp-launcher.ts│ ├── extract.ts # Extract data from sources│ └── select.ts # Interactive selection├── lib/ # Shared utilities├── tests/ # Integration tests└── data/ # Local data storageDependencies
Section titled “Dependencies”@abeauvois/platform-sdk- Platform SDK for API communication (Auth, Fetcher, ConfigProvider)@abeauvois/platform-domain- Domain entitiescleye- CLI framework@poppinss/cliui- Terminal UI
# From root directorybun run cli
# Development mode with watchbun run cli:dev
# Direct executionbun run apps/cli/index.ts <command>Commands
Section titled “Commands”# Direct Gmail read (synchronous, no workflow/task)bun run cli list source gmail --filter=user@example.com --limit-days=7 --with-url
# Gmail read with defaults (7 days, no URL filter)bun run cli list source gmail
# Trigger Gmail ingestion workflow (async, with analysis)bun run cli ingest gmail --filter=user@example.com --limit-days=7Gmail Commands
Section titled “Gmail Commands”Two ways to read Gmail:
| Command | Pattern | Use Case |
|---|---|---|
list source gmail | Direct (sync) | Quick reads, returns raw content immediately |
ingest gmail | Task-based (async) | Full workflow with analysis/enrichment steps |
Direct read flags:
--filter,-f- Filter by sender email address--limit-days,-l- Limit to emails from last N days (default: 7)--with-url,-u- Only include emails containing URLs
Worktree Commands
Section titled “Worktree Commands”Manage git worktrees for parallel development with automatic port offset configuration.
# Create a new worktree with port offset 100bun run cli worktree create feature-auth 100
# Create worktree without opening Warpbun run cli worktree create bugfix-login 200 --no-open
# Create worktree without running bun installbun run cli worktree create feature-x 300 --no-install
# List all worktreesbun run cli worktree list
# Remove a worktreebun run cli worktree remove feature-auth
# Remove worktree and delete the branchbun run cli worktree remove feature-auth --delete-branchPort offset scheme:
Each worktree uses offset ports to avoid conflicts with the main platform:
| Offset | API | Dashboard | Gamification API |
|---|---|---|---|
| 0 | 3000 | 5000 | 3001 |
| 100 | 3100 | 5100 | 3101 |
| 200 | 3200 | 5200 | 3201 |
Create command flags:
--open,-o- Open Warp terminal tabs after creation (default: true)--install,-i- Runbun installafter creation (default: true)
Remove command flags:
--delete-branch,-d- Also delete the git branch--force,-f- Force removal even with uncommitted changes (default: true)
Warp integration:
When creating a worktree, a Warp launch configuration is automatically generated. To start all dev servers:
- Press
CMD+CTRL+Lto open Launch Configurations in Warp - Search for
platform-<branch-name> - Press Enter to launch all services with correct port offsets
Worktree PR Commands
Section titled “Worktree PR Commands”Manage GitHub PRs for worktrees. Requires GitHub CLI (gh) to be installed and authenticated.
# List PRs with associated worktreesbun run cli worktree pr listbun run cli worktree pr list --all # All open PRs (for finding PRs to checkout)bun run cli worktree pr list --all --author @me # Your open PRs
# Create a PR from current worktree branchbun run cli worktree pr createbun run cli worktree pr create --title "Add feature" --body "Description" --draft
# Checkout an existing PR into a new worktreebun run cli worktree pr checkout 123 # PR #123 with default portsbun run cli worktree pr checkout 123 100 # PR #123 with port offset 100
# Show PR status for current branchbun run cli worktree pr statusbun run cli worktree pr status feature-branch --checks
# Sync worktree with base branchbun run cli worktree pr sync # Rebase by defaultbun run cli worktree pr sync --merge # Use merge insteadbun run cli worktree pr sync --push # Push after syncPR List flags:
--all- Show all open PRs (default shows only PRs with worktrees)--author,-a- Filter by author (use@mefor your PRs)--limit,-l- Maximum PRs to show (default: 50)
PR Create flags:
--title,-t- PR title (prompts if not provided)--body,-b- PR description--draft,-d- Create as draft PR--base- Base branch (default: main)
PR Checkout flags:
--open,-o- Open Warp terminal tabs (default: true)--install,-i- Runbun install(default: true)
PR Status flags:
--checks,-c- Show detailed CI check results
PR Sync flags:
--rebase,-r- Use rebase strategy (default)--merge,-m- Use merge strategy--push,-p- Push after successful sync--base,-b- Base branch to sync with (auto-detected from PR)
Configuration
Section titled “Configuration”The CLI fetches configuration from the API server at http://localhost:3000.
Override with environment variable:
PLATFORM_API_URL=http://localhost:4000 bun run cli list source gmailAuthentication
Section titled “Authentication”The CLI manages authentication automatically:
- Checks for existing session in
~/.platform-cli/session.json - If no session, prompts for email/password
- Authenticates with API server
- Stores session token for future use
Session Management
Section titled “Session Management”Sessions are stored in ~/.platform-cli/session.json:
{ "sessionToken": "token-here", "userId": "user-id", "email": "user@example.com"}To clear session (logout):
rm ~/.platform-cli/session.jsonTo renew an expired session:
# From root directorybun run api:renew-session your@email.com yourpassword
# Or with environment variablesexport PLATFORM_EMAIL="your@email.com"export PLATFORM_PASSWORD="yourpassword"bun run api:renew-sessionDevelopment
Section titled “Development”Prerequisites
Section titled “Prerequisites”-
Start the API server:
Terminal window bun run api -
Create a test user via the dashboard at http://localhost:5000
Adding New Commands
Section titled “Adding New Commands”- Create command file in
apps/cli/commands/ - Import and add to parent command
- Use Platform SDK for API operations:
import { Auth, Fetcher } from "@abeauvois/platform-sdk";
const auth = new Auth({ baseUrl: API_URL });const credentials = await auth.login();const fetcher = new Fetcher({ baseUrl: API_URL, credentials });const data = await fetcher.fetch("/api/some-resource");Building
Section titled “Building”# Build from rootbun run build
# Or build CLI independentlycd apps/clibun run buildTroubleshooting
Section titled “Troubleshooting”“Cannot find module ‘@abeauvois/platform-sdk’”
Section titled ““Cannot find module ‘@abeauvois/platform-sdk’””Build the packages:
bun run build:lib“Authentication failed” or 401 Unauthorized
Section titled ““Authentication failed” or 401 Unauthorized”- Check API server is running on http://localhost:3000
- Verify user exists with correct credentials
- Renew session:
bun run api:renew-session your@email.com password - Or clear session file:
rm ~/.platform-cli/session.json
Testing
Section titled “Testing”Run integration tests (requires API server running):
bun test ./apps/cli/tests/integration/gmail-source.test.ts