Files
clide/lib/src/daemon/instance_command.dart
T
jpmschweitzerandClaude Opus 4.8 679b5ba9d9 feat(cli): clide instances / instance verbs for instance discovery (T-247)
Closes the observability half of T-247: a way to find and identify running
clides. `clide instances` scans the runtime socket dir, probes each live
*.sock, and prints its identity (version/pid/workspace/socketPath) as jsonl;
dead sockets are skipped. `clide instance` reports the one you're connected
to. Combined with CLIDE_SOCK honoring (this same ticket), you can now list
instances and pin the CLI to a chosen one.

Server: a new `instance` dispatcher command (registered in buildDispatcher
with the live workspace/pid/socket) returns the identity map; added to the
argv translator's umbrella set so a bare `instance` token routes to it.
Client: a POSIX dir-scan in clide.c (Windows stub until it ships).

Tests: e2e `instances` lists the live test server with its identity; a
cc-free unit test covers the `instance` command shape.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 15:51:13 +02:00

17 lines
897 B
Dart

/// Registers the `instance` command — this running clide's identity in one
/// round-trip (T-247): version, pid, workspace root, and socket path. It's the
/// per-instance metadata the `clide instances` CLI verb aggregates (by probing
/// every live socket in the runtime dir), and it lets a human or agent confirm
/// *which* instance a given socket belongs to.
///
/// Thin + Flutter-free: the caller (main.dart) passes the values it already
/// holds at dispatcher-build time, so this stays trivially testable.
library;
import '../ipc/envelope.dart';
import 'dispatcher.dart';
void registerInstanceCommand(DaemonDispatcher d, {required String version, required int pid, required String workspace, required String socketPath}) {
d.register('instance', (req) async => IpcResponse.ok(id: req.id, data: {'version': version, 'pid': pid, 'workspace': workspace, 'socketPath': socketPath}));
}