@aniketbiswas/obsidian-mcp-server 1.0.0

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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +232 -0
  3. package/build/index.d.ts +26 -0
  4. package/build/index.d.ts.map +1 -0
  5. package/build/index.js +148 -0
  6. package/build/index.js.map +1 -0
  7. package/build/prompts/index.d.ts +33 -0
  8. package/build/prompts/index.d.ts.map +1 -0
  9. package/build/prompts/index.js +152 -0
  10. package/build/prompts/index.js.map +1 -0
  11. package/build/prompts/obsidian.d.ts +17 -0
  12. package/build/prompts/obsidian.d.ts.map +1 -0
  13. package/build/prompts/obsidian.js +305 -0
  14. package/build/prompts/obsidian.js.map +1 -0
  15. package/build/resources/index.d.ts +31 -0
  16. package/build/resources/index.d.ts.map +1 -0
  17. package/build/resources/index.js +111 -0
  18. package/build/resources/index.js.map +1 -0
  19. package/build/resources/obsidian.d.ts +19 -0
  20. package/build/resources/obsidian.d.ts.map +1 -0
  21. package/build/resources/obsidian.js +246 -0
  22. package/build/resources/obsidian.js.map +1 -0
  23. package/build/tools/_template.d.ts +23 -0
  24. package/build/tools/_template.d.ts.map +1 -0
  25. package/build/tools/_template.js +124 -0
  26. package/build/tools/_template.js.map +1 -0
  27. package/build/tools/calculator.d.ts +32 -0
  28. package/build/tools/calculator.d.ts.map +1 -0
  29. package/build/tools/calculator.js +130 -0
  30. package/build/tools/calculator.js.map +1 -0
  31. package/build/tools/daily-notes.d.ts +19 -0
  32. package/build/tools/daily-notes.d.ts.map +1 -0
  33. package/build/tools/daily-notes.js +469 -0
  34. package/build/tools/daily-notes.js.map +1 -0
  35. package/build/tools/greeting.d.ts +23 -0
  36. package/build/tools/greeting.d.ts.map +1 -0
  37. package/build/tools/greeting.js +111 -0
  38. package/build/tools/greeting.js.map +1 -0
  39. package/build/tools/index.d.ts +28 -0
  40. package/build/tools/index.d.ts.map +1 -0
  41. package/build/tools/index.js +46 -0
  42. package/build/tools/index.js.map +1 -0
  43. package/build/tools/links.d.ts +19 -0
  44. package/build/tools/links.d.ts.map +1 -0
  45. package/build/tools/links.js +467 -0
  46. package/build/tools/links.js.map +1 -0
  47. package/build/tools/metadata.d.ts +18 -0
  48. package/build/tools/metadata.d.ts.map +1 -0
  49. package/build/tools/metadata.js +447 -0
  50. package/build/tools/metadata.js.map +1 -0
  51. package/build/tools/navigation.d.ts +19 -0
  52. package/build/tools/navigation.d.ts.map +1 -0
  53. package/build/tools/navigation.js +378 -0
  54. package/build/tools/navigation.js.map +1 -0
  55. package/build/tools/notes.d.ts +19 -0
  56. package/build/tools/notes.d.ts.map +1 -0
  57. package/build/tools/notes.js +622 -0
  58. package/build/tools/notes.js.map +1 -0
  59. package/build/tools/search.d.ts +19 -0
  60. package/build/tools/search.d.ts.map +1 -0
  61. package/build/tools/search.js +418 -0
  62. package/build/tools/search.js.map +1 -0
  63. package/build/tools/templates.d.ts +18 -0
  64. package/build/tools/templates.d.ts.map +1 -0
  65. package/build/tools/templates.js +581 -0
  66. package/build/tools/templates.js.map +1 -0
  67. package/build/tools/vault.d.ts +19 -0
  68. package/build/tools/vault.d.ts.map +1 -0
  69. package/build/tools/vault.js +403 -0
  70. package/build/tools/vault.js.map +1 -0
  71. package/build/types/index.d.ts +11 -0
  72. package/build/types/index.d.ts.map +1 -0
  73. package/build/types/index.js +11 -0
  74. package/build/types/index.js.map +1 -0
  75. package/build/types/obsidian.d.ts +329 -0
  76. package/build/types/obsidian.d.ts.map +1 -0
  77. package/build/types/obsidian.js +38 -0
  78. package/build/types/obsidian.js.map +1 -0
  79. package/build/utils/client.d.ts +201 -0
  80. package/build/utils/client.d.ts.map +1 -0
  81. package/build/utils/client.js +656 -0
  82. package/build/utils/client.js.map +1 -0
  83. package/build/utils/config.d.ts +43 -0
  84. package/build/utils/config.d.ts.map +1 -0
  85. package/build/utils/config.js +117 -0
  86. package/build/utils/config.js.map +1 -0
  87. package/build/utils/frontmatter.d.ts +90 -0
  88. package/build/utils/frontmatter.d.ts.map +1 -0
  89. package/build/utils/frontmatter.js +306 -0
  90. package/build/utils/frontmatter.js.map +1 -0
  91. package/build/utils/index.d.ts +13 -0
  92. package/build/utils/index.d.ts.map +1 -0
  93. package/build/utils/index.js +13 -0
  94. package/build/utils/index.js.map +1 -0
  95. package/build/utils/markdown.d.ts +134 -0
  96. package/build/utils/markdown.d.ts.map +1 -0
  97. package/build/utils/markdown.js +330 -0
  98. package/build/utils/markdown.js.map +1 -0
  99. package/package.json +60 -0
@@ -0,0 +1,329 @@
1
+ /**
2
+ * ============================================================================
3
+ * OBSIDIAN MCP - Type Definitions
4
+ * ============================================================================
5
+ *
6
+ * Comprehensive TypeScript type definitions for the Obsidian Local REST API
7
+ * and internal MCP server data structures.
8
+ *
9
+ * These types ensure type safety throughout the codebase and provide
10
+ * excellent IDE support with autocompletion and error checking.
11
+ * ============================================================================
12
+ */
13
+ /**
14
+ * Configuration for connecting to Obsidian's Local REST API.
15
+ * These values can be set via environment variables.
16
+ */
17
+ export interface ObsidianConfig {
18
+ /** API key from Obsidian Local REST API plugin settings */
19
+ apiKey: string;
20
+ /** Host where Obsidian is running (default: 127.0.0.1) */
21
+ host: string;
22
+ /** Port for the REST API (default: 27124) */
23
+ port: number;
24
+ /** Whether to use HTTPS (default: true) */
25
+ secure: boolean;
26
+ /** Request timeout in milliseconds (default: 30000) */
27
+ timeout: number;
28
+ /** Whether to verify SSL certificates (default: false for self-signed) */
29
+ verifySsl: boolean;
30
+ }
31
+ /**
32
+ * Default configuration values
33
+ */
34
+ export declare const DEFAULT_CONFIG: Omit<ObsidianConfig, "apiKey">;
35
+ /**
36
+ * Basic server status information returned by GET /
37
+ */
38
+ export interface ServerStatus {
39
+ status: string;
40
+ versions: {
41
+ obsidian: string;
42
+ self: string;
43
+ };
44
+ service: string;
45
+ authenticated: boolean;
46
+ }
47
+ /**
48
+ * Represents a file or directory in the vault
49
+ */
50
+ export interface VaultItem {
51
+ /** File or directory name */
52
+ name: string;
53
+ /** Full path from vault root */
54
+ path: string;
55
+ /** Type of item */
56
+ type: "file" | "directory";
57
+ /** File extension (for files only) */
58
+ extension?: string;
59
+ /** File size in bytes (for files only) */
60
+ size?: number;
61
+ /** Creation timestamp */
62
+ ctime?: number;
63
+ /** Modification timestamp */
64
+ mtime?: number;
65
+ }
66
+ /**
67
+ * Directory listing response
68
+ */
69
+ export interface DirectoryListing {
70
+ files: string[];
71
+ }
72
+ /**
73
+ * Note content with optional metadata
74
+ */
75
+ export interface NoteContent {
76
+ /** Raw markdown content */
77
+ content: string;
78
+ /** File path */
79
+ path: string;
80
+ /** Parsed frontmatter (if any) */
81
+ frontmatter?: Record<string, unknown>;
82
+ /** Content without frontmatter */
83
+ body?: string;
84
+ }
85
+ /**
86
+ * Search result from the vault
87
+ */
88
+ export interface SearchResult {
89
+ /** Path to the matching file */
90
+ filename: string;
91
+ /** Relevance score */
92
+ score?: number;
93
+ /** Matching content snippets */
94
+ matches?: SearchMatch[];
95
+ }
96
+ /**
97
+ * Individual search match within a file
98
+ */
99
+ export interface SearchMatch {
100
+ /** Match context/snippet */
101
+ match: string;
102
+ /** Position information */
103
+ position?: {
104
+ start: number;
105
+ end: number;
106
+ };
107
+ }
108
+ /**
109
+ * Response from POST /search
110
+ */
111
+ export interface SearchResponse {
112
+ results: SearchResult[];
113
+ }
114
+ /**
115
+ * Available command in Obsidian
116
+ */
117
+ export interface ObsidianCommand {
118
+ /** Unique command ID */
119
+ id: string;
120
+ /** Human-readable name */
121
+ name: string;
122
+ }
123
+ /**
124
+ * Commands list response
125
+ */
126
+ export interface CommandsResponse {
127
+ commands: ObsidianCommand[];
128
+ }
129
+ /**
130
+ * Supported periodic note periods
131
+ */
132
+ export type PeriodicNotePeriod = "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
133
+ /**
134
+ * Periodic note date specification
135
+ */
136
+ export interface PeriodicNoteDate {
137
+ year: number;
138
+ month: number;
139
+ day: number;
140
+ }
141
+ /**
142
+ * Supported patch operations for note content
143
+ */
144
+ export type PatchOperation = "append" | "prepend" | "replace" | "insert-after" | "insert-before" | "insert-under-heading";
145
+ /**
146
+ * Options for patching note content
147
+ */
148
+ export interface PatchOptions {
149
+ /** The operation to perform */
150
+ operation: PatchOperation;
151
+ /** Content to insert/append/prepend */
152
+ content: string;
153
+ /** Target heading (for heading-based operations) */
154
+ heading?: string;
155
+ /** Target text to find (for insert-before/after operations) */
156
+ targetText?: string;
157
+ /** Line number for line-based operations */
158
+ lineNumber?: number;
159
+ /** Whether to create the file if it doesn't exist */
160
+ createIfNotExists?: boolean;
161
+ }
162
+ /**
163
+ * Standard frontmatter properties
164
+ */
165
+ export interface StandardFrontmatter {
166
+ /** Note title */
167
+ title?: string;
168
+ /** Array of tags */
169
+ tags?: string[];
170
+ /** Aliases for the note */
171
+ aliases?: string[];
172
+ /** Creation date */
173
+ created?: string;
174
+ /** Last modified date */
175
+ modified?: string;
176
+ /** CSS classes to apply */
177
+ cssclass?: string;
178
+ /** Whether to publish the note */
179
+ publish?: boolean;
180
+ /** Custom properties */
181
+ [key: string]: unknown;
182
+ }
183
+ /**
184
+ * Represents a link between notes
185
+ */
186
+ export interface NoteLink {
187
+ /** Source file path */
188
+ source: string;
189
+ /** Target file path or link text */
190
+ target: string;
191
+ /** Display text of the link */
192
+ displayText?: string;
193
+ /** Whether this is an embed (![[link]]) */
194
+ isEmbed?: boolean;
195
+ /** Link type */
196
+ type: "internal" | "external" | "tag";
197
+ }
198
+ /**
199
+ * Backlink information
200
+ */
201
+ export interface Backlink {
202
+ /** Path of the file containing the backlink */
203
+ sourcePath: string;
204
+ /** Context around the link */
205
+ context?: string;
206
+ /** Line number where the link appears */
207
+ lineNumber?: number;
208
+ }
209
+ /**
210
+ * Template for creating new notes
211
+ */
212
+ export interface NoteTemplate {
213
+ /** Template name */
214
+ name: string;
215
+ /** Template content */
216
+ content: string;
217
+ /** Default frontmatter */
218
+ frontmatter?: StandardFrontmatter;
219
+ /** Folder to create the note in */
220
+ folder?: string;
221
+ }
222
+ /**
223
+ * Error response from the API
224
+ */
225
+ export interface ApiError {
226
+ /** Error code */
227
+ code: string;
228
+ /** Error message */
229
+ message: string;
230
+ /** HTTP status code */
231
+ status: number;
232
+ /** Additional error details */
233
+ details?: Record<string, unknown>;
234
+ }
235
+ /**
236
+ * Custom error class for Obsidian API errors
237
+ */
238
+ export declare class ObsidianApiError extends Error {
239
+ readonly code: string;
240
+ readonly status: number;
241
+ readonly details?: Record<string, unknown>;
242
+ constructor(error: ApiError);
243
+ }
244
+ /**
245
+ * Standard success response structure
246
+ */
247
+ export interface ToolSuccessResponse {
248
+ success: true;
249
+ message: string;
250
+ data?: unknown;
251
+ }
252
+ /**
253
+ * Standard error response structure
254
+ */
255
+ export interface ToolErrorResponse {
256
+ success: false;
257
+ error: string;
258
+ code?: string;
259
+ }
260
+ /**
261
+ * Combined tool response type
262
+ */
263
+ export type ToolResponse = ToolSuccessResponse | ToolErrorResponse;
264
+ /**
265
+ * Options for listing vault contents
266
+ */
267
+ export interface ListVaultOptions {
268
+ /** Directory path to list (default: root) */
269
+ path?: string;
270
+ /** Whether to include subdirectories recursively */
271
+ recursive?: boolean;
272
+ /** File extensions to filter by */
273
+ extensions?: string[];
274
+ /** Maximum depth for recursive listing */
275
+ maxDepth?: number;
276
+ }
277
+ /**
278
+ * Options for creating a new note
279
+ */
280
+ export interface CreateNoteOptions {
281
+ /** File path for the note */
282
+ path: string;
283
+ /** Note content */
284
+ content: string;
285
+ /** Whether to overwrite if exists */
286
+ overwrite?: boolean;
287
+ /** Frontmatter to include */
288
+ frontmatter?: StandardFrontmatter;
289
+ /** Whether to create parent directories */
290
+ createFolders?: boolean;
291
+ }
292
+ /**
293
+ * Options for reading a note
294
+ */
295
+ export interface ReadNoteOptions {
296
+ /** File path */
297
+ path: string;
298
+ /** Whether to parse frontmatter */
299
+ parseFrontmatter?: boolean;
300
+ /** Whether to include file stats */
301
+ includeStats?: boolean;
302
+ }
303
+ /**
304
+ * Options for updating a note
305
+ */
306
+ export interface UpdateNoteOptions {
307
+ /** File path */
308
+ path: string;
309
+ /** New content (replaces entire file) */
310
+ content?: string;
311
+ /** Patch options for partial updates */
312
+ patch?: PatchOptions;
313
+ }
314
+ /**
315
+ * Options for searching the vault
316
+ */
317
+ export interface SearchOptions {
318
+ /** Search query */
319
+ query: string;
320
+ /** Folder to search in */
321
+ folder?: string;
322
+ /** File extensions to include */
323
+ extensions?: string[];
324
+ /** Maximum number of results */
325
+ limit?: number;
326
+ /** Whether to include content snippets */
327
+ includeSnippets?: boolean;
328
+ }
329
+ //# sourceMappingURL=obsidian.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obsidian.d.ts","sourceRoot":"","sources":["../../src/types/obsidian.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,EAAE,OAAO,CAAC;IAChB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,CAMzD,CAAC;AAMF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,I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C,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * ============================================================================
3
+ * OBSIDIAN MCP - Type Definitions
4
+ * ============================================================================
5
+ *
6
+ * Comprehensive TypeScript type definitions for the Obsidian Local REST API
7
+ * and internal MCP server data structures.
8
+ *
9
+ * These types ensure type safety throughout the codebase and provide
10
+ * excellent IDE support with autocompletion and error checking.
11
+ * ============================================================================
12
+ */
13
+ /**
14
+ * Default configuration values
15
+ */
16
+ export const DEFAULT_CONFIG = {
17
+ host: "127.0.0.1",
18
+ port: 27124,
19
+ secure: true,
20
+ timeout: 30000,
21
+ verifySsl: false,
22
+ };
23
+ /**
24
+ * Custom error class for Obsidian API errors
25
+ */
26
+ export class ObsidianApiError extends Error {
27
+ code;
28
+ status;
29
+ details;
30
+ constructor(error) {
31
+ super(error.message);
32
+ this.name = "ObsidianApiError";
33
+ this.code = error.code;
34
+ this.status = error.status;
35
+ this.details = error.details;
36
+ }
37
+ }
38
+ //# sourceMappingURL=obsidian.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obsidian.js","sourceRoot":"","sources":["../../src/types/obsidian.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAyBH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAmC;IAC5D,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,KAAK;CACjB,CAAC;AA8PF;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzB,IAAI,CAAS;IACb,MAAM,CAAS;IACf,OAAO,CAA2B;IAElD,YAAY,KAAe;QACzB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * ============================================================================
3
+ * OBSIDIAN MCP - Obsidian REST API Client
4
+ * ============================================================================
5
+ *
6
+ * A robust HTTP client for interacting with Obsidian's Local REST API.
7
+ * Features:
8
+ * - Automatic authentication
9
+ * - Error handling with detailed error messages
10
+ * - Support for all REST API endpoints
11
+ * - Request timeout handling
12
+ * - SSL/TLS configuration for self-signed certificates
13
+ * ============================================================================
14
+ */
15
+ import { ObsidianConfig, ServerStatus, VaultItem, NoteContent, SearchResult, ObsidianCommand, PatchOptions, PeriodicNotePeriod, PeriodicNoteDate, StandardFrontmatter } from "../types/obsidian.js";
16
+ /**
17
+ * Obsidian REST API Client
18
+ *
19
+ * Provides a type-safe interface for all Obsidian Local REST API operations.
20
+ */
21
+ export declare class ObsidianClient {
22
+ private readonly config;
23
+ private readonly baseUrl;
24
+ private readonly agent;
25
+ constructor(config: ObsidianConfig);
26
+ /**
27
+ * Get server status and version information.
28
+ */
29
+ getServerStatus(): Promise<ServerStatus>;
30
+ /**
31
+ * Check if the server is reachable and authenticated.
32
+ */
33
+ healthCheck(): Promise<boolean>;
34
+ /**
35
+ * Get the list of available commands in Obsidian.
36
+ */
37
+ getCommands(): Promise<ObsidianCommand[]>;
38
+ /**
39
+ * Execute a command in Obsidian.
40
+ * @param commandId - The ID of the command to execute
41
+ */
42
+ executeCommand(commandId: string): Promise<void>;
43
+ /**
44
+ * List files in the vault root or a specific directory.
45
+ * @param path - Optional directory path (relative to vault root)
46
+ */
47
+ listDirectory(path?: string): Promise<string[]>;
48
+ /**
49
+ * List all files in the vault recursively.
50
+ * @param basePath - Starting path for the listing
51
+ * @param maxDepth - Maximum recursion depth (default: 10)
52
+ */
53
+ listAllFiles(basePath?: string, maxDepth?: number): Promise<VaultItem[]>;
54
+ /**
55
+ * Recursive helper for listing files.
56
+ */
57
+ private listFilesRecursive;
58
+ /**
59
+ * Get the content of a file from the vault.
60
+ * @param path - File path relative to vault root
61
+ */
62
+ getFile(path: string): Promise<string>;
63
+ /**
64
+ * Get a note with parsed frontmatter.
65
+ * @param path - File path relative to vault root
66
+ */
67
+ getNote(path: string): Promise<NoteContent>;
68
+ /**
69
+ * Create or replace a file in the vault.
70
+ * @param path - File path relative to vault root
71
+ * @param content - File content
72
+ */
73
+ putFile(path: string, content: string): Promise<void>;
74
+ /**
75
+ * Create a note with frontmatter.
76
+ * @param path - File path relative to vault root
77
+ * @param content - Note content (without frontmatter)
78
+ * @param frontmatter - Frontmatter properties
79
+ */
80
+ createNote(path: string, content: string, frontmatter?: StandardFrontmatter): Promise<void>;
81
+ /**
82
+ * Append content to a file.
83
+ * @param path - File path relative to vault root
84
+ * @param content - Content to append
85
+ */
86
+ appendToFile(path: string, content: string): Promise<void>;
87
+ /**
88
+ * Patch a file with specific operations.
89
+ * @param path - File path relative to vault root
90
+ * @param content - Content for the patch operation
91
+ * @param options - Patch operation options
92
+ */
93
+ patchFile(path: string, content: string, options?: Partial<PatchOptions>): Promise<void>;
94
+ /**
95
+ * Delete a file from the vault.
96
+ * @param path - File path relative to vault root
97
+ */
98
+ deleteFile(path: string): Promise<void>;
99
+ /**
100
+ * Get the content of the currently active file in Obsidian.
101
+ */
102
+ getActiveFile(): Promise<NoteContent | null>;
103
+ /**
104
+ * Update the content of the currently active file.
105
+ * @param content - New content for the file
106
+ */
107
+ updateActiveFile(content: string): Promise<void>;
108
+ /**
109
+ * Append content to the currently active file.
110
+ * @param content - Content to append
111
+ */
112
+ appendToActiveFile(content: string): Promise<void>;
113
+ /**
114
+ * Patch the currently active file.
115
+ * @param content - Content for the patch operation
116
+ * @param options - Patch options
117
+ */
118
+ patchActiveFile(content: string, options?: Partial<PatchOptions>): Promise<void>;
119
+ /**
120
+ * Delete the currently active file.
121
+ */
122
+ deleteActiveFile(): Promise<void>;
123
+ /**
124
+ * Open a file in the Obsidian UI.
125
+ * @param path - File path relative to vault root
126
+ * @param newLeaf - Whether to open in a new pane
127
+ */
128
+ openFile(path: string, newLeaf?: boolean): Promise<void>;
129
+ /**
130
+ * Search the vault using Obsidian's query syntax.
131
+ * @param query - Search query (supports Obsidian search syntax)
132
+ */
133
+ search(query: string): Promise<SearchResult[]>;
134
+ /**
135
+ * Simple text search across the vault.
136
+ * @param query - Plain text to search for
137
+ */
138
+ simpleSearch(query: string): Promise<SearchResult[]>;
139
+ /**
140
+ * Get the current periodic note for a given period.
141
+ * @param period - The period type (daily, weekly, monthly, quarterly, yearly)
142
+ */
143
+ getCurrentPeriodicNote(period: PeriodicNotePeriod): Promise<NoteContent | null>;
144
+ /**
145
+ * Get a periodic note for a specific date.
146
+ * @param period - The period type
147
+ * @param date - The specific date
148
+ */
149
+ getPeriodicNote(period: PeriodicNotePeriod, date: PeriodicNoteDate): Promise<NoteContent | null>;
150
+ /**
151
+ * Append content to the current periodic note.
152
+ * @param period - The period type
153
+ * @param content - Content to append
154
+ */
155
+ appendToPeriodicNote(period: PeriodicNotePeriod, content: string): Promise<void>;
156
+ /**
157
+ * Append content to a periodic note for a specific date.
158
+ * @param period - The period type
159
+ * @param date - The specific date
160
+ * @param content - Content to append
161
+ */
162
+ appendToPeriodicNoteByDate(period: PeriodicNotePeriod, date: PeriodicNoteDate, content: string): Promise<void>;
163
+ /**
164
+ * Update the content of the current periodic note.
165
+ * @param period - The period type
166
+ * @param content - New content
167
+ */
168
+ updatePeriodicNote(period: PeriodicNotePeriod, content: string): Promise<void>;
169
+ /**
170
+ * Patch the current periodic note.
171
+ * @param period - The period type
172
+ * @param content - Patch content
173
+ * @param options - Patch options
174
+ */
175
+ patchPeriodicNote(period: PeriodicNotePeriod, content: string, options?: Partial<PatchOptions>): Promise<void>;
176
+ /**
177
+ * Delete the current periodic note.
178
+ * @param period - The period type
179
+ */
180
+ deletePeriodicNote(period: PeriodicNotePeriod): Promise<void>;
181
+ /**
182
+ * Make an HTTP request to the Obsidian API.
183
+ */
184
+ private request;
185
+ }
186
+ /**
187
+ * Get or create the singleton Obsidian client instance.
188
+ * @param config - Configuration (only used on first call)
189
+ */
190
+ export declare function getClient(config: ObsidianConfig): ObsidianClient;
191
+ /**
192
+ * Create a new Obsidian client instance.
193
+ * @param config - Configuration for the client
194
+ */
195
+ export declare function createClient(config: ObsidianConfig): ObsidianClient;
196
+ /**
197
+ * Reset the singleton client instance.
198
+ * Useful for testing or reconnecting with different config.
199
+ */
200
+ export declare function resetClient(): void;
201
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/utils/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EACL,cAAc,EACd,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAEhB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AA8B9B;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;gBAErC,MAAM,EAAE,cAAc;IAkBlC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;IAQ9C;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAA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