@noteplanco/noteplan-mcp 1.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.
Files changed (155) hide show
  1. package/README.md +257 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +8 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/noteplan/embeddings.d.ts +170 -0
  7. package/dist/noteplan/embeddings.d.ts.map +1 -0
  8. package/dist/noteplan/embeddings.js +684 -0
  9. package/dist/noteplan/embeddings.js.map +1 -0
  10. package/dist/noteplan/file-reader.d.ts +77 -0
  11. package/dist/noteplan/file-reader.d.ts.map +1 -0
  12. package/dist/noteplan/file-reader.js +488 -0
  13. package/dist/noteplan/file-reader.js.map +1 -0
  14. package/dist/noteplan/file-writer.d.ts +108 -0
  15. package/dist/noteplan/file-writer.d.ts.map +1 -0
  16. package/dist/noteplan/file-writer.js +621 -0
  17. package/dist/noteplan/file-writer.js.map +1 -0
  18. package/dist/noteplan/filter-store.d.ts +28 -0
  19. package/dist/noteplan/filter-store.d.ts.map +1 -0
  20. package/dist/noteplan/filter-store.js +180 -0
  21. package/dist/noteplan/filter-store.js.map +1 -0
  22. package/dist/noteplan/frontmatter-parser.d.ts +45 -0
  23. package/dist/noteplan/frontmatter-parser.d.ts.map +1 -0
  24. package/dist/noteplan/frontmatter-parser.js +259 -0
  25. package/dist/noteplan/frontmatter-parser.js.map +1 -0
  26. package/dist/noteplan/fuzzy-search.d.ts +7 -0
  27. package/dist/noteplan/fuzzy-search.d.ts.map +1 -0
  28. package/dist/noteplan/fuzzy-search.js +66 -0
  29. package/dist/noteplan/fuzzy-search.js.map +1 -0
  30. package/dist/noteplan/markdown-parser.d.ts +87 -0
  31. package/dist/noteplan/markdown-parser.d.ts.map +1 -0
  32. package/dist/noteplan/markdown-parser.js +519 -0
  33. package/dist/noteplan/markdown-parser.js.map +1 -0
  34. package/dist/noteplan/preferences.d.ts +44 -0
  35. package/dist/noteplan/preferences.d.ts.map +1 -0
  36. package/dist/noteplan/preferences.js +156 -0
  37. package/dist/noteplan/preferences.js.map +1 -0
  38. package/dist/noteplan/ripgrep-search.d.ts +29 -0
  39. package/dist/noteplan/ripgrep-search.d.ts.map +1 -0
  40. package/dist/noteplan/ripgrep-search.js +110 -0
  41. package/dist/noteplan/ripgrep-search.js.map +1 -0
  42. package/dist/noteplan/sqlite-reader.d.ts +77 -0
  43. package/dist/noteplan/sqlite-reader.d.ts.map +1 -0
  44. package/dist/noteplan/sqlite-reader.js +605 -0
  45. package/dist/noteplan/sqlite-reader.js.map +1 -0
  46. package/dist/noteplan/sqlite-writer.d.ts +63 -0
  47. package/dist/noteplan/sqlite-writer.d.ts.map +1 -0
  48. package/dist/noteplan/sqlite-writer.js +574 -0
  49. package/dist/noteplan/sqlite-writer.js.map +1 -0
  50. package/dist/noteplan/types.d.ts +97 -0
  51. package/dist/noteplan/types.d.ts.map +1 -0
  52. package/dist/noteplan/types.js +33 -0
  53. package/dist/noteplan/types.js.map +1 -0
  54. package/dist/noteplan/unified-store.d.ts +289 -0
  55. package/dist/noteplan/unified-store.d.ts.map +1 -0
  56. package/dist/noteplan/unified-store.js +1308 -0
  57. package/dist/noteplan/unified-store.js.map +1 -0
  58. package/dist/server.d.ts +4 -0
  59. package/dist/server.d.ts.map +1 -0
  60. package/dist/server.js +2468 -0
  61. package/dist/server.js.map +1 -0
  62. package/dist/tools/calendar.d.ts +311 -0
  63. package/dist/tools/calendar.d.ts.map +1 -0
  64. package/dist/tools/calendar.js +504 -0
  65. package/dist/tools/calendar.js.map +1 -0
  66. package/dist/tools/embeddings.d.ts +244 -0
  67. package/dist/tools/embeddings.d.ts.map +1 -0
  68. package/dist/tools/embeddings.js +226 -0
  69. package/dist/tools/embeddings.js.map +1 -0
  70. package/dist/tools/events.d.ts +176 -0
  71. package/dist/tools/events.d.ts.map +1 -0
  72. package/dist/tools/events.js +326 -0
  73. package/dist/tools/events.js.map +1 -0
  74. package/dist/tools/filters.d.ts +205 -0
  75. package/dist/tools/filters.d.ts.map +1 -0
  76. package/dist/tools/filters.js +347 -0
  77. package/dist/tools/filters.js.map +1 -0
  78. package/dist/tools/memory.d.ts +6 -0
  79. package/dist/tools/memory.d.ts.map +1 -0
  80. package/dist/tools/memory.js +161 -0
  81. package/dist/tools/memory.js.map +1 -0
  82. package/dist/tools/notes.d.ts +1221 -0
  83. package/dist/tools/notes.d.ts.map +1 -0
  84. package/dist/tools/notes.js +1868 -0
  85. package/dist/tools/notes.js.map +1 -0
  86. package/dist/tools/plugins.d.ts +140 -0
  87. package/dist/tools/plugins.d.ts.map +1 -0
  88. package/dist/tools/plugins.js +782 -0
  89. package/dist/tools/plugins.js.map +1 -0
  90. package/dist/tools/reminders.d.ts +207 -0
  91. package/dist/tools/reminders.d.ts.map +1 -0
  92. package/dist/tools/reminders.js +323 -0
  93. package/dist/tools/reminders.js.map +1 -0
  94. package/dist/tools/search.d.ts +58 -0
  95. package/dist/tools/search.d.ts.map +1 -0
  96. package/dist/tools/search.js +373 -0
  97. package/dist/tools/search.js.map +1 -0
  98. package/dist/tools/spaces.d.ts +484 -0
  99. package/dist/tools/spaces.d.ts.map +1 -0
  100. package/dist/tools/spaces.js +870 -0
  101. package/dist/tools/spaces.js.map +1 -0
  102. package/dist/tools/tasks.d.ts +313 -0
  103. package/dist/tools/tasks.d.ts.map +1 -0
  104. package/dist/tools/tasks.js +690 -0
  105. package/dist/tools/tasks.js.map +1 -0
  106. package/dist/tools/themes.d.ts +91 -0
  107. package/dist/tools/themes.d.ts.map +1 -0
  108. package/dist/tools/themes.js +294 -0
  109. package/dist/tools/themes.js.map +1 -0
  110. package/dist/tools/ui.d.ts +89 -0
  111. package/dist/tools/ui.d.ts.map +1 -0
  112. package/dist/tools/ui.js +137 -0
  113. package/dist/tools/ui.js.map +1 -0
  114. package/dist/utils/applescript.d.ts +5 -0
  115. package/dist/utils/applescript.d.ts.map +1 -0
  116. package/dist/utils/applescript.js +27 -0
  117. package/dist/utils/applescript.js.map +1 -0
  118. package/dist/utils/confirmation-tokens.d.ts +19 -0
  119. package/dist/utils/confirmation-tokens.d.ts.map +1 -0
  120. package/dist/utils/confirmation-tokens.js +58 -0
  121. package/dist/utils/confirmation-tokens.js.map +1 -0
  122. package/dist/utils/date-filters.d.ts +15 -0
  123. package/dist/utils/date-filters.d.ts.map +1 -0
  124. package/dist/utils/date-filters.js +129 -0
  125. package/dist/utils/date-filters.js.map +1 -0
  126. package/dist/utils/date-utils.d.ts +113 -0
  127. package/dist/utils/date-utils.d.ts.map +1 -0
  128. package/dist/utils/date-utils.js +341 -0
  129. package/dist/utils/date-utils.js.map +1 -0
  130. package/dist/utils/folder-matcher.d.ts +14 -0
  131. package/dist/utils/folder-matcher.d.ts.map +1 -0
  132. package/dist/utils/folder-matcher.js +191 -0
  133. package/dist/utils/folder-matcher.js.map +1 -0
  134. package/dist/utils/version.d.ts +10 -0
  135. package/dist/utils/version.d.ts.map +1 -0
  136. package/dist/utils/version.js +88 -0
  137. package/dist/utils/version.js.map +1 -0
  138. package/docs/plugin-api/Calendar.md +448 -0
  139. package/docs/plugin-api/CalendarItem.md +198 -0
  140. package/docs/plugin-api/Clipboard.md +101 -0
  141. package/docs/plugin-api/CommandBar.md +251 -0
  142. package/docs/plugin-api/DataStore.md +700 -0
  143. package/docs/plugin-api/Editor.md +982 -0
  144. package/docs/plugin-api/HTMLView.md +337 -0
  145. package/docs/plugin-api/NoteObject.md +588 -0
  146. package/docs/plugin-api/NotePlan.md +398 -0
  147. package/docs/plugin-api/ParagraphObject.md +242 -0
  148. package/docs/plugin-api/RangeObject.md +56 -0
  149. package/docs/plugin-api/getting-started.md +545 -0
  150. package/docs/plugin-api/plugin-api-condensed.md +526 -0
  151. package/docs/plugin-api/plugin.json +26 -0
  152. package/docs/plugin-api/script.js +542 -0
  153. package/package.json +60 -0
  154. package/scripts/calendar-helper +0 -0
  155. package/scripts/reminders-helper +0 -0
@@ -0,0 +1,137 @@
1
+ // AppleScript-based UI control tools for NotePlan
2
+ import { z } from 'zod';
3
+ import { escapeAppleScript, runAppleScript, APP_NAME } from '../utils/applescript.js';
4
+ // --- Schemas ---
5
+ export const openNoteSchema = z.object({
6
+ title: z.string().optional().describe('Title of the note to open'),
7
+ filename: z.string().optional().describe('Filename of the note to open'),
8
+ inNewWindow: z.boolean().optional().default(false).describe('Open in a new window'),
9
+ inSplitView: z.boolean().optional().default(false).describe('Open in split view'),
10
+ });
11
+ export const openTodaySchema = z.object({});
12
+ export const searchNotesSchema = z.object({
13
+ query: z.string().describe('Search text'),
14
+ });
15
+ export const runPluginSchema = z.object({
16
+ pluginId: z.string().describe('Plugin ID'),
17
+ command: z.string().describe('Command name'),
18
+ arguments: z.string().optional().describe('JSON arguments string'),
19
+ });
20
+ export const reloadPluginsSchema = z.object({});
21
+ export const openViewSchema = z.object({
22
+ name: z.string().describe('Name of the view to open'),
23
+ });
24
+ export const toggleSidebarSchema = z.object({});
25
+ export const closePluginWindowSchema = z.object({
26
+ windowID: z.string().optional().describe('Window ID to close (exact match)'),
27
+ title: z.string().optional().describe('Window title to close (case-insensitive match). Omit both windowID and title to close all plugin windows.'),
28
+ });
29
+ export const listPluginWindowsSchema = z.object({});
30
+ // --- Implementations ---
31
+ export function openNote(args) {
32
+ const { title, filename, inNewWindow, inSplitView } = openNoteSchema.parse(args);
33
+ if (!title && !filename) {
34
+ return { success: false, message: 'Either title or filename is required' };
35
+ }
36
+ let params = '';
37
+ if (title) {
38
+ params += ` titled "${escapeAppleScript(title)}"`;
39
+ }
40
+ if (filename) {
41
+ params += ` at path "${escapeAppleScript(filename)}"`;
42
+ }
43
+ if (inNewWindow) {
44
+ params += ' in new window true';
45
+ }
46
+ if (inSplitView) {
47
+ params += ' in split view true';
48
+ }
49
+ params += ' in background true';
50
+ const script = `tell application "${APP_NAME}" to showNote${params}`;
51
+ runAppleScript(script);
52
+ return { success: true, message: `Opened note${title ? ` "${title}"` : ` (${filename})`}` };
53
+ }
54
+ export function openToday(_args) {
55
+ const script = `tell application "${APP_NAME}" to openToday`;
56
+ runAppleScript(script);
57
+ return { success: true, message: "Opened today's note" };
58
+ }
59
+ export function searchNotes(args) {
60
+ const { query } = searchNotesSchema.parse(args);
61
+ const script = `tell application "${APP_NAME}" to searchNotes for "${escapeAppleScript(query)}" in background true`;
62
+ runAppleScript(script);
63
+ return { success: true, message: `Searching for "${query}"` };
64
+ }
65
+ export function runPlugin(args) {
66
+ const { pluginId, command, arguments: pluginArgs } = runPluginSchema.parse(args);
67
+ let params = `with id "${escapeAppleScript(pluginId)}" with command "${escapeAppleScript(command)}"`;
68
+ if (pluginArgs) {
69
+ params += ` with arguments "${escapeAppleScript(pluginArgs)}"`;
70
+ }
71
+ const script = `tell application "${APP_NAME}" to executePlugin ${params}`;
72
+ runAppleScript(script);
73
+ return { success: true, message: `Ran plugin ${pluginId} command "${command}"` };
74
+ }
75
+ export function reloadPlugins(_args) {
76
+ const script = `tell application "${APP_NAME}" to reloadPlugins`;
77
+ runAppleScript(script);
78
+ return { success: true, message: 'Plugins reloaded' };
79
+ }
80
+ export function openView(args) {
81
+ const { name } = openViewSchema.parse(args);
82
+ const script = `tell application "${APP_NAME}" to openView named "${escapeAppleScript(name)}"`;
83
+ runAppleScript(script);
84
+ return { success: true, message: `Opened view "${name}"` };
85
+ }
86
+ export function toggleSidebar(_args) {
87
+ const script = `tell application "${APP_NAME}" to toggleSidebar`;
88
+ runAppleScript(script);
89
+ return { success: true, message: 'Sidebar toggled' };
90
+ }
91
+ export function closePluginWindow(args) {
92
+ const { windowID, title } = closePluginWindowSchema.parse(args);
93
+ let params = '';
94
+ if (windowID) {
95
+ params = ` with id "${escapeAppleScript(windowID)}"`;
96
+ }
97
+ else if (title) {
98
+ params = ` titled "${escapeAppleScript(title)}"`;
99
+ }
100
+ const script = `tell application "${APP_NAME}" to closePluginWindow${params}`;
101
+ const result = runAppleScript(script);
102
+ // NotePlan currently returns "true" regardless of whether a window was closed.
103
+ // Parse the result for future-proofing in case NotePlan adds proper return values.
104
+ const closed = result !== 'false';
105
+ if (windowID) {
106
+ return { success: closed, message: closed ? `Closed plugin window "${windowID}"` : `No plugin window found with ID "${windowID}"` };
107
+ }
108
+ else if (title) {
109
+ return {
110
+ success: closed,
111
+ message: closed ? `Closed plugin window titled "${title}"` : `No plugin window found titled "${title}"`,
112
+ };
113
+ }
114
+ return { success: closed, message: closed ? 'Closed all plugin windows' : 'No plugin windows were open' };
115
+ }
116
+ export function listPluginWindows(_args) {
117
+ let raw;
118
+ try {
119
+ raw = runAppleScript(`tell application "${APP_NAME}" to listPluginWindows`, 15_000);
120
+ }
121
+ catch (e) {
122
+ return { success: false, error: `Failed to list plugin windows: ${e.message}` };
123
+ }
124
+ let windows;
125
+ try {
126
+ windows = JSON.parse(raw);
127
+ }
128
+ catch {
129
+ return { success: false, error: 'Failed to parse plugin windows list from NotePlan' };
130
+ }
131
+ return {
132
+ success: true,
133
+ count: windows.length,
134
+ windows,
135
+ };
136
+ }
137
+ //# sourceMappingURL=ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/tools/ui.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEtF,kBAAkB;AAElB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAClE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IACxE,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CA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ript(str: string): string;
4
+ export declare function runAppleScript(script: string, timeoutMs?: number): string;
5
+ //# sourceMappingURL=applescript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applescript.d.ts","sourceRoot":"","sources":["../../src/utils/applescript.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAC7C,eAAO,MAAM,QAAQ,aAAa,CAAC;AAEnC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,SAAyB,GAAG,MAAM,CAczF"}
@@ -0,0 +1,27 @@
1
+ // Shared AppleScript utilities for NotePlan MCP tools
2
+ import { execFileSync } from 'child_process';
3
+ export const APPLESCRIPT_TIMEOUT_MS = 15_000;
4
+ export const APP_NAME = 'NotePlan';
5
+ export function escapeAppleScript(str) {
6
+ return str
7
+ .replace(/\\/g, '\\\\')
8
+ .replace(/"/g, '\\"')
9
+ .replace(/[\x00-\x1f]/g, ' ');
10
+ }
11
+ export function runAppleScript(script, timeoutMs = APPLESCRIPT_TIMEOUT_MS) {
12
+ try {
13
+ return execFileSync('osascript', ['-e', script], {
14
+ encoding: 'utf-8',
15
+ stdio: ['pipe', 'pipe', 'pipe'],
16
+ timeout: timeoutMs,
17
+ }).trim();
18
+ }
19
+ catch (error) {
20
+ if (error.killed) {
21
+ throw new Error('AppleScript timed out');
22
+ }
23
+ const stderr = (error.stderr || '').trim();
24
+ throw new Error(stderr || error.message || 'AppleScript execution failed');
25
+ }
26
+ }
27
+ //# sourceMappingURL=applescript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applescript.js","sourceRoot":"","sources":["../../src/utils/applescript.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAC7C,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,OAAO,GAAG;SACP,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,SAAS,GAAG,sBAAsB;IAC/E,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;YAC/C,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,OAAO,EAAE,SAAS;SACnB,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,8BAA8B,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ type ConfirmationContext = {
2
+ tool: string;
3
+ target: string;
4
+ action: string;
5
+ };
6
+ type ConfirmationFailureReason = 'missing' | 'invalid' | 'expired' | 'mismatch';
7
+ export type ConfirmationValidationResult = {
8
+ ok: true;
9
+ } | {
10
+ ok: false;
11
+ reason: ConfirmationFailureReason;
12
+ };
13
+ export declare function issueConfirmationToken(context: ConfirmationContext, ttlMs?: number): {
14
+ confirmationToken: string;
15
+ confirmationExpiresAt: string;
16
+ };
17
+ export declare function validateAndConsumeConfirmationToken(token: unknown, context: ConfirmationContext): ConfirmationValidationResult;
18
+ export {};
19
+ //# sourceMappingURL=confirmation-tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmation-tokens.d.ts","sourceRoot":"","sources":["../../src/utils/confirmation-tokens.ts"],"names":[],"mappings":"AAIA,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAOF,KAAK,yBAAyB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAEhF,MAAM,MAAM,4BAA4B,GACpC;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GACZ;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,yBAAyB,CAAA;CAAE,CAAC;AAwBrD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,mBAAmB,EAC5B,KAAK,SAA8B,GAClC;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,qBAAqB,EAAE,MAAM,CAAA;CAAE,CAW9D;AAED,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,mBAAmB,GAC3B,4BAA4B,CA+B9B"}
@@ -0,0 +1,58 @@
1
+ import { randomUUID } from 'crypto';
2
+ const DEFAULT_CONFIRMATION_TTL_MS = 10 * 60 * 1000;
3
+ const confirmationStore = new Map();
4
+ function normalize(value) {
5
+ return value.trim().toLowerCase();
6
+ }
7
+ function normalizeContext(context) {
8
+ return {
9
+ tool: normalize(context.tool),
10
+ target: normalize(context.target),
11
+ action: normalize(context.action),
12
+ };
13
+ }
14
+ function cleanupExpired(nowMs) {
15
+ for (const [token, stored] of confirmationStore.entries()) {
16
+ if (stored.expiresAt <= nowMs) {
17
+ confirmationStore.delete(token);
18
+ }
19
+ }
20
+ }
21
+ export function issueConfirmationToken(context, ttlMs = DEFAULT_CONFIRMATION_TTL_MS) {
22
+ const token = randomUUID();
23
+ const expiresAtMs = Date.now() + ttlMs;
24
+ confirmationStore.set(token, {
25
+ context: normalizeContext(context),
26
+ expiresAt: expiresAtMs,
27
+ });
28
+ return {
29
+ confirmationToken: token,
30
+ confirmationExpiresAt: new Date(expiresAtMs).toISOString(),
31
+ };
32
+ }
33
+ export function validateAndConsumeConfirmationToken(token, context) {
34
+ if (typeof token !== 'string' || token.trim().length === 0) {
35
+ return { ok: false, reason: 'missing' };
36
+ }
37
+ const nowMs = Date.now();
38
+ cleanupExpired(nowMs);
39
+ const stored = confirmationStore.get(token);
40
+ if (!stored) {
41
+ return { ok: false, reason: 'invalid' };
42
+ }
43
+ if (stored.expiresAt <= nowMs) {
44
+ confirmationStore.delete(token);
45
+ return { ok: false, reason: 'expired' };
46
+ }
47
+ const expected = normalizeContext(context);
48
+ const matches = stored.context.tool === expected.tool &&
49
+ stored.context.target === expected.target &&
50
+ stored.context.action === expected.action;
51
+ if (!matches) {
52
+ confirmationStore.delete(token);
53
+ return { ok: false, reason: 'mismatch' };
54
+ }
55
+ confirmationStore.delete(token);
56
+ return { ok: true };
57
+ }
58
+ //# sourceMappingURL=confirmation-tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmation-tokens.js","sourceRoot":"","sources":["../../src/utils/confirmation-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,2BAA2B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAmBnD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA8B,CAAC;AAEhE,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC;AAED,SAAS,gBAAgB,CAAC,OAA4B;IACpD,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QAC7B,MAAM,EAAE,SAAS,CAAC,O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,CAAC;QACZ,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAC1C,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,OAAO,GACX,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI;QACrC,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;QACzC,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;IAE5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC3C,CAAC;IAED,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Parse flexible date strings like "today", "yesterday", "this week"
3
+ * Returns a Date object representing the start of the period
4
+ */
5
+ export declare function parseFlexibleDateFilter(input: string): Date | null;
6
+ /**
7
+ * Check if a date falls within the specified range
8
+ */
9
+ export declare function isDateInRange(date: Date | undefined, after?: Date | null, before?: Date | null): boolean;
10
+ /**
11
+ * Get the end date for a period filter (for "before" comparisons)
12
+ * For example, "this week" should include all of today
13
+ */
14
+ export declare function getFilterEndDate(input: string): Date | null;
15
+ //# sourceMappingURL=date-filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-filters.d.ts","sourceRoot":"","sources":["../../src/utils/date-filters.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAqDlE;AASD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,GAAG,SAAS,EACtB,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,EACnB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GACnB,OAAO,CAKT;AAcD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAiC3D"}
@@ -0,0 +1,129 @@
1
+ // Date filtering utilities for search
2
+ import { getFirstDayOfWeekCached } from '../noteplan/preferences.js';
3
+ /**
4
+ * Get the start of the week for a given date, respecting NotePlan's firstDayOfWeek setting
5
+ * @param date The reference date
6
+ * @param firstDayOfWeek 0 = Sunday, 1 = Monday, ..., 6 = Saturday
7
+ */
8
+ function getStartOfWeek(date, firstDayOfWeek) {
9
+ const day = date.getDay(); // 0 = Sunday, 1 = Monday, etc.
10
+ // Calculate days to subtract to get to the first day of the week
11
+ const daysToSubtract = (day - firstDayOfWeek + 7) % 7;
12
+ const weekStart = new Date(date);
13
+ weekStart.setDate(date.getDate() - daysToSubtract);
14
+ return startOfDay(weekStart);
15
+ }
16
+ /**
17
+ * Parse flexible date strings like "today", "yesterday", "this week"
18
+ * Returns a Date object representing the start of the period
19
+ */
20
+ export function parseFlexibleDateFilter(input) {
21
+ const lower = input.toLowerCase().trim();
22
+ const now = new Date();
23
+ switch (lower) {
24
+ case 'today':
25
+ return startOfDay(now);
26
+ case 'yesterday':
27
+ return startOfDay(new Date(now.getTime() - 24 * 60 * 60 * 1000));
28
+ case 'this week': {
29
+ const firstDayOfWeek = getFirstDayOfWeekCached();
30
+ return getStartOfWeek(now, firstDayOfWeek);
31
+ }
32
+ case 'last week': {
33
+ const firstDayOfWeek = getFirstDayOfWeekCached();
34
+ const thisWeekStart = getStartOfWeek(now, firstDayOfWeek);
35
+ const lastWeekStart = new Date(thisWeekStart);
36
+ lastWeekStart.setDate(lastWeekStart.getDate() - 7);
37
+ return lastWeekStart;
38
+ }
39
+ case 'this month':
40
+ return new Date(now.getFullYear(), now.getMonth(), 1);
41
+ case 'last month':
42
+ return new Date(now.getFullYear(), now.getMonth() - 1, 1);
43
+ case 'this year':
44
+ return new Date(now.getFullYear(), 0, 1);
45
+ case 'last year':
46
+ return new Date(now.getFullYear() - 1, 0, 1);
47
+ default:
48
+ // Try ISO date parse (YYYY-MM-DD)
49
+ const isoMatch = input.match(/^(\d{4})-(\d{2})-(\d{2})$/);
50
+ if (isoMatch) {
51
+ return new Date(parseInt(isoMatch[1]), parseInt(isoMatch[2]) - 1, parseInt(isoMatch[3]));
52
+ }
53
+ // Try YYYYMMDD format
54
+ const yyyymmdd = input.match(/^(\d{4})(\d{2})(\d{2})$/);
55
+ if (yyyymmdd) {
56
+ return new Date(parseInt(yyyymmdd[1]), parseInt(yyyymmdd[2]) - 1, parseInt(yyyymmdd[3]));
57
+ }
58
+ // Try general Date parse
59
+ const parsed = new Date(input);
60
+ return isNaN(parsed.getTime()) ? null : parsed;
61
+ }
62
+ }
63
+ /**
64
+ * Get the start of a day (midnight)
65
+ */
66
+ function startOfDay(date) {
67
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
68
+ }
69
+ /**
70
+ * Check if a date falls within the specified range
71
+ */
72
+ export function isDateInRange(date, after, before) {
73
+ if (!date)
74
+ return false;
75
+ if (after && date < after)
76
+ return false;
77
+ if (before && date > before)
78
+ return false;
79
+ return true;
80
+ }
81
+ /**
82
+ * Get the end of the week for a given date, respecting NotePlan's firstDayOfWeek setting
83
+ * @param date The reference date
84
+ * @param firstDayOfWeek 0 = Sunday, 1 = Monday, ..., 6 = Saturday
85
+ */
86
+ function getEndOfWeek(date, firstDayOfWeek) {
87
+ const weekStart = getStartOfWeek(date, firstDayOfWeek);
88
+ const weekEnd = new Date(weekStart);
89
+ weekEnd.setDate(weekStart.getDate() + 6); // Week is 7 days, end is start + 6
90
+ return endOfDay(weekEnd);
91
+ }
92
+ /**
93
+ * Get the end date for a period filter (for "before" comparisons)
94
+ * For example, "this week" should include all of today
95
+ */
96
+ export function getFilterEndDate(input) {
97
+ const lower = input.toLowerCase().trim();
98
+ const now = new Date();
99
+ switch (lower) {
100
+ case 'today':
101
+ return endOfDay(now);
102
+ case 'yesterday':
103
+ return endOfDay(new Date(now.getTime() - 24 * 60 * 60 * 1000));
104
+ case 'this week': {
105
+ const firstDayOfWeek = getFirstDayOfWeekCached();
106
+ return getEndOfWeek(now, firstDayOfWeek);
107
+ }
108
+ case 'last week': {
109
+ const firstDayOfWeek = getFirstDayOfWeekCached();
110
+ const thisWeekStart = getStartOfWeek(now, firstDayOfWeek);
111
+ const lastWeekStart = new Date(thisWeekStart);
112
+ lastWeekStart.setDate(lastWeekStart.getDate() - 7);
113
+ return getEndOfWeek(lastWeekStart, firstDayOfWeek);
114
+ }
115
+ case 'this month':
116
+ return new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
117
+ case 'last month':
118
+ return new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59, 999);
119
+ default:
120
+ return null;
121
+ }
122
+ }
123
+ /**
124
+ * Get the end of a day (23:59:59.999)
125
+ */
126
+ function endOfDay(date) {
127
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59, 999);
128
+ }
129
+ //# sourceMappingURL=date-filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-filters.js","sourceRoot":"","sources":["../../src/utils/date-filters.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAAU,EAAE,cAAsB;IACxD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,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+1,113 @@
1
+ /**
2
+ * Get today's date in YYYYMMDD format
3
+ */
4
+ export declare function getTodayDateString(): string;
5
+ /**
6
+ * Format a Date object to YYYYMMDD string
7
+ */
8
+ export declare function formatDateString(date: Date): string;
9
+ /**
10
+ * Parse YYYYMMDD string to Date object
11
+ */
12
+ export declare function parseDateString(dateStr: string): Date | null;
13
+ /**
14
+ * Get the calendar note filename for a date
15
+ * Returns path like Calendar/2024/20240115.md
16
+ */
17
+ export declare function getCalendarNotePath(dateStr: string): string;
18
+ /**
19
+ * Get the weekly note filename for a date
20
+ * Returns path like Calendar/2024/2024-W03.md
21
+ */
22
+ export declare function getWeeklyNotePath(date: Date): string;
23
+ /**
24
+ * Get ISO week number for a date
25
+ */
26
+ export declare function getWeekNumber(date: Date): number;
27
+ /**
28
+ * Get ISO week year for a date (can differ from calendar year at year boundaries)
29
+ * For example: Dec 30, 2024 is in Week 1 of 2025
30
+ */
31
+ export declare function getISOWeekYear(date: Date): number;
32
+ /**
33
+ * Get both ISO week number and year
34
+ */
35
+ export declare function getISOWeek(date: Date): {
36
+ week: number;
37
+ year: number;
38
+ };
39
+ /**
40
+ * Get week number respecting a custom first day of week
41
+ * @param date The date to get the week for
42
+ * @param firstDayOfWeek 0 = Sunday, 1 = Monday, ..., 6 = Saturday
43
+ * @returns Week number and year
44
+ *
45
+ * Week 1 is defined as the week containing January 1
46
+ */
47
+ export declare function getWeekWithFirstDay(date: Date, firstDayOfWeek: number): {
48
+ week: number;
49
+ year: number;
50
+ };
51
+ /**
52
+ * Get week number and year respecting NotePlan's firstDayOfWeek preference
53
+ */
54
+ export declare function getWeekRespectingPreference(date: Date): {
55
+ week: number;
56
+ year: number;
57
+ };
58
+ /**
59
+ * Parse a date input string that could be:
60
+ * - YYYYMMDD
61
+ * - YYYY-MM-DD
62
+ * - today
63
+ * - tomorrow
64
+ * - yesterday
65
+ */
66
+ export declare function parseFlexibleDate(input: string): string;
67
+ /**
68
+ * Format a date string for display
69
+ */
70
+ export declare function formatDateForDisplay(dateStr: string): string;
71
+ /**
72
+ * Check if a filename is a calendar note
73
+ */
74
+ export declare function isCalendarNoteFilename(filename: string): boolean;
75
+ /**
76
+ * Extract date from calendar note filename
77
+ */
78
+ export declare function extractDateFromFilename(filename: string): string | null;
79
+ /**
80
+ * Calendar note types
81
+ */
82
+ export type CalendarNoteType = 'daily' | 'weekly' | 'monthly' | 'quarterly' | 'yearly';
83
+ /**
84
+ * Get the type of calendar note from its filename
85
+ */
86
+ export declare function getCalendarNoteType(filename: string): CalendarNoteType | null;
87
+ /**
88
+ * Get the monthly note filename for a date
89
+ * Returns path like Calendar/2024/2024-01.md
90
+ */
91
+ export declare function getMonthlyNotePath(date: Date, hasYearSubfolders?: boolean): string;
92
+ /**
93
+ * Get the quarterly note filename for a date
94
+ * Returns path like Calendar/2024/2024-Q1.md
95
+ */
96
+ export declare function getQuarterlyNotePath(date: Date, hasYearSubfolders?: boolean): string;
97
+ /**
98
+ * Get the yearly note filename for a date
99
+ * Returns path like Calendar/2024/2024.md
100
+ */
101
+ export declare function getYearlyNotePath(date: Date, hasYearSubfolders?: boolean): string;
102
+ /**
103
+ * Get a date range for a period
104
+ */
105
+ export declare function getDateRange(period: 'today' | 'yesterday' | 'this-week' | 'last-week' | 'this-month' | 'last-month' | string, customStart?: string, customEnd?: string): {
106
+ start: Date;
107
+ end: Date;
108
+ };
109
+ /**
110
+ * Generate all dates in a range
111
+ */
112
+ export declare function getDatesInRange(start: Date, end: Date): Date[];
113
+ //# sourceMappingURL=date-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../../src/utils/date-utils.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAG3C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAKnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,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