diff --git a/lib/mcp/task_service.dart b/lib/mcp/task_service.dart index 18ee0f1..9d184e5 100644 --- a/lib/mcp/task_service.dart +++ b/lib/mcp/task_service.dart @@ -95,17 +95,18 @@ class TaskService { return (reply: await _save(added.note, verb), start: null); } - /// `list_tasks`: repo tasks, open ones unless `status` says otherwise. + /// `list_tasks`: repo tasks, open ones unless `status` says otherwise; + /// `no_repo: true` lists the repo-less notes (ideas) instead. Future list(Map args) => _serial(() async { final a = _Args(args); final repo = a.repo(); final statuses = a.statuses(); + final ideas = a.flag('no_repo'); await _pull(); - return _lines( - await _session.repository.listNotes( - filter: NoteFilter(statuses: statuses, repo: repo, repoTasksOnly: true), - ), + final notes = await _session.repository.listNotes( + filter: NoteFilter(statuses: statuses, repo: repo, repoTasksOnly: !ideas), ); + return _lines(ideas ? notes.where((n) => n.repo == null).toList() : notes); }); /// `search_tasks`: repo tasks of any status whose text or repo matches. diff --git a/lib/mcp/todo_mcp_server.dart b/lib/mcp/todo_mcp_server.dart index ba150a3..9c2b73c 100644 --- a/lib/mcp/todo_mcp_server.dart +++ b/lib/mcp/todo_mcp_server.dart @@ -143,9 +143,13 @@ McpServer _server(TaskService tasks) { 'list_tasks', 'List repo tasks, one line each: 8-char id, status, priority, repo, ' 'title, created_by (kuhy|claude). Default status "open" ' - '(todo + in_progress).', + '(todo + in_progress). no_repo: true lists the notes WITHOUT a repo ' + '(ideas) instead.', { 'repo': repo, + 'no_repo': JsonSchema.boolean( + description: 'List only notes that have no repo (repo shows as -).', + ), 'status': JsonSchema.string( description: 'open | all | todo | in_progress | done | abandoned.', ), diff --git a/pubspec.yaml b/pubspec.yaml index 19aaa5d..911496b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.96+1 +version: 1.0.97+1 environment: sdk: ^3.12.2 diff --git a/test/mcp/mcp_no_repo_test.dart b/test/mcp/mcp_no_repo_test.dart new file mode 100644 index 0000000..610782b --- /dev/null +++ b/test/mcp/mcp_no_repo_test.dart @@ -0,0 +1,55 @@ +// list_tasks `no_repo: true` lists the open notes that have no repo (ideas), +// which the board shows in its Yours lane; without it they stay invisible. +import 'package:flutter_test/flutter_test.dart'; +import 'package:mcp_dart/mcp_dart.dart'; +import 'package:todo/data/note.dart'; + +import 'mcp_harness.dart'; + +void main() { + late McpHarness h; + late McpClient c; + setUp(() async { + h = McpHarness(); + await h.start(); + c = await h.connect(); + }); + tearDown(() => h.dispose()); + + Future idea(String id, String text, Status status) async { + final now = DateTime.now(); + await h.session.repository.upsert( + Note( + id: id, + text: text, + status: status, + priority: Priority.medium, + createdAt: now, + updatedAt: now, + ), + ); + } + + test('no_repo lists only open repo-less notes', () async { + await idea('11111111-aaaa', 'open idea', Status.todo); + await idea('22222222-aaaa', 'finished idea', Status.done); + await h.call(c, 'add_task', {'repo': 'kuhyx/x', 'title': 'repo task'}); + + final plain = await h.call(c, 'list_tasks', {}); + expect(plain, isNot(contains('open idea'))); + final ideas = await h.call(c, 'list_tasks', {'no_repo': true}); + expect(ideas.trim().split('\n'), hasLength(1)); + expect(ideas, allOf(contains('11111111'), contains('open idea'))); + expect(ideas, isNot(contains('repo task'))); + }); + + test('no_repo with nothing to list says so', () async { + expect(await h.call(c, 'list_tasks', {'no_repo': true}), 'no tasks match'); + }); + + test('no_repo is named in the tool text', () async { + final tools = (await c.listTools()).tools; + final list = tools.singleWhere((t) => t.name == 'list_tasks'); + expect(list.description, contains('no_repo')); + }); +}