@topolo/cli 0.1.32 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@topolo/cli",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "Command-line interface for Topolo developers, operators, and agents, with internal first-party scaffolding available under the topolo platform namespace.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "topolo": "dist/index.js"
8
8
  },
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "skills"
11
12
  ],
12
13
  "scripts": {
13
14
  "build": "tsup",
@@ -0,0 +1,141 @@
1
+ # Topolo — agent guide (Codex / general-purpose agents)
2
+
3
+ This file teaches an agent how to interact with the Topolo platform via the `topolo` CLI and, when available, the Topolo MCP server. It is intentionally short, shell-first, and stable across Codex, Cursor, and any other agent that reads `AGENTS.md`.
4
+
5
+ ## What the platform is
6
+
7
+ Topolo is a multi-app SaaS platform. The CLI and MCP server both use `@topolo/sdk`; bundled app IDs come from the generated registry, and newly registered API/technical services can be resolved from the live Auth catalog.
8
+
9
+ - Use `topolo apps --json` or the MCP `topolo_list_applications` tool to discover platform applications, including browser-only Worker apps.
10
+ - Use `topolo apps requirements <application_id> --json` or the MCP `topolo_list_application_requirements` tool before creating or expanding a Topolo app.
11
+ - Use `topolo apps audit <application_id> --json` or the MCP `topolo_audit_applications` tool to inspect current requirement conformance and migration work.
12
+ - Use `topolo services --json` or the MCP `topolo_list_services` tool to discover callable app ids and effective URLs.
13
+ - Use `topolo actions --json` or MCP dynamic action tools to discover callable operations granted to the current credential.
14
+ - The generic `api` command and MCP `topolo_api_call` tool can reach bundled SDK services and live Auth-catalog API/technical services when no action contract exists yet.
15
+
16
+ Every call is scoped to the organization embedded in the credential. There is no `--org` flag anywhere — attempting to target another org will fail.
17
+
18
+ ## Invocation contract
19
+
20
+ Always call `topolo` with `--json` from an agent. JSON schemas are stable; human text is not.
21
+
22
+ ```bash
23
+ topolo <command> [args] --json
24
+ ```
25
+
26
+ Production is the default CLI environment. Use `--env staging` anywhere in the
27
+ command, or set `TOPOLO_ENV=staging`, for internal staging auth, staging service
28
+ discovery, or staging scaffold provisioning. Staging credentials are stored
29
+ separately from production credentials.
30
+
31
+ On success the command prints JSON to stdout and exits 0. On failure it prints `{"error":{"message","code","hint","exitCode"}}` to stderr and exits non-zero. Branch on `code` (not on message text).
32
+
33
+ Exit codes:
34
+
35
+ - `0` success
36
+ - `1` generic error
37
+ - `2` auth error → run `topolo auth login` and retry
38
+ - `3` permission denied → the user's role/scopes are insufficient; surface to user, do not retry
39
+
40
+ ## Setup flow
41
+
42
+ 1. Check install: `command -v topolo || npm install -g @topolo/cli` (requires Node ≥ 20).
43
+ 2. Check credential: `topolo auth status --json`.
44
+ 3. For staging work, check credential with `topolo auth status --env staging --json`.
45
+ 4. If `source` is `none`, run `topolo auth login --client-id=<doac_…>` plus the right `--env` flag and wait for the user to approve in the browser tab that opens. To get a client_id, direct the user to `https://developers.topolo.app/developers/oauth-clients` for production or `https://developers.stg.topolo.us/developers/oauth-clients` for staging and tell them to pick the **CLI / desktop / mobile** tile (that's what enables the device flow). For service-agent installs, use an API key with `topolo auth login --api-key=<key>` or set `TOPOLO_API_KEY` for a single invocation.
46
+ 5. Confirm identity once: `topolo whoami --json`. Reference the returned `organization.name` when explaining results to the user.
47
+
48
+ ## Command surface
49
+
50
+ ### Identity
51
+
52
+ ```bash
53
+ topolo whoami --json
54
+ #=> { "user": {...}, "organization": {...}, "kind": "access_token" | "api_key" }
55
+
56
+ topolo auth status --json
57
+ topolo auth login [--client-id=...] [--api-key=...] [--scope="..."]
58
+ topolo auth logout
59
+ ```
60
+
61
+ ### Application and service discovery
62
+
63
+ ```bash
64
+ topolo apps --json
65
+ topolo apps get <application_id> --json
66
+ topolo apps requirements <application_id> --json
67
+ topolo apps audit <application_id> --json
68
+ topolo services --json
69
+ ```
70
+
71
+ Use `topolo apps` to understand which Topolo application you are dealing with.
72
+ Use `topolo apps requirements` before building so the current platform contract
73
+ is in the agent context.
74
+ Use `topolo services` before `topolo api` so you pass an exact SDK app id
75
+ such as `auth`, `crm`, `mail`, `calendar`, `web`, or `quro.redirect`.
76
+ In staging, `topolo services --env staging --json` also shows
77
+ `environmentSafe`; false means the service still resolves to a production SDK
78
+ URL and the CLI will refuse `topolo api` calls until a staging override is set.
79
+
80
+ ### Credential-scoped actions
81
+
82
+ ```bash
83
+ topolo actions --json
84
+ topolo actions --service mail --json
85
+ topolo actions get topolo_mail_messages_send --json
86
+ topolo actions call topolo_mail_messages_send \
87
+ --data '{"mailboxId":"primary","subject":"Hello","text":"..."}' \
88
+ --confirm --json
89
+ ```
90
+
91
+ `topolo actions` is the normal agent entrypoint for application-specific
92
+ operations. It is filtered by the signed-in organization and the exact service
93
+ permissions on the credential.
94
+
95
+ ### Generic passthrough
96
+
97
+ For any endpoint without a typed subcommand:
98
+
99
+ ```bash
100
+ topolo api <service> <GET|POST|PUT|PATCH|DELETE> <path> [--data '<json>'] [--query key=value] [--confirm] --json
101
+ ```
102
+
103
+ - `<path>` begins with `/api/…` (no host).
104
+ - Discover `<service>` with `topolo services --json`.
105
+ - **Mutating methods require `--confirm`**. If omitted, the CLI refuses.
106
+
107
+ ## Write safety — mandatory
108
+
109
+ Before any mutating call, you MUST:
110
+
111
+ 1. Print the exact method, path, and body you're about to send.
112
+ 2. Get explicit user confirmation.
113
+ 3. Only then run with `--confirm`.
114
+
115
+ Do not batch writes. Do not retry a failed write without re-confirming. The `--confirm` flag exists so a mis-generated write fails loudly instead of silently mutating production data.
116
+
117
+ ## Credential handling
118
+
119
+ - Never commit credentials. If a user shares an API key inline, use it for a single invocation via env var (`TOPOLO_API_KEY=… topolo whoami --json`) rather than writing it anywhere.
120
+ - Prefer `TOPOLO_STAGING_API_KEY`, `TOPOLO_STAGING_ACCESS_TOKEN`, `TOPOLO_PRODUCTION_API_KEY`, or `TOPOLO_PRODUCTION_ACCESS_TOKEN` when a credential is meant for only one environment.
121
+ - The stored config lives at `$XDG_CONFIG_HOME/topolo/config.json` (mode 0600). Don't read or modify it directly — use `topolo auth` commands.
122
+ - Stored OAuth access tokens refresh automatically when the config contains a refresh token and OAuth client id. On `auth_error`, prompt the user to re-run `topolo auth login`.
123
+
124
+ ## Org isolation — do not try to bypass
125
+
126
+ - There is no `orgId` argument on any command.
127
+ - Do not add org hints to `topolo api` request bodies; the backend rederives org from the credential.
128
+ - If the user asks you to access "another org's data", the correct response is: "I can only act as the signed-in user. Sign in with a credential for that org first."
129
+
130
+ ## Debugging
131
+
132
+ - `--no-json` gives human-readable output (useful when showing something to the user directly).
133
+ - `TOPOLO_DEBUG=1` writes request/response traces to stderr while keeping JSON stdout clean.
134
+ - Every request carries `X-Topolo-Request-Id`; if the user reports a failure, ask them for the request-id so support can grep logs.
135
+ - If you set `TOPOLO_AGENT_NAME=<yourAgentLabel>` in the shell before running `topolo`, it's recorded in `X-Topolo-Agent` for audit traceability.
136
+
137
+ ## Reference
138
+
139
+ - Dev console (registration, scopes, clients): `https://developers.topolo.app`
140
+ - CLI README: the `README.md` alongside this file.
141
+ - Schemas: `packages/topolo-sdk/src/modules/` in the monorepo.
@@ -0,0 +1,205 @@
1
+ ---
2
+ name: topolo
3
+ description: Read and write Topolo platform data (identity, application/service discovery, credential-scoped actions, and any SDK-registered Topolo API) from the shell via the `topolo` CLI. Use whenever the user references their Topolo organization, a Topolo app/service, or asks to mint/inspect Topolo credentials.
4
+ ---
5
+
6
+ # Topolo platform
7
+
8
+ The `topolo` CLI is the agent-friendly entry point to the Topolo platform. Every command is scoped to the organization embedded in the current credential — you cannot target another org, and you cannot bypass the credential.
9
+
10
+ ## When this skill fires
11
+
12
+ Use `topolo` whenever the user:
13
+
14
+ - References records, messages, customers, or any other data stored in a Topolo app.
15
+ - Asks about their Topolo identity ("who am I logged in as", "what org am I in", "what scopes do I have").
16
+ - Wants to call an endpoint under a Topolo service from the shell.
17
+ - Mentions a Topolo OAuth client (`doac_…`) or API key.
18
+
19
+ If the user asks a platform question and `topolo` is not installed, install it: `npm install -g @topolo/cli`. Requires Node ≥ 20.
20
+
21
+ ## Credentials — always check first
22
+
23
+ Before any data command, confirm a credential is configured:
24
+
25
+ ```bash
26
+ topolo auth status --json
27
+ ```
28
+
29
+ Production is the default environment. Use `--env staging` anywhere in the
30
+ command, or set `TOPOLO_ENV=staging`, when the user is testing internal staging
31
+ or provisioning a staging-only first-party app:
32
+
33
+ ```bash
34
+ topolo auth status --env staging --json
35
+ topolo auth login --env staging --client-id=<doac_…>
36
+ ```
37
+
38
+ Possible `source` values:
39
+
40
+ | source | meaning |
41
+ | --- | --- |
42
+ | `env:TOPOLO_STAGING_API_KEY` / `env:TOPOLO_PRODUCTION_API_KEY` | Environment-specific service-scoped API key in env |
43
+ | `env:TOPOLO_STAGING_ACCESS_TOKEN` / `env:TOPOLO_PRODUCTION_ACCESS_TOKEN` | Environment-specific short-lived access token in env |
44
+ | `env:TOPOLO_API_KEY` | Shared service-scoped API key in env |
45
+ | `env:TOPOLO_ACCESS_TOKEN` | Shared short-lived access token in env (dev/testing) |
46
+ | `config-file` | Token stored in the selected environment profile at `$XDG_CONFIG_HOME/topolo/config.json` |
47
+ | `none` | Not signed in — call `topolo auth login` |
48
+
49
+ If `source: none`, run `topolo auth login --client-id=<doac_…>` plus the right
50
+ `--env` flag and tell the user to approve the device in the browser tab that
51
+ opens. The CLI blocks until they approve, then stores the token in that
52
+ environment profile.
53
+
54
+ If you don't know the client_id, send them to `https://developers.topolo.app/developers/oauth-clients` for production or `https://developers.stg.topolo.us/developers/oauth-clients` for staging. Prefer a **public** (CLI/desktop/mobile) client — that's the tile that enables the device flow.
55
+
56
+ For service-agent installs, use an API key with `topolo auth login --api-key=<key>` or set `TOPOLO_API_KEY` only for the single command that needs it.
57
+
58
+ ## Output modes
59
+
60
+ All commands support `--json` (machine) and `--no-json` (human). The CLI autodetects: pretty when stdout is a TTY, JSON when piped. **When you call `topolo` from an agent, always pass `--json`** — the JSON shape is stable; the pretty text is not.
61
+
62
+ ## Command reference
63
+
64
+ ### Identity
65
+
66
+ ```bash
67
+ topolo whoami --json
68
+ ```
69
+
70
+ Returns `{ user: { email, name, role, permissions }, organization: { name, slug } | null, kind }`.
71
+
72
+ Use this once at the start of a session to confirm the active user + org — then reference that org context in subsequent explanations so the user doesn't have to re-orient.
73
+
74
+ ### Application and service discovery
75
+
76
+ ```bash
77
+ topolo apps --json
78
+ topolo apps get <application_id> --json
79
+ topolo apps requirements <application_id> --json
80
+ topolo apps audit <application_id> --json
81
+ topolo services --json
82
+ topolo actions --json
83
+ ```
84
+
85
+ `topolo apps` returns every cataloged Topolo application, including browser-only
86
+ Worker apps that do not expose a callable API. `topolo services` returns every
87
+ SDK-app id with its default and effective URL. In staging, a
88
+ service with `environmentSafe: false` still resolves to a production SDK URL and
89
+ the CLI refuses `topolo api` calls for it until a staging URL override is set.
90
+ `topolo apps requirements` returns the current versioned app-build contract and should be run
91
+ before creating or expanding a Topolo app. `topolo apps audit` returns
92
+ catalog-backed requirement scores and migration work. Run `topolo services`
93
+ before `topolo api` when you are not using a cataloged action.
94
+
95
+ ### Credential-scoped actions
96
+
97
+ ```bash
98
+ topolo actions --json
99
+ topolo actions --service mail --json
100
+ topolo actions get topolo_mail_messages_send --json
101
+ topolo actions call topolo_mail_messages_send \
102
+ --data '{"mailboxId":"primary","subject":"Hello","text":"..."}' \
103
+ --confirm --json
104
+ ```
105
+
106
+ `topolo actions` returns the callable action catalog filtered by the current
107
+ credential's organization and permissions. Prefer it over `topolo api` when the
108
+ target app has published a machine action contract through Topolo Developers.
109
+ Writes require `--confirm`.
110
+
111
+ ### Generic API passthrough
112
+
113
+ For any endpoint that doesn't yet have a typed subcommand:
114
+
115
+ ```bash
116
+ topolo api <service> <method> <path> [--data '<json>'] [--query key=value] [--confirm]
117
+ ```
118
+
119
+ - `<service>`: any id from `topolo services --json`.
120
+ - `<method>`: `GET` | `POST` | `PUT` | `PATCH` | `DELETE`.
121
+ - `<path>`: starts with `/api/…` — don't include the host.
122
+ - **Mutating calls require `--confirm`**. If you omit it, the CLI refuses and exits non-zero. This is intentional: confirm before sending writes.
123
+
124
+ Examples:
125
+
126
+ ```bash
127
+ # Read current user via auth service
128
+ topolo api auth GET /api/me --json
129
+
130
+ # Send mail through a published action (requires confirm)
131
+ topolo actions call topolo_mail_messages_send \
132
+ --data '{"mailboxId":"primary","subject":"Hello","text":"..."}' \
133
+ --confirm --json
134
+ ```
135
+
136
+ ## Error handling
137
+
138
+ Exit codes:
139
+
140
+ | Code | Meaning | Action |
141
+ | --- | --- | --- |
142
+ | 0 | Success | — |
143
+ | 1 | Generic error | Surface message to user |
144
+ | 2 | Auth error (expired, invalid token) | Run `topolo auth login` and retry |
145
+ | 3 | Permission denied | User's role/scopes lack the capability — point them to the Developers console |
146
+
147
+ In `--json` mode, errors come on stderr as `{"error":{"message","code","hint","exitCode"}}`. Parse `code` first when branching.
148
+
149
+ Stored OAuth access tokens refresh automatically when the config contains both a refresh token and the OAuth client id used at login. If `whoami` still returns `auth_error`, have the user re-run `topolo auth login`.
150
+
151
+ ## Safety rules
152
+
153
+ 1. **Never run a mutating `topolo actions call …` or `topolo api … POST|PUT|PATCH|DELETE …` without surfacing the exact body to the user first** and confirming. The `--confirm` flag is a guardrail, not your approval.
154
+ 2. **Never write credentials to tracked files.** If a user pastes an API key inline, use it via env var for that invocation (`TOPOLO_API_KEY=… topolo whoami`) rather than committing it.
155
+ 3. **Cross-org isolation is built-in** — there is no `--org` flag anywhere. Don't try to fake one via the passthrough; the backend ignores org hints in the body and rederives org from the credential.
156
+ 4. Audit headers (`X-Topolo-Client`, `X-Topolo-Request-Id`, optional `X-Topolo-Agent`) are set by the CLI automatically. If `TOPOLO_AGENT_NAME` is already exported in the user's shell, leave it alone — it's the audit trail.
157
+
158
+ ## Common flows
159
+
160
+ **"Show me the available Mail actions"**
161
+ ```bash
162
+ topolo whoami --json # confirm org
163
+ topolo actions --service mail --json
164
+ ```
165
+
166
+ **"Send a message through Mail"**
167
+ ```bash
168
+ topolo actions call topolo_mail_messages_send \
169
+ --data '{"mailboxId":"primary","subject":"Hello","text":"..."}' \
170
+ --confirm --json
171
+ ```
172
+
173
+ **"What scopes does my CLI token have?"**
174
+ ```bash
175
+ topolo whoami --json | jq '.user.permissions'
176
+ ```
177
+
178
+ **"What app id should I use?"**
179
+ ```bash
180
+ topolo apps --json
181
+ topolo apps requirements <application_id> --json
182
+ topolo apps audit <application_id> --json
183
+ topolo services --json
184
+ topolo actions --json
185
+ ```
186
+
187
+ **"Sign me in fresh"**
188
+ ```bash
189
+ topolo auth logout
190
+ topolo auth login --client-id=<doac_…>
191
+ # Then wait for the user to approve in the browser.
192
+ ```
193
+
194
+ **"Sign me in to staging"**
195
+ ```bash
196
+ topolo auth logout --env staging
197
+ topolo auth login --env staging --client-id=<doac_…>
198
+ topolo whoami --env staging --json
199
+ ```
200
+
201
+ ## Where to learn more
202
+
203
+ - Topolo Developers console: https://developers.topolo.app
204
+ - CLI source (for when the user asks about an undocumented flag): `TopoloCli/src/commands/` in the PlatformApplications repo.
205
+ - SDK package: `packages/topolo-sdk/src/` — authoritative client, dynamic action catalog, and shared response contracts.