cli: add command-line interface
Send files directly between devices over the internet with no limits
Brought to you by:
denisdev
Originally created by: nak2002k
Adds a standalone CLI tool (altersend) for P2P file transfer without a GUI. Targets users who prefer terminal workflows or need automation scripts.
apps/cli/ package with TypeScript strict modesend — share files, display join code or QR code, optional temp deletionreceive — download files from join code, auto-exits after transferpeek — preview file offers without downloadingcheck-update / update — pear-based auto-update support--no-updates flag on all commands to skip OTA checks--storage, --output, --qr, --temp flags for relevant commandsN/A (terminal-only tool)
Closes [#24]
Single-line progress UI with human-readable sizes, filename truncation, and interruption handling
Documentation
New CLI README covering install/build, commands/examples/flags, exit codes, storage defaults, architecture, and maintainer steps
Chores
Originally posted by: coderabbitai[bot]
📝 Walkthrough
## Walkthrough Adds a new AlterSend CLI app: runtime/type bindings and config, a paparam-based executable, join-code/QR/progress helpers, five commands (send, receive, peek, check-update, update), TypeScript/Vitest config, package manifest, README, and root npm scripts for building/testing the CLI. ## Changes **AlterSend CLI Application** |Layer / File(s)|Summary| |---|---| |**Runtime foundation & Configuration**`apps/cli/src/types.d.ts`, `apps/cli/src/runtime.ts`, `apps/cli/package.json`, `apps/cli/tsconfig.json`, `apps/cli/vitest.config.ts`|Ambient typings for `pear-runtime`, `which-runtime`, and `paparam`; createCliRuntime that instantiates PearRuntime and worker client with platform storage selection and lock-retry; CLI package manifest and TypeScript/test config.| |**CLI entrypoint & Utilities**
`apps/cli/src/index.ts`, `apps/cli/src/joinCode.ts`, `apps/cli/src/progress.ts`, `apps/cli/src/qr.ts`|Node executable using `paparam` that parses/dispatches subcommands; join-code extraction/validation (64-hex chars); throttled single-line progress rendering; TTY-aware QR display.| |**Send command**
`apps/cli/src/commands/send.ts`|Validates file paths and safety, hosts a transfer (client.host), optionally renders QR, waits for peer, shares files, reports progress, and handles SIGINT and error teardown.| |**Receive command**
`apps/cli/src/commands/receive.ts`|Validates/extracts join code, ensures output dir, connects via worker client, converts offers to download requests, updates progress UI, handles interruption, and manages lifecycle.| |**Peek, Check-Update & Update commands**
`apps/cli/src/commands/peek.ts`, `apps/cli/src/commands/check-update.ts`, `apps/cli/src/commands/update.ts`|Peek lists offered files without downloading; check-update waits up to 5s for updater notification; update applies staged updates immediately or after waiting up to 10s, all with event/timeouts and teardown.| |**Documentation & root scripts**
`apps/cli/README.md`, `CLAUDE.md`, `package.json`|Adds comprehensive CLI README (usage, architecture, storage, maintainer steps), CLI subsection in CLAUDE.md listing `cli:build`, `cli:dev`, `cli:test`, and three root npm scripts to build/run/test the CLI.| ## Sequence Diagram(s) :::mermaid sequenceDiagram participant User participant CLI as index.ts participant Command as Command Module participant Runtime as createCliRuntime participant Pear as PearRuntime participant Worker as WorkerClient participant Peer User->>CLI: npm run cli:dev send file.txt CLI->>Command: dispatch send(files, options) Command->>Runtime: createCliRuntime(storage, onEvent) Runtime->>Pear: new PearRuntime(config) Runtime->>Pear: run(workerEntry, args --storage=...) Runtime->>Worker: require and create worker client with onEvent Runtime->>Worker: await client.ready Runtime-->>Command: return {client, destroy, pear} Command->>Worker: client.host() Command->>User: display join code / QR Peer->>Worker: join with code Worker->>Command: onEvent('status','peer-connected') Command->>Worker: client.shareFiles(...) Worker->>Command: onEvent('status','download-progress') Command->>Command: writeProgress() Worker->>Peer: transfer chunks Worker->>Command: onEvent('status','disconnected') Command->>Runtime: destroy() Command->>User: exit 0 ## Estimated code review effort 🎯 3 (Moderate) | ⏱️ ~25 minutes ## Suggested reviewers - denislupookov ## Poem > 🐰 I hopped along the terminal light, > Shared a code, then queued the flight. > Bars and QR in a joyful spin, > Pear hummed softly, transfers begin. > A rabbit clap — the files hop in!
🚥 Pre-merge checks | ✅ 4 | ❌ 1
### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :----------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |✅ Passed checks (4 passed)
| Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. | | Title check | ✅ Passed | The title 'cli: add command-line interface' accurately summarizes the main change: adding a CLI tool for the altersend project with multiple commands (send, receive, peek, check-update, update). | | Linked Issues check | ✅ Passed | The PR implements a complete CLI tool addressing issue `#24`'s requirement for command-line usage by providing send, receive, peek, check-update, and update commands with proper runtime management, storage handling, and progress tracking. | | Out of Scope Changes check | ✅ Passed | All changes are in-scope: CLI implementation in apps/cli/ with required files, package configuration, TypeScript setup, and minimal root-level changes (CLAUDE.md update and npm scripts). No unrelated modifications detected. |✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit testsComment
@coderabbitai helpto get the list of available commands and usage tips.