perks-reminder 0.1.0 → 0.1.1
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/README.md +6 -3
- package/dist/{chunk-BDYPEDZG.js → chunk-3G7AQDNB.js} +131 -16
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,9 +47,12 @@ Connect via Remote Streamable HTTP MCP with OAuth 2.1 PKCE login:
|
|
|
47
47
|
```bash
|
|
48
48
|
npx -y perks-reminder --version
|
|
49
49
|
npx -y perks-reminder mcp
|
|
50
|
-
npx -y perks-reminder
|
|
51
|
-
npx -y perks-reminder
|
|
52
|
-
npx -y perks-reminder
|
|
50
|
+
npx -y perks-reminder status
|
|
51
|
+
npx -y perks-reminder auth login
|
|
52
|
+
npx -y perks-reminder pull
|
|
53
|
+
npx -y perks-reminder push
|
|
54
|
+
npx -y perks-reminder ingest payload.json --json
|
|
55
|
+
npx -y perks-reminder ics --horizon 30
|
|
53
56
|
```
|
|
54
57
|
|
|
55
58
|
## 14 MCP Tools
|
|
@@ -6252,25 +6252,29 @@ function extractDigitsHintFromText(text) {
|
|
|
6252
6252
|
}
|
|
6253
6253
|
return null;
|
|
6254
6254
|
}
|
|
6255
|
-
function
|
|
6256
|
-
const headerSample = text.slice(0, 5e3);
|
|
6257
|
-
const combinedSource = `${fileName ?? ""}
|
|
6258
|
-
${headerSample}`;
|
|
6259
|
-
const detectedCardDigits = extractDigitsHintFromText(headerSample) ?? (fileName ? extractDigitsHintFromText(fileName) : null);
|
|
6260
|
-
let detectedIssuer = null;
|
|
6255
|
+
function detectIssuerFromText(text) {
|
|
6261
6256
|
for (const [pattern, issuer] of ISSUER_PATTERNS) {
|
|
6262
|
-
if (pattern.test(
|
|
6263
|
-
|
|
6264
|
-
break;
|
|
6257
|
+
if (pattern.test(text)) {
|
|
6258
|
+
return issuer;
|
|
6265
6259
|
}
|
|
6266
6260
|
}
|
|
6267
|
-
|
|
6261
|
+
return null;
|
|
6262
|
+
}
|
|
6263
|
+
function detectCardProductFromText(text) {
|
|
6268
6264
|
for (const [pattern, product] of CARD_PRODUCT_PATTERNS) {
|
|
6269
|
-
if (pattern.test(
|
|
6270
|
-
|
|
6271
|
-
break;
|
|
6265
|
+
if (pattern.test(text)) {
|
|
6266
|
+
return product;
|
|
6272
6267
|
}
|
|
6273
6268
|
}
|
|
6269
|
+
return null;
|
|
6270
|
+
}
|
|
6271
|
+
function detectHeaderMetadata(text, fileName, referenceDate) {
|
|
6272
|
+
const headerSample = text.slice(0, 5e3);
|
|
6273
|
+
const combinedSource = `${fileName ?? ""}
|
|
6274
|
+
${headerSample}`;
|
|
6275
|
+
const detectedCardDigits = extractDigitsHintFromText(headerSample) ?? (fileName ? extractDigitsHintFromText(fileName) : null);
|
|
6276
|
+
const detectedIssuer = detectIssuerFromText(combinedSource);
|
|
6277
|
+
const detectedCardProduct = detectCardProductFromText(combinedSource);
|
|
6274
6278
|
let statementPeriodStart = null;
|
|
6275
6279
|
let statementPeriodEnd = null;
|
|
6276
6280
|
const periodRangeMatch = headerSample.match(/(\d{1,2}[/-]\d{1,2}[/-]\d{2,4}|\d{4}-\d{2}-\d{2})\s*(?:[-–—]|to|through|thru)\s*(\d{1,2}[/-]\d{1,2}[/-]\d{2,4}|\d{4}-\d{2}-\d{2})/i);
|
|
@@ -6527,6 +6531,95 @@ function parseDelimitedStatement(lines, delimiter, headerMeta, referenceDate) {
|
|
|
6527
6531
|
}
|
|
6528
6532
|
return { rowsScanned: dataRows.length, rawCredits };
|
|
6529
6533
|
}
|
|
6534
|
+
function isLikelyHeaderlessAmountCell(raw) {
|
|
6535
|
+
const cleaned = raw.trim().replace(/^["']|["']$/g, "").trim();
|
|
6536
|
+
if (!cleaned)
|
|
6537
|
+
return false;
|
|
6538
|
+
if (/^\d{4,5}$/.test(cleaned))
|
|
6539
|
+
return false;
|
|
6540
|
+
return /[$+\-()]|\bCR\b|\.\d{2}$/i.test(cleaned);
|
|
6541
|
+
}
|
|
6542
|
+
function tryParseHeaderlessDelimitedLine(line, activeSectionDigits, headerMeta, referenceDate) {
|
|
6543
|
+
const delimiter = line.includes(" ") ? " " : line.includes(",") ? "," : null;
|
|
6544
|
+
if (!delimiter)
|
|
6545
|
+
return null;
|
|
6546
|
+
const cols = splitDelimitedRow(line, delimiter);
|
|
6547
|
+
if (cols.length < 3)
|
|
6548
|
+
return null;
|
|
6549
|
+
let dateIdx = -1;
|
|
6550
|
+
let postedDate = null;
|
|
6551
|
+
for (let idx = 0; idx < cols.length; idx++) {
|
|
6552
|
+
const parsed = parseFlexibleStatementDate(cols[idx], {
|
|
6553
|
+
closingDateIso: headerMeta.statementPeriodEnd,
|
|
6554
|
+
referenceDate
|
|
6555
|
+
});
|
|
6556
|
+
if (parsed) {
|
|
6557
|
+
dateIdx = idx;
|
|
6558
|
+
postedDate = parsed;
|
|
6559
|
+
break;
|
|
6560
|
+
}
|
|
6561
|
+
}
|
|
6562
|
+
if (dateIdx === -1 || !postedDate)
|
|
6563
|
+
return null;
|
|
6564
|
+
let amountIdx = -1;
|
|
6565
|
+
let parsedAmt = null;
|
|
6566
|
+
for (let idx = cols.length - 1; idx >= 0; idx--) {
|
|
6567
|
+
if (idx === dateIdx)
|
|
6568
|
+
continue;
|
|
6569
|
+
if (!isLikelyHeaderlessAmountCell(cols[idx]))
|
|
6570
|
+
continue;
|
|
6571
|
+
const candidate = parseCurrencyToken(cols[idx]);
|
|
6572
|
+
if (candidate) {
|
|
6573
|
+
amountIdx = idx;
|
|
6574
|
+
parsedAmt = candidate;
|
|
6575
|
+
break;
|
|
6576
|
+
}
|
|
6577
|
+
}
|
|
6578
|
+
if (amountIdx === -1 || !parsedAmt)
|
|
6579
|
+
return null;
|
|
6580
|
+
let rowDigits = null;
|
|
6581
|
+
const descCandidates = [];
|
|
6582
|
+
for (let idx = 0; idx < cols.length; idx++) {
|
|
6583
|
+
if (idx === dateIdx || idx === amountIdx)
|
|
6584
|
+
continue;
|
|
6585
|
+
const cell = cols[idx].trim();
|
|
6586
|
+
if (!cell)
|
|
6587
|
+
continue;
|
|
6588
|
+
if (parseFlexibleStatementDate(cell, {
|
|
6589
|
+
closingDateIso: headerMeta.statementPeriodEnd,
|
|
6590
|
+
referenceDate
|
|
6591
|
+
})) {
|
|
6592
|
+
continue;
|
|
6593
|
+
}
|
|
6594
|
+
const bareDigits = cell.match(/^(?:[-•*xX]+\s*)?(\d{4,5})$/);
|
|
6595
|
+
if (bareDigits) {
|
|
6596
|
+
rowDigits = rowDigits ?? bareDigits[1];
|
|
6597
|
+
continue;
|
|
6598
|
+
}
|
|
6599
|
+
const hintDigits = extractDigitsHintFromText(cell);
|
|
6600
|
+
if (hintDigits && !hasExplicitCreditSignal(cell) && cell.length <= 40) {
|
|
6601
|
+
rowDigits = rowDigits ?? hintDigits;
|
|
6602
|
+
continue;
|
|
6603
|
+
}
|
|
6604
|
+
descCandidates.push(cell);
|
|
6605
|
+
}
|
|
6606
|
+
const description = descCandidates.sort((a, b) => b.length - a.length)[0]?.replace(/\s+/g, " ").trim();
|
|
6607
|
+
if (!description || isBillPaymentOrNoise(description))
|
|
6608
|
+
return null;
|
|
6609
|
+
const isSignedCredit = parsedAmt.explicitSign === "negative" || parsedAmt.explicitSign === "parens" || parsedAmt.explicitSign === "cr" || parsedAmt.explicitSign === "positive" && hasExplicitCreditSignal(description) || parsedAmt.explicitSign === "none" && hasExplicitCreditSignal(description);
|
|
6610
|
+
if (!isSignedCredit)
|
|
6611
|
+
return null;
|
|
6612
|
+
const finalDigits = rowDigits ?? extractDigitsHintFromText(description) ?? activeSectionDigits;
|
|
6613
|
+
return {
|
|
6614
|
+
postedDate,
|
|
6615
|
+
description,
|
|
6616
|
+
amount: Math.round(parsedAmt.magnitude * 100) / 100,
|
|
6617
|
+
rawLine: line,
|
|
6618
|
+
cardDigitsHint: finalDigits,
|
|
6619
|
+
cardMemberHint: null,
|
|
6620
|
+
cardProductHint: headerMeta.detectedCardProduct
|
|
6621
|
+
};
|
|
6622
|
+
}
|
|
6530
6623
|
function parseFreeformStatementText(lines, headerMeta, referenceDate) {
|
|
6531
6624
|
const rawCredits = [];
|
|
6532
6625
|
const trimmedLines = lines.map((l) => l.trim()).filter(Boolean);
|
|
@@ -6537,6 +6630,12 @@ function parseFreeformStatementText(lines, headerMeta, referenceDate) {
|
|
|
6537
6630
|
let i = 0;
|
|
6538
6631
|
while (i < trimmedLines.length) {
|
|
6539
6632
|
const line = trimmedLines[i];
|
|
6633
|
+
const headerlessRow = tryParseHeaderlessDelimitedLine(line, activeSectionDigits, headerMeta, referenceDate);
|
|
6634
|
+
if (headerlessRow) {
|
|
6635
|
+
rawCredits.push(headerlessRow);
|
|
6636
|
+
i++;
|
|
6637
|
+
continue;
|
|
6638
|
+
}
|
|
6540
6639
|
const sectionDigits = extractDigitsHintFromText(line);
|
|
6541
6640
|
if (sectionDigits && !TRAILING_AMOUNT_RE.test(line)) {
|
|
6542
6641
|
activeSectionDigits = sectionDigits;
|
|
@@ -6648,11 +6747,13 @@ function parseStatementContent(input) {
|
|
|
6648
6747
|
})
|
|
6649
6748
|
};
|
|
6650
6749
|
});
|
|
6750
|
+
const distinctRowDigits = new Set(creditLines.map((line) => line.cardDigitsHint).filter((digits) => Boolean(digits)));
|
|
6651
6751
|
return {
|
|
6652
6752
|
metadata: {
|
|
6653
6753
|
sourceFormat: effectiveFormat,
|
|
6654
6754
|
fileName,
|
|
6655
6755
|
...headerMeta,
|
|
6756
|
+
...distinctRowDigits.size > 1 ? { detectedCardDigits: null } : {},
|
|
6656
6757
|
totalRowsScanned: rowsScanned,
|
|
6657
6758
|
creditLinesDetected: creditLines.length
|
|
6658
6759
|
},
|
|
@@ -6837,18 +6938,26 @@ function scoreLineAgainstStatus(line, status, metadata, referenceDate) {
|
|
|
6837
6938
|
score += 38;
|
|
6838
6939
|
reasons.push(`card ending ${card?.lastFourDigits}`);
|
|
6839
6940
|
}
|
|
6840
|
-
const effectiveProductHint = line.cardProductHint ?? metadata.detectedCardProduct;
|
|
6941
|
+
const effectiveProductHint = line.cardProductHint ?? detectCardProductFromText(line.description) ?? metadata.detectedCardProduct;
|
|
6841
6942
|
if (effectiveProductHint && card) {
|
|
6842
6943
|
if (card.name.toLowerCase() === effectiveProductHint.toLowerCase()) {
|
|
6843
6944
|
score += 25;
|
|
6844
6945
|
reasons.push(card.name);
|
|
6845
6946
|
}
|
|
6846
6947
|
}
|
|
6948
|
+
const rawLineIssuer = detectIssuerFromText(line.description);
|
|
6949
|
+
const lineIssuer = rawLineIssuer === "Citi" && /\bciti\s+bike\b/i.test(line.description) ? null : rawLineIssuer;
|
|
6847
6950
|
const familyIssuer = matchedFamily?.issuerHint ?? null;
|
|
6848
6951
|
const headerIssuer = metadata.detectedIssuer ?? null;
|
|
6849
6952
|
if (card) {
|
|
6850
6953
|
const cardIssuerLower = card.issuer.toLowerCase();
|
|
6851
|
-
if (
|
|
6954
|
+
if (lineIssuer) {
|
|
6955
|
+
if (cardIssuerLower === lineIssuer.toLowerCase()) {
|
|
6956
|
+
score += 18;
|
|
6957
|
+
} else {
|
|
6958
|
+
score -= 18;
|
|
6959
|
+
}
|
|
6960
|
+
} else if (familyIssuer && cardIssuerLower === familyIssuer.toLowerCase()) {
|
|
6852
6961
|
score += 12;
|
|
6853
6962
|
} else if (headerIssuer && cardIssuerLower === headerIssuer.toLowerCase()) {
|
|
6854
6963
|
score += 12;
|
|
@@ -6859,6 +6968,12 @@ function scoreLineAgainstStatus(line, status, metadata, referenceDate) {
|
|
|
6859
6968
|
if (/\bplatinum\b/i.test(line.description) && card && !/\bplatinum\b/i.test(card.name)) {
|
|
6860
6969
|
score -= 18;
|
|
6861
6970
|
}
|
|
6971
|
+
if (/\bsapphire\b/i.test(line.description) && card) {
|
|
6972
|
+
score += /\bsapphire\b/i.test(card.name) ? 14 : -14;
|
|
6973
|
+
}
|
|
6974
|
+
if (/\bventure\s*x\b/i.test(line.description) && card) {
|
|
6975
|
+
score += /\bventure\s*x\b/i.test(card.name) ? 14 : -14;
|
|
6976
|
+
}
|
|
6862
6977
|
if (line.cardMemberHint && card) {
|
|
6863
6978
|
const memberTokens = line.cardMemberHint.toLowerCase().split(/\s+/).filter((t) => t.length >= 2);
|
|
6864
6979
|
const cardOwnerText = `${resolveCardPlayerLabel(card) ?? ""} ${card.nickname ?? ""}`.toLowerCase();
|
|
@@ -10602,7 +10717,7 @@ async function importLedgerV2(repo, rawDocument, mode = "merge", audit) {
|
|
|
10602
10717
|
|
|
10603
10718
|
// ../core/dist/mcp/server-info.js
|
|
10604
10719
|
var PERKS_REMINDER_ATTRIBUTION = "Based on Perks Reminder by lifan-builds (https://github.com/lifan-builds/perks-reminder)";
|
|
10605
|
-
var PERKS_REMINDER_VERSION = "0.1.
|
|
10720
|
+
var PERKS_REMINDER_VERSION = "0.1.1";
|
|
10606
10721
|
var PERKS_REMINDER_SERVER_INFO = {
|
|
10607
10722
|
name: "perks-reminder",
|
|
10608
10723
|
title: "Perks Reminder",
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "perks-reminder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Perks Reminder Local — headless stdio MCP server and CLI for credit card perks, statement credits, and annual-fee ROI.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"zod": "^3.25.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@perks-reminder/core": "^0.1.
|
|
59
|
+
"@perks-reminder/core": "^0.1.1"
|
|
60
60
|
}
|
|
61
61
|
}
|