UNPKG

jrnl-mcp

Version:

Model Context Protocol server for jrnl CLI journal application

59 lines (58 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildSearchCommand = buildSearchCommand; exports.buildTagCommand = buildTagCommand; exports.buildStatsCommand = buildStatsCommand; exports.buildListJournalsCommand = buildListJournalsCommand; const dateUtils_1 = require("./dateUtils"); function buildSearchCommand(filters, journal) { const args = []; if (journal) { args.push(journal); } if (filters.from) { args.push(`-from`, (0, dateUtils_1.formatDateForJrnl)(filters.from) || filters.from); } if (filters.to) { args.push(`-to`, (0, dateUtils_1.formatDateForJrnl)(filters.to) || filters.to); } if (filters.tags && filters.tags.length > 0) { // For AND logic: @tag1 @tag2 // For OR logic: @tag1 or @tag2 // Currently implementing AND logic filters.tags.forEach((tag) => { args.push(tag.startsWith("@") ? tag : `@${tag}`); }); } if (filters.contains) { args.push(`-contains`, filters.contains); } if (filters.limit) { args.push(`-n`, filters.limit.toString()); } if (filters.starred) { args.push(`-starred`); } args.push("--export", "json"); return args; } function buildTagCommand(journal) { const args = []; if (journal) { args.push(journal); } args.push("--tags"); return args; } function buildStatsCommand(journal, _timeGrouping) { const args = []; if (journal) { args.push(journal); } // For statistics, we'll export all entries and calculate stats args.push("--export", "json"); return args; } function buildListJournalsCommand() { return ["--list"]; }