feat(spectrum): users / lines / platforms / profile / avatar#8
Conversation
Phase 7. The largest sub-surface — a `spectrum` command group with five
sub-resources, each defaulting to the linked project via resolveProject().
`spectrum users`
ls — table of all Spectrum users on the project
add — POST /api/projects/:id/spectrum/users (interactive
prompts for first/last/email/phone in TTY; --invite
triggers server-side onboarding email)
remove <id> — DELETE; confirmDestructive
`spectrum lines`
ls — table of phone lines with platform/number/status
add — POST /api/projects/:id/lines (server currently
accepts platform="imessage" only; CLI rejects other
values up-front with a hint)
remove <id> — DELETE; confirmDestructive
`spectrum platforms`
ls — Record<platform, on/off> rendered as a table
enable <name> — POST /api/projects/:id/platforms/toggle {enabled:true}
disable <name> — same with {enabled:false}
(server returns "Unsupported platform" for unknown names; CLI surfaces
that with a hint pointing at `platforms ls`)
`spectrum profile`
show — fetches the Spectrum-side metadata (firstName,
lastName, avatarUrl, etc.)
update [...] — PATCH; sends only the fields the user passed
(server tolerates partial)
`spectrum avatar upload <file>`
Three-step flow:
1. GET /api/projects/:id/spectrum/avatar-upload-url for the
presigned PUT url + final avatar URL.
2. PUT the local file body with Content-Type from Bun.file().type.
3. PATCH the Spectrum profile with the new avatarUrl (skip with
--no-update-profile).
Surfaces upload-success / patch-failure separately so a partial
failure prints the URL and the manual recovery command.
All commands accept the standard --project / --env / --token / --json
flags and route errors through the central handler.
src/index.ts: register the spectrum group via
registerSpectrumCommands(program). Layout uses a per-resource file
(src/commands/spectrum/{users,lines,platforms,profile,avatar}.ts) +
an index.ts that wires them together — keeps each file focused.
Verified:
- `photon --help` lists `spectrum`.
- `spectrum --help` lists all 5 sub-resources.
- Each sub-resource without a linked project / --project → friendly
"No project linked" error with hint.
- avatar upload with missing file → "File not found".
- `bunx tsc --noEmit` clean.
Live verification deferred — needs a real project with a Spectrum
tenant set up to exercise create user / toggle imessage / list lines /
upload avatar end-to-end.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Orca <help@stably.ai>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR introduces a comprehensive Spectrum CLI command suite with subcommands for managing avatars, profiles, users, phone lines, and platform integrations. Each subcommand handles project/environment resolution, authentication, API interactions, error handling, and formatted output. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Warning Review ran into problems🔥 ProblemsThese MCP integrations need to be re-authenticated in the Integrations settings: Linear Review rate limit: 2/5 reviews remaining, refill in 30 minutes and 36 seconds. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a new spectrum command group to the Photon CLI, providing project-scoped Spectrum management (users, lines, platforms, profile, avatar) with consistent --project/--env/--token/--json support via resolveProject() and the central API client.
Changes:
- Wire up
photon spectrumcommand registration in the CLI entrypoint. - Implement
spectrum users / lines / platforms / profilesubcommands for CRUD-style operations. - Implement
spectrum avatar uploadwith presigned URL upload flow and optional profile update.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.ts | Registers the new spectrum command group in the root CLI. |
| src/commands/spectrum/index.ts | Adds registerSpectrumCommands() and wires all Spectrum sub-resources. |
| src/commands/spectrum/users.ts | Implements spectrum users list/add/remove with TTY prompting for required fields. |
| src/commands/spectrum/lines.ts | Implements spectrum lines list/add/remove, with client-side platform validation. |
| src/commands/spectrum/platforms.ts | Implements spectrum platforms list/enable/disable via platforms toggle endpoint. |
| src/commands/spectrum/profile.ts | Implements spectrum profile show/update with partial PATCH support. |
| src/commands/spectrum/avatar.ts | Implements avatar upload (presigned PUT) and optional profile patch, with partial-failure messaging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3 substantive findings: - spectrum/avatar.ts: replaced direct process.exit(1) on PATCH failure with die() so output goes through the central formatter (consistency with the rest of the CLI). Also rebuilds the manual-recovery hint to include the original --project / --env / --token context the user passed, and shell-quotes the avatar URL via a new shellQuote() helper so URLs with `&`, `?`, `;` etc. don't break shell copy-paste. - spectrum/users.ts add: resolveProject() + getApi() now run BEFORE fillAddOpts(). Previously a user could fill out 4 interactive prompts (first/last/email/phone) only to learn they're not logged in or have no linked project. Now fails fast. tsc clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Orca <help@stably.ai>
Phase 7 — `spectrum` command group with five sub-resources, each defaulting to the linked project via `resolveProject()`. Largest sub-surface in the CLI.
New commands
Partial-failure path: if upload succeeded but PATCH failed, prints the URL and the manual recovery command.
All commands accept the standard `--project / --env / --token / --json` flags and route errors through the central handler.
Layout
`src/commands/spectrum/{users,lines,platforms,profile,avatar}.ts` — one file per sub-resource. `spectrum/index.ts` wires them together via `registerSpectrumCommands(program)`.
Test plan
Phase 6 + 7 status
🤖 Generated with Claude Code
Made with Orca 🐋
Summary by CodeRabbit