@hediet/linkrpc-cli 0.0.3-next.20260922.2 → 0.0.3-next.20260924.1

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/README.md CHANGED
@@ -6,8 +6,161 @@ The CLI speaks plain linkrpc over sockets, WebSockets, or a child process's
6
6
  stdio: it connects to (or spawns) the server you point it at and drives it
7
7
  through the JSON-RPC channel. Reflection
8
8
  interfaces (`hubrpc.defaults`, `hubrpc.directory`, `hubrpc.schemas`) are
9
- used to discover what the endpoint exposes; the CLI is otherwise generic — it
10
- has no compiled-in knowledge of any particular interface.
9
+ used to discover what the endpoint exposes. Generic RPC commands work with any
10
+ reflected interface; compiled-in views add specialized CLI and TUI renderers.
11
+
12
+ ## Views
13
+
14
+ Views target an **interface** or a **service** (including the main/root service),
15
+ not a service-name-prefix tree. The compiled-in typed registry is shared by the
16
+ CLI and terminal UI:
17
+
18
+ ```sh
19
+ rpc view list
20
+ rpc --endpoint ws://localhost:7700 view targets graph --json
21
+ rpc --endpoint ws://localhost:7700 view open graph --target 'service::' --mode roots --json
22
+ rpc --endpoint ws://localhost:7700 view open graph --target 'service::' --root sessions --params '{}' --json
23
+ rpc --endpoint ws://localhost:7700 view open graph --target 'service::' --root sessions --mode watch --json
24
+ rpc --endpoint ws://localhost:7700 view open graph --target 'service::' --tui
25
+ ```
26
+
27
+ `view list` is offline and prints modes and conditions, for example
28
+ `interface:tag(linkrpc.graph)` and `service:implements(tag(linkrpc.graph))`.
29
+ Conditions match interface IDs or tags, never template IDs. `view targets`
30
+ returns `{ targets, warnings }` with `--json`; targets include their stable `id`,
31
+ `kind`, service route, reporting directory, and implemented interfaces. IDs are
32
+ opaque within the selected endpoint/context and are not row numbers. They do
33
+ not pin schema hashes. The root service reported by the root directory has ID
34
+ `service::`; use the returned IDs for other targets.
35
+
36
+ For spawned/ephemeral endpoints, discover and open on **one connection**:
37
+
38
+ ```sh
39
+ rpc view open graph --interface explorer.graph.v1 --root workspace --json --depth 2 \
40
+ --endpoint-cmd-stdio '<server command>'
41
+ rpc view open graph --interface explorer.graph.v1 --root workspace --tui \
42
+ --endpoint-cmd-stdio '<server command>'
43
+ ```
44
+
45
+ Without `--target`, an exact `--interface` must resolve uniquely. `--service`
46
+ can narrow it, or select a service target by itself. Ambiguity is an error;
47
+ the CLI never chooses the first row. A main interface's default and qualified
48
+ reflection entries count as one implementation, preferring its default route.
49
+ Wrappers may choose `--tui` when stdin and stdout are terminals and otherwise
50
+ use `--json`; the CLI itself remains noninteractive unless `--tui` is explicit.
51
+
52
+ Advertised directory tags allow matching without downloading schemas.
53
+ Absent tags mean no advertised labels: there is no implicit legacy schema scan.
54
+ Interface-ID conditions still match without tags. Listing targets does
55
+ not start watches or load graph data. Opening re-resolves the target and its
56
+ latest schema through the reporting directory, validates the graph template
57
+ contracts and member mappings, and requires compatible roots/object stores.
58
+ Tags are untrusted discovery hints, not permissions or proof of capability.
59
+
60
+ Graph modes:
61
+
62
+ - `--mode roots`: list root names, interface IDs, and parameter schemas without
63
+ starting a graph watch.
64
+ - `--mode snapshot` (default): materialize one root, then cancel its watch.
65
+ `--json` emits the materialized value; unresolved references and cycles use
66
+ `$ref` with `$missing`/`$cycle` markers.
67
+ - `--mode watch`: keep the root watch open until Ctrl-C. With `--json`, emit one
68
+ complete materialized value per JSONL line.
69
+ - `--tui`: explicitly launch the Ink graph browser. There is no automatic
70
+ TTY-dependent mode switch. Multiple roots open a picker; `--root` and
71
+ `--interface` disambiguate. `p` edits JSON parameters, Enter opens a root,
72
+ arrow keys navigate/expand/collapse, `r` returns to roots, and `q` exits.
73
+ The browser fetches one reference level beyond expanded nodes, so collapsed
74
+ rows can show their objects' `title` or `name`. This also refreshes collapsed
75
+ titles when watched roots change. It fetches full objects (which may be large
76
+ or trigger a deferred load), but does not recursively follow their references.
77
+ This is a CLI browsing policy, not a graph protocol or preview feature.
78
+
79
+ `--depth`, `--path`, `--max-objects`, `--max-bytes`, `--max-rounds`,
80
+ `--timeout-ms`, and `--log-timing` bound or diagnose graph loading. The default
81
+ snapshot depth is 2; TUI loading is demand-driven. `--max-depth` bounds directory
82
+ discovery. Use `view open graph --help` for contribution-specific options.
83
+
84
+ Logging uses the canonical `linkrpc.logging` interface from
85
+ `@hediet/linkrpc-infra`. Its ID matches older producers even when directory
86
+ tags are absent. Listing targets does not fetch schemas or logs; opening checks
87
+ the selected interface's actual logging contract, so a tag alone is not enough.
88
+
89
+ ```sh
90
+ rpc view targets logging --json
91
+ rpc --endpoint ws://localhost:7700 view open logging --interface linkrpc.logging --json
92
+ rpc --endpoint ws://localhost:7700 view open logging --interface linkrpc.logging --mode watch --json
93
+ rpc --endpoint ws://localhost:7700 view open logging --interface linkrpc.logging --tui
94
+ ```
95
+
96
+ Snapshot uses the read-only `getLogSnapshot` operation. Watch uses `watchLog`
97
+ (initial snapshot followed by revisioned JSON document patches); a revision
98
+ gap triggers `getLogSnapshot` resynchronization. Each `--json` watch line is a
99
+ complete bounded frame with `revision`, `service`, `startedAt`, `state`,
100
+ `entries`, and `hidden` (earlier matching entries omitted by `--tail`).
101
+ Use `--level` and `--tail` for local display filtering and `--max-bytes` to
102
+ reject oversized authoritative documents (and stop the watch), not to truncate
103
+ them: truncation would corrupt subsequent positional JSON-pointer patches.
104
+ The protocol does not offer a server-side cursor, filter, or backfill beyond
105
+ its snapshot. Thus document retention still depends on the producer's size and
106
+ `--max-bytes` may stop a growing stream; `--tail` only bounds rendered rows.
107
+ No read or local filter change implicitly calls `setLogLevel`.
108
+ The TUI navigates entries with arrows/Page Up/Page Down; `p` pauses display,
109
+ `f` toggles follow, `l` cycles the local level filter, and `c` clears the
110
+ display locally, never remote logs. Clear tracks overlapping retained entries
111
+ across rolling buffers; when a replacement is ambiguous (such as duplicate
112
+ entries without stable IDs), entries may reappear rather than hiding new logs.
113
+ `q` closes the tab/standalone UI.
114
+
115
+ ### Topology view
116
+
117
+ The contributed `topology` view inspects **one selected service's** canonical
118
+ `hubrpc.topology` interface. It is not the network-wide Hub topology scan.
119
+ Interface and service targets match the interface ID, without requiring tags;
120
+ opening validates the current canonical schema and uses the selected default
121
+ or qualified route.
122
+
123
+ ```sh
124
+ rpc --endpoint ws://localhost:7700 view targets topology --json
125
+ rpc --endpoint ws://localhost:7700 view open topology --target 'service::'
126
+ rpc --endpoint ws://localhost:7700 view open topology --interface hubrpc.topology --service demo --json
127
+ rpc --endpoint ws://localhost:7700 view open topology --target 'service::' --mode watch --json
128
+ rpc --endpoint ws://localhost:7700 view open topology --target 'service::' --tui
129
+ ```
130
+
131
+ Snapshot is the default and reads the full `getGraph` result. Watch subscribes
132
+ to `watchGraph` invalidations and re-fetches the full authoritative result;
133
+ `--json` emits one complete snapshot per JSONL line, including all nodes,
134
+ ports, links, transport metadata, descriptors and route claims. Fetch/watch
135
+ errors are reported, not treated as empty topology. `--timeout-ms` bounds
136
+ individual snapshot fetches. Closing a view cancels its watch and pending
137
+ fetches without closing the shared connection.
138
+
139
+ Text output uses `beautiful-mermaid` to draw Unicode boxes and **undirected**
140
+ connection lines. Placement and `from`/`to` endpoint roles do not imply RPC
141
+ direction. Generated node IDs link the diagram to complete node/link/route
142
+ records below it. Box labels are abbreviated ASCII-safe hints; those records
143
+ preserve complete Unicode labels. Remote text cannot supply Mermaid syntax.
144
+ Parallel links share a diagram line, but every link and exact port pair remains
145
+ in the numbered link records. Self-links, cycles and disconnected nodes are
146
+ retained. Unlisted endpoints are marked explicitly. If layout fails or exceeds
147
+ 200 nodes/400 distinct connections, the text explains why the diagram is
148
+ omitted and still includes all authoritative records.
149
+
150
+ In the standalone TUI and regular UI's Topology tab, arrows scroll vertically
151
+ and horizontally, Page Up/Down and `[`/`]` page, Home/End jump vertically,
152
+ `r` refreshes the snapshot, and `?` shows the actual contributed command list.
153
+ The live diagram and records share one bounded, scrollable document. Normal
154
+ host keys still apply: `q`/Ctrl-C quit, and Tab/Escape navigate the regular UI.
155
+ No topology command changes the inspected service or interprets route claims
156
+ as proof of authority.
157
+
158
+ The regular `rpc ui` / `hub ui` has Methods and Schema tabs plus matching
159
+ contributed views. Tab cycles views and `v` switches interface/service scope;
160
+ the displayed conditions explain availability. Graph sessions cancel when
161
+ inactive or disconnected, ignore stale asynchronous results, and restore the
162
+ selected root/params after reconnection. Escape returns focus to the services
163
+ column. Static `--schema` profiles apply to both commands and UI.
11
164
 
12
165
  ## Profiles
13
166
 
@@ -340,18 +493,23 @@ commands:
340
493
  ```sh
341
494
  export LINKRPC_ENDPOINT="$(
342
495
  hub --endpoint 'ws-no-init://localhost:4123?tkn=…' \
343
- connection create --timeout 30s --ttl 5min --schema ./ahp-schema.json
496
+ connection create --timeout 30s --ttl 5min --schema ./service-schema.json
344
497
  )"
345
498
 
346
499
  hub defaults
347
- hub schema show ahp --method initialize
348
- hub call initialize --params '{"channel":"ahp-root://","protocolVersions":["0.6.0"],"clientId":"hub"}'
349
- hub call listSessions --params '{"channel":"ahp-root://","limit":50}'
500
+ hub ls
501
+ hub schema show example.counter --method get
502
+ hub call get --params '{}'
350
503
  hub connection notifications --follow
351
504
  hub connection status
352
505
  hub connection destroy
353
506
  ```
354
507
 
508
+ This example assumes the schema document declares `example.counter` as its
509
+ default interface and the remote JSON-RPC service exposes a bare `get` method.
510
+ Protocol-specific schema generators and initialization sequences belong in
511
+ the consuming application, not the generic CLI.
512
+
355
513
  The endpoint contains a local authentication token and should be treated as a
356
514
  secret. The broker handles `hubrpc.connectionBroker::status`,
357
515
  `hubrpc.connectionBroker::readNotifications`, and