dew/packages/kanban/lib/src/commands/delete_command.dart
Chris Hendrickson 1e263f08c0 fix: tolerate numeric args from MCP JSON in all kanban commands
Replace fragile 'as String'/'as String?' casts in callAsTool() with
string interpolation so that numeric values sent by MCP JSON clients
(double instead of String) no longer throw a type cast error.

Fixes: type 'double' is not a subtype of type 'String' in type cast

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 16:01:36 -04:00

41 lines
1,019 B
Dart

import 'package:dew_core/dew_core.dart';
import 'package:file/file.dart';
import 'package:file/local.dart';
import '../kanban_config.dart';
import '../ticket_store.dart';
class DeleteCommand extends DewCommand with DewToolCommand {
final FileSystem _fs;
DeleteCommand({FileSystem fs = const LocalFileSystem()}) : _fs = fs {
argParser.addOption(
'id',
abbr: 'i',
mandatory: true,
help: 'Ticket ID (e.g. DEW-0001).',
);
}
@override
final String name = 'delete';
@override
final String description = 'Delete a kanban ticket.';
@override
final String toolName = 'kanban_delete_ticket';
@override
Future<String> callAsTool(Map<String, dynamic> args) async {
final id = '${args['id']}'.toUpperCase();
final context = await ProjectContext.find(fs: _fs);
final store = TicketStore(
kanbanDir: context.dirs.kanban,
prefix: context.config.kanban.prefix,
fs: context.fs,
);
await store.delete(id);
return 'Deleted $id.';
}
}