@remits/remits-cli 0.1.107 → 0.1.109

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.107",
3
+ "version": "0.1.109",
4
4
  "description": "Local CLI for auth, component sync, and live test execution against Remits",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -105,10 +105,12 @@ description: Use remits-cli for fast branch-scoped component staging, test execu
105
105
  - [`mcp_jvm_spike_triage`](#mcp_jvm_spike_triage)
106
106
  - [`mcp_support_ticket_queue`](#mcp_support_ticket_queue)
107
107
  - [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)
108
+ - [Registering This Session As An Agent](#registering-this-session-as-an-agent)
109
+ - [What registration actually does](#what-registration-actually-does)
110
+ - [Resolving which agent a command means](#resolving-which-agent-a-command-means)
111
+ - [Which agent gets a ticket](#which-agent-gets-a-ticket)
112
+ - [Background Service and Control Center](#background-service-and-control-center)
110
113
  - [Control Center](#control-center)
111
- - [Agent Dispatch](#agent-dispatch)
112
114
  - [Configuring the Preferred Agent](#configuring-the-preferred-agent)
113
115
  - [Local State Files](#local-state-files)
114
116
  - [Command Reference](#command-reference)
@@ -384,14 +386,16 @@ These files are decision inputs. Read them when the related decision depends on
384
386
  - Read when a support ticket references an account and you need to locate the correct local repo.
385
387
  - Read before concluding that a repo does not exist locally.
386
388
  - `~/.remits-cli/config.json`
387
- - Read when service lifecycle, dashboard, listener, or agent-dispatch behavior matters.
389
+ - Read when service lifecycle, dashboard, or preferred-agent behavior matters.
388
390
  - `~/.remits-cli/service-state.json`
389
391
  - Read when the local control center URL, current dashboard port, repo-scan summary, or websocket status matters.
390
392
  - 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.
393
+ - `~/.remits-cli/agents.json`
394
+ - The agent sessions registered from THIS machine, each with the process it is anchored to.
395
+ - Read when `remits-cli agent work` says no agent is registered, or when several agents are
396
+ registered and a command needs `--agent-id`.
397
+ - `~/.remits-cli/activity.log`
398
+ - Read when diagnosing service lifecycle, websocket, agent registration, or ticket-routing failures.
395
399
  - `~/.remits-cli/sessions.json`
396
400
  - Read when authentication state, active accounts, base URLs, websocket topics, or per-account data mode matters.
397
401
  - `./.remits-cli/current-session.txt`
@@ -420,7 +424,7 @@ Think about remits-cli as two cooperating layers:
420
424
  - which repos exist locally
421
425
  - whether the background service is running
422
426
  - where the control center lives
423
- - whether websocket/tmux dispatch is healthy
427
+ - which agent sessions are registered from this machine
424
428
 
425
429
  2. **Per-repo state** in `./.remits-cli/`
426
430
  - This is the request/response and cache layer for one specific working tree.
@@ -435,21 +439,77 @@ When a user asks an indirect question, map it to the right layer first:
435
439
  - "Why did this ticket open in the wrong repo?" → start in global state.
436
440
  - "What exact payload did this tool call send?" → start in per-repo state.
437
441
  - "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`.
442
+ - "Why is the browser page not showing websocket activity?" → start in `service-state.json` and `activity.log`.
443
+ - "Why is my agent not getting tickets?" → start in `agents.json`, then `remits-cli agent list`.
439
444
 
440
445
  Agents should use this mental model before guessing.
441
446
 
442
447
  ## Support Ticket Mental Model
443
448
 
444
- The local agent workflow includes a lightweight support-ticket system:
449
+ Support tickets are a **first-class platform capability**, not an account convention. Every Remits
450
+ account reads and writes the `support_tickets` collection without owning a Schema, tickets are anchor
451
+ `Object`s on the account the work belongs to, and the lifecycle vocabulary is defined once in the
452
+ platform.
445
453
 
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`.
454
+ **The platform is deliberately not the standard for ticket workflow.** Different Remits
455
+ platforms and products integrate with different systems — Zendesk, Jira, a customer's own portal —
456
+ and each end client has its own rules for how tickets move. Remits owns the *record* and the *verbs*;
457
+ each front-stage platform builds its own workflow on top through its own Embeddables, Rules, and
458
+ Actions. So what you see through `remits-cli` is the shared record underneath every one of those
459
+ workflows, and never one product's view of it.
451
460
 
452
- Use `mcp_support_ticket` to manage lifecycle:
461
+ ### You are an agent, and you register yourself
462
+
463
+ Work reaches you because **this terminal session registered itself as available**:
464
+
465
+ ```bash
466
+ remits-cli agent register # this tab is now a routable agent
467
+ remits-cli agent work # ask for the tickets routed to it
468
+ ```
469
+
470
+ Three tabs running Claude are three agents. Each is independently routable, each reports its own
471
+ activity, and each stops receiving work when its tab closes — a heartbeat process is anchored to the
472
+ session and dies with it, so a crashed agent and a quit agent look identical to the platform.
473
+
474
+ **Nothing is pushed at you.** A terminal mid-task cannot receive a push, so delivery is you asking.
475
+ That is why the routing decision is a durable field on the ticket rather than a message: you can
476
+ restart this terminal, register again, and the work is still there.
477
+
478
+ Two facts about a ticket are separate and must stay separate:
479
+
480
+ | Fact | Field | Means |
481
+ |---|---|---|
482
+ | **Routed** | `routedAgentId` | which agent session should pick this up — delivery |
483
+ | **Owned** | `assignedTo` | who has claimed it — accountability |
484
+ | **Status** | `status` | where it is in the workflow |
485
+
486
+ A ticket routed to you is not yet yours. Claim it with `accept`, and the queue then shows it owned.
487
+
488
+ ### The loop
489
+
490
+ ```bash
491
+ remits-cli agent register --label "claude@merchant-statements"
492
+ remits-cli agent work --wait 300 # blocks until something arrives
493
+ remits-cli agent status --state working --ticket 22454 --activity "reproducing the upload failure"
494
+ # ... investigate, fix, verify ...
495
+ remits-cli agent status --activity "verifying the fix on localhost"
496
+ # ... then close the ticket lifecycle through mcp_support_ticket ...
497
+ remits-cli agent status --state idle # ready for the next one
498
+ ```
499
+
500
+ **Report what you are doing.** `agent status` is how an operator watching the dashboard, or another
501
+ agent, knows this session is alive and what it is on. It costs one command and it is the difference
502
+ between a visible queue and a silent one. Update it when you change what you are doing, not on a
503
+ timer.
504
+
505
+ ### Seeing the queue as a human does
506
+
507
+ `remits-cli start` opens a browser control center showing the same facts you are acting on: which
508
+ agents are registered and what each is doing, which tickets are open, and which agent each is routed
509
+ to. An operator can route a ticket to a specific agent from there. It is a view, not a second system —
510
+ what it shows and what `remits-cli agent work` returns come from the same records.
511
+
512
+ Use `mcp_support_ticket` to manage lifecycle:Use `mcp_support_ticket` to manage lifecycle:
453
513
  - `read` — always start here to load current state
454
514
  - `accept` — claim the ticket so other agents do not work it concurrently
455
515
  - `update_status` — move to `in_progress` or `pending_review`
@@ -462,7 +522,7 @@ Use `mcp_support_ticket` to manage lifecycle:
462
522
  Ticket-routing context:
463
523
  - `accountId` / `accountName` identify the account that owns the ticket.
464
524
  - 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.
525
+ - 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
526
  - For enhancement work, prefer the platform/product implementation context when deciding where code changes belong.
467
527
  - 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
528
 
@@ -2684,16 +2744,53 @@ unless you pass `--data-mode prod` explicitly. So `whoami` can read `prod` while
2684
2744
  lane — which is the safe direction, but not the one you would predict from the output alone. `whoami` says
2685
2745
  so in its own output; when a test run genuinely needs prod data, pass the flag.
2686
2746
 
2687
- ## Persistent Service, Control Center, and Agent Dispatch
2747
+ ## Registering This Session As An Agent
2688
2748
 
2689
- The current mental model is a **background remits-cli service**, not just a listener.
2749
+ `remits-cli agent` is how a terminal session makes itself available to work support tickets. It is
2750
+ independent of everything else — no background service is required, and every tab is its own agent.
2690
2751
 
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
2752
+ ```bash
2753
+ remits-cli agent register # this session is now routable
2754
+ remits-cli agent work --wait 300 # ask for tickets routed here
2755
+ remits-cli agent status --state working --ticket 22454 --activity "reproducing"
2756
+ remits-cli agent list # who else is available for this account
2757
+ remits-cli agent release # stop receiving tickets right now
2758
+ ```
2759
+
2760
+ ### What registration actually does
2761
+
2762
+ - Mints an `agentId` for this session and tells the platform which account repos this machine has
2763
+ checked out. The platform **verifies** those claims against what your user can access and returns
2764
+ the ones it refused, so "I registered but never get tickets for account 52" is answerable from the
2765
+ registration output alone.
2766
+ - Starts a small detached heartbeat process **anchored to the agent process that owns this terminal**
2767
+ (it walks up the process tree to find `claude`/`codex`/`gemini`, then an interactive shell). When
2768
+ that process ends, the heartbeat ends and the session stops being routable within a couple of
2769
+ minutes. Closing the tab is a valid way to go offline; `agent release` just makes it immediate.
2770
+ - Registers in the session's **data lane**. A `test`-lane run only ever reaches a `test`-lane agent,
2771
+ which is what keeps fixture traffic away from a production terminal.
2772
+
2773
+ ### Resolving which agent a command means
2774
+
2775
+ Order: `--agent-id`, then `REMITS_AGENT_ID`, then the single agent registered for this working
2776
+ directory. With several registered and no way to tell them apart, the command **fails and lists the
2777
+ candidates** rather than guessing — routing work to the wrong tab is silent, and a message is not.
2695
2778
 
2696
- ### Starting the Service
2779
+ ### Which agent gets a ticket
2780
+
2781
+ The platform walks a ladder — the ticket's implementation account first (a defect seen on a client is
2782
+ usually fixed in the platform repo above it), then the ticket's own account, then its
2783
+ `PLATFORM`/`PRODUCT` ancestors — and takes the first account with an available agent. Among those it
2784
+ prefers an **idle** agent, then the one that has waited longest, so work spreads across your tabs
2785
+ instead of piling onto whichever one most recently ran a command. A `paused` agent stays visible and
2786
+ is never routed to.
2787
+
2788
+ ## Background Service and Control Center
2789
+
2790
+ `remits-cli start` runs an optional background service for the **human** watching:
2791
+
2792
+ - Maintains persistent WebSocket connections to the Remits platform
2793
+ - Hosts a localhost browser **control center** (typically `http://127.0.0.1:8787/`)
2697
2794
 
2698
2795
  ```bash
2699
2796
  remits-cli start
@@ -2711,50 +2808,27 @@ remits-cli listen status
2711
2808
  remits-cli listen stop
2712
2809
  ```
2713
2810
 
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
2811
+ **The service is not part of ticket delivery.** Agents register and collect work on their own, so the
2812
+ dashboard being down never stops a ticket reaching an agent. What the service adds is visibility: it
2813
+ scans for `account-info.json` files to rebuild the repo index, keeps one WebSocket per platform URL,
2814
+ and holds a PID lock (`~/.remits-cli/listener.pid`) so only one runs per machine.
2722
2815
 
2723
2816
  ### Control Center
2724
2817
 
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
2818
+ The control center shows, in one browser view:
2819
+ - which agent sessions are registered, what each is doing right now, and its recent activity
2820
+ - the open support-ticket queue, and which agent each ticket is routed to
2821
+ - a control to route a ticket at a specific available agent
2730
2822
  - 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.
2741
-
2742
- When a `remits-cli` WebSocket message arrives from the platform:
2823
+ - the discovered account repo index and the important global/per-repo files
2743
2824
 
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
2825
+ **What it shows is what the agents see.** The ticket queue comes from the platform's own generic
2826
+ endpoint, not from any product's tool, so the control center reads the same on every Remits platform
2827
+ and never implies a workflow that a particular product does not have. Product-specific views belong
2828
+ in that product's Embeddables.
2748
2829
 
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.
2830
+ When a user asks a broad or vague question about remits-cli behavior, prefer reasoning from the
2831
+ control center state before spelunking individual files.
2758
2832
 
2759
2833
  ### Configuring the Preferred Agent
2760
2834
 
@@ -2788,11 +2862,13 @@ The agent preference is stored in `~/.remits-cli/config.json` and applies global
2788
2862
  - `listener.pid`
2789
2863
  - PID of the background remits-cli service process.
2790
2864
  - 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.
2865
+ - `agents.json`
2866
+ - The agent sessions registered from this machine, each with the process it is anchored to.
2867
+ - Read this when a command asks for `--agent-id`, or when an agent appears registered locally but
2868
+ is missing from `remits-cli agent list` (that gap IS the "why am I not getting tickets" answer).
2869
+ - `activity.log`
2870
+ - Human-readable chronological event log for service lifecycle, websocket events, agent
2871
+ registration/heartbeat, and ticket routing.
2796
2872
  - This is usually the best forensic file for "what happened?" questions.
2797
2873
 
2798
2874
  **Per-repo** (`./.remits-cli/`):
@@ -2821,6 +2897,11 @@ Reading rules:
2821
2897
  remits-cli auth [--base-url URL] [--account-id ID] [--data-mode test|prod]
2822
2898
  remits-cli sessions [list|remove] [--account-id ID]
2823
2899
  remits-cli config [set] [--agent claude|codex|gemini]
2900
+ remits-cli agent register [--label NAME] [--data-mode test|prod] [--account-id ID]
2901
+ remits-cli agent work [--wait SECONDS] [--json]
2902
+ remits-cli agent status [--state idle|working|paused] [--ticket ID] [--activity "..."] [--step "..."]
2903
+ remits-cli agent list [--account-id ID] [--json]
2904
+ remits-cli agent release
2824
2905
  remits-cli start [--foreground true] [--port 8787]
2825
2906
  remits-cli stop
2826
2907
  remits-cli status [--base-url URL] [--account-id ID] [--data-mode test|prod] [--json]
@@ -2946,7 +3027,6 @@ For tests specifically:
2946
3027
  | 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
3028
  | 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
3029
  | 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
3030
  | Control center URL unknown | Read `~/.remits-cli/service-state.json` or run `remits-cli status` |
2951
3031
  | Dashboard missing repos | Rebuild `~/.remits-cli/account-repos.json` with `remits-cli start` or the control center rescan action |
2952
3032
  | 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 +3087,13 @@ which is the source served to every account repo. Better guides over time are an
3007
3087
  - the active repo session log from `./.remits-cli/sessions/`
3008
3088
  - any `./.remits-cli/tool-responses/<callId>.json` files involved
3009
3089
  - `~/.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
3090
+ - `~/.remits-cli/activity.log` if service / websocket / agent-routing behavior may be relevant
3011
3091
 
3012
3092
  2. **Use the global Remits CLI state to make the bundle self-contained.**
3013
3093
  - Read `./.remits-cli/current-session.txt` to identify the active repo session log.
3014
3094
  - Record the exact repo directory and account context from `account-info.json`.
3015
3095
  - 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`.
3096
+ - If the problem involves support-ticket routing, agent registration, or websocket events, include the relevant lines from `~/.remits-cli/activity.log`.
3017
3097
  - If a tool call stored its full response externally, include that file path and summarize the important fields in `summary.md`.
3018
3098
 
3019
3099
  3. **Stop and document the issue clearly for the user.**