Compare commits
3 Commits
addSeconda
...
sec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31be44a3b9 | ||
|
|
4192bb9dee | ||
|
|
5c29eec50b |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,4 +9,4 @@ accounts.json
|
||||
|
||||
# Runtime output
|
||||
summary.json
|
||||
token-secondary.json
|
||||
summary-secondary.json
|
||||
|
||||
34
src/index.ts
34
src/index.ts
@@ -54,11 +54,13 @@ function getSummaryPath(account: string): string {
|
||||
}
|
||||
|
||||
const VALID_ACCOUNTS = ["work", "secondary"] as const;
|
||||
const accounts = loadAccounts();
|
||||
const accountDescription = VALID_ACCOUNTS
|
||||
.map((key) => `"${key}" (${accounts[key]?.label ?? key})`)
|
||||
.join(" or ");
|
||||
const accountSchema = z
|
||||
.enum(VALID_ACCOUNTS)
|
||||
.describe(
|
||||
"Which email account to use: \"work\" (sj@sjdev.co) or \"secondary\" (ken.jannette@gmail.com)"
|
||||
);
|
||||
.describe(`Which email account to use: ${accountDescription}`);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Load classification prompt
|
||||
@@ -169,7 +171,7 @@ server.registerPrompt(
|
||||
"review_emails",
|
||||
{
|
||||
description:
|
||||
"Review WORK inbox (sj@sjdev.co): classify job application emails (A/B/C/D), delete A+C, summarize B+D.",
|
||||
`Review WORK inbox (${accounts.work?.label ?? "work"}): classify job application emails (A/B/C/D), delete A+C, summarize B+D.`,
|
||||
},
|
||||
() => {
|
||||
const instructions = loadClassificationPrompt();
|
||||
@@ -197,7 +199,7 @@ server.registerPrompt(
|
||||
"review_secondary_emails",
|
||||
{
|
||||
description:
|
||||
"Review SECONDARY inbox (ken.jannette@gmail.com): classify job application emails (A/B/C/D), delete A+C, summarize B+D.",
|
||||
`Review SECONDARY inbox (${accounts.secondary?.label ?? "secondary"}): classify job application emails (A/B/C/D), delete A+C, summarize B+D.`,
|
||||
},
|
||||
() => {
|
||||
const instructions = loadClassificationPrompt();
|
||||
@@ -423,15 +425,30 @@ server.registerTool(
|
||||
summary = JSON.parse(fs.readFileSync(summaryPath, "utf-8"));
|
||||
}
|
||||
|
||||
const now = new Date().toISOString();
|
||||
const now = new Date();
|
||||
const nowIso = now.toISOString();
|
||||
const newEntries: SummaryEntry[] = entries.map((e) => ({
|
||||
...e,
|
||||
addedAt: now,
|
||||
addedAt: nowIso,
|
||||
}));
|
||||
|
||||
summary.push(...newEntries);
|
||||
|
||||
// Purge entries older than 30 days
|
||||
const RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
||||
const cutoff = now.getTime() - RETENTION_MS;
|
||||
const beforePurge = summary.length;
|
||||
summary = summary.filter(
|
||||
(entry) => new Date(entry.addedAt).getTime() >= cutoff
|
||||
);
|
||||
const purged = beforePurge - summary.length;
|
||||
|
||||
fs.writeFileSync(summaryPath, JSON.stringify(summary, null, 2));
|
||||
|
||||
const purgeNote = purged > 0
|
||||
? `\nPurged ${purged} entry/entries older than 30 days.`
|
||||
: "";
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
@@ -439,7 +456,8 @@ server.registerTool(
|
||||
text:
|
||||
`Appended ${newEntries.length} entry/entries to summary.\n` +
|
||||
`Total entries in summary: ${summary.length}\n` +
|
||||
`Summary file: ${summaryPath}`,
|
||||
`Summary file: ${summaryPath}` +
|
||||
purgeNote,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user