@plotio/cli 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +170 -2
- package/dist/plot.js +1494 -0
- package/package.json +37 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Plot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,171 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @plotio/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`plot`: read Plot pages, follow a meeting while it happens, and post back, from
|
|
4
|
+
any agent with a shell (Claude Code, Codex CLI, Amp, OpenCode) or a script.
|
|
5
|
+
|
|
6
|
+
Design and reasoning: `plans/agent-cli-and-mcp.md` at the repo root.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npx @plotio/cli help agents # no install
|
|
12
|
+
npm install -g @plotio/cli # or install the `plot` binary
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Node 22 or later (the repo pins 24 in `.nvmrc`). In this repo,
|
|
16
|
+
`pnpm --filter @plotio/cli start <command>` runs the TypeScript directly (no
|
|
17
|
+
`--` before the command: pnpm passes it through, and `plot` would read it as
|
|
18
|
+
the command).
|
|
19
|
+
|
|
20
|
+
## Getting access
|
|
21
|
+
|
|
22
|
+
Two kinds of credential, both `plot_agent_sk_…` tokens that Plot stores only
|
|
23
|
+
as a hash:
|
|
24
|
+
|
|
25
|
+
- **A page.** Someone picks "Copy agent instructions" on a page, which gives
|
|
26
|
+
a one-time `temp_code_…` (ten minutes, single use).
|
|
27
|
+
`plot open temp_code_… --agent "Claude Code"` redeems it for a token that
|
|
28
|
+
reads that one page (24 hours from the last read, a week at most).
|
|
29
|
+
- **A workspace.** `plot login --agent "Claude Code"` mints a token on this
|
|
30
|
+
machine, opens `<site>/connect?hash=…&agent=…&fp=…` for a person to approve,
|
|
31
|
+
and waits up to ten minutes. Only the hash goes to the browser. The terminal
|
|
32
|
+
prints a six-character code (the hash's first six characters) and the page
|
|
33
|
+
asks the person to type it, so a link sent on by someone else cannot be
|
|
34
|
+
approved by mistake. The URL is printed too, for SSH and sandboxes. The site
|
|
35
|
+
is `--site`, else `PLOT_SITE_URL`, else the web app the API names in its
|
|
36
|
+
OAuth metadata, so `--api` at a local or preview deployment approves there
|
|
37
|
+
rather than on production.
|
|
38
|
+
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
| Command | Does |
|
|
42
|
+
| ------------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
43
|
+
| `plot open <temp_code_…> [--agent <name>]` | Redeem a handoff code and store the page token |
|
|
44
|
+
| `plot login [--agent] [--site] [--no-browser]` | Connect a workspace, approved in the browser |
|
|
45
|
+
| `plot logout [<page>] [--all]` | Revoke a credential on the server, then forget it |
|
|
46
|
+
| `plot whoami [<page>] [--json]` | What the credential acts for, its scope and expiry |
|
|
47
|
+
| `plot pages [--limit <n>] [--next <c>] [--json]` | Pages the workspace grant can read, newest first |
|
|
48
|
+
| `plot read <page> [--json]` | The page as Markdown (topics included), or as JSON; stores the updates cursor |
|
|
49
|
+
| `plot watch <page> [--level …] [options]` | Wait for the next update, print it, store the cursor |
|
|
50
|
+
| `plot topics <page>` | Topics as JSON, with the quotes behind each point |
|
|
51
|
+
| `plot search <query> [--limit] [--next] [--json]` | Search every page the workspace grant can read |
|
|
52
|
+
| `plot post <page> [--branch <id>] [--body <t>]` | Post a message (body from `--body`, else stdin), idempotent per run |
|
|
53
|
+
| `plot mcp-config [--host <h>] [--write] [<page>]` | The MCP server block for a host, pointing at `<api>/mcp` |
|
|
54
|
+
| `plot help agents` | The guide for an AI agent |
|
|
55
|
+
|
|
56
|
+
`<page>` is a page id or a page URL (`https://www.plot.io/p/<id>`).
|
|
57
|
+
|
|
58
|
+
Every command takes `--api <url>`, `--token <token>` and `-h`/`--help`.
|
|
59
|
+
`plot help <command>` lists a command's options.
|
|
60
|
+
|
|
61
|
+
### `watch`
|
|
62
|
+
|
|
63
|
+
One command is one turn: it blocks until something qualifies, prints only
|
|
64
|
+
what is new since the last `watch` of that page, stores the new cursor and
|
|
65
|
+
exits. Levels: `substantial` (default, when Plot's topic model completed a
|
|
66
|
+
run), `every` (any new words), `topics` (a topic changed). Each request asks
|
|
67
|
+
the server to hold it for up to 240 seconds (`wait=240`, kept under the 300
|
|
68
|
+
seconds Node's fetch waits for response headers); where the server
|
|
69
|
+
answers at once instead (Convex reached directly, in local dev and previews),
|
|
70
|
+
`watch` pauses `--interval` seconds (default 3) and asks again.
|
|
71
|
+
`--timeout <seconds>` gives up, cursor unchanged; keep it under your shell
|
|
72
|
+
tool's own timeout. `--from-start` and `--cursor` override the stored cursor,
|
|
73
|
+
and `--partial` includes words still being spoken (marked `interim`).
|
|
74
|
+
|
|
75
|
+
An update is `{notice, page, level, lines, topics, room, lastRunAt, cursor}`:
|
|
76
|
+
`lines` carry `authorName`, `text` and the flags `continues`, `revised`,
|
|
77
|
+
`removed`, `interim`; `topics` carry their `points` with source quotes;
|
|
78
|
+
`room` is who is present. `plot read` also stores the cursor (from its
|
|
79
|
+
`X-Plot-Updates-Cursor` header), so a `watch` after a `read` brings only what
|
|
80
|
+
was said after it. A stored cursor the server refuses (`bad_cursor`,
|
|
81
|
+
`wrong_cursor_page`) is dropped and the watch starts over once.
|
|
82
|
+
|
|
83
|
+
### `pages` and `search`
|
|
84
|
+
|
|
85
|
+
Both page with an opaque `next`; keep passing `--next` until the output has
|
|
86
|
+
no "More:" line, since a short batch does not mean the end. A page token on
|
|
87
|
+
either is refused (`wrong_scope`): they need `plot login`.
|
|
88
|
+
|
|
89
|
+
### `post`
|
|
90
|
+
|
|
91
|
+
Each run generates one idempotency `id` and reuses it if the connection drops
|
|
92
|
+
or a gateway answers 502 to 504, so the message lands once. A refusal is never
|
|
93
|
+
retried: `read_only` means the person who granted access cannot post there.
|
|
94
|
+
|
|
95
|
+
### `mcp-config`
|
|
96
|
+
|
|
97
|
+
Hosts: `claude-code` (default, `.mcp.json`), `cursor` (`~/.cursor/mcp.json`),
|
|
98
|
+
`vscode` (`.vscode/mcp.json`), `zed` (its `settings.json`) and
|
|
99
|
+
`claude-desktop` (a connector added in its settings, OAuth only). The
|
|
100
|
+
`Authorization` header names the `PLOT_TOKEN` environment variable in the
|
|
101
|
+
host's own syntax (`${PLOT_TOKEN}` for Claude Code, `${env:PLOT_TOKEN}` for
|
|
102
|
+
Cursor and VS Code) rather than holding the token, because `.mcp.json` and
|
|
103
|
+
`.vscode/mcp.json` are usually committed. The token itself (the stored
|
|
104
|
+
workspace one, or `<page>`'s) is printed to stderr as an `export` line to run
|
|
105
|
+
where the host starts. `--inline-token` puts the token in the header instead
|
|
106
|
+
(and makes a file it writes `0600`); Zed cannot read a variable there, so its
|
|
107
|
+
block always holds the token. `--no-token` leaves the header out so the host
|
|
108
|
+
signs in with OAuth. `--write` merges the block into the host's file, keeping
|
|
109
|
+
every other server, and refuses a file whose top level is not a JSON object.
|
|
110
|
+
|
|
111
|
+
## Environment
|
|
112
|
+
|
|
113
|
+
| Variable | Meaning |
|
|
114
|
+
| ----------------- | ------------------------------------------------------------------------- |
|
|
115
|
+
| `PLOT_API_URL` | API base. Default `https://agents.plot.io`; a deployment's `.convex.site` |
|
|
116
|
+
| | host for local dev and previews. `--api` wins over it. |
|
|
117
|
+
| `PLOT_SITE_URL` | Where `login` sends the browser. Default: the site the API names. |
|
|
118
|
+
| `PLOT_TOKEN` | Use this token instead of the store (a sandbox or CI job). |
|
|
119
|
+
| `PLOT_AGENT_NAME` | Default `--agent`. Inside Claude Code the default is "Claude Code". |
|
|
120
|
+
| `XDG_CONFIG_HOME` | Where the credential store lives (below). |
|
|
121
|
+
|
|
122
|
+
Token resolution for a page command: `--token`, then `PLOT_TOKEN`, then the
|
|
123
|
+
page's stored grant, then the stored workspace grant. A stored token the
|
|
124
|
+
server calls expired or revoked is removed and the next one tried.
|
|
125
|
+
|
|
126
|
+
## Where credentials live
|
|
127
|
+
|
|
128
|
+
`$XDG_CONFIG_HOME/plot/credentials.json`, by default
|
|
129
|
+
`~/.config/plot/credentials.json`, mode `0600` in a `0700` directory. Keyed by
|
|
130
|
+
API base, so production's and a preview's tokens never collide:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"https://agents.plot.io": {
|
|
135
|
+
"workspace": {
|
|
136
|
+
"token": "plot_agent_sk_…",
|
|
137
|
+
"workspace": "Acme",
|
|
138
|
+
"expiresAt": "…"
|
|
139
|
+
},
|
|
140
|
+
"pages": {
|
|
141
|
+
"<pageId>": {
|
|
142
|
+
"token": "plot_agent_sk_…",
|
|
143
|
+
"expiresAt": "…",
|
|
144
|
+
"title": "…",
|
|
145
|
+
"cursor": "…"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
A page entry can hold just a `cursor` when that page is watched through the
|
|
153
|
+
workspace grant. `plot logout --all` revokes and removes everything for the
|
|
154
|
+
current API base.
|
|
155
|
+
|
|
156
|
+
## Development
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pnpm --filter @plotio/cli test # node --test, no network
|
|
160
|
+
pnpm --filter @plotio/cli type-check
|
|
161
|
+
pnpm --filter @plotio/cli lint
|
|
162
|
+
pnpm --filter @plotio/cli build # dist/plot.js, one bundled file
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`dist/` is not committed; `prepack` runs the build, so `pnpm pack` and
|
|
166
|
+
`pnpm publish` from a clean tree still ship `dist/plot.js`.
|
|
167
|
+
|
|
168
|
+
All HTTP lives in `src/api.ts`. The build bundles with esbuild rather than
|
|
169
|
+
emitting with `tsc`, because `@plot/shared` (token shapes, minting and
|
|
170
|
+
hashing) is a private workspace package: the bundle inlines it, so the
|
|
171
|
+
published package has no dependencies at all.
|