create_weekly_note
Generate a weekly note for a specific date in your Obsidian vault, using templates and custom variables to organize your schedule and tasks.
Instructions
Create a weekly note for a specific date
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Date in the week (YYYY-MM-DD), defaults to this week | |
| variables | No | Additional template variables | |
| vault | Yes | Vault name |
Implementation Reference
- Core implementation of periodic note creation (used for weekly notes by passing 'weekly' type). Handles path generation, template rendering or default content, directory creation, and file writing.async createPeriodicNote( vaultPath: string, type: PeriodicNoteType, date?: Date, variables?: Record<string, any> ): Promise<VaultOperationResult<string>> { try { const noteDate = date || new Date(); const config = this.settings[type]; if (!config.enabled) { return { success: false, error: `${type} notes are not enabled` }; } // Generate note path const notePath = this.getPeriodicNotePath(type, noteDate); const fullPath = path.join(vaultPath, notePath); // Check if note already exists try { await fs.access(fullPath); return { success: true, data: notePath }; // Already exists } catch { // Note doesn't exist, continue to create } // Ensure directory exists await fs.mkdir(path.dirname(fullPath), { recursive: true }); let content: string; // Use template if specified if (config.templatePath) { const renderResult = await this.templateService.renderTemplate( vaultPath, config.templatePath, { targetPath: notePath, variables: { ...this.getPeriodicNoteVariables(type, noteDate), ...variables, }, } ); if (!renderResult.success || !renderResult.data) { return { success: false, error: renderResult.error }; } content = renderResult.data.content; } else { // Generate default content content = this.generateDefaultContent(type, noteDate); } // Write file await fs.writeFile(fullPath, content, 'utf-8'); return { success: true, data: notePath }; } catch (error) { return { success: false, error: `Failed to create ${type} note: ${error instanceof Error ? error.message : String(error)}` }; } }
- src/index.ts:893-910 (handler)Tool dispatch handler case that extracts parameters and calls PeriodicNotesService.createPeriodicNote with type 'weekly'.case 'create_weekly_note': { const connector = this.connectors.get(args?.vault as string); if (!connector || !connector.vaultPath) { throw new Error(`Vault "${args?.vault}" not found or not a local vault`); } const date = args?.date ? new Date(args.date as string) : undefined; const result = await this.periodicNotesService.createPeriodicNote( connector.vaultPath, 'weekly', date, args?.variables as Record<string, any> | undefined ); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/index.ts:407-419 (schema)Schema definition and registration of the create_weekly_note tool in the ListTools response.{ name: 'create_weekly_note', description: 'Create a weekly note for a specific date', inputSchema: { type: 'object', properties: { vault: { type: 'string', description: 'Vault name' }, date: { type: 'string', description: 'Date in the week (YYYY-MM-DD), defaults to this week' }, variables: { type: 'object', description: 'Additional template variables' }, }, required: ['vault'], }, },
- Helper function getDateRange specific logic for weekly notes, calculating Monday to Sunday range.case 'weekly': // Start on Monday const day = start.getDay(); const diff = start.getDate() - day + (day === 0 ? -6 : 1); start.setDate(diff); start.setHours(0, 0, 0, 0); end.setDate(start.getDate() + 6); end.setHours(23, 59, 59, 999); break;
- Weekly-specific default content generation in generateDefaultContent helper.case 'weekly': content += `## Week ${vars.week} Overview\n\n`; content += `**Period:** ${vars.startDate} to ${vars.endDate}\n\n`; content += `## Goals\n\n- \n\n## Reflection\n\n`; break;