chore: adopt Dart 3.9 toolchain — honest floor + tall-style reformat (T-353)
Raise the declared minimums in pubspec.yaml to what our deps already require: Flutter >=3.35.0 / Dart >=3.9.0 (was 3.19.0 / 3.5.0). alchemist 0.12 needs Flutter 3.32; Dart 3.9 first ships in Flutter 3.35, so 3.35 is the binding floor. Pin the exact build toolchain in .fvmrc (Flutter 3.44.1). Moving to the Dart 3.9 language level switches `dart format` to the new "tall" style and enables two new lints. This commit is the resulting mechanical churn, isolated from any behaviour change: - whole-tree `dart format` reformat (tall style) - `dart fix` for unnecessary_underscores + use_null_aware_elements No runtime behaviour change; `make test` green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -211,10 +211,6 @@ class SchemaResult {
|
||||
|
||||
/// Build the standard `userError` response for a schema violation.
|
||||
IpcResponse schemaError(String id, String message) => IpcResponse.err(
|
||||
id: id,
|
||||
error: IpcError(
|
||||
code: IpcExitCode.userError,
|
||||
kind: IpcErrorKind.userError,
|
||||
message: message,
|
||||
),
|
||||
);
|
||||
id: id,
|
||||
error: IpcError(code: IpcExitCode.userError, kind: IpcErrorKind.userError, message: message),
|
||||
);
|
||||
|
||||
+31
-72
@@ -27,47 +27,25 @@ sealed class IpcMessage {
|
||||
}
|
||||
|
||||
class IpcRequest extends IpcMessage {
|
||||
IpcRequest({
|
||||
required this.id,
|
||||
required this.cmd,
|
||||
this.args = const {},
|
||||
});
|
||||
IpcRequest({required this.id, required this.cmd, this.args = const {}});
|
||||
|
||||
final String id;
|
||||
final String cmd;
|
||||
final Map<String, Object?> args;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => {
|
||||
'type': 'request',
|
||||
'v': ipcSchemaVersion,
|
||||
'id': id,
|
||||
'cmd': cmd,
|
||||
'args': args,
|
||||
};
|
||||
Map<String, Object?> toJson() => {'type': 'request', 'v': ipcSchemaVersion, 'id': id, 'cmd': cmd, 'args': args};
|
||||
|
||||
factory IpcRequest.fromJson(Map<String, Object?> j) => IpcRequest(
|
||||
id: j['id']! as String,
|
||||
cmd: j['cmd']! as String,
|
||||
args: (j['args'] as Map?)?.cast<String, Object?>() ?? const {},
|
||||
);
|
||||
factory IpcRequest.fromJson(Map<String, Object?> j) =>
|
||||
IpcRequest(id: j['id']! as String, cmd: j['cmd']! as String, args: (j['args'] as Map?)?.cast<String, Object?>() ?? const {});
|
||||
}
|
||||
|
||||
class IpcResponse extends IpcMessage {
|
||||
IpcResponse.ok({required this.id, this.data = const {}})
|
||||
: ok = true,
|
||||
error = null;
|
||||
IpcResponse.ok({required this.id, this.data = const {}}) : ok = true, error = null;
|
||||
|
||||
IpcResponse.err({required this.id, required IpcError this.error})
|
||||
: ok = false,
|
||||
data = const {};
|
||||
IpcResponse.err({required this.id, required IpcError this.error}) : ok = false, data = const {};
|
||||
|
||||
IpcResponse._({
|
||||
required this.id,
|
||||
required this.ok,
|
||||
required this.data,
|
||||
required this.error,
|
||||
});
|
||||
IpcResponse._({required this.id, required this.ok, required this.data, required this.error});
|
||||
|
||||
final String id;
|
||||
final bool ok;
|
||||
@@ -76,13 +54,13 @@ class IpcResponse extends IpcMessage {
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => {
|
||||
'type': 'response',
|
||||
'v': ipcSchemaVersion,
|
||||
'id': id,
|
||||
'ok': ok,
|
||||
if (ok) 'data': data,
|
||||
if (!ok && error != null) 'error': error!.toJson(),
|
||||
};
|
||||
'type': 'response',
|
||||
'v': ipcSchemaVersion,
|
||||
'id': id,
|
||||
'ok': ok,
|
||||
if (ok) 'data': data,
|
||||
if (!ok && error != null) 'error': error!.toJson(),
|
||||
};
|
||||
|
||||
factory IpcResponse.fromJson(Map<String, Object?> j) {
|
||||
final ok = j['ok'] as bool? ?? false;
|
||||
@@ -96,40 +74,21 @@ class IpcResponse extends IpcMessage {
|
||||
}
|
||||
|
||||
class IpcError {
|
||||
IpcError({
|
||||
required this.code,
|
||||
required this.kind,
|
||||
required this.message,
|
||||
this.hint,
|
||||
});
|
||||
IpcError({required this.code, required this.kind, required this.message, this.hint});
|
||||
|
||||
final int code;
|
||||
final String kind;
|
||||
final String message;
|
||||
final String? hint;
|
||||
|
||||
Map<String, Object?> toJson() => {
|
||||
'code': code,
|
||||
'kind': kind,
|
||||
'message': message,
|
||||
if (hint != null) 'hint': hint,
|
||||
};
|
||||
Map<String, Object?> toJson() => {'code': code, 'kind': kind, 'message': message, if (hint != null) 'hint': hint};
|
||||
|
||||
factory IpcError.fromJson(Map<String, Object?> j) => IpcError(
|
||||
code: (j['code'] as num).toInt(),
|
||||
kind: j['kind']! as String,
|
||||
message: j['message']! as String,
|
||||
hint: j['hint'] as String?,
|
||||
);
|
||||
factory IpcError.fromJson(Map<String, Object?> j) =>
|
||||
IpcError(code: (j['code'] as num).toInt(), kind: j['kind']! as String, message: j['message']! as String, hint: j['hint'] as String?);
|
||||
}
|
||||
|
||||
class IpcEvent extends IpcMessage {
|
||||
IpcEvent({
|
||||
required this.subsystem,
|
||||
required this.kind,
|
||||
required this.timestamp,
|
||||
this.data = const {},
|
||||
});
|
||||
IpcEvent({required this.subsystem, required this.kind, required this.timestamp, this.data = const {}});
|
||||
|
||||
final String subsystem;
|
||||
final String kind;
|
||||
@@ -138,18 +97,18 @@ class IpcEvent extends IpcMessage {
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() => {
|
||||
'type': 'event',
|
||||
'v': ipcSchemaVersion,
|
||||
'subsystem': subsystem,
|
||||
'kind': kind,
|
||||
'ts': timestamp.toIso8601String(),
|
||||
'data': data,
|
||||
};
|
||||
'type': 'event',
|
||||
'v': ipcSchemaVersion,
|
||||
'subsystem': subsystem,
|
||||
'kind': kind,
|
||||
'ts': timestamp.toIso8601String(),
|
||||
'data': data,
|
||||
};
|
||||
|
||||
factory IpcEvent.fromJson(Map<String, Object?> j) => IpcEvent(
|
||||
subsystem: j['subsystem']! as String,
|
||||
kind: j['kind']! as String,
|
||||
timestamp: DateTime.parse(j['ts']! as String),
|
||||
data: (j['data'] as Map?)?.cast<String, Object?>() ?? const {},
|
||||
);
|
||||
subsystem: j['subsystem']! as String,
|
||||
kind: j['kind']! as String,
|
||||
timestamp: DateTime.parse(j['ts']! as String),
|
||||
data: (j['data'] as Map?)?.cast<String, Object?>() ?? const {},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,20 +33,11 @@ abstract class PosixErrno {
|
||||
/// (e.g. `pane.spawn`, `editor.open`) on optional [target] (a path,
|
||||
/// command name, etc.). The returned error uses `notFound`,
|
||||
/// `userError`, or `toolError` based on what's actionable.
|
||||
IpcError errnoToIpcError({
|
||||
required int errno,
|
||||
required String op,
|
||||
String? target,
|
||||
String? raw,
|
||||
}) {
|
||||
IpcError errnoToIpcError({required int errno, required String op, String? target, String? raw}) {
|
||||
final what = target != null ? ' ($target)' : '';
|
||||
switch (errno) {
|
||||
case PosixErrno.enoent:
|
||||
return IpcError(
|
||||
code: IpcExitCode.notFound,
|
||||
kind: IpcErrorKind.notFound,
|
||||
message: '$op: not found$what',
|
||||
);
|
||||
return IpcError(code: IpcExitCode.notFound, kind: IpcErrorKind.notFound, message: '$op: not found$what');
|
||||
case PosixErrno.eacces:
|
||||
case PosixErrno.eperm:
|
||||
return IpcError(
|
||||
@@ -56,23 +47,11 @@ IpcError errnoToIpcError({
|
||||
hint: 'check file permissions or run with appropriate access',
|
||||
);
|
||||
case PosixErrno.eisdir:
|
||||
return IpcError(
|
||||
code: IpcExitCode.userError,
|
||||
kind: IpcErrorKind.userError,
|
||||
message: '$op: is a directory$what',
|
||||
);
|
||||
return IpcError(code: IpcExitCode.userError, kind: IpcErrorKind.userError, message: '$op: is a directory$what');
|
||||
case PosixErrno.enotdir:
|
||||
return IpcError(
|
||||
code: IpcExitCode.userError,
|
||||
kind: IpcErrorKind.userError,
|
||||
message: '$op: not a directory$what',
|
||||
);
|
||||
return IpcError(code: IpcExitCode.userError, kind: IpcErrorKind.userError, message: '$op: not a directory$what');
|
||||
case PosixErrno.eexist:
|
||||
return IpcError(
|
||||
code: IpcExitCode.conflict,
|
||||
kind: IpcErrorKind.conflict,
|
||||
message: '$op: already exists$what',
|
||||
);
|
||||
return IpcError(code: IpcExitCode.conflict, kind: IpcErrorKind.conflict, message: '$op: already exists$what');
|
||||
case PosixErrno.emfile:
|
||||
case PosixErrno.enfile:
|
||||
return IpcError(
|
||||
@@ -82,23 +61,10 @@ IpcError errnoToIpcError({
|
||||
hint: 'system or per-process file descriptor limit reached',
|
||||
);
|
||||
case PosixErrno.enomem:
|
||||
return IpcError(
|
||||
code: IpcExitCode.toolError,
|
||||
kind: IpcErrorKind.toolError,
|
||||
message: '$op: out of memory',
|
||||
);
|
||||
return IpcError(code: IpcExitCode.toolError, kind: IpcErrorKind.toolError, message: '$op: out of memory');
|
||||
case PosixErrno.eagain:
|
||||
return IpcError(
|
||||
code: IpcExitCode.toolError,
|
||||
kind: IpcErrorKind.toolError,
|
||||
message: '$op: resource temporarily unavailable',
|
||||
hint: 'retry may succeed',
|
||||
);
|
||||
return IpcError(code: IpcExitCode.toolError, kind: IpcErrorKind.toolError, message: '$op: resource temporarily unavailable', hint: 'retry may succeed');
|
||||
default:
|
||||
return IpcError(
|
||||
code: IpcExitCode.toolError,
|
||||
kind: IpcErrorKind.toolError,
|
||||
message: '$op failed${raw != null ? ': $raw' : ' (errno=$errno)'}',
|
||||
);
|
||||
return IpcError(code: IpcExitCode.toolError, kind: IpcErrorKind.toolError, message: '$op failed${raw != null ? ': $raw' : ' (errno=$errno)'}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,14 +63,7 @@ class _McpSession {
|
||||
/// HTTP + SSE MCP server. Lifecycle mirrors [IpcServer]: `start()`
|
||||
/// binds + writes the discovery file; `stop()` unbinds + removes it.
|
||||
class McpServer {
|
||||
McpServer({
|
||||
required this.workspaceRoot,
|
||||
required this.log,
|
||||
this.dispatcher,
|
||||
this.discoveryDirOverride,
|
||||
this.bindHost = '127.0.0.1',
|
||||
this.bindPort = 0,
|
||||
});
|
||||
McpServer({required this.workspaceRoot, required this.log, this.dispatcher, this.discoveryDirOverride, this.bindHost = '127.0.0.1', this.bindPort = 0});
|
||||
|
||||
/// Workspace root reported in the discovery file. Helps Claude
|
||||
/// Code show "which clide is this" when multiple are running.
|
||||
@@ -109,9 +102,12 @@ class McpServer {
|
||||
_http = server;
|
||||
_port = server.port;
|
||||
_lockFile = await _writeDiscoveryFile();
|
||||
server.listen(_route, onError: (Object e, StackTrace st) {
|
||||
log.warn('mcp', 'http error: $e');
|
||||
});
|
||||
server.listen(
|
||||
_route,
|
||||
onError: (Object e, StackTrace st) {
|
||||
log.warn('mcp', 'http error: $e');
|
||||
},
|
||||
);
|
||||
log.info('mcp', 'MCP/SSE listening at http://$bindHost:${server.port} (workspace: $workspaceRoot)');
|
||||
}
|
||||
|
||||
@@ -331,12 +327,7 @@ class McpServer {
|
||||
dirHandle.createSync(recursive: true);
|
||||
}
|
||||
final path = '$dir/$pid.lock';
|
||||
final body = jsonEncode({
|
||||
'pid': pid,
|
||||
'workspace': workspaceRoot,
|
||||
'transport': 'sse',
|
||||
'url': 'http://$bindHost:$_port/sse',
|
||||
});
|
||||
final body = jsonEncode({'pid': pid, 'workspace': workspaceRoot, 'transport': 'sse', 'url': 'http://$bindHost:$_port/sse'});
|
||||
File(path).writeAsStringSync(body);
|
||||
return path;
|
||||
}
|
||||
|
||||
+18
-51
@@ -23,14 +23,7 @@ import 'package:clide/src/ipc/schema_v1.dart';
|
||||
/// D-72. Per-handler isolate offload is the dispatcher / handler's
|
||||
/// concern, not this layer's.
|
||||
class IpcServer {
|
||||
IpcServer({
|
||||
required this.dispatcher,
|
||||
required this.workspaceRoot,
|
||||
required this.log,
|
||||
this.events,
|
||||
this.replayDepth = 16,
|
||||
this.eventLogDepth = 1024,
|
||||
});
|
||||
IpcServer({required this.dispatcher, required this.workspaceRoot, required this.log, this.events, this.replayDepth = 16, this.eventLogDepth = 1024});
|
||||
|
||||
final DaemonDispatcher dispatcher;
|
||||
final String workspaceRoot;
|
||||
@@ -94,10 +87,7 @@ class IpcServer {
|
||||
final path = workspaceSocketPath(workspaceRoot);
|
||||
await _prepareParentDir(path);
|
||||
await _unlinkStale(path);
|
||||
final socket = await ServerSocket.bind(
|
||||
InternetAddress(path, type: InternetAddressType.unix),
|
||||
0,
|
||||
);
|
||||
final socket = await ServerSocket.bind(InternetAddress(path, type: InternetAddressType.unix), 0);
|
||||
try {
|
||||
await _chmod(path, 0x180); // 0o600
|
||||
} catch (e, st) {
|
||||
@@ -108,9 +98,12 @@ class IpcServer {
|
||||
}
|
||||
_socket = socket;
|
||||
_socketPath = path;
|
||||
_accepts = socket.listen(_onClient, onError: (Object e, StackTrace st) {
|
||||
log.error('ipc', 'accept loop error', error: e, stackTrace: st);
|
||||
});
|
||||
_accepts = socket.listen(
|
||||
_onClient,
|
||||
onError: (Object e, StackTrace st) {
|
||||
log.error('ipc', 'accept loop error', error: e, stackTrace: st);
|
||||
},
|
||||
);
|
||||
// Subscribe to the bus so we can populate the replay ring AND
|
||||
// fan out to live `tail --events` subscribers. Idempotent —
|
||||
// we only attach when a bus is supplied.
|
||||
@@ -198,11 +191,7 @@ class IpcServer {
|
||||
if (msg is! IpcRequest) {
|
||||
response = IpcResponse.err(
|
||||
id: '',
|
||||
error: IpcError(
|
||||
code: IpcExitCode.userError,
|
||||
kind: IpcErrorKind.userError,
|
||||
message: 'expected request, got ${msg.runtimeType}',
|
||||
),
|
||||
error: IpcError(code: IpcExitCode.userError, kind: IpcErrorKind.userError, message: 'expected request, got ${msg.runtimeType}'),
|
||||
);
|
||||
} else {
|
||||
// Peel off the `_argv` envelope at the server layer so the
|
||||
@@ -238,21 +227,13 @@ class IpcServer {
|
||||
} on FormatException catch (e) {
|
||||
response = IpcResponse.err(
|
||||
id: '',
|
||||
error: IpcError(
|
||||
code: IpcExitCode.userError,
|
||||
kind: IpcErrorKind.userError,
|
||||
message: 'malformed request: ${e.message}',
|
||||
),
|
||||
error: IpcError(code: IpcExitCode.userError, kind: IpcErrorKind.userError, message: 'malformed request: ${e.message}'),
|
||||
);
|
||||
} catch (e, st) {
|
||||
log.error('ipc', 'dispatch threw for "$reqCmd"', error: e, stackTrace: st);
|
||||
response = IpcResponse.err(
|
||||
id: '',
|
||||
error: IpcError(
|
||||
code: IpcExitCode.toolError,
|
||||
kind: IpcErrorKind.toolError,
|
||||
message: 'internal error: $e',
|
||||
),
|
||||
error: IpcError(code: IpcExitCode.toolError, kind: IpcErrorKind.toolError, message: 'internal error: $e'),
|
||||
);
|
||||
}
|
||||
try {
|
||||
@@ -280,10 +261,7 @@ class IpcServer {
|
||||
if (!f.existsSync()) return;
|
||||
// Probe: try connecting. If something answers, refuse to bind.
|
||||
try {
|
||||
final test = await Socket.connect(
|
||||
InternetAddress(path, type: InternetAddressType.unix),
|
||||
0,
|
||||
).timeout(const Duration(milliseconds: 200));
|
||||
final test = await Socket.connect(InternetAddress(path, type: InternetAddressType.unix), 0).timeout(const Duration(milliseconds: 200));
|
||||
await test.close();
|
||||
throw StateError('another clide IPC server is already listening on $path');
|
||||
} on SocketException {
|
||||
@@ -355,11 +333,7 @@ class IpcServer {
|
||||
if (since == null) {
|
||||
return IpcResponse.err(
|
||||
id: req.id,
|
||||
error: IpcError(
|
||||
code: IpcExitCode.userError,
|
||||
kind: IpcErrorKind.userError,
|
||||
message: '--since must be a non-negative integer cursor',
|
||||
),
|
||||
error: IpcError(code: IpcExitCode.userError, kind: IpcErrorKind.userError, message: '--since must be a non-negative integer cursor'),
|
||||
);
|
||||
}
|
||||
final out = <Map<String, Object?>>[];
|
||||
@@ -371,12 +345,10 @@ class IpcServer {
|
||||
// A gap only means something when the caller had a prior position
|
||||
// (since > 0); a first read (since 0) just gets whatever's retained.
|
||||
final gap = since > 0 && since < _droppedThrough;
|
||||
return IpcResponse.ok(id: req.id, data: {
|
||||
'events': out,
|
||||
'cursor': _lastCursor,
|
||||
'gap': gap,
|
||||
if (gap) 'oldestCursor': _eventLog.isEmpty ? _lastCursor : _eventLog.first.cursor,
|
||||
});
|
||||
return IpcResponse.ok(
|
||||
id: req.id,
|
||||
data: {'events': out, 'cursor': _lastCursor, 'gap': gap, if (gap) 'oldestCursor': _eventLog.isEmpty ? _lastCursor : _eventLog.first.cursor},
|
||||
);
|
||||
}
|
||||
|
||||
/// Parse the `--since` flag (a string from argv or an int from a typed
|
||||
@@ -390,12 +362,7 @@ class IpcServer {
|
||||
}
|
||||
|
||||
void _onBusEvent(DaemonEvent e) {
|
||||
final ev = IpcEvent(
|
||||
subsystem: e.subsystem,
|
||||
kind: e.kind,
|
||||
data: e.data,
|
||||
timestamp: e.ts,
|
||||
);
|
||||
final ev = IpcEvent(subsystem: e.subsystem, kind: e.kind, data: e.data, timestamp: e.ts);
|
||||
// Push to replay ring.
|
||||
final ring = _replay.putIfAbsent(e.subsystem, () => Queue<IpcEvent>());
|
||||
ring.addLast(ev);
|
||||
|
||||
Reference in New Issue
Block a user