@remits/remits-cli 0.1.110 → 0.1.112

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@remits/remits-cli",
3
- "version": "0.1.110",
3
+ "version": "0.1.112",
4
4
  "description": "Local CLI for auth, component sync, and live test execution against Remits",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -21,7 +21,11 @@ description: Use remits-cli for fast branch-scoped component staging, test execu
21
21
  - [Big Picture: How remits-cli State Is Organized](#big-picture-how-remits-cli-state-is-organized)
22
22
  - [Support Ticket Mental Model](#support-ticket-mental-model)
23
23
  - [You are an agent, and you register yourself](#you-are-an-agent-and-you-register-yourself)
24
- - [The loop](#the-loop)
24
+ - [Autonomous: one ticket, one process](#autonomous-one-ticket-one-process)
25
+ - [If you are the worker](#if-you-are-the-worker)
26
+ - [Moving a ticket through its lifecycle](#moving-a-ticket-through-its-lifecycle)
27
+ - [When a worker needs a decision from a human](#when-a-worker-needs-a-decision-from-a-human)
28
+ - [The manual loop](#the-manual-loop)
25
29
  - [Efficiency Rules](#efficiency-rules)
26
30
  - [Account Repository Index](#account-repository-index)
27
31
  - [Two Workflows](#two-workflows)
@@ -109,8 +113,10 @@ description: Use remits-cli for fast branch-scoped component staging, test execu
109
113
  - [Multi-Session Support](#multi-session-support)
110
114
  - [Registering This Session As An Agent](#registering-this-session-as-an-agent)
111
115
  - [What registration actually does](#what-registration-actually-does)
116
+ - [What `serve` adds](#what-serve-adds)
112
117
  - [Resolving which agent a command means](#resolving-which-agent-a-command-means)
113
118
  - [Which agent gets a ticket](#which-agent-gets-a-ticket)
119
+ - [Why a routed ticket might not have started](#why-a-routed-ticket-might-not-have-started)
114
120
  - [Background Service and Control Center](#background-service-and-control-center)
115
121
  - [Control Center](#control-center)
116
122
  - [Configuring the Preferred Agent](#configuring-the-preferred-agent)
@@ -291,8 +297,8 @@ every live component present at its real id, and nothing extra.
291
297
  | Command | What it touches | Danger |
292
298
  |---|---|---|
293
299
  | `remits-cli components stage` (alias: deprecated `push`) | **Redis staging cache only.** Never mutates the DB or git. The safe iteration surface. | none |
294
- | `remits-cli components status` | Reads the local branch/user staging scope and branch resolution. | none |
295
- | `remits-cli components clear` | Clears the local branch/user staging cache without changing DB or git. | none |
300
+ | `remits-cli components status` | Reads this lane's staging scope (account/user/branch/workspace) and branch resolution, and lists every other lane on the branch. | none |
301
+ | `remits-cli components clear` | Clears THIS lane's staging cache without changing DB or git. Never touches another workspace lane. | none |
296
302
  | `remits-cli components sync` **on trunk** | **Server-side git→DB reconcile of the whole account** (create/update/**delete**/rename). Reads the pushed remote; ignores local files. | **high** |
297
303
  | `remits-cli components sync` **on a variant branch** | Writes `ComponentVariant` overlays for that branch only. Never touches trunk rows or the account's trunk branch. When the checkout identifies a subscribing account, the branch-local `account-info.json` is refreshed for that subscriber; `--dry-run` reports the plan without writes. | medium (a missing file becomes a **tombstone** that hides the component from subscribers) |
298
304
  | `remits-cli components commit` | **One shot:** `git add -A` + commit + `git push` + **`components sync`** + `git pull --ff-only`. Blindly stages the *entire* working tree (including any drift) and reconciles it into prod. Inherits the danger of whichever sync mode the branch selects. | **highest on trunk** |
@@ -306,7 +312,7 @@ Key implications:
306
312
  - **`components sync` acts on the pushed remote**, so local edits are invisible to it until committed **and
307
313
  pushed**, and a drifted **remote** is dangerous even when your local tree looks fine.
308
314
  - After a successful non-dry-run `components sync` / `components commit`, the server clears the full
309
- branch/user staging scope. This is the expected clean state: old Redis aliases should not keep shadowing
315
+ staging scope for that lane (account/user/branch/workspace). This is the expected clean state: old Redis aliases should not keep shadowing
310
316
  the newly synced DB rows. `components sync --dry-run` intentionally leaves staging untouched.
311
317
 
312
318
  ### Intended workflows
@@ -462,17 +468,21 @@ workflows, and never one product's view of it.
462
468
 
463
469
  ### You are an agent, and you register yourself
464
470
 
465
- **If the user says anything like "register to become a support agent", run exactly this and nothing
466
- else first:**
471
+ **If the user says anything like "register to become a support agent", or "work support tickets",
472
+ run exactly this and nothing else first:**
467
473
 
468
474
  ```bash
469
- remits-cli agent register
475
+ remits-cli agent serve
470
476
  ```
471
477
 
472
478
  No flags, no setup, **no need to be in an account repo** — run it from wherever the session started.
473
479
  It registers this terminal for every account repo indexed on this machine that your user can reach,
474
- against the production platform and the production lane, and prints the accounts it was accepted for.
475
- It also prints the support loop; follow it.
480
+ against the production platform and the production lane, and then **starts working tickets on its
481
+ own**. It returns immediately; a background supervisor does the rest.
482
+
483
+ Use `remits-cli agent register` instead **only** when the user wants presence without autonomy — a
484
+ human, or you in this very tab, will work the tickets by hand. Registering alone starts nothing: it
485
+ makes the session routable and then waits to be asked.
476
486
 
477
487
  Three tabs running an agent are three agents. Each is independently routable, each reports its own
478
488
  activity, and each stops receiving work when its tab closes — a heartbeat anchored to the session dies
@@ -487,27 +497,67 @@ Two facts about a ticket are separate and must stay separate:
487
497
  | Fact | Field | Means |
488
498
  |---|---|---|
489
499
  | **Routed** | `routedAgentId` | which agent session should pick this up — delivery |
500
+ | **Claimed** | `claimedAgentId` | a worker process is running on it *right now* |
490
501
  | **Owned** | `assignedTo` | who has claimed it — accountability |
491
502
  | **Status** | `status` | where it is in the workflow |
492
503
 
493
504
  A ticket routed to you is not yet yours. Claim it with `accept`, and the queue then shows it owned.
494
505
 
495
- ### The loop
506
+ The **claim** is the supervisor's, not yours — it exists so two workers never start on one ticket,
507
+ and it expires on its own so a killed worker cannot park a ticket forever. You do not manage it.
508
+
509
+ ### Autonomous: one ticket, one process
510
+
511
+ ```bash
512
+ remits-cli agent serve # workers are whichever agent THIS session is
513
+ remits-cli agent serve --worker-agent codex --max-concurrent 2
514
+ remits-cli agent serve --mode investigate # read-only workers: no file edits
515
+ remits-cli agent workers # what is running right now
516
+ remits-cli agent release # stop serving, go offline
517
+ ```
518
+
519
+ **Run it in a plain terminal tab.** That tab becomes the agent host: `serve` returns immediately, a
520
+ detached supervisor is anchored to the tab's shell, and closing the tab stops the agent. Nothing in
521
+ that tab is an AI session — the AI only ever appears as the worker processes the supervisor spawns.
522
+
523
+ Starting it from inside an AI session works too and self-detects the worker kind, but it is the
524
+ lesser setup: it parks an interactive session as a heartbeat holder while its workers do the work.
496
525
 
497
- After `register`, **no agent command needs a flag** — they reuse the platform, lane and identity this
498
- session registered with.
526
+ When a ticket is routed to this session, the supervisor launches **a fresh headless agent process
527
+ for that ticket**, in that account's repo, with a brief the platform generates. That process exits
528
+ when the ticket is done.
529
+
530
+ **One ticket = one process is the point, and it is why nothing here ever needs `/clear`.** Context
531
+ grooming cannot be a discipline: `/clear` and `/new` are commands a *human types into a TUI*, and no
532
+ model can invoke them — so a long-lived session working ticket after ticket has no way to reset
533
+ itself. A process that exits has nothing to reset. Do not try to solve context growth by being tidy
534
+ inside one session; let the session end.
535
+
536
+ **`serve` returns immediately, and that is correct.** Do not follow it with a wait, a poll, or a
537
+ loop. The supervisor is detached precisely so this tab is free. Report that you are serving and
538
+ stop; you have not left the job half done.
539
+
540
+ What the supervisor handles for you, so you do not have to think about any of it: collecting routed
541
+ work, claiming each ticket so no second worker starts on it, renewing that claim while the worker
542
+ runs, reporting the worker's activity to the dashboard, dropping the claim when it exits, retrying a
543
+ failed ticket once, and releasing a ticket back to the queue when it has failed too often. Closing
544
+ the terminal stops everything and hands any in-flight work back.
545
+
546
+ ### The manual loop
547
+
548
+ Only when the session registered with `agent register` rather than `agent serve`.
499
549
 
500
550
  ```bash
501
551
  remits-cli agent work --wait 600 # returns as soon as work arrives
502
552
  remits-cli agent status --state working --ticket 22454 --activity "reproducing the upload failure"
503
553
  # ... investigate, fix, verify — keep `status` current as what you are doing changes ...
504
- # ... close the ticket lifecycle through mcp_support_ticket (accept -> update_status -> complete) ...
554
+ # ... close the ticket lifecycle through remits-cli ticket (accept -> status -> complete, ask, or release) ...
505
555
  remits-cli agent status --state idle # then ask for work again
506
556
  ```
507
557
 
508
- **Stay on duty.** When `agent work` returns nothing, ask again — do not stop and wait to be
509
- re-prompted. Registration persists for the life of the session (the heartbeat keeps you visible and
510
- routable even while you are not polling), but collecting work is something you have to do.
558
+ **Nothing wakes this tab.** A routed ticket sits there until someone in this session asks for it, so
559
+ if you are working the manual loop you have to keep asking. If you find yourself wishing you could
560
+ be woken up, that is what `agent serve` is.
511
561
 
512
562
  **Report what you are doing.** `agent status` is how an operator watching the dashboard, or another
513
563
  agent, knows this session is alive and what it is on. It costs one command and it is the difference
@@ -519,10 +569,24 @@ timer.
519
569
  local directory through `~/.remits-cli/account-repos.json` and `cd` there before making changes. You
520
570
  registered from anywhere; you do not fix anything from anywhere.
521
571
 
522
- **Lane note:** `register` defaults to the production lane because a support agent works real tickets.
572
+ **Capacity is real, not advisory.** A serving session tells the platform how many workers it can run
573
+ (`--max-concurrent`, default 1), and the router will not send it more than that. So a session at
574
+ capacity is skipped in favour of one that is free, rather than accumulating tickets it will never
575
+ start.
576
+
577
+ **Lane note:** `register` and `serve` default to the production lane because a support agent works real tickets.
523
578
  `--data-mode test` registers a fixture agent instead, which will never be routed a production ticket —
524
579
  use it only when you are deliberately testing the routing itself.
525
580
 
581
+ ### If you are the worker
582
+
583
+ You know you are one when `REMITS_SUPPORT_TICKET_ID` is set in your environment. Your whole job is
584
+ that one ticket, and your brief is your prompt — follow it. Two things it says that are worth
585
+ repeating: **report progress** with `remits-cli agent status --ticket <id> --activity "..."` (a
586
+ headless run is invisible otherwise), and **end in a terminal state** — `complete` with a real
587
+ resolution, or `update_status` with what you established and what the next agent should try. Exiting
588
+ quietly leaves a ticket that looks in-flight forever.
589
+
526
590
  ### Seeing the queue as a human does
527
591
 
528
592
  `remits-cli start` opens a browser control center showing the same facts you are acting on: which
@@ -530,7 +594,79 @@ agents are registered and what each is doing, which tickets are open, and which
530
594
  to. An operator can route a ticket to a specific agent from there. It is a view, not a second system —
531
595
  what it shows and what `remits-cli agent work` returns come from the same records.
532
596
 
533
- Use `mcp_support_ticket` to manage lifecycle:Use `mcp_support_ticket` to manage lifecycle:
597
+ ### Agent components are workers too
598
+
599
+ An Agent component that works support tickets must register itself in the same presence registry as
600
+ CLI sessions. That makes it visible in `cliAgents()` and `remits-cli agent map`, and lets
601
+ `dispatch(...)` / `ticket route` target it by the same `agentId` field:
602
+
603
+ ```groovy
604
+ def me = workerId() // component:Agent:34
605
+ registerWorker([agentId: me, label: 'Support Triage Agent'])
606
+ def work = workerWork([agentId: me, runId: threadGroupingId()])
607
+ workerStatus([agentId: me, ticketId: work.tickets[0]?.id, activity: 'investigating'])
608
+ ```
609
+
610
+ `workerWork(...)` is the component-side analogue of `remits-cli agent work` — the same code runs behind
611
+ both, so a component and a terminal session get the same answer to the same question. It reads tickets
612
+ routed to that worker, claims what it may start, sweeps eligible unrouted work when it is idle (reported
613
+ separately as `sweptTicketIds`), takes the repository edit lease when available, and returns `phase`,
614
+ `brief`, `briefFacts`, and `editLease`. `phase:'editing'` means the component may edit and stage;
615
+ `phase:'investigating'` means another worker holds the repo lease and the component must stay read-only.
616
+ When a component reaches a resting point, pass `agentId` to `complete(...)`, `ask(...)`, or
617
+ `release(...)` so the ticket verb frees the edit lease and drops its claim.
618
+
619
+ Route to a component by its **id** (`component:Agent:34`) — that is what `workerId()` returns and what
620
+ the component polls on. `ticket route --agent component:Agent:MyAgent` also works: the name is resolved
621
+ and the id form is what gets stored.
622
+
623
+ ### Moving a ticket through its lifecycle
624
+
625
+ **`remits-cli ticket` is the platform surface, and it is what you should reach for.** It reads and
626
+ writes the platform's own ticket record, so the same commands work on every Remits platform.
627
+
628
+ ```bash
629
+ remits-cli ticket read --ticket 22454 # the full record
630
+ remits-cli ticket accept --ticket 22454 # claim it before changing anything
631
+ remits-cli ticket progress --ticket 22454 --summary "Traced it to the posting Action" --category investigation
632
+ remits-cli ticket status --ticket 22454 --status in_progress
633
+ remits-cli ticket complete --ticket 22454 --resolution "What you found and did"
634
+ remits-cli ticket ask --ticket 22454 --question "Re-issue or skip?" --context "412 affected"
635
+ remits-cli ticket reply --ticket 22454 --message "Skip them."
636
+ remits-cli ticket release --ticket 22454 # hand it back to the queue
637
+ ```
638
+
639
+ ### When a worker needs a decision from a human
640
+
641
+ There are **three** ways a run can end, not two, and the third is what stops an agent guessing:
642
+
643
+ | Outcome | Verb | Means |
644
+ |---|---|---|
645
+ | Done | `ticket complete --resolution` | finished, here is what I did |
646
+ | **Blocked on a choice** | `ticket ask --question` | I understand the work; the DECISION is not mine |
647
+ | Could not finish | `ticket status --status pending_review` + `ticket progress` | stuck, here is the hand-off |
648
+
649
+ `ask` puts the question on the ticket as an outbound message and parks it. The queue then shows it as
650
+ **awaiting a response** — distinct from "done, review me", which `pending_review` alone cannot express.
651
+
652
+ Someone answers with `remits-cli ticket reply --message "..."` (or through an operator Embeddable).
653
+ That **re-routes the ticket by default**, so the supervisor's next poll starts a **fresh worker whose
654
+ brief already contains the exchange**. Resumption costs nothing because a worker is one process per
655
+ ticket — there is no session to restore.
656
+
657
+ Ask when the choice is genuinely not yours: which of two behaviours is wanted, whether to touch live
658
+ data, an ambiguity in the request. Do not ask for reassurance about something you can determine
659
+ yourself, and ask **once**, with the options laid out.
660
+
661
+ Inside an autonomous worker `--ticket` defaults to the ticket that worker was launched for.
662
+
663
+ A refusal is an **answer**: "accept it first", "already assigned to someone else", "reopen it
664
+ first". Act on the sentence — do not go looking for another tool that lets you skip the step.
665
+
666
+ **`mcp_support_ticket` is an account convention, not a platform guarantee.** It belongs to one
667
+ particular System Account: it may not exist on the platform you are on, it scopes to its own
668
+ account, and it will refuse a ticket owned by a different one. Use it only when you are working in
669
+ that account and want its product-specific workflow on top of the record. It offers:
534
670
  - `read` — always start here to load current state
535
671
  - `accept` — claim the ticket so other agents do not work it concurrently
536
672
  - `update_status` — move to `in_progress` or `pending_review`
@@ -1071,7 +1207,7 @@ If verification reveals issues, repeat the loop: **edit → stage → run**. Eve
1071
1207
  Don't ask the user for permission to re-iterate — just do it. Only stop to ask if you're stuck or unsure about the intended behavior.
1072
1208
 
1073
1209
  If the work is tied to a support ticket:
1074
- - Use `mcp_support_ticket` to mark the ticket `in_progress` once you have started substantive work.
1210
+ - Use `remits-cli ticket status --status in_progress` once you have started substantive work.
1075
1211
  - If a new reply arrives, re-read the ticket and incorporate the reply into your current plan.
1076
1212
 
1077
1213
  #### Step 6: Update Documentation
@@ -1151,8 +1287,8 @@ unexpectedly, stop and inspect the repo-local session log before running any mut
1151
1287
  If the request came from a support ticket, the task is not complete until you update the ticket lifecycle yourself:
1152
1288
 
1153
1289
  1. Re-read the ticket if needed to confirm the latest state and replies.
1154
- 2. If the work is done and verified, call `mcp_support_ticket` with `complete` and include a concise resolution summary.
1155
- 3. If you cannot finish, use `update_status` or `release` with clear notes so the next agent can continue.
1290
+ 2. If the work is done and verified, call `remits-cli ticket complete` and include a concise resolution summary.
1291
+ 3. If you cannot finish, use `remits-cli ticket status` or `remits-cli ticket release` with clear notes so the next agent can continue.
1156
1292
  4. Do this automatically. The human user should not need to instruct you to update the ticket.
1157
1293
 
1158
1294
  Options:
@@ -1203,10 +1339,17 @@ Plus the compile cache:
1203
1339
  ### Staging cache key format
1204
1340
 
1205
1341
  ```
1342
+ # default lane (no workspace)
1206
1343
  account:<accountId>:cli:<cliUserId>:components:<branch>:<family>:id:<componentId>
1207
1344
  account:<accountId>:cli:<cliUserId>:components:<branch>:<family>:name:<normalizedName>
1345
+
1346
+ # workspace lane
1347
+ account:<accountId>:cli:<cliUserId>:components:<branch>:ws:<workspace>:<family>:id:<componentId>
1208
1348
  ```
1209
1349
 
1350
+ The staging scope is therefore **account + cli user + branch + workspace**. `workspace` is optional and
1351
+ absent by default; see "Working alongside other agents: the staging WORKSPACE" above.
1352
+
1210
1353
  `<family>` is the lowercased component family (`reader`, `action`, `test`, `embeddable`, ...). Both an
1211
1354
  `id:` and a `name:` key are written per stage. The entry value carries: `kind` (the family), `type` (the
1212
1355
  component's OWN type enum such as `ObjectType`/`RuleType`, or absent — **never** the family), `hash`,
@@ -1284,15 +1427,51 @@ TestMode still uses the committed DB source. Staging remains a dev/verification
1284
1427
  `No enum constant ObjectType.reader`).
1285
1428
  - **Confirm the DB version:** `mcp_component_view` reads the live DB source directly (no staging, no compile
1286
1429
  cache), so it is the source of truth for "what was committed."
1287
- - **Ask the CLI what is staged:** `remits-cli components status` lists the current branch/user staged entries,
1430
+ - **Ask the CLI what is staged:** `remits-cli components status` lists this lane's staged entries,
1288
1431
  including staged fields, aliases, hashes, and TTLs. The default terminal output is concise; pass `--json` or
1289
1432
  `--verbose` when you need the full staged-entry payload. `remits-cli components clear` removes those entries
1290
1433
  when you intentionally want to fall back to DB source.
1291
1434
 
1435
+ ### Working alongside other agents: the staging WORKSPACE
1436
+
1437
+ Staging is scoped by `(account, cli user, branch, workspace)`. Account and user are fixed for a repo, so
1438
+ **without a workspace the git branch is the only isolation axis** — and `components stage` uploads the
1439
+ ENTIRE repo and REPLACES the lane rather than merging into it. Two agents on one branch therefore
1440
+ overwrite each other, and a `components commit` clears the lane out from under the other one.
1441
+
1442
+ If more than one agent is working on the same branch, give each its own workspace:
1443
+
1444
+ ```bash
1445
+ git worktree add ../repo-agent-a forked # one checkout per agent, same branch
1446
+ cd ../repo-agent-a
1447
+ remits-cli workspace use --auto # names the lane after this directory
1448
+ remits-cli components stage # isolated: nobody else sees it, nobody overwrites it
1449
+ remits-cli test run --test 42
1450
+ remits-cli token --path /page/whatever
1451
+ ```
1452
+
1453
+ A workspace narrows STAGING and nothing else. A commit still targets the same branch and the same owner
1454
+ account, and the run still resolves whatever committed variant branch the account subscribes to — so it
1455
+ does **not** have the side effects of inventing a throwaway git branch per agent (which would make a
1456
+ commit write `ComponentVariant` overlays for a branch nobody subscribes to).
1457
+
1458
+ - `.remits-cli/workspace` is per-checkout and gitignored, so each worktree keeps its own lane.
1459
+ - Precedence: `--workspace NAME` > `REMITS_WORKSPACE` > `.remits-cli/workspace` > shared default lane.
1460
+ - `--no-workspace` targets the shared lane for one command without clearing the file.
1461
+ - Every stage / test run / token / clear prints its `Staging lane:` — if a change seems to have had no
1462
+ effect, check that line FIRST. A mismatched lane resolves committed source, which looks identical to
1463
+ "the stage did not work".
1464
+ - `remits-cli components status` lists every lane staged on the branch, so you can see whether another
1465
+ agent is working alongside you.
1466
+ - `remits-cli components clear --all` is scoped to YOUR lane and never touches another agent's.
1467
+
1292
1468
  ### Stage / sync / clear with remits-cli
1293
1469
 
1294
1470
  - `remits-cli components stage` writes local file changes into the Redis staging cache for the current
1295
- branch/user scope. This is the normal edit/test loop.
1471
+ branch/user/workspace scope. This is the normal edit/test loop.
1472
+ - `remits-cli components stage --changed-only` stages just the components this working tree edited. It
1473
+ does NOT reconcile, so entries for components it did not mention are left alone rather than deleted.
1474
+ Useful on a large repo; a full stage is still the default and the safest.
1296
1475
  - `remits-cli components status` shows which branch/variant world the checkout resolves, plus staged entries,
1297
1476
  staged fields, aliases, hashes, and TTLs. Use `--json` or `--verbose` for the full staged-entry payload.
1298
1477
  - **A full `stage` makes the `.meta.yml` AUTHORITATIVE.** Staging layers a payload over what is already
@@ -2729,8 +2908,11 @@ ticket with `mcp_support_ticket read` before lifecycle work and honor `mirrorOnl
2729
2908
  | `priorities` / `types` / `sources` / `tags` | no | Additional filters |
2730
2909
  | `assignedTo` / `unassigned` | no | Assignment filters |
2731
2910
  | `implementationAccountId` | no | Filter by owning `PLATFORM`/`PRODUCT` account |
2732
- | `search` | no | Case-insensitive across subject, description, account, affected component, sender, tags |
2733
- | `sortBy` / `sortDirection` | no | `triage` (default-style: critical/high unassigned first), `updated`, `priority`, `status`, `account` |
2911
+ | `workstream` / `plannedIn` / `boardStage` / `size` / `blockedBy` | no | SDLC-agnostic planning filters; exact matches on compact queue fields |
2912
+ | `rank` / `minRank` / `maxRank` | no | Exact or inclusive range filters for numeric planning rank |
2913
+ | `search` | no | Case-insensitive across subject, description, account, affected component, sender, tags, workstream, and planning fields |
2914
+ | `sortBy` | no | `triage` (default-style: critical/high unassigned first), `updated`, `priority`, `status`, `account`, `plannedIn`, `boardStage`, `rank`, `size` |
2915
+ | `sortDirection` | no | `asc` / `desc`, and it means the same thing on every axis. Natural order is `desc` for `triage`/`updated`/`priority` and `asc` for `status`/`account`/`rank`/`plannedIn`/`boardStage`/`size`, so pass it only to invert one |
2734
2916
  | `limit` / `offset` / `scanLimitPerAccount` | no | Paging and scan bounds |
2735
2917
  | `dataMode` | no | Normal agent work uses the **prod** ticket queue |
2736
2918
 
@@ -2771,13 +2953,18 @@ so in its own output; when a test run genuinely needs prod data, pass the flag.
2771
2953
  independent of everything else — no background service is required, and every tab is its own agent.
2772
2954
 
2773
2955
  ```bash
2774
- remits-cli agent register # this session is now routable — no flags, any directory
2775
- remits-cli agent work --wait 300 # ask for tickets routed here
2776
- remits-cli agent status --state working --ticket 22454 --activity "reproducing"
2956
+ remits-cli agent serve # routable AND autonomously working tickets — the usual choice
2957
+ remits-cli agent workers # what this session is running right now
2777
2958
  remits-cli agent list # who else is available across the accounts you cover
2778
- remits-cli agent release # stop receiving tickets right now
2959
+ remits-cli agent release # stop serving and stop receiving tickets right now
2960
+
2961
+ remits-cli agent register # presence ONLY — nothing starts on its own
2962
+ remits-cli agent work --wait 300 # ask for tickets routed here (manual loop)
2963
+ remits-cli agent status --state working --ticket 22454 --activity "reproducing"
2779
2964
  ```
2780
2965
 
2966
+ `serve` is `register` plus a supervisor. Everything below about registration applies to both.
2967
+
2781
2968
  **Defaults exist so the user does not have to type them.** With no flags, `register` targets the
2782
2969
  production platform (`REMITS_BASE_URL` when set) and the **prod** lane, and claims every account repo
2783
2970
  indexed on this machine. That is a deliberate exception to the CLI's test-first default: registering
@@ -2798,6 +2985,48 @@ platform, lane and identity it registered with.
2798
2985
  minutes. Closing the tab is a valid way to go offline; `agent release` just makes it immediate.
2799
2986
  - Registers in the session's **data lane**. A `test`-lane run only ever reaches a `test`-lane agent,
2800
2987
  which is what keeps fixture traffic away from a production terminal.
2988
+ - Declares **capacity** — how many tickets this session can genuinely run at once (`--max-concurrent`,
2989
+ default 1). The router will not exceed it.
2990
+
2991
+ ### What `serve` adds
2992
+
2993
+ The same detached process that maintains presence also polls for work. On each poll it publishes the
2994
+ tickets it currently has running, renews their claims, and takes at most enough new ones to fill its
2995
+ capacity. For each new ticket it launches a headless worker:
2996
+
2997
+ | | headless invocation | edit mode | investigate mode |
2998
+ |---|---|---|---|
2999
+ | `codex` | `codex exec --cd <repo>` | `--sandbox workspace-write` | `--sandbox read-only` |
3000
+ | `claude` | `claude -p --add-dir <repo>` | `--permission-mode acceptEdits` | `--permission-mode plan` |
3001
+ | `gemini` | `gemini -p` in `<repo>` | `--approval-mode auto_edit` | `--approval-mode plan` |
3002
+
3003
+ **Which of the three it launches:** `--worker-agent` if you pass it, otherwise **whatever agent this
3004
+ session is** (detected from the process the agent anchored to — which finds nothing in a plain tab),
3005
+ otherwise `~/.remits-cli/config.json`'s `agent` (set it with `remits-cli config set --agent NAME`),
3006
+ otherwise `claude`. **It prints which it chose and why on startup**, because in the intended
3007
+ plain-tab setup the choice comes from a config file you may have set months ago. So running `agent serve` inside a Codex tab gives you Codex workers
3008
+ without a flag, and the label the operator sees (`codex@repo`) is resolved the same way — the label
3009
+ and the worker are one answer, not two.
3010
+
3011
+ The brief always arrives on **stdin**, never in argv — it is a page of prose and argv has a hard
3012
+ length limit, so an argv brief would fail on exactly the detailed tickets that most need the detail.
3013
+ The brief itself is generated by the platform, so all three worker types are told the same thing.
3014
+
3015
+ **Following a run.** `remits-cli start`'s control center lists every worker; **Follow live** streams
3016
+ that run's transcript into the page, rendering commands with their exit codes, file edits, and the
3017
+ agent's own messages as distinct things. It keeps working after the worker exits — a finished run is
3018
+ usually the one worth reading. For a terminal instead, each worker prints a `tail -f` for its log in
3019
+ `~/.remits-cli/workers/`.
3020
+
3021
+ **There is no terminal to attach to, by design.** A worker is spawned with pipes and runs
3022
+ non-interactively (`codex exec`, `claude -p`), so there is no tty and no prompt to type at — the
3023
+ whole point is that it needs no supervision. Following the transcript is the way to watch, and it is
3024
+ strictly better than a terminal would be: the output is structured, so it can be read as events
3025
+ rather than scraped back out of ANSI text.
3026
+
3027
+ **No worker ever commits.** The brief forbids `git commit`/`git push` and nothing in the supervisor
3028
+ runs git — a worker leaves its changes in the working tree and says so on the ticket, for a human to
3029
+ review.
2801
3030
 
2802
3031
  ### Resolving which agent a command means
2803
3032
 
@@ -2812,7 +3041,22 @@ usually fixed in the platform repo above it), then the ticket's own account, the
2812
3041
  `PLATFORM`/`PRODUCT` ancestors — and takes the first account with an available agent. Among those it
2813
3042
  prefers an **idle** agent, then the one that has waited longest, so work spreads across your tabs
2814
3043
  instead of piling onto whichever one most recently ran a command. A `paused` agent stays visible and
2815
- is never routed to.
3044
+ is never routed to, and so is one **at capacity** — those are different facts and stay separate:
3045
+ `paused` means a human stopped this session, at-capacity means its workers are all busy.
3046
+
3047
+ ### Why a routed ticket might not have started
3048
+
3049
+ In order of likelihood:
3050
+
3051
+ 1. **The session registered but never served.** `agent register` starts nothing. `agent workers`
3052
+ showing none while a ticket is routed here is this.
3053
+ 2. **At capacity.** Check `agent workers`; the ticket starts when one finishes.
3054
+ 3. **Another session is running it.** A claim held by a different agent blocks it until that claim is
3055
+ dropped or expires.
3056
+ 4. **No local checkout.** The worker still starts, and its brief tells it to locate the repo rather
3057
+ than guess — but if the account genuinely is not on this machine it will say so and stop.
3058
+ 5. **It failed twice already** and was released back to the queue. The transcripts in
3059
+ `~/.remits-cli/workers/` say why.
2816
3060
 
2817
3061
  ## Background Service and Control Center
2818
3062
 
@@ -2926,18 +3170,25 @@ Reading rules:
2926
3170
  remits-cli auth [--base-url URL] [--account-id ID] [--data-mode test|prod]
2927
3171
  remits-cli sessions [list|remove] [--account-id ID]
2928
3172
  remits-cli config [set] [--agent claude|codex|gemini]
2929
- remits-cli agent register [--label NAME] [--data-mode test|prod] [--account-id ID]
3173
+ remits-cli agent serve [--worker-agent claude|codex|gemini] [--max-concurrent N] [--mode edit|investigate] [--label NAME] [--data-mode test|prod]
3174
+ remits-cli agent workers [--json]
3175
+ remits-cli agent register [--label NAME] [--data-mode test|prod] [--account-id ID] [--max-concurrent N]
2930
3176
  remits-cli agent work [--wait SECONDS] [--json]
2931
3177
  remits-cli agent status [--state idle|working|paused] [--ticket ID] [--activity "..."] [--step "..."]
2932
3178
  remits-cli agent list [--account-id ID] [--json]
3179
+ remits-cli agent map [--account-ids 1,4] [--json] # who is EDITING which repository, from which checkout/branch/staging lane
2933
3180
  remits-cli agent release
3181
+ remits-cli ticket read|accept|status|progress|complete|release|reopen|assign|planning --ticket ID [--status S] [--resolution "..."] [--summary "..."] [--category C] [--assignee EMAIL] [--workstream VALUE] [--planned-in VALUE] [--board-stage VALUE] [--rank N] [--size VALUE] [--blocked-by VALUE] [--notes "..."]
3182
+ remits-cli ticket lease|unlease|force-unlease --ticket ID [--reason "..."] # force-unlease breaks SOMEBODY ELSE'S lease; operator only
3183
+ remits-cli ticket where --ticket ID # WHERE this work is: repo account, checkout, branch, staging lane, live lease + holder's location, claim, your phase
2934
3184
  remits-cli start [--foreground true] [--port 8787]
2935
3185
  remits-cli stop
2936
3186
  remits-cli status [--base-url URL] [--account-id ID] [--data-mode test|prod] [--json]
2937
3187
  remits-cli whoami [--base-url URL] [--account-id ID] [--data-mode test|prod] [--json]
2938
3188
  remits-cli listen [stop|status] [--foreground true] # compatibility alias
2939
3189
  remits-cli data-mode [set test|prod]
2940
- remits-cli components stage [--branch <name>] [--data-mode test|prod] [--json|--verbose]
3190
+ remits-cli components stage [--branch <name>] [--workspace <name>] [--changed-only] [--data-mode test|prod] [--json|--verbose]
3191
+ remits-cli workspace [show | use <name> | use --auto | clear]
2941
3192
  remits-cli components status [--branch <name>] [--component-type <type>] [--component-id <id>] [--json|--verbose]
2942
3193
  remits-cli components clear [--branch <name>] [--component-type <type>] [--component-id <id>] [--all] [--json|--verbose] # id alone scopes to one component when unambiguous (ids are type-local; add --component-type if the same id is staged in multiple families); no filter clears the whole branch scope; --all forces the full wipe
2943
3194
  remits-cli components sync [--branch <name>] [--data-mode test|prod] [--force-tombstones] [--dry-run] [--summary] [--changed-only [--changed-since <ref>]] # gated; on trunk = full repo->DB reconcile, on a variant branch = ComponentVariant overlays only