Repository navigation
Conversation
A `perspective` command for the External REST API and the hosted MCP server, built for humans and coding agents alike: JSON on stdout, JSON errors on stderr, stable exit codes. - auth: browser OAuth (PKCE, loopback redirect) for MCP tools, API key (stdin, validated) for REST; flag > env > file precedence; tokens refresh automatically; credentials file is 0600. - REST: workspaces list, funnels list, contacts list/get/create/set, metrics kpi/chart/insight/subtypes. - tools list/describe/call: generic access to every MCP tool, with a minimal stateless JSON-RPC client (JSON and SSE replies). - skill show/install and skills/perspective/SKILL.md. - Vitest suite and a CI workflow on Node 22 and 24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CAP-4819 Perspective CLI: new repo with agent SKILL.md + developer docs
Build a Scope
Out of scope
|
Linear: CAP-4819
What
The first version of
perspective, a CLI that wraps the External API (/v1). It is built for both people and coding agents:{"error":{code,message,status?,hint?}}.auth login/status/logoutGET /v1/workspacesworkspaces list,funnels listGET /v1/workspacescontacts list [--all] / get / create / set/v1/funnels/{id}/contacts…metrics kpi <subtypes…|all> / chart / insight / subtypes/v1/funnels/{id}/metrics/…skill show / installskills/perspective/SKILL.mdDesign notes
auth loginprompts for the key on a terminal (input hidden), reads it from stdin when piped, or takes--api-key. It validates the key before storing it in~/.config/perspective/credentials.json(0600). The key resolves in this order:--api-keyflag, thenPERSPECTIVE_API_KEY, then the file.--fields(global) keeps only the listed fields, so a large list doesn't flood an agent's context.--dry-runoncontacts create/setprints the request without sending it. HTTP 429 is retried up to 3 times, waitingRetry-After(at most a minute).metrics kpitakes several KPIs orallin one call. Parse errors (unknown option or command, missing argument) are JSON too.commanderis the only runtime dependency.auth statusfirstfunnels listcontacts create/setand show the request before sending, because they can trigger automations and emails; and offer--skip-automation--fieldson large liststotal_sessionsbefore ranking rates.@perspective-software/cli(public). The Release workflow publishes on av*tag via npm trusted publishing; the first version is published by hand. Install withnpm i -g @perspective-software/cli.Verification
npm run typecheckpasses;npm testpasses 33 tests (multi-KPI name resolution, request timeout, broken credentials file, base URL and --tz-offset validation, large integers in --set, API client against a fake fetch, error mapping, 429 retry and backoff, field selection, dry-run without the key, credential precedence, file permissions, argument parsing, metrics window).--api-keyreturns exit 3 with a JSON error, and commands without a key return exit 3 with a hint.script): the instructions andAPI key:stay visible, input isn't echoed, and Ctrl+C exits 130.workspaces list,funnels list(167 funnels) and--status livecontacts listpaging (8 contacts at 3 per page) and--all, pluscontacts getmetrics kpi,chart(5 types plus the A/B variant) andinsightlive, notonline(the swagger enum in perspective-external-api is wrong), and that a wrong funnel ID returns 403. Both are fixed.metrics kpiwith one KPI, two KPIs andallwas checked against production. KPI units were confirmed in perspective-metrics.--fieldswas checked against production on funnels, contacts and a KPI.--dry-runwas checked for both writes, including with no API key configured.contacts create/set), and a real 429. The retry is unit-tested.Docs PR: Perspective-Software/developer-docs#19 (CLI section).
🤖 Generated with Claude Code