d1390994cc
The server reads the commands Claude Code's initialize response lists (bundled, user, project, plugin and claude.ai-synced skills plus CLI commands, with descriptions and argument hints), drops terminal-only ones, and serves them per chat over a new chat_commands request without waiting for a CLI start. The composer palette lists them after the recorded commands; choosing one inserts "/<name> " and sending passes it to the harness as an ordinary prompt. Codex, OpenCode and Pi chats reply with an empty list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
1.0 KiB
Dart
28 lines
1.0 KiB
Dart
import '../../../core/api_gateway.dart';
|
|
import 'chat_commands.dart';
|
|
|
|
/// The session's harness commands from a `chat_commands` reply list: each
|
|
/// entry's `name`, `description` and `argument_hint`. Entries without a usable
|
|
/// single-word name are skipped and duplicates keep their first entry, in the
|
|
/// server's order. A harness without commands yields an empty list.
|
|
List<ChatCommand> chatHarnessCommandsFromWire(List<JsonMap> entries) {
|
|
final seen = <String>{};
|
|
final commands = <ChatCommand>[];
|
|
for (final entry in entries) {
|
|
var name = '${entry['name'] ?? ''}'.trim();
|
|
if (name.startsWith('/')) name = name.substring(1);
|
|
if (name.isEmpty || name.contains(RegExp(r'\s'))) continue;
|
|
if (!seen.add(name.toLowerCase())) continue;
|
|
final description = '${entry['description'] ?? ''}'.trim();
|
|
final hint = '${entry['argument_hint'] ?? ''}'.trim();
|
|
commands.add(
|
|
ChatCommand.harness(
|
|
name: name,
|
|
summary: description,
|
|
usage: hint.isEmpty ? '/$name' : '/$name $hint',
|
|
),
|
|
);
|
|
}
|
|
return commands;
|
|
}
|