mcp-adr-analysis-server 2.0.10 → 2.0.11

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.
Files changed (69) hide show
  1. package/README.md +1 -1
  2. package/dist/src/index.d.ts +1 -2
  3. package/dist/src/index.d.ts.map +1 -1
  4. package/dist/src/index.js +260 -464
  5. package/dist/src/index.js.map +1 -1
  6. package/dist/src/prompts/adr-suggestion-prompts.d.ts.map +1 -1
  7. package/dist/src/prompts/adr-suggestion-prompts.js +2 -0
  8. package/dist/src/prompts/adr-suggestion-prompts.js.map +1 -1
  9. package/dist/src/tools/adr-suggestion-tool.d.ts +16 -0
  10. package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
  11. package/dist/src/tools/adr-suggestion-tool.js +55 -2
  12. package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
  13. package/dist/src/tools/smart-git-push-tool.d.ts +16 -0
  14. package/dist/src/tools/smart-git-push-tool.d.ts.map +1 -1
  15. package/dist/src/tools/smart-git-push-tool.js +111 -3
  16. package/dist/src/tools/smart-git-push-tool.js.map +1 -1
  17. package/dist/src/tools/smart-score-tool.d.ts +39 -4
  18. package/dist/src/tools/smart-score-tool.d.ts.map +1 -1
  19. package/dist/src/tools/smart-score-tool.js +94 -15
  20. package/dist/src/tools/smart-score-tool.js.map +1 -1
  21. package/dist/src/tools/todo-management-tool-v2.d.ts +329 -0
  22. package/dist/src/tools/todo-management-tool-v2.d.ts.map +1 -0
  23. package/dist/src/tools/todo-management-tool-v2.js +644 -0
  24. package/dist/src/tools/todo-management-tool-v2.js.map +1 -0
  25. package/dist/src/tools/tool-chain-orchestrator.d.ts +3 -41
  26. package/dist/src/tools/tool-chain-orchestrator.d.ts.map +1 -1
  27. package/dist/src/tools/tool-chain-orchestrator.js +10 -198
  28. package/dist/src/tools/tool-chain-orchestrator.js.map +1 -1
  29. package/dist/src/types/conversation-context.d.ts +6 -0
  30. package/dist/src/types/conversation-context.d.ts.map +1 -1
  31. package/dist/src/types/conversation-context.js +9 -1
  32. package/dist/src/types/conversation-context.js.map +1 -1
  33. package/dist/src/types/knowledge-graph-schemas.d.ts +298 -6
  34. package/dist/src/types/knowledge-graph-schemas.d.ts.map +1 -1
  35. package/dist/src/types/knowledge-graph-schemas.js +31 -3
  36. package/dist/src/types/knowledge-graph-schemas.js.map +1 -1
  37. package/dist/src/types/todo-json-schemas.d.ts +663 -0
  38. package/dist/src/types/todo-json-schemas.d.ts.map +1 -0
  39. package/dist/src/types/todo-json-schemas.js +113 -0
  40. package/dist/src/types/todo-json-schemas.js.map +1 -0
  41. package/dist/src/utils/chain-of-thought-template.d.ts.map +1 -1
  42. package/dist/src/utils/chain-of-thought-template.js.map +1 -1
  43. package/dist/src/utils/knowledge-graph-manager.d.ts +37 -0
  44. package/dist/src/utils/knowledge-graph-manager.d.ts.map +1 -1
  45. package/dist/src/utils/knowledge-graph-manager.js +169 -3
  46. package/dist/src/utils/knowledge-graph-manager.js.map +1 -1
  47. package/dist/src/utils/project-health-scoring.js +5 -5
  48. package/dist/src/utils/project-health-scoring.js.map +1 -1
  49. package/dist/src/utils/todo-json-manager.d.ts +71 -0
  50. package/dist/src/utils/todo-json-manager.d.ts.map +1 -0
  51. package/dist/src/utils/todo-json-manager.js +394 -0
  52. package/dist/src/utils/todo-json-manager.js.map +1 -0
  53. package/dist/src/utils/todo-markdown-converter.d.ts +16 -0
  54. package/dist/src/utils/todo-markdown-converter.d.ts.map +1 -0
  55. package/dist/src/utils/todo-markdown-converter.js +362 -0
  56. package/dist/src/utils/todo-markdown-converter.js.map +1 -0
  57. package/dist/src/utils/todo-migration.d.ts +47 -0
  58. package/dist/src/utils/todo-migration.d.ts.map +1 -0
  59. package/dist/src/utils/todo-migration.js +261 -0
  60. package/dist/src/utils/todo-migration.js.map +1 -0
  61. package/package.json +1 -1
  62. package/dist/src/tools/human-override-tool.d.ts +0 -42
  63. package/dist/src/tools/human-override-tool.d.ts.map +0 -1
  64. package/dist/src/tools/human-override-tool.js +0 -431
  65. package/dist/src/tools/human-override-tool.js.map +0 -1
  66. package/dist/src/tools/todo-management-tool.d.ts +0 -344
  67. package/dist/src/tools/todo-management-tool.d.ts.map +0 -1
  68. package/dist/src/tools/todo-management-tool.js +0 -1249
  69. package/dist/src/tools/todo-management-tool.js.map +0 -1
package/dist/src/index.js CHANGED
@@ -198,7 +198,8 @@ export class McpAdrAnalysisServer {
198
198
  type: 'boolean',
199
199
  description: 'Include compliance checks in the analysis',
200
200
  default: true
201
- }
201
+ },
202
+ conversationContext: CONVERSATION_CONTEXT_SCHEMA
202
203
  }
203
204
  }
204
205
  },
@@ -236,14 +237,15 @@ export class McpAdrAnalysisServer {
236
237
  enum: ['web-application', 'mobile-app', 'microservices', 'data-platform', 'api-service', 'general'],
237
238
  description: 'Type of PRD for optimized knowledge generation',
238
239
  default: 'general'
239
- }
240
+ },
241
+ conversationContext: CONVERSATION_CONTEXT_SCHEMA
240
242
  },
241
243
  required: ['prdPath']
242
244
  }
243
245
  },
244
246
  {
245
247
  name: 'generate_adr_todo',
246
- description: 'Generate TDD-focused todo.md from existing ADRs with two-phase approach: test generation and production code',
248
+ description: 'Generate TDD-focused todo.md from existing ADRs with JSON-first approach: creates structured JSON TODO and syncs to markdown',
247
249
  inputSchema: {
248
250
  type: 'object',
249
251
  properties: {
@@ -265,7 +267,7 @@ export class McpAdrAnalysisServer {
265
267
  },
266
268
  linkAdrs: {
267
269
  type: 'boolean',
268
- description: 'Link all ADRs to create comprehensive system test coverage',
270
+ description: 'Auto-detect and link ADR dependencies in task creation',
269
271
  default: true
270
272
  },
271
273
  includeRules: {
@@ -288,7 +290,22 @@ export class McpAdrAnalysisServer {
288
290
  type: 'boolean',
289
291
  description: 'Preserve existing TODO.md content by merging instead of overwriting',
290
292
  default: true
291
- }
293
+ },
294
+ forceSyncToMarkdown: {
295
+ type: 'boolean',
296
+ description: 'Force sync JSON to markdown even if markdown is newer',
297
+ default: false
298
+ },
299
+ intentId: {
300
+ type: 'string',
301
+ description: 'Link generated tasks to specific knowledge graph intent'
302
+ },
303
+ createJsonBackup: {
304
+ type: 'boolean',
305
+ description: 'Create backup of existing JSON TODO data before import',
306
+ default: true
307
+ },
308
+ conversationContext: CONVERSATION_CONTEXT_SCHEMA
292
309
  }
293
310
  }
294
311
  },
@@ -1248,86 +1265,178 @@ export class McpAdrAnalysisServer {
1248
1265
  }
1249
1266
  },
1250
1267
  {
1251
- name: 'manage_todo',
1252
- description: 'Manage TODO.md files with incremental updates, task status tracking, and smart merging',
1268
+ name: 'manage_todo_json',
1269
+ description: 'JSON-first TODO management with consistent LLM interactions, automatic scoring sync, and knowledge graph integration',
1253
1270
  inputSchema: {
1254
1271
  type: 'object',
1255
1272
  properties: {
1256
1273
  operation: {
1257
1274
  type: 'string',
1258
- enum: ['update_status', 'add_tasks', 'merge_adr_updates', 'sync_progress', 'analyze_progress', 'delete_task', 'edit_task', 'move_task', 'manage_section', 'search_tasks'],
1259
- description: 'Operation to perform on TODO.md'
1275
+ enum: ['create_task', 'update_task', 'bulk_update', 'get_tasks', 'get_analytics', 'import_adr_tasks', 'sync_knowledge_graph', 'sync_to_markdown', 'import_from_markdown'],
1276
+ description: 'Operation to perform on TODO JSON backend'
1260
1277
  },
1261
- todoPath: {
1278
+ projectPath: {
1262
1279
  type: 'string',
1263
- default: 'TODO.md',
1264
- description: 'Path to TODO.md file'
1280
+ description: 'Project root path (uses configured PROJECT_PATH if not provided)'
1265
1281
  },
1266
- updates: {
1282
+ taskId: {
1283
+ type: 'string',
1284
+ description: 'Task ID for update operations'
1285
+ },
1286
+ title: {
1287
+ type: 'string',
1288
+ description: 'Task title for create operations'
1289
+ },
1290
+ description: {
1291
+ type: 'string',
1292
+ description: 'Task description'
1293
+ },
1294
+ priority: {
1295
+ type: 'string',
1296
+ enum: ['low', 'medium', 'high', 'critical'],
1297
+ default: 'medium',
1298
+ description: 'Task priority level'
1299
+ },
1300
+ assignee: {
1301
+ type: 'string',
1302
+ description: 'Task assignee'
1303
+ },
1304
+ dueDate: {
1305
+ type: 'string',
1306
+ description: 'Due date (ISO string format)'
1307
+ },
1308
+ category: {
1309
+ type: 'string',
1310
+ description: 'Task category'
1311
+ },
1312
+ tags: {
1267
1313
  type: 'array',
1268
- items: {
1269
- type: 'object',
1270
- properties: {
1271
- taskId: { type: 'string' },
1272
- status: { type: 'string', enum: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'] },
1273
- notes: { type: 'string' },
1274
- assignee: { type: 'string' }
1275
- },
1276
- required: ['taskId', 'status']
1277
- },
1278
- description: 'Status updates to apply (for update_status operation)'
1314
+ items: { type: 'string' },
1315
+ description: 'Task tags'
1279
1316
  },
1280
- tasks: {
1317
+ dependencies: {
1281
1318
  type: 'array',
1282
- items: {
1283
- type: 'object',
1284
- properties: {
1285
- title: { type: 'string' },
1286
- status: { type: 'string', enum: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'] },
1287
- priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
1288
- category: { type: 'string' },
1289
- assignee: { type: 'string' },
1290
- notes: { type: 'string' },
1291
- estimatedHours: { type: 'number' }
1292
- },
1293
- required: ['title', 'status']
1319
+ items: { type: 'string' },
1320
+ description: 'Task dependencies (task IDs)'
1321
+ },
1322
+ intentId: {
1323
+ type: 'string',
1324
+ description: 'Link to knowledge graph intent'
1325
+ },
1326
+ linkedAdrs: {
1327
+ type: 'array',
1328
+ items: { type: 'string' },
1329
+ description: 'Related ADR files'
1330
+ },
1331
+ autoComplete: {
1332
+ type: 'boolean',
1333
+ default: false,
1334
+ description: 'Auto-complete when criteria are met'
1335
+ },
1336
+ completionCriteria: {
1337
+ type: 'string',
1338
+ description: 'Auto-completion rules'
1339
+ },
1340
+ updates: {
1341
+ type: 'object',
1342
+ properties: {
1343
+ title: { type: 'string' },
1344
+ description: { type: 'string' },
1345
+ status: { type: 'string', enum: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'] },
1346
+ priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
1347
+ assignee: { type: 'string' },
1348
+ dueDate: { type: 'string' },
1349
+ progressPercentage: { type: 'number', minimum: 0, maximum: 100 },
1350
+ notes: { type: 'string' },
1351
+ tags: { type: 'array', items: { type: 'string' } }
1352
+ },
1353
+ description: 'Fields to update for update operations'
1354
+ },
1355
+ reason: {
1356
+ type: 'string',
1357
+ description: 'Reason for update (for changelog)'
1358
+ },
1359
+ filters: {
1360
+ type: 'object',
1361
+ properties: {
1362
+ status: { type: 'string', enum: ['pending', 'in_progress', 'completed', 'blocked', 'cancelled'] },
1363
+ priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
1364
+ assignee: { type: 'string' },
1365
+ category: { type: 'string' },
1366
+ hasDeadline: { type: 'boolean' },
1367
+ overdue: { type: 'boolean' },
1368
+ tags: { type: 'array', items: { type: 'string' } }
1294
1369
  },
1295
- description: 'New tasks to add (for add_tasks operation)'
1370
+ description: 'Filter criteria for get_tasks operation'
1371
+ },
1372
+ sortBy: {
1373
+ type: 'string',
1374
+ enum: ['priority', 'dueDate', 'createdAt', 'updatedAt'],
1375
+ default: 'priority',
1376
+ description: 'Sort field for get_tasks operation'
1377
+ },
1378
+ sortOrder: {
1379
+ type: 'string',
1380
+ enum: ['asc', 'desc'],
1381
+ default: 'desc',
1382
+ description: 'Sort order for get_tasks operation'
1383
+ },
1384
+ limit: {
1385
+ type: 'number',
1386
+ description: 'Maximum number of tasks to return'
1296
1387
  },
1297
- section: {
1388
+ timeframe: {
1298
1389
  type: 'string',
1299
- description: 'Section to add tasks to (for add_tasks operation)'
1390
+ enum: ['day', 'week', 'month', 'all'],
1391
+ default: 'week',
1392
+ description: 'Analysis timeframe for analytics'
1393
+ },
1394
+ includeVelocity: {
1395
+ type: 'boolean',
1396
+ default: true,
1397
+ description: 'Include velocity metrics in analytics'
1398
+ },
1399
+ includeScoring: {
1400
+ type: 'boolean',
1401
+ default: true,
1402
+ description: 'Include scoring metrics in analytics'
1300
1403
  },
1301
1404
  adrDirectory: {
1302
1405
  type: 'string',
1303
1406
  default: 'docs/adrs',
1304
- description: 'ADR directory path (for merge_adr_updates and sync_progress operations)'
1407
+ description: 'ADR directory path for imports'
1305
1408
  },
1306
- preserveCompleted: {
1409
+ preserveExisting: {
1307
1410
  type: 'boolean',
1308
1411
  default: true,
1309
- description: 'Keep completed tasks during merge (for merge_adr_updates operation)'
1412
+ description: 'Keep existing tasks during imports'
1310
1413
  },
1311
- preserveCustom: {
1414
+ autoLinkDependencies: {
1312
1415
  type: 'boolean',
1313
1416
  default: true,
1314
- description: 'Keep manually added tasks during merge (for merge_adr_updates operation)'
1417
+ description: 'Auto-detect task dependencies'
1418
+ },
1419
+ direction: {
1420
+ type: 'string',
1421
+ enum: ['to_kg', 'from_kg', 'bidirectional'],
1422
+ default: 'bidirectional',
1423
+ description: 'Knowledge graph sync direction'
1315
1424
  },
1316
- updateAdrs: {
1425
+ force: {
1317
1426
  type: 'boolean',
1318
1427
  default: false,
1319
- description: 'Update ADR status based on TODO progress (for sync_progress operation)'
1428
+ description: 'Force operation even if conflicts exist'
1320
1429
  },
1321
- timeframe: {
1430
+ mergeStrategy: {
1322
1431
  type: 'string',
1323
- enum: ['day', 'week', 'month', 'all'],
1324
- default: 'week',
1325
- description: 'Analysis timeframe (for analyze_progress operation)'
1432
+ enum: ['overwrite', 'merge', 'preserve_json'],
1433
+ default: 'merge',
1434
+ description: 'Merge strategy for imports'
1326
1435
  },
1327
- includeVelocity: {
1436
+ backupExisting: {
1328
1437
  type: 'boolean',
1329
1438
  default: true,
1330
- description: 'Include velocity metrics in analysis (for analyze_progress operation)'
1439
+ description: 'Create backup before destructive operations'
1331
1440
  }
1332
1441
  },
1333
1442
  required: ['operation']
@@ -1559,7 +1668,8 @@ export class McpAdrAnalysisServer {
1559
1668
  type: 'string',
1560
1669
  description: 'Path to TODO.md file',
1561
1670
  default: 'TODO.md'
1562
- }
1671
+ },
1672
+ conversationContext: CONVERSATION_CONTEXT_SCHEMA
1563
1673
  },
1564
1674
  required: ['operation']
1565
1675
  }
@@ -1572,7 +1682,7 @@ export class McpAdrAnalysisServer {
1572
1682
  properties: {
1573
1683
  operation: {
1574
1684
  type: 'string',
1575
- enum: ['recalculate_scores', 'sync_scores', 'diagnose_scores', 'optimize_weights', 'reset_scores'],
1685
+ enum: ['recalculate_scores', 'sync_scores', 'diagnose_scores', 'optimize_weights', 'reset_scores', 'get_score_trends', 'get_intent_scores'],
1576
1686
  description: 'Smart scoring operation to perform'
1577
1687
  },
1578
1688
  projectPath: {
@@ -1607,7 +1717,7 @@ export class McpAdrAnalysisServer {
1607
1717
  type: 'array',
1608
1718
  items: {
1609
1719
  type: 'string',
1610
- enum: ['manage_todo', 'smart_git_push', 'compare_adr_progress', 'analyze_content_security', 'validate_rules']
1720
+ enum: ['manage_todo_json', 'smart_git_push', 'compare_adr_progress', 'analyze_content_security', 'validate_rules']
1611
1721
  },
1612
1722
  description: 'Tools to trigger for fresh data (for sync_scores operation)'
1613
1723
  },
@@ -1668,56 +1778,13 @@ export class McpAdrAnalysisServer {
1668
1778
  type: 'boolean',
1669
1779
  default: true,
1670
1780
  description: 'Immediately recalculate after reset (for reset_scores operation)'
1671
- }
1672
- },
1673
- required: ['operation', 'projectPath']
1674
- }
1675
- },
1676
- {
1677
- name: 'human_override',
1678
- description: 'Human override to force AI-powered tool planning when LLMs get confused or stuck - cuts through confusion with direct task execution',
1679
- inputSchema: {
1680
- type: 'object',
1681
- properties: {
1682
- taskDescription: {
1683
- type: 'string',
1684
- description: 'What the human wants accomplished (in plain English)'
1685
1781
  },
1686
- projectPath: {
1687
- type: 'string',
1688
- description: 'Path to project directory'
1689
- },
1690
- adrDirectory: {
1782
+ intentId: {
1691
1783
  type: 'string',
1692
- default: 'docs/adrs',
1693
- description: 'ADR directory path'
1694
- },
1695
- todoPath: {
1696
- type: 'string',
1697
- default: 'TODO.md',
1698
- description: 'Path to TODO.md file'
1699
- },
1700
- priority: {
1701
- type: 'string',
1702
- enum: ['low', 'medium', 'high', 'critical'],
1703
- default: 'high',
1704
- description: 'Task priority level'
1705
- },
1706
- forceExecution: {
1707
- type: 'boolean',
1708
- default: true,
1709
- description: 'Force immediate execution planning'
1710
- },
1711
- deadline: {
1712
- type: 'string',
1713
- description: 'When this must be completed (optional)'
1714
- },
1715
- additionalContext: {
1716
- type: 'string',
1717
- description: 'Any additional context or constraints (optional)'
1784
+ description: 'Intent ID to get score trends for (for get_intent_scores operation)'
1718
1785
  }
1719
1786
  },
1720
- required: ['taskDescription', 'projectPath']
1787
+ required: ['operation', 'projectPath']
1721
1788
  }
1722
1789
  }
1723
1790
  ]
@@ -1819,8 +1886,8 @@ export class McpAdrAnalysisServer {
1819
1886
  case 'list_directory':
1820
1887
  response = await this.listDirectory(args);
1821
1888
  break;
1822
- case 'manage_todo':
1823
- response = await this.manageTodo(args);
1889
+ case 'manage_todo_json':
1890
+ response = await this.manageTodoJson(args);
1824
1891
  break;
1825
1892
  case 'generate_deployment_guidance':
1826
1893
  response = await this.generateDeploymentGuidance(args);
@@ -1834,9 +1901,6 @@ export class McpAdrAnalysisServer {
1834
1901
  case 'smart_score':
1835
1902
  response = await this.smartScore(args);
1836
1903
  break;
1837
- case 'human_override':
1838
- response = await this.humanOverride(args);
1839
- break;
1840
1904
  default:
1841
1905
  throw new McpAdrError(`Unknown tool: ${name}`, 'UNKNOWN_TOOL');
1842
1906
  }
@@ -3247,371 +3311,102 @@ The enhanced process maintains full traceability from PRD requirements to genera
3247
3311
  }
3248
3312
  }
3249
3313
  async generateAdrTodo(args) {
3250
- const { scope = 'all', phase = 'both', linkAdrs = true, includeRules = true, ruleSource = 'both', todoPath = 'todo.md', preserveExisting = true } = args;
3314
+ const { scope = 'all', phase = 'both', linkAdrs = true, includeRules = true, ruleSource = 'both', preserveExisting = true, forceSyncToMarkdown = false, intentId, createJsonBackup = true } = args;
3251
3315
  const { getAdrDirectoryPath } = await import('./utils/config.js');
3252
3316
  const path = await import('path');
3253
- const fs = await import('fs/promises');
3254
3317
  // Use absolute ADR path relative to project
3255
3318
  const absoluteAdrPath = args.adrDirectory ?
3256
3319
  path.resolve(this.config.projectPath, args.adrDirectory) :
3257
3320
  getAdrDirectoryPath(this.config);
3258
3321
  // Keep relative path for display purposes
3259
3322
  const adrDirectory = args.adrDirectory || this.config.adrDirectory;
3260
- // Resolve absolute TODO path
3261
- const absoluteTodoPath = path.resolve(this.config.projectPath, todoPath);
3262
- this.logger.info(`Generating TDD-focused todo for ADRs in: ${absoluteAdrPath} (phase: ${phase})`);
3323
+ this.logger.info(`Generating JSON-first TODO for ADRs in: ${absoluteAdrPath} (phase: ${phase})`);
3263
3324
  try {
3264
- // Check if TODO.md already exists
3265
- let existingTodoExists = false;
3266
- try {
3267
- await fs.access(absoluteTodoPath);
3268
- existingTodoExists = true;
3269
- this.logger.info(`Existing TODO.md found at: ${absoluteTodoPath}`);
3270
- }
3271
- catch (error) {
3272
- if (error.code !== 'ENOENT') {
3273
- this.logger.error(`Error accessing existing TODO.md: ${error.message}`);
3274
- }
3275
- }
3276
- // If preserving existing content and file exists, use manageTodo merge instead
3277
- if (preserveExisting && existingTodoExists) {
3278
- this.logger.info('Preserving existing TODO.md content, using merge approach');
3279
- // Use manageTodo to merge ADR updates with existing content
3280
- const { manageTodo } = await import('./tools/todo-management-tool.js');
3281
- const mergeResult = await manageTodo({
3282
- operation: 'merge_adr_updates',
3283
- todoPath: absoluteTodoPath,
3284
- adrDirectory: absoluteAdrPath,
3285
- preserveCompleted: true,
3286
- preserveCustom: true
3287
- }, this.config.projectPath);
3288
- return {
3289
- content: [{
3290
- type: 'text',
3291
- text: `# TODO.md Merge Completed
3292
-
3293
- ## Existing File Preserved
3294
- - **Location**: ${absoluteTodoPath}
3295
- - **Action**: Merged ADR updates with existing content
3296
- - **Preservation**: Custom tasks and completed items preserved
3297
-
3298
- ## Analysis Information
3299
- - **ADR Directory**: ${adrDirectory}
3300
- - **Scope**: ${scope}
3301
- - **TDD Phase**: ${phase}
3302
- - **ADR Linking**: ${linkAdrs ? 'Enabled' : 'Disabled'}
3303
- - **Rules Integration**: ${includeRules ? `Enabled (${ruleSource})` : 'Disabled'}
3304
-
3305
- ${mergeResult.content[0].text}
3306
-
3307
- ## Next Steps
3308
- 1. Review merged TODO.md content
3309
- 2. Update task statuses as needed using \`manage_todo\`
3310
- 3. Use \`compare_adr_progress\` to validate implementation status
3311
-
3312
- *To force regeneration, set \`preserveExisting: false\` in the request*`
3313
- }]
3314
- };
3315
- }
3316
- const { discoverAdrsInDirectory } = await import('./utils/adr-discovery.js');
3317
- const { scanProjectStructure } = await import('./utils/actual-file-operations.js');
3318
- // Use actual ADR discovery
3319
- const discoveryResult = await discoverAdrsInDirectory(absoluteAdrPath, true, this.config.projectPath);
3320
- let adrContent = `Found ${discoveryResult.adrs.length} ADRs in ${absoluteAdrPath}:\n\n`;
3321
- discoveryResult.adrs.forEach(adr => {
3322
- adrContent += `### ${adr.title}\n`;
3323
- adrContent += `- **File**: ${adr.filename}\n`;
3324
- adrContent += `- **Status**: ${adr.status}\n`;
3325
- adrContent += `- **Context**: ${adr.context}\n`;
3326
- adrContent += `- **Decision**: ${adr.decision}\n`;
3327
- adrContent += `- **Consequences**: ${adr.consequences}\n\n`;
3328
- });
3329
- // For ADR linking, also discover all project structure
3330
- let projectStructurePrompt = '';
3331
- if (linkAdrs) {
3332
- const projectStructure = await scanProjectStructure(this.config.projectPath, {
3333
- readContent: false,
3334
- includeHidden: false
3335
- });
3336
- const codeFiles = [
3337
- ...projectStructure.buildFiles.filter(f => f.filename.match(/\.(ts|js|py|java|cs|go|rb|php|swift|kt|rs|cpp|c|h)$/)),
3338
- ...projectStructure.configFiles.filter(f => f.filename.match(/\.(ts|js)$/))
3339
- ];
3340
- projectStructurePrompt = `
3341
- ## Project Structure (for ADR linking)
3342
- Found ${codeFiles.length} code files:
3343
- ${codeFiles.map(f => `- ${f.relativePath} (${f.type})`).join('\n')}
3344
- `;
3345
- }
3346
- // For rules integration, extract architectural rules from ADRs
3347
- let rulesPrompt = '';
3348
- if (includeRules) {
3325
+ // Always use JSON-first TODO system
3326
+ this.logger.info('Using JSON-first TODO system for ADR task generation');
3327
+ const { manageTodoV2 } = await import('./tools/todo-management-tool-v2.js');
3328
+ // Optional: Create backup if requested and JSON exists
3329
+ if (createJsonBackup) {
3349
3330
  try {
3350
- const rulesResult = await this.generateRules({
3351
- source: ruleSource,
3352
- adrDirectory: adrDirectory,
3331
+ await manageTodoV2({
3332
+ operation: 'import_from_markdown',
3353
3333
  projectPath: this.config.projectPath,
3354
- outputFormat: 'json'
3334
+ mergeStrategy: 'preserve_json',
3335
+ backupExisting: true
3355
3336
  });
3356
- if (rulesResult.content) {
3357
- rulesPrompt = `
3358
- ## Architectural Rules (for compliance validation)
3359
- The following architectural rules have been extracted from ADRs and should be validated in tests:
3360
-
3361
- ${Array.isArray(rulesResult.content) ? rulesResult.content.map((c) => c.text || c).join('\n') : rulesResult.content}
3362
- `;
3363
- }
3337
+ this.logger.info('Created backup of existing JSON TODO data');
3364
3338
  }
3365
3339
  catch (error) {
3366
- this.logger.warn(`Failed to extract rules: ${error instanceof Error ? error.message : String(error)}`);
3367
- rulesPrompt = `
3368
- ## Architectural Rules (failed to extract)
3369
- Note: Could not extract architectural rules automatically. Manual rule validation may be needed.
3370
- `;
3340
+ // Continue if backup fails - might be first time setup
3341
+ this.logger.debug('No existing JSON data to backup');
3371
3342
  }
3372
3343
  }
3373
- // Generate TDD-focused todo creation prompt
3374
- const todoPrompt = `
3375
- # TDD-Focused ADR Todo Generation Request
3376
-
3377
- ## Step 1: ADR Discovery Results
3378
- ${adrContent}
3379
- ${projectStructurePrompt}
3380
- ${rulesPrompt}
3381
-
3382
- ## Step 2: TDD Todo Generation Analysis
3383
-
3384
- Once you have discovered and read the ADR files, please analyze them and generate a comprehensive TDD-focused todo.md file.
3385
-
3386
- ## TDD Phase: ${phase}
3387
- ${phase === 'test' ? '**Focus on Phase 1: Mock Test Generation Only**' : ''}
3388
- ${phase === 'production' ? '**Focus on Phase 2: Production Code Implementation (assumes tests exist)**' : ''}
3389
- ${phase === 'both' ? '**Generate both Phase 1 (Tests) and Phase 2 (Production) tasks**' : ''}
3390
-
3391
- ## Requirements
3392
-
3393
- 1. **Extract Tasks**: Identify all implementation tasks from ADRs
3394
- 2. **TDD Approach**: For each task, create:
3395
- - Phase 1: Mock test specifications
3396
- - Phase 2: Production implementation tasks
3397
- 3. **ADR Linking**: ${linkAdrs ? 'Link related ADRs to create comprehensive system tests' : 'Focus on individual ADR tasks'}
3398
- 4. **Rules Integration**: ${includeRules ? `Include architectural rules validation in tests (source: ${ruleSource})` : 'Skip architectural rules validation'}
3399
- 5. **Categorize**: Group tasks by ADR and testing phase
3400
- 6. **Status Detection**: Determine task completion status
3401
- 7. **Progress Tracking**: Calculate overall progress for both test and implementation phases
3402
- 8. **Scope Filter**: ${scope === 'all' ? 'Include all tasks' : `Focus on ${scope} tasks only`}
3403
-
3404
- ## TDD Todo.md Format
3405
-
3406
- \`\`\`markdown
3407
- # TDD-Focused ADR Implementation Progress
3408
-
3409
- **Last Updated**: [Date]
3410
- **Overall Progress**: [X]% Complete
3411
- **Test Coverage**: [X]% Complete
3412
- **Implementation Coverage**: [X]% Complete
3413
-
3414
- ## Summary
3415
- - Total ADRs: [count]
3416
- - Total Tasks: [count] (Tests: [count], Implementation: [count])
3417
- - Completed: [count]
3418
- - In Progress: [count]
3419
- - Pending: [count]
3420
-
3421
- ## System Architecture Overview (from linked ADRs)
3422
- [Brief summary of how all ADRs connect to form the complete system]
3423
-
3424
- ## Phase 1: Test Generation Tasks
3425
-
3426
- ### ADR-001: [Title]
3427
- #### Test Specifications
3428
- - [ ] TEST: Unit test for [component/function]
3429
- - Mock: [what to mock]
3430
- - Expected: [expected behavior]
3431
- - Coverage: [what this tests]
3432
- - [ ] TEST: Integration test for [feature]
3433
- - Setup: [test environment]
3434
- - Scenario: [test scenario]
3435
- - Assertions: [what to verify]
3436
- ${includeRules ? `- [ ] RULE: Architectural rule validation test for [rule name]
3437
- - Validation: [what rule to check]
3438
- - Pattern: [validation pattern/regex]
3439
- - Expected: [compliant behavior]` : ''}
3440
-
3441
- ### ADR-002: [Title]
3442
- #### Test Specifications
3443
- - [ ] TEST: [test description]
3444
- ${includeRules ? '- [ ] RULE: [rule validation test]' : ''}
3445
- ...
3446
-
3447
- ## Phase 2: Production Implementation Tasks
3448
-
3449
- ### ADR-001: [Title]
3450
- #### Implementation Tasks (after tests pass)
3451
- - [ ] IMPL: Implement [component/function]
3452
- - Precondition: Unit test for [component] exists
3453
- - Definition: [what to implement]
3454
- - Acceptance: All related tests pass
3455
- ${includeRules ? ` - Compliance: Must pass architectural rule validation` : ''}
3456
- - [ ] IMPL: [implementation task]
3457
-
3458
- ### ADR-002: [Title]
3459
- #### Implementation Tasks
3460
- - [ ] IMPL: [implementation description]
3461
- ${includeRules ? ' - Compliance: [specific rule requirements]' : ''}
3462
- ...
3463
-
3464
- ## ADR Dependencies and Links
3465
- - ADR-001 → ADR-002: [relationship description]
3466
- - ADR-002 → ADR-003: [relationship description]
3467
-
3468
- ## Test-First Development Workflow
3469
- 1. Complete all Phase 1 tests for a component
3470
- ${includeRules ? '2. Complete architectural rule validation tests' : ''}
3471
- ${includeRules ? '3' : '2'}. Run tests (they should fail)
3472
- ${includeRules ? '4' : '3'}. Implement Phase 2 production code
3473
- ${includeRules ? '5' : '4'}. Run tests (they should pass)
3474
- ${includeRules ? '6. Validate architectural rule compliance' : ''}
3475
- ${includeRules ? '7' : '5'}. Refactor if needed while maintaining rule compliance
3476
- \`\`\`
3477
-
3478
- Please provide:
3479
- 1. Comprehensive task extraction from all ADRs
3480
- 2. Test specifications for each implementation task
3481
- ${includeRules ? '3. Architectural rule validation tests and compliance checks' : ''}
3482
- ${includeRules ? '4' : '3'}. Clear separation of test and implementation phases
3483
- ${includeRules ? '5' : '4'}. ADR relationship mapping for system-wide test coverage
3484
- ${includeRules ? '6' : '5'}. TDD workflow recommendations with rule compliance integration
3485
- `;
3486
- // Execute the todo generation with AI if enabled, otherwise return prompt
3487
- const { executePromptWithFallback, formatMCPResponse } = await import('./utils/prompt-execution.js');
3488
- const executionResult = await executePromptWithFallback(todoPrompt, 'Generate TDD-focused todo.md file from ADR analysis with test-first approach and system-wide coverage', {
3489
- temperature: 0.1,
3490
- maxTokens: 8000,
3491
- systemPrompt: `You are an expert in Test-Driven Development (TDD) and architectural implementation.
3492
- Analyze the provided ADRs to extract actionable tasks following a strict TDD approach.
3493
-
3494
- Key responsibilities:
3495
- 1. For each implementation task, FIRST define the test specifications
3496
- 2. Create mock test descriptions that verify the expected behavior
3497
- 3. Link related ADRs to ensure comprehensive system test coverage
3498
- 4. Separate test generation (Phase 1) from production code (Phase 2)
3499
- 5. Ensure every production task has corresponding test coverage
3500
- 6. Map ADR dependencies to identify integration test requirements
3501
- ${includeRules ? '7. Include architectural rule validation in test specifications' : ''}
3502
- ${includeRules ? '8. Create compliance checks for extracted architectural rules' : ''}
3503
- ${includeRules ? '9. Ensure implementation tasks include rule compliance verification' : ''}
3504
-
3505
- Follow the TDD red-green-refactor cycle:
3506
- - Red: Write failing tests first (Phase 1)${includeRules ? ' including rule validation tests' : ''}
3507
- - Green: Implement minimal code to pass tests (Phase 2)
3508
- - Refactor: Improve code while keeping tests green${includeRules ? ' and maintaining rule compliance' : ''}
3509
-
3510
- ${includeRules ? 'The architectural rules provide constraints and patterns that must be validated in tests and followed in implementation.' : ''}
3511
-
3512
- The todo.md should serve as the glue connecting all ADRs into a cohesive, testable${includeRules ? ', rule-compliant' : ''} system.`,
3513
- responseFormat: 'text'
3344
+ // Import ADR tasks into JSON system with enhanced parameters
3345
+ const importResult = await manageTodoV2({
3346
+ operation: 'import_adr_tasks',
3347
+ projectPath: this.config.projectPath,
3348
+ adrDirectory: absoluteAdrPath,
3349
+ preserveExisting,
3350
+ autoLinkDependencies: linkAdrs,
3351
+ ...(intentId && { intentId })
3514
3352
  });
3515
- if (executionResult.isAIGenerated) {
3516
- // AI execution successful - return actual todo generation results
3517
- return formatMCPResponse({
3518
- ...executionResult,
3519
- content: `# TDD-Focused ADR Todo Generation Results
3353
+ // Sync JSON data to markdown with force option
3354
+ await manageTodoV2({
3355
+ operation: 'sync_to_markdown',
3356
+ projectPath: this.config.projectPath,
3357
+ force: forceSyncToMarkdown
3358
+ });
3359
+ return {
3360
+ content: [{
3361
+ type: 'text',
3362
+ text: `# ✅ JSON-First TODO Generated from ADRs
3363
+
3364
+ ## 🏗️ JSON-First TODO System Active
3365
+ ✅ **todo-data.json** - JSON-first TODO backend created/updated
3366
+ ✅ **TODO.md** - Markdown frontend ${forceSyncToMarkdown ? 'synchronized' : 'available for sync'}
3520
3367
 
3521
- ## Analysis Information
3368
+ ## Configuration Applied
3522
3369
  - **ADR Directory**: ${adrDirectory}
3523
3370
  - **Scope**: ${scope}
3524
3371
  - **TDD Phase**: ${phase}
3525
- - **ADR Linking**: ${linkAdrs ? 'Enabled' : 'Disabled'}
3372
+ - **ADR Dependency Linking**: ${linkAdrs ? 'Enabled' : 'Disabled'}
3526
3373
  - **Rules Integration**: ${includeRules ? `Enabled (${ruleSource})` : 'Disabled'}
3527
-
3528
- ## AI-Generated TDD Todo Results
3529
-
3530
- ${executionResult.content}
3531
-
3532
- ## TDD Implementation Workflow
3533
-
3534
- ### Phase 1: Test Generation (Red Phase)
3535
- 1. **Review Test Specifications**: Examine each test task for completeness
3536
- 2. **Create Mock Tests**: Implement test files with proper mocking
3537
- 3. **Define Assertions**: Ensure tests verify expected behavior
3538
- 4. **Run Tests**: Confirm all tests fail (red phase)
3539
-
3540
- ### Phase 2: Production Implementation (Green Phase)
3541
- 1. **Implement Minimal Code**: Write just enough code to pass tests
3542
- 2. **Run Tests Again**: Verify tests now pass (green phase)
3543
- 3. **Check Coverage**: Ensure all ADR requirements are tested
3544
- 4. **Integration Testing**: Verify ADR interactions work correctly
3545
-
3546
- ### Phase 3: Refactoring (Refactor Phase)
3547
- 1. **Improve Code Quality**: Refactor while keeping tests green
3548
- 2. **Update Documentation**: Keep ADRs and tests in sync
3549
- 3. **Performance Optimization**: Optimize without breaking tests
3550
-
3551
- ## ADR System Integration
3552
-
3553
- The todo.md serves as the glue connecting all ADRs by:
3554
- - **Mapping Dependencies**: Shows how ADRs relate to each other
3555
- - **System-wide Coverage**: Ensures no gaps in test coverage
3556
- - **Progress Tracking**: Monitors both test and implementation completion
3557
- - **Working Environment**: Defines the expected system outcome
3558
-
3559
- ## Integration Commands
3560
-
3561
- ### Generate Test Phase Only:
3562
- \`\`\`json
3563
- {
3564
- "tool": "generate_adr_todo",
3565
- "args": {
3566
- "adrDirectory": "${adrDirectory}",
3567
- "phase": "test",
3568
- "linkAdrs": true,
3569
- "includeRules": true,
3570
- "ruleSource": "both"
3571
- }
3572
- }
3573
- \`\`\`
3574
-
3575
- ### Generate Production Phase Only:
3576
- \`\`\`json
3577
- {
3578
- "tool": "generate_adr_todo",
3579
- "args": {
3580
- "adrDirectory": "${adrDirectory}",
3581
- "phase": "production",
3582
- "scope": "pending",
3583
- "includeRules": true
3584
- }
3585
- }
3586
- \`\`\`
3587
-
3588
- ### Update Full TDD Todo with Rules:
3589
- \`\`\`json
3590
- {
3591
- "tool": "generate_adr_todo",
3592
- "args": {
3593
- "adrDirectory": "${adrDirectory}",
3594
- "phase": "both",
3595
- "linkAdrs": true,
3596
- "includeRules": true,
3597
- "ruleSource": "both"
3598
- }
3599
- }
3600
- \`\`\`
3601
- `,
3602
- });
3603
- }
3604
- else {
3605
- // Fallback to prompt-only mode
3606
- return {
3607
- content: [
3608
- {
3609
- type: 'text',
3610
- text: `TDD-focused ADR todo generation for: ${adrDirectory}\n\nPhase: ${phase}\nADR Linking: ${linkAdrs ? 'Enabled' : 'Disabled'}\nRules Integration: ${includeRules ? `Enabled (${ruleSource})` : 'Disabled'}\nScope: ${scope}\n\nPlease generate a TDD-focused todo.md using the following prompt:\n\n${todoPrompt}`
3611
- }
3612
- ]
3613
- };
3614
- }
3374
+ - **Preserve Existing**: ${preserveExisting}
3375
+ - **Force Markdown Sync**: ${forceSyncToMarkdown ? 'Enabled' : 'Disabled'}
3376
+ - **Intent Linking**: ${intentId ? `Linked to ${intentId}` : 'None'}
3377
+ - **JSON Backup**: ${createJsonBackup ? 'Created' : 'Skipped'}
3378
+
3379
+ ## JSON-First Architecture Benefits
3380
+ ✅ **Structured Data**: JSON backend ensures consistent LLM interactions
3381
+ ✅ **Automatic Sync**: JSON-to-markdown conversion maintains TODO.md compatibility
3382
+ ✅ **Enhanced Metadata**: Full task lifecycle with dependencies, assignees, priorities
3383
+ ✅ **Complete Integration**: Native support for scoring, git automation, and knowledge graph
3384
+ ✅ **Backup Protection**: Automatic data preservation during updates
3385
+ ✅ **No Manual Setup**: All cache files auto-generated, tests can immediately validate
3386
+
3387
+ ${importResult.content[0].text}
3388
+
3389
+ ## Available Operations (use manage_todo_v2 tool)
3390
+ 1. **View Tasks**: \`get_tasks\` operation with filtering and sorting
3391
+ 2. **Update Status**: \`update_task\` operation with status, progress, notes
3392
+ 3. **Bulk Updates**: \`bulk_update\` operation for multiple tasks
3393
+ 4. **Analytics**: \`get_analytics\` operation for progress metrics
3394
+ 5. **Sync Control**: \`sync_to_markdown\` and \`sync_knowledge_graph\` operations
3395
+
3396
+ ## Validation & Progress Tracking
3397
+ - **Progress Check**: Use \`compare_adr_progress\` to validate implementation vs ADRs
3398
+ - **Git Integration**: Use \`smart_git_push\` for automatic task status updates
3399
+ - **Scoring**: Integrated with smart scoring for release readiness assessment
3400
+
3401
+ ## TDD Workflow Integration
3402
+ - **Phase 1**: Mock test generation tasks created
3403
+ - **Phase 2**: Production implementation tasks linked to tests
3404
+ - **Dependencies**: ADR relationships mapped to task dependencies
3405
+ - **Validation**: Architectural rules integrated into task criteria
3406
+
3407
+ *All TODO data is now managed in JSON format with automatic markdown sync*`
3408
+ }]
3409
+ };
3615
3410
  }
3616
3411
  catch (error) {
3617
3412
  throw new McpAdrError(`Failed to generate ADR todo: ${error instanceof Error ? error.message : String(error)}`, 'GENERATION_ERROR');
@@ -4511,7 +4306,12 @@ Please provide:
4511
4306
  }
4512
4307
  // If no intent found, create a standalone execution record
4513
4308
  if (!intentId) {
4514
- intentId = await this.kgManager.createIntent(`Standalone tool execution: ${toolName}`, [`Execute ${toolName}`, 'Complete tool operation'], 'medium');
4309
+ // Extract human request from conversation context if available
4310
+ let humanRequest = `Standalone tool execution: ${toolName}`;
4311
+ if (parameters?.conversationContext?.humanRequest) {
4312
+ humanRequest = parameters.conversationContext.humanRequest;
4313
+ }
4314
+ intentId = await this.kgManager.createIntent(humanRequest, [`Execute ${toolName}`, 'Complete tool operation'], 'medium');
4515
4315
  }
4516
4316
  // Determine tasks created/modified from tool operation
4517
4317
  const todoTasksCreated = [];
@@ -4731,13 +4531,18 @@ Please provide:
4731
4531
  throw new McpAdrError(`Failed to list directory: ${error instanceof Error ? error.message : String(error)}`, 'DIRECTORY_LIST_ERROR');
4732
4532
  }
4733
4533
  }
4734
- async manageTodo(args) {
4534
+ async manageTodoJson(args) {
4735
4535
  try {
4736
- const { manageTodo } = await import('./tools/todo-management-tool.js');
4737
- return await manageTodo(args, this.config.projectPath);
4536
+ const { manageTodoV2 } = await import('./tools/todo-management-tool-v2.js');
4537
+ // Add projectPath to args if not provided
4538
+ const argsWithPath = {
4539
+ ...args,
4540
+ projectPath: args.projectPath || this.config.projectPath
4541
+ };
4542
+ return await manageTodoV2(argsWithPath);
4738
4543
  }
4739
4544
  catch (error) {
4740
- throw new McpAdrError(`TODO management failed: ${error instanceof Error ? error.message : String(error)}`, 'TODO_MANAGEMENT_ERROR');
4545
+ throw new McpAdrError(`JSON TODO management failed: ${error instanceof Error ? error.message : String(error)}`, 'TODO_JSON_MANAGEMENT_ERROR');
4741
4546
  }
4742
4547
  }
4743
4548
  async generateDeploymentGuidance(args) {
@@ -4776,15 +4581,6 @@ Please provide:
4776
4581
  throw new McpAdrError(`Smart score analysis failed: ${error instanceof Error ? error.message : String(error)}`, 'SMART_SCORE_ERROR');
4777
4582
  }
4778
4583
  }
4779
- async humanOverride(args) {
4780
- try {
4781
- const { humanOverride } = await import('./tools/human-override-tool.js');
4782
- return await humanOverride(args);
4783
- }
4784
- catch (error) {
4785
- throw new McpAdrError(`Human override failed: ${error instanceof Error ? error.message : String(error)}`, 'HUMAN_OVERRIDE_ERROR');
4786
- }
4787
- }
4788
4584
  }
4789
4585
  /**
4790
4586
  * Main execution