mergestorm 0.3.9 → 0.3.15

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 (76) hide show
  1. package/README.md +67 -24
  2. package/dist/api.d.ts +106 -40
  3. package/dist/api.js +245 -9
  4. package/dist/client/index.d.ts +5 -0
  5. package/dist/client/index.js +5 -0
  6. package/dist/commands/branches.d.ts +6 -2
  7. package/dist/commands/branches.js +29 -14
  8. package/dist/commands/browse.d.ts +39 -0
  9. package/dist/commands/browse.js +259 -0
  10. package/dist/commands/credits.js +30 -12
  11. package/dist/commands/help.d.ts +5 -0
  12. package/dist/commands/help.js +93 -0
  13. package/dist/commands/jobs.d.ts +11 -2
  14. package/dist/commands/jobs.js +64 -15
  15. package/dist/commands/login.js +32 -10
  16. package/dist/commands/logout.js +2 -1
  17. package/dist/commands/pr.d.ts +22 -0
  18. package/dist/commands/pr.js +127 -0
  19. package/dist/commands/queue.d.ts +12 -0
  20. package/dist/commands/queue.js +160 -0
  21. package/dist/commands/registry.d.ts +1 -1
  22. package/dist/commands/registry.js +115 -33
  23. package/dist/commands/review-client.d.ts +106 -0
  24. package/dist/commands/review-client.js +399 -0
  25. package/dist/commands/review.d.ts +36 -6
  26. package/dist/commands/review.js +395 -145
  27. package/dist/commands/settings.d.ts +17 -0
  28. package/dist/commands/settings.js +89 -0
  29. package/dist/commands/skill.d.ts +20 -0
  30. package/dist/commands/skill.js +145 -0
  31. package/dist/commands/stack.d.ts +36 -2
  32. package/dist/commands/stack.js +341 -113
  33. package/dist/commands/status.d.ts +18 -2
  34. package/dist/commands/status.js +236 -21
  35. package/dist/commands/whoami.d.ts +3 -1
  36. package/dist/commands/whoami.js +21 -7
  37. package/dist/errors.d.ts +18 -2
  38. package/dist/errors.js +22 -1
  39. package/dist/git-stack.d.ts +2 -0
  40. package/dist/git-stack.js +4 -0
  41. package/dist/git.d.ts +12 -1
  42. package/dist/git.js +52 -7
  43. package/dist/shell.d.ts +1 -1
  44. package/dist/shell.js +39 -28
  45. package/dist/stack-dto.d.ts +266 -0
  46. package/dist/stack-dto.js +7 -0
  47. package/dist/submit-pr-base.d.ts +31 -0
  48. package/dist/submit-pr-base.js +69 -0
  49. package/dist/ui/ansi.d.ts +2 -0
  50. package/dist/ui/ansi.js +2 -0
  51. package/dist/ui/banner.d.ts +34 -2
  52. package/dist/ui/banner.js +170 -79
  53. package/dist/ui/box.d.ts +13 -9
  54. package/dist/ui/box.js +28 -44
  55. package/dist/ui/findings.d.ts +4 -1
  56. package/dist/ui/findings.js +14 -7
  57. package/dist/ui/job-envelope.d.ts +68 -0
  58. package/dist/ui/job-envelope.js +35 -0
  59. package/dist/ui/line-tabs.d.ts +27 -0
  60. package/dist/ui/line-tabs.js +170 -0
  61. package/dist/ui/logo.d.ts +10 -2
  62. package/dist/ui/logo.js +13 -9
  63. package/dist/ui/present.d.ts +10 -0
  64. package/dist/ui/present.js +13 -0
  65. package/dist/ui/prompt.d.ts +148 -0
  66. package/dist/ui/prompt.js +433 -71
  67. package/dist/ui/select.js +1 -1
  68. package/dist/ui/tabs.d.ts +125 -0
  69. package/dist/ui/tabs.js +480 -0
  70. package/dist/ui/usage.d.ts +29 -1
  71. package/dist/ui/usage.js +71 -2
  72. package/dist/ui/width.d.ts +26 -0
  73. package/dist/ui/width.js +262 -0
  74. package/package.json +6 -1
  75. package/skill/SKILL.md +98 -0
  76. package/skill/mergestorm-pr-loop/SKILL.md +76 -0
package/README.md CHANGED
@@ -28,7 +28,7 @@ After install, both `mergestorm` and `mg` invoke the same CLI.
28
28
  ## Source
29
29
 
30
30
  Public source (MIT): [github.com/marginsystems/mergestorm-cli](https://github.com/marginsystems/mergestorm-cli).
31
- Tags there match npm versions (`v0.3.9`, …). Clone, install, and build:
31
+ Tags there match npm versions (`v0.3.13`, …). Clone, install, and build:
32
32
 
33
33
  ```bash
34
34
  git clone https://github.com/marginsystems/mergestorm-cli.git
@@ -41,18 +41,16 @@ node dist/cli.js --help
41
41
 
42
42
  ## Interactive shell
43
43
 
44
- On a TTY, bare `mergestorm` (or `mergestorm shell`) opens a branded REPL: a **full-width** welcome panel (logo + status on the left, tips / what's new on the right) and a **full-width** bordered input box with a live `/` slash-command dropdown. Non-TTY (CI/pipes) prints usage instead — no hanging prompt.
44
+ On a TTY, bare `mergestorm` (or `mergestorm shell`) opens a branded REPL: a compact **full-width** welcome panel (mark, version, status, usage bar) and a **full-width** bordered input box with a live `/` slash-command dropdown. The welcome panel reflows on terminal resize instead of wrapping or smearing. Non-TTY (CI/pipes) prints usage instead — no hanging prompt.
45
45
 
46
46
  ```
47
- ╭─ mergestorm v0.3.9 ──────────────────────────────────────────────────────────╮
48
- │ ▟██████████▛ Tips for getting started │
49
- │ ▜████████▛ review review origin/HEAD or main │
50
- │ ▝▜████▛▘ stack create → submit → restack → land │
51
- │ ▜██▛ /help list all commands │
52
- │ ██ │
53
- │ ▝▘ What's new in v0.3.9 │
54
- │ ● msk… · maelstrom • MIT license + public source (mergestorm-cli) │
55
- │ [████░░░░░░░░░░] 12% used │
47
+ ╭──────────────────────────────────────────────────────────────────────────────╮
48
+ │ ▟██▛ mergestorm v0.3.15 │
49
+ │ ▜▙ ● msk_live_… · maelstrom │
50
+ │ [████████░░░░░░░░░░░░░░░░░░░░░░] 25% used · Resets Sep 5, 10:53am (UTC)│
51
+ │ │
52
+ │ review a diff · usage for tabs · /help for all commands │
53
+ │ New in v0.3.15: PR wait + settings + both skills in the npm tarball │
56
54
  ╰──────────────────────────────────────────────────────────────────────────────╯
57
55
  mergestorm
58
56
  ╭──────────────────────────────────────────────────────────────────────────────╮
@@ -60,15 +58,15 @@ mergestorm
60
58
  ╰──────────────────────────────────────────────────────────────────────────────╯
61
59
  /review Review git diff (default origin/HEAD or main or master)
62
60
 
63
- mergestorm> credits
61
+ mergestorm> usage
64
62
  mergestorm> branches
65
63
  mergestorm> chain
66
64
  mergestorm> exit
67
65
  ```
68
66
 
69
- Bare command names still work exactly as before (`review`, `help`, `exit`, …) — typing `/` at the start of a line just opens the live autocomplete dropdown (filtered as you type, navigate with Up/Down, accept with Tab/Enter/Right). Arrow-key history, Ctrl+A/E, Ctrl+U/K work as in a regular shell. At the idle prompt, **Ctrl+C twice** (within ~1.5s) exits the shell; a single Ctrl+C clears the line and shows a confirm hint. While `review` / `status` is waiting, Ctrl+C detaches or aborts that wait (job may keep running) — it does not exit the shell. Ctrl+D on an empty line, or `exit` / `quit`, also leave the shell. On a dumb terminal, without color, or when piped, the box falls back to plain ASCII borders (or no shell at all for non-TTY input).
67
+ Bare command names still work exactly as before (`review`, `help`, `exit`, …) — typing `/` at the start of a line opens a compact autocomplete overlay (aliases folded onto the primary name, Up/Down scroll a viewport, Esc dismisses, Tab completes, Enter accepts a prefix or submits an exact name as typed, Left/Right move the cursor). Arrow-key history, Ctrl+A/E, Ctrl+U/K work as in a regular shell. At the idle prompt, **Ctrl+C twice** (within ~1.5s) exits the shell; a single Ctrl+C clears the line and shows a confirm hint. While `review` / `status` is waiting, Ctrl+C detaches or aborts that wait (job may keep running) — it does not exit the shell. Ctrl+D on an empty line, or `exit` / `quit`, also leave the shell. On a dumb terminal, without color, or when piped, the box falls back to plain ASCII borders (or no shell at all for non-TTY input).
70
68
 
71
- `credits` / `usage` print a usage meter — long bar + `N% used`, then `Resets … (UTC)` — for standard and premium. `branches` (alias `chains`) lists recently reviewed branches; on a TTY you arrow-select one to open its review-chain timeline. `chain [slug]` shows that timeline directly (defaults to `local/<current-git-branch>`).
69
+ `credits` / `usage` on a TTY open a tabbed **Status / Usage / Jobs** browser (Usage selected): Left/Right switch tabs, Up/Down scroll or select, Enter on a job opens its `status` detail in place, Esc backs out, `q` closes. `status` with no job id opens the same browser on the Status tab. Piped / non-TTY output keeps the static panel: key · plan, a credit bar sized to the terminal, `Resets … (UTC)`, then the last five jobs; `--json` adds `recent_jobs` and is unchanged. `branches` (alias `chains`) lists recently reviewed branches; on a TTY you arrow-select one to open its review-chain timeline. `chain [slug]` shows that timeline directly (defaults to `local/<current-git-branch>`).
72
70
 
73
71
  ## Commands
74
72
 
@@ -81,26 +79,29 @@ mergestorm login Sign in via browser; stores an API key in ~/.mer
81
79
  mergestorm login --key Paste an existing API key instead (headless/CI)
82
80
  mergestorm logout Remove the stored API key
83
81
  mergestorm review [base] [head] Review git diff base...head (default: origin/HEAD or main or master)
84
- mergestorm status <job_id> Fetch a review job and print JSON (one shot)
85
- mergestorm credits [--json] Standard + premium credit balance (usage bars)
82
+ mergestorm status <job_id> Fetch a review job (envelope; --json --wait --timeout)
83
+ mergestorm status Tabbed Status / Usage / Jobs browser (TTY)
84
+ mergestorm credits [--json] Usage panel (bar + last 5 jobs); tabbed browser on a TTY
86
85
  mergestorm jobs [n] [--json] Recent review jobs (default 10, max 50)
87
86
  mergestorm branches [n] Recently reviewed branches (arrow-pick on TTY)
88
87
  mergestorm chain [slug] Branch review-chain timeline (default: current branch)
89
88
  mergestorm whoami [--json] Key prefix, plan, API base, config path
89
+ mergestorm skill install --claude|--cursor Copy the mergestorm-review and mergestorm-pr-loop skills into this repo
90
90
  mergestorm thread <slug> Jobs in a review thread
91
- mergestorm stack create [name] New local stack layer (optional `--onto` / `--trunk`)
92
- mergestorm stack submit Push layers, open chained PRs (`gh`), register via adopt
91
+ mergestorm stack create [name] New local stack layer (optional `--onto` / `--trunk` / `--extend`)
92
+ mergestorm stack submit Push layers, open PRs (`gh`), register via adopt (optional `--extend`)
93
93
  mergestorm stack list [--json] List registered stacks
94
94
  mergestorm stack adopt <owner/repo>#<pr> Import an existing open PR chain
95
95
  mergestorm stack restack <stack-id> Restack descendants
96
96
  mergestorm stack land <stack-id> Land / promote (into review unit when present)
97
- mergestorm stack auto-promote on|off <stack-id> Toggle auto-promote when green
98
97
  mergestorm stack reset --force Clear local authoring state (not branches/PRs)
99
98
  ```
100
99
 
101
- `mg` is a short alias for `mergestorm` (same binary), e.g. `mg stack create`. Happy path: **create → commit → submit → restack → land**. On review-unit stacks, `stack land` **promotes** the tip into the unit (same gates as the dashboard); otherwise it lands the bottom open PR. `stack auto-promote` turns on land-when-green for a registered stack (`auto-land` remains a deprecated alias). `stack adopt` is for importing a chain that already exists on GitHub (legacy / Graphite). Restack/land use the same login key (`/api/v1/stacks`).
100
+ `mg` is a short alias for `mergestorm` (same binary), e.g. `mg stack create`. Happy path: **create → commit → submit → restack → land**. On review-unit stacks, `stack land` **promotes** the tip into the unit (same gates as the dashboard); otherwise it lands the bottom open PR. `stack adopt` is for importing a chain that already exists on GitHub (legacy / Graphite). Restack/land use the same login key (`/api/v1/stacks`). Unattended landing is `mg queue add`.
101
+
102
+ `stack create` checks out a new branch from the current tip (or `--onto <branch>`), discovers trunk (`main` / `master` / `origin/HEAD`, overridable with `--trunk`), and records `{ branch, parentBranch }` in CLI-managed state under **`~/.mergestorm/stacks/<repo-id>/stack.json`**. The CLI updates this automatically; never edit it. Linked worktrees share state, while independent clones remain isolated. Creating onto trunk with a non-empty active stack starts a new one. `--trunk` only sets trunk metadata — it does **not** change the parent; use `--onto main` (etc.) for a fresh stack from trunk.
102
103
 
103
- `stack create` is local-only: it checks out a new branch from the current tip (or `--onto <branch>`), discovers trunk (`main` / `master` / `origin/HEAD`, overridable with `--trunk`), and records `{ branch, parentBranch }` in CLI-managed state under **`~/.mergestorm/stacks/<repo-id>/stack.json`**. The CLI updates this automatically; never edit it. Linked worktrees share state, while independent clones remain isolated. Creating onto trunk with a non-empty active stack starts a new one. No repository file, GitHub call, or API call is made.
104
+ If the parent branch is already a layer of a **registered** (submitted) stack, `create` and `submit` refuse unless you pass **`--extend`**. That blocks accidentally gluing an unrelated PR onto an open unit. Growing a registered stack on purpose: `mg stack create --onto <tip> --extend` → commit → `mg stack submit --extend`.
104
105
 
105
106
  `stack submit` walks the **active** local stack: `git push -u origin` each layer, opens a PR with `gh` (`--base` = parent or trunk; skips heads that already have an open PR; body from the tip commit — Summary + Test plan, preserving Fixes/Closes/Resolves), registers the stack with `POST /api/v1/stacks/adopt` internally (Mergestorm API key), then drops that local stack entry so the next create onto trunk is clean. Push/PR auth is your local `git` + `gh auth` — not a GitHub App installation token.
106
107
 
@@ -118,19 +119,38 @@ Removes `~/.mergestorm/config.json` so the stored key is no longer used.
118
119
 
119
120
  ### `review [base] [head]`
120
121
 
121
- Collects `git diff base...head` (default: discovered trunk — `origin/HEAD`, `main`, or `master`), attaches the changed file contents (up to 40 files, skipping files > 400 KB), submits the job, and polls until it finishes (~3 min max). The thread slug is derived from the current branch (`local/<branch>`), so repeated runs on the same branch chain their findings. Programmatic callers can provide explicit review context through the Review Jobs API.
122
+ Collects `git diff base...head` (default: discovered trunk — `origin/HEAD`, `main`, or `master`), attaches the changed file contents (up to 40 files, skipping files > 400 KB), submits the job, and polls until it finishes (~8 min max — Core plus a Max fleet can exceed 3 minutes). The thread slug defaults to the current branch (`local/<branch>`); pass `--thread` to override so follow-ups chain on a chosen slug. The CLI does not scan `.mergestorm/context/`.
122
123
 
123
124
  ```bash
124
125
  mergestorm review # discovered trunk (origin/HEAD, main, or master)...HEAD
125
126
  mergestorm review develop # develop...HEAD
126
127
  mergestorm review main feat/x # main...feat/x
128
+ mergestorm review main --router max
129
+ mergestorm review main --router manual --specialists security,frontend
130
+ mergestorm review --json --context "focus on auth" --context-file docs/adr/007.md
127
131
  ```
128
132
 
129
- Exit code is non-zero on quota limit (402), submission failure, a `failed`/`quota_exceeded` job, or a poll timeout. In the interactive shell, Ctrl+C during the wait detaches (job keeps running) — use `status <job_id>` later.
133
+ `--router` is the same smart-router mode as Agents settings (`off` / `standard` / `max` / `manual`). `--specialists` pins or invokes lanes on that request (comma-separated). Omit both to use the signed-in user's saved fleet settings (paid default is Standard, same as the dashboard). Manual accepts up to 5 lane ids — the same cap as Agents (the smart router caps `standard` at 3 and `max` at 5).
134
+
135
+ `--context` is author guidance (or `--context -` to read stdin). `--context-file` is repeatable up to 10 files (16 KB each, 60 KB total). `--idempotency-key` replays a prior 202 for the same key. `--webhook-url` must be https; the one-time `webhook_secret` is printed only in `--json` output. Webhook delivery is best-effort (no retry).
136
+
137
+ Exit codes for `review` and `status`:
138
+
139
+ | Exit | Meaning |
140
+ |------|---------|
141
+ | 0 | Success (`completed` or `no_changes`) |
142
+ | 2 | Usage / bad flags |
143
+ | 3 | Quota (`402` or `quota_exceeded`) |
144
+ | 4 | Failed job or other submission error |
145
+ | 5 | Poll / request timeout |
146
+ | 6 | Auth (missing or invalid API key) |
147
+ | 7 | Rate limited (`429`) — wait `retry_after_seconds`, or check a running review with `mergestorm jobs` / `status` |
148
+
149
+ In the interactive shell, Ctrl+C during the wait detaches (job keeps running) — use `status <job_id>` later.
130
150
 
131
151
  ### `status <job_id>`
132
152
 
133
- Fetches a job by id and prints the raw JSON (status, verdict, summary, findings). In the shell, output is formatted for reading.
153
+ Fetches a job by id. One-shot default (and `--json` in either mode) prints the same `mergestorm.review_job/v1` object as `review --json`. `--wait [--timeout seconds]` polls until the job finishes; timeout is exit 5 with the id in the object. In the shell, default output is pretty (requested vs run specialists and credits).
134
154
 
135
155
  ### `credits` / `jobs` / `whoami`
136
156
 
@@ -148,6 +168,29 @@ Require a logged-in key and API support for `GET /api/v1/me` and `GET /api/v1/re
148
168
  | `MERGESTORM_API_URL` | API base URL | `https://api.mergestorm.ai` |
149
169
  | `NO_COLOR` | Disable ANSI colors | — |
150
170
 
171
+ ## Verify (public source vs npm)
172
+
173
+ Build **only** from [marginsystems/mergestorm-cli](https://github.com/marginsystems/mergestorm-cli). Tags there (`vX.Y.Z`) match npm versions. Compare your local pack to the registry hashes below (or `npm view mergestorm@VERSION dist`).
174
+
175
+ | npm | Public git tag | Public commit | npm `dist.shasum` (sha1) | npm `dist.integrity` |
176
+ |-----|----------------|---------------|--------------------------|----------------------|
177
+ | `0.3.9` | [`v0.3.9`](https://github.com/marginsystems/mergestorm-cli/tree/v0.3.9) | `89eaebc29cf793db52baf3e9af0f2bed6e42e458` | `f904f4f642a07c0f9716fe36ed9e5a813be47530` | `sha512-zkbEhwkog13xC70LcM77bWFzLTyoE7Q81daaxz/1Gk3IqVyEoyhKpR+PAtfTp+Mk3MqJ7yVhvZ8/9UG4hpT/Dw==` |
178
+
179
+ ```bash
180
+ git clone https://github.com/marginsystems/mergestorm-cli.git
181
+ cd mergestorm-cli
182
+ git checkout v0.3.9
183
+ git rev-parse HEAD # expect 89eaebc29cf793db52baf3e9af0f2bed6e42e458
184
+ npm ci
185
+ npm run build
186
+ npm pack
187
+ shasum -a 1 mergestorm-0.3.9.tgz
188
+ # expect f904f4f642a07c0f9716fe36ed9e5a813be47530
189
+ # also: npm view mergestorm@0.3.9 dist.shasum dist.integrity
190
+ ```
191
+
192
+ After each release, the new row’s git commit is the public `v*` tag tip; shasum/integrity come from the npm registry for that version.
193
+
151
194
  ## See also
152
195
 
153
196
  - [Public source — mergestorm-cli](https://github.com/marginsystems/mergestorm-cli)
package/dist/api.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { type Config } from "./config.js";
2
+ import type { MergeQueueEntryDto, StackDto } from "./stack-dto.js";
3
+ export type { MergeQueueBounceDetail, MergeQueueBounceKind, MergeQueueEnqueuedBy, MergeQueueEnqueuedVia, MergeQueueEntryDto, MergeQueueEntryState, StackBranchState, StackCiStatus, StackDto, StackLayerChecks, StackLayerDto, StackReviewStatus, StackTempestStatus, StackUnitDto, StackUnitMemberDto, } from "./stack-dto.js";
2
4
  /** Default per-request timeout so a hung API cannot stall the shell/CI forever. */
3
5
  export declare const DEFAULT_API_TIMEOUT_MS = 30000;
4
6
  /** Message prefix of the CommandError thrown when a request exceeds its timeout. */
@@ -8,10 +10,17 @@ export type ApiFetchInit = RequestInit & {
8
10
  /** Override {@link DEFAULT_API_TIMEOUT_MS}. */
9
11
  timeoutMs?: number;
10
12
  };
11
- export declare function apiFetch(cfg: Config, route: string, init?: ApiFetchInit): Promise<{
13
+ export type ApiFetchResult = {
12
14
  status: number;
13
15
  body: unknown;
14
- }>;
16
+ retryAfterSeconds?: number;
17
+ };
18
+ /** Prefer the larger of `Retry-After` and JSON `retry_after_seconds`. */
19
+ export declare function parseRetryAfterSeconds(input: {
20
+ header?: string | null;
21
+ body?: unknown;
22
+ }): number | undefined;
23
+ export declare function apiFetch(cfg: Config, route: string, init?: ApiFetchInit): Promise<ApiFetchResult>;
15
24
  export declare function devicePost(base: string, route: string, json: unknown, opts?: {
16
25
  timeoutMs?: number;
17
26
  signal?: AbortSignal;
@@ -28,7 +37,7 @@ export type MeResponse = {
28
37
  };
29
38
  plan_key: string;
30
39
  plan_label_key?: string;
31
- /** Start of next UTC month (usage meters reset). Older APIs omit this. */
40
+ /** When the current credit window ends (signup anniversary or Stripe period). Older APIs omit this. */
32
41
  resets_at?: string;
33
42
  usage: {
34
43
  standard: {
@@ -36,11 +45,6 @@ export type MeResponse = {
36
45
  limit: number | null;
37
46
  remaining: number | null;
38
47
  };
39
- premium: {
40
- used: number;
41
- limit: number | null;
42
- remaining: number | null;
43
- };
44
48
  };
45
49
  };
46
50
  export type JobListItem = {
@@ -53,7 +57,9 @@ export type JobListItem = {
53
57
  head_label: string | null;
54
58
  created_at: string;
55
59
  finished_at: string | null;
56
- credits: number;
60
+ credits: {
61
+ standard: number;
62
+ } | null;
57
63
  };
58
64
  export type ThreadListItem = {
59
65
  slug: string;
@@ -88,50 +94,110 @@ export type ThreadDetail = {
88
94
  finished_at?: string | null;
89
95
  }[];
90
96
  };
91
- /** Fetch /api/v1/me; returns null on 404/network so callers can degrade. */
92
- export declare function getMe(cfg?: Config, opts?: {
93
- timeoutMs?: number;
94
- }): Promise<MeResponse | null>;
95
- export declare function listJobs(limit?: number, cfg?: Config): Promise<JobListItem[]>;
96
- export type StackLayerDto = {
97
- branch: string;
98
- parentBranch: string | null;
99
- prNumber: number;
100
- position: number;
101
- state: string;
102
- title: string | null;
103
- htmlUrl: string | null;
104
- ciStatus: string;
105
- reviewStatus: string;
106
- checks: {
107
- total: number;
108
- success: number;
109
- pending: number;
110
- failure: number;
111
- failingName: string | null;
112
- } | null;
113
- conflictDetail: string | null;
114
- lastRestackedSha: string | null;
97
+ export type PrReviewFinding = {
98
+ path?: string;
99
+ line?: number;
100
+ severity: string;
101
+ body: string;
102
+ title?: string;
103
+ specialist?: string;
115
104
  };
116
- export type StackDto = {
105
+ export type PrReviewFindings = {
106
+ specialists_run?: string[];
107
+ inline?: PrReviewFinding[];
108
+ off_diff?: PrReviewFinding[];
109
+ offDiff?: PrReviewFinding[];
110
+ patchPolicy?: unknown;
111
+ };
112
+ export type PrVortexReview = {
113
+ schema: "mergestorm.pr_review/v1";
117
114
  id: string;
118
115
  owner: string;
119
116
  repo: string;
120
- trunkBranch: string;
121
- autoPromoteWhenGreen: boolean;
122
- layers: StackLayerDto[];
117
+ pr_number: number;
118
+ status: string;
119
+ raw_status?: string;
120
+ phase: string | null;
121
+ verdict: string | null;
122
+ summary?: string | null;
123
+ head_sha: string | null;
124
+ review_count: number;
125
+ skip_reason: string | null;
126
+ reviewed_at: string | null;
127
+ finding_count: number;
128
+ findings: PrReviewFindings | null;
129
+ patch_policy: unknown | null;
130
+ };
131
+ /**
132
+ * Bearer-writable settings keys, mirroring the `/api/v1/settings` allowlist.
133
+ * The connected flags are read-only there and deliberately absent here.
134
+ */
135
+ export declare const SETTINGS_WRITABLE_KEYS: readonly ["auto_review_enabled", "auto_patch_enabled", "vortex_show_thinking_traces", "repo_overview_enabled", "review_unit_land_prs_enabled", "cyclone_review_unit_land_prs_enabled", "vortex_seam_specialist_enabled"];
136
+ export type SettingsWritableKey = (typeof SETTINGS_WRITABLE_KEYS)[number];
137
+ export type SettingsPatch = Partial<Record<SettingsWritableKey, boolean>>;
138
+ /** GET and PATCH `/api/v1/settings` both answer with this shape. */
139
+ export type SettingsResponse = Record<SettingsWritableKey, boolean> & {
140
+ cyclone_connected: boolean;
141
+ github_connected: boolean;
123
142
  };
143
+ /**
144
+ * Fetch Bearer /api/v1/settings; null on 404/network/timeouts so panels can
145
+ * degrade (same contract as {@link getMe}), while 401 still surfaces.
146
+ */
147
+ export declare function getSettings(cfg?: Config, opts?: {
148
+ timeoutMs?: number;
149
+ }): Promise<SettingsResponse | null>;
150
+ /**
151
+ * PATCH Bearer /api/v1/settings and return the stored result. Rejections
152
+ * (unknown key, cyclone_not_connected, …) surface the API's own `message`
153
+ * so the CLI never invents a reason.
154
+ */
155
+ export declare function patchSettings(patch: SettingsPatch, cfg?: Config, opts?: {
156
+ timeoutMs?: number;
157
+ }): Promise<SettingsResponse>;
158
+ /** Fetch /api/v1/me; returns null on 404/network so callers can degrade. */
159
+ export declare function getMe(cfg?: Config, opts?: {
160
+ timeoutMs?: number;
161
+ }): Promise<MeResponse | null>;
162
+ export declare function listJobs(limit?: number, cfg?: Config, opts?: {
163
+ timeoutMs?: number;
164
+ }): Promise<JobListItem[]>;
165
+ /** Fetch one review job (Bearer GET /api/v1/reviews/:id). */
166
+ export declare function getReview(jobId: string, cfg?: Config, opts?: {
167
+ signal?: AbortSignal;
168
+ timeoutMs?: number;
169
+ }): Promise<unknown>;
170
+ /** Fetch the latest Vortex pass for one GitHub PR. */
171
+ export declare function getPrVortexReview(owner: string, repo: string, prNumber: number, cfg?: Config, opts?: {
172
+ signal?: AbortSignal;
173
+ timeoutMs?: number;
174
+ }): Promise<PrVortexReview>;
124
175
  /** List stacks (Bearer GET /api/v1/stacks). */
125
- export declare function listStacks(cfg?: Config): Promise<StackDto[]>;
176
+ export declare function listStacks(cfg?: Config, opts?: {
177
+ timeoutMs?: number;
178
+ }): Promise<StackDto[]>;
179
+ /** Fetch one owned stack with enriched GitHub checks and agent state. */
180
+ export declare function getEnrichedStack(stackId: string, cfg?: Config, opts?: {
181
+ timeoutMs?: number;
182
+ }): Promise<StackDto | null>;
126
183
  /** Adopt an open PR chain (Bearer POST /api/v1/stacks/adopt). */
127
184
  export declare function adoptStack(owner: string, repo: string, prNumber: number, cfg?: Config): Promise<unknown>;
185
+ /** Mint or reuse the PR3+ park freeze (Bearer POST /api/v1/stacks/:id/ensure-upper-park). */
186
+ export declare function ensureUpperPark(stackId: string, cfg?: Config): Promise<{
187
+ freezeBranch: string;
188
+ created: boolean;
189
+ }>;
128
190
  /** Restack descendants (Bearer POST /api/v1/stacks/:id/restack). */
129
191
  export declare function restackStack(stackId: string, cfg?: Config): Promise<unknown>;
130
192
  /** Land the bottom open layer (Bearer POST /api/v1/stacks/:id/land-next). */
131
193
  export declare function landNextStack(stackId: string, cfg?: Config, opts?: {
132
194
  prNumber?: number;
133
195
  }): Promise<unknown>;
134
- /** Toggle auto-promote when green (Bearer PATCH /api/v1/stacks/:id). */
135
- export declare function setStackAutoPromote(stackId: string, autoPromoteWhenGreen: boolean, cfg?: Config): Promise<unknown>;
196
+ /** List the authenticated user's live merge-queue entries. */
197
+ export declare function listMergeQueueEntries(cfg?: Config): Promise<MergeQueueEntryDto[]>;
198
+ /** Enqueue a stack for verified landing. */
199
+ export declare function enqueueStack(stackId: string, cfg?: Config): Promise<unknown>;
200
+ /** Cancel a live merge-queue entry by entry id. */
201
+ export declare function cancelMergeQueueEntry(entryId: string, cfg?: Config): Promise<unknown>;
136
202
  /** Recently reviewed branches/threads (Bearer GET /api/v1/threads). */
137
203
  export declare function listThreads(limit?: number, cfg?: Config): Promise<ThreadListItem[]>;