@motir/cli 0.1.0 → 0.2.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.
Files changed (3) hide show
  1. package/README.md +78 -15
  2. package/dist/index.js +50445 -482
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -1,10 +1,22 @@
1
1
  # `@motir/cli` — the `motir` command-line tool
2
2
 
3
- Terminal dispatch of the Motir work loop. The CLI is an **MCP client** of the
4
- Motir server (`/api/mcp`): every command speaks Model Context Protocol to the
5
- tenant with a personal access token (PAT) as a bearer credential. There is no
6
- parallel REST path — if the CLI needs a capability it lands as an MCP tool
7
- first, then the CLI consumes it (story 7.9 architecture).
3
+ Terminal dispatch of the Motir work loop. The CLI is a client of **Motir's
4
+ public REST API** (`/api/v1`): every command is an ordinary HTTPS request
5
+ carrying a personal access token (PAT) as its bearer. There is no private
6
+ channel — the CLI uses the same documented endpoints, the same credential and
7
+ the same scopes any third-party integration gets, and if it needs a capability
8
+ that capability lands on `/api/v1` first, where everyone can reach it.
9
+
10
+ That is the point rather than an implementation detail: nothing this tool does
11
+ is unavailable to a script you write yourself. The reference is at
12
+ [`/docs/api`](https://app.motir.co/docs/api) and the machine-readable spec at
13
+ [`/api/openapi/v1.json`](https://app.motir.co/api/openapi/v1.json) — the same
14
+ document this package's types are generated from.
15
+
16
+ > It was an MCP client until Story 11.5 (`docs/decisions/cli-v1-client.md`).
17
+ > Motir still SERVES the Model Context Protocol at `/api/mcp`, for agents; the
18
+ > CLI is simply no longer one of its clients, and no longer ships an
19
+ > agent-protocol SDK to everyone who installs it.
8
20
 
9
21
  > **Status (Subtask 7.9.1):** this is the scaffold + auth + link layer. Read
10
22
  > commands (`ready` / `status` / `open` — 7.9.2), single dispatch (`next` /
@@ -43,9 +55,46 @@ pnpm --filter @motir/cli build # produces dist/index.js (the `motir` binary
43
55
  node packages/cli/dist/index.js --help
44
56
  ```
45
57
 
46
- ## Commands (this subtask)
58
+ ## Authenticate
47
59
 
48
60
  ```sh
61
+ motir login
62
+ ```
63
+
64
+ `motir login` is a **device grant**: it prints a short code and a URL, opens
65
+ Motir in your browser, and waits for you to approve it there. Codes last 15
66
+ minutes and nothing is written to disk until you approve. It is **headless by
67
+ construction** — the code and URL are printed whether or not a browser opens, so
68
+ an SSH session or a container uses the same command; `--no-browser` skips the
69
+ launch attempt outright.
70
+
71
+ The approval mints a CLI-scoped PAT: scopes `read`, `work_items:write`,
72
+ `integration` (fixed — the grant can neither widen nor narrow them), 90-day
73
+ expiry, labelled `CLI · <hostname>`. It lands in `~/.config/motir/config.json`,
74
+ `chmod 600`, keyed by server URL.
75
+
76
+ There are three credential tiers, and `motir login` is the middle one:
77
+
78
+ | Tier | How | For |
79
+ | -------------------------- | ---------------------------------- | ------------------------------- |
80
+ | `MOTIR_TOKEN` | export it — no login step, no file | CI, containers, read-only boxes |
81
+ | `motir login` | browser approval | a person at a terminal |
82
+ | `motir auth login --token` | paste a PAT you already hold | scripts, older servers |
83
+
84
+ `MOTIR_TOKEN` is honoured by **every** command (paired with `MOTIR_SERVER` when
85
+ there is no `.motir.json` to walk up to) and outranks a stored credential.
86
+
87
+ **Disconnecting** is two different things: `motir logout` forgets the local copy
88
+ on this machine, while **revoking the token in Settings → Account → API tokens**
89
+ is the server-side kill switch. Full guide: [`docs/cli.md` §
90
+ Authenticate](../../docs/cli.md#authenticate).
91
+
92
+ ## Setup commands
93
+
94
+ ```sh
95
+ motir login [--server <url>] [--no-browser] # connect this terminal
96
+ motir logout [--server <url>] # forget the local credential
97
+
49
98
  motir auth login [--server <url>] [--token <pat>] # validate + store a PAT
50
99
  motir auth status [--server <url>] # server, token prefix, owning user
51
100
  motir auth logout [--server <url>] # forget the stored token
@@ -67,10 +116,19 @@ motir ready [--kinds <list>] [--assignee <id|me|unassigned>] [--json]
67
116
  motir status [--json] # ready / in-flight + active sprint
68
117
  motir sprints [--state <planned|active|complete>] [--json]
69
118
  motir sprint [ref] [--kinds <list>] [--json] # defaults to the ACTIVE sprint
70
- motir show <key> [--json] # one item, in full
119
+ motir show <key> [--activity|--comments] [--json] # one item, in full
71
120
  motir open <key> [--print] # …in the browser
72
121
  ```
73
122
 
123
+ **`motir show --activity` / `--comments`** add the DISCUSSION the aggregate does
124
+ not carry: `--activity` interleaves comment threads with the change trail,
125
+ `--comments` prints the threads alone. Both are opt-in — the stream is a second
126
+ tool call, so a plain `show` stays one round-trip no matter how loud a card got —
127
+ and comment bodies print **in full**, never excerpted. ONE page is printed and
128
+ never drained: when more remains the footer says how much and points at `motir
129
+ open <key>`; with `--json` the activity page rides along **unaltered** under an
130
+ `activity` key. Passing both flags is refused rather than silently resolved.
131
+
74
132
  `motir sprint`'s **`ref` resolves in order**: omitted → the active sprint; then a
75
133
  sprint **id**; then an **exact name**; then a **name prefix** — each
76
134
  case-insensitive, first rule yielding exactly one sprint wins. An ambiguous
@@ -154,9 +212,11 @@ the item in the session exclude list so the next `motir next` moves past it;
154
212
  > `in_progress` status, so if the store cannot be written the CLI warns once and
155
213
  > the run continues rather than aborting.
156
214
 
157
- **Closing out.** After you merge, `motir done <key>`. The default workflow has
158
- no direct `in_progress → done` edge, so an item dispatched with `--print` (which
159
- never observed an agent finish) needs `motir done --via in_review <key>`; an
215
+ **Closing out.** After you merge, `motir done <key>`. Since MOTIR-1625 the
216
+ default workflow carries a direct `in_progress → done` edge, so this is one legal
217
+ hop whether or not the item ever reached In Review. `motir done --via in_review
218
+ <key>` still walks it through review explicitly — useful on a custom workflow
219
+ that has no direct edge, or when you want the review hop on the record. An
160
220
  illegal flip surfaces the server's own allowed-targets error verbatim. A merged
161
221
  **session** PR closes out in bulk with `motir done --session <branch>`.
162
222
 
@@ -452,10 +512,10 @@ pnpm vitest run tests/cli/ # the story suite — the BUILT binary,
452
512
  ```
453
513
 
454
514
  **The package suite** (`packages/cli/test/**`) covers each module in isolation.
455
- Where a module talks to a server it is pointed at a REAL MCP server the test
456
- starts in-process (`test/helpers/mcpTestServer.ts`) with canned tool results —
457
- the transport, framing and error envelopes are the real ones, only the data is
458
- scripted. `test/auto.test.ts` drives the whole `motir auto` loop against a
515
+ Where a module talks to a server it is pointed at a REAL HTTP server the test
516
+ starts in-process (`test/helpers/testServer.ts`) with canned `/api/v1`
517
+ responses — the framing, status handling and URL building are the real ones,
518
+ only the data is scripted. `test/auto.test.ts` drives the whole `motir auto` loop against a
459
519
  scripted server, agent and git, because its load-bearing properties — that it
460
520
  re-queries every iteration, that an integrated item unlocks its dependents
461
521
  mid-run, that `main` is never advanced, and that the pull request opens even when
@@ -463,7 +523,7 @@ the run ended badly — are not visible in any single function.
463
523
 
464
524
  **The story suite** (`tests/cli/cli-story.test.ts`, in the root Vitest lane where
465
525
  Postgres is) spawns the BUILT binary as a child process against the real
466
- `/api/mcp` route, with a scripted fake agent and a recorded fake `gh`. It is what
526
+ `/api/v1` routes, with a scripted fake agent and a recorded fake `gh`. It is what
467
527
  proves the assembled tool works: repo routing into real checkouts, the
468
528
  session-branch cascade, one pull request per touched repo, a `main` nobody
469
529
  advanced, and the help surface of the binary a user actually runs.
@@ -478,6 +538,9 @@ uses; the story suite rides the sharded Vitest job.
478
538
 
479
539
  ## Releasing
480
540
 
541
+ What each version changed, for the person who installs it, is
542
+ [`CHANGELOG.md`](./CHANGELOG.md). Below is how one gets published.
543
+
481
544
  Releases publish to the **public npm registry** via CI — the
482
545
  `.github/workflows/release-cli.yml` workflow, triggered by a package-scoped git
483
546
  tag. There is no manual `npm publish` in the normal path.