aifastdb 2.2.2 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aifastdb.win32-x64-msvc.node +0 -0
- package/dist/dev-plan-store.d.ts +104 -0
- package/dist/dev-plan-store.d.ts.map +1 -1
- package/dist/dev-plan-store.js +331 -34
- package/dist/dev-plan-store.js.map +1 -1
- package/dist/federation/FederatedDb.d.ts +138 -1
- package/dist/federation/FederatedDb.d.ts.map +1 -1
- package/dist/federation/FederatedDb.js +158 -0
- package/dist/federation/FederatedDb.js.map +1 -1
- package/dist/federation/index.d.ts +1 -1
- package/dist/federation/index.d.ts.map +1 -1
- package/dist/federation/index.js.map +1 -1
- package/dist/federation/types.d.ts +136 -4
- package/dist/federation/types.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/index.d.ts +5 -16
- package/dist/mcp-server/index.d.ts.map +1 -1
- package/dist/mcp-server/index.js +6 -689
- package/dist/mcp-server/index.js.map +1 -1
- package/dist/security/server/routes.d.ts +46 -0
- package/dist/security/server/routes.d.ts.map +1 -1
- package/dist/security/server/routes.js +568 -1
- package/dist/security/server/routes.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp-server/index.js
CHANGED
|
@@ -3,31 +3,20 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* AiFastDB MCP Server
|
|
5
5
|
*
|
|
6
|
-
* Provides document storage
|
|
7
|
-
*
|
|
6
|
+
* Provides document storage and architecture documentation management
|
|
7
|
+
* through the Model Context Protocol (MCP).
|
|
8
8
|
*
|
|
9
|
-
* Tools
|
|
9
|
+
* Tools:
|
|
10
10
|
* - save_document: Save task documents (task_plan, findings, progress)
|
|
11
11
|
* - get_document: Retrieve a specific document
|
|
12
12
|
* - list_documents: List documents by task or type
|
|
13
13
|
* - search_documents: Search documents by content or tags
|
|
14
14
|
* - list_tasks: List all tasks
|
|
15
|
+
* - generate_task_id: Generate a new task ID
|
|
15
16
|
* - save_architecture: Save architecture documentation
|
|
16
17
|
* - get_architecture: Retrieve architecture documentation
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
* - devplan_init: Initialize a dev plan for a project
|
|
20
|
-
* - devplan_save_section: Save/update a document section
|
|
21
|
-
* - devplan_get_section: Read a document section
|
|
22
|
-
* - devplan_list_sections: List all document sections
|
|
23
|
-
* - devplan_create_main_task: Create a main task (development phase)
|
|
24
|
-
* - devplan_add_sub_task: Add a sub task under a main task
|
|
25
|
-
* - devplan_upsert_task: Idempotent import (upsert) main/sub tasks — prevents duplicates
|
|
26
|
-
* - devplan_complete_task: Complete a task (auto-updates progress, anchors Git commit)
|
|
27
|
-
* - devplan_list_tasks: List tasks with optional filters
|
|
28
|
-
* - devplan_get_progress: Get project progress overview
|
|
29
|
-
* - devplan_export_markdown: Export plan as Markdown
|
|
30
|
-
* - devplan_sync_git: Sync task statuses with Git history (revert rolled-back tasks)
|
|
19
|
+
* Note: DevPlan tools have been moved to the standalone `aifastdb-devplan` package.
|
|
31
20
|
*/
|
|
32
21
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
33
22
|
if (k2 === undefined) k2 = k;
|
|
@@ -71,7 +60,6 @@ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
|
71
60
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
72
61
|
const document_store_1 = require("../document-store");
|
|
73
62
|
const document_store_2 = require("../document-store");
|
|
74
|
-
const dev_plan_store_1 = require("../dev-plan-store");
|
|
75
63
|
// ============================================================================
|
|
76
64
|
// Configuration
|
|
77
65
|
// ============================================================================
|
|
@@ -102,14 +90,6 @@ function getStore() {
|
|
|
102
90
|
}
|
|
103
91
|
return store;
|
|
104
92
|
}
|
|
105
|
-
// DevPlan store cache (keyed by projectName)
|
|
106
|
-
const devPlanCache = new Map();
|
|
107
|
-
function getDevPlan(projectName) {
|
|
108
|
-
if (!devPlanCache.has(projectName)) {
|
|
109
|
-
devPlanCache.set(projectName, (0, dev_plan_store_1.createDevPlan)(projectName));
|
|
110
|
-
}
|
|
111
|
-
return devPlanCache.get(projectName);
|
|
112
|
-
}
|
|
113
93
|
// ============================================================================
|
|
114
94
|
// Tool Definitions
|
|
115
95
|
// ============================================================================
|
|
@@ -286,320 +266,6 @@ const TOOLS = [
|
|
|
286
266
|
required: ['projectName'],
|
|
287
267
|
},
|
|
288
268
|
},
|
|
289
|
-
// ==========================================================================
|
|
290
|
-
// DevPlan Tools — 通用开发计划管理
|
|
291
|
-
// ==========================================================================
|
|
292
|
-
{
|
|
293
|
-
name: 'devplan_init',
|
|
294
|
-
description: 'Initialize a development plan for a project. Creates an empty plan structure. Also lists existing plans if no projectName is given.',
|
|
295
|
-
inputSchema: {
|
|
296
|
-
type: 'object',
|
|
297
|
-
properties: {
|
|
298
|
-
projectName: {
|
|
299
|
-
type: 'string',
|
|
300
|
-
description: 'Project name (e.g., "federation-db", "aidb-viewer"). Omit to list existing plans.',
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
name: 'devplan_save_section',
|
|
307
|
-
description: 'Save or update a document section in the dev plan. Sections are typed: overview, core_concepts, api_design, file_structure, config, examples, technical_notes, api_endpoints, milestones, changelog, custom. technical_notes and custom support subSection for multiple sub-documents.',
|
|
308
|
-
inputSchema: {
|
|
309
|
-
type: 'object',
|
|
310
|
-
properties: {
|
|
311
|
-
projectName: {
|
|
312
|
-
type: 'string',
|
|
313
|
-
description: 'Project name',
|
|
314
|
-
},
|
|
315
|
-
section: {
|
|
316
|
-
type: 'string',
|
|
317
|
-
enum: ['overview', 'core_concepts', 'api_design', 'file_structure', 'config', 'examples', 'technical_notes', 'api_endpoints', 'milestones', 'changelog', 'custom'],
|
|
318
|
-
description: 'Document section type',
|
|
319
|
-
},
|
|
320
|
-
title: {
|
|
321
|
-
type: 'string',
|
|
322
|
-
description: 'Section title (e.g., "概述 - 背景与目标")',
|
|
323
|
-
},
|
|
324
|
-
content: {
|
|
325
|
-
type: 'string',
|
|
326
|
-
description: 'Markdown content for this section',
|
|
327
|
-
},
|
|
328
|
-
version: {
|
|
329
|
-
type: 'string',
|
|
330
|
-
description: 'Optional version string (default: "1.0.0")',
|
|
331
|
-
},
|
|
332
|
-
subSection: {
|
|
333
|
-
type: 'string',
|
|
334
|
-
description: 'Optional sub-section name for technical_notes/custom (e.g., "security", "resilience")',
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
required: ['projectName', 'section', 'title', 'content'],
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
name: 'devplan_get_section',
|
|
342
|
-
description: 'Read a specific document section from the dev plan.',
|
|
343
|
-
inputSchema: {
|
|
344
|
-
type: 'object',
|
|
345
|
-
properties: {
|
|
346
|
-
projectName: {
|
|
347
|
-
type: 'string',
|
|
348
|
-
description: 'Project name',
|
|
349
|
-
},
|
|
350
|
-
section: {
|
|
351
|
-
type: 'string',
|
|
352
|
-
enum: ['overview', 'core_concepts', 'api_design', 'file_structure', 'config', 'examples', 'technical_notes', 'api_endpoints', 'milestones', 'changelog', 'custom'],
|
|
353
|
-
description: 'Document section type',
|
|
354
|
-
},
|
|
355
|
-
subSection: {
|
|
356
|
-
type: 'string',
|
|
357
|
-
description: 'Optional sub-section name',
|
|
358
|
-
},
|
|
359
|
-
},
|
|
360
|
-
required: ['projectName', 'section'],
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
name: 'devplan_list_sections',
|
|
365
|
-
description: 'List all document sections in the dev plan for a project.',
|
|
366
|
-
inputSchema: {
|
|
367
|
-
type: 'object',
|
|
368
|
-
properties: {
|
|
369
|
-
projectName: {
|
|
370
|
-
type: 'string',
|
|
371
|
-
description: 'Project name',
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
|
-
required: ['projectName'],
|
|
375
|
-
},
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
name: 'devplan_create_main_task',
|
|
379
|
-
description: 'Create a main task (development phase) in the dev plan. A main task groups multiple sub-tasks.',
|
|
380
|
-
inputSchema: {
|
|
381
|
-
type: 'object',
|
|
382
|
-
properties: {
|
|
383
|
-
projectName: {
|
|
384
|
-
type: 'string',
|
|
385
|
-
description: 'Project name',
|
|
386
|
-
},
|
|
387
|
-
taskId: {
|
|
388
|
-
type: 'string',
|
|
389
|
-
description: 'Main task ID (e.g., "phase-7", "phase-14B")',
|
|
390
|
-
},
|
|
391
|
-
title: {
|
|
392
|
-
type: 'string',
|
|
393
|
-
description: 'Task title (e.g., "阶段七:Store Trait 与适配器")',
|
|
394
|
-
},
|
|
395
|
-
priority: {
|
|
396
|
-
type: 'string',
|
|
397
|
-
enum: ['P0', 'P1', 'P2'],
|
|
398
|
-
description: 'Priority level',
|
|
399
|
-
},
|
|
400
|
-
description: {
|
|
401
|
-
type: 'string',
|
|
402
|
-
description: 'Optional task description',
|
|
403
|
-
},
|
|
404
|
-
estimatedHours: {
|
|
405
|
-
type: 'number',
|
|
406
|
-
description: 'Optional estimated hours',
|
|
407
|
-
},
|
|
408
|
-
},
|
|
409
|
-
required: ['projectName', 'taskId', 'title', 'priority'],
|
|
410
|
-
},
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
name: 'devplan_add_sub_task',
|
|
414
|
-
description: 'Add a sub-task under a main task. Sub-tasks correspond to Cursor TodoList items.',
|
|
415
|
-
inputSchema: {
|
|
416
|
-
type: 'object',
|
|
417
|
-
properties: {
|
|
418
|
-
projectName: {
|
|
419
|
-
type: 'string',
|
|
420
|
-
description: 'Project name',
|
|
421
|
-
},
|
|
422
|
-
taskId: {
|
|
423
|
-
type: 'string',
|
|
424
|
-
description: 'Sub-task ID (e.g., "T7.2", "T14.8")',
|
|
425
|
-
},
|
|
426
|
-
parentTaskId: {
|
|
427
|
-
type: 'string',
|
|
428
|
-
description: 'Parent main task ID (e.g., "phase-7")',
|
|
429
|
-
},
|
|
430
|
-
title: {
|
|
431
|
-
type: 'string',
|
|
432
|
-
description: 'Sub-task title',
|
|
433
|
-
},
|
|
434
|
-
estimatedHours: {
|
|
435
|
-
type: 'number',
|
|
436
|
-
description: 'Optional estimated hours',
|
|
437
|
-
},
|
|
438
|
-
description: {
|
|
439
|
-
type: 'string',
|
|
440
|
-
description: 'Optional task description',
|
|
441
|
-
},
|
|
442
|
-
},
|
|
443
|
-
required: ['projectName', 'taskId', 'parentTaskId', 'title'],
|
|
444
|
-
},
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
name: 'devplan_upsert_task',
|
|
448
|
-
description: 'Idempotent import (upsert) for main tasks or sub-tasks. If the task does not exist, it will be created. If it already exists, it will be updated with the new data while preserving the higher-priority status (e.g., completed tasks will not be reverted to pending). This is the recommended tool for bulk data import to prevent duplicates.',
|
|
449
|
-
inputSchema: {
|
|
450
|
-
type: 'object',
|
|
451
|
-
properties: {
|
|
452
|
-
projectName: {
|
|
453
|
-
type: 'string',
|
|
454
|
-
description: 'Project name',
|
|
455
|
-
},
|
|
456
|
-
taskType: {
|
|
457
|
-
type: 'string',
|
|
458
|
-
enum: ['main', 'sub'],
|
|
459
|
-
description: 'Whether this is a main task or sub-task',
|
|
460
|
-
},
|
|
461
|
-
taskId: {
|
|
462
|
-
type: 'string',
|
|
463
|
-
description: 'Task ID (e.g., "phase-7" for main, "T7.2" for sub)',
|
|
464
|
-
},
|
|
465
|
-
title: {
|
|
466
|
-
type: 'string',
|
|
467
|
-
description: 'Task title',
|
|
468
|
-
},
|
|
469
|
-
// Main task specific
|
|
470
|
-
priority: {
|
|
471
|
-
type: 'string',
|
|
472
|
-
enum: ['P0', 'P1', 'P2'],
|
|
473
|
-
description: 'Priority level (required for main tasks)',
|
|
474
|
-
},
|
|
475
|
-
// Sub task specific
|
|
476
|
-
parentTaskId: {
|
|
477
|
-
type: 'string',
|
|
478
|
-
description: 'Parent main task ID (required for sub-tasks)',
|
|
479
|
-
},
|
|
480
|
-
description: {
|
|
481
|
-
type: 'string',
|
|
482
|
-
description: 'Optional task description',
|
|
483
|
-
},
|
|
484
|
-
estimatedHours: {
|
|
485
|
-
type: 'number',
|
|
486
|
-
description: 'Optional estimated hours',
|
|
487
|
-
},
|
|
488
|
-
status: {
|
|
489
|
-
type: 'string',
|
|
490
|
-
enum: ['pending', 'in_progress', 'completed', 'cancelled'],
|
|
491
|
-
description: 'Target status (default: pending). Higher-priority existing status is preserved unless preserveStatus is false.',
|
|
492
|
-
},
|
|
493
|
-
preserveStatus: {
|
|
494
|
-
type: 'boolean',
|
|
495
|
-
description: 'If true (default), existing higher-priority status is preserved. Set to false to force overwrite.',
|
|
496
|
-
},
|
|
497
|
-
},
|
|
498
|
-
required: ['projectName', 'taskType', 'taskId', 'title'],
|
|
499
|
-
},
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
name: 'devplan_complete_task',
|
|
503
|
-
description: 'Mark a task as completed. For sub-tasks: auto-updates parent main task progress count and completedAt timestamp. If all sub-tasks are done, the main task is also auto-completed. For main tasks: directly marks as completed.',
|
|
504
|
-
inputSchema: {
|
|
505
|
-
type: 'object',
|
|
506
|
-
properties: {
|
|
507
|
-
projectName: {
|
|
508
|
-
type: 'string',
|
|
509
|
-
description: 'Project name',
|
|
510
|
-
},
|
|
511
|
-
taskId: {
|
|
512
|
-
type: 'string',
|
|
513
|
-
description: 'Task ID (sub-task like "T7.2" or main task like "phase-7")',
|
|
514
|
-
},
|
|
515
|
-
taskType: {
|
|
516
|
-
type: 'string',
|
|
517
|
-
enum: ['sub', 'main'],
|
|
518
|
-
description: 'Whether this is a sub-task or main task (default: "sub")',
|
|
519
|
-
},
|
|
520
|
-
},
|
|
521
|
-
required: ['projectName', 'taskId'],
|
|
522
|
-
},
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
name: 'devplan_list_tasks',
|
|
526
|
-
description: 'List tasks in the dev plan. Can list main tasks, or sub-tasks of a specific main task.',
|
|
527
|
-
inputSchema: {
|
|
528
|
-
type: 'object',
|
|
529
|
-
properties: {
|
|
530
|
-
projectName: {
|
|
531
|
-
type: 'string',
|
|
532
|
-
description: 'Project name',
|
|
533
|
-
},
|
|
534
|
-
parentTaskId: {
|
|
535
|
-
type: 'string',
|
|
536
|
-
description: 'Optional: List sub-tasks of this main task ID. If omitted, lists main tasks.',
|
|
537
|
-
},
|
|
538
|
-
status: {
|
|
539
|
-
type: 'string',
|
|
540
|
-
enum: ['pending', 'in_progress', 'completed', 'cancelled'],
|
|
541
|
-
description: 'Optional: Filter by status',
|
|
542
|
-
},
|
|
543
|
-
priority: {
|
|
544
|
-
type: 'string',
|
|
545
|
-
enum: ['P0', 'P1', 'P2'],
|
|
546
|
-
description: 'Optional: Filter by priority (main tasks only)',
|
|
547
|
-
},
|
|
548
|
-
},
|
|
549
|
-
required: ['projectName'],
|
|
550
|
-
},
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
name: 'devplan_get_progress',
|
|
554
|
-
description: 'Get overall project progress: section count, main task count, sub-task completion rates, per-phase progress bars.',
|
|
555
|
-
inputSchema: {
|
|
556
|
-
type: 'object',
|
|
557
|
-
properties: {
|
|
558
|
-
projectName: {
|
|
559
|
-
type: 'string',
|
|
560
|
-
description: 'Project name',
|
|
561
|
-
},
|
|
562
|
-
},
|
|
563
|
-
required: ['projectName'],
|
|
564
|
-
},
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
name: 'devplan_export_markdown',
|
|
568
|
-
description: 'Export the dev plan as a Markdown document. Scope can be "full" (documents + tasks) or "tasks" (task summary only).',
|
|
569
|
-
inputSchema: {
|
|
570
|
-
type: 'object',
|
|
571
|
-
properties: {
|
|
572
|
-
projectName: {
|
|
573
|
-
type: 'string',
|
|
574
|
-
description: 'Project name',
|
|
575
|
-
},
|
|
576
|
-
scope: {
|
|
577
|
-
type: 'string',
|
|
578
|
-
enum: ['full', 'tasks'],
|
|
579
|
-
description: 'Export scope: "full" for documents + tasks, "tasks" for task summary only (default: "tasks")',
|
|
580
|
-
},
|
|
581
|
-
},
|
|
582
|
-
required: ['projectName'],
|
|
583
|
-
},
|
|
584
|
-
},
|
|
585
|
-
{
|
|
586
|
-
name: 'devplan_sync_git',
|
|
587
|
-
description: 'Synchronize DevPlan task statuses with Git history. Checks if completed tasks\' commits are still ancestors of the current HEAD. If a completed task\'s commit was rolled back (e.g., via git reset), the task is automatically reverted to pending. Use dryRun=true to preview changes without modifying data.',
|
|
588
|
-
inputSchema: {
|
|
589
|
-
type: 'object',
|
|
590
|
-
properties: {
|
|
591
|
-
projectName: {
|
|
592
|
-
type: 'string',
|
|
593
|
-
description: 'Project name',
|
|
594
|
-
},
|
|
595
|
-
dryRun: {
|
|
596
|
-
type: 'boolean',
|
|
597
|
-
description: 'If true, only report which tasks would be reverted without actually changing them (default: false)',
|
|
598
|
-
},
|
|
599
|
-
},
|
|
600
|
-
required: ['projectName'],
|
|
601
|
-
},
|
|
602
|
-
},
|
|
603
269
|
];
|
|
604
270
|
async function handleToolCall(name, args) {
|
|
605
271
|
const db = getStore();
|
|
@@ -797,355 +463,6 @@ async function handleToolCall(name, args) {
|
|
|
797
463
|
})),
|
|
798
464
|
});
|
|
799
465
|
}
|
|
800
|
-
// ========================================================================
|
|
801
|
-
// DevPlan Tool Handlers
|
|
802
|
-
// ========================================================================
|
|
803
|
-
case 'devplan_init': {
|
|
804
|
-
if (!args.projectName) {
|
|
805
|
-
// List existing plans
|
|
806
|
-
const plans = (0, dev_plan_store_1.listDevPlans)();
|
|
807
|
-
return JSON.stringify({
|
|
808
|
-
existingPlans: plans,
|
|
809
|
-
availableSections: dev_plan_store_1.ALL_SECTIONS,
|
|
810
|
-
sectionDescriptions: dev_plan_store_1.SECTION_DESCRIPTIONS,
|
|
811
|
-
message: plans.length > 0
|
|
812
|
-
? `Found ${plans.length} existing plan(s). Provide a projectName to initialize a new one.`
|
|
813
|
-
: 'No existing plans. Provide a projectName to create one.',
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
const plan = getDevPlan(args.projectName);
|
|
817
|
-
return JSON.stringify({
|
|
818
|
-
success: true,
|
|
819
|
-
projectName: args.projectName,
|
|
820
|
-
availableSections: dev_plan_store_1.ALL_SECTIONS,
|
|
821
|
-
sectionDescriptions: dev_plan_store_1.SECTION_DESCRIPTIONS,
|
|
822
|
-
message: `DevPlan initialized for "${args.projectName}". Use devplan_save_section to add document sections and devplan_create_main_task to add development phases.`,
|
|
823
|
-
});
|
|
824
|
-
}
|
|
825
|
-
case 'devplan_save_section': {
|
|
826
|
-
if (!args.projectName || !args.section || !args.title || !args.content) {
|
|
827
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName, section, title, content');
|
|
828
|
-
}
|
|
829
|
-
const plan = getDevPlan(args.projectName);
|
|
830
|
-
const id = plan.saveSection({
|
|
831
|
-
projectName: args.projectName,
|
|
832
|
-
section: args.section,
|
|
833
|
-
title: args.title,
|
|
834
|
-
content: args.content,
|
|
835
|
-
version: args.version,
|
|
836
|
-
subSection: args.subSection,
|
|
837
|
-
});
|
|
838
|
-
return JSON.stringify({
|
|
839
|
-
success: true,
|
|
840
|
-
documentId: id,
|
|
841
|
-
projectName: args.projectName,
|
|
842
|
-
section: args.section,
|
|
843
|
-
subSection: args.subSection || null,
|
|
844
|
-
title: args.title,
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
case 'devplan_get_section': {
|
|
848
|
-
if (!args.projectName || !args.section) {
|
|
849
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName, section');
|
|
850
|
-
}
|
|
851
|
-
const plan = getDevPlan(args.projectName);
|
|
852
|
-
const doc = plan.getSection(args.section, args.subSection);
|
|
853
|
-
if (!doc) {
|
|
854
|
-
return JSON.stringify({
|
|
855
|
-
found: false,
|
|
856
|
-
message: `Section "${args.section}"${args.subSection ? ` (${args.subSection})` : ''} not found for project "${args.projectName}"`,
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
return JSON.stringify({
|
|
860
|
-
found: true,
|
|
861
|
-
document: doc,
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
case 'devplan_list_sections': {
|
|
865
|
-
if (!args.projectName) {
|
|
866
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName');
|
|
867
|
-
}
|
|
868
|
-
const plan = getDevPlan(args.projectName);
|
|
869
|
-
const sections = plan.listSections();
|
|
870
|
-
return JSON.stringify({
|
|
871
|
-
projectName: args.projectName,
|
|
872
|
-
count: sections.length,
|
|
873
|
-
sections: sections.map(s => ({
|
|
874
|
-
id: s.id,
|
|
875
|
-
section: s.section,
|
|
876
|
-
subSection: s.subSection || null,
|
|
877
|
-
title: s.title,
|
|
878
|
-
version: s.version,
|
|
879
|
-
contentPreview: s.content.slice(0, 200) + (s.content.length > 200 ? '...' : ''),
|
|
880
|
-
updatedAt: s.updatedAt,
|
|
881
|
-
})),
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
case 'devplan_create_main_task': {
|
|
885
|
-
if (!args.projectName || !args.taskId || !args.title || !args.priority) {
|
|
886
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName, taskId, title, priority');
|
|
887
|
-
}
|
|
888
|
-
const plan = getDevPlan(args.projectName);
|
|
889
|
-
try {
|
|
890
|
-
const mainTask = plan.createMainTask({
|
|
891
|
-
projectName: args.projectName,
|
|
892
|
-
taskId: args.taskId,
|
|
893
|
-
title: args.title,
|
|
894
|
-
priority: args.priority,
|
|
895
|
-
description: args.description,
|
|
896
|
-
estimatedHours: args.estimatedHours,
|
|
897
|
-
});
|
|
898
|
-
return JSON.stringify({
|
|
899
|
-
success: true,
|
|
900
|
-
mainTask: {
|
|
901
|
-
id: mainTask.id,
|
|
902
|
-
taskId: mainTask.taskId,
|
|
903
|
-
title: mainTask.title,
|
|
904
|
-
priority: mainTask.priority,
|
|
905
|
-
status: mainTask.status,
|
|
906
|
-
},
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
catch (err) {
|
|
910
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, err instanceof Error ? err.message : String(err));
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
case 'devplan_add_sub_task': {
|
|
914
|
-
if (!args.projectName || !args.taskId || !args.parentTaskId || !args.title) {
|
|
915
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName, taskId, parentTaskId, title');
|
|
916
|
-
}
|
|
917
|
-
const plan = getDevPlan(args.projectName);
|
|
918
|
-
try {
|
|
919
|
-
const subTask = plan.addSubTask({
|
|
920
|
-
projectName: args.projectName,
|
|
921
|
-
taskId: args.taskId,
|
|
922
|
-
parentTaskId: args.parentTaskId,
|
|
923
|
-
title: args.title,
|
|
924
|
-
estimatedHours: args.estimatedHours,
|
|
925
|
-
description: args.description,
|
|
926
|
-
});
|
|
927
|
-
return JSON.stringify({
|
|
928
|
-
success: true,
|
|
929
|
-
subTask: {
|
|
930
|
-
id: subTask.id,
|
|
931
|
-
taskId: subTask.taskId,
|
|
932
|
-
parentTaskId: subTask.parentTaskId,
|
|
933
|
-
title: subTask.title,
|
|
934
|
-
status: subTask.status,
|
|
935
|
-
},
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
catch (err) {
|
|
939
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, err instanceof Error ? err.message : String(err));
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
case 'devplan_upsert_task': {
|
|
943
|
-
if (!args.projectName || !args.taskType || !args.taskId || !args.title) {
|
|
944
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName, taskType, taskId, title');
|
|
945
|
-
}
|
|
946
|
-
const plan = getDevPlan(args.projectName);
|
|
947
|
-
const upsertTaskType = args.taskType;
|
|
948
|
-
const targetStatus = args.status || 'pending';
|
|
949
|
-
const preserveStatus = args.preserveStatus !== false; // 默认 true
|
|
950
|
-
try {
|
|
951
|
-
if (upsertTaskType === 'main') {
|
|
952
|
-
if (!args.priority) {
|
|
953
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required for main task: priority');
|
|
954
|
-
}
|
|
955
|
-
const mainTask = plan.upsertMainTask({
|
|
956
|
-
projectName: args.projectName,
|
|
957
|
-
taskId: args.taskId,
|
|
958
|
-
title: args.title,
|
|
959
|
-
priority: args.priority,
|
|
960
|
-
description: args.description,
|
|
961
|
-
estimatedHours: args.estimatedHours,
|
|
962
|
-
}, { preserveStatus, status: targetStatus });
|
|
963
|
-
return JSON.stringify({
|
|
964
|
-
success: true,
|
|
965
|
-
taskType: 'main',
|
|
966
|
-
mainTask: {
|
|
967
|
-
id: mainTask.id,
|
|
968
|
-
taskId: mainTask.taskId,
|
|
969
|
-
title: mainTask.title,
|
|
970
|
-
priority: mainTask.priority,
|
|
971
|
-
status: mainTask.status,
|
|
972
|
-
updatedAt: mainTask.updatedAt,
|
|
973
|
-
},
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
else {
|
|
977
|
-
if (!args.parentTaskId) {
|
|
978
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required for sub-task: parentTaskId');
|
|
979
|
-
}
|
|
980
|
-
const subTask = plan.upsertSubTask({
|
|
981
|
-
projectName: args.projectName,
|
|
982
|
-
taskId: args.taskId,
|
|
983
|
-
parentTaskId: args.parentTaskId,
|
|
984
|
-
title: args.title,
|
|
985
|
-
estimatedHours: args.estimatedHours,
|
|
986
|
-
description: args.description,
|
|
987
|
-
}, { preserveStatus, status: targetStatus });
|
|
988
|
-
return JSON.stringify({
|
|
989
|
-
success: true,
|
|
990
|
-
taskType: 'sub',
|
|
991
|
-
subTask: {
|
|
992
|
-
id: subTask.id,
|
|
993
|
-
taskId: subTask.taskId,
|
|
994
|
-
parentTaskId: subTask.parentTaskId,
|
|
995
|
-
title: subTask.title,
|
|
996
|
-
status: subTask.status,
|
|
997
|
-
updatedAt: subTask.updatedAt,
|
|
998
|
-
},
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
catch (err) {
|
|
1003
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, err instanceof Error ? err.message : String(err));
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
case 'devplan_complete_task': {
|
|
1007
|
-
if (!args.projectName || !args.taskId) {
|
|
1008
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName, taskId');
|
|
1009
|
-
}
|
|
1010
|
-
const plan = getDevPlan(args.projectName);
|
|
1011
|
-
const taskType = args.taskType || 'sub';
|
|
1012
|
-
try {
|
|
1013
|
-
if (taskType === 'main') {
|
|
1014
|
-
const mainTask = plan.completeMainTask(args.taskId);
|
|
1015
|
-
return JSON.stringify({
|
|
1016
|
-
success: true,
|
|
1017
|
-
taskType: 'main',
|
|
1018
|
-
mainTask: {
|
|
1019
|
-
taskId: mainTask.taskId,
|
|
1020
|
-
title: mainTask.title,
|
|
1021
|
-
status: mainTask.status,
|
|
1022
|
-
completedAt: mainTask.completedAt,
|
|
1023
|
-
totalSubtasks: mainTask.totalSubtasks,
|
|
1024
|
-
completedSubtasks: mainTask.completedSubtasks,
|
|
1025
|
-
},
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
|
-
else {
|
|
1029
|
-
const result = plan.completeSubTask(args.taskId);
|
|
1030
|
-
return JSON.stringify({
|
|
1031
|
-
success: true,
|
|
1032
|
-
taskType: 'sub',
|
|
1033
|
-
subTask: {
|
|
1034
|
-
taskId: result.subTask.taskId,
|
|
1035
|
-
title: result.subTask.title,
|
|
1036
|
-
status: result.subTask.status,
|
|
1037
|
-
completedAt: result.subTask.completedAt,
|
|
1038
|
-
completedAtCommit: result.completedAtCommit || null,
|
|
1039
|
-
},
|
|
1040
|
-
mainTask: {
|
|
1041
|
-
taskId: result.mainTask.taskId,
|
|
1042
|
-
title: result.mainTask.title,
|
|
1043
|
-
status: result.mainTask.status,
|
|
1044
|
-
totalSubtasks: result.mainTask.totalSubtasks,
|
|
1045
|
-
completedSubtasks: result.mainTask.completedSubtasks,
|
|
1046
|
-
},
|
|
1047
|
-
mainTaskCompleted: result.mainTaskCompleted,
|
|
1048
|
-
completedAtCommit: result.completedAtCommit || null,
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
catch (err) {
|
|
1053
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, err instanceof Error ? err.message : String(err));
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
case 'devplan_list_tasks': {
|
|
1057
|
-
if (!args.projectName) {
|
|
1058
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName');
|
|
1059
|
-
}
|
|
1060
|
-
const plan = getDevPlan(args.projectName);
|
|
1061
|
-
if (args.parentTaskId) {
|
|
1062
|
-
// List sub-tasks of a main task
|
|
1063
|
-
const subTasks = plan.listSubTasks(args.parentTaskId, {
|
|
1064
|
-
status: args.status,
|
|
1065
|
-
});
|
|
1066
|
-
return JSON.stringify({
|
|
1067
|
-
projectName: args.projectName,
|
|
1068
|
-
parentTaskId: args.parentTaskId,
|
|
1069
|
-
count: subTasks.length,
|
|
1070
|
-
subTasks: subTasks.map(st => ({
|
|
1071
|
-
taskId: st.taskId,
|
|
1072
|
-
title: st.title,
|
|
1073
|
-
status: st.status,
|
|
1074
|
-
estimatedHours: st.estimatedHours,
|
|
1075
|
-
completedAt: st.completedAt,
|
|
1076
|
-
})),
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
|
-
else {
|
|
1080
|
-
// List main tasks
|
|
1081
|
-
const mainTasks = plan.listMainTasks({
|
|
1082
|
-
status: args.status,
|
|
1083
|
-
priority: args.priority,
|
|
1084
|
-
});
|
|
1085
|
-
return JSON.stringify({
|
|
1086
|
-
projectName: args.projectName,
|
|
1087
|
-
count: mainTasks.length,
|
|
1088
|
-
mainTasks: mainTasks.map(mt => ({
|
|
1089
|
-
taskId: mt.taskId,
|
|
1090
|
-
title: mt.title,
|
|
1091
|
-
priority: mt.priority,
|
|
1092
|
-
status: mt.status,
|
|
1093
|
-
totalSubtasks: mt.totalSubtasks,
|
|
1094
|
-
completedSubtasks: mt.completedSubtasks,
|
|
1095
|
-
estimatedHours: mt.estimatedHours,
|
|
1096
|
-
completedAt: mt.completedAt,
|
|
1097
|
-
})),
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
case 'devplan_get_progress': {
|
|
1102
|
-
if (!args.projectName) {
|
|
1103
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName');
|
|
1104
|
-
}
|
|
1105
|
-
const plan = getDevPlan(args.projectName);
|
|
1106
|
-
const progress = plan.getProgress();
|
|
1107
|
-
return JSON.stringify(progress);
|
|
1108
|
-
}
|
|
1109
|
-
case 'devplan_export_markdown': {
|
|
1110
|
-
if (!args.projectName) {
|
|
1111
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName');
|
|
1112
|
-
}
|
|
1113
|
-
const plan = getDevPlan(args.projectName);
|
|
1114
|
-
const scope = args.scope || 'tasks';
|
|
1115
|
-
const markdown = scope === 'full'
|
|
1116
|
-
? plan.exportToMarkdown()
|
|
1117
|
-
: plan.exportTaskSummary();
|
|
1118
|
-
return JSON.stringify({
|
|
1119
|
-
projectName: args.projectName,
|
|
1120
|
-
scope,
|
|
1121
|
-
markdown,
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1124
|
-
case 'devplan_sync_git': {
|
|
1125
|
-
if (!args.projectName) {
|
|
1126
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, 'Missing required: projectName');
|
|
1127
|
-
}
|
|
1128
|
-
const plan = getDevPlan(args.projectName);
|
|
1129
|
-
const dryRun = args.dryRun ?? false;
|
|
1130
|
-
try {
|
|
1131
|
-
const result = plan.syncWithGit(dryRun);
|
|
1132
|
-
return JSON.stringify({
|
|
1133
|
-
success: true,
|
|
1134
|
-
dryRun,
|
|
1135
|
-
...result,
|
|
1136
|
-
summary: result.error
|
|
1137
|
-
? `⚠️ ${result.error}`
|
|
1138
|
-
: result.reverted.length === 0
|
|
1139
|
-
? `✅ All ${result.checked} completed tasks are consistent with Git HEAD (${result.currentHead})`
|
|
1140
|
-
: dryRun
|
|
1141
|
-
? `⚠️ ${result.reverted.length} of ${result.checked} tasks would be reverted (dry run, no changes made)`
|
|
1142
|
-
: `🔄 ${result.reverted.length} of ${result.checked} tasks reverted to pending due to Git rollback`,
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
|
-
catch (err) {
|
|
1146
|
-
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, err instanceof Error ? err.message : String(err));
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
466
|
default:
|
|
1150
467
|
throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
1151
468
|
}
|
|
@@ -1156,7 +473,7 @@ async function handleToolCall(name, args) {
|
|
|
1156
473
|
async function main() {
|
|
1157
474
|
const server = new index_js_1.Server({
|
|
1158
475
|
name: 'aifastdb-mcp',
|
|
1159
|
-
version: '2.
|
|
476
|
+
version: '2.1.0',
|
|
1160
477
|
}, {
|
|
1161
478
|
capabilities: {
|
|
1162
479
|
tools: {},
|