Files
pipelines/app/test/features/chat/domain/chat_harness_commands_test.dart
T
alan d1390994cc Chat: offer the session's Claude Code skills and slash commands in the palette
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>
2026-11-25 20:53:57 +00:00

68 lines
2.3 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/domain/chat_commands.dart';
import 'package:pipelines_app/features/chat/domain/chat_harness_commands.dart';
void main() {
final harness = chatHarnessCommandsFromWire([
{
'name': 'code-review',
'description': ' Review the diff ',
'argument_hint': '[low|high]',
},
{'name': '/probe-skill'},
{'name': 'anthropic-skills:pdf', 'description': 'PDF'},
{'name': 'Code-Review', 'description': 'duplicate'},
{'name': 'two words'},
{'name': ''},
{'name': 'help', 'description': 'shadowed'},
]);
test('wire entries become harness commands with usage and summary', () {
expect(harness.map((command) => command.name), [
'code-review',
'probe-skill',
'anthropic-skills:pdf',
'help',
]);
final review = harness.first;
expect(review.fromHarness, isTrue);
expect(review.takesArgument, isTrue);
expect(review.summary, 'Review the diff');
expect(review.usage, '/code-review [low|high]');
expect(harness[1].usage, '/probe-skill');
expect(chatHarnessCommandsFromWire(const []), isEmpty);
});
test('suggestions list recorded commands first, then matching skills', () {
final all = chatCommandSuggestions('/', harness);
expect(all.take(chatCommands.length), chatCommands);
expect(all.skip(chatCommands.length).map((command) => command.name), [
'code-review',
'probe-skill',
'anthropic-skills:pdf',
]);
expect(chatCommandSuggestions('/CODE', harness).single.name, 'code-review');
expect(
chatCommandSuggestions('/pdf', harness).single.name,
'anthropic-skills:pdf',
);
expect(chatCommandSuggestions('/code-review x', harness), isEmpty);
// Without harness commands the recorded list is unchanged.
expect(chatCommandSuggestions('/'), chatCommands);
});
test('a harness command is named only when no recorded command is', () {
expect(
chatHarnessCommandNamed('/code-review low', harness)?.name,
'code-review',
);
expect(
chatHarnessCommandNamed('/Probe-Skill', harness)?.name,
'probe-skill',
);
expect(chatHarnessCommandNamed('/help', harness), isNull);
expect(chatHarnessCommandNamed('/code', harness), isNull);
expect(chatHarnessCommandNamed('plain', harness), isNull);
});
}