list_journals
Access and display all available journals from the command-line journal management system for efficient organization and retrieval of entries.
Instructions
List all available journals
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/journalHandlers.ts:12-58 (handler)The core handler function that lists available journals by running `jrnl --list`, parsing the output, and returning structured JournalInfo array with current journal detection.export async function listJournals( executor: JrnlExecutor, ): Promise<{ journals: JournalInfo[]; currentJournal?: string }> { const command = buildListJournalsCommand(); const result = await executor.execute(command); try { // Parse jrnl --list output // Format can be: // Journals defined in config (/path/to/config) // * default -> /path/to/default.txt // work -> /path/to/work.txt const lines = result.trim().split("\n"); const journals: JournalInfo[] = []; for (const line of lines) { // Skip header lines if (line.includes("Journals defined in config") || line.trim() === "") { continue; } const match = line.match(/^(\s*\*?\s*)(\w+)\s*->\s*(.+)$/); if (match) { const isDefault = line.trim().startsWith("*"); const name = match[2].trim(); const path = match[3].trim(); journals.push({ name, path, isDefault, }); if (isDefault && !currentJournal) { currentJournal = name; } } } return { journals, currentJournal, }; } catch (error) { throw new Error(`Failed to parse journal list: ${error}`); } }
- src/handlers/journalHandlers.ts:4-8 (schema)Type definition for the output structure of listJournals tool.export interface JournalInfo { name: string; path: string; isDefault: boolean; }
- src/index.ts:120-127 (registration)Tool registration in ListToolsRequestHandler, defining name, description, and empty input schema.{ name: "list_journals", description: "List all available journals", inputSchema: { type: "object", properties: {}, }, },
- src/index.ts:219-227 (registration)Dispatch handler in CallToolRequestSchema that invokes the listJournals function.case "list_journals": return { content: [ { type: "text", text: JSON.stringify(await listJournals(executor), null, 2), }, ], };
- src/utils/commandBuilder.ts:84-86 (helper)Helper function that builds the command arguments for listing journals (`jrnl --list`).export function buildListJournalsCommand(): string[] { return ["--list"]; }