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>
20 lines
897 B
Dart
20 lines
897 B
Dart
/// Tests for the `instance` command verb (T-247) — this clide's identity
|
|
/// (version / pid / workspace / socket path), the per-instance metadata the
|
|
/// `clide instances` CLI verb aggregates. Covers the dispatch mechanics
|
|
/// independent of the C client.
|
|
library;
|
|
|
|
import 'package:clide/clide.dart';
|
|
import 'package:clide/src/daemon/instance_command.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
test('instance resolves and returns version/pid/workspace/socketPath', () async {
|
|
final d = DaemonDispatcher();
|
|
registerInstanceCommand(d, version: '1.2.3', pid: 4242, workspace: '/repo', socketPath: '/run/user/1000/clide/abc.sock');
|
|
final r = await d.dispatch(IpcRequest(id: '1', cmd: 'instance', args: const {}));
|
|
expect(r.ok, isTrue);
|
|
expect(r.data, {'version': '1.2.3', 'pid': 4242, 'workspace': '/repo', 'socketPath': '/run/user/1000/clide/abc.sock'});
|
|
});
|
|
}
|