@dizzlkheinz/ynab-mcpb 0.15.0 → 0.16.0

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 (30) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/bundle/index.cjs +50 -49
  3. package/dist/server/YNABMCPServer.d.ts +2 -6
  4. package/dist/server/YNABMCPServer.js +5 -1
  5. package/dist/server/resources.d.ts +17 -13
  6. package/dist/server/resources.js +237 -48
  7. package/dist/tools/reconcileAdapter.d.ts +1 -0
  8. package/dist/tools/reconcileAdapter.js +1 -0
  9. package/dist/tools/reconciliation/analyzer.d.ts +5 -1
  10. package/dist/tools/reconciliation/analyzer.js +10 -8
  11. package/dist/tools/reconciliation/csvParser.d.ts +3 -0
  12. package/dist/tools/reconciliation/csvParser.js +58 -19
  13. package/dist/tools/reconciliation/executor.js +47 -1
  14. package/dist/tools/reconciliation/index.js +82 -42
  15. package/dist/tools/reconciliation/reportFormatter.d.ts +1 -0
  16. package/dist/tools/reconciliation/reportFormatter.js +49 -36
  17. package/docs/reference/API.md +144 -0
  18. package/docs/technical/reconciliation-system-architecture.md +2251 -0
  19. package/package.json +1 -1
  20. package/src/server/YNABMCPServer.ts +7 -0
  21. package/src/server/__tests__/resources.template.test.ts +198 -0
  22. package/src/server/__tests__/resources.test.ts +10 -2
  23. package/src/server/resources.ts +307 -62
  24. package/src/tools/reconcileAdapter.ts +2 -0
  25. package/src/tools/reconciliation/__tests__/reportFormatter.test.ts +23 -23
  26. package/src/tools/reconciliation/analyzer.ts +18 -6
  27. package/src/tools/reconciliation/csvParser.ts +84 -18
  28. package/src/tools/reconciliation/executor.ts +58 -1
  29. package/src/tools/reconciliation/index.ts +112 -61
  30. package/src/tools/reconciliation/reportFormatter.ts +55 -37
@@ -14,6 +14,8 @@ import type {
14
14
  import type { LegacyReconciliationResult } from './executor.js';
15
15
  import type { MoneyValue } from '../../utils/money.js';
16
16
 
17
+ const SECTION_DIVIDER = '-'.repeat(60);
18
+
17
19
  /**
18
20
  * Options for report formatting
19
21
  */
@@ -24,6 +26,7 @@ export interface ReportFormatterOptions {
24
26
  includeDetailedMatches?: boolean | undefined;
25
27
  maxUnmatchedToShow?: number | undefined;
26
28
  maxInsightsToShow?: number | undefined;
29
+ notes?: string[] | undefined;
27
30
  }
28
31
 
29
32
  /**
@@ -40,6 +43,11 @@ export function formatHumanReadableReport(
40
43
  // Header
41
44
  sections.push(formatHeader(accountLabel, analysis));
42
45
 
46
+ // Contextual notes (if provided)
47
+ if (options.notes && options.notes.length > 0) {
48
+ sections.push(formatNotesSection(options.notes));
49
+ }
50
+
43
51
  // Balance check section
44
52
  sections.push(formatBalanceSection(analysis.balance_info, analysis.summary));
45
53
 
@@ -67,12 +75,22 @@ export function formatHumanReadableReport(
67
75
  */
68
76
  function formatHeader(accountName: string, analysis: ReconciliationAnalysis): string {
69
77
  const lines: string[] = [];
70
- lines.push(`📊 ${accountName} Reconciliation Report`);
71
- lines.push('═'.repeat(60));
78
+ lines.push(`${accountName} Reconciliation Report`);
79
+ lines.push(SECTION_DIVIDER);
72
80
  lines.push(`Statement Period: ${analysis.summary.statement_date_range}`);
73
81
  return lines.join('\n');
74
82
  }
75
83
 
84
+ function formatNotesSection(notes: string[]): string {
85
+ const lines: string[] = [];
86
+ lines.push('Notes');
87
+ lines.push(SECTION_DIVIDER);
88
+ for (const note of notes) {
89
+ lines.push(`- ${note}`);
90
+ }
91
+ return lines.join('\n');
92
+ }
93
+
76
94
  /**
77
95
  * Format the balance check section
78
96
  */
@@ -81,18 +99,18 @@ function formatBalanceSection(
81
99
  summary: ReconciliationAnalysis['summary'],
82
100
  ): string {
83
101
  const lines: string[] = [];
84
- lines.push('BALANCE CHECK');
85
- lines.push('═'.repeat(60));
102
+ lines.push('Balance Check');
103
+ lines.push(SECTION_DIVIDER);
86
104
 
87
105
  // Current balances
88
- lines.push(`✓ YNAB Cleared Balance: ${summary.current_cleared_balance.value_display}`);
89
- lines.push(`✓ Statement Balance: ${summary.target_statement_balance.value_display}`);
106
+ lines.push(`- YNAB Cleared Balance: ${summary.current_cleared_balance.value_display}`);
107
+ lines.push(`- Statement Balance: ${summary.target_statement_balance.value_display}`);
90
108
  lines.push('');
91
109
 
92
110
  // Discrepancy status
93
111
  const discrepancyMilli = balanceInfo.discrepancy.value_milliunits;
94
112
  if (discrepancyMilli === 0) {
95
- lines.push('✅ BALANCES MATCH PERFECTLY');
113
+ lines.push('Balances match perfectly.');
96
114
  } else {
97
115
  const direction = discrepancyMilli > 0 ? 'ynab_higher' : 'bank_higher';
98
116
  const directionLabel =
@@ -100,8 +118,8 @@ function formatBalanceSection(
100
118
  ? 'YNAB shows MORE than statement'
101
119
  : 'Statement shows MORE than YNAB';
102
120
 
103
- lines.push(`❌ DISCREPANCY: ${balanceInfo.discrepancy.value_display}`);
104
- lines.push(` Direction: ${directionLabel}`);
121
+ lines.push(`Discrepancy: ${balanceInfo.discrepancy.value_display}`);
122
+ lines.push(`Direction: ${directionLabel}`);
105
123
  }
106
124
 
107
125
  return lines.join('\n');
@@ -115,21 +133,21 @@ function formatTransactionAnalysisSection(
115
133
  options: ReportFormatterOptions,
116
134
  ): string {
117
135
  const lines: string[] = [];
118
- lines.push('TRANSACTION ANALYSIS');
119
- lines.push('═'.repeat(60));
136
+ lines.push('Transaction Analysis');
137
+ lines.push(SECTION_DIVIDER);
120
138
 
121
139
  const summary = analysis.summary;
122
140
  lines.push(
123
- `✓ Automatically matched: ${summary.auto_matched} of ${summary.bank_transactions_count} transactions`,
141
+ `- Automatically matched: ${summary.auto_matched} of ${summary.bank_transactions_count} transactions`,
124
142
  );
125
- lines.push(`✓ Suggested matches: ${summary.suggested_matches}`);
126
- lines.push(`✓ Unmatched bank: ${summary.unmatched_bank}`);
127
- lines.push(`✓ Unmatched YNAB: ${summary.unmatched_ynab}`);
143
+ lines.push(`- Suggested matches: ${summary.suggested_matches}`);
144
+ lines.push(`- Unmatched bank: ${summary.unmatched_bank}`);
145
+ lines.push(`- Unmatched YNAB: ${summary.unmatched_ynab}`);
128
146
 
129
147
  // Show unmatched bank transactions (if any)
130
148
  if (analysis.unmatched_bank.length > 0) {
131
149
  lines.push('');
132
- lines.push('❌ UNMATCHED BANK TRANSACTIONS:');
150
+ lines.push('Unmatched bank transactions:');
133
151
  const maxToShow = options.maxUnmatchedToShow ?? 5;
134
152
  const toShow = analysis.unmatched_bank.slice(0, maxToShow);
135
153
 
@@ -145,7 +163,7 @@ function formatTransactionAnalysisSection(
145
163
  // Show suggested matches (if any)
146
164
  if (analysis.suggested_matches.length > 0) {
147
165
  lines.push('');
148
- lines.push('💡 SUGGESTED MATCHES:');
166
+ lines.push('Suggested matches:');
149
167
  const maxToShow = options.maxUnmatchedToShow ?? 3;
150
168
  const toShow = analysis.suggested_matches.slice(0, maxToShow);
151
169
 
@@ -194,8 +212,8 @@ function formatAmount(amountMilli: number): string {
194
212
  */
195
213
  function formatInsightsSection(insights: ReconciliationInsight[], maxToShow: number = 3): string {
196
214
  const lines: string[] = [];
197
- lines.push('KEY INSIGHTS');
198
- lines.push('═'.repeat(60));
215
+ lines.push('Key Insights');
216
+ lines.push(SECTION_DIVIDER);
199
217
 
200
218
  const toShow = insights.slice(0, maxToShow);
201
219
  for (const insight of toShow) {
@@ -222,18 +240,18 @@ function formatInsightsSection(insights: ReconciliationInsight[], maxToShow: num
222
240
  }
223
241
 
224
242
  /**
225
- * Get emoji icon for severity level
243
+ * Get text icon for severity level
226
244
  */
227
245
  function getSeverityIcon(severity: string): string {
228
246
  switch (severity) {
229
247
  case 'critical':
230
- return '🚨';
248
+ return '[CRITICAL]';
231
249
  case 'warning':
232
- return 'âš ī¸';
250
+ return '[WARN]';
233
251
  case 'info':
234
- return 'â„šī¸';
252
+ return '[INFO]';
235
253
  default:
236
- return 'â€ĸ';
254
+ return '[NOTE]';
237
255
  }
238
256
  }
239
257
 
@@ -260,13 +278,13 @@ function formatEvidenceSummary(evidence: Record<string, unknown>): string | null
260
278
  */
261
279
  function formatExecutionSection(execution: LegacyReconciliationResult): string {
262
280
  const lines: string[] = [];
263
- lines.push('EXECUTION SUMMARY');
264
- lines.push('═'.repeat(60));
281
+ lines.push('Execution Summary');
282
+ lines.push(SECTION_DIVIDER);
265
283
 
266
284
  const summary = execution.summary;
267
- lines.push(`â€ĸ Transactions created: ${summary.transactions_created}`);
268
- lines.push(`â€ĸ Transactions updated: ${summary.transactions_updated}`);
269
- lines.push(`â€ĸ Date adjustments: ${summary.dates_adjusted}`);
285
+ lines.push(`Transactions created: ${summary.transactions_created}`);
286
+ lines.push(`Transactions updated: ${summary.transactions_updated}`);
287
+ lines.push(`Date adjustments: ${summary.dates_adjusted}`);
270
288
 
271
289
  // Show top recommendations if any
272
290
  if (execution.recommendations.length > 0) {
@@ -275,7 +293,7 @@ function formatExecutionSection(execution: LegacyReconciliationResult): string {
275
293
  const maxRecs = 3;
276
294
  const toShow = execution.recommendations.slice(0, maxRecs);
277
295
  for (const rec of toShow) {
278
- lines.push(` â€ĸ ${rec}`);
296
+ lines.push(` - ${rec}`);
279
297
  }
280
298
  if (execution.recommendations.length > maxRecs) {
281
299
  lines.push(` ... and ${execution.recommendations.length - maxRecs} more`);
@@ -284,9 +302,9 @@ function formatExecutionSection(execution: LegacyReconciliationResult): string {
284
302
 
285
303
  lines.push('');
286
304
  if (summary.dry_run) {
287
- lines.push('âš ī¸ Dry run only — no YNAB changes were applied.');
305
+ lines.push('NOTE: Dry run only - no YNAB changes were applied.');
288
306
  } else {
289
- lines.push('✅ Changes applied to YNAB. Review structured output for action details.');
307
+ lines.push('Changes applied to YNAB. Review structured output for action details.');
290
308
  }
291
309
 
292
310
  return lines.join('\n');
@@ -300,8 +318,8 @@ function formatRecommendationsSection(
300
318
  execution?: LegacyReconciliationResult,
301
319
  ): string {
302
320
  const lines: string[] = [];
303
- lines.push('RECOMMENDED ACTIONS');
304
- lines.push('═'.repeat(60));
321
+ lines.push('Recommended Actions');
322
+ lines.push(SECTION_DIVIDER);
305
323
 
306
324
  // If we have execution results, recommendations are already shown
307
325
  if (execution && !execution.summary.dry_run) {
@@ -312,11 +330,11 @@ function formatRecommendationsSection(
312
330
  // Show next steps from analysis
313
331
  if (analysis.next_steps.length > 0) {
314
332
  for (const step of analysis.next_steps) {
315
- lines.push(`â€ĸ ${step}`);
333
+ lines.push(`- ${step}`);
316
334
  }
317
335
  } else {
318
- lines.push('â€ĸ No specific actions recommended.');
319
- lines.push('â€ĸ Review the structured output for detailed match information.');
336
+ lines.push('No specific actions recommended.');
337
+ lines.push('Review the structured output for detailed match information.');
320
338
  }
321
339
 
322
340
  return lines.join('\n');