@topolo/cli 0.7.4 → 0.8.0

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.
@@ -1,164 +0,0 @@
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 assumes no repository access or private product knowledge; public Topolo docs and credential-scoped runtime discovery are authoritative.
4
-
5
- ## What the platform is
6
-
7
- Topolo is a multi-app SaaS platform. The CLI and MCP server both use `@topolo/sdk`; every application resolves from the live credential-scoped registry, so newly registered apps and API/technical services work immediately — there is no bundled application catalog to rely on or wait for.
8
-
9
- - Use `topolo apps --json` or the MCP `topolo_search_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_search_applications` tool to discover callable app ids and effective URLs.
13
- - Use `topolo actions --service <app> --json` or MCP `topolo_search_actions` to discover callable operations granted to the current credential; invoke automatic reads with `topolo_read_action` and confirmation-gated operations with `topolo_call_action`.
14
- - Use `topolo actions capabilities`, `actions examples`, `actions validate`, and `actions plan` (or their MCP equivalents) to obtain schemas, examples, verification, and rollback before execution.
15
- - The generic `api` command and MCP `topolo_api_call` tool can reach any live Auth-catalog application or API/technical service when no action contract exists yet; discover ids with `topolo apps --json` first.
16
-
17
- Every call is scoped to the organization embedded in the credential. There is no `--org` flag anywhere — attempting to target another org will fail.
18
-
19
- ## Invocation contract
20
-
21
- Always call `topolo` with `--json` from an agent. JSON schemas are stable; human text is not.
22
-
23
- ```bash
24
- topolo <command> [args] --json
25
- ```
26
-
27
- Production is the default CLI environment. Use `--env staging` anywhere in the
28
- command, or set `TOPOLO_ENV=staging`, for internal staging auth, staging service
29
- discovery, or staging scaffold provisioning. Staging credentials are stored
30
- separately from production credentials.
31
-
32
- 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).
33
-
34
- Exit codes:
35
-
36
- - `0` success
37
- - `1` generic error
38
- - `2` auth error → run `topolo auth login` and retry
39
- - `3` permission denied → the user's role/scopes are insufficient; surface to user, do not retry
40
-
41
- ## Setup flow
42
-
43
- 1. Check install: `command -v topolo || npm install -g @topolo/cli` (requires Node ≥ 20). To wire the skill + MCP into this agent, run `topolo skills install` (credential-free — the MCP reads the `topolo auth login` credential).
44
- 2. Check credential: `topolo auth status --json`.
45
- 3. For staging work, check credential with `topolo auth status --env staging --json`.
46
- 4. If `source` is `none`, run `topolo auth login` (add `--env staging` for staging) and wait for the user to approve in the browser tab that opens. **No `--client-id` is needed** — the CLI has a built-in first-party client, so any Topolo user can sign in; capabilities are decided by their permissions. (`--client-id=<doac_…>` is only for advanced/self-hosted OAuth clients.) For service-agent / headless installs, use an API key with `topolo auth login --api-key=<key>` or set `TOPOLO_API_KEY` for a single invocation.
47
- 5. Confirm identity once: `topolo whoami --json`. Reference the returned `organization.name` when explaining results to the user.
48
- 6. To act in a different org or personal space: `topolo context ls --json` then `topolo context use <organization-name|personal> --json`. Each context has its own credential; the CLI + MCP run in the active one. This does not change the user's web context, and later web switches do not alter the issued credential.
49
-
50
- ## Command surface
51
-
52
- ### Identity
53
-
54
- ```bash
55
- topolo whoami --json
56
- #=> { "user": {...}, "organization": {...}, "kind": "access_token" | "api_key" }
57
-
58
- topolo auth status --json
59
- topolo auth login [--api-key=...] [--client-id=... (advanced)] [--scope="..."]
60
- topolo auth logout
61
- ```
62
-
63
- ### Contexts (personal + multiple organizations)
64
-
65
- ```bash
66
- topolo context ls --json # personal + your orgs; marks the active one
67
- topolo context use <organization-name|personal> --json # switch the active context (validated server-side)
68
- ```
69
-
70
- There is no `--org` flag — switch context to act in a different organization. `topolo whoami` reflects the active context.
71
- The switch is local to the CLI/MCP credential store and its token refresh chain;
72
- it never changes the shared web preference.
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
- ```
83
-
84
- Use `topolo apps` to understand which Topolo application you are dealing with.
85
- Use `topolo apps requirements` before building so the current platform contract
86
- is in the agent context.
87
- Use `topolo services` before `topolo api` so you pass an exact SDK app id
88
- such as `auth`, `crm`, `mail`, `calendar`, `web`, or `quro.redirect`.
89
- In staging, `topolo services --env staging --json` also shows
90
- `environmentSafe`; false means the service still resolves to a production SDK
91
- URL and the CLI will refuse `topolo api` calls until a staging override is set.
92
-
93
- ### Credential-scoped actions
94
-
95
- ```bash
96
- topolo actions --service mail --json
97
- topolo actions get app_topolo_mail.messages.send --json
98
- topolo actions examples app_topolo_mail.messages.send --json
99
- topolo actions validate app_topolo_mail.messages.send \
100
- --data '{"mailboxId":"primary","subject":"Hello","text":"..."}' --json
101
- topolo actions plan app_topolo_mail.messages.send \
102
- --data '{"mailboxId":"primary","subject":"Hello","text":"..."}' --json
103
- topolo actions call app_topolo_mail.messages.send \
104
- --data '{"mailboxId":"primary","subject":"Hello","text":"..."}' \
105
- --confirm --json
106
- ```
107
-
108
- `topolo actions` is the normal agent entrypoint for application-specific
109
- operations. It is filtered by the signed-in organization and the exact service
110
- permissions on the credential. Actions marked `authorizationMode: "runtime"`
111
- have input-dependent policy and are definitively authorized by the target app
112
- for the supplied organization, application, and resource at invocation time.
113
- Never guess a missing action, field, resource id, endpoint, verification step,
114
- or rollback. If catalog metadata and `https://docs.topolo.app` do not provide a
115
- complete contract, report the missing publication contract instead of reading
116
- source code or inferring a private API.
117
-
118
- ### Generic passthrough
119
-
120
- For any endpoint without a typed subcommand:
121
-
122
- ```bash
123
- topolo api <service> <GET|POST|PUT|PATCH|DELETE> <path> [--data '<json>'] [--query key=value] [--confirm] --json
124
- ```
125
-
126
- - `<path>` begins with `/api/…` (no host).
127
- - Discover `<service>` with `topolo services --json`.
128
- - **Mutating methods require `--confirm`**. If omitted, the CLI refuses.
129
-
130
- ## Write safety — mandatory
131
-
132
- Before any mutating call, you MUST:
133
-
134
- 1. Print the exact method, path, and body you're about to send.
135
- 2. Get explicit user confirmation.
136
- 3. Only then run with `--confirm`.
137
-
138
- 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.
139
-
140
- ## Credential handling
141
-
142
- - 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.
143
- - 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.
144
- - The stored config lives at `$XDG_CONFIG_HOME/topolo/config.json` (mode 0600). Don't read or modify it directly — use `topolo auth` commands.
145
- - 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`.
146
-
147
- ## Org isolation — do not try to bypass
148
-
149
- - There is no `orgId` argument on any command.
150
- - Do not add org hints to `topolo api` request bodies; the backend rederives org from the credential.
151
- - 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."
152
-
153
- ## Debugging
154
-
155
- - `--no-json` gives human-readable output (useful when showing something to the user directly).
156
- - `TOPOLO_DEBUG=1` writes request/response traces to stderr while keeping JSON stdout clean.
157
- - Every request carries `X-Topolo-Request-Id`; if the user reports a failure, ask them for the request-id so support can grep logs.
158
- - If you set `TOPOLO_AGENT_NAME=<yourAgentLabel>` in the shell before running `topolo`, it's recorded in `X-Topolo-Agent` for audit traceability.
159
-
160
- ## Reference
161
-
162
- - Documentation: `https://docs.topolo.app` (guides, authentication, API reference).
163
- - Developers console (register apps / OAuth clients): `https://developers.topolo.app`
164
- - CLI help: `topolo --help` and `topolo <command> --help`.