@remits/remits-cli 0.1.108 → 0.1.110

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.108",
3
+ "version": "0.1.110",
4
4
  "description": "Local CLI for auth, component sync, and live test execution against Remits",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -20,6 +20,8 @@ description: Use remits-cli for fast branch-scoped component staging, test execu
20
20
  - [Required Local Index Reads](#required-local-index-reads)
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
+ - [You are an agent, and you register yourself](#you-are-an-agent-and-you-register-yourself)
24
+ - [The loop](#the-loop)
23
25
  - [Efficiency Rules](#efficiency-rules)
24
26
  - [Account Repository Index](#account-repository-index)
25
27
  - [Two Workflows](#two-workflows)
@@ -105,10 +107,12 @@ description: Use remits-cli for fast branch-scoped component staging, test execu
105
107
  - [`mcp_jvm_spike_triage`](#mcp_jvm_spike_triage)
106
108
  - [`mcp_support_ticket_queue`](#mcp_support_ticket_queue)
107
109
  - [Multi-Session Support](#multi-session-support)
108
- - [Persistent Service, Control Center, and Agent Dispatch](#persistent-service-control-center-and-agent-dispatch)
109
- - [Starting the Service](#starting-the-service)
110
+ - [Registering This Session As An Agent](#registering-this-session-as-an-agent)
111
+ - [What registration actually does](#what-registration-actually-does)
112
+ - [Resolving which agent a command means](#resolving-which-agent-a-command-means)
113
+ - [Which agent gets a ticket](#which-agent-gets-a-ticket)
114
+ - [Background Service and Control Center](#background-service-and-control-center)
110
115
  - [Control Center](#control-center)
111
- - [Agent Dispatch](#agent-dispatch)
112
116
  - [Configuring the Preferred Agent](#configuring-the-preferred-agent)
113
117
  - [Local State Files](#local-state-files)
114
118
  - [Command Reference](#command-reference)
@@ -384,14 +388,16 @@ These files are decision inputs. Read them when the related decision depends on
384
388
  - Read when a support ticket references an account and you need to locate the correct local repo.
385
389
  - Read before concluding that a repo does not exist locally.
386
390
  - `~/.remits-cli/config.json`
387
- - Read when service lifecycle, dashboard, listener, or agent-dispatch behavior matters.
391
+ - Read when service lifecycle, dashboard, or preferred-agent behavior matters.
388
392
  - `~/.remits-cli/service-state.json`
389
393
  - Read when the local control center URL, current dashboard port, repo-scan summary, or websocket status matters.
390
394
  - Read when the user asks whether the remits-cli service is running or where to open the browser view.
391
- - `~/.remits-cli/dispatch-panes.json`
392
- - Read when support-ticket follow-up routing, pane reuse, or pane replacement behavior matters.
393
- - `~/.remits-cli/tmux-activity.log`
394
- - Read when diagnosing service lifecycle, websocket, tmux, ticket-routing, or dispatch failures.
395
+ - `~/.remits-cli/agents.json`
396
+ - The agent sessions registered from THIS machine, each with the process it is anchored to.
397
+ - Read when `remits-cli agent work` says no agent is registered, or when several agents are
398
+ registered and a command needs `--agent-id`.
399
+ - `~/.remits-cli/activity.log`
400
+ - Read when diagnosing service lifecycle, websocket, agent registration, or ticket-routing failures.
395
401
  - `~/.remits-cli/sessions.json`
396
402
  - Read when authentication state, active accounts, base URLs, websocket topics, or per-account data mode matters.
397
403
  - `./.remits-cli/current-session.txt`
@@ -420,7 +426,7 @@ Think about remits-cli as two cooperating layers:
420
426
  - which repos exist locally
421
427
  - whether the background service is running
422
428
  - where the control center lives
423
- - whether websocket/tmux dispatch is healthy
429
+ - which agent sessions are registered from this machine
424
430
 
425
431
  2. **Per-repo state** in `./.remits-cli/`
426
432
  - This is the request/response and cache layer for one specific working tree.
@@ -435,21 +441,96 @@ When a user asks an indirect question, map it to the right layer first:
435
441
  - "Why did this ticket open in the wrong repo?" → start in global state.
436
442
  - "What exact payload did this tool call send?" → start in per-repo state.
437
443
  - "Why is the dashboard showing stale repos?" → start in `service-state.json` and `account-repos.json`.
438
- - "Why is the browser page not showing websocket activity?" → start in `service-state.json` and `tmux-activity.log`.
444
+ - "Why is the browser page not showing websocket activity?" → start in `service-state.json` and `activity.log`.
445
+ - "Why is my agent not getting tickets?" → start in `agents.json`, then `remits-cli agent list`.
439
446
 
440
447
  Agents should use this mental model before guessing.
441
448
 
442
449
  ## Support Ticket Mental Model
443
450
 
444
- The local agent workflow includes a lightweight support-ticket system:
451
+ Support tickets are a **first-class platform capability**, not an account convention. Every Remits
452
+ account reads and writes the `support_tickets` collection without owning a Schema, tickets are anchor
453
+ `Object`s on the account the work belongs to, and the lifecycle vocabulary is defined once in the
454
+ platform.
445
455
 
446
- - Support tickets are Firestore documents in `support_tickets`.
447
- - Support tickets belong to the actual Remits account the work relates to.
448
- - Tickets are created centrally from support intake and pushed to local agents over the `remits-cli` WebSocket channel.
449
- - Each incoming ticket becomes a tmux workstream in the shared `remits-listener` session, so you can think of it as a localized Jira-style queue for active agent work.
450
- - Review centralized listener/tmux activity in `~/.remits-cli/tmux-activity.log`.
456
+ **The platform is deliberately not the standard for ticket workflow.** Different Remits
457
+ platforms and products integrate with different systems — Zendesk, Jira, a customer's own portal —
458
+ and each end client has its own rules for how tickets move. Remits owns the *record* and the *verbs*;
459
+ each front-stage platform builds its own workflow on top through its own Embeddables, Rules, and
460
+ Actions. So what you see through `remits-cli` is the shared record underneath every one of those
461
+ workflows, and never one product's view of it.
451
462
 
452
- Use `mcp_support_ticket` to manage lifecycle:
463
+ ### You are an agent, and you register yourself
464
+
465
+ **If the user says anything like "register to become a support agent", run exactly this and nothing
466
+ else first:**
467
+
468
+ ```bash
469
+ remits-cli agent register
470
+ ```
471
+
472
+ No flags, no setup, **no need to be in an account repo** — run it from wherever the session started.
473
+ 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.
476
+
477
+ Three tabs running an agent are three agents. Each is independently routable, each reports its own
478
+ activity, and each stops receiving work when its tab closes — a heartbeat anchored to the session dies
479
+ with it, so a crashed agent and a quit agent look identical to the platform.
480
+
481
+ **Nothing is pushed at you.** A terminal mid-task cannot receive a push, so delivery is you asking.
482
+ That is why the routing decision is a durable field on the ticket rather than a message: you can
483
+ restart this terminal, register again, and the work is still there.
484
+
485
+ Two facts about a ticket are separate and must stay separate:
486
+
487
+ | Fact | Field | Means |
488
+ |---|---|---|
489
+ | **Routed** | `routedAgentId` | which agent session should pick this up — delivery |
490
+ | **Owned** | `assignedTo` | who has claimed it — accountability |
491
+ | **Status** | `status` | where it is in the workflow |
492
+
493
+ A ticket routed to you is not yet yours. Claim it with `accept`, and the queue then shows it owned.
494
+
495
+ ### The loop
496
+
497
+ After `register`, **no agent command needs a flag** — they reuse the platform, lane and identity this
498
+ session registered with.
499
+
500
+ ```bash
501
+ remits-cli agent work --wait 600 # returns as soon as work arrives
502
+ remits-cli agent status --state working --ticket 22454 --activity "reproducing the upload failure"
503
+ # ... 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) ...
505
+ remits-cli agent status --state idle # then ask for work again
506
+ ```
507
+
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.
511
+
512
+ **Report what you are doing.** `agent status` is how an operator watching the dashboard, or another
513
+ agent, knows this session is alive and what it is on. It costs one command and it is the difference
514
+ between a visible queue and a silent one. Update it when you change what you are doing, not on a
515
+ timer.
516
+
517
+ **Work the ticket in the right repo.** A ticket names its `accountId`, and often an
518
+ `implementationAccountId` — the platform/product account whose repo holds the code. Resolve that to a
519
+ local directory through `~/.remits-cli/account-repos.json` and `cd` there before making changes. You
520
+ registered from anywhere; you do not fix anything from anywhere.
521
+
522
+ **Lane note:** `register` defaults to the production lane because a support agent works real tickets.
523
+ `--data-mode test` registers a fixture agent instead, which will never be routed a production ticket —
524
+ use it only when you are deliberately testing the routing itself.
525
+
526
+ ### Seeing the queue as a human does
527
+
528
+ `remits-cli start` opens a browser control center showing the same facts you are acting on: which
529
+ agents are registered and what each is doing, which tickets are open, and which agent each is routed
530
+ to. An operator can route a ticket to a specific agent from there. It is a view, not a second system —
531
+ what it shows and what `remits-cli agent work` returns come from the same records.
532
+
533
+ Use `mcp_support_ticket` to manage lifecycle:Use `mcp_support_ticket` to manage lifecycle:
453
534
  - `read` — always start here to load current state
454
535
  - `accept` — claim the ticket so other agents do not work it concurrently
455
536
  - `update_status` — move to `in_progress` or `pending_review`
@@ -462,7 +543,7 @@ Use `mcp_support_ticket` to manage lifecycle:
462
543
  Ticket-routing context:
463
544
  - `accountId` / `accountName` identify the account that owns the ticket.
464
545
  - If present, `implementationAccountId` / `implementationAccountName` identify the owning `PLATFORM` or `PRODUCT` implementation context.
465
- - The local listener should prefer `implementationAccountId` when choosing the initial working directory for a ticket, with fallback to `accountId` if the platform/product repo is not available locally.
546
+ - Prefer `implementationAccountId` when choosing the working directory for a ticket, falling back to `accountId` when the platform/product repo is not available locally. Routing already uses that same ladder, so the repo you were routed through is usually the right one.
466
547
  - For enhancement work, prefer the platform/product implementation context when deciding where code changes belong.
467
548
  - For defect investigations, start from the owning ticket account, then move to the platform/product context if the root cause is in shared components.
468
549
 
@@ -2684,16 +2765,61 @@ unless you pass `--data-mode prod` explicitly. So `whoami` can read `prod` while
2684
2765
  lane — which is the safe direction, but not the one you would predict from the output alone. `whoami` says
2685
2766
  so in its own output; when a test run genuinely needs prod data, pass the flag.
2686
2767
 
2687
- ## Persistent Service, Control Center, and Agent Dispatch
2768
+ ## Registering This Session As An Agent
2688
2769
 
2689
- The current mental model is a **background remits-cli service**, not just a listener.
2770
+ `remits-cli agent` is how a terminal session makes itself available to work support tickets. It is
2771
+ independent of everything else — no background service is required, and every tab is its own agent.
2690
2772
 
2691
- That service does three jobs:
2692
- - Maintains persistent WebSocket connections to the Remits platform
2693
- - Manages tmux-based agent dispatch for inbound `remits-cli` support messages
2694
- - Hosts a localhost browser **control center** that shows the full local integration state
2773
+ ```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"
2777
+ remits-cli agent list # who else is available across the accounts you cover
2778
+ remits-cli agent release # stop receiving tickets right now
2779
+ ```
2780
+
2781
+ **Defaults exist so the user does not have to type them.** With no flags, `register` targets the
2782
+ production platform (`REMITS_BASE_URL` when set) and the **prod** lane, and claims every account repo
2783
+ indexed on this machine. That is a deliberate exception to the CLI's test-first default: registering
2784
+ presence mutates no business data, and a test-lane agent is silently useless for support — it appears
2785
+ online and can never be routed a production ticket. Every command after `register` reuses the
2786
+ platform, lane and identity it registered with.
2787
+
2788
+ ### What registration actually does
2789
+
2790
+ - Mints an `agentId` for this session and tells the platform which account repos this machine has
2791
+ checked out — read from the machine-wide index (`~/.remits-cli/account-repos.json`), which is why
2792
+ the working directory does not matter. The platform **verifies** those claims against what your user
2793
+ can access and returns the ones it refused, so "I registered but never get tickets for account 52"
2794
+ is answerable from the registration output alone.
2795
+ - Starts a small detached heartbeat process **anchored to the agent process that owns this terminal**
2796
+ (it walks up the process tree to find `claude`/`codex`/`gemini`, then an interactive shell). When
2797
+ that process ends, the heartbeat ends and the session stops being routable within a couple of
2798
+ minutes. Closing the tab is a valid way to go offline; `agent release` just makes it immediate.
2799
+ - Registers in the session's **data lane**. A `test`-lane run only ever reaches a `test`-lane agent,
2800
+ which is what keeps fixture traffic away from a production terminal.
2801
+
2802
+ ### Resolving which agent a command means
2803
+
2804
+ Order: `--agent-id`, then `REMITS_AGENT_ID`, then the single agent registered for this working
2805
+ directory. With several registered and no way to tell them apart, the command **fails and lists the
2806
+ candidates** rather than guessing — routing work to the wrong tab is silent, and a message is not.
2807
+
2808
+ ### Which agent gets a ticket
2809
+
2810
+ The platform walks a ladder — the ticket's implementation account first (a defect seen on a client is
2811
+ usually fixed in the platform repo above it), then the ticket's own account, then its
2812
+ `PLATFORM`/`PRODUCT` ancestors — and takes the first account with an available agent. Among those it
2813
+ prefers an **idle** agent, then the one that has waited longest, so work spreads across your tabs
2814
+ instead of piling onto whichever one most recently ran a command. A `paused` agent stays visible and
2815
+ is never routed to.
2816
+
2817
+ ## Background Service and Control Center
2695
2818
 
2696
- ### Starting the Service
2819
+ `remits-cli start` runs an optional background service for the **human** watching:
2820
+
2821
+ - Maintains persistent WebSocket connections to the Remits platform
2822
+ - Hosts a localhost browser **control center** (typically `http://127.0.0.1:8787/`)
2697
2823
 
2698
2824
  ```bash
2699
2825
  remits-cli start
@@ -2711,50 +2837,27 @@ remits-cli listen status
2711
2837
  remits-cli listen stop
2712
2838
  ```
2713
2839
 
2714
- The service:
2715
- - Scans the machine for `account-info.json` files and rebuilds `~/.remits-cli/account-repos.json`
2716
- - Maintains one WebSocket connection per unique platform URL across all sessions
2717
- - Subscribes to topics for every authenticated account
2718
- - Handles `TestSuite` messages (test results) and `remits-cli` messages (agent dispatch)
2719
- - Reconnects automatically if the connection drops
2720
- - Uses a PID lock file (`~/.remits-cli/listener.pid`) to ensure only one service per machine
2721
- - Writes `~/.remits-cli/service-state.json` so agents can discover the dashboard URL and current runtime status
2840
+ **The service is not part of ticket delivery.** Agents register and collect work on their own, so the
2841
+ dashboard being down never stops a ticket reaching an agent. What the service adds is visibility: it
2842
+ scans for `account-info.json` files to rebuild the repo index, keeps one WebSocket per platform URL,
2843
+ and holds a PID lock (`~/.remits-cli/listener.pid`) so only one runs per machine.
2722
2844
 
2723
2845
  ### Control Center
2724
2846
 
2725
- `remits-cli start` should provide a localhost URL such as `http://127.0.0.1:8787/`.
2726
-
2727
- The control center is the fastest way to understand the whole integration surface in one browser view. It shows:
2728
- - whether the remits-cli service is running
2729
- - the current dashboard URL and port
2847
+ The control center shows, in one browser view:
2848
+ - which agent sessions are registered, what each is doing right now, and its recent activity
2849
+ - the open support-ticket queue, and which agent each ticket is routed to
2850
+ - a control to route a ticket at a specific available agent
2730
2851
  - websocket connection and topic health
2731
- - tmux availability, session state, and tracked panes
2732
- - the discovered account repo index
2733
- - the important global JSON/log files
2734
- - the important per-repo remits-cli files for every indexed account repo
2735
-
2736
- When a user asks a broad or vague question about remits-cli behavior, prefer opening or reasoning from the control center state before spelunking random files individually.
2737
-
2738
- ### Agent Dispatch
2739
-
2740
- All dispatched agents run as **panes** within a single tmux session named `remits-listener`. This gives the user a single window where they can see and interact with all active agent workstreams side by side.
2852
+ - the discovered account repo index and the important global/per-repo files
2741
2853
 
2742
- When a `remits-cli` WebSocket message arrives from the platform:
2854
+ **What it shows is what the agents see.** The ticket queue comes from the platform's own generic
2855
+ endpoint, not from any product's tool, so the control center reads the same on every Remits platform
2856
+ and never implies a workflow that a particular product does not have. Product-specific views belong
2857
+ in that product's Embeddables.
2743
2858
 
2744
- 1. The message's `accountId` is used to look up the account's local directory from the account repo index
2745
- 2. If the message has a `ticketId` that already has an active pane, the new message is **delivered to the existing pane** (the agent receives the follow-up in-context)
2746
- 3. If no pane exists for the `ticketId`, a new pane is **split into the `remits-listener` tmux session**, running the preferred AI coding agent with the message prompt at the account's directory
2747
- 4. Panes are automatically tiled for a clean layout
2748
-
2749
- **Ticket tracking:** Each support-ticket message should include a `ticketId`. The listener maps ticket workstreams to tmux pane IDs so follow-up messages for the same ticket are routed to the same agent session. Legacy payloads that only include `taskId` are still supported as a fallback. If the pane has been closed, a fresh pane is created.
2750
-
2751
- **Inspecting activity:** Use `tail -f ~/.remits-cli/tmux-activity.log` to watch service start/stop, WebSocket subscriptions, ticket dispatch receipt, pane creation, follow-up delivery, and failures.
2752
-
2753
- **Interacting with agents:** Attach to the tmux session to see all active agents:
2754
- ```bash
2755
- tmux attach -t remits-listener
2756
- ```
2757
- Use standard tmux navigation (`Ctrl-b` + arrow keys) to switch between panes.
2859
+ When a user asks a broad or vague question about remits-cli behavior, prefer reasoning from the
2860
+ control center state before spelunking individual files.
2758
2861
 
2759
2862
  ### Configuring the Preferred Agent
2760
2863
 
@@ -2788,11 +2891,13 @@ The agent preference is stored in `~/.remits-cli/config.json` and applies global
2788
2891
  - `listener.pid`
2789
2892
  - PID of the background remits-cli service process.
2790
2893
  - Use it only to confirm process presence; use `service-state.json` for richer service details.
2791
- - `dispatch-panes.json`
2792
- - Maps active ticket routing keys (`ticket:<id>` or legacy `task:<id>`) to tmux pane IDs.
2793
- - Read this when follow-up messages appear to route to the wrong pane or when panes are being recreated.
2794
- - `tmux-activity.log`
2795
- - Human-readable chronological event log for service lifecycle, websocket events, tmux actions, and dispatch behavior.
2894
+ - `agents.json`
2895
+ - The agent sessions registered from this machine, each with the process it is anchored to.
2896
+ - Read this when a command asks for `--agent-id`, or when an agent appears registered locally but
2897
+ is missing from `remits-cli agent list` (that gap IS the "why am I not getting tickets" answer).
2898
+ - `activity.log`
2899
+ - Human-readable chronological event log for service lifecycle, websocket events, agent
2900
+ registration/heartbeat, and ticket routing.
2796
2901
  - This is usually the best forensic file for "what happened?" questions.
2797
2902
 
2798
2903
  **Per-repo** (`./.remits-cli/`):
@@ -2821,6 +2926,11 @@ Reading rules:
2821
2926
  remits-cli auth [--base-url URL] [--account-id ID] [--data-mode test|prod]
2822
2927
  remits-cli sessions [list|remove] [--account-id ID]
2823
2928
  remits-cli config [set] [--agent claude|codex|gemini]
2929
+ remits-cli agent register [--label NAME] [--data-mode test|prod] [--account-id ID]
2930
+ remits-cli agent work [--wait SECONDS] [--json]
2931
+ remits-cli agent status [--state idle|working|paused] [--ticket ID] [--activity "..."] [--step "..."]
2932
+ remits-cli agent list [--account-id ID] [--json]
2933
+ remits-cli agent release
2824
2934
  remits-cli start [--foreground true] [--port 8787]
2825
2935
  remits-cli stop
2826
2936
  remits-cli status [--base-url URL] [--account-id ID] [--data-mode test|prod] [--json]
@@ -2946,7 +3056,6 @@ For tests specifically:
2946
3056
  | Staged Reader test run throws `No enum constant ObjectType.<family>` | The staged entry has the component family in `type` (should be `kind`). Clear + re-stage; if it persists, inspect the staged payload with `mcp_cache` and escalate as a CLI/platform staging bug. |
2947
3057
  | Unsure whether a run used staged vs DB source | Query `mcp_system_logs` for `Using Cached BCD` — `Signature: cli:<hash>` = staged, `version:<N>:<sourceHash12>` = DB. CLI/MCP tool results also report `componentSource` and `componentSignature` when available. |
2948
3058
  | Service already running | Run `remits-cli status` to get the dashboard URL, or `remits-cli stop` before restarting. |
2949
- | tmux not installed | Install tmux (`brew install tmux` on macOS). Required for agent dispatch. |
2950
3059
  | Control center URL unknown | Read `~/.remits-cli/service-state.json` or run `remits-cli status` |
2951
3060
  | Dashboard missing repos | Rebuild `~/.remits-cli/account-repos.json` with `remits-cli start` or the control center rescan action |
2952
3061
  | Agent dispatch to wrong directory | Check `~/.remits-cli/account-repos.json` has the correct directory and that you resolved the account type correctly. A `CLIENT` ticket may still belong to a parent `PLATFORM` or `PRODUCT` repo for code changes. |
@@ -3007,13 +3116,13 @@ which is the source served to every account repo. Better guides over time are an
3007
3116
  - the active repo session log from `./.remits-cli/sessions/`
3008
3117
  - any `./.remits-cli/tool-responses/<callId>.json` files involved
3009
3118
  - `~/.remits-cli/account-repos.json` if repo resolution may be relevant
3010
- - `~/.remits-cli/tmux-activity.log` if listener / websocket / dispatch behavior may be relevant
3119
+ - `~/.remits-cli/activity.log` if service / websocket / agent-routing behavior may be relevant
3011
3120
 
3012
3121
  2. **Use the global Remits CLI state to make the bundle self-contained.**
3013
3122
  - Read `./.remits-cli/current-session.txt` to identify the active repo session log.
3014
3123
  - Record the exact repo directory and account context from `account-info.json`.
3015
3124
  - If repo selection or account targeting may be part of the issue, include the relevant entry from `~/.remits-cli/account-repos.json`.
3016
- - If the problem involves support-ticket delivery, tmux panes, or websocket events, include the relevant lines from `~/.remits-cli/tmux-activity.log`.
3125
+ - If the problem involves support-ticket routing, agent registration, or websocket events, include the relevant lines from `~/.remits-cli/activity.log`.
3017
3126
  - If a tool call stored its full response externally, include that file path and summarize the important fields in `summary.md`.
3018
3127
 
3019
3128
  3. **Stop and document the issue clearly for the user.**